Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp730340ybt; Fri, 19 Jun 2020 12:12:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyibHBILiQmV3hmw1yhXsPHw6WWWjaIHfdJWkX15EbCqH/y9M0Qc4ZKNwzf+xRE89ozM/19 X-Received: by 2002:a17:906:fb9b:: with SMTP id lr27mr4853003ejb.405.1592593963678; Fri, 19 Jun 2020 12:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592593963; cv=none; d=google.com; s=arc-20160816; b=0Pjw1tDMOkRHM892O5m2kxveTPj52U4CmVvmtwgP9cwrTWJC3soW943kNYEim4VX5L cHsJHXcKJsD7iclwEgMc75bVQhh7J8+lP4Ue4PJaaZUgzFcoprJLhd2X62rpApwda/3B zk+L0XIzg5Ism7TSY3s+ejdM7T3xVyl4Sc5v82EcYjF8ePrC0sL7HcAd0l9cK5QjA+cN B2E6dvfOlQYf9MpcMUJ80b04AJrQNnYrDZVt9jekt2UpeMoIaSavmBkqDh92SUxQXcvV Nns5dCfldx7Uy4cc2JPZhdqI4/Ij5EZge+Km/mysgEHkwuDxbfKHHo5IpDN8i4XKgh+C XC2w== 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=X3GmXmtCKHY647eDVydD8GTf12836mF4Wwv+E1HYV3I=; b=WUW7SWHovt74TZXb9iRY669OnYScqNU21AGx8zTKZUWYPTcSoFSYjpargu49v9lRem J4F8QmOkkon2pgYDv3Mp7UeypNcWc5UNlgZCF2mo4UbwuS781Nvm77aEbCy6hy2ciog0 oiVCR1V1aqiRebViQ/Cg/xPg7dCCAIg1xA+v68UxXUZzcMhl76ImWs7liairfaJ7emVr jYRGxSRmqlRhtwfTtIimLZ9W3gpQdTkJlGWxhHpGqs/JYjpNiwy11v54SWCLPsAcquS5 I1DjWyWnnP6r88UA1E/zVem7vbWh35M2vL3XkC1KWcld3COwazy+lNxoH2wU00Kv9/+M UV3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Fs/Hqc4k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm15si4869321ejc.728.2020.06.19.12.12.20; Fri, 19 Jun 2020 12:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Fs/Hqc4k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733189AbgFSOlO (ORCPT + 99 others); Fri, 19 Jun 2020 10:41:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:59326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387524AbgFSOlD (ORCPT ); Fri, 19 Jun 2020 10:41:03 -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 1A7542070A; Fri, 19 Jun 2020 14:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592577663; bh=VsihRR3Y1zmxLKTxg56v6Z1yJ6j+QS1iZJgaK1mjsJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fs/Hqc4k5yZAPiGkgq+yNHL0fnyuf70YbmwEKgWnZZMA/PrqwCfjllHKbzZ0IwkYe B8YB/1OGcdcIMFsvGn2nCgsC08ohMyjSqvR80Uj0S4FlCb4mcKnbBiQrK/PeurwGar IKHhH+4LP9Xm3wL+OU5I6/KGx/qBexGOhGXZ6e7I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jim Mattson , Xiaoyao Li , Sean Christopherson , Paolo Bonzini Subject: [PATCH 4.9 039/128] KVM: nVMX: Consult only the "basic" exit reason when routing nested exit Date: Fri, 19 Jun 2020 16:32:13 +0200 Message-Id: <20200619141622.282898678@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141620.148019466@linuxfoundation.org> References: <20200619141620.148019466@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Sean Christopherson commit 2ebac8bb3c2d35f5135466490fc8eeaf3f3e2d37 upstream. Consult only the basic exit reason, i.e. bits 15:0 of vmcs.EXIT_REASON, when determining whether a nested VM-Exit should be reflected into L1 or handled by KVM in L0. For better or worse, the switch statement in nested_vmx_exit_reflected() currently defaults to "true", i.e. reflects any nested VM-Exit without dedicated logic. Because the case statements only contain the basic exit reason, any VM-Exit with modifier bits set will be reflected to L1, even if KVM intended to handle it in L0. Practically speaking, this only affects EXIT_REASON_MCE_DURING_VMENTRY, i.e. a #MC that occurs on nested VM-Enter would be incorrectly routed to L1, as "failed VM-Entry" is the only modifier that KVM can currently encounter. The SMM modifiers will never be generated as KVM doesn't support/employ a SMI Transfer Monitor. Ditto for "exit from enclave", as KVM doesn't yet support virtualizing SGX, i.e. it's impossible to enter an enclave in a KVM guest (L1 or L2). Fixes: 644d711aa0e1 ("KVM: nVMX: Deciding if L0 or L1 should handle an L2 exit") Cc: Jim Mattson Cc: Xiaoyao Li Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20200227174430.26371-1-sean.j.christopherson@intel.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -8207,7 +8207,7 @@ static bool nested_vmx_exit_handled(stru return true; } - switch (exit_reason) { + switch ((u16)exit_reason) { case EXIT_REASON_EXCEPTION_NMI: if (is_nmi(intr_info)) return false;