On 5/29/22 03:32, Hyeonggon Yoo wrote: > On Mon, May 16, 2022 at 07:04:32AM -0700, Dave Hansen wrote: > Writing code I'm a bit confused: > commit d1440b23c922d8 ("x86/mm: Factor out pageattr > _PAGE_GLOBAL setting") says: > > "This unconditional setting of _PAGE_GLOBAL is a problem when we have > PTI and non-PTI and we want some areas to have _PAGE_GLOBAL and some > not." > > Is this this sentence not valid anymore in PTI, > and just unconditionally setting _PAGE_GLOBAL would be okay in kernel > side regardless of PTI? I believe it's still valid. IIRC, there are three cases: 1. No KPTI. All kernel mappings are _PAGE_GLOBAL. Basically, for present mappings, if _PAGE_USER is clear, _PAGE_GLOBAL is set. 2. KPTI with PCID hardware support (or in a few other cases): The kernel image is mostly non-global. Anything mapped into userspace *is* marked global, like entry text. 3. KPTI without PCIDs: Basically case #2, but with more of the kernel image left global. So, not only are there different KPTI modes, there a different pars of the kernel that require different _PAGE_GLOBAL behavior. pti_kernel_image_global_ok() in arch/x86/mm/pti.c explains it pretty well.