From patchwork Mon Dec 4 20:35:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10091509 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 D2C2360327 for ; Mon, 4 Dec 2017 20:38:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C41A52925F for ; Mon, 4 Dec 2017 20:38:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B807129416; Mon, 4 Dec 2017 20:38:26 +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 33CF62925F for ; Mon, 4 Dec 2017 20:38:26 +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=5meK/SEt7e6gfdCFv+PnrFhX0UlKFNCJ9bu6LBF+Ofk=; b=iVARfirJXLkSFjggvrgnuQ+4pZ ri6Zt6Sgzm0Ef+rU/TM1zTt0mTdSh2Xd+Ef6E7JVdxVzSh3dt2mGvwviDCHDN4gQsKYjLK/T9nzqc rf/r4UEBpcF2pUWXayfOHaisVMhkHIaoVEyU0SeQvcbhQIJa/uGWJzfpaQsoNWN4LejGQwDb7pu4S n1nj6aiu593obOt6dUbNlUgt22pcl2ZkXFkSDmgppV14iRugTUIXMZwr/vLvmUPX2y3fWRc5olYoF h2tOdQSlYGxEjl/mGjz+HU8lkOUXCMMdOO3IczqZJhuRk1QZ3/31xiO/ULyipKHD34zwoQnJuW3LR G01gwSHw==; 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 1eLxVR-0008Oo-7I; Mon, 04 Dec 2017 20:38:25 +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 1eLxTI-0006BY-RU for linux-arm-kernel@lists.infradead.org; Mon, 04 Dec 2017 20:36:22 +0000 Received: by mail-wm0-x244.google.com with SMTP id b76so16706886wmg.1 for ; Mon, 04 Dec 2017 12:35:52 -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=H3UHU6SKbUaYY+fJMVRFGAOcJOcW4NAOt6j9Jv1qXKw=; b=hkyyIOgNiD2yk/QiH/b+ZJ7bja7odRW6fhLeq4vgJnhFUk2R88fLvHgC4F0jZTP2yz g0SW2fbYTDFzw3ek2jtatoLIq3AOzjBzcqhDpbiWPbQBrEbglZfWaZ3hkI9MpOtJgVXm UYLcHUriynwBE2BJvAyniPBQ0XPLbk+Fk9Ledy/T8Xi2Zy0Tfs4yamv5fyx0MuK6cduZ KTOO8rBSNjr3eif7G/nL/FW9E9ye8mofVeCJnOgfxpxdY1ROLmEabYkdSwVKw2se2BhR 9JesGNFfhdvHYNJvjiMaeNILL4xcXA+nATFysw5jxMAoJzOEVrfPAMGVRqy/u3AXHpD8 9hcw== 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=H3UHU6SKbUaYY+fJMVRFGAOcJOcW4NAOt6j9Jv1qXKw=; b=Yl71brDgnvUXFxOqV9MYYNhjObY3ANtVdw5UsNVPNQ3tFas2Kkv52+F1Dt9LBgF4Tb q47MlhslfWQZgNn9vD6j2u1II0Bwz8JX8m9abHvJteE95c7LOAuUontQkn/4RgTe75fM 8aNmE2R1Fn1yNdsmq9uLBjHistEE1gxw/bOjy7FP1Z4e8UNEftolsJxDyAu2SpM1Ldnu uUfg59bTvjkUGxSleXXMEKTm+axaPI9Il37MMCzb5lxgDFVF/jTMLyVZ8YPF6xpPFYIW oij5b4Zb0hmNM7wYASxReOrNds221x60nSSdiZjjvAu3MKNRk+KSku9/swEMjwluxMtZ 6qqA== X-Gm-Message-State: AJaThX757DpAebQ8RK24IhHwirqoq8Y/PR6uXZh7adoLdUlajeKMXXEr 6TJwJCJI4an7Ob/uxWz9F6wbfA== X-Google-Smtp-Source: AGs4zMbDMue5elYQG0Qj67flH6S0CBtUJHSvJQzXWc0cgaUKLO5d9dMaTzs65/Cdbu2A7tDAW6YdEg== X-Received: by 10.80.152.66 with SMTP id h2mr31815408edb.192.1512419751247; Mon, 04 Dec 2017 12:35:51 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 12:35:50 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH v3 02/16] KVM: Prepare for moving vcpu_load/vcpu_put into arch specific code Date: Mon, 4 Dec 2017 21:35:24 +0100 Message-Id: <20171204203538.8370-3-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_123613_039830_32F7ABA2 X-CRM114-Status: GOOD ( 11.97 ) 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 In preparation for moving calls to vcpu_load() and vcpu_put() into the architecture specific implementations of the KVM vcpu ioctls, move the calls in the main kvm_vcpu_ioctl() dispatcher function to each case of the ioctl select statement. This allows us to move the vcpu_load() and vcpu_put() calls into architecture specific implementations of vcpu ioctls, one by one. Reviewed-by: David Hildenbrand Signed-off-by: Christoffer Dall Reviewed-by: Cornelia Huck --- virt/kvm/kvm_main.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 39961fb8aef7..480b16c48f6b 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2525,13 +2525,13 @@ static long kvm_vcpu_ioctl(struct file *filp, if (mutex_lock_killable(&vcpu->mutex)) return -EINTR; - vcpu_load(vcpu); switch (ioctl) { case KVM_RUN: { struct pid *oldpid; r = -EINVAL; if (arg) goto out; + vcpu_load(vcpu); oldpid = rcu_access_pointer(vcpu->pid); if (unlikely(oldpid != current->pids[PIDTYPE_PID].pid)) { /* The thread running this VCPU changed. */ @@ -2543,6 +2543,7 @@ static long kvm_vcpu_ioctl(struct file *filp, put_pid(oldpid); } r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run); + vcpu_put(vcpu); trace_kvm_userspace_exit(vcpu->run->exit_reason, r); break; } @@ -2553,7 +2554,9 @@ static long kvm_vcpu_ioctl(struct file *filp, kvm_regs = kzalloc(sizeof(struct kvm_regs), GFP_KERNEL); if (!kvm_regs) goto out; + vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl_get_regs(vcpu, kvm_regs); + vcpu_put(vcpu); if (r) goto out_free1; r = -EFAULT; @@ -2573,7 +2576,9 @@ static long kvm_vcpu_ioctl(struct file *filp, r = PTR_ERR(kvm_regs); goto out; } + vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl_set_regs(vcpu, kvm_regs); + vcpu_put(vcpu); kfree(kvm_regs); break; } @@ -2582,7 +2587,9 @@ 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; @@ -2598,13 +2605,17 @@ static long kvm_vcpu_ioctl(struct file *filp, kvm_sregs = NULL; goto out; } + vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl_set_sregs(vcpu, kvm_sregs); + vcpu_put(vcpu); break; } case KVM_GET_MP_STATE: { struct kvm_mp_state mp_state; + vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl_get_mpstate(vcpu, &mp_state); + vcpu_put(vcpu); if (r) goto out; r = -EFAULT; @@ -2619,7 +2630,9 @@ static long kvm_vcpu_ioctl(struct file *filp, r = -EFAULT; if (copy_from_user(&mp_state, argp, sizeof(mp_state))) goto out; + vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl_set_mpstate(vcpu, &mp_state); + vcpu_put(vcpu); break; } case KVM_TRANSLATE: { @@ -2628,7 +2641,9 @@ static long kvm_vcpu_ioctl(struct file *filp, r = -EFAULT; if (copy_from_user(&tr, argp, sizeof(tr))) goto out; + vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl_translate(vcpu, &tr); + vcpu_put(vcpu); if (r) goto out; r = -EFAULT; @@ -2643,7 +2658,9 @@ static long kvm_vcpu_ioctl(struct file *filp, r = -EFAULT; if (copy_from_user(&dbg, argp, sizeof(dbg))) goto out; + vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl_set_guest_debug(vcpu, &dbg); + vcpu_put(vcpu); break; } case KVM_SET_SIGNAL_MASK: { @@ -2674,7 +2691,9 @@ 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; @@ -2690,14 +2709,17 @@ static long kvm_vcpu_ioctl(struct file *filp, fpu = NULL; goto out; } + vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, fpu); + vcpu_put(vcpu); break; } default: + vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl(filp, ioctl, arg); + vcpu_put(vcpu); } out: - vcpu_put(vcpu); mutex_unlock(&vcpu->mutex); kfree(fpu); kfree(kvm_sregs);