Skip to contentSkip to conversation

s390x: SIMD support

GIT PULL Applied Cornelia Huck 2 participants 12 messages May 28, 2015

lore
Share & tools
lore
#1 lore raw

[Qemu-devel] [PULL 03/10] s390x: Store Additional Status SIGP order

In reply to Cornelia Huck

From: Eric Farman <[email protected]>

Add handling for the Store Additional Status at Address order that exists for the Signal Processor (SIGP) instruction.

---
 target-s390x/cpu.h |  1 +
 target-s390x/kvm.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
target-s390x/cpu.h +1 -0
index 708349c..031f94d 100644
@@ -945,6 +945,7 @@ struct sysib_322 {
 #define SIGP_SET_PREFIX        0x0d
 #define SIGP_STORE_STATUS_ADDR 0x0e
 #define SIGP_SET_ARCH          0x12
+#define SIGP_STORE_ADTL_STATUS 0x17
 
 /* SIGP condition codes */
 #define SIGP_CC_ORDER_CODE_ACCEPTED 0
target-s390x/kvm.c +55 -0

73 lines not on this page · raw message

Signature · 1 line
2.4.2
#0 lore raw

The following changes since commit 0915aed5842bd4dbe396b92d4f3b846ae29ad663:

Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging (2015-05-26 11:31:03 +0100)

are available in the git repository at:

git://github.com/cohuck/qemu tags/s390x-20150528

for you to fetch changes up to 46ca6b3bc99ebf9205e28ed14c023ebf84d39bb7:

s390x: Enable vector processing capability (2015-05-27 17:52:04 +0200)

----------------------------------------------------------------
A set of patches add support for vector registers on s390x.
Notable: Floating point registers and vector registers overlap, so extra care is needed so that we end up with a consistent state in all cases.

----------------------------------------------------------------

Eric Farman (10):
s390x: Common access to floating point registers
s390x: Vector Register IOCTLs
s390x: Store Additional Status SIGP order
gdb-xml: Include XML for s390 vector registers
s390x: gdb updates for vector registers
s390x: Add vector registers to HMP output linux/elf.h update
s390x: Add vector registers to ELF dump
s390x: Migrate vector registers
s390x: Enable vector processing capability

 configure                |   2 +-
 gdb-xml/s390-vx.xml      |  59 +++++++++++++++++++++++++
 include/elf.h            |   2 +
 linux-user/signal.c      |   4 +-
 target-s390x/arch_dump.c |  42 +++++++++++++++++-
 target-s390x/cpu.h       |  26 ++++++++++-
 target-s390x/gdbstub.c   |  50 ++++++++++++++++++++-
 target-s390x/helper.c    |   2 +-
 target-s390x/kvm.c       | 110 +++++++++++++++++++++++++++++++++++++++--------
 target-s390x/machine.c   |  93 ++++++++++++++++++++++++++++++++-------
 target-s390x/translate.c |  10 ++++-
 11 files changed, 357 insertions(+), 43 deletions(-)
 create mode 100644 gdb-xml/s390-vx.xml
Signature · 1 line
2.4.2
#2 lore raw

[Qemu-devel] [PULL 10/10] s390x: Enable vector processing capability

From: Eric Farman <[email protected]>

Everything is finally in place, inform the kernel that user space supports vector registers.

---
 target-s390x/kvm.c | 1 +
 1 file changed, 1 insertion(+)
target-s390x/kvm.c +1 -0
index 61e1321..6de7759 100644
@@ -269,6 +269,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
     }
 
     kvm_vm_enable_cap(s, KVM_CAP_S390_USER_SIGP, 0);
+    kvm_vm_enable_cap(s, KVM_CAP_S390_VECTOR_REGISTERS, 0);
     kvm_vm_enable_cap(s, KVM_CAP_S390_USER_STSI, 0);
 
     return 0;
Signature · 1 line
2.4.2
#3 lore raw

[Qemu-devel] [PULL 04/10] gdb-xml: Include XML for s390 vector registers

In reply to Cornelia Huck

From: Eric Farman <[email protected]>

Include the vector registers XML file that is provided by gdb, and can be used by the qemu gdbserver interface.

---
 gdb-xml/s390-vx.xml | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 gdb-xml/s390-vx.xml
