From patchwork Mon Mar 23 17:05:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 46213 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A32AE214B0 for ; Mon, 23 Mar 2015 17:08:11 +0000 (UTC) Received: by lams18 with SMTP id s18sf28389434lam.2 for ; Mon, 23 Mar 2015 10:08:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding:cc :subject:precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=P9LwbTqYN5Zki8sjWvBncIzQXkRbsb6IzPsndUz9hrc=; b=kaxoSt/j4kUF+WLVrdJOl7zpo0T6AnG1+DWf1tTnSjpR+fWNpiTpJfJOTGNvAL2WSd XbNfCvP9TruYqsZPhe188XUtACVMruPHGqaENJI7EBjfw2VPA1LzoV365nzTYOxyPo90 FnbkbtOu/vRvGM6efRog6C6RyFPAAuDaTSV12TugdR21OYllOWmXSTsk3WUvLbMitq4u QY0CuV96B+w/xbmfqDS8L2YMEVv6IvWavHQ7zIkPavO9nMVl6gb0Zz2JIzvGMWCURYxt 7agGZNGmgRgC/IEQTo3zU805uJcgStE7Nmq2uK9y+G9choFJUxPSaU6oiSHdTW5YYN6B 2t9Q== X-Gm-Message-State: ALoCoQm2l+RkCGGIqTsMTiJc4d5YbqDWsu5oKs4ePGazuntwshNuCo11d+k97xKywSrvqB40xmPD X-Received: by 10.194.95.67 with SMTP id di3mr58098wjb.0.1427130490616; Mon, 23 Mar 2015 10:08:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.202.133 with SMTP id ki5ls720935lac.90.gmail; Mon, 23 Mar 2015 10:08:10 -0700 (PDT) X-Received: by 10.112.25.38 with SMTP id z6mr118968lbf.106.1427130490386; Mon, 23 Mar 2015 10:08:10 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id q1si1049804laj.84.2015.03.23.10.08.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2015 10:08:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbcgn8 with SMTP id gn8so123060523lbc.2 for ; Mon, 23 Mar 2015 10:08:10 -0700 (PDT) X-Received: by 10.152.178.197 with SMTP id da5mr166325lac.56.1427130490296; Mon, 23 Mar 2015 10:08:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp955112lbq; Mon, 23 Mar 2015 10:08:09 -0700 (PDT) X-Received: by 10.140.44.134 with SMTP id g6mr71627qga.85.1427130488994; Mon, 23 Mar 2015 10:08:08 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w69si1251131qha.88.2015.03.23.10.08.08 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 23 Mar 2015 10:08:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:57170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya5pg-0000bu-2G for patch@linaro.org; Mon, 23 Mar 2015 13:08:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya5n6-0005Bl-41 for qemu-devel@nongnu.org; Mon, 23 Mar 2015 13:05:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ya5my-0005yy-7X for qemu-devel@nongnu.org; Mon, 23 Mar 2015 13:05:28 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:35910 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya5my-0005yO-29 for qemu-devel@nongnu.org; Mon, 23 Mar 2015 13:05:20 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaroharston) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1Ya6rE-0005wQ-OI; Mon, 23 Mar 2015 19:13:48 +0100 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Mon, 23 Mar 2015 17:05:42 +0000 Message-Id: <1427130344-27986-5-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.3.2 In-Reply-To: <1427130344-27986-1-git-send-email-alex.bennee@linaro.org> References: <1427130344-27986-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: alex.bennee@linaro.org X-SA-Exim-Scanned: No (on socrates.bennee.com); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 88.198.71.155 Cc: Peter Maydell , kvm@vger.kernel.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org Subject: [Qemu-devel] [PATCH v5 4/6] target-arm: kvm64 sync FP register state 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.bennee@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 For migration to work we need to sync all of the register state. This is especially noticeable when GCC starts using FP registers as spill registers even with integer programs. Signed-off-by: Alex BennĂ©e --- v4: - fixed merge conflicts - rm superfluous reg.id++ v5: - use interim float128 to deal with endianess - correctly map into vfp.regs[] - fix spacing around []s diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c index fed03f2..857e970 100644 --- a/target-arm/kvm64.c +++ b/target-arm/kvm64.c @@ -126,9 +126,16 @@ bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx) #define AARCH64_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \ KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) +#define AARCH64_SIMD_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U128 | \ + KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) + +#define AARCH64_SIMD_CTRL_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U32 | \ + KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) + int kvm_arch_put_registers(CPUState *cs, int level) { struct kvm_one_reg reg; + uint32_t fpr; uint64_t val; int i; int ret; @@ -207,15 +214,42 @@ int kvm_arch_put_registers(CPUState *cs, int level) } } + /* Advanced SIMD and FP registers + * We map Qn = regs[2n+1]:regs[2n] + */ + for (i = 0; i < 32; i++) { + int rd = i << 1; + float128 fp_val = make_float128(env->vfp.regs[rd + 1], + env->vfp.regs[rd]); + reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); + reg.addr = (uintptr_t)(&fp_val); + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + reg.addr = (uintptr_t)(&fpr); + fpr = vfp_get_fpsr(env); + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + fpr = vfp_get_fpcr(env); + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + if (!write_list_to_kvmstate(cpu)) { return EINVAL; } kvm_arm_sync_mpstate_to_kvm(cpu); - /* TODO: - * FP state - */ return ret; } @@ -223,6 +257,7 @@ int kvm_arch_get_registers(CPUState *cs) { struct kvm_one_reg reg; uint64_t val; + uint32_t fpr; int i; int ret; @@ -304,6 +339,38 @@ int kvm_arch_get_registers(CPUState *cs) } } + /* Advanced SIMD and FP registers + * We map Qn = regs[2n+1]:regs[2n] + */ + for (i = 0; i < 32; i++) { + float128 fp_val; + reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); + reg.addr = (uintptr_t)(&fp_val); + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } else { + int rd = i << 1; + env->vfp.regs[rd + 1] = fp_val.high; + env->vfp.regs[rd] = fp_val.low; + } + } + + reg.addr = (uintptr_t)(&fpr); + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + vfp_set_fpsr(env, fpr); + + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + vfp_set_fpcr(env, fpr); + if (!write_kvmstate_to_list(cpu)) { return EINVAL; }