Skip to content

Commit c947948

Browse files
committed
Merge branch 'for-next/mm' into for-next/core
* for-next/mm: arm64: booting: Require placement within 48-bit addressable memory arm64: mm: kfence: only handle translation faults arm64/mm: Simplify and document pte_to_phys() for 52 bit addresses
2 parents 37f5d61 + 453dfce commit c947948

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

Documentation/arm64/booting.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ Header notes:
121121
to the base of DRAM, since memory below it is not
122122
accessible via the linear mapping
123123
1
124-
2MB aligned base may be anywhere in physical
125-
memory
124+
2MB aligned base such that all image_size bytes
125+
counted from the start of the image are within
126+
the 48-bit addressable range of physical memory
126127
Bits 4-63 Reserved.
127128
============= ===============================================================
128129

arch/arm64/include/asm/assembler.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -660,12 +660,10 @@ alternative_endif
660660
.endm
661661

662662
.macro pte_to_phys, phys, pte
663-
#ifdef CONFIG_ARM64_PA_BITS_52
664-
ubfiz \phys, \pte, #(48 - 16 - 12), #16
665-
bfxil \phys, \pte, #16, #32
666-
lsl \phys, \phys, #16
667-
#else
668663
and \phys, \pte, #PTE_ADDR_MASK
664+
#ifdef CONFIG_ARM64_PA_BITS_52
665+
orr \phys, \phys, \phys, lsl #PTE_ADDR_HIGH_SHIFT
666+
and \phys, \phys, GENMASK_ULL(PHYS_MASK_SHIFT - 1, PAGE_SHIFT)
669667
#endif
670668
.endm
671669

arch/arm64/include/asm/pgtable-hwdef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
#ifdef CONFIG_ARM64_PA_BITS_52
160160
#define PTE_ADDR_HIGH (_AT(pteval_t, 0xf) << 12)
161161
#define PTE_ADDR_MASK (PTE_ADDR_LOW | PTE_ADDR_HIGH)
162+
#define PTE_ADDR_HIGH_SHIFT 36
162163
#else
163164
#define PTE_ADDR_MASK PTE_ADDR_LOW
164165
#endif

arch/arm64/include/asm/pgtable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
7777
static inline phys_addr_t __pte_to_phys(pte_t pte)
7878
{
7979
return (pte_val(pte) & PTE_ADDR_LOW) |
80-
((pte_val(pte) & PTE_ADDR_HIGH) << 36);
80+
((pte_val(pte) & PTE_ADDR_HIGH) << PTE_ADDR_HIGH_SHIFT);
8181
}
8282
static inline pteval_t __phys_to_pte_val(phys_addr_t phys)
8383
{
84-
return (phys | (phys >> 36)) & PTE_ADDR_MASK;
84+
return (phys | (phys >> PTE_ADDR_HIGH_SHIFT)) & PTE_ADDR_MASK;
8585
}
8686
#else
8787
#define __pte_to_phys(pte) (pte_val(pte) & PTE_ADDR_MASK)

arch/arm64/mm/fault.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ static bool is_el1_mte_sync_tag_check_fault(unsigned long esr)
354354
return false;
355355
}
356356

357+
static bool is_translation_fault(unsigned long esr)
358+
{
359+
return (esr & ESR_ELx_FSC_TYPE) == ESR_ELx_FSC_FAULT;
360+
}
361+
357362
static void __do_kernel_fault(unsigned long addr, unsigned long esr,
358363
struct pt_regs *regs)
359364
{
@@ -386,7 +391,8 @@ static void __do_kernel_fault(unsigned long addr, unsigned long esr,
386391
} else if (addr < PAGE_SIZE) {
387392
msg = "NULL pointer dereference";
388393
} else {
389-
if (kfence_handle_page_fault(addr, esr & ESR_ELx_WNR, regs))
394+
if (is_translation_fault(esr) &&
395+
kfence_handle_page_fault(addr, esr & ESR_ELx_WNR, regs))
390396
return;
391397

392398
msg = "paging request";

0 commit comments

Comments
 (0)