]> Git Repo - linux.git/commitdiff
x86/mce/therm_throt: Mask out read-only and reserved MSR bits
authorSrinivas Pandruvada <[email protected]>
Thu, 28 Nov 2019 15:08:24 +0000 (07:08 -0800)
committerBorislav Petkov <[email protected]>
Fri, 29 Nov 2019 08:17:52 +0000 (09:17 +0100)
While writing to MSR IA32_THERM_STATUS/IA32_PKG_THERM_STATUS, avoid
writing 1 to read only and reserved fields because updating some fields
generates exception.

 [ bp: Vertically align for better readability. ]

Fixes: f6656208f04e ("x86/mce/therm_throt: Optimize notifications of thermal throttle")
Reported-by: Dominik Brodowski <[email protected]>
Tested-by: Dominik Brodowski <[email protected]>
Signed-off-by: Srinivas Pandruvada <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: linux-edac <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: x86-ml <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
arch/x86/kernel/cpu/mce/therm_throt.c

index d01e0da0163ac810f2af5f5a74b5cf8cfe1bffd1..b38010b541d6edff1f6b6cf885b6d76ba89847d5 100644 (file)
@@ -195,17 +195,24 @@ static const struct attribute_group thermal_attr_group = {
 #define THERM_THROT_POLL_INTERVAL      HZ
 #define THERM_STATUS_PROCHOT_LOG       BIT(1)
 
+#define THERM_STATUS_CLEAR_CORE_MASK (BIT(1) | BIT(3) | BIT(5) | BIT(7) | BIT(9) | BIT(11) | BIT(13) | BIT(15))
+#define THERM_STATUS_CLEAR_PKG_MASK  (BIT(1) | BIT(3) | BIT(5) | BIT(7) | BIT(9) | BIT(11))
+
 static void clear_therm_status_log(int level)
 {
        int msr;
-       u64 msr_val;
+       u64 mask, msr_val;
 
-       if (level == CORE_LEVEL)
-               msr = MSR_IA32_THERM_STATUS;
-       else
-               msr = MSR_IA32_PACKAGE_THERM_STATUS;
+       if (level == CORE_LEVEL) {
+               msr  = MSR_IA32_THERM_STATUS;
+               mask = THERM_STATUS_CLEAR_CORE_MASK;
+       } else {
+               msr  = MSR_IA32_PACKAGE_THERM_STATUS;
+               mask = THERM_STATUS_CLEAR_PKG_MASK;
+       }
 
        rdmsrl(msr, msr_val);
+       msr_val &= mask;
        wrmsrl(msr, msr_val & ~THERM_STATUS_PROCHOT_LOG);
 }
 
This page took 0.045841 seconds and 4 git commands to generate.