Skip to content

Commit 4357f03

Browse files
committed
Merge tag 'pm-5.15-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fixes from Rafael Wysocki: "These fix two cpufreq issues, one in the intel_pstate driver and one in the core. Specifics: - Prevent intel_pstate from avoiding to use HWP, even if instructed to do so via the kernel command line, when HWP has been enabled already by the platform firmware (Doug Smythies). - Prevent use-after-free from occurring in the schedutil cpufreq governor on exit by fixing a core helper function that attempts to access memory associated with a kobject after calling kobject_put() on it (James Morse)" * tag 'pm-5.15-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: cpufreq: schedutil: Destroy mutex before kobject_put() frees the memory cpufreq: intel_pstate: Override parameters if HWP forced by BIOS
2 parents b9b11b1 + cdef119 commit 4357f03

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

drivers/cpufreq/cpufreq_governor_attr_set.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ unsigned int gov_attr_set_put(struct gov_attr_set *attr_set, struct list_head *l
7474
if (count)
7575
return count;
7676

77-
kobject_put(&attr_set->kobj);
7877
mutex_destroy(&attr_set->update_lock);
78+
kobject_put(&attr_set->kobj);
7979
return 0;
8080
}
8181
EXPORT_SYMBOL_GPL(gov_attr_set_put);

drivers/cpufreq/intel_pstate.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3205,11 +3205,15 @@ static int __init intel_pstate_init(void)
32053205
if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
32063206
return -ENODEV;
32073207

3208-
if (no_load)
3209-
return -ENODEV;
3210-
32113208
id = x86_match_cpu(hwp_support_ids);
32123209
if (id) {
3210+
bool hwp_forced = intel_pstate_hwp_is_enabled();
3211+
3212+
if (hwp_forced)
3213+
pr_info("HWP enabled by BIOS\n");
3214+
else if (no_load)
3215+
return -ENODEV;
3216+
32133217
copy_cpu_funcs(&core_funcs);
32143218
/*
32153219
* Avoid enabling HWP for processors without EPP support,
@@ -3219,8 +3223,7 @@ static int __init intel_pstate_init(void)
32193223
* If HWP is enabled already, though, there is no choice but to
32203224
* deal with it.
32213225
*/
3222-
if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
3223-
intel_pstate_hwp_is_enabled()) {
3226+
if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) || hwp_forced) {
32243227
hwp_active++;
32253228
hwp_mode_bdw = id->driver_data;
32263229
intel_pstate.attr = hwp_cpufreq_attrs;
@@ -3235,7 +3238,11 @@ static int __init intel_pstate_init(void)
32353238

32363239
goto hwp_cpu_matched;
32373240
}
3241+
pr_info("HWP not enabled\n");
32383242
} else {
3243+
if (no_load)
3244+
return -ENODEV;
3245+
32393246
id = x86_match_cpu(intel_pstate_cpu_ids);
32403247
if (!id) {
32413248
pr_info("CPU model not supported\n");
@@ -3314,10 +3321,9 @@ static int __init intel_pstate_setup(char *str)
33143321
else if (!strcmp(str, "passive"))
33153322
default_driver = &intel_cpufreq;
33163323

3317-
if (!strcmp(str, "no_hwp")) {
3318-
pr_info("HWP disabled\n");
3324+
if (!strcmp(str, "no_hwp"))
33193325
no_hwp = 1;
3320-
}
3326+
33213327
if (!strcmp(str, "force"))
33223328
force_load = 1;
33233329
if (!strcmp(str, "hwp_only"))

0 commit comments

Comments
 (0)