Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Rick P Edgecombe <rick.p.edgecombe@intel.com>
Cc: "dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"kas@kernel.org" <kas@kernel.org>,
	 "binbin.wu@linux.intel.com" <binbin.wu@linux.intel.com>,
	Xiaoyao Li <xiaoyao.li@intel.com>,
	 "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Yan Y Zhao <yan.y.zhao@intel.com>,
	 Kai Huang <kai.huang@intel.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	 "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	 "linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH] KVM: VMX: Explicitly track TDX VMs' root level instead of guessing it from CPUID
Date: Wed, 19 Aug 2026 12:41:21 -0700	[thread overview]
Message-ID: <aoYG4XA6pXAXiHlP@google.com> (raw)
In-Reply-To: <e5979a0a4d7c24d88f57981aba0fda6d8a5e2f29.camel@intel.com>

On Wed, Aug 19, 2026, Rick P Edgecombe wrote:
> On Wed, 2026-08-19 at 11:45 -0700, Sean Christopherson wrote:
> > Hmm, for defense in depth, I want to explicitly check mirror_root_level,
> > because returning '0' would likely have dire consequences.  How about this?
> 
> :) Sure.
> 
> Yan and I were discussing what might be a new level of defense on MMU checking.
> We were basically trying to work out your thinking on some of the defensive
> patches lately. It seems there has also been a new level of activity on the bugs
> front so we want to adapt to any learnings you had. I actually planned to bring
> it up in PUCK, but...
> 
> Can you share any thoughts? Should we be more paranoid in general, or same as
> always? Or more specifically paranoid where issues hit?

The big learning I've had is that simply detecting bugs doesn't help protect the
host unless KVM also takes evasive action when the bug is detected.  E.g. a WARN
will (hopefully) be super helpful in root causing what went wrong, but it doesn't
do anything to mitigate the bug in real time.

A theme common to several (not all, but several) of the recent guest-exploitable
vulnerabilities is that KVM *did* have relevant sanity checks, but KVM didn't
actually do anything meaningful when a check failed and/or an assumption didn't
hold true.  It's not always possible/desirable to take evasive action (see below),
but in most cases it is.

Other than that, I don't think there's anything "new" per se, just a bit more of
a sense of urgency.  E.g. avoid BUG() and BUG_ON() unless there's a *very* high
probability the alternative is worse (this is why I said above that doing more
than WARNing may not be desirable).  If you fix a bug that could be applicable to
other code, look for ways to (practically) eliminate the potential source of bugs
(much of the guard() stuff falls into this category; the cleanup behavior makes
it a lot hard to end up with deadlock due to forgetting an unlock in a rare path).
And so on and so forth.

As for this exact sanity check, the reason why I think it's worth keeping is that
we've already messed it up once, the code pretty much only runs once per VM boot,
and if KVM configures the wrong level, the *best* case scenario is probably that
the host panics.  I.e. my past statements along the lines of "at some point we have
to not screw up" still hold true, but as with many kernel rules and guidlines, it
needs to be applied with a healthy dose of critical thinking.

  reply	other threads:[~2026-08-19 19:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 22:45 [PATCH] KVM: VMX: Explicitly track TDX VMs' root level instead of guessing it from CPUID Sean Christopherson
2026-08-19  0:53 ` Edgecombe, Rick P
2026-08-19  0:59   ` Sean Christopherson
2026-08-19 14:35     ` Edgecombe, Rick P
2026-08-19 15:56       ` Sean Christopherson
2026-08-19 17:35         ` Edgecombe, Rick P
2026-08-19 18:45           ` Sean Christopherson
2026-08-19 18:56             ` Edgecombe, Rick P
2026-08-19 19:41               ` Sean Christopherson [this message]
2026-08-19 22:36                 ` Edgecombe, Rick P

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aoYG4XA6pXAXiHlP@google.com \
    --to=seanjc@google.com \
    --cc=binbin.wu@linux.intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=kai.huang@intel.com \
    --cc=kas@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=x86@kernel.org \
    --cc=xiaoyao.li@intel.com \
    --cc=yan.y.zhao@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox