From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C11DC433E0 for ; Tue, 16 Jun 2020 15:56:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 565A4207C4 for ; Tue, 16 Jun 2020 15:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592322966; bh=vW18VRNYV9BtNXSDwWxZYN38v2KsWgMa+JvycMWRHYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=L1UU4fZjSG9hfIqSiZpVngPVBZKBI4dPLCthL8WikmvhWgm9UdJoBglWqH+FXMcju bxS69NdF36HKP//r8R4Ah4oPiS/ys74CIBKs7gAPYVKXX2cZwPOm4m7+VEGkVoTh/K hjBm8jZQxC20e4ux3gm3ywPwj2DqL+p17ImEEk84= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733147AbgFPP4E (ORCPT ); Tue, 16 Jun 2020 11:56:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:56276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733130AbgFPPz4 (ORCPT ); Tue, 16 Jun 2020 11:55:56 -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 6D2D6207C4; Tue, 16 Jun 2020 15:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592322955; bh=vW18VRNYV9BtNXSDwWxZYN38v2KsWgMa+JvycMWRHYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gPB46nckNhqd/dvqngGPBDC9cNnUCirxXKV0pmIkloREgGUtO1fcKw/ypJFbAbhwJ kUl/tXuP1ONmZQLlk8x+CrEdzcQYMlrj+oFv4E3xgdlBkM0sJVM+VNWwdihhsK+Uve Mmn7rhJZT5Jtl2f1rZ0J3hopawdmhzRcDAmJacxg= 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 5.6 128/161] KVM: nVMX: Consult only the "basic" exit reason when routing nested exit Date: Tue, 16 Jun 2020 17:35:18 +0200 Message-Id: <20200616153112.459145837@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200616153106.402291280@linuxfoundation.org> References: <20200616153106.402291280@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/nested.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -5562,7 +5562,7 @@ bool nested_vmx_exit_reflected(struct kv vmcs_read32(VM_EXIT_INTR_ERROR_CODE), KVM_ISA_VMX); - switch (exit_reason) { + switch ((u16)exit_reason) { case EXIT_REASON_EXCEPTION_NMI: if (is_nmi(intr_info)) return false;