Skip to content

Commit 8afc43e

Browse files
iii-ihuth
authored andcommitted
s390x/gdb: Split s390-virt.xml
Both TCG and KVM emulate ckc, cputm, last_break and prefix, and it's quite useful to have them during debugging. Right now they are grouped together with KVM-only pp, pfault_token, pfault_select and pfault_compare in s390-virt.xml, and are not available when debugging TCG-emulated code. Move KVM-only registers into the new s390-virt-kvm.xml file. Advertise s390-virt.xml always, and the new s390-virt-kvm.xml only for KVM. Signed-off-by: Ilya Leoshkevich <[email protected]> Message-Id: <[email protected]> Acked-by: David Hildenbrand <[email protected]> Signed-off-by: Thomas Huth <[email protected]>
1 parent cc5ee50 commit 8afc43e

File tree

5 files changed

+61
-26
lines changed

5 files changed

+61
-26
lines changed

configs/targets/s390x-linux-user.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ TARGET_ARCH=s390x
22
TARGET_SYSTBL_ABI=common,64
33
TARGET_SYSTBL=syscall.tbl
44
TARGET_BIG_ENDIAN=y
5-
TARGET_XML_FILES= gdb-xml/s390x-core64.xml gdb-xml/s390-acr.xml gdb-xml/s390-fpr.xml gdb-xml/s390-vx.xml gdb-xml/s390-cr.xml gdb-xml/s390-virt.xml gdb-xml/s390-gs.xml
5+
TARGET_XML_FILES= gdb-xml/s390x-core64.xml gdb-xml/s390-acr.xml gdb-xml/s390-fpr.xml gdb-xml/s390-vx.xml gdb-xml/s390-cr.xml gdb-xml/s390-virt.xml gdb-xml/s390-virt-kvm.xml gdb-xml/s390-gs.xml

configs/targets/s390x-softmmu.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
TARGET_ARCH=s390x
22
TARGET_BIG_ENDIAN=y
33
TARGET_SUPPORTS_MTTCG=y
4-
TARGET_XML_FILES= gdb-xml/s390x-core64.xml gdb-xml/s390-acr.xml gdb-xml/s390-fpr.xml gdb-xml/s390-vx.xml gdb-xml/s390-cr.xml gdb-xml/s390-virt.xml gdb-xml/s390-gs.xml
4+
TARGET_XML_FILES= gdb-xml/s390x-core64.xml gdb-xml/s390-acr.xml gdb-xml/s390-fpr.xml gdb-xml/s390-vx.xml gdb-xml/s390-cr.xml gdb-xml/s390-virt.xml gdb-xml/s390-virt-kvm.xml gdb-xml/s390-gs.xml

gdb-xml/s390-virt-kvm.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<!-- Copyright 2023 IBM Corp.
3+
4+
This work is licensed under the terms of the GNU GPL, version 2 or
5+
(at your option) any later version. See the COPYING file in the
6+
top-level directory. -->
7+
8+
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
9+
<feature name="org.gnu.gdb.s390.virt.kvm">
10+
<reg name="pp" bitsize="64" type="uint64" group="system"/>
11+
<reg name="pfault_token" bitsize="64" type="uint64" group="system"/>
12+
<reg name="pfault_select" bitsize="64" type="uint64" group="system"/>
13+
<reg name="pfault_compare" bitsize="64" type="uint64" group="system"/>
14+
</feature>

gdb-xml/s390-virt.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,4 @@
1111
<reg name="cputm" bitsize="64" type="uint64" group="system"/>
1212
<reg name="last_break" bitsize="64" type="code_ptr" group="system"/>
1313
<reg name="prefix" bitsize="64" type="data_ptr" group="system"/>
14-
<reg name="pp" bitsize="64" type="uint64" group="system"/>
15-
<reg name="pfault_token" bitsize="64" type="uint64" group="system"/>
16-
<reg name="pfault_select" bitsize="64" type="uint64" group="system"/>
17-
<reg name="pfault_compare" bitsize="64" type="uint64" group="system"/>
1814
</feature>

target/s390x/gdbstub.c

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,8 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
206206
#define S390_VIRT_CPUTM_REGNUM 1
207207
#define S390_VIRT_BEA_REGNUM 2
208208
#define S390_VIRT_PREFIX_REGNUM 3
209-
#define S390_VIRT_PP_REGNUM 4
210-
#define S390_VIRT_PFT_REGNUM 5
211-
#define S390_VIRT_PFS_REGNUM 6
212-
#define S390_VIRT_PFC_REGNUM 7
213209
/* total number of registers in s390-virt.xml */
214-
#define S390_NUM_VIRT_REGS 8
210+
#define S390_NUM_VIRT_REGS 4
215211

