[PATCH v2] s390x/gdb: Split s390-virt.xml

Ilya Leoshkevich posted 1 patch 1 year, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230314101813.174874-1-iii@linux.ibm.com
Maintainers: Laurent Vivier <laurent@vivier.eu>, Thomas Huth <thuth@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>
configs/targets/s390x-linux-user.mak |  2 +-
configs/targets/s390x-softmmu.mak    |  2 +-
gdb-xml/s390-virt-kvm.xml            | 14 ++++++
gdb-xml/s390-virt.xml                |  4 --
target/s390x/gdbstub.c               | 65 +++++++++++++++++++---------
5 files changed, 61 insertions(+), 26 deletions(-)
create mode 100644 gdb-xml/s390-virt-kvm.xml
[PATCH v2] s390x/gdb: Split s390-virt.xml
Posted by Ilya Leoshkevich 1 year, 1 month ago
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 <iii@linux.ibm.com>
Message-Id: <20230313211614.98739-1-iii@linux.ibm.com>
---

v1: https://lists.gnu.org/archive/html/qemu-devel/2023-03/msg04307.html
v1 -> v2: Improve the naming and the commit message (Christian).

 configs/targets/s390x-linux-user.mak |  2 +-
 configs/targets/s390x-softmmu.mak    |  2 +-
 gdb-xml/s390-virt-kvm.xml            | 14 ++++++
 gdb-xml/s390-virt.xml                |  4 --
 target/s390x/gdbstub.c               | 65 +++++++++++++++++++---------
 5 files changed, 61 insertions(+), 26 deletions(-)
 create mode 100644 gdb-xml/s390-virt-kvm.xml

diff --git a/configs/targets/s390x-linux-user.mak b/configs/targets/s390x-linux-user.mak
index e2978248ede..24c04c85894 100644
--- a/configs/targets/s390x-linux-user.mak
+++ b/configs/targets/s390x-linux-user.mak
@@ -2,4 +2,4 @@ TARGET_ARCH=s390x
 TARGET_SYSTBL_ABI=common,64
 TARGET_SYSTBL=syscall.tbl
 TARGET_BIG_ENDIAN=y
-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
+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
diff --git a/configs/targets/s390x-softmmu.mak b/configs/targets/s390x-softmmu.mak
index 258b4cf3582..70d2f9f0ba0 100644
--- a/configs/targets/s390x-softmmu.mak
+++ b/configs/targets/s390x-softmmu.mak
@@ -1,4 +1,4 @@
 TARGET_ARCH=s390x
 TARGET_BIG_ENDIAN=y
 TARGET_SUPPORTS_MTTCG=y
-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
+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
diff --git a/gdb-xml/s390-virt-kvm.xml b/gdb-xml/s390-virt-kvm.xml
new file mode 100644
index 00000000000..a256eddaf57
--- /dev/null
+++ b/gdb-xml/s390-virt-kvm.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<!-- Copyright 2023 IBM Corp.
+
+     This work is licensed under the terms of the GNU GPL, version 2 or
+     (at your option) any later version. See the COPYING file in the
+     top-level directory. -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.s390.virt.kvm">
+  <reg name="pp" bitsize="64" type="uint64" group="system"/>
+  <reg name="pfault_token" bitsize="64" type="uint64" group="system"/>
+  <reg name="pfault_select" bitsize="64" type="uint64" group="system"/>
+  <reg name="pfault_compare" bitsize="64" type="uint64" group="system"/>
+</feature>
diff --git a/gdb-xml/s390-virt.xml b/gdb-xml/s390-virt.xml
index e2e9a7ad3cc..438eb68aabe 100644
--- a/gdb-xml/s390-virt.xml
+++ b/gdb-xml/s390-virt.xml
@@ -11,8 +11,4 @@
   <reg name="cputm" bitsize="64" type="uint64" group="system"/>
   <reg name="last_break" bitsize="64" type="code_ptr" group="system"/>
   <reg name="prefix" bitsize="64" type="data_ptr" group="system"/>
