* [PATCH 0/2] target/arm: Support SME2 in gdbstub
@ 2025-10-16 12:21 Peter Maydell
2025-10-16 12:21 ` [PATCH 1/2] target/arm: Implement SME2 support " Peter Maydell
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Peter Maydell @ 2025-10-16 12:21 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: Vacha Bhavsar
This patchseries adds SME2 support to the gdbstub. This is
fairly straightforward as the only thing we need to do is
expose the new ZT0 register in the XML in the way that gdb
documents that we should.
Patch 2 is a simple "check reads and writes" test case along
the lines of our existing SME tests. I don't think there are
any specific gdb version requirements here because the XML
should be enough for gdb to know it's a 64 byte vector.
(I also did a little manual testing with a program that
reads and writes the ZT0 value in guest code to confirm that
gdb interactions do the right thing.)
thanks
-- PMM
Peter Maydell (2):
target/arm: Implement SME2 support in gdbstub
tests/tcg/aarch64: Add test case for SME2 gdbstub registers
target/arm/cpu.h | 1 +
target/arm/internals.h | 3 +
target/arm/gdbstub.c | 7 +++
target/arm/gdbstub64.c | 76 ++++++++++++++++++++++++++
tests/tcg/aarch64/Makefile.target | 9 ++-
tests/tcg/aarch64/gdbstub/test-sme2.py | 41 ++++++++++++++
6 files changed, 136 insertions(+), 1 deletion(-)
create mode 100644 tests/tcg/aarch64/gdbstub/test-sme2.py
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] target/arm: Implement SME2 support in gdbstub
2025-10-16 12:21 [PATCH 0/2] target/arm: Support SME2 in gdbstub Peter Maydell
@ 2025-10-16 12:21 ` Peter Maydell
2025-10-16 21:17 ` Richard Henderson
2025-10-16 12:21 ` [PATCH 2/2] tests/tcg/aarch64: Add test case for SME2 gdbstub registers Peter Maydell
2025-10-16 21:10 ` [PATCH 0/2] target/arm: Support SME2 in gdbstub Richard Henderson
2 siblings, 1 reply; 8+ messages in thread
From: Peter Maydell @ 2025-10-16 12:21 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: Vacha Bhavsar
For SME2, we need to expose the new ZT0 register in the gdbstub XML.
gdb documents that the requirements are:
> The ‘org.gnu.gdb.aarch64.sme2’ feature is optional. If present,
> then the ‘org.gnu.gdb.aarch64.sme’ feature must also be present.
> The ‘org.gnu.gdb.aarch64.sme2’ feature should contain the
> following:
>
> - ZT0 is a register of 512 bits (64 bytes). It is defined as a
> vector of bytes.
Implement this.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/cpu.h | 1 +
target/arm/internals.h | 3 ++
target/arm/gdbstub.c | 7 ++++
target/arm/gdbstub64.c | 76 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 87 insertions(+)
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index bf221e6f973..912f7a87e42 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -939,6 +939,7 @@ struct ArchCPU {
DynamicGDBFeatureInfo dyn_sysreg_feature;
DynamicGDBFeatureInfo dyn_svereg_feature;
DynamicGDBFeatureInfo dyn_smereg_feature;
+ DynamicGDBFeatureInfo dyn_sme2reg_feature;
DynamicGDBFeatureInfo dyn_m_systemreg_feature;
DynamicGDBFeatureInfo dyn_m_secextreg_feature;
diff --git a/target/arm/internals.h b/target/arm/internals.h
index f539bbe58e1..c41c1f224a5 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -1715,10 +1715,13 @@ static inline uint64_t pmu_counter_mask(CPUARMState *env)
GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *cpu, int base_reg);
GDBFeature *arm_gen_dynamic_smereg_feature(CPUState *cpu, int base_reg);
+GDBFeature *arm_gen_dynamic_sme2reg_feature(CPUState *cpu, int base_reg);
int aarch64_gdb_get_sve_reg(CPUState *cs, GByteArray *buf, int reg);
int aarch64_gdb_set_sve_reg(CPUState *cs, uint8_t *buf, int reg);
int aarch64_gdb_get_sme_reg(CPUState *cs, GByteArray *buf, int reg);
int aarch64_gdb_set_sme_reg(CPUState *cs, uint8_t *buf, int reg);
+int aarch64_gdb_get_sme2_reg(CPUState *cs, GByteArray *buf, int reg);
+int aarch64_gdb_set_sme2_reg(CPUState *cs, uint8_t *buf, int reg);
int aarch64_gdb_get_fpu_reg(CPUState *cs, GByteArray *buf, int reg);
int aarch64_gdb_set_fpu_reg(CPUState *cs, uint8_t *buf, int reg);
int aarch64_gdb_get_pauth_reg(CPUState *cs, GByteArray *buf, int reg);
diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
index 8d2229f5192..7cac2a5965e 100644
--- a/target/arm/gdbstub.c
+++ b/target/arm/gdbstub.c
@@ -554,6 +554,13 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
arm_gen_dynamic_smereg_feature(cs, cs->gdb_num_regs);
gdb_register_coprocessor(cs, aarch64_gdb_get_sme_reg,
aarch64_gdb_set_sme_reg, sme_feature, 0);
+ if (isar_feature_aa64_sme2(&cpu->isar)) {
+ GDBFeature *sme2_feature =
+ arm_gen_dynamic_sme2reg_feature(cs, cs->gdb_num_regs);
+ gdb_register_coprocessor(cs, aarch64_gdb_get_sme2_reg,
+ aarch64_gdb_set_sme2_reg,
+ sme2_feature, 0);
+ }
}
/*
* Note that we report pauth information via the feature name
diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c
index 65d6bbe65fb..7f7d706324e 100644
--- a/target/arm/gdbstub64.c
+++ b/target/arm/gdbstub64.c
@@ -335,6 +335,58 @@ int aarch64_gdb_set_sme_reg(CPUState *cs, uint8_t *buf, int reg)
return 0;
}
+int aarch64_gdb_get_sme2_reg(CPUState *cs, GByteArray *buf, int reg)
+{
+ ARMCPU *cpu = ARM_CPU(cs);
+ CPUARMState *env = &cpu->env;
+ int len = 0;
+
+ switch (reg) {
+ case 0: /* ZT0 */
+ for (int i = 0; i < ARRAY_SIZE(env->za_state.zt0); i+= 2) {
+ len += gdb_get_reg128(buf, env->za_state.zt0[i + 1],
+ env->za_state.zt0[i]);
+ }
+ return len;
+ default:
+ /* gdbstub asked for something out of range */
+ qemu_log_mask(LOG_UNIMP, "%s: out of range register %d", __func__, reg);
+ break;
+ }
+
+ return 0;
+}
+
+int aarch64_gdb_set_sme2_reg(CPUState *cs, uint8_t *buf, int reg)
+{
+ ARMCPU *cpu = ARM_CPU(cs);
+ CPUARMState *env = &cpu->env;
+ int len = 0;
+
+ switch (reg) {
+ case 0: /* ZT0 */
+ for (int i = 0; i < ARRAY_SIZE(env->za_state.zt0); i += 2) {
+ if (target_big_endian()) {
+ env->za_state.zt0[i + 1] = ldq_p(buf);
+ buf += 8;
+ env->za_state.zt0[i] = ldq_p(buf);
+ } else {
+ env->za_state.zt0[i] = ldq_p(buf);
+ buf += 8;
+ env->za_state.zt0[i + 1] = ldq_p(buf);
+ }
+ buf += 8;
+ len += 16;
+ }
+ return len;
+ default:
+ /* gdbstub asked for something out of range */
+ break;
+ }
+
+ return 0;
+}
+
int aarch64_gdb_get_pauth_reg(CPUState *cs, GByteArray *buf, int reg)
{
ARMCPU *cpu = ARM_CPU(cs);
@@ -534,6 +586,30 @@ GDBFeature *arm_gen_dynamic_smereg_feature(CPUState *cs, int base_reg)
return &cpu->dyn_smereg_feature.desc;
}
+GDBFeature *arm_gen_dynamic_sme2reg_feature(CPUState *cs, int base_reg)
+{
+ ARMCPU *cpu = ARM_CPU(cs);
+ GDBFeatureBuilder builder;
+ int reg = 0;
+
+ gdb_feature_builder_init(&builder, &cpu->dyn_sme2reg_feature.desc,
+ "org.gnu.gdb.aarch64.sme2", "sme2-registers.xml",
+ base_reg);
+
+
+ /* Create the sme2_bv vector type (a 64 byte vector) */
+ gdb_feature_builder_append_tag(
+ &builder, "<vector id=\"sme2_bv\" type=\"uint8\" count=\"64\"/>");
+
+ /* Define the ZT0 register */
+ gdb_feature_builder_append_reg(&builder, "zt0", 64 * 8, reg++,
+ "sme2_bv", NULL);
+
+ gdb_feature_builder_end(&builder);
+
+ return &cpu->dyn_sme2reg_feature.desc;
+}
+
#ifdef CONFIG_USER_ONLY
int aarch64_gdb_get_tag_ctl_reg(CPUState *cs, GByteArray *buf, int reg)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] tests/tcg/aarch64: Add test case for SME2 gdbstub registers
2025-10-16 12:21 [PATCH 0/2] target/arm: Support SME2 in gdbstub Peter Maydell
2025-10-16 12:21 ` [PATCH 1/2] target/arm: Implement SME2 support " Peter Maydell
@ 2025-10-16 12:21 ` Peter Maydell
2025-10-16 21:19 ` Richard Henderson
2025-10-17 15:11 ` Peter Maydell
2025-10-16 21:10 ` [PATCH 0/2] target/arm: Support SME2 in gdbstub Richard Henderson
2 siblings, 2 replies; 8+ messages in thread
From: Peter Maydell @ 2025-10-16 12:21 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: Vacha Bhavsar
Test the SME2 register exposure over gdbstub, in the same way
we already do for SME.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
tests/tcg/aarch64/Makefile.target | 9 +++++-
tests/tcg/aarch64/gdbstub/test-sme2.py | 41 ++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
create mode 100644 tests/tcg/aarch64/gdbstub/test-sme2.py
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index 55ce34e45ee..9fa86874534 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -164,7 +164,14 @@ run-gdbstub-sysregs-sme-tile-slice: sysregs
"selected gdb ($(GDB)) does not support SME ZA tile slices")
endif
-EXTRA_RUNS += run-gdbstub-sysregs-sme run-gdbstub-sysregs-sme-tile-slice
+run-gdbstub-sysregs-sme2: sysregs
+ $(call run-test, $@, $(GDB_SCRIPT) \
+ --gdb $(GDB) \
+ --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
+ --bin $< --test $(AARCH64_SRC)/gdbstub/test-sme2.py, \
+ gdbstub SME ZA tile slice support)
+
+EXTRA_RUNS += run-gdbstub-sysregs-sme run-gdbstub-sysregs-sme-tile-slice run-gdbstub-sysregs-sme2
endif
diff --git a/tests/tcg/aarch64/gdbstub/test-sme2.py b/tests/tcg/aarch64/gdbstub/test-sme2.py
new file mode 100644
index 00000000000..1d189ac01ca
--- /dev/null
+++ b/tests/tcg/aarch64/gdbstub/test-sme2.py
@@ -0,0 +1,41 @@
+#
+# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+#
+# Test the SME registers are visible and changeable via gdbstub
+#
+# This is launched via tests/guest-debug/run-test.py
+#
+
+import argparse
+import gdb
+from test_gdbstub import main, report
+
+MAGIC = 0x01020304
+BASIC_ZA_TEST = 0
+TILE_SLICE_TEST = 0
+
+
+def run_test():
+ """Test reads and writes of the SME2 ZT0 register"""
+ frame = gdb.selected_frame()
+ rname = "zt0"
+ zt0 = frame.read_register(rname)
+ report(True, "Reading %s" % rname)
+
+ # Writing to the ZT0 register, byte by byte.
+ for i in range(0, 64):
+ cmd = "set $zt0[%d] = 0x01" % (i)
+ gdb.execute(cmd)
+ report(True, "%s" % cmd)
+
+ # Reading from the ZT0 register, byte by byte.
+ for i in range(0, 64):
+ reg = "$zt0[%d]" % (i)
+ v = gdb.parse_and_eval(reg)
+ report(str(v.type) == "uint8_t", "size of %s" % (reg))
+ report(v == 0x1, "%s is 0x%x" % (reg, 0x1))
+
+main(run_test, expected_arch="aarch64")
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] target/arm: Support SME2 in gdbstub
2025-10-16 12:21 [PATCH 0/2] target/arm: Support SME2 in gdbstub Peter Maydell
2025-10-16 12:21 ` [PATCH 1/2] target/arm: Implement SME2 support " Peter Maydell
2025-10-16 12:21 ` [PATCH 2/2] tests/tcg/aarch64: Add test case for SME2 gdbstub registers Peter Maydell
@ 2025-10-16 21:10 ` Richard Henderson
2 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2025-10-16 21:10 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: Vacha Bhavsar
On 10/16/25 05:21, Peter Maydell wrote:
> This patchseries adds SME2 support to the gdbstub. This is
> fairly straightforward as the only thing we need to do is
> expose the new ZT0 register in the XML in the way that gdb
> documents that we should.
We're also missing TPIDR2.
According to gdb/features/aarch64-tls.c, "org.gnu.gdb.aarch64.tls" should contain 2
registers, tpidr and tpidr2. Apparently the second is optional, and we should have been
providing the "tls" with just tpidr all along.
r~
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] target/arm: Implement SME2 support in gdbstub
2025-10-16 12:21 ` [PATCH 1/2] target/arm: Implement SME2 support " Peter Maydell
@ 2025-10-16 21:17 ` Richard Henderson
2025-10-17 14:14 ` Peter Maydell
0 siblings, 1 reply; 8+ messages in thread
From: Richard Henderson @ 2025-10-16 21:17 UTC (permalink / raw)
To: qemu-devel
On 10/16/25 05:21, Peter Maydell wrote:
> For SME2, we need to expose the new ZT0 register in the gdbstub XML.
> gdb documents that the requirements are:
>
>> The ‘org.gnu.gdb.aarch64.sme2’ feature is optional. If present,
>> then the ‘org.gnu.gdb.aarch64.sme’ feature must also be present.
>> The ‘org.gnu.gdb.aarch64.sme2’ feature should contain the
>> following:
>>
>> - ZT0 is a register of 512 bits (64 bytes). It is defined as a
>> vector of bytes.
>
> Implement this.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
The size of ZT0 is fixed at 512 bits.
There's no need for the xml to be dynamically generated.
r~
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] tests/tcg/aarch64: Add test case for SME2 gdbstub registers
2025-10-16 12:21 ` [PATCH 2/2] tests/tcg/aarch64: Add test case for SME2 gdbstub registers Peter Maydell
@ 2025-10-16 21:19 ` Richard Henderson
2025-10-17 15:11 ` Peter Maydell
1 sibling, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2025-10-16 21:19 UTC (permalink / raw)
To: qemu-devel
On 10/16/25 05:21, Peter Maydell wrote:
> Test the SME2 register exposure over gdbstub, in the same way
> we already do for SME.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> tests/tcg/aarch64/Makefile.target | 9 +++++-
> tests/tcg/aarch64/gdbstub/test-sme2.py | 41 ++++++++++++++++++++++++++
> 2 files changed, 49 insertions(+), 1 deletion(-)
> create mode 100644 tests/tcg/aarch64/gdbstub/test-sme2.py
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] target/arm: Implement SME2 support in gdbstub
2025-10-16 21:17 ` Richard Henderson
@ 2025-10-17 14:14 ` Peter Maydell
0 siblings, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2025-10-17 14:14 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel
On Thu, 16 Oct 2025 at 22:17, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 10/16/25 05:21, Peter Maydell wrote:
> > For SME2, we need to expose the new ZT0 register in the gdbstub XML.
> > gdb documents that the requirements are:
> >
> >> The ‘org.gnu.gdb.aarch64.sme2’ feature is optional. If present,
> >> then the ‘org.gnu.gdb.aarch64.sme’ feature must also be present.
> >> The ‘org.gnu.gdb.aarch64.sme2’ feature should contain the
> >> following:
> >>
> >> - ZT0 is a register of 512 bits (64 bytes). It is defined as a
> >> vector of bytes.
> >
> > Implement this.
> >
> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>
> The size of ZT0 is fixed at 512 bits.
> There's no need for the xml to be dynamically generated.
I suppose not. GDB upstream dynamically generates the XML,
though, so there's no upstream XML file for us to use.
-- PMM
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] tests/tcg/aarch64: Add test case for SME2 gdbstub registers
2025-10-16 12:21 ` [PATCH 2/2] tests/tcg/aarch64: Add test case for SME2 gdbstub registers Peter Maydell
2025-10-16 21:19 ` Richard Henderson
@ 2025-10-17 15:11 ` Peter Maydell
1 sibling, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2025-10-17 15:11 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: Vacha Bhavsar
On Thu, 16 Oct 2025 at 13:21, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> Test the SME2 register exposure over gdbstub, in the same way
> we already do for SME.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> tests/tcg/aarch64/Makefile.target | 9 +++++-
> tests/tcg/aarch64/gdbstub/test-sme2.py | 41 ++++++++++++++++++++++++++
> 2 files changed, 49 insertions(+), 1 deletion(-)
> create mode 100644 tests/tcg/aarch64/gdbstub/test-sme2.py
>
> diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
> index 55ce34e45ee..9fa86874534 100644
> --- a/tests/tcg/aarch64/Makefile.target
> +++ b/tests/tcg/aarch64/Makefile.target
> @@ -164,7 +164,14 @@ run-gdbstub-sysregs-sme-tile-slice: sysregs
> "selected gdb ($(GDB)) does not support SME ZA tile slices")
> endif
>
> -EXTRA_RUNS += run-gdbstub-sysregs-sme run-gdbstub-sysregs-sme-tile-slice
> +run-gdbstub-sysregs-sme2: sysregs
> + $(call run-test, $@, $(GDB_SCRIPT) \
> + --gdb $(GDB) \
> + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
> + --bin $< --test $(AARCH64_SRC)/gdbstub/test-sme2.py, \
> + gdbstub SME ZA tile slice support)
> +
> +EXTRA_RUNS += run-gdbstub-sysregs-sme run-gdbstub-sysregs-sme-tile-slice run-gdbstub-sysregs-sme2
>
> endif
>
> diff --git a/tests/tcg/aarch64/gdbstub/test-sme2.py b/tests/tcg/aarch64/gdbstub/test-sme2.py
> new file mode 100644
> index 00000000000..1d189ac01ca
> --- /dev/null
> +++ b/tests/tcg/aarch64/gdbstub/test-sme2.py
> @@ -0,0 +1,41 @@
> +#
> +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
This is obviously wrong -- I used the SME test case as
an initial template, but forgot to edit the copyright line :-/
Will fix in v2.
> +#
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +#
> +# Test the SME registers are visible and changeable via gdbstub
> +#
> +# This is launched via tests/guest-debug/run-test.py
> +#
> +
> +import argparse
> +import gdb
> +from test_gdbstub import main, report
> +
> +MAGIC = 0x01020304
> +BASIC_ZA_TEST = 0
> +TILE_SLICE_TEST = 0
These constants and the argparse import aren't needed
for this simple test case.
-- PMM
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-10-17 15:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16 12:21 [PATCH 0/2] target/arm: Support SME2 in gdbstub Peter Maydell
2025-10-16 12:21 ` [PATCH 1/2] target/arm: Implement SME2 support " Peter Maydell
2025-10-16 21:17 ` Richard Henderson
2025-10-17 14:14 ` Peter Maydell
2025-10-16 12:21 ` [PATCH 2/2] tests/tcg/aarch64: Add test case for SME2 gdbstub registers Peter Maydell
2025-10-16 21:19 ` Richard Henderson
2025-10-17 15:11 ` Peter Maydell
2025-10-16 21:10 ` [PATCH 0/2] target/arm: Support SME2 in gdbstub 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).