All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] sandbox: fix sandbox_reset()
@ 2021-05-12 16:38 Heinrich Schuchardt
  2021-05-12 17:53 ` Vincent Stehlé
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2021-05-12 16:38 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 arch/sandbox/cpu/start.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index e87365e800..4ffd97ccbc 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 1/1] sandbox: fix sandbox_reset()
  2021-05-12 16:38 [PATCH 1/1] sandbox: fix sandbox_reset() Heinrich Schuchardt
@ 2021-05-12 17:53 ` Vincent Stehlé
  2021-05-15 15:20 ` Simon Glass
  2021-07-04 20:15 ` Simon Glass
  2 siblings, 0 replies; 4+ messages in thread
From: Vincent Stehlé @ 2021-05-12 17:53 UTC (permalink / raw)
  To: u-boot

On Wed, May 12, 2021 at 06:38:51PM +0200, Heinrich Schuchardt wrote:
> 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.

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):

  Tested-by: Vincent Stehl? <vincent.stehle@arm.com>

Best regards,
Vincent.

> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  arch/sandbox/cpu/start.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
> index e87365e800..4ffd97ccbc 100644
> --- a/arch/sandbox/cpu/start.c
> +++ b/arch/sandbox/cpu/start.c
> @@ -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
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] sandbox: fix sandbox_reset()
  2021-05-12 16:38 [PATCH 1/1] sandbox: fix sandbox_reset() Heinrich Schuchardt
  2021-05-12 17:53 ` Vincent Stehlé
@ 2021-05-15 15:20 ` Simon Glass
  2021-07-04 20:15 ` Simon Glass
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2021-05-15 15:20 UTC (permalink / raw)
  To: u-boot

On Wed, 12 May 2021 at 10:39, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> 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.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  arch/sandbox/cpu/start.c | 3 ---
>  1 file changed, 3 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] sandbox: fix sandbox_reset()
  2021-05-12 16:38 [PATCH 1/1] sandbox: fix sandbox_reset() Heinrich Schuchardt
  2021-05-12 17:53 ` Vincent Stehlé
  2021-05-15 15:20 ` Simon Glass
@ 2021-07-04 20:15 ` Simon Glass
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2021-07-04 20:15 UTC (permalink / raw)
  To: Simon Glass
  Cc: Patrick Delaunay, U-Boot Mailing List, Vincent Stehlé,
	Heinrich Schuchardt

On Wed, 12 May 2021 at 10:39, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> 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.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  arch/sandbox/cpu/start.c | 3 ---
>  1 file changed, 3 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-04 20:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12 16:38 [PATCH 1/1] sandbox: fix sandbox_reset() Heinrich Schuchardt
2021-05-12 17:53 ` Vincent Stehlé
2021-05-15 15:20 ` Simon Glass
2021-07-04 20:15 ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.