gdb-xml/s390-vx.xml new file +59 -0
new file mode 100644
index 0000000..8239c11
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2010-2014 Free Software Foundation, Inc.
+
+     Copying and distribution of this file, with or without modification,
+     are permitted in any medium without royalty provided the copyright
+     notice and this notice are preserved.  -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.s390.vx">
+  <vector id="v4f" type="ieee_single" count="4"/>
+  <vector id="v2d" type="ieee_double" count="2"/>
+  <vector id="v16i8" type="int8" count="16"/>
+  <vector id="v8i16" type="int16" count="8"/>
+  <vector id="v4i32" type="int32" count="4"/>
+  <vector id="v2i64" type="int64" count="2"/>
+  <union id="vec128">
+    <field name="v4_float" type="v4f"/>
+    <field name="v2_double" type="v2d"/>
+    <field name="v16_int8" type="v16i8"/>
+    <field name="v8_int16" type="v8i16"/>
+    <field name="v4_int32" type="v4i32"/>
+    <field name="v2_int64" type="v2i64"/>
+    <field name="uint128" type="uint128"/>
+  </union>
+
+  <reg name="v0l" bitsize="64" type="uint64"/>
+  <reg name="v1l" bitsize="64" type="uint64"/>
+  <reg name="v2l" bitsize="64" type="uint64"/>
+  <reg name="v3l" bitsize="64" type="uint64"/>
+  <reg name="v4l" bitsize="64" type="uint64"/>
+  <reg name="v5l" bitsize="64" type="uint64"/>
+  <reg name="v6l" bitsize="64" type="uint64"/>
+  <reg name="v7l" bitsize="64" type="uint64"/>
+  <reg name="v8l" bitsize="64" type="uint64"/>
+  <reg name="v9l" bitsize="64" type="uint64"/>
+  <reg name="v10l" bitsize="64" type="uint64"/>
+  <reg name="v11l" bitsize="64" type="uint64"/>
+  <reg name="v12l" bitsize="64" type="uint64"/>
+  <reg name="v13l" bitsize="64" type="uint64"/>
+  <reg name="v14l" bitsize="64" type="uint64"/>
+  <reg name="v15l" bitsize="64" type="uint64"/>
+
+  <reg name="v16" bitsize="128" type="vec128"/>
+  <reg name="v17" bitsize="128" type="vec128"/>
+  <reg name="v18" bitsize="128" type="vec128"/>
+  <reg name="v19" bitsize="128" type="vec128"/>
+  <reg name="v20" bitsize="128" type="vec128"/>
+  <reg name="v21" bitsize="128" type="vec128"/>
+  <reg name="v22" bitsize="128" type="vec128"/>
+  <reg name="v23" bitsize="128" type="vec128"/>
+  <reg name="v24" bitsize="128" type="vec128"/>
+  <reg name="v25" bitsize="128" type="vec128"/>
+  <reg name="v26" bitsize="128" type="vec128"/>
+  <reg name="v27" bitsize="128" type="vec128"/>
+  <reg name="v28" bitsize="128" type="vec128"/>
+  <reg name="v29" bitsize="128" type="vec128"/>
+  <reg name="v30" bitsize="128" type="vec128"/>
+  <reg name="v31" bitsize="128" type="vec128"/>
+</feature>
Signature · 1 line
2.4.2
#4 lore raw

[Qemu-devel] [PULL 05/10] s390x: gdb updates for vector registers

In reply to Cornelia Huck

From: Eric Farman <[email protected]>

gdb allows registers to be displayed/modified, and is being updated to account for the new vector registers. Mirror these changes in the gdb stub in qemu so that this can be performed when gdb is attached to the qemu gdbserver.

---
 configure              |  2 +-
 target-s390x/gdbstub.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
configure +1 -1
index 9852aef..b707429 100755
@@ -5292,7 +5292,7 @@ case "$target_name" in
     echo "TARGET_ABI32=y" >> $config_target_mak
   ;;
   s390x)
-    gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml"
+    gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml"
   ;;
   tricore)
   ;;
target-s390x/gdbstub.c +46 -0

56 lines not on this page · raw message

Signature · 1 line
2.4.2
#5 lore raw

[Qemu-devel] [PULL 06/10] s390x: Add vector registers to HMP output

In reply to Cornelia Huck

From: Eric Farman <[email protected]>

There are mechanisms to dump registers via the qemu HMP interface, such as the "info registers" command. Expand this output to dump the new vector registers.

---
 target-s390x/translate.c | 6 ++++++
 1 file changed, 6 insertions(+)
