Skip to content

Commit 2b8acd7

Browse files
Merge patch series "NAPOT Fixes"
Alexandre Ghiti <alexghiti@rivosinc.com> says: This contains 2 fixes for NAPOT: patch 1 disables the use of NAPOT mapping for vmalloc/vmap and patch 2 implements pte_leaf_size() to report NAPOT size. * b4-shazam-merge: riscv: Fix pte_leaf_size() for NAPOT Revert "riscv: mm: support Svnapot in huge vmap" Link: https://lore.kernel.org/r/20240227205016.121901-1-alexghiti@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2 parents e2b6bc2 + e0fe5ab commit 2b8acd7

File tree

2 files changed

+5
-60
lines changed

2 files changed

+5
-60
lines changed

arch/riscv/include/asm/pgtable.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,10 @@ static inline pte_t pte_mkhuge(pte_t pte)
439439
return pte;
440440
}
441441

442+
#define pte_leaf_size(pte) (pte_napot(pte) ? \
443+
napot_cont_size(napot_cont_order(pte)) :\
444+
PAGE_SIZE)
445+
442446
#ifdef CONFIG_NUMA_BALANCING
443447
/*
444448
* See the comment in include/asm-generic/pgtable.h

arch/riscv/include/asm/vmalloc.h

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -19,65 +19,6 @@ static inline bool arch_vmap_pmd_supported(pgprot_t prot)
1919
return true;
2020
}
2121

22-
#ifdef CONFIG_RISCV_ISA_SVNAPOT
23-
#include <linux/pgtable.h>
22+
#endif
2423

25-
#define arch_vmap_pte_range_map_size arch_vmap_pte_range_map_size
26-
static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr, unsigned long end,
27-
u64 pfn, unsigned int max_page_shift)
28-
{
29-
unsigned long map_size = PAGE_SIZE;
30-
unsigned long size, order;
31-
32-
if (!has_svnapot())
33-
return map_size;
34-
35-
for_each_napot_order_rev(order) {
36-
if (napot_cont_shift(order) > max_page_shift)
37-
continue;
38-
39-
size = napot_cont_size(order);
40-
if (end - addr < size)
41-
continue;
42-
43-
if (!IS_ALIGNED(addr, size))
44-
continue;
45-
46-
if (!IS_ALIGNED(PFN_PHYS(pfn), size))
47-
continue;
48-
49-
map_size = size;
50-
break;
51-
}
52-
53-
return map_size;
54-
}
55-
56-
#define arch_vmap_pte_supported_shift arch_vmap_pte_supported_shift
57-
static inline int arch_vmap_pte_supported_shift(unsigned long size)
58-
{
59-
int shift = PAGE_SHIFT;
60-
unsigned long order;
61-
62-
if (!has_svnapot())
63-
return shift;
64-
65-
WARN_ON_ONCE(size >= PMD_SIZE);
66-
67-
for_each_napot_order_rev(order) {
68-
if (napot_cont_size(order) > size)
69-
continue;
70-
71-
if (!IS_ALIGNED(size, napot_cont_size(order)))
72-
continue;
73-
74-
shift = napot_cont_shift(order);
75-
break;
76-
}
77-
78-
return shift;
79-
}
80-
81-
#endif /* CONFIG_RISCV_ISA_SVNAPOT */
82-
#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
8324
#endif /* _ASM_RISCV_VMALLOC_H */

0 commit comments

Comments
 (0)