Skip to content

Commit a179a4b

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Fix hugetlb_mask_last_page() when NAPOT is enabled
When NAPOT is enabled, a new hugepage size is available and then we need to make hugetlb_mask_last_page() aware of that. Fixes: 82a1a1f ("riscv: mm: support Svnapot in hugetlb page") Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Link: https://lore.kernel.org/r/20240117195741.1926459-3-alexghiti@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 1458eb2 commit a179a4b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

arch/riscv/mm/hugetlbpage.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,26 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
125125
return pte;
126126
}
127127

128+
unsigned long hugetlb_mask_last_page(struct hstate *h)
129+
{
130+
unsigned long hp_size = huge_page_size(h);
131+
132+
switch (hp_size) {
133+
#ifndef __PAGETABLE_PMD_FOLDED
134+
case PUD_SIZE:
135+
return P4D_SIZE - PUD_SIZE;
136+
#endif
137+
case PMD_SIZE:
138+
return PUD_SIZE - PMD_SIZE;
139+
case napot_cont_size(NAPOT_CONT64KB_ORDER):
140+
return PMD_SIZE - napot_cont_size(NAPOT_CONT64KB_ORDER);
141+
default:
142+
break;
143+
}
144+
145+
return 0UL;
146+
}
147+
128148
static pte_t get_clear_contig(struct mm_struct *mm,
129149
unsigned long addr,
130150
pte_t *ptep,

0 commit comments

Comments
 (0)