Skip to contentSkip to conversation

platform/x86: ISST: Check HWP support before MSR access

PATCH Superseded lirongqing 2 participants 5 messages Feb 28 – Mar 2

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

lirongqing

author
#0 lore raw

PATCH 1/1 platform/x86: ISST: Check HWP support before MSR access

From: Li RongQing <[email protected]>

On some systems, HWP can be explicitly disabled in the BIOS settings When HWP is disabled by firmware, the HWP CPUID bit is not set, and attempting to read MSR_PM_ENABLE will result in a General Protection (GP) fault.

[  426.715441] unchecked MSR access error: RDMSR from 0x770 at rIP: 0xffffffffc33db92e (disable_dynamic_sst_features+0xe/0x50 [isst_tpmi_core])
[  426.715450] Call Trace:
[  426.715453]  <TASK>
[  426.715454]  ? ex_handler_msr+0xf6/0x150
[  426.715461]  ? fixup_exception+0x1ad/0x340
[  426.715462]  ? gp_try_fixup_and_notify+0x1e/0xb0
[  426.715466]  ? exc_general_protection+0xc9/0x390
[  426.715470]  ? terminate_walk+0x64/0x100
[  426.715474]  ? asm_exc_general_protection+0x22/0x30
[  426.715477]  ? disable_dynamic_sst_features+0xe/0x50 [isst_tpmi_core]
[  426.715480]  isst_if_def_ioctl+0xece/0x1050 [isst_tpmi_core]
[  426.715484]  ? ioctl_has_perm.constprop.42+0xe0/0x130
[  426.715489]  isst_if_def_ioctl+0x10d/0x1a0 [isst_if_common]
[  426.715495]  __se_sys_ioctl+0x86/0xc0
[  426.715498]  do_syscall_64+0x8a/0x100
[  426.715500]  entry_SYSCALL_64_after_hwframe+0x78/0xe2
[  426.715503] RIP: 0033:0x7f36eaef54a7

Add a check for X86_FEATURE_HWP before accessing the MSR. If HWP is not available, return false safely.

Fixes 12a7d2cb811dd8a ("platform/x86: ISST: Add SST-CP support via TPMI")
---
 drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +3 -0
index b8cdaa2..6f46cbb 100644
@@ -558,6 +558,9 @@ static bool disable_dynamic_sst_features(void)
 {
 	u64 value;
 
+	if (!static_cpu_has(X86_FEATURE_HWP))
+		return true;
+
 	rdmsrq(MSR_PM_ENABLE, value);
 	return !(value & 0x1);
 }
Signature · 1 line
2.9.4
#1 lore raw
Quoted 54 lines · lirongqing

From: Li RongQing <[email protected]>

On some systems, HWP can be explicitly disabled in the BIOS settings When HWP is disabled by firmware, the HWP CPUID bit is not set, and attempting to read MSR_PM_ENABLE will result in a General Protection (GP) fault.

[  426.715441] unchecked MSR access error: RDMSR from 0x770 at rIP:
0xffffffffc33db92e (disable_dynamic_sst_features+0xe/0x50 [isst_tpmi_core])
[  426.715450] Call Trace:
[  426.715453]  <TASK>
[  426.715454]  ? ex_handler_msr+0xf6/0x150
[  426.715461]  ? fixup_exception+0x1ad/0x340
[  426.715462]  ? gp_try_fixup_and_notify+0x1e/0xb0
[  426.715466]  ? exc_general_protection+0xc9/0x390
[  426.715470]  ? terminate_walk+0x64/0x100
[  426.715474]  ? asm_exc_general_protection+0x22/0x30
[  426.715477]  ? disable_dynamic_sst_features+0xe/0x50 [isst_tpmi_core]
[  426.715480]  isst_if_def_ioctl+0xece/0x1050 [isst_tpmi_core] [  426.715484]  ? ioctl_has_perm.constprop.42+0xe0/0x130 [  426.715489]  isst_if_def_ioctl+0x10d/0x1a0 [isst_if_common] [  426.715495]  __se_sys_ioctl+0x86/0xc0
[  426.715498]  do_syscall_64+0x8a/0x100
[  426.715500]  entry_SYSCALL_64_after_hwframe+0x78/0xe2 [  426.715503] RIP: 0033:0x7f36eaef54a7

