hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/10013 ---------------------------------------------- Add a kernel command line parameter "novipsmt" to disable VIP-SMT sysfs interface at boot time. When novipsmt is specified, the vip_smt directory will not be created under/sys/devices/system/cpu/cpuX/regs/. This allows users to disable VIP-SMT functionality if needed. Usage: - Disable via boot param: novipsmt or novipsmt=force Signed-off-by: Yipeng Zou <zouyipeng@huawei.com> Reviewed-by: Liao Chang <liaochang1@huawei.com> --- .../admin-guide/kernel-parameters.txt | 4 ++ arch/arm64/kernel/vip_smt.c | 38 ++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index cbc2064a8d80..9e52f393b679 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3998,6 +3998,10 @@ nosmt=force: Force disable SMT, cannot be undone via the sysfs control file. + novipsmt [ARM64] Disable VIP-SMT sysfs interface at boot. + When specified, vip_smt directory will not be created + under /sys/devices/system/cpu/cpuX/regs/. + nosoftlockup [KNL] Disable the soft-lockup detector. nospec_store_bypass_disable diff --git a/arch/arm64/kernel/vip_smt.c b/arch/arm64/kernel/vip_smt.c index c3823a674cfe..ff9b1675aa83 100644 --- a/arch/arm64/kernel/vip_smt.c +++ b/arch/arm64/kernel/vip_smt.c @@ -213,7 +213,7 @@ struct vip_smt_reg_data { */ bool vip_smt_available(void) { - return cpus_have_cap(ARM64_HAS_VIP_SMT); + return (vip_smt_control == VIP_SMT_ENABLED) && cpus_have_cap(ARM64_HAS_VIP_SMT); } EXPORT_SYMBOL_GPL(vip_smt_available); @@ -361,6 +361,9 @@ static const struct attribute_group vip_smt_attr_group = { int vip_smt_cpu_sysfs_create(unsigned int cpu, struct cpuinfo_arm64 *info) { + if (vip_smt_control != VIP_SMT_ENABLED) + return -1; + if (!vip_smt_core_has_smt(cpu)) return -1; @@ -410,6 +413,33 @@ void vip_smt_exit_idle(void) } } +/** + * vip_smt_disable - Disable VIP-SMT feature + * @state: Disable state ("force" means force disable) + */ +static void __init vip_smt_disable(char *state) +{ + if (!state) { + vip_smt_control = VIP_SMT_DISABLED; + pr_info("VIP-SMT: Disabled via cmdline\n"); + } else if (strcmp(state, "force") == 0) { + vip_smt_control = VIP_SMT_FORCE_DISABLED; + pr_info("VIP-SMT: Force disabled via cmdline\n"); + } else { + vip_smt_control = VIP_SMT_DISABLED; + } +} + +/** + * vip_smt_cmdline_disable - cmdline parameter handler + */ +static int __init vip_smt_cmdline_disable(char *str) +{ + vip_smt_disable(str); + return 0; +} +early_param("novipsmt", vip_smt_cmdline_disable); + /** * vip_smt_probe - Detect hardware support for VIP-SMT * @@ -431,6 +461,12 @@ static bool vip_smt_probe(void) bool has_vip_smt_support(const struct arm64_cpu_capabilities *entry, int __unused) { + /* If hardware not supported or disabled, set to NOT_SUPPORTED */ + if (vip_smt_control != VIP_SMT_ENABLED) { + pr_info("VIP-SMT: Disabled in cmdline.\n"); + return false; + } + /* Only can access from el2 for now!, configure in el3. */ if (!is_kernel_in_hyp_mode()) { pr_info("VIP-SMT: Only support in EL2 for now.\n"); -- 2.34.1