From 92f692b80809076d80269168931ffb240742c029 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mar 30 2024 08:56:45 +0000 Subject: thermal: intel: hfi: Refactor enabling code into helper functions (CVE-2024-26646 bsc#1222070). --- diff --git a/patches.suse/thermal-intel-hfi-Refactor-enabling-code-into-helper.patch b/patches.suse/thermal-intel-hfi-Refactor-enabling-code-into-helper.patch new file mode 100644 index 0000000..86ee561 --- /dev/null +++ b/patches.suse/thermal-intel-hfi-Refactor-enabling-code-into-helper.patch @@ -0,0 +1,107 @@ +From 8a8b6bb93c704776c4b05cb517c3fa8baffb72f5 Mon Sep 17 00:00:00 2001 +From: Ricardo Neri +Date: Tue, 2 Jan 2024 20:14:56 -0800 +Subject: [PATCH] thermal: intel: hfi: Refactor enabling code into helper functions +Git-commit: 8a8b6bb93c704776c4b05cb517c3fa8baffb72f5 +Patch-mainline: v6.8-rc1 +References: CVE-2024-26646 bsc#1222070 + +In preparation for the addition of a suspend notifier, wrap the logic to +enable HFI and program its memory buffer into helper functions. Both the +CPU hotplug callback and the suspend notifier will use them. + +This refactoring does not introduce functional changes. + +Signed-off-by: Ricardo Neri +Signed-off-by: Rafael J. Wysocki +Acked-by: Takashi Iwai + +--- + drivers/thermal/intel/intel_hfi.c | 43 ++++++++++++++++--------------- + 1 file changed, 22 insertions(+), 21 deletions(-) + +diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c +index c69db6c90869..820613e293cd 100644 +--- a/drivers/thermal/intel/intel_hfi.c ++++ b/drivers/thermal/intel/intel_hfi.c +@@ -347,6 +347,26 @@ static void init_hfi_instance(struct hfi_instance *hfi_instance) + hfi_instance->data = hfi_instance->hdr + hfi_features.hdr_size; + } + ++/* Caller must hold hfi_instance_lock. */ ++static void hfi_enable(void) ++{ ++ u64 msr_val; ++ ++ rdmsrl(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val); ++ msr_val |= HW_FEEDBACK_CONFIG_HFI_ENABLE_BIT; ++ wrmsrl(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val); ++} ++ ++static void hfi_set_hw_table(struct hfi_instance *hfi_instance) ++{ ++ phys_addr_t hw_table_pa; ++ u64 msr_val; ++ ++ hw_table_pa = virt_to_phys(hfi_instance->hw_table); ++ msr_val = hw_table_pa | HW_FEEDBACK_PTR_VALID_BIT; ++ wrmsrl(MSR_IA32_HW_FEEDBACK_PTR, msr_val); ++} ++ + /** + * intel_hfi_online() - Enable HFI on @cpu + * @cpu: CPU in which the HFI will be enabled +@@ -364,8 +384,6 @@ void intel_hfi_online(unsigned int cpu) + { + struct hfi_instance *hfi_instance; + struct hfi_cpu_info *info; +- phys_addr_t hw_table_pa; +- u64 msr_val; + u16 die_id; + + /* Nothing to do if hfi_instances are missing. */ +@@ -409,8 +427,6 @@ void intel_hfi_online(unsigned int cpu) + if (!hfi_instance->hw_table) + goto unlock; + +- hw_table_pa = virt_to_phys(hfi_instance->hw_table); +- + /* + * Allocate memory to keep a local copy of the table that + * hardware generates. +@@ -420,16 +436,6 @@ void intel_hfi_online(unsigned int cpu) + if (!hfi_instance->local_table) + goto free_hw_table; + +- /* +- * Program the address of the feedback table of this die/package. On +- * some processors, hardware remembers the old address of the HFI table +- * even after having been reprogrammed and re-enabled. Thus, do not free +- * the pages allocated for the table or reprogram the hardware with a +- * new base address. Namely, program the hardware only once. +- */ +- msr_val = hw_table_pa | HW_FEEDBACK_PTR_VALID_BIT; +- wrmsrl(MSR_IA32_HW_FEEDBACK_PTR, msr_val); +- + init_hfi_instance(hfi_instance); + + INIT_DELAYED_WORK(&hfi_instance->update_work, hfi_update_work_fn); +@@ -438,13 +444,8 @@ void intel_hfi_online(unsigned int cpu) + + cpumask_set_cpu(cpu, hfi_instance->cpus); + +- /* +- * Enable the hardware feedback interface and never disable it. See +- * comment on programming the address of the table. +- */ +- rdmsrl(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val); +- msr_val |= HW_FEEDBACK_CONFIG_HFI_ENABLE_BIT; +- wrmsrl(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val); ++ hfi_set_hw_table(hfi_instance); ++ hfi_enable(); + + unlock: + mutex_unlock(&hfi_instance_lock); +-- +2.43.0 + diff --git a/series.conf b/series.conf index 5dde099..c3d5c36 100644 --- a/series.conf +++ b/series.conf @@ -45090,6 +45090,7 @@ patches.suse/ACPI-resource-Add-Infinity-laptops-to-irq1_edge_low_.patch patches.suse/ACPI-LPSS-Fix-the-fractional-clock-divider-flags.patch patches.suse/PNP-ACPI-fix-fortify-warning.patch + patches.suse/thermal-intel-hfi-Refactor-enabling-code-into-helper.patch patches.suse/PM-hibernate-Enforce-ordering-during-image-compressi.patch patches.suse/ipmi-Use-regspacings-passed-as-a-module-parameter.patch patches.suse/efivarfs-force-RO-when-remounting-if-SetVariable-is-.patch