From patchwork Wed Nov 29 16:41:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10082837 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 92B6A60311 for ; Wed, 29 Nov 2017 16:46:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB8A029A44 for ; Wed, 29 Nov 2017 16:46:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEB9129B3F; Wed, 29 Nov 2017 16:46:16 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 66605283F9 for ; Wed, 29 Nov 2017 16:46:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=O/YpfNxsXsOAhgMdIia+mukIWmWB4KoZTyRAOBwJtmM=; b=c+Cv+u1FhPMpTnzNL8vZFR9AHl k4lT3uG/OzmG3O6mXMmm7VBNqkLV1w3MhImS9IOVZFW/QRYrlRchGC8ByodOyqBA5TwB1uR/rt+C/ p/2rLa6PJpb0QOa6oWNC0AHH19lUI1IbI1s/wu78i/n9IYYVx6XNvS8kNYcXjRqv22AAoRepmeW5Y 9FUg6Z1I4gres9uJWYcCeQVzwguPjbDzuwWQ4T1HutOcZ0kIcFHNCjYzQdgdFS+nENUc5LZWa/CUO rN7KBMBiO56L7goJoE3Nd32sGpD2mWhpk0DNuy5wxEscGjxRe2GFFapD7GEQ2jlAre0nnjCirOzVz JgRgJ//w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eK5V1-0001yl-6j; Wed, 29 Nov 2017 16:46:15 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eK5Qu-0004f6-Ni for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2017 16:42:11 +0000 Received: by mail-wm0-x242.google.com with SMTP id 9so7568592wme.4 for ; Wed, 29 Nov 2017 08:41:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SDbGekwTGfPeOtIY2YvyvCh3khoLc38Ey9F55tV3OzA=; b=TUA1xHVmPw6HhIspyafTM96ZBHoTQSAHY5W1ESq/GTA4WsfUbAoIDQkpnCcKR4sRhR tu46FTdPCHtq9jCaUphotAC2FwxcaCIFu9QarRPQdLZp2NCEmngmL8FIVQtTbLshfkXR Ziqt3qlSF1f81sRK35uiIAstpAiHybKenNUKQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SDbGekwTGfPeOtIY2YvyvCh3khoLc38Ey9F55tV3OzA=; b=pBWwBVSgkdw7NTMA2z3+HW4DAwu7t92vMGnXSdxoHgk3zl5KTVDcqkxHthDUKNh6ug vFwHEDLvj0hY6nvaAtBEtjzoM0xSvIqU1h8IkWz1CZp1SgecT7EZJ1jWamz+2yxF5EEH Z1kBrLwQ5x7WJAw1fHb8AjHUHdTT8ha4SZ+VTftGxWAjY8fA2RSsH9IA1TKGNtf80d3Z ptMJzof4vXiyqLLatiN6LUvB8bypgVSZQMBRZrTGHkrE0+TuMWqICmYlPAQBj9krKr9K SXpnqnxaLD8sGr4U/LhNvzUBXXgTNeK1XaGyfU0HXpMa2YYHH/5PKnVQaZYx0dhpkkZZ W3+g== X-Gm-Message-State: AJaThX7rvNEZjJxVx1DBRtYFMkgBiq5aqYWEmNCqzfMH2Eb1+WOPhPxB b/tyPB2K7LH9l/X15Ijyy9X1Tw== X-Google-Smtp-Source: AGs4zMYdR7I998I3tymksI+Ie8LeJ8RwXeP+fEHp9QltLrFMUtAVaZ77xHguNx/isHjkk/Qg6zuZUA== X-Received: by 10.28.12.75 with SMTP id 72mr2872353wmm.133.1511973701269; Wed, 29 Nov 2017 08:41:41 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id e71sm2080765wma.13.2017.11.29.08.41.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Nov 2017 08:41:40 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH v2 13/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_fpu Date: Wed, 29 Nov 2017 17:41:13 +0100 Message-Id: <20171129164116.16167-14-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171129164116.16167-1-christoffer.dall@linaro.org> References: <20171129164116.16167-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171129_084201_205214_7249B34A X-CRM114-Status: GOOD ( 13.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mips@linux-mips.org, Andrew Jones , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Marc Zyngier , James Hogan , Cornelia Huck , Christian Borntraeger , kvm-ppc@vger.kernel.org, Alexander Graf , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , linux-s390@vger.kernel.org, kvmarm@lists.cs.columbia.edu, Christoffer Dall MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_set_fpu(). Signed-off-by: Christoffer Dall Reviewed-by: David Hildenbrand --- arch/s390/kvm/kvm-s390.c | 15 ++++++++++++--- arch/x86/kvm/x86.c | 8 ++++++-- virt/kvm/kvm_main.c | 2 -- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 88dcb89..43278f3 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2752,15 +2752,24 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) { - if (test_fp_ctl(fpu->fpc)) - return -EINVAL; + int ret = 0; + + vcpu_load(vcpu); + + if (test_fp_ctl(fpu->fpc)) { + ret = -EINVAL; + goto out; + } vcpu->run->s.regs.fpc = fpu->fpc; if (MACHINE_HAS_VX) convert_fp_to_vx((__vector128 *) vcpu->run->s.regs.vrs, (freg_t *) fpu->fprs); else memcpy(vcpu->run->s.regs.fprs, &fpu->fprs, sizeof(fpu->fprs)); - return 0; + +out: + vcpu_put(vcpu); + return ret; } int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 8b54567..fd8b92f 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7699,8 +7699,11 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) int kvm_arch_vcpu_ioctl_set_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(fxsave->st_space, fpu->fpr, 128); fxsave->cwd = fpu->fcw; @@ -7711,6 +7714,7 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) fxsave->rdp = fpu->last_dp; memcpy(fxsave->xmm_space, fpu->xmm, sizeof fxsave->xmm_space); + vcpu_put(vcpu); return 0; } diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 73ad70a..06751bb 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2689,9 +2689,7 @@ static long kvm_vcpu_ioctl(struct file *filp, fpu = NULL; goto out; } - vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, fpu); - vcpu_put(vcpu); break; } default: