s390x: Use uint64_t for vector registers

CPU_DoubleU is primarily used to reinterpret between integer and floats.
We don't really need this functionality. So let's just keep it simple
and use an uint64_t.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
This commit is contained in:
David Hildenbrand 2019-05-29 09:15:38 +02:00
parent ec8e23e37f
commit 4f83d7d212
9 changed files with 97 additions and 97 deletions

View file

@ -123,7 +123,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(get_freg(env, i)->ll, &sregs->fpregs.fprs[i]);
__put_user(*get_freg(env, i), &sregs->fpregs.fprs[i]);
}
}
@ -254,7 +254,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(get_freg(env, i)->ll, &sc->fpregs.fprs[i]);
__get_user(*get_freg(env, i), &sc->fpregs.fprs[i]);
}
return err;

View file

@ -104,7 +104,7 @@ static void s390x_write_elf64_fpregset(Note *note, S390CPU *cpu, int id)
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(get_freg(cs, i)->ll);
note->contents.fpregset.fprs[i] = cpu_to_be64(*get_freg(cs, i));
}
}
@ -114,7 +114,7 @@ static void s390x_write_elf64_vregslo(Note *note, S390CPU *cpu, int id)
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);
note->contents.vregslo.vregs[i] = cpu_to_be64(cpu->env.vregs[i][1]);
}
}
@ -127,8 +127,8 @@ static void s390x_write_elf64_vregshi(Note *note, S390CPU *cpu, int id)
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);
temp_vregshi->vregs[i][0] = cpu_to_be64(cpu->env.vregs[i + 16][0]);
temp_vregshi->vregs[i][1] = cpu_to_be64(cpu->env.vregs[i + 16][1]);
}
}

View file

@ -66,7 +66,7 @@ struct CPUS390XState {
* 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] QEMU_ALIGNED(16); /* vector registers */
uint64_t vregs[32][2] QEMU_ALIGNED(16); /* vector registers */
uint32_t aregs[16]; /* access registers */
uint8_t riccb[64]; /* runtime instrumentation control */
uint64_t gscb[4]; /* guarded storage control */
@ -153,7 +153,7 @@ struct CPUS390XState {
};
static inline CPU_DoubleU *get_freg(CPUS390XState *cs, int nr)
static inline uint64_t *get_freg(CPUS390XState *cs, int nr)
{
return &cs->vregs[nr][0];
}

View file

@ -390,8 +390,8 @@ static int mchk_store_vregs(CPUS390XState *env, uint64_t mcesao)
}
for (i = 0; i < 32; i++) {
sa->vregs[i][0] = cpu_to_be64(env->vregs[i][0].ll);
sa->vregs[i][1] = cpu_to_be64(env->vregs[i][1].ll);
sa->vregs[i][0] = cpu_to_be64(env->vregs[i][0]);
sa->vregs[i][1] = cpu_to_be64(env->vregs[i][1]);
}
cpu_physical_memory_unmap(sa, len, 1, len);
@ -429,7 +429,7 @@ static void do_mchk_interrupt(CPUS390XState *env)
lowcore->ar_access_id = 1;
for (i = 0; i < 16; i++) {
lowcore->floating_pt_save_area[i] = cpu_to_be64(get_freg(env, i)->ll);
lowcore->floating_pt_save_area[i] = cpu_to_be64(*get_freg(env, i));
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]);

View file

