Skip to contentSkip to conversation

x86/kpti: WARN if kernel memory mapped to userspace is non-global

PATCH New Dave Hansen 1 participant 1 message Dec 16, 2017

Subsystems (2)
lore
Share & tools
lore

Dave Hansen

author maintainer
#0 lore raw

PATCH 1/1 x86/kpti: WARN if kernel memory mapped to userspace is non-global

From: Dave Hansen <[email protected]>

All memory being mapped out to userspace is shared. That means that it is both safe and _expected_ to have the page table Global bit set.

If a PMD is found without Global set, it either a place that could be performing better, or something unexpected is being mapped out to userspace. Both of those are things for which a warning is good.

Cc Thomas Gleixner <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Rik van Riel <[email protected]>

---

 b/arch/x86/mm/kpti.c |    3 +++
 1 file changed, 3 insertions(+)
arch/x86/mm/kpti.c renamed from arch/x86/mm/kpti.c~kaiser-set-global-in-kernel-for-shared +3 -0
diff -puN arch/x86/mm/kpti.c~kaiser-set-global-in-kernel-for-shared arch/x86/mm/kpti.c
@@ -157,6 +157,9 @@ kpti_clone_pmds(unsigned long start, uns
 		if (WARN_ON(!target_pmd))
 			return;
 
+		/* Only clone PMDs which we *intend* to share: */
+		WARN_ON_ONCE(!(pmd_flags(*target_pmd) & _PAGE_GLOBAL));
+
 		/*
 		 * Copy the PMD.  That is, the kernelmode and usermode
 		 * tables will share the last-level page tables of this

_