Messages in this thread | | | From | "Edgecombe, Rick P" <> | Subject | Re: [PATCH] x86/mm/cpa: set PAGE_KERNEL in __set_pages_p() | Date | Tue, 10 May 2022 00:47:11 +0000 |
| |
On Fri, 2022-05-06 at 14:19 +0900, Hyeonggon Yoo wrote: > __set_pages_np() not only clears _PAGE_PRESENT and _PAGE_RW, but also > clears _PAGE_GLOBAL to avoid confusing _PAGE_GLOBAL as _PAGE_PROTNONE > when the PTE is not present. > > Common usage for __set_pages_p() is to call it after > __set_pages_np(). > Therefore calling __set_pages_p() after __set_pages_np() clears > _PAGE_GLOBAL, making it unable to globally shared in TLB. > > As they are called by set_direct_map_{invalid,default}_noflush(), > pages in direct map cannot be globally shared in TLB after being used > by > vmalloc, secretmem, and hibernation. > > So set PAGE_KERNEL isntead of __pgprot(_PAGE_PRESENT | _PAGE_RW) in > __set_pages_p().
Nice find. I think we can't always set PAGE_KERNEL also because of the PTI code. It sometimes wants the direct map to be non global.
Maybe something like this? (_PAGE_PRESENT | _PAGE_RW | _PAGE_GLOBAL) & __default_kernel_pte_mask
That would add back in a little of the "default global" behavior that was removed in d1440b2, but I think it should be ok because it is limited to the direct map. Otherwise, I wonder if the existing global clearing logic is really needed.
| |