Add a check for X86_FEATURE_HWP before accessing the MSR. If HWP is not available, return false safely.

Fixes 12a7d2cb811dd8a ("platform/x86: ISST: Add SST-CP support via

TPMI")

---
 drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c | 3 +++

 1 file changed, 3 insertions(+)

diff --git a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c index b8cdaa2..6f46cbb 100644

drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +0 -0
@@ -558,6 +558,9 @@ static bool disable_dynamic_sst_features(void)
  {
  	u64 value;

drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +3 -0
+	if (!static_cpu_has(X86_FEATURE_HWP))
+		return true;
+

  rdmsrq(MSR_PM_ENABLE, value);
  return !(value & 0x1);
 }

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to lirongqing
Quoted 28 lines · lirongqing

From: Li RongQing <[email protected]>

On some systems, HWP can be explicitly disabled in the BIOS settings When HWP is disabled by firmware, the HWP CPUID bit is not set, and attempting to read MSR_PM_ENABLE will result in a General Protection (GP) fault.

[  426.715441] unchecked MSR access error: RDMSR from 0x770 at rIP:
0xffffffffc33db92e (disable_dynamic_sst_features+0xe/0x50 [isst_tpmi_core])
[  426.715450] Call Trace:
[  426.715453]  <TASK>
[  426.715454]  ? ex_handler_msr+0xf6/0x150
[  426.715461]  ? fixup_exception+0x1ad/0x340
[  426.715462]  ? gp_try_fixup_and_notify+0x1e/0xb0
[  426.715466]  ? exc_general_protection+0xc9/0x390
[  426.715470]  ? terminate_walk+0x64/0x100
[  426.715474]  ? asm_exc_general_protection+0x22/0x30
[  426.715477]  ? disable_dynamic_sst_features+0xe/0x50 [isst_tpmi_core]
[  426.715480]  isst_if_def_ioctl+0xece/0x1050 [isst_tpmi_core] [  426.715484]  ? ioctl_has_perm.constprop.42+0xe0/0x130 [  426.715489]  isst_if_def_ioctl+0x10d/0x1a0 [isst_if_common] [  426.715495]  __se_sys_ioctl+0x86/0xc0
[  426.715498]  do_syscall_64+0x8a/0x100
[  426.715500]  entry_SYSCALL_64_after_hwframe+0x78/0xe2 [  426.715503] RIP: 0033:0x7f36eaef54a7

Quoted 6 lines

Add a check for X86_FEATURE_HWP before accessing the MSR. If HWP is not available, return false safely.

Fixes 12a7d2cb811dd8a ("platform/x86: ISST: Add SST-CP support via

TPMI")

Quoted 20 lines

---
 drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c | 3 +++

 1 file changed, 3 insertions(+)

diff --git a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c index b8cdaa2..6f46cbb 100644

drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +0 -0
@@ -558,6 +558,9 @@ static bool disable_dynamic_sst_features(void)
  {
  	u64 value;

drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +3 -0
+	if (!static_cpu_has(X86_FEATURE_HWP))
+		return true;
+

  rdmsrq(MSR_PM_ENABLE, value);
  return !(value & 0x1);
 }

#3 lore raw
In reply to lirongqing
Quoted 24 lines

On some systems, HWP can be explicitly disabled in the BIOS settings When HWP is disabled by firmware, the HWP CPUID bit is not set, and attempting to read MSR_PM_ENABLE will result in a General Protection
(GP) fault.

[  426.715441] unchecked MSR access error: RDMSR from 0x770 at rIP:
0xffffffffc33db92e (disable_dynamic_sst_features+0xe/0x50 [isst_tpmi_core])
[  426.715450] Call Trace:
[  426.715453]  <TASK>
[  426.715454]  ? ex_handler_msr+0xf6/0x150 [  426.715461]  ?
fixup_exception+0x1ad/0x340 [  426.715462]  ?
gp_try_fixup_and_notify+0x1e/0xb0 [  426.715466]  ?
exc_general_protection+0xc9/0x390 [  426.715470]  ?
terminate_walk+0x64/0x100 [  426.715474]  ?
asm_exc_general_protection+0x22/0x30
[  426.715477]  ? disable_dynamic_sst_features+0xe/0x50 [isst_tpmi_core]
[  426.715480]  isst_if_def_ioctl+0xece/0x1050 [isst_tpmi_core]
[  426.715484]  ? ioctl_has_perm.constprop.42+0xe0/0x130
[  426.715489]  isst_if_def_ioctl+0x10d/0x1a0 [isst_if_common]
[  426.715495]  __se_sys_ioctl+0x86/0xc0 [  426.715498]
do_syscall_64+0x8a/0x100 [  426.715500]
entry_SYSCALL_64_after_hwframe+0x78/0xe2
[  426.715503] RIP: 0033:0x7f36eaef54a7
Quoted 2 lines

Add a check for X86_FEATURE_HWP before accessing the MSR. If HWP is not available, return false safely.

It returns true, not false. Could you revise this commit message in the merge?

[Li,Rongqing]

Quoted 24 lines
Fixes 12a7d2cb811dd8a ("platform/x86: ISST: Add SST-CP support via TPMI")
---
 drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +3 -1
index b8cdaa2..6f46cbb 100644
@@ -558,6 +558,9 @@ static bool disable_dynamic_sst_features(void)
 {
 	u64 value;
 
+	if (!static_cpu_has(X86_FEATURE_HWP))
+		return true;
+
 	rdmsrq(MSR_PM_ENABLE, value);
 	return !(value & 0x1);
 }
--

2.9.4

#4 lore raw
Quoted 28 lines · Li,Rongqing(ACG CCN)
Quoted 28 lines

On some systems, HWP can be explicitly disabled in the BIOS settings When
HWP is disabled by firmware, the HWP CPUID bit is not set, and attempting to
read MSR_PM_ENABLE will result in a General Protection (GP) fault.

[  426.715441] unchecked MSR access error: RDMSR from 0x770 at rIP:
0xffffffffc33db92e (disable_dynamic_sst_features+0xe/0x50 [isst_tpmi_core])
[  426.715450] Call Trace:
[  426.715453]  <TASK>
[  426.715454]  ? ex_handler_msr+0xf6/0x150 [  426.715461]  ?

fixup_exception+0x1ad/0x340 [  426.715462]  ?
gp_try_fixup_and_notify+0x1e/0xb0 [  426.715466]  ?
exc_general_protection+0xc9/0x390 [  426.715470]  ?
terminate_walk+0x64/0x100 [  426.715474]  ?
asm_exc_general_protection+0x22/0x30
[  426.715477]  ? disable_dynamic_sst_features+0xe/0x50

[isst_tpmi_core]
[  426.715480]  isst_if_def_ioctl+0xece/0x1050 [isst_tpmi_core] [  426.715484]  ? ioctl_has_perm.constprop.42+0xe0/0x130 [  426.715489]  isst_if_def_ioctl+0x10d/0x1a0 [isst_if_common] [  426.715495]  __se_sys_ioctl+0x86/0xc0 [  426.715498]

do_syscall_64+0x8a/0x100 [  426.715500]
entry_SYSCALL_64_after_hwframe+0x78/0xe2

[  426.715503] RIP: 0033:0x7f36eaef54a7

Quoted 6 lines
Quoted 3 lines

Add a check for X86_FEATURE_HWP before accessing the MSR. If HWP is not
available, return false safely.

It returns true, not false. Could you revise this commit message in the merge?

You should submit V2.

Thanks,
Srinivas

Quoted 31 lines

[Li,Rongqing]

Quoted 27 lines
Fixes 12a7d2cb811dd8a ("platform/x86: ISST: Add SST-CP support via

TPMI")

---
 drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c | 3
+++

 1 file changed, 3 insertions(+)

diff --git a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c index b8cdaa2..6f46cbb 100644

drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +3 -1
@@ -558,6 +558,9 @@ static bool disable_dynamic_sst_features(void)
  {
  	u64 value;
 
+	if (!static_cpu_has(X86_FEATURE_HWP))
+		return true;
+
  	rdmsrq(MSR_PM_ENABLE, value);
  	return !(value & 0x1);
  }
--

2.9.4