Skip to content

Commit c2f84ed

Browse files
committed
x86/mce/therm_throt: Do not access uninitialized therm_work
jira LE-3201 Rebuild_History Non-Buildable kernel-rt-4.18.0-553.22.1.rt7.363.el8_10 commit-author Chuansheng Liu <chuansheng.liu@intel.com> commit 9783709 It is relatively easy to trigger the following boot splat on an Ice Lake client platform. The call stack is like: kernel BUG at kernel/timer/timer.c:1152! Call Trace: __queue_delayed_work queue_delayed_work_on therm_throt_process intel_thermal_interrupt ... The reason is that a CPU's thermal interrupt is enabled prior to executing its hotplug onlining callback which will initialize the throttling workqueues. Such a race can lead to therm_throt_process() accessing an uninitialized therm_work, leading to the above BUG at a very early bootup stage. Therefore, unmask the thermal interrupt vector only after having setup the workqueues completely. [ bp: Heavily massage commit message and correct comment formatting. ] Fixes: f665620 ("x86/mce/therm_throt: Optimize notifications of thermal throttle") Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com> Signed-off-by: Borislav Petkov <bp@suse.de> Acked-by: Tony Luck <tony.luck@intel.com> Link: https://lkml.kernel.org/r/20200107004116.59353-1-chuansheng.liu@intel.com (cherry picked from commit 9783709) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent bf67d69 commit c2f84ed

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/thermal/intel/therm_throt.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ static void thermal_throttle_remove_dev(struct device *dev)
269269
static int thermal_throttle_online(unsigned int cpu)
270270
{
271271
struct device *dev = get_cpu_device(cpu);
272+
u32 l;
272273

273274
/*
274275
* The first CPU coming online will enable the HFI. Usually this causes
@@ -277,6 +278,10 @@ static int thermal_throttle_online(unsigned int cpu)
277278
*/
278279
intel_hfi_online(cpu);
279280

281+
/* Unmask the thermal vector after the above workqueues are initialized. */
282+
l = apic_read(APIC_LVTTHMR);
283+
apic_write(APIC_LVTTHMR, l & ~APIC_LVT_MASKED);
284+
280285
return thermal_throttle_add_dev(dev, cpu);
281286
}
282287

@@ -533,10 +538,6 @@ void intel_init_thermal(struct cpuinfo_x86 *c)
533538
rdmsr(MSR_IA32_MISC_ENABLE, l, h);
534539
wrmsr(MSR_IA32_MISC_ENABLE, l | MSR_IA32_MISC_ENABLE_TM1, h);
535540

536-
/* Unmask the thermal vector: */
537-
l = apic_read(APIC_LVTTHMR);
538-
apic_write(APIC_LVTTHMR, l & ~APIC_LVT_MASKED);
539-
540541
pr_info_once("CPU0: Thermal monitoring enabled (%s)\n",
541542
tm2 ? "TM2" : "TM1");
542543

0 commit comments

Comments
 (0)