FROMLIST: arm64: mm: Introduce TTBR_ASID_MASK for getting at the ASID in the TTBR
authorWill Deacon <will.deacon@arm.com>
Fri, 1 Dec 2017 17:33:48 +0000 (17:33 +0000)
committerGreg Kroah-Hartman <gregkh@google.com>
Sat, 6 Jan 2018 10:14:01 +0000 (11:14 +0100)
There are now a handful of open-coded masks to extract the ASID from a
TTBR value, so introduce a TTBR_ASID_MASK and use that instead.

Suggested-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git
 commit b519538dfefc2f8478a1bcb458459c861d431784)

Change-Id: I538071c8ec96dca587205c78839c07b6c772fa91
[ghackmann@google.com: adjust context, applying asm-uaccess.h changes
 to uaccess.h instead]
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
arch/arm64/include/asm/mmu.h
arch/arm64/include/asm/uaccess.h
arch/arm64/kernel/entry.S

index bb907189aef024f1cf5bd023f27317dcff929b96..39e502f0ab806c9ab3b5e568ed88fd4bdf16f2d2 100644 (file)
@@ -17,6 +17,7 @@
 #define __ASM_MMU_H
 
 #define USER_ASID_FLAG (UL(1) << 48)
+#define TTBR_ASID_MASK (UL(0xffff) << 48)
 
 #ifndef __ASSEMBLY__
 
index d4383596a38c688cf2b69ca01c28cb1bc9cf6554..57c4bbdf77cc76bb99b89c62eba16fa83879702e 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <asm/alternative.h>
 #include <asm/kernel-pgtable.h>
+#include <asm/mmu.h>
 #include <asm/sysreg.h>
 
 #ifndef __ASSEMBLY__
@@ -149,7 +150,7 @@ static inline void __uaccess_ttbr0_disable(void)
        write_sysreg(ttbr + SWAPPER_DIR_SIZE, ttbr0_el1);
        isb();
        /* Set reserved ASID */
-       ttbr &= ~(0xffffUL << 48);
+       ttbr &= ~TTBR_ASID_MASK;
        write_sysreg(ttbr, ttbr1_el1);
        isb();
 }
@@ -168,7 +169,7 @@ static inline void __uaccess_ttbr0_enable(void)
 
        /* Restore active ASID */
        ttbr1 = read_sysreg(ttbr1_el1);
-       ttbr1 |= ttbr0 & (0xffffUL << 48);
+       ttbr1 |= ttbr0 & TTBR_ASID_MASK;
        write_sysreg(ttbr1, ttbr1_el1);
        isb();
 
@@ -456,7 +457,7 @@ extern __must_check long strnlen_user(const char __user *str, long n);
        msr     ttbr0_el1, \tmp1                // set reserved TTBR0_EL1
        isb
        sub     \tmp1, \tmp1, #SWAPPER_DIR_SIZE
-       bic     \tmp1, \tmp1, #(0xffff << 48)
+       bic     \tmp1, \tmp1, #TTBR_ASID_MASK
        msr     ttbr1_el1, \tmp1                // set reserved ASID
        isb
        .endm
index 60d69614e17465dbc10014fba079edc1e0f9d378..1c7f6f9961a15fce382ddaf879731361f2897aa2 100644 (file)
@@ -165,7 +165,7 @@ alternative_else_nop_endif
 
        .if     \el != 0
        mrs     x21, ttbr1_el1
-       tst     x21, #0xffff << 48              // Check for the reserved ASID
+       tst     x21, #TTBR_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