From patchwork Fri Jun 19 14:30:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 223777 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=unavailable 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 25568C433E1 for ; Fri, 19 Jun 2020 16:27:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F205A217A0 for ; Fri, 19 Jun 2020 16:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592584038; bh=wA/z1Zo8HdXoPQpYnhLsBY8h2ygok12Fbcuw5q4Zky8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BPycpOQeg5ndiHxU33SEb7x+jN8q7C/kEdudDCtzAlLZr0UYEaiJZBqD1sZi/WPz0 6/OdiRVUItGFNY87XP8Gz/QOksMiahFhR422hzCnVZztv2R1i4DUR8K4KiXGoKnpJw BYLokohlSOwPvPYgkeoaKYUr5NuLz8J8yIiqo318= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389408AbgFSO4S (ORCPT ); Fri, 19 Jun 2020 10:56:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:51178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389374AbgFSO4N (ORCPT ); Fri, 19 Jun 2020 10:56:13 -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 7405F2158C; Fri, 19 Jun 2020 14:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578573; bh=wA/z1Zo8HdXoPQpYnhLsBY8h2ygok12Fbcuw5q4Zky8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PyMl4UMK0ALnm7oHo3Tg7oJ+m5fepqHpSHihi3SdQ337t4mPR4Ce8TScUMbyf2ijA ANQJqF/Flb2YJJTRS1XdCZPSPGzbS1NBeSy04CoPIbxCgUATuaK3sy0EJ072Pw1Yub IVckkkdqsJkTQpuHKQND70JBbeuCKbP533ZY3f1g= 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.19 073/267] KVM: nVMX: Consult only the "basic" exit reason when routing nested exit Date: Fri, 19 Jun 2020 16:30:58 +0200 Message-Id: <20200619141652.399461563@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -9683,7 +9683,7 @@ static bool nested_vmx_exit_reflected(st 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;