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>
This commit is contained in:
parent
0915aed584
commit
c498d8e36e
@ -4098,7 +4098,7 @@ static void save_sigregs(CPUS390XState *env, target_sigregs *sregs)
|
||||
*/
|
||||
//save_fp_regs(¤t->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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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]);
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user