-  <reg name="pp" bitsize="64" type="uint64" group="system"/>
-  <reg name="pfault_token" bitsize="64" type="uint64" group="system"/>
-  <reg name="pfault_select" bitsize="64" type="uint64" group="system"/>
-  <reg name="pfault_compare" bitsize="64" type="uint64" group="system"/>
 </feature>
diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c
index a5d69d0e0bc..e1153f5dc4a 100644
--- a/target/s390x/gdbstub.c
+++ b/target/s390x/gdbstub.c
@@ -205,12 +205,8 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
 #define S390_VIRT_CPUTM_REGNUM  1
 #define S390_VIRT_BEA_REGNUM    2
 #define S390_VIRT_PREFIX_REGNUM 3
-#define S390_VIRT_PP_REGNUM     4
-#define S390_VIRT_PFT_REGNUM    5
-#define S390_VIRT_PFS_REGNUM    6
-#define S390_VIRT_PFC_REGNUM    7
 /* total number of registers in s390-virt.xml */
-#define S390_NUM_VIRT_REGS 8
+#define S390_NUM_VIRT_REGS 4
 
 static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int n)
 {
@@ -223,14 +219,6 @@ static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int n)
         return gdb_get_regl(mem_buf, env->gbea);
     case S390_VIRT_PREFIX_REGNUM:
         return gdb_get_regl(mem_buf, env->psa);
-    case S390_VIRT_PP_REGNUM:
-        return gdb_get_regl(mem_buf, env->pp);
-    case S390_VIRT_PFT_REGNUM:
-        return gdb_get_regl(mem_buf, env->pfault_token);
-    case S390_VIRT_PFS_REGNUM:
-        return gdb_get_regl(mem_buf, env->pfault_select);
-    case S390_VIRT_PFC_REGNUM:
-        return gdb_get_regl(mem_buf, env->pfault_compare);
     default:
         return 0;
     }
@@ -255,19 +243,51 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
         env->psa = ldtul_p(mem_buf);
         cpu_synchronize_post_init(env_cpu(env));
         return 8;
-    case S390_VIRT_PP_REGNUM:
+    default:
+        return 0;
+    }
+}
+
+/* the values represent the positions in s390-virt-kvm.xml */
+#define S390_VIRT_KVM_PP_REGNUM     0
+#define S390_VIRT_KVM_PFT_REGNUM    1
+#define S390_VIRT_KVM_PFS_REGNUM    2
+#define S390_VIRT_KVM_PFC_REGNUM    3
+/* total number of registers in s390-virt-kvm.xml */
+#define S390_NUM_VIRT_KVM_REGS 4
+
+static int cpu_read_virt_kvm_reg(CPUS390XState *env, GByteArray *mem_buf, int n)
+{
+    switch (n) {
+    case S390_VIRT_KVM_PP_REGNUM:
+        return gdb_get_regl(mem_buf, env->pp);
+    case S390_VIRT_KVM_PFT_REGNUM:
+        return gdb_get_regl(mem_buf, env->pfault_token);
+    case S390_VIRT_KVM_PFS_REGNUM:
+        return gdb_get_regl(mem_buf, env->pfault_select);
+    case S390_VIRT_KVM_PFC_REGNUM:
+        return gdb_get_regl(mem_buf, env->pfault_compare);
+    default:
+        return 0;
+    }
+}
+
+static int cpu_write_virt_kvm_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
+{
+    switch (n) {
+    case S390_VIRT_KVM_PP_REGNUM:
         env->pp = ldtul_p(mem_buf);
         cpu_synchronize_post_init(env_cpu(env));
         return 8;
-    case S390_VIRT_PFT_REGNUM:
+    case S390_VIRT_KVM_PFT_REGNUM:
         env->pfault_token = ldtul_p(mem_buf);
         cpu_synchronize_post_init(env_cpu(env));
         return 8;
-    case S390_VIRT_PFS_REGNUM:
+    case S390_VIRT_KVM_PFS_REGNUM:
         env->pfault_select = ldtul_p(mem_buf);
         cpu_synchronize_post_init(env_cpu(env));
         return 8;
-    case S390_VIRT_PFC_REGNUM:
+    case S390_VIRT_KVM_PFC_REGNUM:
         env->pfault_compare = ldtul_p(mem_buf);
         cpu_synchronize_post_init(env_cpu(env));
         return 8;
@@ -320,10 +340,15 @@ void s390_cpu_gdb_init(CPUState *cs)
                              cpu_write_c_reg,
                              S390_NUM_C_REGS, "s390-cr.xml", 0);
 
+    gdb_register_coprocessor(cs, cpu_read_virt_reg,
+                             cpu_write_virt_reg,
+                             S390_NUM_VIRT_REGS, "s390-virt.xml", 0);
+
     if (kvm_enabled()) {
-        gdb_register_coprocessor(cs, cpu_read_virt_reg,
-                                 cpu_write_virt_reg,
-                                 S390_NUM_VIRT_REGS, "s390-virt.xml", 0);
+        gdb_register_coprocessor(cs, cpu_read_virt_kvm_reg,
+                                 cpu_write_virt_kvm_reg,
+                                 S390_NUM_VIRT_KVM_REGS, "s390-virt-kvm.xml",
+                                 0);
     }
 #endif
 }
