sandbox: implement reset

Up to now the sandbox would shutdown upon a cold reset request. Instead it
should be reset.

In our coding we use static variables like LIST_HEAD(efi_obj_list). A reset
can occur at any time, e.g. via an UEFI binary calling the reset service.
The only safe way to return to an initial state is to relaunch the U-Boot
binary.

The reset implementation uses execv() to relaunch U-Boot.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Heinrich Schuchardt
2020-10-27 20:29:25 +01:00
committed by Simon Glass
parent c0b19f25a1
commit 329dccc067
6 changed files with 61 additions and 0 deletions

View File

@@ -355,4 +355,19 @@ int os_read_file(const char *name, void **bufp, int *sizep);
*/
void *os_find_text_base(void);
/**
* os_relaunch() - restart the sandbox
*
* This functions is used to implement the cold reboot of the sand box.
* @argv[0] specifies the binary that is started while the calling process
* stops immediately. If the new binary cannot be started, the process is
* terminated and 1 is set as shell return code.
*
* The PID of the process stays the same. All file descriptors that have not
* been opened with O_CLOEXEC stay open including stdin, stdout, stderr.
*
* @argv: NULL terminated list of command line parameters
*/
void os_relaunch(char *argv[]);
#endif