Commit d989010b authored by Anshuman Khandual's avatar Anshuman Khandual Committed by Catalin Marinas
Browse files

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 <will@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Oliver Upton <oupton@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: kvmarm@lists.linux.dev
Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 2615924e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
	.macro	__uaccess_ttbr0_disable, tmp1
	mrs	\tmp1, ttbr1_el1			// swapper_pg_dir
	bic	\tmp1, \tmp1, #TTBR_ASID_MASK
	bic	\tmp1, \tmp1, #TTBRx_EL1_ASID_MASK
	sub	\tmp1, \tmp1, #RESERVED_SWAPPER_OFFSET	// reserved_pg_dir
	msr	ttbr0_el1, \tmp1			// set reserved TTBR0_EL1
	add	\tmp1, \tmp1, #RESERVED_SWAPPER_OFFSET
+0 −1
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@
#define MMCF_AARCH32	0x1	/* mm context flag for AArch32 executables */
#define USER_ASID_BIT	48
#define USER_ASID_FLAG	(UL(1) << USER_ASID_BIT)
#define TTBR_ASID_MASK	(UL(0xffff) << 48)

#ifndef __ASSEMBLER__

+2 −1
Original line number Diff line number Diff line
@@ -210,7 +210,8 @@ static inline void update_saved_ttbr0(struct task_struct *tsk,
	if (mm == &init_mm)
		ttbr = phys_to_ttbr(__pa_symbol(reserved_pg_dir));
	else
		ttbr = phys_to_ttbr(virt_to_phys(mm->pgd)) | ASID(mm) << 48;
		ttbr = phys_to_ttbr(virt_to_phys(mm->pgd)) |
		       FIELD_PREP(TTBRx_EL1_ASID_MASK, ASID(mm));

	WRITE_ONCE(task_thread_info(tsk)->ttbr0, ttbr);
}
+3 −3
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ static inline void __uaccess_ttbr0_disable(void)

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

	/* Restore active ASID */
	ttbr1 = read_sysreg(ttbr1_el1);
	ttbr1 &= ~TTBR_ASID_MASK;		/* safety measure */
	ttbr1 |= ttbr0 & TTBR_ASID_MASK;
	ttbr1 &= ~TTBRx_EL1_ASID_MASK;		/* safety measure */
	ttbr1 |= ttbr0 & TTBRx_EL1_ASID_MASK;
	write_sysreg(ttbr1, ttbr1_el1);

	/* Restore user page table */
+1 −1
Original line number Diff line number Diff line
@@ -473,7 +473,7 @@ alternative_else_nop_endif
	 */
SYM_CODE_START_LOCAL(__swpan_entry_el1)
	mrs	x21, ttbr0_el1
	tst	x21, #TTBR_ASID_MASK		// Check for the reserved ASID
	tst	x21, #TTBRx_EL1_ASID_MASK	// Check for the reserved ASID
	orr	x23, x23, #PSR_PAN_BIT		// Set the emulated PAN in the saved SPSR
	b.eq	1f				// TTBR0 access already disabled
	and	x23, x23, #~PSR_PAN_BIT		// Clear the emulated PAN in the saved SPSR
Loading