From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH v2] KVM: nVMX: Fix attempting to emulate "Acknowledge interrupt on exit" when there is no interrupt which L1 requires to inject to L2 Date: Wed, 2 Aug 2017 10:13:09 +0200 Message-ID: <09b9f160-eae2-c7a8-2405-053c7d44dbcb@redhat.com> References: <1501554327-3608-1-git-send-email-wanpeng.li@hotmail.com> <20170801195859.GB1437@flask> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "linux-kernel@vger.kernel.org" , kvm , Wanpeng Li To: Wanpeng Li , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Return-path: In-Reply-To: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 02/08/2017 10:05, Wanpeng Li wrote: >>> >>> SDM says that with acknowledge interrupt on exit, bit 31 of the VM-exit >>> interrupt information (valid interrupt) is always set to 1 on >>> EXIT_REASON_EXTERNAL_INTERRUPT. We don't want to break hypervisors >>> expecting an interrupt in that case, so we should do a userspace VM exit >>> when the window is open and then inject the userspace interrupt with a >>> VM exit. >> Agreed. >> >>> The simplest thing that came to my mind is to: >>> >>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c >>> index 39a6222bf968..9ad0c882c4f5 100644 >>> --- a/arch/x86/kvm/vmx.c >>> +++ b/arch/x86/kvm/vmx.c >>> @@ -10687,7 +10687,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 && !nested_exit_intr_ack_set(vcpu))) && >>> nested_exit_on_intr(vcpu)) { >>> if (vmx->nested.nested_run_pending) >>> return -EBUSY; >>> >> Agreed. > > What's your opinion, Paolo? :) Actually I considered the above idea > before, it is what SDM defined. Radim and I always agree. :) Paolo