public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: sjg@chromium.org, xypron.glpk@gmx.de, u-boot@lists.denx.de
Cc: Pavel Skripkin <paskripkin@gmail.com>
Subject: [PATCH] sandbox: disable tracing before unmapping RAM
Date: Wed, 12 Apr 2023 21:55:44 +0300	[thread overview]
Message-ID: <20230412185544.150241-1-paskripkin@gmail.com> (raw)

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>
---
 arch/sandbox/cpu/state.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index 69da378ab5..d8d5da25b1 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -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,9 @@ int state_uninit(void)
 	if (state->jumped_fname)
 		os_unlink(state->jumped_fname);
 
+	/* Disable tracing before unmapping RAM */
+	trace_set_enabled(0);
+
 	os_free(state->state_fdt);
 	os_free(state->ram_buf);
 	memset(state, '\0', sizeof(*state));
-- 
2.39.2


             reply	other threads:[~2023-04-13 14:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12 18:55 Pavel Skripkin [this message]
2023-04-19  1:45 ` [PATCH] sandbox: disable tracing before unmapping RAM Simon Glass
2023-04-25 13:43   ` Pavel Skripkin
2023-04-25 13:59     ` Tom Rini
2023-04-25 14:00       ` Pavel Skripkin
2023-04-28 19:20         ` Simon Glass
2023-04-28 19:21           ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230412185544.150241-1-paskripkin@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox