FAILED: patch "[PATCH] ACPI: CPPC: Propagate errors from cross-CPU FFH calls" failed to apply to 6.6-stable tree
Subsystems (5)
Sasha Levin
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 36e96b469da24868f727b4cd168d7cf01cbd163d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 36e96b469da24868f727b4cd168d7cf01cbd163d Mon Sep 17 00:00:00 2001
From: Christian Loehle <[email protected]>
Date: Wed, 16 Sep 2026 17:28:02 +0100
Subject: [PATCH] ACPI: CPPC: Propagate errors from cross-CPU FFH calls
The arm64 and RISC-V CPPC FFH accessors ignore the return value of smp_call_function_single(). If the target CPU is offline, the call can return -ENXIO without running the callback. The accessors then consume callback output which was never initialized and may report success.
CPU offlining leaves the CPU's CPPC sysfs attributes present. On arm64, the AMU feature mask does not exclude an offline CPU, so a paired counter read can expose uninitialized stack values through feedback_ctrs. RISC-V has the same problem in both SBI and CSR reads, and its write paths also inspect an uninitialized callback status after a failed cross-CPU call.
Return the SMP call error before using callback output. The arm64 single and paired counter readers already check the helper's return value. For RISC-V, also check the callback status before copying a read value: an unsupported CSR sets the error but does not initialize the value.
--- arch/arm64/kernel/topology.c | 2 +- drivers/acpi/riscv/cppc.c | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-)
arch/arm64/kernel/topology.c +1 -1
@@ -427,7 +427,7 @@ int counters_read_on_cpu(int cpu, smp_call_func_t func, void *val)return -EPERM ;func (val); }else { -smp_call_function_single (cpu, func, val,1 ); +return smp_call_function_single (cpu, func, val,1 ); }return 0 ;
drivers/acpi/riscv/cppc.c +20 -6
@@ -97,6 +97,7 @@ bool cpc_ffh_supported(void)int cpc_read_ffh (int cpu,struct cpc_reg *reg,u64 *val) {struct sbi_cppc_data data; +int ret;if (WARN_ON_ONCE (irqs_disabled ()))return -EPERM ;
@@ -107,19 +108,27 @@ int cpc_read_ffh(int cpu, struct cpc_reg *reg, u64 *val) data.reg =FFH_CPPC_SBI_REG (reg->address); -smp_call_function_single (cpu, sbi_cppc_read, &data,1 ); + ret =smp_call_function_single (cpu, sbi_cppc_read, &data,1 ); +if (ret) +return ret; +if (data.ret.error) +return sbi_err_map_linux_errno (data.ret.error); *val = data.ret.value; -return (data.ret.error) ?sbi_err_map_linux_errno (data.ret.error) :0 ; +return 0 ; }else if (FFH_CPPC_TYPE (reg->address) ==FFH_CPPC_CSR ) { data.reg =FFH_CPPC_CSR_NUM (reg->address); -smp_call_function_single (cpu, cppc_ffh_csr_read, &data,1 ); + ret =smp_call_function_single (cpu, cppc_ffh_csr_read, &data,1 ); +if (ret) +return ret; +if (data.ret.error) +return data.ret.error; *val = data.ret.value; -return data.ret.error; +return 0 ; }return -EINVAL ;
@@ -128,6 +137,7 @@ int cpc_read_ffh(int cpu, struct cpc_reg *reg, u64 *val)int cpc_write_ffh (int cpu,struct cpc_reg *reg,u64 val) {struct sbi_cppc_data data; +int ret;if (WARN_ON_ONCE (irqs_disabled ()))return -EPERM ;
@@ -139,14 +149,18 @@ int cpc_write_ffh(int cpu, struct cpc_reg *reg, u64 val) data.reg =FFH_CPPC_SBI_REG (reg->address); data.val = val; -smp_call_function_single (cpu, sbi_cppc_write, &data,1 ); + ret =smp_call_function_single (cpu, sbi_cppc_write, &data,1 ); +if (ret) +return ret;return (data.ret.error) ?sbi_err_map_linux_errno (data.ret.error) :0 ; }else if (FFH_CPPC_TYPE (reg->address) ==FFH_CPPC_CSR ) { data.reg =FFH_CPPC_CSR_NUM (reg->address); data.val = val; -smp_call_function_single (cpu, cppc_ffh_csr_write, &data,1 ); + ret =smp_call_function_single (cpu, cppc_ffh_csr_write, &data,1 ); +if (ret) +return ret;return data.ret.error; }
Signature · 1 line
2.53.0