hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/arch/arm64/mm/proc.S
....@@ -47,17 +47,19 @@
4747
4848 #ifdef CONFIG_KASAN_HW_TAGS
4949 #define TCR_MTE_FLAGS SYS_TCR_EL1_TCMA1 | TCR_TBI1 | TCR_TBID1
50
-#else
50
+#elif defined(CONFIG_ARM64_MTE)
5151 /*
5252 * The mte_zero_clear_page_tags() implementation uses DC GZVA, which relies on
5353 * TBI being enabled at EL1.
5454 */
5555 #define TCR_MTE_FLAGS TCR_TBI1 | TCR_TBID1
56
+#else
57
+#define TCR_MTE_FLAGS 0
5658 #endif
5759
5860 /*
5961 * 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.
6163 */
6264 #define MAIR_EL1_SET \
6365 (MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRnE, MT_DEVICE_nGnRnE) | \
....@@ -427,47 +429,6 @@
427429 * Memory region attributes
428430 */
429431 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
471432 msr mair_el1, x5
472433 /*
473434 * Set/prepare TCR and TTBR. TCR_EL1.T1SZ gets further
....@@ -475,11 +436,8 @@
475436 */
476437 mov_q x10, TCR_TxSZ(VA_BITS) | TCR_CACHE_FLAGS | TCR_SMP_FLAGS | \
477438 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
+
483441 tcr_clear_errata_bits x10, x9, x5
484442
485443 #ifdef CONFIG_ARM64_VA_BITS_52