target-s390x/translate.c +6 -0
index 06fc192..fbffd30 100644
@@ -121,6 +121,12 @@ void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
         }
     }
 
+    for (i = 0; i < 32; i++) {
+        cpu_fprintf(f, "V%02d=%016" PRIx64 "%016" PRIx64, i,
+                    env->vregs[i][0].ll, env->vregs[i][1].ll);
+        cpu_fprintf(f, (i % 2) ? " " : "\n");
+    }
+
 #ifndef CONFIG_USER_ONLY
     for (i = 0; i < 16; i++) {
         cpu_fprintf(f, "C%02d=%016" PRIx64, i, env->cregs[i]);
Signature · 1 line
2.4.2
#6 lore raw

[Qemu-devel] [PULL 07/10] linux/elf.h update

In reply to Cornelia Huck

From: Eric Farman <[email protected]>

Sync with kernel elf.h updates to get s390x vector register definitions.

---
 include/elf.h | 2 ++
 1 file changed, 2 insertions(+)
include/elf.h +2 -0
index 3e75f05..4afd474 100644
@@ -1456,6 +1456,8 @@ typedef struct elf64_shdr {
 #define NT_TASKSTRUCT	4
 #define NT_AUXV		6
 #define NT_PRXFPREG     0x46e62b7f      /* copied from gdb5.1/include/elf/common.h */
+#define NT_S390_VXRS_HIGH 0x30a         /* s390 vector registers 16-31 */
+#define NT_S390_VXRS_LOW  0x309         /* s390 vector registers 0-15 (lower half) */
 #define NT_S390_PREFIX  0x305           /* s390 prefix register */
 #define NT_S390_CTRS    0x304           /* s390 control registers */
 #define NT_S390_TODPREG 0x303           /* s390 TOD programmable register */
Signature · 1 line
2.4.2
#7 lore raw

[Qemu-devel] [PULL 09/10] s390x: Migrate vector registers

In reply to Cornelia Huck

From: Eric Farman <[email protected]>

When migrating a guest, be sure to include the vector registers. The vector registers are defined in a subsection, similar to the existing subsection for floating point registers. Since the floating point registers are always present (and thus migrated), we can skip them when performing the migration of the vector registers which may or may not be present.

---
 target-s390x/cpu.h     | 14 ++++++++++++
 target-s390x/machine.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
target-s390x/cpu.h +14 -0
index 031f94d..a71abae 100644
@@ -1190,4 +1190,18 @@ static inline int s390_assign_subch_ioeventfd(EventNotifier *notifier,
     }
 }
 
+#ifdef CONFIG_KVM
+static inline bool vregs_needed(void *opaque)
+{
+    if (kvm_enabled()) {
+        return kvm_check_extension(kvm_state, KVM_CAP_S390_VECTOR_REGISTERS);
+    }
+    return 0;
+}
+#else
+static inline bool vregs_needed(void *opaque)
+{
+    return 0;
+}
+#endif
 #endif
target-s390x/machine.c +61 -0

73 lines not on this page · raw message

Signature · 1 line
2.4.2
#8 lore raw

[Qemu-devel] [PULL 01/10] s390x: Common access to floating point registers

In reply to Cornelia Huck

From: Eric Farman <[email protected]>

Provide a routine to access the correct floating point register, to simplify future expansion.

---
 linux-user/signal.c      | 4 ++--
 target-s390x/arch_dump.c | 3 ++-
 target-s390x/cpu.h       | 5 +++++
 target-s390x/gdbstub.c   | 4 ++--
 target-s390x/helper.c    | 2 +-
 target-s390x/kvm.c       | 9 ++++++---
 target-s390x/translate.c | 2 +-
 7 files changed, 19 insertions(+), 10 deletions(-)
linux-user/signal.c +2 -2
index 5bb399e..1166f2f 100644
@@ -4098,7 +4098,7 @@ static void save_sigregs(CPUS390XState *env, target_sigregs *sregs)
      */
     //save_fp_regs(&current->thread.fp_regs); FIXME
     for (i = 0; i < 16; i++) {
-        __put_user(env->fregs[i].ll, &sregs->fpregs.fprs[i]);
+        __put_user(get_freg(env, i)->ll, &sregs->fpregs.fprs[i]);
     }
 }
 