-- 
2.39.2
Re: [PATCH v2] s390x/gdb: Split s390-virt.xml
Posted by Thomas Huth 1 year ago
On 14/03/2023 11.18, Ilya Leoshkevich wrote:
> 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 <iii@linux.ibm.com>
> Message-Id: <20230313211614.98739-1-iii@linux.ibm.com>
> ---
> 
> v1: https://lists.gnu.org/archive/html/qemu-devel/2023-03/msg04307.html
> v1 -> v2: Improve the naming and the commit message (Christian).
> 
>   configs/targets/s390x-linux-user.mak |  2 +-
>   configs/targets/s390x-softmmu.mak    |  2 +-
>   gdb-xml/s390-virt-kvm.xml            | 14 ++++++
>   gdb-xml/s390-virt.xml                |  4 --
>   target/s390x/gdbstub.c               | 65 +++++++++++++++++++---------
>   5 files changed, 61 insertions(+), 26 deletions(-)
>   create mode 100644 gdb-xml/s390-virt-kvm.xml
> 
> diff --git a/configs/targets/s390x-linux-user.mak b/configs/targets/s390x-linux-user.mak
> index e2978248ede..24c04c85894 100644
> --- a/configs/targets/s390x-linux-user.mak
> +++ b/configs/targets/s390x-linux-user.mak
> @@ -2,4 +2,4 @@ TARGET_ARCH=s390x
>   TARGET_SYSTBL_ABI=common,64
>   TARGET_SYSTBL=syscall.tbl
>   TARGET_BIG_ENDIAN=y
> -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
> +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
> diff --git a/configs/targets/s390x-softmmu.mak b/configs/targets/s390x-softmmu.mak
> index 258b4cf3582..70d2f9f0ba0 100644
> --- a/configs/targets/s390x-softmmu.mak
> +++ b/configs/targets/s390x-softmmu.mak
> @@ -1,4 +1,4 @@
>   TARGET_ARCH=s390x
>   TARGET_BIG_ENDIAN=y
>   TARGET_SUPPORTS_MTTCG=y
> -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
> +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
> diff --git a/gdb-xml/s390-virt-kvm.xml b/gdb-xml/s390-virt-kvm.xml
> new file mode 100644
> index 00000000000..a256eddaf57
> --- /dev/null
> +++ b/gdb-xml/s390-virt-kvm.xml
> @@ -0,0 +1,14 @@
> +<?xml version="1.0"?>
> +<!-- Copyright 2023 IBM Corp.
> +
> +     This work is licensed under the terms of the GNU GPL, version 2 or
> +     (at your option) any later version. See the COPYING file in the
> +     top-level directory. -->
> +
> +<!DOCTYPE feature SYSTEM "gdb-target.dtd">
> +<feature name="org.gnu.gdb.s390.virt.kvm">
> +  <reg name="pp" bitsize="64" type="uint64" group="system"/>
> +  <reg name="pfault_token" bitsize="64" type="uint64" group="system"/>
> +  <reg name="pfault_select" bitsize="64" type="uint64" group="system"/>
> +  <reg name="pfault_compare" bitsize="64" type="uint64" group="system"/>
> +</feature>
> diff --git a/gdb-xml/s390-virt.xml b/gdb-xml/s390-virt.xml
> index e2e9a7ad3cc..438eb68aabe 100644
> --- a/gdb-xml/s390-virt.xml
> +++ b/gdb-xml/s390-virt.xml
> @@ -11,8 +11,4 @@
>     <reg name="cputm" bitsize="64" type="uint64" group="system"/>
>     <reg name="last_break" bitsize="64" type="code_ptr" group="system"/>
>     <reg name="prefix" bitsize="64" type="data_ptr" group="system"/>
> -  <reg name="pp" bitsize="64" type="uint64" group="system"/>
> -  <reg name="pfault_token" bitsize="64" type="uint64" group="system"/>
> -  <reg name="pfault_select" bitsize="64" type="uint64" group="system"/>
> -  <reg name="pfault_compare" bitsize="64" type="uint64" group="system"/>
>   </feature>
> diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c
> index a5d69d0e0bc..e1153f5dc4a 100644
> --- a/target/s390x/gdbstub.c
> +++ b/target/s390x/gdbstub.c
> @@ -205,12 +205,8 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
>   #define S390_VIRT_CPUTM_REGNUM  1
>   #define S390_VIRT_BEA_REGNUM    2
>   #define S390_VIRT_PREFIX_REGNUM 3
> -#define S390_VIRT_PP_REGNUM     4
> -#define S390_VIRT_PFT_REGNUM    5
> -#define S390_VIRT_PFS_REGNUM    6
> -#define S390_VIRT_PFC_REGNUM    7
>   /* total number of registers in s390-virt.xml */
> -#define S390_NUM_VIRT_REGS 8
> +#define S390_NUM_VIRT_REGS 4
>   
>   static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int n)
>   {
> @@ -223,14 +219,6 @@ static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int n)
>           return gdb_get_regl(mem_buf, env->gbea);
>       case S390_VIRT_PREFIX_REGNUM:
>           return gdb_get_regl(mem_buf, env->psa);
> -    case S390_VIRT_PP_REGNUM:
> -        return gdb_get_regl(mem_buf, env->pp);
> -    case S390_VIRT_PFT_REGNUM:
> -        return gdb_get_regl(mem_buf, env->pfault_token);
> -    case S390_VIRT_PFS_REGNUM:
> -        return gdb_get_regl(mem_buf, env->pfault_select);
> -    case S390_VIRT_PFC_REGNUM:
> -        return gdb_get_regl(mem_buf, env->pfault_compare);
>       default:
>           return 0;
>       }
> @@ -255,19 +243,51 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
>           env->psa = ldtul_p(mem_buf);
>           cpu_synchronize_post_init(env_cpu(env));
>           return 8;
> -    case S390_VIRT_PP_REGNUM:
> +    default:
> +        return 0;
> +    }
> +}
> +
> +/* the values represent the positions in s390-virt-kvm.xml */
> +#define S390_VIRT_KVM_PP_REGNUM     0
> +#define S390_VIRT_KVM_PFT_REGNUM    1
> +#define S390_VIRT_KVM_PFS_REGNUM    2
> +#define S390_VIRT_KVM_PFC_REGNUM    3
> +/* total number of registers in s390-virt-kvm.xml */
> +#define S390_NUM_VIRT_KVM_REGS 4
> +
> +static int cpu_read_virt_kvm_reg(CPUS390XState *env, GByteArray *mem_buf, int n)
> +{
> +    switch (n) {
> +    case S390_VIRT_KVM_PP_REGNUM:
> +        return gdb_get_regl(mem_buf, env->pp);
> +    case S390_VIRT_KVM_PFT_REGNUM:
> +        return gdb_get_regl(mem_buf, env->pfault_token);
> +    case S390_VIRT_KVM_PFS_REGNUM:
> +        return gdb_get_regl(mem_buf, env->pfault_select);
> +    case S390_VIRT_KVM_PFC_REGNUM:
> +        return gdb_get_regl(mem_buf, env->pfault_compare);
> +    default:
> +        return 0;
> +    }
> +}
> +
> +static int cpu_write_virt_kvm_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
> +{
> +    switch (n) {
> +    case S390_VIRT_KVM_PP_REGNUM:
>           env->pp = ldtul_p(mem_buf);
>           cpu_synchronize_post_init(env_cpu(env));
>           return 8;
> -    case S390_VIRT_PFT_REGNUM:
> +    case S390_VIRT_KVM_PFT_REGNUM:
>           env->pfault_token = ldtul_p(mem_buf);
>           cpu_synchronize_post_init(env_cpu(env));
>           return 8;
> -    case S390_VIRT_PFS_REGNUM:
> +    case S390_VIRT_KVM_PFS_REGNUM:
>           env->pfault_select = ldtul_p(mem_buf);
>           cpu_synchronize_post_init(env_cpu(env));
>           return 8;
> -    case S390_VIRT_PFC_REGNUM:
> +    case S390_VIRT_KVM_PFC_REGNUM:
>           env->pfault_compare = ldtul_p(mem_buf);
>           cpu_synchronize_post_init(env_cpu(env));
>           return 8;
> @@ -320,10 +340,15 @@ void s390_cpu_gdb_init(CPUState *cs)
>                                cpu_write_c_reg,
>                                S390_NUM_C_REGS, "s390-cr.xml", 0);
>   
> +    gdb_register_coprocessor(cs, cpu_read_virt_reg,
> +                             cpu_write_virt_reg,
> +                             S390_NUM_VIRT_REGS, "s390-virt.xml", 0);
> +
>       if (kvm_enabled()) {
> -        gdb_register_coprocessor(cs, cpu_read_virt_reg,
> -                                 cpu_write_virt_reg,
> -                                 S390_NUM_VIRT_REGS, "s390-virt.xml", 0);
> +        gdb_register_coprocessor(cs, cpu_read_virt_kvm_reg,
> +                                 cpu_write_virt_kvm_reg,
> +                                 S390_NUM_VIRT_KVM_REGS, "s390-virt-kvm.xml",
> +                                 0);
>       }
>   #endif
>   }

