linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mm/cpa: set PAGE_KERNEL in __set_pages_p()
@ 2022-05-06  5:19 Hyeonggon Yoo
  2022-05-09 16:06 ` Tom Lendacky
  2022-05-10  0:47 ` [PATCH] x86/mm/cpa: set PAGE_KERNEL in __set_pages_p() Edgecombe, Rick P
  0 siblings, 2 replies; 18+ messages in thread
From: Hyeonggon Yoo @ 2022-05-06  5:19 UTC (permalink / raw)
  To: Rick Edgecombe
  Cc: 42.hyeyoo, Dave Hansen, Andy Lutomirski, Peter Zijlstra,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	H. Peter Anvin, Kirill A. Shutemov, Brijesh Singh, Tom Lendacky,
	Tianyu Lan, Aneesh Kumar K.V, linux-kernel

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

Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
---
 arch/x86/mm/pat/set_memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index abf5ed76e4b7..fcb6147c4cd4 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -2177,7 +2177,7 @@ static int __set_pages_p(struct page *page, int numpages)
 	struct cpa_data cpa = { .vaddr = &tempaddr,
 				.pgd = NULL,
 				.numpages = numpages,
-				.mask_set = __pgprot(_PAGE_PRESENT | _PAGE_RW),
+				.mask_set = PAGE_KERNEL,
 				.mask_clr = __pgprot(0),
 				.flags = 0};
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-06-02 16:47 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-06  5:19 [PATCH] x86/mm/cpa: set PAGE_KERNEL in __set_pages_p() Hyeonggon Yoo
2022-05-09 16:06 ` Tom Lendacky
2022-05-10 11:57   ` Hyeonggon Yoo
2022-05-10 13:35     ` Tom Lendacky
2022-05-10 14:39       ` Dave Hansen
2022-05-11  5:20         ` Is _PAGE_PROTNONE set only for user mappings? Hyeonggon Yoo
2022-05-12 10:37           ` Mel Gorman
2022-05-13  5:33             ` Hyeonggon Yoo
2022-05-16 13:03               ` Mel Gorman
2022-05-16 14:04               ` Dave Hansen
2022-05-22  3:56                 ` Hyeonggon Yoo
2022-05-24 20:22                   ` Sean Christopherson
2022-05-26 10:33                     ` Hyeonggon Yoo
2022-05-29 10:32                 ` Hyeonggon Yoo
2022-06-02 16:47                   ` Dave Hansen
2022-05-10  0:47 ` [PATCH] x86/mm/cpa: set PAGE_KERNEL in __set_pages_p() Edgecombe, Rick P
2022-05-10 11:50   ` Hyeonggon Yoo
2022-05-10 15:38     ` Edgecombe, Rick P

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).