Received: by 10.223.176.5 with SMTP id f5csp1481127wra; Wed, 7 Feb 2018 21:13:25 -0800 (PST) X-Google-Smtp-Source: AH8x224QfFvmaHjIHwk4tZNbTrn90qhY9luFz+zsT1PKAUiDIN4yKeBEuYk7io0hZuRUcM/5y6EL X-Received: by 2002:a17:902:8585:: with SMTP id e5-v6mr8329154plo.165.1518066804923; Wed, 07 Feb 2018 21:13:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518066804; cv=none; d=google.com; s=arc-20160816; b=xK8o3vtukD/W8lSyJ2u5EVvflyFgGZ/tmy+5A6H3W1iIXwM+lXU/C9qGYgdi6kz0cl Uoq8rA6k/hSGoaSt53KzGJl6+paVLUUvJv/3nfV3kaqByxU8dogbM0atVFbMlVlw1k4E OQYS3w3jON2aPuLHPSFJE9D7BTmbfXHD8jWe8zccfH/XVgjP6IdcsPYROifzJwSeFmWn 9ibjh1q54V79KY7WNVZMgzG/tj7TnJksnOJMDqjpwNjQXC4lmJxM62CRNTVs/kJB9y8t aqzGz9caMxveJfSBT54LUeKGfSw4eHjUkkDdgUnEkForDTJkAIQD0P6LteN6wS35QYMj KaJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=DS+BtHaIPJiqC69BouMHxQbDnjzceA8YpQze3oGk8Pk=; b=Kco+4I+PRC1/Vvl3ui5L2jaiH15K5JXa1oumbYenq+SNKCattyzw5nLboKpx48Pqdc 4gQicI3c+4YbIm5UWQFN7FbzjT+VwWzNHiUBqIwU+lQyGXU+oVkRx5zwiAcWgHjmUtDN Fi4jcYBWQwC6D+Jb6wnqSzQD8A6FQbFmVqrVzNSNBUHlqcTtSGFSb4V2SkRcDdBS7H5J pRgDU839Ix8OXi4UebemQe2O6JbcJGNPYNjq+2/glmcq+785BAoaEAf39gi+Er+jXXdO 3vQgeMT/pjjP2EYMAPA+oY1ShfrOhWYkpvYPEs1uJygJkguuviJGXr/TNLZMUrFW0xJt gK9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si502702plh.549.2018.02.07.21.12.59; Wed, 07 Feb 2018 21:13:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750923AbeBHFL6 (ORCPT + 99 others); Thu, 8 Feb 2018 00:11:58 -0500 Received: from mga17.intel.com ([192.55.52.151]:9549 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbeBHFL5 (ORCPT ); Thu, 8 Feb 2018 00:11:57 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Feb 2018 21:11:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,476,1511856000"; d="scan'208";a="16402229" Received: from gao-cwp.sh.intel.com ([10.239.13.104]) by fmsmga008.fm.intel.com with ESMTP; 07 Feb 2018 21:11:55 -0800 From: Chao Gao To: kvm@vger.kernel.org Cc: Chao Gao , linux-kernel@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Paolo Bonzini Subject: [PATCH] x86/kvm/vmx: Don't halt vcpu when L1 is injecting events to L2 Date: Thu, 8 Feb 2018 13:13:36 +0800 Message-Id: <1518066816-7197-1-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Although L2 is in halt state, it will be in the active state after VM entry if the VM entry is vectoring. Halting the vcpu here means the event won't be injected to L2 and this decision isn't reported to L1. Thus L0 drops an event that should be injected to L2. Because virtual interrupt delivery may wake L2 vcpu, if VID is enabled, do the same thing -- don't halt L2. Signed-off-by: Chao Gao --- arch/x86/kvm/vmx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index bb5b488..e1fe4e4 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -10985,8 +10985,14 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) if (ret) return ret; - if (vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) - return kvm_vcpu_halt(vcpu); + if (vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) { + u32 intr_info = vmcs_read32(VM_ENTRY_INTR_INFO_FIELD); + u32 exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL); + + if (!(intr_info & VECTORING_INFO_VALID_MASK) && + !(exec_control & SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY)) + return kvm_vcpu_halt(vcpu); + } vmx->nested.nested_run_pending = 1; -- 1.9.1