From: Roman Kagan Subject: [PATCH 4/5] kvm/vmx: kick L2 guest to L1 by ready async_pf Date: Fri, 2 Dec 2016 11:47:53 +0300 Message-ID: <20161202084754.22860-5-rkagan@virtuozzo.com> References: <20161202084754.22860-1-rkagan@virtuozzo.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Denis Lunev , Roman Kagan To: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Paolo Bonzini , Return-path: Received: from mail-db5eur01on0119.outbound.protection.outlook.com ([104.47.2.119]:32352 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932795AbcLBIsU (ORCPT ); Fri, 2 Dec 2016 03:48:20 -0500 In-Reply-To: <20161202084754.22860-1-rkagan@virtuozzo.com> Sender: kvm-owner@vger.kernel.org List-ID: When async pagefault is resolved vCPU may be executing L2 guest. In order to allow L1 take better scheduling decisions in such cases, make L2 exit to L1 on a fake external interupt, without actually injecting it (unless L2 has other reasons to vmexit). This patch does that for x86/Intel. Signed-off-by: Roman Kagan --- arch/x86/kvm/vmx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 5382b82..fc97489 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -10420,7 +10420,8 @@ static int vmx_check_nested_events(struct kvm_vcpu *vcpu, bool external_intr) return 0; } - if ((kvm_cpu_has_interrupt(vcpu) || external_intr) && + if ((kvm_cpu_has_interrupt(vcpu) || external_intr || + kvm_async_pf_has_ready(vcpu)) && nested_exit_on_intr(vcpu)) { if (vmx->nested.nested_run_pending) return -EBUSY; @@ -10772,9 +10773,9 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason, if ((exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT) && nested_exit_intr_ack_set(vcpu)) { int irq = kvm_cpu_get_interrupt(vcpu); - WARN_ON(irq < 0); - vmcs12->vm_exit_intr_info = irq | - INTR_INFO_VALID_MASK | INTR_TYPE_EXT_INTR; + if (irq >= 0) + vmcs12->vm_exit_intr_info = irq | + INTR_INFO_VALID_MASK | INTR_TYPE_EXT_INTR; } trace_kvm_nested_vmexit_inject(vmcs12->vm_exit_reason, -- 2.9.3