@ -116,7 +116,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, get_freg(env, n - S390_F0_REGNUM)->ll);
return gdb_get_reg64(mem_buf, *get_freg(env, n - S390_F0_REGNUM));
default:
return 0;
}
@ -129,7 +129,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:
get_freg(env, n - S390_F0_REGNUM)->ll = ldtul_p(mem_buf);
*get_freg(env, n - S390_F0_REGNUM) = ldtul_p(mem_buf);
return 8;
default:
return 0;
@ -150,11 +150,11 @@ static int cpu_read_vreg(CPUS390XState *env, uint8_t *mem_buf, int n)
switch (n) {
case S390_V0L_REGNUM ... S390_V15L_REGNUM:
ret = gdb_get_reg64(mem_buf, env->vregs[n][1].ll);
ret = gdb_get_reg64(mem_buf, env->vregs[n][1]);
break;
case S390_V16_REGNUM ... S390_V31_REGNUM:
ret = gdb_get_reg64(mem_buf, env->vregs[n][0].ll);
ret += gdb_get_reg64(mem_buf + 8, env->vregs[n][1].ll);
ret = gdb_get_reg64(mem_buf, env->vregs[n][0]);
ret += gdb_get_reg64(mem_buf + 8, env->vregs[n][1]);
break;
default:
ret = 0;
@ -167,11 +167,11 @@ static int cpu_write_vreg(CPUS390XState *env, uint8_t *mem_buf, int n)
{
switch (n) {
case S390_V0L_REGNUM ... S390_V15L_REGNUM:
env->vregs[n][1].ll = ldtul_p(mem_buf + 8);
env->vregs[n][1] = ldtul_p(mem_buf + 8);
return 8;
case S390_V16_REGNUM ... S390_V31_REGNUM:
env->vregs[n][0].ll = ldtul_p(mem_buf);
env->vregs[n][1].ll = ldtul_p(mem_buf + 8);
env->vregs[n][0] = ldtul_p(mem_buf);
env->vregs[n][1] = ldtul_p(mem_buf + 8);
return 16;
default:
return 0;

View file

@ -249,7 +249,7 @@ int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch)
cpu_physical_memory_write(offsetof(LowCore, ar_access_id), &ar_id, 1);
}
for (i = 0; i < 16; ++i) {
sa->fprs[i] = cpu_to_be64(get_freg(&cpu->env, i)->ll);
sa->fprs[i] = cpu_to_be64(*get_freg(&cpu->env, i));
}
for (i = 0; i < 16; ++i) {
sa->grs[i] = cpu_to_be64(cpu->env.regs[i]);
@ -299,8 +299,8 @@ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len)
if (s390_has_feat(S390_FEAT_VECTOR)) {
for (i = 0; i < 32; i++) {
sa->vregs[i][0] = cpu_to_be64(cpu->env.vregs[i][0].ll);
sa->vregs[i][1] = cpu_to_be64(cpu->env.vregs[i][1].ll);
sa->vregs[i][0] = cpu_to_be64(cpu->env.vregs[i][0]);
sa->vregs[i][1] = cpu_to_be64(cpu->env.vregs[i][1]);
}
}
if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && len >= ADTL_GS_MIN_SIZE) {
@ -341,13 +341,13 @@ void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags)
if (s390_has_feat(S390_FEAT_VECTOR)) {
for (i = 0; i < 32; i++) {
qemu_fprintf(f, "V%02d=%016" PRIx64 "%016" PRIx64 "%c",
i, env->vregs[i][0].ll, env->vregs[i][1].ll,
i, env->vregs[i][0], env->vregs[i][1],
i % 2 ? '\n' : ' ');
}
} else {
for (i = 0; i < 16; i++) {
qemu_fprintf(f, "F%02d=%016" PRIx64 "%c",
i, get_freg(env, i)->ll,
i, *get_freg(env, i),
(i % 4) == 3 ? '\n' : ' ');
}
}

View file

