From: Nicholas Piggin <npiggin@gmail.com>
To: qemu-devel@nongnu.org
Cc: Nicholas Piggin <npiggin@gmail.com>,
qemu-ppc@nongnu.org, Benjamin Gray <bgray@linux.ibm.com>
Subject: [PULL 5/8] target/ppc: Fix GDB register indexing on secondary CPUs
Date: Sun, 31 Mar 2024 17:33:42 +1000 [thread overview]
Message-ID: <20240331073349.88324-6-npiggin@gmail.com> (raw)
In-Reply-To: <20240331073349.88324-1-npiggin@gmail.com>
From: Benjamin Gray <bgray@linux.ibm.com>
The GDB server protocol assigns an arbitrary numbering of the SPRs.
We track this correspondence on each SPR with gdb_id, using it to
resolve any SPR requests GDB makes.
Early on we generate an XML representation of the SPRs to give GDB,
including this numbering. However the XML is cached globally, and we
skip setting the SPR gdb_id values on subsequent threads if we detect
it is cached. This causes QEMU to fail to resolve SPR requests against
secondary CPUs because it cannot find the matching gdb_id value on that
thread's SPRs.
This is a minimal fix to first assign the gdb_id values, then return
early if the XML is cached. Otherwise we generate the XML using the
now already initialised gdb_id values.
Fixes: 1b53948ff8f7 ("target/ppc: Use GDBFeature for dynamic XML")
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
target/ppc/gdbstub.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c
index 3f1e61bdb7..3b28d4e21c 100644
--- a/target/ppc/gdbstub.c
+++ b/target/ppc/gdbstub.c
@@ -305,14 +305,6 @@ static void gdb_gen_spr_feature(CPUState *cs)
unsigned int num_regs = 0;
int i;
- if (pcc->gdb_spr.xml) {
- return;
- }
-
- gdb_feature_builder_init(&builder, &pcc->gdb_spr,
- "org.qemu.power.spr", "power-spr.xml",
- cs->gdb_num_regs);
-
for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) {
ppc_spr_t *spr = &env->spr_cb[i];
@@ -320,9 +312,6 @@ static void gdb_gen_spr_feature(CPUState *cs)
continue;
}
- gdb_feature_builder_append_reg(&builder, g_ascii_strdown(spr->name, -1),
- TARGET_LONG_BITS, num_regs,
- "int", "spr");
/*
* GDB identifies registers based on the order they are
* presented in the XML. These ids will not match QEMU's
@@ -335,6 +324,26 @@ static void gdb_gen_spr_feature(CPUState *cs)
num_regs++;
}
+ if (pcc->gdb_spr.xml) {
+ return;
+ }
+
+ gdb_feature_builder_init(&builder, &pcc->gdb_spr,
+ "org.qemu.power.spr", "power-spr.xml",
+ cs->gdb_num_regs);
+
+ for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) {
+ ppc_spr_t *spr = &env->spr_cb[i];
+
+ if (!spr->name) {
+ continue;
+ }
+
+ gdb_feature_builder_append_reg(&builder, g_ascii_strdown(spr->name, -1),
+ TARGET_LONG_BITS, spr->gdb_id,
+ "int", "spr");
+ }
+
gdb_feature_builder_end(&builder);
}
#endif
--
2.43.0
next prev parent reply other threads:[~2024-03-31 7:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-31 7:33 [PULL 0/8] ppc-for-9.0-3 queue Nicholas Piggin
2024-03-31 7:33 ` [PULL 1/8] spapr: nested: use bitwise NOT operator for flags check Nicholas Piggin
2024-03-31 7:33 ` [PULL 2/8] hw/ppc/spapr: Include missing 'sysemu/tcg.h' header Nicholas Piggin
2024-03-31 7:33 ` [PULL 3/8] target/ppc/mmu-radix64: Use correct string format in walk_tree() Nicholas Piggin
2024-03-31 7:33 ` [PULL 4/8] target/ppc: Restore [H]DEXCR to 64-bits Nicholas Piggin
2024-03-31 7:33 ` Nicholas Piggin [this message]
2024-03-31 7:33 ` [PULL 6/8] target/ppc: Do not clear MSR[ME] on MCE interrupts to supervisor Nicholas Piggin
2024-03-31 7:33 ` [PULL 7/8] tests/avocado: Fix ppc_hv_tests.py xorriso dependency guard Nicholas Piggin
2024-03-31 7:33 ` [PULL 8/8] tests/avocado: ppc_hv_tests.py set alpine time before setup-alpine Nicholas Piggin
2024-04-01 12:09 ` [PULL 0/8] ppc-for-9.0-3 queue Peter Maydell
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=20240331073349.88324-6-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=bgray@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).