[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aHUfecs9UJPx0v_C@google.com>
Date: Mon, 14 Jul 2025 08:17:13 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Tom Lendacky <thomas.lendacky@....com>
Cc: Borislav Petkov <bp@...en8.de>, Nikunj A Dadhania <nikunj@....com>, linux-kernel@...r.kernel.org,
x86@...nel.org, tglx@...utronix.de, mingo@...hat.com,
dave.hansen@...ux.intel.com, santosh.shukla@....com
Subject: Re: [PATCH] x86/sev: Improve handling of writes to intercepted GUEST_TSC_FREQ
On Mon, Jul 14, 2025, Tom Lendacky wrote:
> On 7/14/25 09:24, Sean Christopherson wrote:
> > On Mon, Jul 14, 2025, Borislav Petkov wrote:
> >> On Fri, Jul 11, 2025 at 09:42:00AM +0530, Nikunj A Dadhania wrote:
> >>> From: Sean Christopherson <seanjc@...gle.com>
> >>>
> >>> For Secure TSC enabled guests, don't panic when a guest writes to
> >>> intercepted GUEST_TSC_FREQ MSR. Instead, ignore writes to GUEST_TSC_FREQ,
> >>> similar to MSR_IA32_TSC, and log a warning instead.
> >>
> >> Why?
> >>
> >> Nothing should poke at the TSC MSR and those who do, deserve what they get.
> >>
> >>> Only terminate the guest when reading from intercepted GUEST_TSC_FREQ MSR
> >>> with Secure TSC enabled, as this indicates an unexpected hypervisor
> >>> configuration.
> >>
> >> Huh, this sounds weird.
> >>
> >> What are we "fixing" here?
> >
> > Returning ES_VMM_ERROR is misleading/wrong, and panicking doesn't match how the
> > kernel handles every other "bad" WRMSR. How's this for a changelog?
> >
> > For Secure TSC enabled guests, don't panic if the kernel hits a #VC due
> > to attempting to write to GUEST_TSC_FREQ, and instead WARN and drop the
> > write. The kernel should never write GUEST_TSC_FREQ as it's read-only,
> > but panicking with ES_VMM_ERROR is both misleading (it's entirely
> > reasonable for a VMM to intercept writes to a read-only MSR), and
> > unnecessary, e.g. the kernel eats #GPs with a WARN on every other "bad"
> > WRMSR.
>
> Maybe it should be returning ES_EXCEPTION then instead of ES_VMM_ERROR
> and forward a #GP, which is what would have happened if the guest tried
> to write to the read-only MSR if it wasn't being intercepted.
>
> I'm still not a fan of intercepting writes to read-only MSRs that are
> passed into the guest. If we're trying to replicate bare-metal behavior,
> then allowing the write to fail with a #GP seems appropriate.
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.
Powered by blists - more mailing lists