Skip to content

Commit c84e1ef

Browse files
committed
Merge tag 'asm-generic-fixes-5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic
Pull asm-generic fix from Arnd Bergmann: "Add correct MAX_POSSIBLE_PHYSMEM_BITS setting to asm-generic. This is a single bugfix for a bug that Stefan Agner found on 32-bit Arm, but that exists on several other architectures" * tag 'asm-generic-fixes-5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic: arch: pgtable: define MAX_POSSIBLE_PHYSMEM_BITS where needed
2 parents 303bc93 + cef3970 commit c84e1ef

8 files changed

Lines changed: 28 additions & 0 deletions

File tree

arch/arc/include/asm/pgtable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@
134134

135135
#ifdef CONFIG_ARC_HAS_PAE40
136136
#define PTE_BITS_NON_RWX_IN_PD1 (0xff00000000 | PAGE_MASK | _PAGE_CACHEABLE)
137+
#define MAX_POSSIBLE_PHYSMEM_BITS 40
137138
#else
138139
#define PTE_BITS_NON_RWX_IN_PD1 (PAGE_MASK | _PAGE_CACHEABLE)
140+
#define MAX_POSSIBLE_PHYSMEM_BITS 32
139141
#endif
140142

141143
/**************************************************************************

arch/arm/include/asm/pgtable-2level.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
#define PTE_HWTABLE_OFF (PTE_HWTABLE_PTRS * sizeof(pte_t))
7676
#define PTE_HWTABLE_SIZE (PTRS_PER_PTE * sizeof(u32))
7777

78+
#define MAX_POSSIBLE_PHYSMEM_BITS 32
79+
7880
/*
7981
* PMD_SHIFT determines the size of the area a second-level page table can map
8082
* PGDIR_SHIFT determines what a third-level page table entry can map

arch/arm/include/asm/pgtable-3level.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#define PTE_HWTABLE_OFF (0)
2626
#define PTE_HWTABLE_SIZE (PTRS_PER_PTE * sizeof(u64))
2727

28+
#define MAX_POSSIBLE_PHYSMEM_BITS 40
29+
2830
/*
2931
* PGDIR_SHIFT determines the size a top-level page table entry can map.
3032
*/

arch/mips/include/asm/pgtable-32.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ static inline void pmd_clear(pmd_t *pmdp)
154154

155155
#if defined(CONFIG_XPA)
156156

157+
#define MAX_POSSIBLE_PHYSMEM_BITS 40
157158
#define pte_pfn(x) (((unsigned long)((x).pte_high >> _PFN_SHIFT)) | (unsigned long)((x).pte_low << _PAGE_PRESENT_SHIFT))
158159
static inline pte_t
159160
pfn_pte(unsigned long pfn, pgprot_t prot)
@@ -169,6 +170,7 @@ pfn_pte(unsigned long pfn, pgprot_t prot)
169170

170171
#elif defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32)
171172

173+
#define MAX_POSSIBLE_PHYSMEM_BITS 36
172174
#define pte_pfn(x) ((unsigned long)((x).pte_high >> 6))
173175

174176
static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot)
@@ -183,6 +185,7 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot)
183185

184186
#else
185187

188+
#define MAX_POSSIBLE_PHYSMEM_BITS 32
186189
#ifdef CONFIG_CPU_VR41XX
187190
#define pte_pfn(x) ((unsigned long)((x).pte >> (PAGE_SHIFT + 2)))
188191
#define pfn_pte(pfn, prot) __pte(((pfn) << (PAGE_SHIFT + 2)) | pgprot_val(prot))

arch/powerpc/include/asm/book3s/32/pgtable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ static inline bool pte_user(pte_t pte)
3636
*/
3737
#ifdef CONFIG_PTE_64BIT
3838
#define PTE_RPN_MASK (~((1ULL << PTE_RPN_SHIFT) - 1))
39+
#define MAX_POSSIBLE_PHYSMEM_BITS 36
3940
#else
4041
#define PTE_RPN_MASK (~((1UL << PTE_RPN_SHIFT) - 1))
42+
#define MAX_POSSIBLE_PHYSMEM_BITS 32
4143
#endif
4244

4345
/*

arch/powerpc/include/asm/nohash/32/pgtable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
153153
*/
154154
#if defined(CONFIG_PPC32) && defined(CONFIG_PTE_64BIT)
155155
#define PTE_RPN_MASK (~((1ULL << PTE_RPN_SHIFT) - 1))
156+
#define MAX_POSSIBLE_PHYSMEM_BITS 36
156157
#else
157158
#define PTE_RPN_MASK (~((1UL << PTE_RPN_SHIFT) - 1))
159+
#define MAX_POSSIBLE_PHYSMEM_BITS 32
158160
#endif
159161

160162
/*

arch/riscv/include/asm/pgtable-32.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
#define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT)
1515
#define PGDIR_MASK (~(PGDIR_SIZE - 1))
1616

17+
#define MAX_POSSIBLE_PHYSMEM_BITS 34
18+
1719
#endif /* _ASM_RISCV_PGTABLE_32_H */

include/linux/pgtable.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,19 @@ typedef unsigned int pgtbl_mod_mask;
14271427

14281428
#endif /* !__ASSEMBLY__ */
14291429

1430+
#if !defined(MAX_POSSIBLE_PHYSMEM_BITS) && !defined(CONFIG_64BIT)
1431+
#ifdef CONFIG_PHYS_ADDR_T_64BIT
1432+
/*
1433+
* ZSMALLOC needs to know the highest PFN on 32-bit architectures
1434+
* with physical address space extension, but falls back to
1435+
* BITS_PER_LONG otherwise.
1436+
*/
1437+
#error Missing MAX_POSSIBLE_PHYSMEM_BITS definition
1438+
#else
1439+
#define MAX_POSSIBLE_PHYSMEM_BITS 32
1440+
#endif
1441+
#endif
1442+
14301443
#ifndef has_transparent_hugepage
14311444
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
14321445
#define has_transparent_hugepage() 1

0 commit comments

Comments
 (0)