hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/9795 ---------------------------------------- Add detection for the ARM64 Domain-based TLB Invalidation (TLBID) feature as defined in ARMv9.3-A architecture. TLBID allows TLB invalidation operations to be scoped to a specific domain, avoiding the need for global TLB invalidation broadcasts across the system. This reduces cache coherency traffic and improves performance in virtualization scenarios. Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- arch/arm64/Kconfig | 20 ++++++++++++++++++++ arch/arm64/include/asm/cpufeature.h | 6 ++++++ arch/arm64/kernel/cpufeature.c | 10 ++++++++++ arch/arm64/tools/cpucaps | 2 +- arch/arm64/tools/sysreg | 5 ++++- 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index ca1041ff7f8c..bdf9c643a8e6 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -2290,6 +2290,26 @@ config ARM64_TLB_RANGE The feature introduces new assembly instructions, and they were support when binutils >= 2.30. +config ARM64_TLBID + bool "Enable support for TLBID (TLBI Domains)" + default y + help + TLBI broadcasting all PEs introduces performance noise. By + combining hardware and software, TLBID (TLBI Domain) limit TLBI + to an appropriate scope, avoiding the performance overhead caused + by broadcasting. + + Arm Architecture defines the FEAT_TLBID extension since Armv9.3, + when present, allows the OSPM to target TLB invalidations to + a specific domain. A TLBI domain can be contained in multiple + parent domains. + + The TLBI table lists all the PE and SMMU components and the TLBI + Domains that each component belongs to. + + The feature is detected at runtime, and will remain disabled + if the system does not implement the feature. + config ARM64_MPAM bool "Enable support for MPAM" select ACPI_MPAM if ACPI diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index fed81fd3baf2..9ff5141518b4 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -892,6 +892,12 @@ static inline bool system_supports_tlb_range(void) cpus_have_const_cap(ARM64_HAS_TLB_RANGE); } +static inline bool system_supports_tlbid(void) +{ + return IS_ENABLED(CONFIG_ARM64_TLBID) && + cpus_have_const_cap(ARM64_HAS_TLBID); +} + static inline bool cpus_support_mpam(void) { return IS_ENABLED(CONFIG_ARM64_MPAM) && diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 3dd327850d35..63115dfa0236 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -447,6 +447,7 @@ static const struct arm64_ftr_bits ftr_id_aa64mmfr3[] = { }; static const struct arm64_ftr_bits ftr_id_aa64mmfr4[] = { + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR4_EL1_TLBID_SHIFT, 4, 0), S_ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR4_EL1_E2H0_SHIFT, 4, 0), ARM64_FTR_END, }; @@ -3256,6 +3257,15 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .type = ARM64_CPUCAP_SYSTEM_FEATURE, .matches = has_copy_opt, }, +#endif +#ifdef CONFIG_ARM64_TLBID + { + .desc = "Domain based ARM64 TLB invalidation", + .capability = ARM64_HAS_TLBID, + .type = ARM64_CPUCAP_SYSTEM_FEATURE, + .matches = has_cpuid_feature, + ARM64_CPUID_FIELDS(ID_AA64MMFR4_EL1, TLBID, IMP) + }, #endif {}, }; diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps index f6445266e886..7320731020ef 100644 --- a/arch/arm64/tools/cpucaps +++ b/arch/arm64/tools/cpucaps @@ -116,7 +116,7 @@ HAS_HW_XCALL_XINT WORKAROUND_PHYTIUM_FT3386 HAS_COPY_OPT HAS_LSUI -KABI_RESERVE_9 +HAS_TLBID KABI_RESERVE_10 KABI_RESERVE_11 KABI_RESERVE_12 diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg index 4770bc4b7690..470b07be5d2c 100644 --- a/arch/arm64/tools/sysreg +++ b/arch/arm64/tools/sysreg @@ -2246,7 +2246,10 @@ UnsignedEnum 47:44 SRMASK 0b0000 NI 0b0001 IMP EndEnum -Res0 43:40 +UnsignedEnum 43:40 TLBID + 0b0000 NI + 0b0001 IMP +EndEnum UnsignedEnum 39:36 E3DSE 0b0000 NI 0b0001 IMP -- 2.43.0