qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Patch: Sparc prevent segfault when dumping uninitialzed cpu state
@ 2025-02-03  3:14 Henk van der Laak (LaakSoft) via
  2025-02-03  3:45 ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Henk van der Laak (LaakSoft) via @ 2025-02-03  3:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland, Artyom Tarasenko

Hi all, my first contribution. I checked code style, patch submission 
rules and did a manual test (details on request)

Synopsis:
It's a corner case, where a segfault occurs when logging Sparc CPU state 
in a partially initialized state.

No related bug report.

Open to harsh criticism ;-)

Regards,

Henk van der Laak <henk@laaksoft.nl>


Patch is based off 6fccaa2fba391815308a746d68f7fa197bc93586 
(origin/master) as of Sun Feb 2 11:09:10 2025 -0500
Signed-off-by: Henk van der Laak <henk@laaksoft.nl>

---
  target/sparc/cpu.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index fbd38ec334..83aaa456fc 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -642,7 +642,12 @@ static void sparc_cpu_dump_state(CPUState *cs, FILE 
*f, int flags)
                               x == 0 ? 'o' : (x == 1 ? 'l' : 'i'),
                               i, i + REGS_PER_LINE - 1);
              }
-            qemu_fprintf(f, TARGET_FMT_lx " ", env->regwptr[i + x * 8]);
+            /*
+             * regwptr may not be initialized yet when logging
+             * e.g. cpu_reset
+             */
+            qemu_fprintf(f, TARGET_FMT_lx " ",
+                env->regwptr ? env->regwptr[i + x * 8] : 0);
              if (i % REGS_PER_LINE == REGS_PER_LINE - 1) {
                  qemu_fprintf(f, "\n");
              }
-- 
2.43.0



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

end of thread, other threads:[~2025-02-03  4:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-03  3:14 Patch: Sparc prevent segfault when dumping uninitialzed cpu state Henk van der Laak (LaakSoft) via
2025-02-03  3:45 ` Richard Henderson
     [not found]   ` <a392d217-852c-46b4-84ef-d8ea5ad296c1@laaksoft.nl>
2025-02-03  4:10     ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).