aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Farman <farman@linux.vnet.ibm.com>2015-05-07 14:35:44 -0400
committerCornelia Huck <cornelia.huck@de.ibm.com>2015-05-27 17:52:03 +0200
commitc498d8e36e2998fb67de21a34ece633d356a4834 (patch)
tree5b767101eb99af8c7adefdec65cbae2f737325f0
parent0915aed5842bd4dbe396b92d4f3b846ae29ad663 (diff)
s390x: Common access to floating point registers
Provide a routine to access the correct floating point register, to simplify future expansion. Suggested-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
-rw-r--r--linux-user/signal.c4
-rw-r--r--target-s390x/arch_dump.c3
-rw-r--r--target-s390x/cpu.h5
-rw-r--r--target-s390x/gdbstub.c4
-rw-r--r--target-s390x/helper.c2
-rw-r--r--target-s390x/kvm.c9
-rw-r--r--target-s390x/translate.c2
7 files changed, 19 insertions, 10 deletions
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 5bb399e16b..1166f2fdb2 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -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;
diff --git a/target-s390x/arch_dump.c b/target-s390x/arch_dump.c
index a1554f5754..36e8407283 100644
--- a/target-s390x/arch_dump.c
+++ b/target-s390x/arch_dump.c
@@ -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);
}
}
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index c55721114e..e968769e8e 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -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>
diff --git a/target-s390x/gdbstub.c b/target-s390x/gdbstub.c
index 8945f0271d..40bdfe7c65 100644
--- a/target-s390x/gdbstub.c
+++ b/target-s390x/gdbstub.c
@@ -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;
diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index 041c9c7429..6b47766494 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -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]);
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index ea18015793..1a40a94a51 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -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);
diff --git a/target-s390x/translate.c b/target-s390x/translate.c
index 80e3a545e4..96b43b3b6e 100644
--- a/target-s390x/translate.c
+++ b/target-s390x/translate.c
@@ -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 {