From patchwork Mon Dec 4 20:35:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10091491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 47AF560327 for ; Mon, 4 Dec 2017 20:37:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B281293F1 for ; Mon, 4 Dec 2017 20:37:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FDD329416; Mon, 4 Dec 2017 20:37:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABD62293F1 for ; Mon, 4 Dec 2017 20:37:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752214AbdLDUhD (ORCPT ); Mon, 4 Dec 2017 15:37:03 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:39090 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752050AbdLDUgG (ORCPT ); Mon, 4 Dec 2017 15:36:06 -0500 Received: by mail-wm0-f68.google.com with SMTP id i11so16609333wmf.4 for ; Mon, 04 Dec 2017 12:36:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=christofferdall-dk.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=0jA6jwwKq/w9QX6Sb+PJi/1faDcXiI97NtbAWON3tMM=; b=Cw6UZNtTULNDo1fU/X6OUgrpJg6o7i9Nxa/HjHIEpXefoNbs+a0eJG418L0b5/7c5q HBm8ga56pJaFMEDdHW2g90eMPfTwB/FKVDQKS66BuA4Pz7vWwjM0Jozd7GOLEDfETpjN Sj19ZmNRe13XXGzsNdsQoweK++GQ0YpJrFMmgSzxMHh4nvtpsKbc0oPYsmx92f8ij4VD GGimReEl2WbpMIYKdUgzmzligAU111zSBHm5xH2VEY0m0WicFRAC5iZ+M18LF/XYxn2L 1ksvYdUf4ATG0FK89qsINutfP0KCrhgkgclJkJTLdQ2+ghjWBO0tO1fctBo3823VKLt8 wPZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=0jA6jwwKq/w9QX6Sb+PJi/1faDcXiI97NtbAWON3tMM=; b=UYZrKpi9enOItyn9RiyM40qyKO9taGirBFMJihx3hXj5z2MIJ3NszYZUWbdYFPzMAN Dg04tZ7hh3wcsKoVZN6gD6eRVcnxB/DSFzwG7C4VLf/e6CLrcx/RrolmhMrOc+NUrHO0 GwkvGBfBcISGljIWWK/Pfmmg8ynHSp1Pi12RQHW2dw7/O4qkjBb9FNmBHmFcZIqMHQLa 78omZVcf9vP4Pyr4QkTM3lQH09c0+iEehltGk50vGdbc1iIFOc9FXWRFMWxIXhi3QqgZ 3KtSEM+LSCwMouEANnjzT3/D5RBzCn9mTzWZTVOnBCg5D9Vuo5vwp19dlWyWcenfacGG ZZwA== X-Gm-Message-State: AKGB3mKNdbn2Bp5N8VKe9p4iVDFdBjIYwZnHKBXpoIu6Oj+kCPVxWvK+ OriQB82Eujjco+vk3p7/RfJrqar3Ozq2iQ== X-Google-Smtp-Source: AGs4zMbcOXdLLFKvrX6kVFhAZhjqnoumP7Njt+KqnF197iTzI7VZxnVTA52ADCtTBDNjLrc70j5hcA== X-Received: by 10.80.165.41 with SMTP id y38mr1230084edb.72.1512419765211; Mon, 04 Dec 2017 12:36:05 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id k42sm8434943edb.94.2017.12.04.12.36.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 12:36:04 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Cc: Andrew Jones , Christoffer Dall , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Marc Zyngier , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, James Hogan , linux-mips@linux-mips.org, Paul Mackerras , kvm-ppc@vger.kernel.org, Christian Borntraeger , Cornelia Huck , linux-s390@vger.kernel.org Subject: [PATCH v3 12/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_fpu Date: Mon, 4 Dec 2017 21:35:34 +0100 Message-Id: <20171204203538.8370-13-cdall@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171204203538.8370-1-cdall@kernel.org> References: <20171204203538.8370-1-cdall@kernel.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christoffer Dall Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_get_fpu(). Reviewed-by: David Hildenbrand Signed-off-by: Christoffer Dall Reviewed-by: Cornelia Huck --- arch/s390/kvm/kvm-s390.c | 4 ++++ arch/x86/kvm/x86.c | 7 +++++-- virt/kvm/kvm_main.c | 2 -- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 4bf80b57b5c1..88dcb89656be 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2765,6 +2765,8 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) { + vcpu_load(vcpu); + /* make sure we have the latest values */ save_fpu_regs(); if (MACHINE_HAS_VX) @@ -2773,6 +2775,8 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) else memcpy(fpu->fprs, vcpu->run->s.regs.fprs, sizeof(fpu->fprs)); fpu->fpc = vcpu->run->s.regs.fpc; + + vcpu_put(vcpu); return 0; } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5d19caee6d51..19b70e016858 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7678,9 +7678,11 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) { - struct fxregs_state *fxsave = - &vcpu->arch.guest_fpu.state.fxsave; + struct fxregs_state *fxsave; + vcpu_load(vcpu); + + fxsave = &vcpu->arch.guest_fpu.state.fxsave; memcpy(fpu->fpr, fxsave->st_space, 128); fpu->fcw = fxsave->cwd; fpu->fsw = fxsave->swd; @@ -7690,6 +7692,7 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) fpu->last_dp = fxsave->rdp; memcpy(fpu->xmm, fxsave->xmm_space, sizeof fxsave->xmm_space); + vcpu_put(vcpu); return 0; } diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c688eb777bec..73ad70af6b2d 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2673,9 +2673,7 @@ static long kvm_vcpu_ioctl(struct file *filp, r = -ENOMEM; if (!fpu) goto out; - vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl_get_fpu(vcpu, fpu); - vcpu_put(vcpu); if (r) goto out; r = -EFAULT;