Skip to contentSkip to conversation

sandbox: disable tracing before unmapping RAM

PATCH In review Pavel Skripkin 3 participants 7 messages Apr 13, 2023 – Apr 28, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sandbox: disable tracing before unmapping RAM

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

---
 arch/sandbox/cpu/state.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/sandbox/cpu/state.c +4 -0
index 69da378ab5..d8d5da25b1 100644
@@ -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));
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Pavel Skripkin

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.

Quoted 6 lines

Fix it by disabling tracing before unmapping memory

---
 arch/sandbox/cpu/state.c | 4 ++++
 1 file changed, 4 insertions(+)
#2 lore raw

Hi Simon,

Simon Glass <[email protected]> says:

Quoted 19 lines · Pavel Skripkin
Quoted 18 lines

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.

Quoted 8 lines
Quoted 6 lines

Fix it by disabling tracing before unmapping memory

---
 arch/sandbox/cpu/state.c | 4 ++++
 1 file changed, 4 insertions(+)

Thank you for review!

+Tom, I guess?

@Tom, could you, please, pick following patch?

https://lists.denx.de/pipermail/u-boot/2023-April/515192.html

With regards,
Pavel Skripkin

#3 lore raw
Quoted 31 lines · Pavel Skripkin

Hi Simon,

Simon Glass <[email protected]> says:

Quoted 19 lines · Pavel Skripkin
Quoted 18 lines

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.

Quoted 8 lines
Quoted 6 lines

Fix it by disabling tracing before unmapping memory

---
 arch/sandbox/cpu/state.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 8 lines

Thank you for review!

+Tom, I guess?

@Tom, could you, please, pick following patch?

https://lists.denx.de/pipermail/u-boot/2023-April/515192.html

Simon takes sandbox patches himself and I've assigned this to him in patchwork, thanks for submitting the patch.

Signature · 1 line
Tom
#4 lore raw

Hi Tom,

Tom Rini <[email protected]> says:

Quoted 3 lines

Simon takes sandbox patches himself and I've assigned this to him in patchwork, thanks for submitting the patch.

Ah, sorry for noise then. I am just unfamiliar with u-boot development process.

Thank you!

With regards,
Pavel Skripkin

#5 lore raw

Hi Tom,

Tom Rini <[email protected]> says:

Quoted 3 lines

Simon takes sandbox patches himself and I've assigned this to him in patchwork, thanks for submitting the patch.

Ah, sorry for noise then. I am just unfamiliar with u-boot development process.

Thank you!

With regards,
Pavel Skripkin

Applied to u-boot-dm, thanks!

#6 lore raw

Hi Pavel,

Quoted 4 lines · Simon Glass

Hi Tom,

Tom Rini <[email protected]> says:

Quoted 8 lines
Quoted 3 lines

Simon takes sandbox patches himself and I've assigned this to him in patchwork, thanks for submitting the patch.

Ah, sorry for noise then. I am just unfamiliar with u-boot development process.

Thank you!

Note, I had to add a check for tracing being enabled, to avoid build errors.

Regards,
SImon