From patchwork Sat Nov 25 20:57:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10075163 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 53E1060383 for ; Sat, 25 Nov 2017 20:59:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44E4A286EC for ; Sat, 25 Nov 2017 20:59:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3743A28B53; Sat, 25 Nov 2017 20:59:51 +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 CA79D286EC for ; Sat, 25 Nov 2017 20:59:50 +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=eMGNrTqDSry5qbXjESCA3HbGVzf/99WXR7EvGCP/ilw=; b=kloZH7oVV/FfroWSDEzZSfa7s7 S13BOIOvxo4sbunaQ3Rfwr5gMGd1SLcEZLsCiY0qwRVRb6HsGXamjkk5ypj4y2QV0XsG4X05KYzpy KhVwz5YxSG+plBMmENMsvIAhDhv35nUTgM3n/cVQ52U3HJGBp4lRPw/F2eErpc5BpVR9HYx119th+ 7gjkN8cOuZu2O0stxi5iGOYsG/ErJ00HidPp66oCR7FsFaaSbdQh9qK9zJoEMZ72TRDy0hwDEgDy/ 68dR7W4qrWM1q7YPvoTSqzbjseN9tt1RIUqiJPB2PeutTlY5BYPmUZE7lkLlfP4uSeJA6VFzF8BQz 7wSsEGzQ==; 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 1eIhYE-0006yf-1H; Sat, 25 Nov 2017 20:59:50 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eIhW7-00059F-Vg for linux-arm-kernel@lists.infradead.org; Sat, 25 Nov 2017 20:57:49 +0000 Received: by mail-wr0-x242.google.com with SMTP id l22so22981357wrc.11 for ; Sat, 25 Nov 2017 12:57:23 -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=zrY9wnaKokWnAolmrxh9O3IQDcVtQpq4BORcfzDbKds=; b=dgGLukwFVeq8sB2eOr7PZPaVA4IKc0sP+CD5yE4K9M0TMGFbgtFzM/9lh16lMOM3Oj 4SRELHGOj1dDkItO62EYjnH2K+GcndVQsMP4CaSoTWxJQWovNVdjHf1NOCjXWjV0fBNr xO1Q0awaY8IUXFivfROYZQULwPXsTtffmIf9I= 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=zrY9wnaKokWnAolmrxh9O3IQDcVtQpq4BORcfzDbKds=; b=I+aQXQdk/pGJGNIKV5I5+0bL1ub7F2sHBaiO96nMAiaHCwmz3Qh5bb/H63JbCRZasB S5HjlHLxuH13oLn3yBp1/14/Q81iaoeNXTHKKsKDyN8+JAWYciE32c8/W6AMzUpxFzGx Vl2lq27vK1L/ZPNQcsryM0z7Jh9mztCKL5H8uEurU6A32nm8WVmf0/IDRgUf6tSkJvb2 4DvALKIzlR7n7lYHrYCeJKIzBd1WsnJ8/sM4ubp+mDqutAVO/HegtLxp3xUxnTs8SpoN 6/667jwxpipTzuqXMcKbmmrNL6GNAPmC9EXRsnc27bpic5Tdc4RPK3kH59DsC+uCqHH7 yC9g== X-Gm-Message-State: AJaThX6LNr85fu/FL9a+26P7HdTTIvY8H30joGoI39NSUqzJNaNCjSbD ieqbBCq6wMawamdOhQhmMpD+wQ== X-Google-Smtp-Source: AGs4zMY/c0UWlAUU3bgeVNDasXCBKV6miVh2JkuDzknzSCn/XyWfjujNhzZYZci7eBGUz2/eCJyycw== X-Received: by 10.223.135.243 with SMTP id c48mr25188642wrc.140.1511643441783; Sat, 25 Nov 2017 12:57:21 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Nov 2017 12:57:21 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH 06/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_sregs Date: Sat, 25 Nov 2017 21:57:09 +0100 Message-Id: <20171125205718.7731-7-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_125740_291544_1A5DD255 X-CRM114-Status: GOOD ( 12.18 ) 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_sregs(). Signed-off-by: Christoffer Dall --- arch/powerpc/kvm/book3s.c | 10 +++++++++- arch/powerpc/kvm/booke.c | 11 ++++++++++- arch/s390/kvm/kvm-s390.c | 8 ++++++++ arch/x86/kvm/x86.c | 6 ++++++ virt/kvm/kvm_main.c | 4 ---- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 047d3178d70f..b7db75010843 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -484,7 +484,15 @@ void kvmppc_subarch_vcpu_uninit(struct kvm_vcpu *vcpu) int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) { - return vcpu->kvm->arch.kvm_ops->get_sregs(vcpu, sregs); + int ret; + + ret = vcpu_load(vcpu); + if (ret) + return ret; + ret = vcpu->kvm->arch.kvm_ops->get_sregs(vcpu, sregs); + + vcpu_put(vcpu); + return ret; } int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 47b3d11345ed..d770f465cb9d 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1620,11 +1620,20 @@ int kvmppc_set_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) { + int ret; + + ret = vcpu_load(vcpu); + if (ret) + return ret; + sregs->pvr = vcpu->arch.pvr; get_sregs_base(vcpu, sregs); get_sregs_arch206(vcpu, sregs); - return vcpu->kvm->arch.kvm_ops->get_sregs(vcpu, sregs); + ret = vcpu->kvm->arch.kvm_ops->get_sregs(vcpu, sregs); + + vcpu_put(vcpu); + return ret; } int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index eb2724d6e524..93a19e7e4f59 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2746,8 +2746,16 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) { + int r; + + r = vcpu_load(vcpu); + if (r) + return r; + memcpy(&sregs->acrs, &vcpu->run->s.regs.acrs, sizeof(sregs->acrs)); memcpy(&sregs->crs, &vcpu->arch.sie_block->gcr, sizeof(sregs->crs)); + + vcpu_put(vcpu); return 0; } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index e4e34af97ba0..7faa9479e8d8 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7381,8 +7381,13 @@ EXPORT_SYMBOL_GPL(kvm_get_cs_db_l_bits); int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) { + int r; struct desc_ptr dt; + r = vcpu_load(vcpu); + if (r) + return r; + kvm_get_segment(vcpu, &sregs->cs, VCPU_SREG_CS); kvm_get_segment(vcpu, &sregs->ds, VCPU_SREG_DS); kvm_get_segment(vcpu, &sregs->es, VCPU_SREG_ES); @@ -7414,6 +7419,7 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, set_bit(vcpu->arch.interrupt.nr, (unsigned long *)sregs->interrupt_bitmap); + vcpu_put(vcpu); return 0; } diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 7671ebb5971f..dbfaf190fca3 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2589,11 +2589,7 @@ static long kvm_vcpu_ioctl(struct file *filp, r = -ENOMEM; if (!kvm_sregs) goto out; - r = vcpu_load(vcpu); - if (r) - goto out; r = kvm_arch_vcpu_ioctl_get_sregs(vcpu, kvm_sregs); - vcpu_put(vcpu); if (r) goto out; r = -EFAULT;