From patchwork Wed Nov 29 16:41:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10082835 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 8D39D60311 for ; Wed, 29 Nov 2017 16:45:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63ABE283F9 for ; Wed, 29 Nov 2017 16:45:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5800B29B3E; Wed, 29 Nov 2017 16:45:56 +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 DF08329A45 for ; Wed, 29 Nov 2017 16:45:55 +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=X9t/hs5lea7acOzVq+l8rwgNEd5hQa2kJJnFjaB4syk=; b=ChyuKXpb4h6oaSYekxPfhOjDSY Co+Lo1JBRgRL924pHirMHRKz46F5r1qormpDatSK4+Ovql3Cksb/ya23WNycEI2dHiv1qHkziEgQi TGOoyWDEFxnulmsigh2Nhbf8l0kTejSDUQIGzfRL8tIwWfY9Ifg0w2wKBsRzQknRWuZFOTlr34CWT fEvM4L35opfTqrTI+at5eu8RRRU597F0baUsKyiTl5yCFAAB73sCoUMO4RJGi145JshdZrQjVKhV8 b7N328a88zVulr4Iyh7PYrGtMq8ZGgjkXsGRox/Vtp/M1J41HytgNhtZ20XmS6YxAusI0f9t6BucS DAHgk1pw==; 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 1eK5Ug-0001YV-Ol; Wed, 29 Nov 2017 16:45:54 +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-0004d8-PW for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2017 16:42:07 +0000 Received: by mail-wm0-x242.google.com with SMTP id 64so7183071wme.3 for ; Wed, 29 Nov 2017 08:41:40 -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=bXfLhAEXBmFfhF4Y9EDpbD2ojmAQNtJrWASQpFnQlEs=; b=IwSwInD36GPInvsJ0rPss88a+UA6wsQ8lggIfAwjr3lAtr/3k5WXNcg9GNkbu4ca0f p96o1AHcYIPWFYraqTzXnq/hiGimLCq8/FfIWYtm5bG/aSWv9+3EKj+/lQ9+Vm3sMT0y 6QKLG7P9R8wkxOdHl53Jzmj2GdKyWalPeTD2U= 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=bXfLhAEXBmFfhF4Y9EDpbD2ojmAQNtJrWASQpFnQlEs=; b=CnG4M0nwb3cvMuAeVgKhXKV8Y7ioVnmA2120C22yl37bsLvXqpwnp40w4XC1//rt9e hXsFL9v1ZrhpQGsCkRSnhfnppzNSFNyXh6OWgLYyjLivII04hj/DGhql5yDaODOVZQMP /7CAiQAoKXZJ9+4DuMf7ZxjQxetDrSAsLUCryKUmpqP2xClA5hl6fZkimCPODbq5HDnF lsuzz/8r0j+Jw/H/Jyn8p08FTD21TWH9A4pLju/B7bw4lO2EyrqRyBmTuyGZnJJ52oss GKayUlq43tTKfPuqmpE7mIkCCafiH0FFzz9+gUim0+OI3KQ2ecn8Zp+DIcPFeyRmlwGv +YXA== X-Gm-Message-State: AJaThX4jGvRDeOacsL7K+eHJ9Ia9T8K5ciMoGO8UufxPQQr+k6aecVbK D6bB4OB86nW16igvktlvYtIIng== X-Google-Smtp-Source: AGs4zMbv+G1mcEGiWdi3mpvG9Runv4gYfnIkUrUzinx+nm7bxOIVZQoI1SLzwC/GXbalj4pstlCC2g== X-Received: by 10.28.46.136 with SMTP id u130mr2680657wmu.127.1511973699600; Wed, 29 Nov 2017 08:41:39 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Nov 2017 08:41:38 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH v2 12/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_fpu Date: Wed, 29 Nov 2017 17:41:12 +0100 Message-Id: <20171129164116.16167-13-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_256299_D015F890 X-CRM114-Status: GOOD ( 12.50 ) 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 Reviewed-by: David Hildenbrand --- 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 4bf80b5..88dcb89 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 a074b0bd..8b54567 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7679,9 +7679,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; @@ -7691,6 +7693,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 c688eb7..73ad70a 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;