From: cdall@kernel.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.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 [thread overview]
Message-ID: <20171204203538.8370-3-cdall@kernel.org> (raw)
In-Reply-To: <20171204203538.8370-1-cdall@kernel.org>
From: Christoffer Dall <christoffer.dall@linaro.org>
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 <david@redhat.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
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);
--
2.14.2
next prev parent reply other threads:[~2017-12-04 20:35 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-04 20:35 [PATCH v3 00/16] Move vcpu_load and vcpu_put calls to arch code Christoffer Dall
2017-12-04 20:35 ` [PATCH v3 01/16] KVM: Take vcpu->mutex outside vcpu_load Christoffer Dall
2017-12-05 14:32 ` Christian Borntraeger
2017-12-11 11:51 ` Cornelia Huck
2017-12-04 20:35 ` Christoffer Dall [this message]
2017-12-11 11:57 ` [PATCH v3 02/16] KVM: Prepare for moving vcpu_load/vcpu_put into arch specific code Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 03/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_run Christoffer Dall
2017-12-05 14:39 ` Christian Borntraeger
2017-12-11 12:02 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 04/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_regs Christoffer Dall
2017-12-08 16:21 ` David Hildenbrand
2017-12-11 12:07 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 05/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_regs Christoffer Dall
2017-12-08 16:22 ` David Hildenbrand
2017-12-11 12:09 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 06/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_sregs Christoffer Dall
2017-12-08 16:23 ` David Hildenbrand
2017-12-11 12:13 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 07/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_sregs Christoffer Dall
2017-12-08 16:26 ` David Hildenbrand
2017-12-11 9:19 ` Christoffer Dall
2017-12-12 16:33 ` Paolo Bonzini
2017-12-11 12:15 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 08/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_mpstate Christoffer Dall
2017-12-11 12:23 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 09/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_mpstate Christoffer Dall
2017-12-11 12:25 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 10/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_translate Christoffer Dall
2017-12-11 12:29 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 11/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_guest_debug Christoffer Dall
2017-12-11 12:39 ` Cornelia Huck
2017-12-11 15:18 ` Christoffer Dall
2017-12-12 16:36 ` Paolo Bonzini
2017-12-04 20:35 ` [PATCH v3 12/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_fpu Christoffer Dall
2017-12-11 12:43 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 13/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_fpu Christoffer Dall
2017-12-11 12:45 ` Cornelia Huck
2017-12-04 20:35 ` [PATCH v3 14/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl Christoffer Dall
2017-12-11 13:12 ` Cornelia Huck
2017-12-11 15:22 ` Christoffer Dall
2017-12-12 16:47 ` Paolo Bonzini
2017-12-04 20:35 ` [PATCH v3 15/16] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN Christoffer Dall
2017-12-04 20:35 ` [PATCH v3 16/16] KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_first_run_init Christoffer Dall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171204203538.8370-3-cdall@kernel.org \
--to=cdall@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).