From: Joerg Roedel <[email protected]> In the KVM_RUN path, select a runnable VCPU plane and use it to enter the guest. Also handle KVM_REQ_PLANE_RESCHED events to switch planes without exiting to user-space.
Signed-off-by: Joerg Roedel <[email protected]> --- arch/x86/kvm/x86.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 7e94a378b3d2..b9828cd31136 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -11398,6 +11398,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) goto out; } } + + if (kvm_check_request(KVM_REQ_PLANE_RESCHED, vcpu)) { + vcpu->common->plane_switch = true; + r = 0; + goto out; + } } if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win || @@ -12076,7 +12082,7 @@ static int kvm_x86_vcpu_pre_run(struct kvm_vcpu *vcpu) return kvm_x86_call(vcpu_pre_run)(vcpu); } -int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) +static int __kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) { struct kvm_queued_exception *ex = &vcpu->arch.exception; struct kvm_run *kvm_run = vcpu->run; @@ -12196,6 +12202,27 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) return r; } +int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu_plane0) +{ + struct kvm_vcpu_common *common = vcpu_plane0->common; + int ret; + + do { + struct kvm_vcpu *vcpu = kvm_vcpu_select_plane(vcpu_plane0); + + if (vcpu == NULL) + return -EINVAL; + + common->plane_switch = false; + + ret = __kvm_arch_vcpu_ioctl_run(vcpu); + if (ret) + break; + } while (vcpu_plane0->common->plane_switch); + + return ret; +} + static void __get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) { if (vcpu->arch.emulate_regs_need_sync_to_vcpu) { -- 2.53.0
