.. | .. |
---|
47 | 47 | |
---|
48 | 48 | #ifdef CONFIG_KASAN_HW_TAGS |
---|
49 | 49 | #define TCR_MTE_FLAGS SYS_TCR_EL1_TCMA1 | TCR_TBI1 | TCR_TBID1 |
---|
50 | | -#else |
---|
| 50 | +#elif defined(CONFIG_ARM64_MTE) |
---|
51 | 51 | /* |
---|
52 | 52 | * The mte_zero_clear_page_tags() implementation uses DC GZVA, which relies on |
---|
53 | 53 | * TBI being enabled at EL1. |
---|
54 | 54 | */ |
---|
55 | 55 | #define TCR_MTE_FLAGS TCR_TBI1 | TCR_TBID1 |
---|
| 56 | +#else |
---|
| 57 | +#define TCR_MTE_FLAGS 0 |
---|
56 | 58 | #endif |
---|
57 | 59 | |
---|
58 | 60 | /* |
---|
59 | 61 | * Default MAIR_EL1. MT_NORMAL_TAGGED is initially mapped as Normal memory and |
---|
60 | | - * changed during __cpu_setup to Normal Tagged if the system supports MTE. |
---|
| 62 | + * changed during mte_cpu_setup to Normal Tagged if the system supports MTE. |
---|
61 | 63 | */ |
---|
62 | 64 | #define MAIR_EL1_SET \ |
---|
63 | 65 | (MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRnE, MT_DEVICE_nGnRnE) | \ |
---|
.. | .. |
---|
427 | 429 | * Memory region attributes |
---|
428 | 430 | */ |
---|
429 | 431 | mov_q x5, MAIR_EL1_SET |
---|
430 | | -#ifdef CONFIG_ARM64_MTE |
---|
431 | | - mte_tcr .req x20 |
---|
432 | | - |
---|
433 | | - mov mte_tcr, #0 |
---|
434 | | - |
---|
435 | | - /* |
---|
436 | | - * Update MAIR_EL1, GCR_EL1 and TFSR*_EL1 if MTE is supported |
---|
437 | | - * (ID_AA64PFR1_EL1[11:8] > 1). |
---|
438 | | - */ |
---|
439 | | - mrs x10, ID_AA64PFR1_EL1 |
---|
440 | | - ubfx x10, x10, #ID_AA64PFR1_MTE_SHIFT, #4 |
---|
441 | | - cmp x10, #ID_AA64PFR1_MTE |
---|
442 | | - b.lt 1f |
---|
443 | | - |
---|
444 | | - /* Normal Tagged memory type at the corresponding MAIR index */ |
---|
445 | | - mov x10, #MAIR_ATTR_NORMAL_TAGGED |
---|
446 | | - bfi x5, x10, #(8 * MT_NORMAL_TAGGED), #8 |
---|
447 | | - |
---|
448 | | - mov x10, #KERNEL_GCR_EL1 |
---|
449 | | - msr_s SYS_GCR_EL1, x10 |
---|
450 | | - |
---|
451 | | - /* |
---|
452 | | - * If GCR_EL1.RRND=1 is implemented the same way as RRND=0, then |
---|
453 | | - * RGSR_EL1.SEED must be non-zero for IRG to produce |
---|
454 | | - * pseudorandom numbers. As RGSR_EL1 is UNKNOWN out of reset, we |
---|
455 | | - * must initialize it. |
---|
456 | | - */ |
---|
457 | | - mrs x10, CNTVCT_EL0 |
---|
458 | | - ands x10, x10, #SYS_RGSR_EL1_SEED_MASK |
---|
459 | | - csinc x10, x10, xzr, ne |
---|
460 | | - lsl x10, x10, #SYS_RGSR_EL1_SEED_SHIFT |
---|
461 | | - msr_s SYS_RGSR_EL1, x10 |
---|
462 | | - |
---|
463 | | - /* clear any pending tag check faults in TFSR*_EL1 */ |
---|
464 | | - msr_s SYS_TFSR_EL1, xzr |
---|
465 | | - msr_s SYS_TFSRE0_EL1, xzr |
---|
466 | | - |
---|
467 | | - /* set the TCR_EL1 bits */ |
---|
468 | | - mov_q mte_tcr, TCR_MTE_FLAGS |
---|
469 | | -1: |
---|
470 | | -#endif |
---|
471 | 432 | msr mair_el1, x5 |
---|
472 | 433 | /* |
---|
473 | 434 | * Set/prepare TCR and TTBR. TCR_EL1.T1SZ gets further |
---|
.. | .. |
---|
475 | 436 | */ |
---|
476 | 437 | mov_q x10, TCR_TxSZ(VA_BITS) | TCR_CACHE_FLAGS | TCR_SMP_FLAGS | \ |
---|
477 | 438 | TCR_TG_FLAGS | TCR_KASLR_FLAGS | TCR_ASID16 | \ |
---|
478 | | - TCR_TBI0 | TCR_A1 | TCR_KASAN_SW_FLAGS |
---|
479 | | -#ifdef CONFIG_ARM64_MTE |
---|
480 | | - orr x10, x10, mte_tcr |
---|
481 | | - .unreq mte_tcr |
---|
482 | | -#endif |
---|
| 439 | + TCR_TBI0 | TCR_A1 | TCR_KASAN_SW_FLAGS | TCR_MTE_FLAGS |
---|
| 440 | + |
---|
483 | 441 | tcr_clear_errata_bits x10, x9, x5 |
---|
484 | 442 | |
---|
485 | 443 | #ifdef CONFIG_ARM64_VA_BITS_52 |
---|