The patch looks reasonable to me, but I'm not that much familiar with the 
gdb stuff ... Richard, David, Alex, Christian, any objections? If not, I 
could queue this for my next pull request if nobody else wants to take it.

  Thomas
Re: [PATCH v2] s390x/gdb: Split s390-virt.xml
Posted by David Hildenbrand 1 year ago
On 20.04.23 17:41, Thomas Huth wrote:
> On 14/03/2023 11.18, Ilya Leoshkevich wrote:
>> 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 <iii@linux.ibm.com>
>> Message-Id: <20230313211614.98739-1-iii@linux.ibm.com>
>> ---
>>
>> v1: https://lists.gnu.org/archive/html/qemu-devel/2023-03/msg04307.html
>> v1 -> v2: Improve the naming and the commit message (Christian).
>>
>>    configs/targets/s390x-linux-user.mak |  2 +-
>>    configs/targets/s390x-softmmu.mak    |  2 +-
>>    gdb-xml/s390-virt-kvm.xml            | 14 ++++++
>>    gdb-xml/s390-virt.xml                |  4 --
>>    target/s390x/gdbstub.c               | 65 +++++++++++++++++++---------
>>    5 files changed, 61 insertions(+), 26 deletions(-)
>>    create mode 100644 gdb-xml/s390-virt-kvm.xml
>>
>> diff --git a/configs/targets/s390x-linux-user.mak b/configs/targets/s390x-linux-user.mak
>> index e2978248ede..24c04c85894 100644
>> --- a/configs/targets/s390x-linux-user.mak
>> +++ b/configs/targets/s390x-linux-user.mak
>> @@ -2,4 +2,4 @@ TARGET_ARCH=s390x
>>    TARGET_SYSTBL_ABI=common,64
>>    TARGET_SYSTBL=syscall.tbl
>>    TARGET_BIG_ENDIAN=y
>> -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
>> +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
>> diff --git a/configs/targets/s390x-softmmu.mak b/configs/targets/s390x-softmmu.mak
>> index 258b4cf3582..70d2f9f0ba0 100644
>> --- a/configs/targets/s390x-softmmu.mak
>> +++ b/configs/targets/s390x-softmmu.mak
>> @@ -1,4 +1,4 @@
>>    TARGET_ARCH=s390x
>>    TARGET_BIG_ENDIAN=y
>>    TARGET_SUPPORTS_MTTCG=y
>> -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
>> +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
>> diff --git a/gdb-xml/s390-virt-kvm.xml b/gdb-xml/s390-virt-kvm.xml
>> new file mode 100644
>> index 00000000000..a256eddaf57
>> --- /dev/null
>> +++ b/gdb-xml/s390-virt-kvm.xml
>> @@ -0,0 +1,14 @@
>> +<?xml version="1.0"?>
>> +<!-- Copyright 2023 IBM Corp.
>> +
>> +     This work is licensed under the terms of the GNU GPL, version 2 or
>> +     (at your option) any later version. See the COPYING file in the
>> +     top-level directory. -->
>> +
>> +<!DOCTYPE feature SYSTEM "gdb-target.dtd">
>> +<feature name="org.gnu.gdb.s390.virt.kvm">
>> +  <reg name="pp" bitsize="64" type="uint64" group="system"/>
>> +  <reg name="pfault_token" bitsize="64" type="uint64" group="system"/>
>> +  <reg name="pfault_select" bitsize="64" type="uint64" group="system"/>
>> +  <reg name="pfault_compare" bitsize="64" type="uint64" group="system"/>
>> +</feature>
>> diff --git a/gdb-xml/s390-virt.xml b/gdb-xml/s390-virt.xml
>> index e2e9a7ad3cc..438eb68aabe 100644
>> --- a/gdb-xml/s390-virt.xml
>> +++ b/gdb-xml/s390-virt.xml
>> @@ -11,8 +11,4 @@
>>      <reg name="cputm" bitsize="64" type="uint64" group="system"/>
>>      <reg name="last_break" bitsize="64" type="code_ptr" group="system"/>
>>      <reg name="prefix" bitsize="64" type="data_ptr" group="system"/>
>> -  <reg name="pp" bitsize="64" type="uint64" group="system"/>
>> -  <reg name="pfault_token" bitsize="64" type="uint64" group="system"/>
>> -  <reg name="pfault_select" bitsize="64" type="uint64" group="system"/>
>> -  <reg name="pfault_compare" bitsize="64" type="uint64" group="system"/>
>>    </feature>
>> diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c
>> index a5d69d0e0bc..e1153f5dc4a 100644
>> --- a/target/s390x/gdbstub.c
>> +++ b/target/s390x/gdbstub.c
>> @@ -205,12 +205,8 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
>>    #define S390_VIRT_CPUTM_REGNUM  1
>>    #define S390_VIRT_BEA_REGNUM    2
>>    #define S390_VIRT_PREFIX_REGNUM 3
>> -#define S390_VIRT_PP_REGNUM     4
>> -#define S390_VIRT_PFT_REGNUM    5
>> -#define S390_VIRT_PFS_REGNUM    6
>> -#define S390_VIRT_PFC_REGNUM    7
>>    /* total number of registers in s390-virt.xml */
>> -#define S390_NUM_VIRT_REGS 8
>> +#define S390_NUM_VIRT_REGS 4
>>    
>>    static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int n)
>>    {
>> @@ -223,14 +219,6 @@ static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int n)
>>            return gdb_get_regl(mem_buf, env->gbea);
>>        case S390_VIRT_PREFIX_REGNUM:
>>            return gdb_get_regl(mem_buf, env->psa);
>> -    case S390_VIRT_PP_REGNUM:
>> -        return gdb_get_regl(mem_buf, env->pp);
>> -    case S390_VIRT_PFT_REGNUM:
>> -        return gdb_get_regl(mem_buf, env->pfault_token);
>> -    case S390_VIRT_PFS_REGNUM:
>> -        return gdb_get_regl(mem_buf, env->pfault_select);
>> -    case S390_VIRT_PFC_REGNUM:
>> -        return gdb_get_regl(mem_buf, env->pfault_compare);
>>        default:
>>            return 0;
>>        }
>> @@ -255,19 +243,51 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
>>            env->psa = ldtul_p(mem_buf);
>>            cpu_synchronize_post_init(env_cpu(env));
>>            return 8;
>> -    case S390_VIRT_PP_REGNUM:
>> +    default:
>> +        return 0;
>> +    }
>> +}
>> +
>> +/* the values represent the positions in s390-virt-kvm.xml */
>> +#define S390_VIRT_KVM_PP_REGNUM     0
>> +#define S390_VIRT_KVM_PFT_REGNUM    1
>> +#define S390_VIRT_KVM_PFS_REGNUM    2
>> +#define S390_VIRT_KVM_PFC_REGNUM    3
>> +/* total number of registers in s390-virt-kvm.xml */
>> +#define S390_NUM_VIRT_KVM_REGS 4
>> +
>> +static int cpu_read_virt_kvm_reg(CPUS390XState *env, GByteArray *mem_buf, int n)
>> +{
>> +    switch (n) {
>> +    case S390_VIRT_KVM_PP_REGNUM:
>> +        return gdb_get_regl(mem_buf, env->pp);
>> +    case S390_VIRT_KVM_PFT_REGNUM:
>> +        return gdb_get_regl(mem_buf, env->pfault_token);
>> +    case S390_VIRT_KVM_PFS_REGNUM:
>> +        return gdb_get_regl(mem_buf, env->pfault_select);
>> +    case S390_VIRT_KVM_PFC_REGNUM:
>> +        return gdb_get_regl(mem_buf, env->pfault_compare);
>> +    default:
>> +        return 0;
>> +    }
>> +}
>> +
>> +static int cpu_write_virt_kvm_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
>> +{
>> +    switch (n) {
>> +    case S390_VIRT_KVM_PP_REGNUM:
>>            env->pp = ldtul_p(mem_buf);
>>            cpu_synchronize_post_init(env_cpu(env));
>>            return 8;
>> -    case S390_VIRT_PFT_REGNUM:
>> +    case S390_VIRT_KVM_PFT_REGNUM:
>>            env->pfault_token = ldtul_p(mem_buf);
>>            cpu_synchronize_post_init(env_cpu(env));
>>            return 8;
>> -    case S390_VIRT_PFS_REGNUM:
>> +    case S390_VIRT_KVM_PFS_REGNUM:
>>            env->pfault_select = ldtul_p(mem_buf);
>>            cpu_synchronize_post_init(env_cpu(env));
>>            return 8;
>> -    case S390_VIRT_PFC_REGNUM:
>> +    case S390_VIRT_KVM_PFC_REGNUM:
>>            env->pfault_compare = ldtul_p(mem_buf);
>>            cpu_synchronize_post_init(env_cpu(env));
>>            return 8;
>> @@ -320,10 +340,15 @@ void s390_cpu_gdb_init(CPUState *cs)
>>                                 cpu_write_c_reg,
>>                                 S390_NUM_C_REGS, "s390-cr.xml", 0);
>>    
>> +    gdb_register_coprocessor(cs, cpu_read_virt_reg,
>> +                             cpu_write_virt_reg,
>> +                             S390_NUM_VIRT_REGS, "s390-virt.xml", 0);
>> +
>>        if (kvm_enabled()) {
>> -        gdb_register_coprocessor(cs, cpu_read_virt_reg,
>> -                                 cpu_write_virt_reg,
>> -                                 S390_NUM_VIRT_REGS, "s390-virt.xml", 0);
>> +        gdb_register_coprocessor(cs, cpu_read_virt_kvm_reg,
>> +                                 cpu_write_virt_kvm_reg,
>> +                                 S390_NUM_VIRT_KVM_REGS, "s390-virt-kvm.xml",
>> +                                 0);
>>        }
>>    #endif
>>    }
> 
> The patch looks reasonable to me, but I'm not that much familiar with the
> gdb stuff ... Richard, David, Alex, Christian, any objections? If not, I
> could queue this for my next pull request if nobody else wants to take it.

No objection from my side. Don't have time to try it out, though

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb