Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1457873ybf; Thu, 27 Feb 2020 11:20:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwvaIiuNZp56I3O8pHx2bHi7H2m56MBWixyOK2RXD8SoFbvtxdeLTvycrhsqWbUNsK8fDLm X-Received: by 2002:a05:6808:48c:: with SMTP id z12mr444811oid.92.1582831255705; Thu, 27 Feb 2020 11:20:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582831255; cv=none; d=google.com; s=arc-20160816; b=LLs1UOLbrPNiR1Oais8gamWuowpHMLhBJJgKNnoaaHfgP/EuVhtuwV7BElxL224Fgi I80dl9iaBSmbHwTW+xh9p9Gu/7Wdl0Er6Rn+lQYHKfsuhlwpxp3Ad6FxShgp6woFXegW X2BaImSiSepJt3AFl6iEI1AtaTOtPbAZU2pBpizZN7mHkYhx5g+zm/uGLXN6KRfeRDxC hxBx0Y54vih4Eoenq5QUfvdwI5XMokK+/pEKXe2RGPFeZr6jtLBsPrTbTS5RNM8Xynog DmOmK8tQhUrRcZcUFHxCabPGWCmUmdzrtgtPGQAQWXA9UxaZUrSU3vIUyN2fdqsehwCO +c2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=wD0YMiaevfN+rD/Y82hagTpEJtCW8Y8b9WogafbNlr4=; b=KaHd5FjZwpZlEhUSvmonYfSeXA8A5w9kQscOP72m1kyuwjT52D6jOdGE+M0mdsJO/L gdo04bnuG6UqKMA9sV1ehNRPqcrivNfRBSjEpbE+qsbsRqPvnMjHCbYusCwsY1K6EtfA 6OlHbcUqQOceIQNQ5vFQ2WnxjjGuz6+YXe79hR4GEglEmGi5b1BYUpxbQJd+43Rm9NT1 iMytYAIYHHHg1uqGpiWp5mBU2eyCIZvLMX5x5pGb6zHVFREc47aqa1lSF27LxDDdfzV2 RF3y4VaqeqIO37i10QYonBMsxSNjre8LUmyfrRxC1egs/xo66FXg+KjhzV+QW2Mu34db GcAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TG7xD62g; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si437050oim.30.2020.02.27.11.20.43; Thu, 27 Feb 2020 11:20:55 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=TG7xD62g; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730055AbgB0TUd (ORCPT + 99 others); Thu, 27 Feb 2020 14:20:33 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33315 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729593AbgB0TUc (ORCPT ); Thu, 27 Feb 2020 14:20:32 -0500 Received: by mail-lj1-f195.google.com with SMTP id y6so539718lji.0 for ; Thu, 27 Feb 2020 11:20:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wD0YMiaevfN+rD/Y82hagTpEJtCW8Y8b9WogafbNlr4=; b=TG7xD62gYjK7JebjkwSkRbrtK7tgXmZfvP3BlvPcKRsY+UWUX/GDsGuX3IdePtnuL8 A7STMFwgkh3q8DBiCkD1Bd4hO3+xgTGI6Rq9MvE3DdiY4jZbP8Ws8SxibxjDpIUDWAFj e5zse9h6xkdEo25W4b5f/heAsIPtHGyjPhWWm3VTiA1CPmNZ2t/Ob9GZN/ywhaBuxI3U 6WOqdFskbcxvcsOBubvozsLBge6ki61QQ7YAPKWQ0eM5dBu0OLHiS1C0ZhZ0QxUPyjf8 nd+oDjh4DmcwDiFwq+Ffe2Bo+TNWnIzO/dqfvqqg3kUFcXFc3y26crYwUrywzFSOKFid 7AuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wD0YMiaevfN+rD/Y82hagTpEJtCW8Y8b9WogafbNlr4=; b=EdPjm11j+N/frLzni12Wf08vUrX19ezMDDNg24zqupR8gieisGVK6bvle01X0RpxXS pRpwml/gLWc3UCdWyckYFrE8tqnj5hb0m31Pz6mRJVNTJkM+y1UdJDgHfZQGCQ7GYggZ q7aylYe+OpQZ7+XLbGhtLQRfIYW3bWkF1pZXDlNL6TU5paLH+7r+PJvNl/w2tmY+iJdE dmuE3BYMHL8+zNTt0a1R545B1Ne5glJJGUYaD6rSnqyeVTLHgIexF1f3QyS7HToQfeXg BEMP11j6qicqm6OfhBdqJkaf29Ywi8v4YDA4PXlPhNt93sfYH3MRr+3tq+5WnuFyhBMZ SmYw== X-Gm-Message-State: ANhLgQ26ba1kq+Fl1jlYxuxng5CECYo6BiaRHJe5hWpjbKc29ZXBU4BZ D2xK+IqU5nNiwQ1eDo88Xy4EajRL9pHvRkD+NqY0Xg== X-Received: by 2002:a05:651c:555:: with SMTP id q21mr333700ljp.241.1582831230661; Thu, 27 Feb 2020 11:20:30 -0800 (PST) MIME-Version: 1.0 References: <20200227174430.26371-1-sean.j.christopherson@intel.com> In-Reply-To: <20200227174430.26371-1-sean.j.christopherson@intel.com> From: Oliver Upton Date: Thu, 27 Feb 2020 11:20:19 -0800 Message-ID: Subject: Re: [PATCH] KVM: nVMX: Consult only the "basic" exit reason when routing nested exit To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm list , Linux Kernel Mailing List , Xiaoyao Li Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 27, 2020 at 9:47 AM Sean Christopherson wrote: > > 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 > --- > arch/x86/kvm/vmx/nested.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > index 0946122a8d3b..127065bbde2c 100644 > --- a/arch/x86/kvm/vmx/nested.c > +++ b/arch/x86/kvm/vmx/nested.c > @@ -5554,7 +5554,7 @@ bool nested_vmx_exit_reflected(struct kvm_vcpu *vcpu, u32 exit_reason) > 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; > -- > 2.24.1 > Reviewed-by: Oliver Upton