@@ -4239,7 +4239,7 @@ restore_sigregs(CPUS390XState *env, target_sigregs *sc)
         __get_user(env->aregs[i], &sc->regs.acrs[i]);
     }
     for (i = 0; i < 16; i++) {
-        __get_user(env->fregs[i].ll, &sc->fpregs.fprs[i]);
+        __get_user(get_freg(env, i)->ll, &sc->fpregs.fprs[i]);
     }
 
     return err;
target-s390x/arch_dump.c +2 -1
index a1554f5..36e8407 100644
@@ -78,11 +78,12 @@ static void s390x_write_elf64_prstatus(Note *note, S390CPU *cpu)
 static void s390x_write_elf64_fpregset(Note *note, S390CPU *cpu)
 {
     int i;
+    CPUS390XState *cs = &cpu->env;
 
     note->hdr.n_type = cpu_to_be32(NT_FPREGSET);
     note->contents.fpregset.fpc = cpu_to_be32(cpu->env.fpc);
     for (i = 0; i <= 15; i++) {
-        note->contents.fpregset.fprs[i] = cpu_to_be64(cpu->env.fregs[i].ll);
+        note->contents.fpregset.fprs[i] = cpu_to_be64(get_freg(cs, i)->ll);
     }
 }
 
target-s390x/cpu.h +5 -0
index c557211..e968769 100644
@@ -162,6 +162,11 @@ typedef struct CPUS390XState {
 
 } CPUS390XState;
 
+static inline CPU_DoubleU *get_freg(CPUS390XState *cs, int nr)
+{
+    return &cs->fregs[nr];
+}
+
 #include "cpu-qom.h"
 #include <sysemu/kvm.h>
 
target-s390x/gdbstub.c +2 -2
index 8945f02..40bdfe7 100644
@@ -111,7 +111,7 @@ static int cpu_read_fp_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
     case S390_FPC_REGNUM:
         return gdb_get_reg32(mem_buf, env->fpc);
     case S390_F0_REGNUM ... S390_F15_REGNUM:
-        return gdb_get_reg64(mem_buf, env->fregs[n - S390_F0_REGNUM].ll);
+        return gdb_get_reg64(mem_buf, get_freg(env, n - S390_F0_REGNUM)->ll);
     default:
         return 0;
     }
@@ -124,7 +124,7 @@ static int cpu_write_fp_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
         env->fpc = ldl_p(mem_buf);
         return 4;
     case S390_F0_REGNUM ... S390_F15_REGNUM:
-        env->fregs[n - S390_F0_REGNUM].ll = ldtul_p(mem_buf);
+        get_freg(env, n - S390_F0_REGNUM)->ll = ldtul_p(mem_buf);
         return 8;
     default:
         return 0;
target-s390x/helper.c +1 -1
index 041c9c7..6b47766 100644
@@ -445,7 +445,7 @@ static void do_mchk_interrupt(CPUS390XState *env)
     lowcore = cpu_map_lowcore(env);
 
     for (i = 0; i < 16; i++) {
-        lowcore->floating_pt_save_area[i] = cpu_to_be64(env->fregs[i].ll);
+        lowcore->floating_pt_save_area[i] = cpu_to_be64(get_freg(env, i)->ll);
         lowcore->gpregs_save_area[i] = cpu_to_be64(env->regs[i]);
         lowcore->access_regs_save_area[i] = cpu_to_be32(env->aregs[i]);
         lowcore->cregs_save_area[i] = cpu_to_be64(env->cregs[i]);
target-s390x/kvm.c +6 -3
index ea18015..1a40a94 100644
@@ -339,7 +339,7 @@ int kvm_arch_put_registers(CPUState *cs, int level)
 
     /* Floating point */
     for (i = 0; i < 16; i++) {
-        fpu.fprs[i] = env->fregs[i].ll;
+        fpu.fprs[i] = get_freg(env, i)->ll;
     }
     fpu.fpc = env->fpc;
 
@@ -474,7 +474,7 @@ int kvm_arch_get_registers(CPUState *cs)
         return r;
     }
     for (i = 0; i < 16; i++) {
-        env->fregs[i].ll = fpu.fprs[i];
+        get_freg(env, i)->ll = fpu.fprs[i];
     }
     env->fpc = fpu.fpc;
 
@@ -1363,6 +1363,7 @@ static int kvm_s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch)
     static const uint8_t ar_id = 1;
     uint64_t ckc = cpu->env.ckc >> 8;
     void *mem;
