From patchwork Wed May 20 16:33:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 474568 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 89EF014027F for ; Thu, 21 May 2015 02:34:18 +1000 (AEST) Received: from localhost ([::1]:53274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yv6wi-0006Lt-Ap for incoming@patchwork.ozlabs.org; Wed, 20 May 2015 12:34:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yv6w7-0005KM-R0 for qemu-devel@nongnu.org; Wed, 20 May 2015 12:33:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yv6w3-00019W-Od for qemu-devel@nongnu.org; Wed, 20 May 2015 12:33:39 -0400 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:44008) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yv6w3-00018d-Gg for qemu-devel@nongnu.org; Wed, 20 May 2015 12:33:35 -0400 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 May 2015 17:33:33 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 20 May 2015 17:33:31 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 5FF8E1B08070 for ; Wed, 20 May 2015 17:34:19 +0100 (BST) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t4KGXUhA62455980 for ; Wed, 20 May 2015 16:33:30 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t4KGXTQZ011891 for ; Wed, 20 May 2015 10:33:30 -0600 Received: from gondolin.boeblingen.de.ibm.com (dyn-9-152-224-143.boeblingen.de.ibm.com [9.152.224.143]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t4KGXTcH011866; Wed, 20 May 2015 10:33:29 -0600 From: Cornelia Huck To: qemu-devel@nongnu.org Date: Wed, 20 May 2015 18:33:17 +0200 Message-Id: <1432139606-23705-2-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <1432139606-23705-1-git-send-email-cornelia.huck@de.ibm.com> References: <1432139606-23705-1-git-send-email-cornelia.huck@de.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15052016-0041-0000-0000-000004755B7F X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.107 Cc: Eric Farman , borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, Cornelia Huck , agraf@suse.de Subject: [Qemu-devel] [PATCH 01/10] s390x: Common access to floating point registers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Eric Farman Provide a routine to access the correct floating point register, to simplify future expansion. Suggested-by: David Hildenbrand Signed-off-by: Eric Farman Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- 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(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 5bb399e..1166f2f 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(¤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; diff --git a/target-s390x/arch_dump.c b/target-s390x/arch_dump.c index a1554f5..36e8407 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 c557211..e968769 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 diff --git a/target-s390x/gdbstub.c b/target-s390x/gdbstub.c index 8945f02..40bdfe7 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 041c9c7..6b47766 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 ea18015..1a40a94 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 80e3a54..96b43b3 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 {