From patchwork Sat Nov 25 20:57:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10075177 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 A40CD60353 for ; Sat, 25 Nov 2017 21:16:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95A3E28FEB for ; Sat, 25 Nov 2017 21:16:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A6E128FED; Sat, 25 Nov 2017 21:16:15 +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 122AE28FEB for ; Sat, 25 Nov 2017 21:16:15 +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=fKIhoOKBcYRU/7sfEGHmmM9s39UDgl7zTtMIqUnzjME=; b=kcbYowYvgrOYdUqHvb2lamX9/r y8xRA+/E5B9BZRtrLAjEqAIPCzYB/jv1CqhpHLk6txx4rDDKhBsai39zJVIJ1akWMw0jc/teSnPSz UrbaN0KiE03U4xyQ07/wkpdwIkeiHjWbsWgMjzGtZS3Ge2I+xVZPshZ29hjKSNfgoBhpttHkcujaK KkF0fKdb3qUYmz9wI3HI8psOprVdU9fr0ecSk7YGvklYDSRf7950aE7bqSJnYh1HA0+LhIszjeT3o xv7xI4gkb0pkMtN2br5H5HtOn8+o7gVj6DvTICOJC/GKQuHuq+N82p7xSeaD8pjfUcVKmG9Mat405 UrE8Akvg==; 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 1eIho5-0007x9-Ve; Sat, 25 Nov 2017 21:16:14 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eIhWM-0005Ak-Lv for linux-arm-kernel@lists.infradead.org; Sat, 25 Nov 2017 20:58:03 +0000 Received: by mail-wm0-x244.google.com with SMTP id u83so27776995wmb.5 for ; Sat, 25 Nov 2017 12:57:35 -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=SCt8PKDwj8NdxkYkTRO/tiMpMynrFEUWAHQZsoHGuu0=; b=BdbI7PVMIMYMxkUy3u4R0Q4g97BuVrAwOSUge58npKm/ZtzXrvPPO/Ob/Du/OC+jPG Gafnzc3ImU3VR4C+5weSq1ATmc5XCFoQLy2lqACLcioCNwnpN6F8x0w2kEz0oQF61fME 3vfBKOTglO0btuPh2Ogyzp1vvDg3g87vTjc/Y= 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=SCt8PKDwj8NdxkYkTRO/tiMpMynrFEUWAHQZsoHGuu0=; b=FzWRpAjt790UBb1vf7FATuZQY6iXe5z4rW/6mjFOzJa0ncQasaCK6O7cpnMNbMpVEe Ma9UIMHhxiHPNVHPz8QR/3sZKemSpwmHUAD03m5LPCLRYmWmyOLOMUBVtQo5tdNwj2em jC1/6fUe5+susFrih2lWJpbEqxDAAcE1Pt3OJuy0ZN9m/syKH8t2DCPAlCXGc04KbcI4 pUzaV+pc89yMIUCll2PzzALNQmWghaLVIGaLXDI3O/d7z2aVbva8/ykndkZqywRleAA0 YNiFKPZXWxFHxiZjkv2zZY5KrMmqzLLmI1YGauFPCu3unmbAt1hU0VC/iY8AKHKpH5c6 eh6A== X-Gm-Message-State: AJaThX7qcMIZteqNYClekWVsUlj8VTZTOG7wM7iCBNY03CuInpkPBuVl xZEdN/fZwUbubVm/2pcy61ctrQ== X-Google-Smtp-Source: AGs4zMY77LHfAeb6uGAIzKVGOux3ismS1De3ouZmiwNriq5l2t82Whhcup9P/F17f2lKcmZ5vqARsw== X-Received: by 10.28.6.2 with SMTP id 2mr12557438wmg.37.1511643454449; Sat, 25 Nov 2017 12:57:34 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id z37sm15157577wrc.31.2017.11.25.12.57.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Nov 2017 12:57:33 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH 13/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_fpu Date: Sat, 25 Nov 2017 21:57:16 +0100 Message-Id: <20171125205718.7731-14-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171125205718.7731-1-christoffer.dall@linaro.org> References: <20171125205718.7731-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171125_125755_437032_2635C03B X-CRM114-Status: GOOD ( 13.29 ) 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 --- arch/s390/kvm/kvm-s390.c | 15 +++++++++++++-- arch/x86/kvm/x86.c | 11 +++++++++-- virt/kvm/kvm_main.c | 4 ---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index e4ddf6a5cb4e..46d015083136 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2769,15 +2769,26 @@ 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) { + int ret; + + ret = vcpu_load(vcpu); + if (ret) + return ret; + + ret = -EINVAL; if (test_fp_ctl(fpu->fpc)) - return -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; + + ret = 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 f275fefbc4e0..230d552cdc4b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7701,8 +7701,14 @@ 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; + int ret; + struct fxregs_state *fxsave; + + ret = vcpu_load(vcpu); + if (ret) + return ret; + + fxsave = &vcpu->arch.guest_fpu.state.fxsave; memcpy(fxsave->st_space, fpu->fpr, 128); fxsave->cwd = fpu->fcw; @@ -7713,6 +7719,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 8f767922fbbd..08a610619572 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2697,11 +2697,7 @@ static long kvm_vcpu_ioctl(struct file *filp, fpu = NULL; goto out; } - r = vcpu_load(vcpu); - if (r) - goto out; r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, fpu); - vcpu_put(vcpu); break; } default: