forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/arch/x86/kernel/cpu/tsx.c
....@@ -14,6 +14,9 @@
1414
1515 #include "cpu.h"
1616
17
+#undef pr_fmt
18
+#define pr_fmt(fmt) "tsx: " fmt
19
+
1720 enum tsx_ctrl_states tsx_ctrl_state __ro_after_init = TSX_CTRL_NOT_SUPPORTED;
1821
1922 void tsx_disable(void)
....@@ -55,24 +58,6 @@
5558 wrmsrl(MSR_IA32_TSX_CTRL, tsx);
5659 }
5760
58
-static bool __init tsx_ctrl_is_supported(void)
59
-{
60
- u64 ia32_cap = x86_read_arch_cap_msr();
61
-
62
- /*
63
- * TSX is controlled via MSR_IA32_TSX_CTRL. However, support for this
64
- * MSR is enumerated by ARCH_CAP_TSX_MSR bit in MSR_IA32_ARCH_CAPABILITIES.
65
- *
66
- * TSX control (aka MSR_IA32_TSX_CTRL) is only available after a
67
- * microcode update on CPUs that have their MSR_IA32_ARCH_CAPABILITIES
68
- * bit MDS_NO=1. CPUs with MDS_NO=0 are not planned to get
69
- * MSR_IA32_TSX_CTRL support even after a microcode update. Thus,
70
- * tsx= cmdline requests will do nothing on CPUs without
71
- * MSR_IA32_TSX_CTRL support.
72
- */
73
- return !!(ia32_cap & ARCH_CAP_TSX_CTRL_MSR);
74
-}
75
-
7661 static enum tsx_ctrl_states x86_get_tsx_auto_mode(void)
7762 {
7863 if (boot_cpu_has_bug(X86_BUG_TAA))
....@@ -86,8 +71,21 @@
8671 char arg[5] = {};
8772 int ret;
8873
89
- if (!tsx_ctrl_is_supported())
74
+ /*
75
+ * TSX is controlled via MSR_IA32_TSX_CTRL. However, support for this
76
+ * MSR is enumerated by ARCH_CAP_TSX_MSR bit in MSR_IA32_ARCH_CAPABILITIES.
77
+ *
78
+ * TSX control (aka MSR_IA32_TSX_CTRL) is only available after a
79
+ * microcode update on CPUs that have their MSR_IA32_ARCH_CAPABILITIES
80
+ * bit MDS_NO=1. CPUs with MDS_NO=0 are not planned to get
81
+ * MSR_IA32_TSX_CTRL support even after a microcode update. Thus,
82
+ * tsx= cmdline requests will do nothing on CPUs without
83
+ * MSR_IA32_TSX_CTRL support.
84
+ */
85
+ if (!(x86_read_arch_cap_msr() & ARCH_CAP_TSX_CTRL_MSR))
9086 return;
87
+
88
+ setup_force_cpu_cap(X86_FEATURE_MSR_TSX_CTRL);
9189
9290 ret = cmdline_find_option(boot_command_line, "tsx", arg, sizeof(arg));
9391 if (ret >= 0) {
....@@ -99,7 +97,7 @@
9997 tsx_ctrl_state = x86_get_tsx_auto_mode();
10098 } else {
10199 tsx_ctrl_state = TSX_CTRL_DISABLE;
102
- pr_err("tsx: invalid option, defaulting to off\n");
100
+ pr_err("invalid option, defaulting to off\n");
103101 }
104102 } else {
105103 /* tsx= not provided */