Skip to contentSkip to conversation

x86/head/64: remove redundant check on level2_kernel_pgt's _PAGE_PRESENT bit

PATCH Superseded Wei Yang 2 participants 3 messages May 23, 2024 x86

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH v2 1/1 x86/head/64: remove redundant check on level2_kernel_pgt's _PAGE_PRESENT bit

This patch tries to remove a redundant check on kernel code's PMD _PAGE_PRESENT attribute before fix up.

Current process looks like this:

pmd in [0, _text)
unset _PAGE_PRESENT
pmd in [_text, _end]
if (_PAGE_PRESENT)
fix up delta
pmd in (_end, 512)
unset _PAGE_PRESENT

Since we have compiled in _PAGE_PRESENT in this page table, it is not necessary to check _PAGE_PRESENT again before fixing up delta

CC Thomas Gleixner <[email protected]>
CC Kirill A. Shutemov <[email protected]>
CC Ingo Molnar <[email protected]>
CC Steve Wahl <[email protected]>

---
v2: adjust the change log to emphasize the redundant check

---
 arch/x86/kernel/head64.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/head64.c +1 -2
index a817ed0724d1..bac33ec19aa2 100644
@@ -260,8 +260,7 @@ unsigned long __head __startup_64(unsigned long physaddr,
 
 	/* fixup pages that are part of the kernel image */
 	for (; i <= pmd_index((unsigned long)_end); i++)
-		if (pmd[i] & _PAGE_PRESENT)
-			pmd[i] += load_delta;
+		pmd[i] += load_delta;
 
 	/* invalidate pages after the kernel image */
 	for (; i < PTRS_PER_PMD; i++)
Signature · 1 line
2.34.1
#1 lore raw
Quoted 2 lines · Wei Yang

This patch tries to remove a redundant check on kernel code's PMD _PAGE_PRESENT attribute before fix up.

Tries? s/This patch tries to r/R/

Quoted 10 lines

Current process looks like this:

pmd in [0, _text)
unset _PAGE_PRESENT
pmd in [_text, _end]
if (_PAGE_PRESENT)
fix up delta
pmd in (_end, 512)
unset _PAGE_PRESENT

Quoted 2 lines

Since we have compiled in _PAGE_PRESENT in this page table, it is not necessary to check _PAGE_PRESENT again before fixing up delta

level2_kernel_pgt compiled with _PAGE_PRESENT set. The check is redundant.

Signature · 1 line
  Kiryl Shutsemau / Kirill A. Shutemov
author
#2 lore raw

Thanks for comment.

Quoted 5 lines · Kirill A . Shutemov
Quoted 2 lines · Wei Yang

This patch tries to remove a redundant check on kernel code's PMD _PAGE_PRESENT attribute before fix up.

Tries? s/This patch tries to r/R/

Will use this one.

Quoted 11 lines
Quoted 11 lines

Current process looks like this:

pmd in [0, _text)
unset _PAGE_PRESENT
pmd in [_text, _end]
if (_PAGE_PRESENT)
fix up delta
pmd in (_end, 512)
unset _PAGE_PRESENT

Quoted 6 lines
Quoted 2 lines

Since we have compiled in _PAGE_PRESENT in this page table, it is not necessary to check _PAGE_PRESENT again before fixing up delta

level2_kernel_pgt compiled with _PAGE_PRESENT set. The check is redundant.

Will use this one, thanks

Quoted 3 lines
Signature · 2 lines
-- 
 Kiryl Shutsemau / Kirill A. Shutemov
Signature · 2 lines
Wei Yang
Help you, Help me