@ -418,21 +418,21 @@ int kvm_arch_put_registers(CPUState *cs, int level)
if (can_sync_regs(cs, KVM_SYNC_VRS)) {
for (i = 0; i < 32; i++) {
cs->kvm_run->s.regs.vrs[i][0] = env->vregs[i][0].ll;
cs->kvm_run->s.regs.vrs[i][1] = env->vregs[i][1].ll;
cs->kvm_run->s.regs.vrs[i][0] = env->vregs[i][0];
cs->kvm_run->s.regs.vrs[i][1] = env->vregs[i][1];
}
cs->kvm_run->s.regs.fpc = env->fpc;
cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_VRS;
} else if (can_sync_regs(cs, KVM_SYNC_FPRS)) {
for (i = 0; i < 16; i++) {
cs->kvm_run->s.regs.fprs[i] = get_freg(env, i)->ll;
cs->kvm_run->s.regs.fprs[i] = *get_freg(env, i);
}
cs->kvm_run->s.regs.fpc = env->fpc;
cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_FPRS;
} else {
/* Floating point */
for (i = 0; i < 16; i++) {
fpu.fprs[i] = get_freg(env, i)->ll;
fpu.fprs[i] = *get_freg(env, i);
}
fpu.fpc = env->fpc;
@ -586,13 +586,13 @@ int kvm_arch_get_registers(CPUState *cs)
/* Floating point and vector registers */
if (can_sync_regs(cs, KVM_SYNC_VRS)) {
for (i = 0; i < 32; i++) {
env->vregs[i][0].ll = cs->kvm_run->s.regs.vrs[i][0];
env->vregs[i][1].ll = cs->kvm_run->s.regs.vrs[i][1];
env->vregs[i][0] = cs->kvm_run->s.regs.vrs[i][0];
env->vregs[i][1] = cs->kvm_run->s.regs.vrs[i][1];
}
env->fpc = cs->kvm_run->s.regs.fpc;
} else if (can_sync_regs(cs, KVM_SYNC_FPRS)) {
for (i = 0; i < 16; i++) {
get_freg(env, i)->ll = cs->kvm_run->s.regs.fprs[i];
*get_freg(env, i) = cs->kvm_run->s.regs.fprs[i];
}
env->fpc = cs->kvm_run->s.regs.fpc;
} else {
@ -601,7 +601,7 @@ int kvm_arch_get_registers(CPUState *cs)
return r;
}
for (i = 0; i < 16; i++) {
get_freg(env, i)->ll = fpu.fprs[i];
*get_freg(env, i) = fpu.fprs[i];
}
env->fpc = fpu.fpc;
}

View file