+    int i;
     hwaddr len = SAVE_AREA_SIZE;
 
     mem = cpu_physical_memory_map(addr, &len, 1);
@@ -1377,7 +1378,9 @@ static int kvm_s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch)
     if (store_arch) {
         cpu_physical_memory_write(offsetof(LowCore, ar_access_id), &ar_id, 1);
     }
-    memcpy(mem, &cpu->env.fregs, 128);
+    for (i = 0; i < 16; ++i) {
+        *((uint64 *)mem + i) = get_freg(&cpu->env, i)->ll;
+    }
     memcpy(mem + 128, &cpu->env.regs, 128);
     memcpy(mem + 256, &cpu->env.psw, 16);
     memcpy(mem + 280, &cpu->env.psa, 4);
target-s390x/translate.c +1 -1
index 80e3a54..96b43b3 100644
@@ -113,7 +113,7 @@ void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
     }
 
     for (i = 0; i < 16; i++) {
-        cpu_fprintf(f, "F%02d=%016" PRIx64, i, env->fregs[i].ll);
+        cpu_fprintf(f, "F%02d=%016" PRIx64, i, get_freg(env, i)->ll);
         if ((i % 4) == 3) {
             cpu_fprintf(f, "\n");
         } else {
Signature · 1 line
2.4.2
#9 lore raw

[Qemu-devel] [PULL 02/10] s390x: Vector Register IOCTLs

In reply to Cornelia Huck

From: Eric Farman <[email protected]>

Handle the actual syncing of the vector registers with kernel space, via the get/put register IOCTLs.

The vector registers that were introduced with the z13 overlay the existing floating point registers. FP registers 0-15 are the high-halves of vector registers 0-15. Thus, remove the freg fields and replace them with the equivalent vector field to avoid errors in duplication. Moreover, synchronize either the vector registers via kvm_sync_regs, or floating point registers via the GET/SET FPU IOCTLs.

---
 target-s390x/cpu.h       |  8 ++++++--
 target-s390x/kvm.c       | 49 ++++++++++++++++++++++++++++++++----------------
 target-s390x/machine.c   | 32 +++++++++++++++----------------
 target-s390x/translate.c |  2 +-
 4 files changed, 56 insertions(+), 35 deletions(-)
target-s390x/cpu.h +6 -2
index e968769..708349c 100644
@@ -81,7 +81,11 @@ typedef struct MchkQueue {
 
 typedef struct CPUS390XState {
     uint64_t regs[16];     /* GP registers */
-    CPU_DoubleU fregs[16]; /* FP registers */
+    /*
+     * The floating point registers are part of the vector registers.
+     * vregs[0][0] -> vregs[15][0] are 16 floating point registers
+     */
+    CPU_DoubleU vregs[32][2];  /* vector registers */
     uint32_t aregs[16];    /* access registers */
 
     uint32_t fpc;          /* floating-point control register */
@@ -164,7 +168,7 @@ typedef struct CPUS390XState {
 
 static inline CPU_DoubleU *get_freg(CPUS390XState *cs, int nr)
 {
-    return &cs->fregs[nr];
+    return &cs->vregs[nr][0];
 }
 
 #include "cpu-qom.h"
target-s390x/kvm.c +33 -16

63 lines not on this page · raw message

target-s390x/machine.c +16 -16
index 7853e3c..1a9390b 100644
@@ -47,22 +47,22 @@ const VMStateDescription vmstate_fpu = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_UINT64(env.fregs[0].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[1].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[2].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[3].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[4].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[5].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[6].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[7].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[8].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[9].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[10].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[11].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[12].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[13].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[14].ll, S390CPU),
-        VMSTATE_UINT64(env.fregs[15].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[0][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[1][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[2][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[3][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[4][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[5][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[6][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[7][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[8][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[9][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[10][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[11][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[12][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[13][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[14][0].ll, S390CPU),
+        VMSTATE_UINT64(env.vregs[15][0].ll, S390CPU),
         VMSTATE_UINT32(env.fpc, S390CPU),
         VMSTATE_END_OF_LIST()
     }
target-s390x/translate.c +1 -1
index 96b43b3..06fc192 100644
@@ -187,7 +187,7 @@ void s390x_translate_init(void)
     for (i = 0; i < 16; i++) {
         snprintf(cpu_reg_names[i + 16], sizeof(cpu_reg_names[0]), "f%d", i);
         fregs[i] = tcg_global_mem_new(TCG_AREG0,
-                                      offsetof(CPUS390XState, fregs[i].d),
+                                      offsetof(CPUS390XState, vregs[i][0].d),
                                       cpu_reg_names[i + 16]);
     }
 }
Signature · 1 line
2.4.2
#10 lore raw

[Qemu-devel] [PULL 08/10] s390x: Add vector registers to ELF dump

In reply to Cornelia Huck

From: Eric Farman <[email protected]>

Create ELF notes for the vector registers where applicable, so that their contents can be examined by utilities such as crash or readelf.

---
 target-s390x/arch_dump.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
target-s390x/arch_dump.c +39 -0
index 36e8407..dab63eb 100644
@@ -44,6 +44,18 @@ struct S390xElfFpregsetStruct {
 
 typedef struct S390xElfFpregsetStruct S390xElfFpregset;
 
+struct S390xElfVregsLoStruct {
+    uint64_t vregs[16];
+} QEMU_PACKED;
+
+typedef struct S390xElfVregsLoStruct S390xElfVregsLo;
+
+struct S390xElfVregsHiStruct {
+    uint64_t vregs[16][2];
+} QEMU_PACKED;
+
+typedef struct S390xElfVregsHiStruct S390xElfVregsHi;
+
 typedef struct noteStruct {
     Elf64_Nhdr hdr;
     char name[5];
@@ -51,6 +63,8 @@ typedef struct noteStruct {
     union {
         S390xElfPrstatus prstatus;
         S390xElfFpregset fpregset;
+        S390xElfVregsLo vregslo;
+        S390xElfVregsHi vregshi;
         uint32_t prefix;
         uint64_t timer;
         uint64_t todcmp;
@@ -87,6 +101,29 @@ static void s390x_write_elf64_fpregset(Note *note, S390CPU *cpu)
     }
 }
 
+static void s390x_write_elf64_vregslo(Note *note, S390CPU *cpu)
+{
+    int i;
+
+    note->hdr.n_type = cpu_to_be32(NT_S390_VXRS_LOW);
+    for (i = 0; i <= 15; i++) {
+        note->contents.vregslo.vregs[i] = cpu_to_be64(cpu->env.vregs[i][1].ll);
+    }
+}
+
+static void s390x_write_elf64_vregshi(Note *note, S390CPU *cpu)
+{
+    int i;
+    S390xElfVregsHi *temp_vregshi;
+
+    temp_vregshi = &note->contents.vregshi;
+
+    note->hdr.n_type = cpu_to_be32(NT_S390_VXRS_HIGH);
+    for (i = 0; i <= 15; i++) {
+        temp_vregshi->vregs[i][0] = cpu_to_be64(cpu->env.vregs[i + 16][0].ll);
+        temp_vregshi->vregs[i][1] = cpu_to_be64(cpu->env.vregs[i + 16][1].ll);
+    }
+}
 
 static void s390x_write_elf64_timer(Note *note, S390CPU *cpu)
 {
@@ -135,6 +172,8 @@ static const struct NoteFuncDescStruct {
     {sizeof(((Note *)0)->contents.timer),    s390x_write_elf64_timer},
     {sizeof(((Note *)0)->contents.todcmp),   s390x_write_elf64_todcmp},
     {sizeof(((Note *)0)->contents.todpreg),  s390x_write_elf64_todpreg},
+    {sizeof(((Note *)0)->contents.vregslo),  s390x_write_elf64_vregslo},
+    {sizeof(((Note *)0)->contents.vregshi),  s390x_write_elf64_vregshi},
     { 0, NULL}
 };
 
Signature · 1 line
2.4.2
#11 lore raw
In reply to Cornelia Huck
Quoted 10 lines · Cornelia Huck

The following changes since commit 0915aed5842bd4dbe396b92d4f3b846ae29ad663:

Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging (2015-05-26 11:31:03 +0100)

are available in the git repository at:

git://github.com/cohuck/qemu tags/s390x-20150528

for you to fetch changes up to 46ca6b3bc99ebf9205e28ed14c023ebf84d39bb7:

Quoted 7 lines

s390x: Enable vector processing capability (2015-05-27 17:52:04 +0200)

----------------------------------------------------------------
A set of patches add support for vector registers on s390x.
Notable: Floating point registers and vector registers overlap, so extra care is needed so that we end up with a consistent state in all cases.

Applied, thanks.

-- PMM