arm64-r/mpu: add TBI setting to r82 when use SW_TAG

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2024-03-25 13:29:46 +08:00 committed by Xiang Xiao
parent 8b49e17f1f
commit e9617583bc
2 changed files with 14 additions and 0 deletions

View file

@ -387,6 +387,12 @@ void arm64_mpu_init(bool is_primary_core)
uint64_t val;
uint32_t r_index;
#ifdef CONFIG_MM_KASAN_SW_TAGS
val = read_sysreg(tcr_el1);
val |= (TCR_TBI0 | TCR_TBI1 | TCR_ASID_8);
write_sysreg(val, tcr_el1);
#endif
/* Current MPU code supports only EL1 */
__asm__ volatile ("mrs %0, CurrentEL" : "=r" (val));

View file

@ -50,6 +50,14 @@
#define MPU_RBAR_AP_POS 2U
#define MPU_RBAR_AP_MSK (0x3UL << MPU_RBAR_AP_POS)
/* TCR_EL1 */
#define TCR_AS_SHIFT 36U
#define TCR_ASID_8 (0ULL << TCR_AS_SHIFT)
#define TCR_ASID_16 (1ULL << TCR_AS_SHIFT)
#define TCR_TBI0 (1ULL << 37)
#define TCR_TBI1 (1ULL << 38)
/* RBAR_EL1 XN */
#define MPU_RBAR_XN_POS 1U