public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Rick P Edgecombe <rick.p.edgecombe@intel.com>
Cc: Chao Gao <chao.gao@intel.com>,
	Dave Hansen <dave.hansen@intel.com>,
	 "x86@kernel.org" <x86@kernel.org>,
	"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>,
	Vishal L Verma <vishal.l.verma@intel.com>,
	 "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>
Subject: Re: [PATCH 1/2] KVM: TDX: Allow TDs to read MSR_IA32_PLATFORM_ID
Date: Tue, 28 Apr 2026 11:44:02 -0700	[thread overview]
Message-ID: <afD_8se-aOikeHTT@google.com> (raw)
In-Reply-To: <b8c413a52c0285534d552c8646f9071fca4351f4.camel@intel.com>

On Tue, Apr 28, 2026, Rick P Edgecombe wrote:
> On Tue, 2026-04-28 at 09:30 -0700, Sean Christopherson wrote:
> > > This patch looks good to me. But the rule for which MSRs should be emulated
> > > by KVM for TDX is not very clear to me.
> > 
> > I would strongly prefer to not take this patch, and instead fix the guest. 
> > This isn't some latent/pre-existing guest behavior, it's brand new
> > functionality. I.e. Linux-as-a-TDX-guest broke itself.
> > 
> > More importantly from a guest security perspective, consuming
> > MSR_IA32_PLATFORM_ID is actively dangerous.  E.g. it could allow the untrusted
> > host to steer the guest's behavior with respect to feature detection and
> > enablement.
> 
> I feel like you could make similar cases about a lot the VMM controlled MSRs.

Oh, for sure.  And far worse (yet another reminder that I need to refresh this
series).

https://lore.kernel.org/all/20250227021855.3257188-1-seanjc@google.com

> > And once KVM allows reads from MSR_IA32_PLATFORM_ID, there's no going back. 
> > E.g. if the TDX-Module wants to emulate MSR_IA32_PLATFORM_ID, because there's
> > an actual *need* to do so, then we're going to have a (minor) mess with KVM's
> > ABI.
> 
> This is a problem with the bare metal KVM behavior too, and it's just super old?

No?  Oh, I see what you're asking.  I'm mostly concerned about the host side of
things.  The problem with TDX is that a TDX-Module update could effectively change
KVM's behavior, i.e. if the TDX-Module decides it needs to emulate PLATFORM_ID for
whatever reason.  So not only would KVM need to enumerate to userspace that the
MSR is supported/emulated for TDX guests, KVM would also need to differentiate
between emulated by KVM and emulated by the TDX-Module.

> For TDX, hmm. I guess the standard thing to do in order to avoid creating a KVM
> ABI problems is just match the arch behavior. But for TDs, it is a very special
> type of VM. The special TDX guest things can't work on bare metal. Furthermore,
> guest opt ins can change what arch is even supposed to be virtualized. So the
> normal KVM default thing to do doesn't always fit.
> 
> So instead we will just virtualize as little as possible to keep Linux guest
> running? Ok.

Yeah, and the sequence of events matters.  Most of KVM's half-hearted emulation
of random MSRs exists because KVM needed to be able to run existing kernels.  But
once KVM (and other hypervisors) existed, kernels learned to run as guests (and
hardware vendors largely did a better job of explicitly enumerating MSRs and
whatnot), and so the need to throw hacks into KVM mostly went away.

> > > Maybe we can document the rule here, if there is one. That would make it
> > > much easier to tell whether future issues like this are guest regressions
> > > or missing KVM handling.
> 
> Speaking in general now about TDX guest ABI, not about this specific MSR. I
> agree it would be good to have some story about how this is supposed to work and
> evolve. Similar to the CPUID bit stuff we are trying to clean up.
> 
> I'm also remembering the debate about what to do about the MTRR bit being forced
> on, but not being able to apply the KVM solution (which got ripped out anyway)
> to the S-EPT. Or the guest maxpfn thing, where we got the TDX module to add
> CPUID bit support we needed. By default, we can try to make it so the TDX module
> will, or will let us, faithfully match the normal x86 arch bit behavior.

  reply	other threads:[~2026-04-28 18:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28  2:47 [PATCH 0/2] Fix MSR_IA32_PLATFORM_ID access for TDX guests Binbin Wu
2026-04-28  2:47 ` [PATCH 1/2] KVM: TDX: Allow TDs to read MSR_IA32_PLATFORM_ID Binbin Wu
2026-04-28  5:31   ` Xiaoyao Li
2026-04-28 11:44   ` Chao Gao
2026-04-28 16:30     ` Sean Christopherson
2026-04-28 18:31       ` Edgecombe, Rick P
2026-04-28 18:44         ` Sean Christopherson [this message]
2026-04-28 19:28           ` Edgecombe, Rick P
2026-04-28 18:49   ` Dave Hansen
2026-04-28  2:47 ` [PATCH 2/2] x86/cpu: Skip reading MSR_IA32_PLATFORM_ID in virtualized environment Binbin Wu
2026-04-28  6:01   ` Xiaoyao Li
2026-04-28  9:57     ` Binbin Wu
2026-04-28 18:54     ` Edgecombe, Rick P
2026-04-28 19:13       ` Dave Hansen

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=afD_8se-aOikeHTT@google.com \
    --to=seanjc@google.com \
    --cc=binbin.wu@linux.intel.com \
    --cc=chao.gao@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=kas@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=vishal.l.verma@intel.com \
    --cc=x86@kernel.org \
    --cc=xiaoyao.li@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