From: Sean Christopherson <seanjc@google.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>,
Nikunj A Dadhania <nikunj@amd.com>,
linux-kernel@vger.kernel.org, x86@kernel.org,
tglx@linutronix.de, mingo@redhat.com,
dave.hansen@linux.intel.com, santosh.shukla@amd.com
Subject: Re: [PATCH] x86/sev: Improve handling of writes to intercepted GUEST_TSC_FREQ
Date: Mon, 14 Jul 2025 09:36:04 -0700 [thread overview]
Message-ID: <aHUx9ILdUZJHefjZ@google.com> (raw)
In-Reply-To: <20250714161639.GLaHUtZwleS3COfxxX@fat_crate.local>
On Mon, Jul 14, 2025, Borislav Petkov wrote:
> On Mon, Jul 14, 2025 at 08:17:13AM -0700, Sean Christopherson wrote:
> > The guest cannot dictate VMM behavior. If the guest side wants to panic, then
> > so be it, panic. But don't blame the VMM for taking a conservative approach.
> >
> > If you want to dictate VMM behavior, then the required behavior needs to be
> > explicitly documented in an "official" spec, e.g. the GHCB.
>
> Ok, so you want to squash the #GP from an attempted write to a MSR into
> a warning because this is how the hypervisor has been handling it already for
> others. Ok, I guess this is established protocol or whatnot.
Or as Tom suggested, return ES_EXCEPTION and let the kernel's normal machinery
WARN on the bad WRMSR.
> Now, why should it panic when a *read* is then attempted?
Because as you note below, the MSR read should succeed. __vc_handle_secure_tsc_msrs()
is invoked if and only if secure TSC is enabled for the guest. If RDMSR #VCs,
then the hypervisor has decided to intercept GUEST_TSC_FREQ despite enabling and
advertising secure TSC to the guest. The guest kernel can either continue on
with degraded security (potentially dangerously so) or panic/terminate.
> The APM says:
>
> "Guests that run with Secure TSC enabled may read the GUEST_TSC_FREQ MSR
> (C001_0134h) which returns the effective frequency in MHz of the guest view of
> TSC. This MSR is read-only and attempting to write the MSR or read it when
> outside of a guest with Secure TSC enabled causes a #GP(0) exception."
>
> So what is the established protocol for reading non-existent MSRs?
Looks like Linux-as-a-guest will request emulation from the hypervisor. What
the hypervisor does is completely unknown, at least as far as the guest is
concerned. E.g. the hypervisor could return an error (i.e. "inject" a #GP), or
it could provide garbage (on RDMSR) and drop writres.
> Also, if secure TSC is enabled, that MSR read should succeed.
>
> The original text in the patch:
>
> "Only terminate the guest when reading from intercepted GUEST_TSC_FREQ MSR
> with Secure TSC enabled, as this indicates an unexpected hypervisor
> configuration."
>
> doesn't make too much sense to me.
>
> Maybe you need to explain things in detail as virt and I don't understand each
> other too much yet.
>
> :-)
>
> --
> Regards/Gruss,
> Boris.
>
> https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2025-07-14 16:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-11 4:12 [PATCH] x86/sev: Improve handling of writes to intercepted GUEST_TSC_FREQ Nikunj A Dadhania
2025-07-14 10:44 ` Borislav Petkov
2025-07-14 14:24 ` Sean Christopherson
2025-07-14 14:59 ` Tom Lendacky
2025-07-14 15:17 ` Sean Christopherson
2025-07-14 16:16 ` Borislav Petkov
2025-07-14 16:36 ` Sean Christopherson [this message]
2025-07-15 8:37 ` Nikunj A Dadhania
2025-07-15 8:43 ` Borislav Petkov
2025-07-15 8:58 ` Nikunj A Dadhania
2025-07-15 8:38 ` Borislav Petkov
2025-07-15 9:13 ` Nikunj A Dadhania
2025-07-15 9:44 ` Borislav Petkov
2025-07-15 12:47 ` Tom Lendacky
2025-07-16 6:09 ` Nikunj A Dadhania
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=aHUx9ILdUZJHefjZ@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nikunj@amd.com \
--cc=santosh.shukla@amd.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.