@@ -299,6 +299,27 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
299
299
if (WARN_ON (!target_pmd ))
300
300
return ;
301
301
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
+
302
323
/*
303
324
* Copy the PMD. That is, the kernelmode and usermode
304
325
* tables will share the last-level page tables of this
@@ -348,7 +369,7 @@ static void __init pti_clone_entry_text(void)
348
369
{
349
370
pti_clone_pmds ((unsigned long ) __entry_text_start ,
350
371
(unsigned long ) __irqentry_text_end ,
351
- _PAGE_RW | _PAGE_GLOBAL );
372
+ _PAGE_RW );
352
373
}
353
374
354
375
/*
0 commit comments