]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox: disable tracing before unmapping RAM
authorPavel Skripkin <paskripkin@gmail.com>
Wed, 12 Apr 2023 18:55:44 +0000 (21:55 +0300)
committerSimon Glass <sjg@chromium.org>
Fri, 28 Apr 2023 17:47:01 +0000 (11:47 -0600)
Currently doing 'reset' command in sandbox with tracing enabled causes
SIGSEV

```
Hit any key to stop autoboot:  0
=>
=>
=> reset
resetting ...
Segmentation fault (core dumped)

```

Tracing callback uses RAM buffer for storing tracing reports, but
state_uninit() function unmaps whole RAM, which causes SIGSEV on umapped
memory inside tracing subsystem.

Fix it by disabling tracing before unmapping memory

Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Add missing check for CONFIG_TRACE:
Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/cpu/state.c

index 69da378ab59ba8dd9dc2aa67b83e5dc3918c9599..d67834988fd4127aff47c20d682210ebaaa7c24c 100644 (file)
@@ -10,6 +10,7 @@
 #include <fdtdec.h>
 #include <log.h>
 #include <os.h>
+#include <trace.h>
 #include <asm/malloc.h>
 #include <asm/state.h>
 #include <asm/test.h>
@@ -525,6 +526,10 @@ int state_uninit(void)
        if (state->jumped_fname)
                os_unlink(state->jumped_fname);
 
+       /* Disable tracing before unmapping RAM */
+       if (IS_ENABLED(CONFIG_TRACE))
+               trace_set_enabled(0);
+
        os_free(state->state_fdt);
        os_free(state->ram_buf);
        memset(state, '\0', sizeof(*state));