Skip to content

Commit 3e844d8

Browse files
committed
x86/mm: Ensure forced page table splitting
There are a few kernel users like kfence that require 4k pages to work correctly and do not support large mappings. They use set_memory_4k() to break down those large mappings. That, in turn relies on cpa_data->force_split option to indicate to set_memory code that it should split page tables regardless of whether the need to be. But, a recent change added an optimization which would return early if a set_memory request came in that did not change permissions. It did not consult ->force_split and would mistakenly optimize away the splitting that set_memory_4k() needs. This broke kfence. Skip the same-permission optimization when ->force_split is set. Fixes: 127960a ("x86/mm: Inhibit _PAGE_NX changes from cpa_process_alias()") Signed-off-by: Dave Hansen <[email protected]> Tested-by: Marco Elver <[email protected]> Cc: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/all/CA+G9fYuFxZTxkeS35VTZMXwQvohu73W3xbZ5NtjebsVvH6hCuA@mail.gmail.com/
1 parent 1cfaac2 commit 3e844d8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/mm/pat/set_memory.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,8 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int primary)
17271727
/*
17281728
* No changes, easy!
17291729
*/
1730-
if (!(pgprot_val(cpa->mask_set) | pgprot_val(cpa->mask_clr)))
1730+
if (!(pgprot_val(cpa->mask_set) | pgprot_val(cpa->mask_clr)) &&
1731+
!cpa->force_split)
17311732
return ret;
17321733

17331734
while (rempages) {

0 commit comments

Comments
 (0)