From patchwork Mon Dec 4 20:35:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10091519 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 0E52060327 for ; Mon, 4 Dec 2017 20:40:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E584629440 for ; Mon, 4 Dec 2017 20:40:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9D4029443; Mon, 4 Dec 2017 20:40:05 +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 8326929441 for ; Mon, 4 Dec 2017 20:40:05 +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=KjNjPd29cgPGjTjP+fcz4My7cS65ZPlzOxehXAGdgDs=; b=YyTrMAl1W0QKFSO1F4SZh1Ixy5 dMOvBcJZF2TYBEMNvErmN2xw1EMIrGVCeiTlhIT2t++fqH/k4iR26kaxWYar+NsUmCuHTXn5GUoD/ MeVNGJDQT9GpkftE7X0X7Qq/+fU2KoI4sx9r8T8op0qvfVYfduB5JG7ujt+sAKnET1yWjP0P+RLUm 3zYw3jI2NA9aHtFCAQ6SNQDwTOsNAYYwmw+rVpJwhUHmAwYPeJ2d9Psbuo4rOPP7NAl0Co7DNDWMQ Y7lgpksV+Nwod/xMsXPKqB1A5/MJA0logNcCX/nveReFd6gP1RVJfgxvuChAu5RHqPasq70AnvwF9 EttxXyHw==; 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 1eLxWu-0001Tj-Nv; Mon, 04 Dec 2017 20:39:56 +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 1eLxTX-0006Ci-PE for linux-arm-kernel@lists.infradead.org; Mon, 04 Dec 2017 20:36:36 +0000 Received: by mail-wm0-x244.google.com with SMTP id f140so16627588wmd.2 for ; Mon, 04 Dec 2017 12:36:07 -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=/sNphlMbDKiBIPVVmKYnzJtUTOvcCdWKJRmCkp2sPiM=; b=Nmc6iqaEKdu5Hdp4B5yzpdUuFxFm2p2hvoG7wnOxBCjreTYVuM5SerPbgwacQNkjzf txyAuBwsbZ+etzg8fCl2Dsg/3BYCgOGLJvCbcRFPNxgj43yIJFMKJ+k1H8kjwE6nasq8 27FLr7sb5zyGapwjSl8gvs9hF0islUOft1oBuamehtP5+6dAL0Tp2n3BsFtV5wbzHeZ2 tuqrug5gHWY9b94bnH2FN+mfzHzpNC/IFG6cQz3rXit5DZr1mPu6wnBJOmO/Tbgo1psG IAWGl2D1VEJfL4xd0PiPTCC0khPmuURyFz1B62yhK2MlxlmfVHeFhLviKCsCiPHFWa0M S0EA== 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=/sNphlMbDKiBIPVVmKYnzJtUTOvcCdWKJRmCkp2sPiM=; b=MUXZ6ZxMM/jrPU/5GRk6oqlpa0YoPlui35Qcroxd3mYoKR8X6UIsEgfOo3B72ygmwG yhXQFbEL/zFbTKomBgt2gxjs29wPV6epJWTDGeZQ0rnT/FIGV0piPKxVfw/dlLQ6Z0O5 z0oHDSsiyf2M5oYULP6NS5KWALbOwf+lH54en0g0YsXj6y92gR1tESO7yXot8fKefcQA 7sXUr6ng3MDqHmzzVVZV5LXl3SBCn9lIts4bTgZUevUN1HYnjkh45Fn5/kronA3CeW9w HmejFk0a1JCFrh4sRoG9d2k2tPhpqzI5JmCRL9FdWj0AkPZTBYDkTdzxMInEUiXXOiH5 MUQg== X-Gm-Message-State: AJaThX7NX3RezLKByxoZV+vX/NixqXWXWeTNNHWdVfQSF4+KOQ+zjlUF 9+GBTW/kf9D+7OqmbYS0EyRBIQ== X-Google-Smtp-Source: AGs4zMaJwFMjVdWw9m5Qy4MWHBdyMWWc3tiO59muy39op+PH76epdv+6jwgx1v/OVLzvXxFArVOE+w== X-Received: by 10.80.240.200 with SMTP id a8mr32259168edm.288.1512419766569; Mon, 04 Dec 2017 12:36:06 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 12:36:05 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH v3 13/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_fpu Date: Mon, 4 Dec 2017 21:35:35 +0100 Message-Id: <20171204203538.8370-14-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171204_123628_939363_8A5DFE9A X-CRM114-Status: GOOD ( 12.91 ) 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 , kvm-ppc@vger.kernel.org, Paul Mackerras , Christian Borntraeger , 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 From: Christoffer Dall Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_set_fpu(). Reviewed-by: David Hildenbrand Signed-off-by: Christoffer Dall Reviewed-by: Cornelia Huck --- 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 88dcb89656be..43278f334ce3 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 19b70e016858..95a329580c8b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7698,8 +7698,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; @@ -7710,6 +7713,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 73ad70af6b2d..06751bbecd58 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: