Skip to contentSkip to conversation

sandbox: fix sandbox_reset()

PATCH New Heinrich Schuchardt 3 participants 4 messages May 12, 2021 – Jul 4, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sandbox: fix sandbox_reset()

state_uninit() and dm_uninit() are mutually exclusive:

state_uninit() prints via drivers. So it cannot be executed after dm_uninit().

dm_uninit() requires memory. So it cannot be executed after state_uninit() which releases all memory.

Just skip dm_uninit() when resetting the sandbox. We will wake up in a new process and allocate new memory. So this cleanup is not required. We don't do it in sandbox_exit() either.

This avoids a segmentation error when efi_reset_system_boottime() is invoked by a UEFI application.

---
 arch/sandbox/cpu/start.c | 3 ---
 1 file changed, 3 deletions(-)
arch/sandbox/cpu/start.c +0 -3
index e87365e800..4ffd97ccbc 100644
@@ -425,9 +425,6 @@ void sandbox_reset(void)
 	if (state_uninit())
 		os_exit(2);
 
-	if (dm_uninit())
-		os_exit(2);
-
 	/* Restart U-Boot */
 	os_relaunch(os_argv);
 }

--
2.30.2

#1 lore raw

PATCH 1/1 sandbox: fix sandbox_reset()

Quoted 8 lines · Heinrich Schuchardt

state_uninit() and dm_uninit() are mutually exclusive:

state_uninit() prints via drivers. So it cannot be executed after dm_uninit().

dm_uninit() requires memory. So it cannot be executed after state_uninit() which releases all memory.

Quoted 6 lines

Just skip dm_uninit() when resetting the sandbox. We will wake up in a new process and allocate new memory. So this cleanup is not required. We don't do it in sandbox_exit() either.

This avoids a segmentation error when efi_reset_system_boottime() is invoked by a UEFI application.

Hi Heinrich,

Thanks for fixing this!

Before, I was hitting the following segfault with the sandbox under qemu arm64 when running the UEFI SCT:

Boot services test: ExitBootServices_Conf

Iterations: 1/1

System will cold reset after 2 second and test will be resumed after reboot.resetting ... Writing sandbox state
qemu: uncaught target signal 11 (Segmentation fault) - core dumped

With your patch I do not hit this segfault anymore.

FWIW, feel free to add (or not):

Best regards,
Vincent.

Quoted 23 lines
---
 arch/sandbox/cpu/start.c | 3 ---
 1 file changed, 3 deletions(-)
arch/sandbox/cpu/start.c +0 -4
index e87365e800..4ffd97ccbc 100644
@@ -425,9 +425,6 @@ void sandbox_reset(void)
 	if (state_uninit())
 		os_exit(2);
 
-	if (dm_uninit())
-		os_exit(2);
-
 	/* Restart U-Boot */
 	os_relaunch(os_argv);
 }
--

2.30.2

#2 lore raw

PATCH 1/1 sandbox: fix sandbox_reset()

In reply to Heinrich Schuchardt
Quoted 13 lines · Heinrich Schuchardt

state_uninit() and dm_uninit() are mutually exclusive:

state_uninit() prints via drivers. So it cannot be executed after dm_uninit().

dm_uninit() requires memory. So it cannot be executed after state_uninit() which releases all memory.

Just skip dm_uninit() when resetting the sandbox. We will wake up in a new process and allocate new memory. So this cleanup is not required. We don't do it in sandbox_exit() either.

Quoted 7 lines

This avoids a segmentation error when efi_reset_system_boottime() is invoked by a UEFI application.

---
 arch/sandbox/cpu/start.c | 3 ---
 1 file changed, 3 deletions(-)
Reviewed-by on v1 1/1
#3 lore raw
Quoted 13 lines · Heinrich Schuchardt

state_uninit() and dm_uninit() are mutually exclusive:

state_uninit() prints via drivers. So it cannot be executed after dm_uninit().

dm_uninit() requires memory. So it cannot be executed after state_uninit() which releases all memory.

Just skip dm_uninit() when resetting the sandbox. We will wake up in a new process and allocate new memory. So this cleanup is not required. We don't do it in sandbox_exit() either.

Quoted 7 lines

This avoids a segmentation error when efi_reset_system_boottime() is invoked by a UEFI application.

---
 arch/sandbox/cpu/start.c | 3 ---
 1 file changed, 3 deletions(-)

Applied to u-boot-dm/next, thanks!