Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751251AbdHCMaZ (ORCPT ); Thu, 3 Aug 2017 08:30:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44066 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751131AbdHCMaX (ORCPT ); Thu, 3 Aug 2017 08:30:23 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A934C356E2 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=rkrcmar@redhat.com Date: Thu, 3 Aug 2017 14:30:20 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Wanpeng Li Cc: "linux-kernel@vger.kernel.org" , kvm , Paolo Bonzini , Wanpeng Li Subject: Re: [PATCH v3] KVM: nVMX: Fix attempting to emulate "Acknowledge interrupt on exit" when there is no interrupt which L1 requires to inject to L2 Message-ID: <20170803123020.GA1015@flask> References: <1501670903-3368-1-git-send-email-wanpeng.li@hotmail.com> <20170802202628.GB32403@flask> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 03 Aug 2017 12:30:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1489 Lines: 31 2017-08-03 07:01+0800, Wanpeng Li: > 2017-08-03 4:26 GMT+08:00 Radim Krčmář : > > 2017-08-02 03:48-0700, Wanpeng Li: > >> From: Wanpeng Li > >> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > >> @@ -10761,7 +10761,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))) && > > > > I think it would be safer to also add something like the second hunk I > > posted (that also takes nested_exit_on_intr() into account). > > > > The issue is that we're allowing L2's GUEST_RFLAGS and > > GUEST_INTERRUPTIBILITY_INFO to disable userspace interrupt injection > > even though neither affect delivery of interrupts into L1. > > This means that L2 can block/postpone the delivery to L1 by doing "cli; > > busy_loop/normal_critical_section". > > Ouch! My fault, the v3 patch w/o the second hunk and w/ the second > hunk both can result in L1 guest softlockup. I just tested the patch > with L2 windows guest yesterday, however, the softlockup can happen > when the L2 is the linux guest. So should we still take the v2 for the > moment? Sure, that one is an improvement over the current situation (I guess it doesn't break any hypervisor). I'll just add a comment about its incorrectness.