From patchwork Wed May 20 16:33:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 474573 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 2B8CA14027F for ; Thu, 21 May 2015 02:36:38 +1000 (AEST) Received: from localhost ([::1]:53297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yv6yy-0001yk-4U for incoming@patchwork.ozlabs.org; Wed, 20 May 2015 12:36:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yv6w9-0005KU-D6 for qemu-devel@nongnu.org; Wed, 20 May 2015 12:33:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yv6w4-00019l-1m for qemu-devel@nongnu.org; Wed, 20 May 2015 12:33:41 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:40249) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yv6w3-00018V-Ke for qemu-devel@nongnu.org; Wed, 20 May 2015 12:33:35 -0400 Received: from /spool/local by e06smtp15.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 e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 20 May 2015 17:33:31 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 7BAF21B0806E 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 b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t4KGXUDM11862318 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 t4KGXUg2011904 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 t4KGXTcI011866; Wed, 20 May 2015 10:33:30 -0600 From: Cornelia Huck To: qemu-devel@nongnu.org Date: Wed, 20 May 2015 18:33:18 +0200 Message-Id: <1432139606-23705-3-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-0021-0000-0000-000003F6E3E7 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.111 Cc: Eric Farman , borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, Cornelia Huck , agraf@suse.de Subject: [Qemu-devel] [PATCH 02/10] s390x: Vector Register IOCTLs 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 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. Signed-off-by: Eric Farman Signed-off-by: Cornelia Huck --- 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(-) diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index e968769..708349c 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -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" diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 1a40a94..ca8ffcc 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -337,15 +337,24 @@ int kvm_arch_put_registers(CPUState *cs, int level) } } - /* Floating point */ - for (i = 0; i < 16; i++) { - fpu.fprs[i] = get_freg(env, i)->ll; - } - fpu.fpc = env->fpc; + 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.fpc = env->fpc; + cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_VRS; + } else { + /* Floating point */ + for (i = 0; i < 16; i++) { + fpu.fprs[i] = get_freg(env, i)->ll; + } + fpu.fpc = env->fpc; - r = kvm_vcpu_ioctl(cs, KVM_SET_FPU, &fpu); - if (r < 0) { - return r; + r = kvm_vcpu_ioctl(cs, KVM_SET_FPU, &fpu); + if (r < 0) { + return r; + } } /* Do we need to save more than that? */ @@ -468,15 +477,23 @@ int kvm_arch_get_registers(CPUState *cs) } } - /* Floating point */ - r = kvm_vcpu_ioctl(cs, KVM_GET_FPU, &fpu); - if (r < 0) { - return r; - } - for (i = 0; i < 16; i++) { - get_freg(env, i)->ll = fpu.fprs[i]; + /* 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->fpc = cs->kvm_run->s.regs.fpc; + } else { + r = kvm_vcpu_ioctl(cs, KVM_GET_FPU, &fpu); + if (r < 0) { + return r; + } + for (i = 0; i < 16; i++) { + get_freg(env, i)->ll = fpu.fprs[i]; + } + env->fpc = fpu.fpc; } - env->fpc = fpu.fpc; /* The prefix */ if (can_sync_regs(cs, KVM_SYNC_PREFIX)) { diff --git a/target-s390x/machine.c b/target-s390x/machine.c index 7853e3c..1a9390b 100644 --- a/target-s390x/machine.c +++ b/target-s390x/machine.c @@ -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() } diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 96b43b3..06fc192 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -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]); } }