[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240131175738.GIZbqKEhlDKhaKfh_w@fat_crate.local>
Date: Wed, 31 Jan 2024 18:57:38 +0100
From: Borislav Petkov <bp@...en8.de>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Isaku Yamahata <isaku.yamahata@...el.com>, x86@...nel.org,
linux-kernel@...r.kernel.org, Juergen Gross <jgross@...e.com>
Subject: Re: [PATCH, RESEND] x86/pat: Simplifying the PAT programming protocol
On Wed, Jan 24, 2024 at 03:06:50PM +0200, Kirill A. Shutemov wrote:
> The programming protocol for the PAT MSR follows the MTRR programming
> protocol. However, this protocol is cumbersome and requires disabling
> caching (CR0.CD=1), which is not possible on some platforms.
>
> Specifically, a TDX guest is not allowed to set CR0.CD. It triggers
> a #VE exception.
>
> Turned out the requirement to follow the MTRR programming protocol for
> PAT programming is unnecessarily strict. The new Intel Software
> Developer Manual[1] (December 2023) relaxes this requirement. Please
> refer to the section titled "Programming the PAT" for more information.
How about you state that requirement here instead of referring to that
doc which is hard to read and changes constantly?
I'd prefer to have that programming requirement spelled out here to know
in the future what that requirement was and what "variant" was added to
the kernel in case someone decides to relax it even more.
>
> The AMD documentation does not link PAT programming to MTRR.
>
> The kernel only needs to flush the TLB after updating the PAT MSR. The
> set_memory code already takes care of flushing the TLB and cache when
> changing the memory type of a page.
So far so good. However, what guarantees that this relaxing of the
protocol doesn't break any existing machines?
If anything, this patch needs to be tested on everything possible. I can
do that on AMD hw and some old Intels, just to be sure.
> @@ -296,13 +298,8 @@ void __init pat_bp_init(void)
> /*
> * Xen PV doesn't allow to set PAT MSR, but all cache modes are
> * supported.
> - * When running as TDX guest setting the PAT MSR won't work either
> - * due to the requirement to set CR0.CD when doing so. Rely on
> - * firmware to have set the PAT MSR correctly.
> */
> - if (pat_disabled ||
> - cpu_feature_enabled(X86_FEATURE_XENPV) ||
> - cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) {
> + if (pat_disabled || cpu_feature_enabled(X86_FEATURE_XENPV)) {
> init_cache_modes(pat_msr_val);
> return;
What does that mean, now, practically?
That TDX guests virtualize the PAT MSR just like with any other guest or
what is going on there?
This should be explicitly stated in the commit message.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists