Skip to content

Commit c5f756d

Browse files
Vladimir Isaevvineetgarc
authored andcommitted
ARC: mm: PAE: use 40-bit physical page mask
32-bit PAGE_MASK can not be used as a mask for physical addresses when PAE is enabled. PAGE_MASK_PHYS must be used for physical addresses instead of PAGE_MASK. Without this, init gets SIGSEGV if pte_modify was called: | potentially unexpected fatal signal 11. | Path: /bin/busybox | CPU: 0 PID: 1 Comm: init Not tainted 5.12.0-rc5-00003-g1e43c377a79f-dirty | Insn could not be fetched | @no matching VMA found | ECR: 0x00040000 EFA: 0x00000000 ERET: 0x00000000 | STAT: 0x80080082 [IE U ] BTA: 0x00000000 | SP: 0x5f9ffe44 FP: 0x00000000 BLK: 0xaf3d4 | LPS: 0x000d093e LPE: 0x000d0950 LPC: 0x00000000 | r00: 0x00000002 r01: 0x5f9fff14 r02: 0x5f9fff20 | ... | Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b Signed-off-by: Vladimir Isaev <[email protected]> Reported-by: kernel test robot <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: [email protected] Signed-off-by: Vineet Gupta <[email protected]>
1 parent 3433adc commit c5f756d

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

arch/arc/include/asm/page.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@
77

88
#include <uapi/asm/page.h>
99

10+
#ifdef CONFIG_ARC_HAS_PAE40
11+
12+
#define MAX_POSSIBLE_PHYSMEM_BITS 40
13+
#define PAGE_MASK_PHYS (0xff00000000ull | PAGE_MASK)
14+
15+
#else /* CONFIG_ARC_HAS_PAE40 */
16+
17+
#define MAX_POSSIBLE_PHYSMEM_BITS 32
18+
#define PAGE_MASK_PHYS PAGE_MASK
19+
20+
#endif /* CONFIG_ARC_HAS_PAE40 */
21+
1022
#ifndef __ASSEMBLY__
1123

1224
#define clear_page(paddr) memset((paddr), 0, PAGE_SIZE)

arch/arc/include/asm/pgtable.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@
107107
#define ___DEF (_PAGE_PRESENT | _PAGE_CACHEABLE)
108108

109109
/* Set of bits not changed in pte_modify */
110-
#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_SPECIAL)
111-
110+
#define _PAGE_CHG_MASK (PAGE_MASK_PHYS | _PAGE_ACCESSED | _PAGE_DIRTY | \
111+
_PAGE_SPECIAL)
112112
/* More Abbrevaited helpers */
113113
#define PAGE_U_NONE __pgprot(___DEF)
114114
#define PAGE_U_R __pgprot(___DEF | _PAGE_READ)
@@ -132,13 +132,7 @@
132132
#define PTE_BITS_IN_PD0 (_PAGE_GLOBAL | _PAGE_PRESENT | _PAGE_HW_SZ)
133133
#define PTE_BITS_RWX (_PAGE_EXECUTE | _PAGE_WRITE | _PAGE_READ)
134134

135-
#ifdef CONFIG_ARC_HAS_PAE40
136-
#define PTE_BITS_NON_RWX_IN_PD1 (0xff00000000 | PAGE_MASK | _PAGE_CACHEABLE)
137-
#define MAX_POSSIBLE_PHYSMEM_BITS 40
138-
#else
139-
#define PTE_BITS_NON_RWX_IN_PD1 (PAGE_MASK | _PAGE_CACHEABLE)
140-
#define MAX_POSSIBLE_PHYSMEM_BITS 32
141-
#endif
135+
#define PTE_BITS_NON_RWX_IN_PD1 (PAGE_MASK_PHYS | _PAGE_CACHEABLE)
142136

143137
/**************************************************************************
144138
* Mapping of vm_flags (Generic VM) to PTE flags (arch specific)

arch/arc/include/uapi/asm/page.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@
3333

3434
#define PAGE_MASK (~(PAGE_SIZE-1))
3535

36-
3736
#endif /* _UAPI__ASM_ARC_PAGE_H */

arch/arc/mm/ioremap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ EXPORT_SYMBOL(ioremap);
5353
void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size,
5454
unsigned long flags)
5555
{
56+
unsigned int off;
5657
unsigned long vaddr;
5758
struct vm_struct *area;
58-
phys_addr_t off, end;
59+
phys_addr_t end;
5960
pgprot_t prot = __pgprot(flags);
6061

6162
/* Don't allow wraparound, zero size */
@@ -72,7 +73,7 @@ void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size,
7273

7374
/* Mappings have to be page-aligned */
7475
off = paddr & ~PAGE_MASK;
75-
paddr &= PAGE_MASK;
76+
paddr &= PAGE_MASK_PHYS;
7677
size = PAGE_ALIGN(end + 1) - paddr;
7778

7879
/*

arch/arc/mm/tlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long vaddr_unaligned,
576576
pte_t *ptep)
577577
{
578578
unsigned long vaddr = vaddr_unaligned & PAGE_MASK;
579-
phys_addr_t paddr = pte_val(*ptep) & PAGE_MASK;
579+
phys_addr_t paddr = pte_val(*ptep) & PAGE_MASK_PHYS;
580580
struct page *page = pfn_to_page(pte_pfn(*ptep));
581581

582582
create_tlb(vma, vaddr, ptep);

0 commit comments

Comments
 (0)