From: Jan Beulich <jbeulich@suse.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Andrew Lutomirski <luto@kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
lkml <linux-kernel@vger.kernel.org>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] x86/PAT: have pat_enabled() properly reflect state when running on e.g. Xen
Date: Wed, 6 Jul 2022 08:17:41 +0200 [thread overview]
Message-ID: <b7fa785b-cea3-3e05-c101-d6c7bd101ef3@suse.com> (raw)
In-Reply-To: <YsRjX/U1XN8rq+8u@zn.tnic>
On 05.07.2022 18:14, Borislav Petkov wrote:
> On Tue, Jul 05, 2022 at 05:56:36PM +0200, Jan Beulich wrote:
>> Re-using pat_disabled like you do in your suggestion below won't
>> work, because mtrr_bp_init() calls pat_disable() when MTRRs
>> appear to be disabled (from the kernel's view). The goal is to
>> honor "nopat" without honoring any other calls to pat_disable().
>
> Actually, the current goal is to adjust Xen dom0 because:
>
> 1. it uses the PAT code
>
> 2. but then it does something special and hides the MTRRs
>
> which is not something real hardware does.
>
> So this one-off thing should be prominent, visible and not get in the
> way.
>
> As to mtrr_bp_init(), can you use X86_FEATURE_XENPV there to detect this
> special case when the kernel is running as dom0 and set stuff there
> accordingly so that it doesn't disable PAT?
Sure, but that alone won't help. There's a beneficial side effect
of running through pat_disable(): That way pat_init() will bail
right away. Without that I'd need to further special case things
there (as under Xen/PV PAT must not be written, only read) and I'd
also need to set pat_bp_enabled and pat_bp_initialized somewhere.
I could of course check X86_FEATURE_XENPV in all the necessary
places, but I was quite certain _that_ wouldn't be liked (nor
would I be convinced this is the right thing to do - see bottom).
> Then you don't have to touch pat_disabled() either but intergrate the
> Xen variant properly...
>
>> I can probably fiddle with pat_enabled() instead of with
>> init_cache_modes(), but when making the change I had the feeling
>> this might be less liked (as looking more hacky, at least to me).
>
> Why would that be more hacky?
My view on it, as said. I did actually make several attempts, until
reaching what I then submitted. All earlier ones were quite a bit
more intrusive (see above for an outline).
> I'd much rather check upfront what the kernel is running on and act
> accordingly instead of hooking into random functions and then years
> later wonder why was it done in the first place.
Thank you for putting it that kindly. It was a pretty conscious
decision where to make the changes, after - as said - quite a bit
of trying other variants. History with Xen-specific changes has
taught me to try to keep them as uninvasive and generic as possible.
The more things smelled like Xen-only, the less they were liked.
>> But besides the "where" the other question is: Do you really want
>> me to limit this to Xen/PV, rather than - as I have it now -
>> extending it to any hypervisor, which may behave in similar ways?
>
> Well, do you know of some other HV which hides MTRRs from the guest?
>
> I haven't heard of any...
Any decent hypervisor will allow overriding CPUID, so in principle
I'd expect any to permit disabling MTRR to leave a guest to use
the (more modern and less cumbersome) PAT alone.
Jan
next prev parent reply other threads:[~2022-07-06 6:17 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-28 14:50 Jan Beulich
2022-05-03 12:54 ` Juergen Gross
2022-05-11 13:32 ` Juergen Gross
2022-05-21 13:56 ` Chuck Zmudzinski
2022-05-25 8:55 ` Ping: " Jan Beulich
2022-07-04 11:58 ` Thorsten Leemhuis
2022-07-04 12:26 ` Jan Beulich
2022-07-05 10:57 ` Thorsten Leemhuis
2022-07-05 11:02 ` Jan Beulich
2022-07-05 13:36 ` Borislav Petkov
2022-07-05 13:38 ` Juergen Gross
2022-07-14 17:17 ` Chuck Zmudzinski
2022-07-14 22:33 ` Chuck Zmudzinski
2022-07-14 22:45 ` Chuck Zmudzinski
2022-07-19 14:26 ` Chuck Zmudzinski
2022-07-05 15:04 ` Borislav Petkov
2022-07-05 15:56 ` Jan Beulich
2022-07-05 16:14 ` Borislav Petkov
2022-07-06 6:17 ` Jan Beulich [this message]
2022-07-06 17:01 ` Borislav Petkov
2022-07-07 6:38 ` Jan Beulich
2022-07-11 10:40 ` Borislav Petkov
2022-07-11 11:38 ` Chuck Zmudzinski
2022-07-11 12:28 ` [PATCH] x86/PAT: have pat_enabled() properly reflect state when running on e.g. Xen, with corrected patch Chuck Zmudzinski
2022-07-11 14:18 ` [PATCH] x86/PAT: have pat_enabled() properly reflect state when running on e.g. Xen Chuck Zmudzinski
2022-07-11 14:31 ` Juergen Gross
2022-07-11 17:41 ` Chuck Zmudzinski
2022-07-12 5:49 ` Juergen Gross
2022-07-12 6:04 ` Jan Beulich
2022-07-12 13:22 ` Chuck Zmudzinski
2022-07-12 13:32 ` Juergen Gross
2022-07-12 15:09 ` Chuck Zmudzinski
2022-07-12 15:30 ` Juergen Gross
2022-07-12 16:34 ` Chuck Zmudzinski
2022-08-15 10:20 ` [tip: x86/urgent] x86/PAT: Have pat_enabled() properly reflect state when running on Xen tip-bot2 for Jan Beulich
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=b7fa785b-cea3-3e05-c101-d6c7bd101ef3@suse.com \
--to=jbeulich@suse.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome