Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752162AbdHBINQ (ORCPT ); Wed, 2 Aug 2017 04:13:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41638 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751154AbdHBINN (ORCPT ); Wed, 2 Aug 2017 04:13:13 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B5E8AC0ED40A Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com 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 To: Wanpeng Li , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Cc: "linux-kernel@vger.kernel.org" , kvm , Wanpeng Li References: <1501554327-3608-1-git-send-email-wanpeng.li@hotmail.com> <20170801195859.GB1437@flask> From: Paolo Bonzini Message-ID: <09b9f160-eae2-c7a8-2405-053c7d44dbcb@redhat.com> Date: Wed, 2 Aug 2017 10:13:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 02 Aug 2017 08:13:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1292 Lines: 35 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