From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roman Kagan Subject: [PATCH v2 4/5] kvm/vmx: kick L2 guest to L1 by ready async_pf Date: Mon, 12 Dec 2016 17:32:24 +0300 Message-ID: <20161212143225.10580-5-rkagan@virtuozzo.com> References: <20161212143225.10580-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-ve1eur01on0118.outbound.protection.outlook.com ([104.47.1.118]:36135 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751613AbcLLXD4 (ORCPT ); Mon, 12 Dec 2016 18:03:56 -0500 In-Reply-To: <20161212143225.10580-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