From patchwork Sat Nov 25 20:57:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10075169 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 39E9960383 for ; Sat, 25 Nov 2017 21:00:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B0A128F53 for ; Sat, 25 Nov 2017 21:00:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FAAC28F69; Sat, 25 Nov 2017 21:00:52 +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=ham 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 86ED428F53 for ; Sat, 25 Nov 2017 21:00:51 +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=yDjsKLHlFMgaDKgk51w3ylKwSX3/A+LJ1P9bth1kyFs=; b=bSd8QLgYFwiKhlTOwsNynlTtEt b9wH/i7JCkdp4WmFbi7uOwgQ1okQEmwYJBB+wTNu0gYQKZsDC1spF/O7+pC9EFGyKBvlilUNk4Ok5 3arUrFwhUZwbVk2/2v8LcjUOhmnG1QENknvcESsXS0h0qeIRNAgqtKqXVlMfpflBzJYm6KnRAU2kw FpkViBe/F18gNu4u4emX8BfqF0hdIY5n7LgSLTiZSrJ7pOTLdi0xZ/BI3iL+GeAt6c8NN4vwNio8j LxSdQtaBgzMuTiABNbojJ+AcluBc0II0lhsEPxeIPHvBfcA6RQnsEzNbam+ffvM1bk29A4Yr5W1LJ tHXm61mQ==; 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 1eIhZC-0000f9-N3; Sat, 25 Nov 2017 21:00: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 1eIhWH-0005AD-Vd for linux-arm-kernel@lists.infradead.org; Sat, 25 Nov 2017 20:57:56 +0000 Received: by mail-wr0-x242.google.com with SMTP id w95so23074042wrc.2 for ; Sat, 25 Nov 2017 12:57:30 -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=ui5mN1YFQ4xoRI57vbCAGUgorxDcqfto5Fqw+/t0EH8=; b=IuqAmmS/XqxdikR/NooGXBGp5lHAdQmFvTybNDlcXrbiaUtWyhNFQ+z3Rr7vQUmnPU 4EryX4GhZ9H6CHsLXMQclunCVGR9e+Z0g3Fosu89VtGGTBhXrcxT25RiAq0GngemodXC EifAgOQsVnsP7gvwggkmtF8L1DYZJMqbNO6ac= 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=ui5mN1YFQ4xoRI57vbCAGUgorxDcqfto5Fqw+/t0EH8=; b=BhweEeRrgOoKa1UuxjlAZnaoCdQLUv9EEVWvJxH2YiqepfNzsf+/7gGmOXEs9cEVah IiLZ+m+ypwNRAtyPV+/NsqwpjEAWlRzQhO3GSPps9V010469Inid58qS+ITD47cJIpft lf9fc8a2A95jYETwVch3J5PdfSIGCWIKt3G9z4v21bOacqJ/Cqp+Z+WJjnGbut0gu9Qn wm7pjzHlIWeUfU8vH53fnGrraiHc3trEfpReScCAnuq8cEQxYNG0bHnoKBtr6b/cf1qK 3nxsMGanNRnBPvq0E4iogvJNx3+6U5Wuvoty7qE5KR5g8aYS1X4nhB6kDSAzauZHOG1q XcEw== X-Gm-Message-State: AJaThX7w9l88lIVvBb3Ulf0gQQVJOn1MAvCjgdd42Kv1UjoXTZjJJBiu je9nlV0C1rejuac745ne0s2IoQ== X-Google-Smtp-Source: AGs4zMaJ6QA2oT9qIhdCM7Ee5szQBtmE1+FC0zXt1DNfQ3dlWmWt0jL9ut0wCDCEzn7KT8q/uYrlqw== X-Received: by 10.223.164.22 with SMTP id d22mr30855660wra.232.1511643449007; Sat, 25 Nov 2017 12:57:29 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Nov 2017 12:57:28 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH 10/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_translate Date: Sat, 25 Nov 2017 21:57:13 +0100 Message-Id: <20171125205718.7731-11-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_125751_073369_A993BD1C X-CRM114-Status: GOOD ( 11.49 ) 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_translate(). Signed-off-by: Christoffer Dall --- arch/powerpc/kvm/booke.c | 4 ++++ arch/x86/kvm/x86.c | 6 ++++++ virt/kvm/kvm_main.c | 4 ---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 59d1d0bd6909..8069d93bf654 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1804,7 +1804,11 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, { int r; + r = vcpu_load(vcpu); + if (r) + return r; r = kvmppc_core_vcpu_translate(vcpu, tr); + vcpu_put(vcpu); return r; } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1a4fa1f2fa46..ae8685155d11 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7654,6 +7654,11 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, unsigned long vaddr = tr->linear_address; gpa_t gpa; int idx; + int r; + + r = vcpu_load(vcpu); + if (r) + return r; idx = srcu_read_lock(&vcpu->kvm->srcu); gpa = kvm_mmu_gva_to_gpa_system(vcpu, vaddr, NULL); @@ -7663,6 +7668,7 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, tr->writeable = 1; tr->usermode = 0; + vcpu_put(vcpu); return 0; } diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index bcfdb4800e44..173f98d9c58d 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2635,11 +2635,7 @@ static long kvm_vcpu_ioctl(struct file *filp, r = -EFAULT; if (copy_from_user(&tr, argp, sizeof(tr))) goto out; - r = vcpu_load(vcpu); - if (r) - goto out; r = kvm_arch_vcpu_ioctl_translate(vcpu, &tr); - vcpu_put(vcpu); if (r) goto out; r = -EFAULT;