Skip to content

Commit 5a43b87

Browse files
spandruvadasuryasaimadhu
authored andcommitted
x86/mce/therm_throt: Mask out read-only and reserved MSR bits
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: f665620 ("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]
1 parent c2da5bd commit 5a43b87

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

arch/x86/kernel/cpu/mce/therm_throt.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,24 @@ static const struct attribute_group thermal_attr_group = {
195195
#define THERM_THROT_POLL_INTERVAL HZ
196196
#define THERM_STATUS_PROCHOT_LOG BIT(1)
197197

198+
#define THERM_STATUS_CLEAR_CORE_MASK (BIT(1) | BIT(3) | BIT(5) | BIT(7) | BIT(9) | BIT(11) | BIT(13) | BIT(15))
199+
#define THERM_STATUS_CLEAR_PKG_MASK (BIT(1) | BIT(3) | BIT(5) | BIT(7) | BIT(9) | BIT(11))
200+
198201
static void clear_therm_status_log(int level)
199202
{
200203
int msr;
201-
u64 msr_val;
204+
u64 mask, msr_val;
202205

203-
if (level == CORE_LEVEL)
204-
msr = MSR_IA32_THERM_STATUS;
205-
else
206-
msr = MSR_IA32_PACKAGE_THERM_STATUS;
206+
if (level == CORE_LEVEL) {
207+
msr = MSR_IA32_THERM_STATUS;
208+
mask = THERM_STATUS_CLEAR_CORE_MASK;
209+
} else {
210+
msr = MSR_IA32_PACKAGE_THERM_STATUS;
211+
mask = THERM_STATUS_CLEAR_PKG_MASK;
212+
}
207213

208214
rdmsrl(msr, msr_val);
215+
msr_val &= mask;
209216
wrmsrl(msr, msr_val & ~THERM_STATUS_PROCHOT_LOG);
210217
}
211218

0 commit comments

Comments
 (0)