Skip to content

Commit 3fb7f3a

Browse files
committed
Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 pti updates from Thomas Gleixner: "Two small PTI updates: - Handle unaligned addresses gracefully in pti_clone_pagetable(). Not an issue with current callers, but a correctness problem. Adds a warning so any caller which hands in an unaligned address gets pointed out clearly. - Prevent PTI functions from being invoked when PTI is disabled at boottime. While this does not cause any harm today, it's pointless code executed and prone to cause subtle issues if the PTI implementation changes internally over time" * 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/mm/pti: Do not invoke PTI functions when PTI is disabled x86/mm/pti: Handle unaligned address gracefully in pti_clone_pagetable()
2 parents 3cd0462 + 990784b commit 3fb7f3a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/x86/mm/pti.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,15 @@ pti_clone_pgtable(unsigned long start, unsigned long end,
330330

331331
pud = pud_offset(p4d, addr);
332332
if (pud_none(*pud)) {
333-
addr += PUD_SIZE;
333+
WARN_ON_ONCE(addr & ~PUD_MASK);
334+
addr = round_up(addr + 1, PUD_SIZE);
334335
continue;
335336
}
336337

337338
pmd = pmd_offset(pud, addr);
338339
if (pmd_none(*pmd)) {
339-
addr += PMD_SIZE;
340+
WARN_ON_ONCE(addr & ~PMD_MASK);
341+
addr = round_up(addr + 1, PMD_SIZE);
340342
continue;
341343
}
342344

@@ -666,6 +668,8 @@ void __init pti_init(void)
666668
*/
667669
void pti_finalize(void)
668670
{
671+
if (!boot_cpu_has(X86_FEATURE_PTI))
672+
return;
669673
/*
670674
* We need to clone everything (again) that maps parts of the
671675
* kernel image.

0 commit comments

Comments
 (0)