aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoffer Dall <christoffer.dall@linaro.org>2018-02-27 06:33:50 -0500
committerMarc Zyngier <marc.zyngier@arm.com>2018-03-14 14:29:14 -0400
commite21a4f3a930cda6e4902cb5b3213365e5ff3ce7c (patch)
tree6200880064b9c113f5498186ac1ac704427d61ca
parent62b06f8f429cd233e4e2e7bbd21081ad60c9018f (diff)
KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN
Calling vcpu_load() registers preempt notifiers for this vcpu and calls kvm_arch_vcpu_load(). The latter will soon be doing a lot of heavy lifting on arm/arm64 and will try to do things such as enabling the virtual timer and setting us up to handle interrupts from the timer hardware. Loading state onto hardware registers and enabling hardware to signal interrupts can be problematic when we're not actually about to run the VCPU, because it makes it difficult to establish the right context when handling interrupts from the timer, and it makes the register access code difficult to reason about. Luckily, now when we call vcpu_load in each ioctl implementation, we can simply remove the call from the non-KVM_RUN vcpu ioctls, and our kvm_arch_vcpu_load() is only used for loading vcpu content to the physical CPU when we're actually going to run the vcpu. Cc: stable@vger.kernel.org Fixes: 9b062471e52a ("KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl") Reviewed-by: Julien Grall <julien.grall@arm.com> Reviewed-by: Marc Zyngier <marc.zyngier@arm.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r--arch/arm64/kvm/guest.c3
-rw-r--r--virt/kvm/arm/arm.c9
2 files changed, 0 insertions, 12 deletions
diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
index d7e3299a7734..959e50d2588c 100644
--- a/arch/arm64/kvm/guest.c
+++ b/arch/arm64/kvm/guest.c
@@ -363,8 +363,6 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
363{ 363{
364 int ret = 0; 364 int ret = 0;
365 365
366 vcpu_load(vcpu);
367
368 trace_kvm_set_guest_debug(vcpu, dbg->control); 366 trace_kvm_set_guest_debug(vcpu, dbg->control);
369 367
370 if (dbg->control & ~KVM_GUESTDBG_VALID_MASK) { 368 if (dbg->control & ~KVM_GUESTDBG_VALID_MASK) {
@@ -386,7 +384,6 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
386 } 384 }
387 385
388out: 386out:
389 vcpu_put(vcpu);
390 return ret; 387 return ret;
391} 388}
392 389
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
index 86941f6181bb..53572304843b 100644
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
@@ -384,14 +384,11 @@ static void vcpu_power_off(struct kvm_vcpu *vcpu)
384int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, 384int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
385 struct kvm_mp_state *mp_state) 385 struct kvm_mp_state *mp_state)
386{ 386{
387 vcpu_load(vcpu);
388
389 if (vcpu->arch.power_off) 387 if (vcpu->arch.power_off)
390 mp_state->mp_state = KVM_MP_STATE_STOPPED; 388 mp_state->mp_state = KVM_MP_STATE_STOPPED;
391 else 389 else
392 mp_state->mp_state = KVM_MP_STATE_RUNNABLE; 390 mp_state->mp_state = KVM_MP_STATE_RUNNABLE;
393 391
394 vcpu_put(vcpu);
395 return 0; 392 return 0;
396} 393}
397 394
@@ -400,8 +397,6 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
400{ 397{
401 int ret = 0; 398 int ret = 0;
402 399
403 vcpu_load(vcpu);
404
405 switch (mp_state->mp_state) { 400 switch (mp_state->mp_state) {
406 case KVM_MP_STATE_RUNNABLE: 401 case KVM_MP_STATE_RUNNABLE:
407 vcpu->arch.power_off = false; 402 vcpu->arch.power_off = false;
@@ -413,7 +408,6 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
413 ret = -EINVAL; 408 ret = -EINVAL;
414 } 409 }
415 410
416 vcpu_put(vcpu);
417 return ret; 411 return ret;
418} 412}
419 413
@@ -1036,8 +1030,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
1036 struct kvm_device_attr attr; 1030 struct kvm_device_attr attr;
1037 long r; 1031 long r;
1038 1032
1039 vcpu_load(vcpu);
1040
1041 switch (ioctl) { 1033 switch (ioctl) {
1042 case KVM_ARM_VCPU_INIT: { 1034 case KVM_ARM_VCPU_INIT: {
1043 struct kvm_vcpu_init init; 1035 struct kvm_vcpu_init init;
@@ -1114,7 +1106,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
1114 r = -EINVAL; 1106 r = -EINVAL;
1115 } 1107 }
1116 1108
1117 vcpu_put(vcpu);
1118 return r; 1109 return r;
1119} 1110}
1120 1111