Received: by 10.223.176.5 with SMTP id f5csp252801wra; Thu, 8 Feb 2018 21:08:33 -0800 (PST) X-Google-Smtp-Source: AH8x224HasoN6doEiKC8CiN6uTEJVMwcbB1LBPiz8WgOCuowH4WwH9pOL2BLZ5Xj8Ji2DomIZghH X-Received: by 2002:a17:902:8ec4:: with SMTP id x4-v6mr1330602plo.271.1518152913436; Thu, 08 Feb 2018 21:08:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518152913; cv=none; d=google.com; s=arc-20160816; b=0QH5ey7ZyRWAWid6NtThHJh159cKKzhclbJAoXGqAswkExysVWBHwNLBozaOrTtY3c mYjKgqX2kgs08ZvnS3ltS2oHBSwhotvOAYAicPqxVeWBscqjzEsi+obJMXb6/M8whdrE mvEI680Kuu3KULAP/Rv4WP0Z6QdLi+Q5OF6E57l/563mM2VWtXek6im7iKjWqQaBsBk7 Uu1mY+X2GY6nra/Xi6yzeOc3rnczZZCTsaoKBSZCYk4LwjzpOf+VDIxiGwvehPF1aNiC n5peHTvZrHExRslFV+YhTN8JnmmJQRsyz554aGU0+uYCk8PbkUi6EHU6LrBb6UN+oed3 /8hA== 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=qsPUfRsfrxSxiLTf37VVnyf7FJd2+xYL3fYIfMQVTCw=; b=yRivyJZ0x1KRZ+MFPQaUxWvJeJaHMFzUxwTCjMCGPV6S0/3b9Sn1ZLBxaSKEjrgtm4 2t9Fscm7gUx41XmuHg0J1Kg+BBRjTugajYFATxT3Weoz44cmmr1QTNTj+Y9EqivqOnRX xPLApIDAXIowmW0A9LjfrMbMQbbmRH+RHc0KQAzYjYOSEDmCo+nIZd7Mynt9Zpyp2jI+ vnHH6hGwZcnEiLTJerix9afElCTHx/+7gzIq7VaCTMMy4iEKKQ1RN2mM6iyIoh9IsoXv 0ITYgZGf0Swgyp3Kj/YUNTp0rVsUkDzL64lhbAU1Tw4eFGi5sobByEn0QXr3hAxh686F pl7g== 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 w11-v6si1028498plz.782.2018.02.08.21.08.19; Thu, 08 Feb 2018 21:08:33 -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 S1750970AbeBIFHk (ORCPT + 99 others); Fri, 9 Feb 2018 00:07:40 -0500 Received: from mga12.intel.com ([192.55.52.136]:9300 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750770AbeBIFHj (ORCPT ); Fri, 9 Feb 2018 00:07:39 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Feb 2018 21:07:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,482,1511856000"; d="scan'208";a="25973512" Received: from gao-cwp.sh.intel.com ([10.239.13.104]) by orsmga003.jf.intel.com with ESMTP; 08 Feb 2018 21:07:36 -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 , Liran Alon Subject: [PATCH v2] x86/kvm/vmx: Don't halt vcpu when L1 is injecting events to L2 Date: Fri, 9 Feb 2018 13:09:12 +0800 Message-Id: <1518152952-12633-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 according to SDM 26.6.2 Activity State. 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. Cc: Liran Alon Signed-off-by: Chao Gao --- Changes in v2: - Remove VID stuff. Only handle event injection in this patch. --- arch/x86/kvm/vmx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index bb5b488..42f39d9 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -10985,7 +10985,12 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) if (ret) return ret; - if (vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) + /* + * If we're entering a halted L2 vcpu and the L2 vcpu won't be woken + * by event injection, halt vcpu for optimization. + */ + if ((vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) && + !(vmcs12->vm_entry_intr_info_field & VECTORING_INFO_VALID_MASK)) return kvm_vcpu_halt(vcpu); vmx->nested.nested_run_pending = 1; -- 1.9.1