Skip to content

Commit d989010

Browse files
Anshuman Khandualctmarinas
authored andcommitted
arm64/mm: Directly use TTBRx_EL1_ASID_MASK
Replace all TTBR_ASID_MASK macro instances with TTBRx_EL1_ASID_MASK which is a standard field mask from tools sysreg format. Drop the now redundant custom macro TTBR_ASID_MASK. No functional change. Cc: Will Deacon <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Oliver Upton <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Anshuman Khandual <[email protected]> Signed-off-by: Catalin Marinas <[email protected]>
1 parent 2615924 commit d989010

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

arch/arm64/include/asm/asm-uaccess.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
1616
.macro __uaccess_ttbr0_disable, tmp1
1717
mrs \tmp1, ttbr1_el1 // swapper_pg_dir
18-
bic \tmp1, \tmp1, #TTBR_ASID_MASK
18+
bic \tmp1, \tmp1, #TTBRx_EL1_ASID_MASK
1919
sub \tmp1, \tmp1, #RESERVED_SWAPPER_OFFSET // reserved_pg_dir
2020
msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1
2121
add \tmp1, \tmp1, #RESERVED_SWAPPER_OFFSET

arch/arm64/include/asm/mmu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define MMCF_AARCH32 0x1 /* mm context flag for AArch32 executables */
1111
#define USER_ASID_BIT 48
1212
#define USER_ASID_FLAG (UL(1) << USER_ASID_BIT)
13-
#define TTBR_ASID_MASK (UL(0xffff) << 48)
1413

1514
#ifndef __ASSEMBLER__
1615

arch/arm64/include/asm/mmu_context.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ static inline void update_saved_ttbr0(struct task_struct *tsk,
210210
if (mm == &init_mm)
211211
ttbr = phys_to_ttbr(__pa_symbol(reserved_pg_dir));
212212
else
213-
ttbr = phys_to_ttbr(virt_to_phys(mm->pgd)) | ASID(mm) << 48;
213+
ttbr = phys_to_ttbr(virt_to_phys(mm->pgd)) |
214+
FIELD_PREP(TTBRx_EL1_ASID_MASK, ASID(mm));
214215

215216
WRITE_ONCE(task_thread_info(tsk)->ttbr0, ttbr);
216217
}

arch/arm64/include/asm/uaccess.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static inline void __uaccess_ttbr0_disable(void)
6262

6363
local_irq_save(flags);
6464
ttbr = read_sysreg(ttbr1_el1);
65-
ttbr &= ~TTBR_ASID_MASK;
65+
ttbr &= ~TTBRx_EL1_ASID_MASK;
6666
/* reserved_pg_dir placed before swapper_pg_dir */
6767
write_sysreg(ttbr - RESERVED_SWAPPER_OFFSET, ttbr0_el1);
6868
/* Set reserved ASID */
@@ -85,8 +85,8 @@ static inline void __uaccess_ttbr0_enable(void)
8585

8686
/* Restore active ASID */
8787
ttbr1 = read_sysreg(ttbr1_el1);
88-
ttbr1 &= ~TTBR_ASID_MASK; /* safety measure */
89-
ttbr1 |= ttbr0 & TTBR_ASID_MASK;
88+
ttbr1 &= ~TTBRx_EL1_ASID_MASK; /* safety measure */
89+
ttbr1 |= ttbr0 & TTBRx_EL1_ASID_MASK;
9090
write_sysreg(ttbr1, ttbr1_el1);
9191

9292
/* Restore user page table */

arch/arm64/kernel/entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ alternative_else_nop_endif
473473
*/
474474
SYM_CODE_START_LOCAL(__swpan_entry_el1)
475475
mrs x21, ttbr0_el1
476-
tst x21, #TTBR_ASID_MASK // Check for the reserved ASID
476+
tst x21, #TTBRx_EL1_ASID_MASK // Check for the reserved ASID
477477
orr x23, x23, #PSR_PAN_BIT // Set the emulated PAN in the saved SPSR
478478
b.eq 1f // TTBR0 access already disabled
479479
and x23, x23, #~PSR_PAN_BIT // Clear the emulated PAN in the saved SPSR

arch/arm64/mm/context.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,11 @@ void cpu_do_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm)
358358

359359
/* SW PAN needs a copy of the ASID in TTBR0 for entry */
360360
if (IS_ENABLED(CONFIG_ARM64_SW_TTBR0_PAN))
361-
ttbr0 |= FIELD_PREP(TTBR_ASID_MASK, asid);
361+
ttbr0 |= FIELD_PREP(TTBRx_EL1_ASID_MASK, asid);
362362

363363
/* Set ASID in TTBR1 since TCR.A1 is set */
364-
ttbr1 &= ~TTBR_ASID_MASK;
365-
ttbr1 |= FIELD_PREP(TTBR_ASID_MASK, asid);
364+
ttbr1 &= ~TTBRx_EL1_ASID_MASK;
365+
ttbr1 |= FIELD_PREP(TTBRx_EL1_ASID_MASK, asid);
366366

367367
cpu_set_reserved_ttbr0_nosync();
368368
write_sysreg(ttbr1, ttbr1_el1);

0 commit comments

Comments
 (0)