[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86/PAT: have pat_enabled() properly reflect state when running on e.g. Xen


  • To: Borislav Petkov <bp@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 5 Jul 2022 17:56:36 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gjMyEbqYPvaU75TqQFujOmryjN0HbAjJDuVylj2I6no=; b=iBBE19kEcwR2Vd8VdwFbYF2lKr935SjvQBtRVYZCCtzY+IN2+//9VLvpq8xMuvu+ohKP2Ctcgaqv0hby1VLJwzL0XNGPDnaOzepOmQFObFa8epq433IkoJE2pecj6blxIFjDCODQSqj40vkxl8Uz13yjAaqMdIp1DIOT79anI5/E7noez8M2H2VE0/FGcLsXtuucrlE+W+NcWZX5sBNjcEQMsjtwy9ntBT9oUQWiBzTTW6Pbr4jxt57ENg4u1YPZmjAfVRn3kj2ueaGNzehk9zoTaQNrm+VCpcp9fsOkJJ9B8icTH/JyTX4tFqllWzvlWZi6eyhr8pZ8ffrVFBzmJw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TlZ/aPlnkrnQiPS4KtMzYWgEh2HFKLz6m5vJNzrPzmNd04uSsBmxfIjIxcMqirteqmRKpDgQnfYh0G7l4j3LiYj5B/OKgrCC9avGC01MjngpFdeLLJh7xQ+pM8V3aE3M1Nm6FdGss7DVy6DK7nXlGd8ge7RAn884m7Dzrs+RomnWuAbMmvLn1vHbxE4ZyVKkR4/0CRzYCOqPpHn6arPpRbGdqv7RzFqIxT6+tZS2ixfEmFLakv0JtGNmCgT4wvp8Pe6MGC3sVVBDxZgr+xFOPPCsNLQQfet/D07fCUENRG0qAXuPYN5TLjFeSOgFw2oQwbXFO9MN7YZAxfwvSoTW4w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Lutomirski <luto@xxxxxxxxxx>, "dave.hansen@xxxxxxxxxxxxxxx" <dave.hansen@xxxxxxxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, lkml <linux-kernel@xxxxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 05 Jul 2022 15:56:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 05.07.2022 17:04, Borislav Petkov wrote:
> On Thu, Apr 28, 2022 at 04:50:29PM +0200, Jan Beulich wrote:
>> --- a/arch/x86/mm/pat/memtype.c
>> +++ b/arch/x86/mm/pat/memtype.c
>> @@ -62,6 +62,7 @@
>>  
>>  static bool __read_mostly pat_bp_initialized;
>>  static bool __read_mostly pat_disabled = !IS_ENABLED(CONFIG_X86_PAT);
>> +static bool __initdata pat_force_disabled = !IS_ENABLED(CONFIG_X86_PAT);
>>  static bool __read_mostly pat_bp_enabled;
>>  static bool __read_mostly pat_cm_initialized;
> 
> Why yet another boolean var?

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().

> Why not extend pat_enabled() to reflect the Xen case and explain it
> properly above it?

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).

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?

Jan

> My comment is likely wrong because I don't know what the Xen HV hides or
> doesn't but you get the idea...
> 
> diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
> index d5ef64ddd35e..a8f1a02f9bc2 100644
> --- a/arch/x86/mm/pat/memtype.c
> +++ b/arch/x86/mm/pat/memtype.c
> @@ -92,6 +92,13 @@ early_param("nopat", nopat);
>  
>  bool pat_enabled(void)
>  {
> +     /*
> +      * Xen PV doesn't expose the PAT MSR to dom0 so the proper init path
> +      * there cannot be exercised. Announce PAT is enabled in that case too.
> +      */
> +     if (cpu_feature_enabled(X86_FEATURE_XENPV) && !pat_disabled)
> +             return true;
> +
>       return pat_bp_enabled;
>  }
>  EXPORT_SYMBOL_GPL(pat_enabled);
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.