@ -66,22 +66,22 @@ static const VMStateDescription vmstate_fpu = {
.minimum_version_id = 1,
.needed = fpu_needed,
.fields = (VMStateField[]) {
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_UINT64(env.vregs[0][0], S390CPU),
VMSTATE_UINT64(env.vregs[1][0], S390CPU),
VMSTATE_UINT64(env.vregs[2][0], S390CPU),
VMSTATE_UINT64(env.vregs[3][0], S390CPU),
VMSTATE_UINT64(env.vregs[4][0], S390CPU),
VMSTATE_UINT64(env.vregs[5][0], S390CPU),
VMSTATE_UINT64(env.vregs[6][0], S390CPU),
VMSTATE_UINT64(env.vregs[7][0], S390CPU),
VMSTATE_UINT64(env.vregs[8][0], S390CPU),
VMSTATE_UINT64(env.vregs[9][0], S390CPU),
VMSTATE_UINT64(env.vregs[10][0], S390CPU),
VMSTATE_UINT64(env.vregs[11][0], S390CPU),
VMSTATE_UINT64(env.vregs[12][0], S390CPU),
VMSTATE_UINT64(env.vregs[13][0], S390CPU),
VMSTATE_UINT64(env.vregs[14][0], S390CPU),
VMSTATE_UINT64(env.vregs[15][0], S390CPU),
VMSTATE_UINT32(env.fpc, S390CPU),
VMSTATE_END_OF_LIST()
}
@ -99,54 +99,54 @@ static const VMStateDescription vmstate_vregs = {
.needed = vregs_needed,
.fields = (VMStateField[]) {
/* vregs[0][0] -> vregs[15][0] and fregs are overlays */
VMSTATE_UINT64(env.vregs[16][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[17][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[18][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[19][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[20][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[21][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[22][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[23][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[24][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[25][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[26][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[27][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[28][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[29][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[30][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[31][0].ll, S390CPU),
VMSTATE_UINT64(env.vregs[0][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[1][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[2][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[3][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[4][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[5][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[6][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[7][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[8][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[9][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[10][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[11][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[12][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[13][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[14][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[15][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[16][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[17][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[18][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[19][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[20][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[21][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[22][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[23][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[24][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[25][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[26][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[27][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[28][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[29][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[30][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[31][1].ll, S390CPU),
VMSTATE_UINT64(env.vregs[16][0], S390CPU),
VMSTATE_UINT64(env.vregs[17][0], S390CPU),
VMSTATE_UINT64(env.vregs[18][0], S390CPU),
VMSTATE_UINT64(env.vregs[19][0], S390CPU),
VMSTATE_UINT64(env.vregs[20][0], S390CPU),
VMSTATE_UINT64(env.vregs[21][0], S390CPU),
VMSTATE_UINT64(env.vregs[22][0], S390CPU),
VMSTATE_UINT64(env.vregs[23][0], S390CPU),
VMSTATE_UINT64(env.vregs[24][0], S390CPU),
VMSTATE_UINT64(env.vregs[25][0], S390CPU),
VMSTATE_UINT64(env.vregs[26][0], S390CPU),
VMSTATE_UINT64(env.vregs[27][0], S390CPU),
VMSTATE_UINT64(env.vregs[28][0], S390CPU),
VMSTATE_UINT64(env.vregs[29][0], S390CPU),
VMSTATE_UINT64(env.vregs[30][0], S390CPU),
VMSTATE_UINT64(env.vregs[31][0], S390CPU),
VMSTATE_UINT64(env.vregs[0][1], S390CPU),
VMSTATE_UINT64(env.vregs[1][1], S390CPU),
VMSTATE_UINT64(env.vregs[2][1], S390CPU),
VMSTATE_UINT64(env.vregs[3][1], S390CPU),
VMSTATE_UINT64(env.vregs[4][1], S390CPU),
VMSTATE_UINT64(env.vregs[5][1], S390CPU),
VMSTATE_UINT64(env.vregs[6][1], S390CPU),
VMSTATE_UINT64(env.vregs[7][1], S390CPU),
VMSTATE_UINT64(env.vregs[8][1], S390CPU),
VMSTATE_UINT64(env.vregs[9][1], S390CPU),
VMSTATE_UINT64(env.vregs[10][1], S390CPU),
VMSTATE_UINT64(env.vregs[11][1], S390CPU),
VMSTATE_UINT64(env.vregs[12][1], S390CPU),
VMSTATE_UINT64(env.vregs[13][1], S390CPU),
VMSTATE_UINT64(env.vregs[14][1], S390CPU),
VMSTATE_UINT64(env.vregs[15][1], S390CPU),
VMSTATE_UINT64(env.vregs[16][1], S390CPU),
VMSTATE_UINT64(env.vregs[17][1], S390CPU),
VMSTATE_UINT64(env.vregs[18][1], S390CPU),
VMSTATE_UINT64(env.vregs[19][1], S390CPU),
VMSTATE_UINT64(env.vregs[20][1], S390CPU),
VMSTATE_UINT64(env.vregs[21][1], S390CPU),
VMSTATE_UINT64(env.vregs[22][1], S390CPU),
VMSTATE_UINT64(env.vregs[23][1], S390CPU),
VMSTATE_UINT64(env.vregs[24][1], S390CPU),
VMSTATE_UINT64(env.vregs[25][1], S390CPU),
VMSTATE_UINT64(env.vregs[26][1], S390CPU),
VMSTATE_UINT64(env.vregs[27][1], S390CPU),
VMSTATE_UINT64(env.vregs[28][1], S390CPU),
VMSTATE_UINT64(env.vregs[29][1], S390CPU),
VMSTATE_UINT64(env.vregs[30][1], S390CPU),
VMSTATE_UINT64(env.vregs[31][1], S390CPU),
VMSTATE_END_OF_LIST()
}
};

View file

@ -149,7 +149,7 @@ void s390x_translate_init(void)
static inline int vec_full_reg_offset(uint8_t reg)
{
g_assert(reg < 32);
return offsetof(CPUS390XState, vregs[reg][0].d);
return offsetof(CPUS390XState, vregs[reg][0]);
}
static inline int vec_reg_offset(uint8_t reg, uint8_t enr, TCGMemOp es)