Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2524189yba; Mon, 15 Apr 2019 13:33:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/cHth5Cn2wypPqJz+Mgh/19eD/MjjNJSCsrG+v7HrKDUCvO85m/jYhRfjDyUGtcrIxuFB X-Received: by 2002:a65:62ce:: with SMTP id m14mr58937099pgv.191.1555360381539; Mon, 15 Apr 2019 13:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555360381; cv=none; d=google.com; s=arc-20160816; b=ykZLnCV6622Q2jovCHAoGrGx5/tU2kBtfyL1neMUuBRs4p213rskGEvo2cAA2qOgwB NS+F135k3h2QH8L5U/th0ZTb6DD1c/VptsfbeoloU3rtuHARphACw+3NjIu1y5QTfcTk muGWZ3+hg306Mjn6UsutjQCSxMEdjRUkkgO3qj5JiD8YAiW6QQg5AqEfKPvGYIlavp1L /wlmDYaiO4MmVbcMzJqoCSgeyQGXM5lMfw8yN0joopVpM48OHBKdLosfxDgGy4SKz3cP BnjQLGXDK5NNR0AUM/kfe1ufBXZz0Od+d1KGn2/AtLBC4Y727fctcECvNzSWjCbDFHha vdOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jON93PMlFYOQPX0ZOgPnzb+TwncAgep11uL7WLlkcsg=; b=zdikczvE3ORnlhIvcJd8qdBVD1QhpvxrebFhDVJoo2oy581sGBEGEbgPaKu/eBnu5x XoGETjHkTSx9IGbjdOdkFci+oCVVW+mfVhRQ5QhrnSnfPy2/zEcagLiQ/vscGHUDBIO4 oZng6abs0y+kj36l4uXwD3UeeqlwOkG4oW5hrsR4x72Dzzrnfc1Jqki9b+ggjL7Vtugs uO0kCnFMn0lAaRFYUQkuijivQhyMo544jnAm6xOXsPEtsLficrCTh5KVFSKcMAHojNg7 t8jJhIUGE8RTccsFq6QRzSc7wU4Qs8OFonzh5Pdd9JI3lqJCw3K+GCEOytDaYX9gmph8 ZMYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KpXMYi2v; 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 k75si45631033pgc.515.2019.04.15.13.32.45; Mon, 15 Apr 2019 13:33:01 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=KpXMYi2v; 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 S1730290AbfDOT0Q (ORCPT + 99 others); Mon, 15 Apr 2019 15:26:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:38108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728163AbfDOTEu (ORCPT ); Mon, 15 Apr 2019 15:04:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9CB22218D3; Mon, 15 Apr 2019 19:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355090; bh=m27+std3nGEjoEfWY8130YdlrwBcOKx0ogHcBRyzlwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KpXMYi2vb+wPW5Boec40JcaAB1xPpkkNwx3RX+ObG1koqjmVEJQsc5YGZ3dPra7Uj QxndVc011sOBDq8Irg2LyvYrkfX+v+w1Cbx+3oX76EqERS7x01JuRQEWY9WEsXPSI+ qW9vf0WDPEQS+VVQO/UcSXnPfS+aoLj5uiB0FjuU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jim Mattson , Peter Shier , Sean Christopherson , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Sasha Levin Subject: [PATCH 4.19 001/101] kvm: nVMX: NMI-window and interrupt-window exiting should wake L2 from HLT Date: Mon, 15 Apr 2019 20:57:59 +0200 Message-Id: <20190415183740.416561639@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 9ebdfe5230f2e50e3ba05c57723a06e90946815a ] According to the SDM, "NMI-window exiting" VM-exits wake a logical processor from the same inactive states as would an NMI and "interrupt-window exiting" VM-exits wake a logical processor from the same inactive states as would an external interrupt. Specifically, they wake a logical processor from the shutdown state and from the states entered using the HLT and MWAIT instructions. Fixes: 6dfacadd5858 ("KVM: nVMX: Add support for activity state HLT") Signed-off-by: Jim Mattson Reviewed-by: Peter Shier Suggested-by: Sean Christopherson [Squashed comments of two Jim's patches and used the simplified code hunk provided by Sean. - Radim] Signed-off-by: Radim Krčmář Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index f99f59625da5..e61ac229a6c1 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -12836,11 +12836,15 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) nested_cache_shadow_vmcs12(vcpu, vmcs12); /* - * If we're entering a halted L2 vcpu and the L2 vcpu won't be woken - * by event injection, halt vcpu. + * If we're entering a halted L2 vcpu and the L2 vcpu won't be + * awakened by event injection or by an NMI-window VM-exit or + * by an interrupt-window VM-exit, halt the vcpu. */ if ((vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) && - !(vmcs12->vm_entry_intr_info_field & INTR_INFO_VALID_MASK)) { + !(vmcs12->vm_entry_intr_info_field & INTR_INFO_VALID_MASK) && + !(vmcs12->cpu_based_vm_exec_control & CPU_BASED_VIRTUAL_NMI_PENDING) && + !((vmcs12->cpu_based_vm_exec_control & CPU_BASED_VIRTUAL_INTR_PENDING) && + (vmcs12->guest_rflags & X86_EFLAGS_IF))) { vmx->nested.nested_run_pending = 0; return kvm_vcpu_halt(vcpu); } -- 2.19.1