@@ -299,6 +299,27 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
299299 if (WARN_ON (!target_pmd ))
300300 return ;
301301
302+ /*
303+ * Only clone present PMDs. This ensures only setting
304+ * _PAGE_GLOBAL on present PMDs. This should only be
305+ * called on well-known addresses anyway, so a non-
306+ * present PMD would be a surprise.
307+ */
308+ if (WARN_ON (!(pmd_flags (* pmd ) & _PAGE_PRESENT )))
309+ return ;
310+
311+ /*
312+ * Setting 'target_pmd' below creates a mapping in both
313+ * the user and kernel page tables. It is effectively
314+ * global, so set it as global in both copies. Note:
315+ * the X86_FEATURE_PGE check is not _required_ because
316+ * the CPU ignores _PAGE_GLOBAL when PGE is not
317+ * supported. The check keeps consistentency with
318+ * code that only set this bit when supported.
319+ */
320+ if (boot_cpu_has (X86_FEATURE_PGE ))
321+ * pmd = pmd_set_flags (* pmd , _PAGE_GLOBAL );
322+
302323 /*
303324 * Copy the PMD. That is, the kernelmode and usermode
304325 * tables will share the last-level page tables of this
@@ -348,7 +369,7 @@ static void __init pti_clone_entry_text(void)
348369{
349370 pti_clone_pmds ((unsigned long ) __entry_text_start ,
350371 (unsigned long ) __irqentry_text_end ,
351- _PAGE_RW | _PAGE_GLOBAL );
372+ _PAGE_RW );
352373}
353374
354375/*
0 commit comments