216212
static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int n)
217213
{
@@ -224,14 +220,6 @@ static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int n)
224220
return gdb_get_regl(mem_buf, env->gbea);
225221
case S390_VIRT_PREFIX_REGNUM:
226222
return gdb_get_regl(mem_buf, env->psa);
227-
case S390_VIRT_PP_REGNUM:
228-
return gdb_get_regl(mem_buf, env->pp);
229-
case S390_VIRT_PFT_REGNUM:
230-
return gdb_get_regl(mem_buf, env->pfault_token);
231-
case S390_VIRT_PFS_REGNUM:
232-
return gdb_get_regl(mem_buf, env->pfault_select);
233-
case S390_VIRT_PFC_REGNUM:
234-
return gdb_get_regl(mem_buf, env->pfault_compare);
235223
default:
236224
return 0;
237225
}
@@ -256,19 +244,51 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
256244
env->psa = ldtul_p(mem_buf);
257245
cpu_synchronize_post_init(env_cpu(env));
258246
return 8;
259-
case S390_VIRT_PP_REGNUM:
247+
default:
248+
return 0;
249+
}
250+
}
251+
252+
/* the values represent the positions in s390-virt-kvm.xml */
253+
#define S390_VIRT_KVM_PP_REGNUM 0
254+
#define S390_VIRT_KVM_PFT_REGNUM 1
255+
#define S390_VIRT_KVM_PFS_REGNUM 2
256+
#define S390_VIRT_KVM_PFC_REGNUM 3
257+
/* total number of registers in s390-virt-kvm.xml */
258+
#define S390_NUM_VIRT_KVM_REGS 4
259+
260+
static int cpu_read_virt_kvm_reg(CPUS390XState *env, GByteArray *mem_buf, int n)
261+
{
262+
switch (n) {
263+
case S390_VIRT_KVM_PP_REGNUM:
264+
return gdb_get_regl(mem_buf, env->pp);
265+
case S390_VIRT_KVM_PFT_REGNUM:
266+
return gdb_get_regl(mem_buf, env->pfault_token);
267+
case S390_VIRT_KVM_PFS_REGNUM:
268+
return gdb_get_regl(mem_buf, env->pfault_select);
269+
case S390_VIRT_KVM_PFC_REGNUM:
270+
return gdb_get_regl(mem_buf, env->pfault_compare);
271+
default:
272+
return 0;
273+
}
274+
}
275+
276+
static int cpu_write_virt_kvm_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
277+
{
278+
switch (n) {
279+
case S390_VIRT_KVM_PP_REGNUM:
260280
env->pp = ldtul_p(mem_buf);
261281
cpu_synchronize_post_init(env_cpu(env));
262282
return 8;
263-
case S390_VIRT_PFT_REGNUM:
283+
case S390_VIRT_KVM_PFT_REGNUM:
264284
env->pfault_token = ldtul_p(mem_buf);
265285
cpu_synchronize_post_init(env_cpu(env));
266286
return 8;
267-
case S390_VIRT_PFS_REGNUM:
287+
case S390_VIRT_KVM_PFS_REGNUM:
268288
env->pfault_select = ldtul_p(mem_buf);
269289
cpu_synchronize_post_init(env_cpu(env));
270290
return 8;
271-
case S390_VIRT_PFC_REGNUM:
291+
case S390_VIRT_KVM_PFC_REGNUM:
272292
env->pfault_compare = ldtul_p(mem_buf);
273293
cpu_synchronize_post_init(env_cpu(env));
274294
return 8;
@@ -321,10 +341,15 @@ void s390_cpu_gdb_init(CPUState *cs)
321341
cpu_write_c_reg,
322342
S390_NUM_C_REGS, "s390-cr.xml", 0);
323343

344+
gdb_register_coprocessor(cs, cpu_read_virt_reg,
345+
cpu_write_virt_reg,
346+
S390_NUM_VIRT_REGS, "s390-virt.xml", 0);
347+
324348
if (kvm_enabled()) {
325-
gdb_register_coprocessor(cs, cpu_read_virt_reg,
326-
cpu_write_virt_reg,
327-
S390_NUM_VIRT_REGS, "s390-virt.xml", 0);
349+
gdb_register_coprocessor(cs, cpu_read_virt_kvm_reg,
350+
cpu_write_virt_kvm_reg,
351+
S390_NUM_VIRT_KVM_REGS, "s390-virt-kvm.xml",
352+
0);
328353
}
329354
#endif
330355
}

0 commit comments

Comments
 (0)