From patchwork Mon Dec 4 20:35:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10091489 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 D62B460327 for ; Mon, 4 Dec 2017 20:37:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7206290AA for ; Mon, 4 Dec 2017 20:37:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBBDA293F1; Mon, 4 Dec 2017 20:37: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 683C4290AA for ; Mon, 4 Dec 2017 20:37: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=DFfn3WPnHM/eRKDGlI908uE/N9EFNFDwStAiINIaqP4=; b=q9BeoBaIhMkCUfhMT8MTumOzKX C4Ea2rQsf+8HkGIOsU5mCmTpZL3fP7O5bD9jY17yVqvnrgCflgLuI+qDb2DJCEsWUHmx5pWq3F90X 2eQ7AsIZJhT3CWBV0c6iHmAKhEMQ8n2caXJSuGVK8BkPcep0zAWCcm551tcK5yWa7uod5rtj0y3GS EjrQLVomAewTRR0WxkFZFyykbw6R8q5wl5+evouJ0M7pTmofIlRxIDxcjCu6n3/diOFKf+7Y0ipl0 7tbGkjhHId1RHhzKrlyp31Buamsluf9KQHloB/M38XVKo0z82MnIGz2VT9CGvHXGH2VHNahTn3HHO 39TAePgA==; 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 1eLxU1-00070G-N7; Mon, 04 Dec 2017 20:36:57 +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 1eLxTI-0006Bz-2S for linux-arm-kernel@lists.infradead.org; Mon, 04 Dec 2017 20:36:15 +0000 Received: by mail-wm0-x242.google.com with SMTP id g75so8238673wme.0 for ; Mon, 04 Dec 2017 12:35:58 -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=6sXuqbCDVaNJ0JhSfw/I4+3+m51clULBvpEUyvl9FPA=; b=O+u9SW4qaxxG3p+0bbG//MUlrQC+2p6rA4y60kvPEgp9L01lIZSuf06oiemH6HKTD+ prDzb05tJgnp0MrpaKHlbcTdDCJlYruquFc7BXXcJ/6sHZWCyYtguEkDTfgLV+yJd8VA gHm4KOOSI/TqwUBcpUxM5SQk9xnNGj/Jc22K7NT6wz7JYHlGf5reTS7dO5ZOuj6Ub3au KBybLbuav/sQYXr1qwzBMHU4IYIvV8Ol6aimfpkCQIwbGtbNhjyXMKp2WyNBHR5V5S59 lmkCLJn9tcFrG6c+pP1Kl5zzaa+o8723dMOXPJJS3TsTPlnpFSGuRXpeIFchanLP4KNW bVkA== 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=6sXuqbCDVaNJ0JhSfw/I4+3+m51clULBvpEUyvl9FPA=; b=HP2Sz56ceWMlvpfzLuWiFo/Kk2yIBHw16K3KXnHbdAb6+ddihhglZx9UbJ4S0GQasE GleSkYoC++XMBALrv2EtnREKUDGUs+Lv491Eizy/g816OczA3o5xlj2PzowqqHZgj5lN hGHJFrKvrriUBtO72MauO4upnz+Op2xKmJOcdKdtgRWW4QNukVMjZBFdvjYT3YxutXXw egA7JkuQBlA9EUpl49POlYd7tyT/EQUxiv1nP8EdG/dABm7qhP8AyqQJsHf5lqReEXLh kL7i4MPPPdWr1sPs4OsVtNmJcqdqemBTelOJ/o7AIU3Fu0/lMsCVFFRAEQAXnv17R4uy 45zQ== X-Gm-Message-State: AJaThX4LVd1T/UfwtUz8ybMlyQAs8FcZjov+0Oh6j00WumD73y7dNaQp U0Obc2kMkNn/TXFrWjt48wfdBg== X-Google-Smtp-Source: AGs4zMYK+G1A/wrSV4DAzMfwTOHHYV75h6ETAK+Qhnf1qbbMaYUgogLV0JHO66eMLk7dd59pDzO3bA== X-Received: by 10.80.166.34 with SMTP id d31mr32321267edc.96.1512419756704; Mon, 04 Dec 2017 12:35:56 -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.35.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 12:35:55 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH v3 06/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_sregs Date: Mon, 4 Dec 2017 21:35:28 +0100 Message-Id: <20171204203538.8370-7-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_123612_328778_745FC7F9 X-CRM114-Status: GOOD ( 12.28 ) 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_get_sregs(). Signed-off-by: Christoffer Dall Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck --- arch/powerpc/kvm/book3s.c | 8 +++++++- arch/powerpc/kvm/booke.c | 9 ++++++++- arch/s390/kvm/kvm-s390.c | 4 ++++ arch/x86/kvm/x86.c | 3 +++ virt/kvm/kvm_main.c | 2 -- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 24bc7aabfc44..6cc2377549f7 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -484,7 +484,13 @@ 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; + + vcpu_load(vcpu); + 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 bcbbeddc3430..f647e121070e 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1613,11 +1613,18 @@ 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; + + vcpu_load(vcpu); + 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 e3476430578a..18011fc4ac49 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2737,8 +2737,12 @@ 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) { + vcpu_load(vcpu); + 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 75eacce78f59..20a5f6776eea 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7400,6 +7400,8 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, { struct desc_ptr dt; + vcpu_load(vcpu); + 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); @@ -7431,6 +7433,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 963e249d7b79..779c03e39fa4 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2581,9 +2581,7 @@ static long kvm_vcpu_ioctl(struct file *filp, r = -ENOMEM; if (!kvm_sregs) goto out; - vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl_get_sregs(vcpu, kvm_sregs); - vcpu_put(vcpu); if (r) goto out; r = -EFAULT;