[PATCH 2/2] riscv: mm: use pXX_none() instead of raw pXX_val() == 0 checks
cuitao
cuitao at kylinos.cn
Thu Apr 16 04:54:39 PDT 2026
The page table entry empty checks in create_pud_mapping,
create_p4d_mapping, and create_pgd_mapping use open-coded
pud_val()/p4d_val()/pgd_val() comparisons against zero, while
create_pmd_mapping and create_pte_mapping use the proper pmd_none()
and pte_none() helpers.
Using pXX_none() is the canonical and portable way to check for empty
entries.
Signed-off-by: cuitao <cuitao at kylinos.cn>
---
arch/riscv/mm/init.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 811e03786c56..33af0958a65d 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -638,12 +638,12 @@ static void __meminit create_pud_mapping(pud_t *pudp, uintptr_t va, phys_addr_t
uintptr_t pud_index = pud_index(va);
if (sz == PUD_SIZE) {
- if (pud_val(pudp[pud_index]) == 0)
+ if (pud_none(pudp[pud_index]))
pudp[pud_index] = pfn_pud(PFN_DOWN(pa), prot);
return;
}
- if (pud_val(pudp[pud_index]) == 0) {
+ if (pud_none(pudp[pud_index])) {
next_phys = pt_ops.alloc_pmd(va);
pudp[pud_index] = pfn_pud(PFN_DOWN(next_phys), PAGE_TABLE);
nextp = pt_ops.get_pmd_virt(next_phys);
@@ -664,12 +664,12 @@ static void __meminit create_p4d_mapping(p4d_t *p4dp, uintptr_t va, phys_addr_t
uintptr_t p4d_index = p4d_index(va);
if (sz == P4D_SIZE) {
- if (p4d_val(p4dp[p4d_index]) == 0)
+ if (p4d_none(p4dp[p4d_index]))
p4dp[p4d_index] = pfn_p4d(PFN_DOWN(pa), prot);
return;
}
- if (p4d_val(p4dp[p4d_index]) == 0) {
+ if (p4d_none(p4dp[p4d_index])) {
next_phys = pt_ops.alloc_pud(va);
p4dp[p4d_index] = pfn_p4d(PFN_DOWN(next_phys), PAGE_TABLE);
nextp = pt_ops.get_pud_virt(next_phys);
@@ -721,12 +721,12 @@ void __meminit create_pgd_mapping(pgd_t *pgdp, uintptr_t va, phys_addr_t pa, phy
uintptr_t pgd_idx = pgd_index(va);
if (sz == PGDIR_SIZE) {
- if (pgd_val(pgdp[pgd_idx]) == 0)
+ if (pgd_none(pgdp[pgd_idx]))
pgdp[pgd_idx] = pfn_pgd(PFN_DOWN(pa), prot);
return;
}
- if (pgd_val(pgdp[pgd_idx]) == 0) {
+ if (pgd_none(pgdp[pgd_idx])) {
next_phys = alloc_pgd_next(va);
pgdp[pgd_idx] = pfn_pgd(PFN_DOWN(next_phys), PAGE_TABLE);
nextp = get_pgd_next_virt(next_phys);
--
2.43.0
More information about the kvm-riscv
mailing list