mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: Borislav Petkov <bp@alien8.de>,
	Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Cc: "Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"David Hildenbrand" <david@redhat.com>,
	"Yu Zhao" <yuzhao@google.com>,
	linux-kernel@vger.kernel.org,
	"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
	"Andi Shyti" <andi.shyti@linux.intel.com>,
	drm-intel@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [RESUBMIT][PATCH] x86/mm: Fix PAT bit missing from page protection modify mask
Date: Thu, 1 Jun 2023 10:47:39 +0200	[thread overview]
Message-ID: <cfd19da7-4148-f277-0cf8-507b94d214a3@suse.com> (raw)
In-Reply-To: <20230531181412.GFZHeOdMHIGOXB2hwL@fat_crate.local>


[-- Attachment #1.1.1: Type: text/plain, Size: 1783 bytes --]

On 31.05.23 20:14, Borislav Petkov wrote:
> On Fri, May 19, 2023 at 08:36:34PM +0200, Janusz Krzysztofik wrote:
>> diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
>> index 15ae4d6ba4768..56466afd04307 100644
>> --- a/arch/x86/include/asm/pgtable.h
>> +++ b/arch/x86/include/asm/pgtable.h
>> @@ -654,8 +654,10 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
>>   #define pgprot_modify pgprot_modify
>>   static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
>>   {
>> -	pgprotval_t preservebits = pgprot_val(oldprot) & _PAGE_CHG_MASK;
>> -	pgprotval_t addbits = pgprot_val(newprot) & ~_PAGE_CHG_MASK;
>> +	unsigned long mask = _PAGE_CHG_MASK | _PAGE_CACHE_MASK;
>> +
>> +	pgprotval_t preservebits = pgprot_val(oldprot) & mask;
>> +	pgprotval_t addbits = pgprot_val(newprot) & ~mask;
>>   	return __pgprot(preservebits | addbits);
>>   }
>>   
>> -- 
> 
> This certainly needs Jürgen and he's on CC already, moving him to To:.
> 
> Also, why isn't this a Xen-specific fix but you're keeping _PAGE_PAT for
> baremetal too, i.e., modifying the generic function?
> 

As described in the commit message, this only works on bare metal due to the
PAT bit not being needed for WC mappings.

Making this patch Xen specific would try to cure the symptoms without fixing
the underlying problem: _PAGE_PAT should be regarded the same way as the bits
for caching mode (_PAGE_CHG_MASK).

In case a WP or WT mapped memory area would be mmap()-ed on bare metal, the
result would be a WC or UC mapped memory area in userland. This isn't as
problematic as the case under Xen, but it still results in worse performance
than necessary.

IOW:

Acked-by: Juergen Gross <jgross@suse.com>


Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

  parent reply	other threads:[~2023-06-01  8:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-19 18:36 Janusz Krzysztofik
2023-05-31  9:35 ` Andi Shyti
     [not found] ` <20230531181412.GFZHeOdMHIGOXB2hwL@fat_crate.local>
2023-06-01  8:47   ` Juergen Gross [this message]
2023-06-02 14:43     ` Borislav Petkov
2023-06-02 14:48       ` Juergen Gross
2023-06-02 14:53         ` Juergen Gross
2023-06-05 15:51           ` Janusz Krzysztofik

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=cfd19da7-4148-f277-0cf8-507b94d214a3@suse.com \
    --to=jgross@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi.shyti@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=david@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=drm-intel@lists.freedesktop.org \
    --cc=hpa@zytor.com \
    --cc=janusz.krzysztofik@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marmarek@invisiblethingslab.com \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yuzhao@google.com \
    /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

all inboxes | Powered by JetHome®