From patchwork Sat Nov 25 20:57:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10075173 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 1667460383 for ; Sat, 25 Nov 2017 21:01:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 072B928F53 for ; Sat, 25 Nov 2017 21:01:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFDC928F69; Sat, 25 Nov 2017 21:01:34 +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 7BA7E28F53 for ; Sat, 25 Nov 2017 21:01:34 +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=0h+FKH4YyL+p3YXOL0sgP4CgBMcEJD3r4f7CqyW5Npg=; b=ajTldcWoSGz+J23UJLkAM2HUaA l9TwQreQk3l2zr0SGfOLoEXw06fNviS6F8yv80ZrfLle49NPnFPuX2HLxKO5AKQ3dQDxBnagQFtNm 1L6y/RbzmuZZ5AZGeAqOMNoQYMOqsVPgInxrqOOmVfDB6P8Bhp2xGEjYaIvQl9vxGwmHf51GfSe0N FVScUqQN0ElpJEs/k1TzTHxk0+URmlkY1RjKUliyCO8hJSH8MqUsRW8cR2KEYNLt+A861gNikhlHJ /1Me43kDolWgXotUKoZBXsnAcYBGM01Q+wccS6wPFTQT1i7O4AolMiVH9xZh21Us873fKh+707VN4 a6Kk9jTg==; 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 1eIhZt-0001KT-Hu; Sat, 25 Nov 2017 21:01:33 +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-0005AT-Lu for linux-arm-kernel@lists.infradead.org; Sat, 25 Nov 2017 20:58:01 +0000 Received: by mail-wm0-x244.google.com with SMTP id y80so28093314wmd.0 for ; Sat, 25 Nov 2017 12:57:34 -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=VMHtK4XT1rnBlaXMNbXsVNbWuHXe49QHEAm+dEIpggU=; b=CXCEBfrHxjufX/7hq2EEOeL0ebUREZO8WgVju1Krey6aIS/RHQAY3qMFwXmYPkuz7G QXvae8ttZjxTdNehVOqIu0Jw5vauMktbU3bePgyKe+89IPSEw3ELq5gL/DyV7px5QRdp Ke3fJmmPJAIXULusD2pamhEFozRJrLALdiZXo= 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=VMHtK4XT1rnBlaXMNbXsVNbWuHXe49QHEAm+dEIpggU=; b=kwrrDpOQ2/GKzEEmGb4FWZNDDCwTKgBbH7HfD4dI1kPB1WGW634XDpxEd0GcbrJpcy lmvWrvsXOLhDY85l2jZVzWShkzA1rFfs+l7FHnusADJWCS+6p+iNPeTH/pF2zMuB08iG GrIxnygdGi4+ibjdHCE8qRCy4th/pNUycOWsT3NUpHmtCE50Nz826Beds6z/kk9Ga/IB Vri1ML+m24Y68lhIPrW2xFX4jGOKnVwzeeKZ6cK24UbuPVzZxizc5WnB6Tc+Fgri8tru qDzLaY56OXZU+RN0imDzK/HT4thCCaMrvv23P8tZg4o+x7tZhgdsRRgtilCA8GGqD86D kmoQ== X-Gm-Message-State: AJaThX74oUXb0ex3/GOebPcLakK8ttlxoPX9He6YDmOWRSFz9O3sRR5G +o2u5EWVOxa9RgzGD8vtUf4CQA== X-Google-Smtp-Source: AGs4zMZ/roYukCLNH+M/yuVclPVPbaIYdDaF4G14v4FsTIovrInaUEBMezbTooTXVjoOnxogk0b+Mw== X-Received: by 10.28.131.203 with SMTP id f194mr14114056wmd.39.1511643452770; Sat, 25 Nov 2017 12:57:32 -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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Nov 2017 12:57:31 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH 12/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_fpu Date: Sat, 25 Nov 2017 21:57:15 +0100 Message-Id: <20171125205718.7731-13-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_477393_43416D6F X-CRM114-Status: GOOD ( 12.73 ) 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_get_fpu(). Signed-off-by: Christoffer Dall --- arch/s390/kvm/kvm-s390.c | 8 ++++++++ arch/x86/kvm/x86.c | 10 ++++++++-- virt/kvm/kvm_main.c | 4 ---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index ac26d95444c9..e4ddf6a5cb4e 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2782,6 +2782,12 @@ 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) { + int r; + + r = vcpu_load(vcpu); + if (r) + return r; + /* make sure we have the latest values */ save_fpu_regs(); if (MACHINE_HAS_VX) @@ -2790,6 +2796,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 09135bd759a4..f275fefbc4e0 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7678,9 +7678,14 @@ 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; + int r; + struct fxregs_state *fxsave; + + r = vcpu_load(vcpu); + if (r) + return r; + fxsave = &vcpu->arch.guest_fpu.state.fxsave; memcpy(fpu->fpr, fxsave->st_space, 128); fpu->fcw = fxsave->cwd; fpu->fsw = fxsave->swd; @@ -7690,6 +7695,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 6b87c24c60da..8f767922fbbd 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2681,11 +2681,7 @@ static long kvm_vcpu_ioctl(struct file *filp, r = -ENOMEM; if (!fpu) goto out; - r = vcpu_load(vcpu); - if (r) - goto out; r = kvm_arch_vcpu_ioctl_get_fpu(vcpu, fpu); - vcpu_put(vcpu); if (r) goto out; r = -EFAULT;