From: Christian Loehle <christian.loehle@arm.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org, Len Brown <lenb@kernel.org>,
Jie Zhan <zhanjie9@hisilicon.com>,
Lifeng Zheng <zhenglifeng1@huawei.com>,
Pierre Gondois <pierre.gondois@arm.com>,
Sumit Gupta <sumitg@nvidia.com>,
Sudeep Holla <sudeep.holla@arm.com>,
Ionela Voinescu <ionela.voinescu@arm.com>,
zhongqiu.han@oss.qualcomm.com,
Christian Loehle <christian.loehle@arm.com>,
Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH v4 10/15] ACPI: CPPC: Reject direct reads of write-only controls
Date: Wed, 26 Aug 2026 07:30:14 +0100 [thread overview]
Message-ID: <20260826063019.670240-11-christian.loehle@arm.com> (raw)
In-Reply-To: <20260826063019.670240-1-christian.loehle@arm.com>
Between _CPC revision 3 and revision 4, Desired Performance changed from
Read/Write to Write. Revision 4 also added the write-only OSPM Nominal
Performance control. ACPI 6.6 section 4.6.3 says reads of write-only bit
positions produce undefined results.
The public Desired Performance helper already rejects revision-4 readback,
but the common register accessor still permits either write-only control to
be read. Reject both centrally so new callers cannot consume undefined
values.
A partial SystemMemory field still makes cpc_write() read its complete
access unit to preserve bits outside the field. This is valid because
MASK_VAL_WRITE() replaces every bit of the write-only field, discarding its
undefined readback while preserving the surrounding bits. The descriptor
lock serializes the RMW, and the preceding SystemMemory validation rejects
unsafe cross-descriptor partial writers.
Mark an inaccessible OSPM Nominal Performance control unsupported because
it is optional. Do the same for inaccessible Desired Performance while
parsing, then let the post-parse control check accept it only for immutable
autonomous selection. This preserves the autonomous-only exception without
accepting an unusable Desired control in non-autonomous mode.
Fixes: 71e1815113f7 ("ACPI: CPPC: Add support for CPPC v4")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20260807111303.1062391-1-christian.loehle%40arm.com
Link: https://sashiko.dev/#/patchset/20260808082644.1251332-1-christian.loehle%40arm.com
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
---
drivers/acpi/cppc_acpi.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 61afb44d552c..a5920e627d00 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -333,6 +333,21 @@ static bool cpc_reg_is_writable(unsigned int reg_idx)
}
}
+static bool cpc_reg_is_write_only(const struct cpc_desc *cpc_desc,
+ unsigned int reg_idx)
+{
+ return cpc_desc->version >= CPPC_V4_REV &&
+ (reg_idx == DESIRED_PERF || reg_idx == OSPM_NOMINAL_PERF);
+}
+
+static void cpc_disable_reg(struct cpc_desc *cpc_desc, unsigned int reg_idx)
+{
+ struct cpc_register_resource *reg = &cpc_desc->cpc_regs[reg_idx];
+
+ reg->type = ACPI_TYPE_INTEGER;
+ reg->cpc_entry.int_value = 0;
+}
+
static bool cpc_sysmem_reg_needs_rmw(const struct cpc_register_resource *reg)
{
const struct cpc_reg *gas = ®->cpc_entry.reg;
@@ -1291,6 +1306,17 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
size_t access_width;
err = cpc_validate_sysmem_reg(cpc_ptr, gas_t, i - 2);
+ if (err && (i - 2 == DESIRED_PERF ||
+ i - 2 == OSPM_NOMINAL_PERF)) {
+ const char *name = i - 2 == DESIRED_PERF ?
+ "Desired Performance" :
+ "OSPM Nominal Performance";
+
+ pr_warn("CPU%d: disabling inaccessible %s register\n",
+ pr->id, name);
+ cpc_disable_reg(cpc_ptr, i - 2);
+ continue;
+ }
if (err) {
ret = err;
goto out_free;
@@ -1684,6 +1710,10 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
}
if (reg->bit_offset || reg->bit_width != size) {
+ /*
+ * MASK_VAL_WRITE() discards the field's old bits, so undefined
+ * readback from a write-only field is not propagated.
+ */
switch (size) {
case 8:
prev_val = readb_relaxed(vaddr);
@@ -1775,6 +1805,8 @@ static int cppc_get_reg_val(int cpu, enum cppc_regs reg_idx, u64 *val)
pr_debug("No CPC descriptor for CPU:%d\n", cpu);
return -ENODEV;
}
+ if (cpc_reg_is_write_only(cpc_desc, reg_idx))
+ return -EOPNOTSUPP;
reg = &cpc_desc->cpc_regs[reg_idx];
--
2.34.1
next prev parent reply other threads:[~2026-08-26 6:30 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 6:30 [PATCH v4 00/15] ACPI: CPPC: Fix register access and lifetime bugs Christian Loehle
2026-08-26 6:30 ` [PATCH v4 01/15] ACPI: CPPC: Validate the _CPC package header Christian Loehle
2026-08-26 6:30 ` [PATCH v4 02/15] ACPI: CPPC: Validate _CPC entry and control semantics Christian Loehle
2026-08-26 6:30 ` [PATCH v4 03/15] ACPI: CPPC: Propagate performance-control write errors Christian Loehle
2026-08-26 6:30 ` [PATCH v4 04/15] ACPI: CPPC: Use 64-bit masks for register fields Christian Loehle
2026-08-26 6:30 ` [PATCH v4 05/15] ACPI: CPPC: Serialize PCC single-register payload updates Christian Loehle
2026-08-26 6:30 ` [PATCH v4 06/15] ACPI: CPPC: Serialize PCC EPP " Christian Loehle
2026-08-26 6:30 ` [PATCH v4 07/15] ACPI: CPPC: Release CPC descriptors through kobject Christian Loehle
2026-08-26 6:30 ` [PATCH v4 08/15] ACPI: CPPC: Release PCC data after probe failures Christian Loehle
2026-08-26 6:30 ` [PATCH v4 09/15] ACPI: CPPC: Reject unsafe cross-CPU SystemMemory RMW Christian Loehle
2026-08-26 6:30 ` Christian Loehle [this message]
2026-08-26 6:30 ` [PATCH v4 11/15] ACPI: CPPC: Validate and access PCC register layouts Christian Loehle
2026-08-26 6:30 ` [PATCH v4 12/15] ACPI: CPPC: Validate SystemIO " Christian Loehle
2026-08-26 6:30 ` [PATCH v4 13/15] ACPI: CPPC: Validate PCC overlaps across processors Christian Loehle
2026-08-26 6:30 ` [PATCH v4 14/15] ACPI: CPPC: Validate SystemIO " Christian Loehle
2026-08-26 6:30 ` [PATCH v4 15/15] ACPI: CPPC: Clear Performance Limited without a stale read Christian Loehle
2026-08-26 13:59 ` Sumit Gupta
2026-08-26 14:49 ` Christian Loehle
2026-08-26 14:17 ` [PATCH v4 00/15] ACPI: CPPC: Fix register access and lifetime bugs Sumit Gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260826063019.670240-11-christian.loehle@arm.com \
--to=christian.loehle@arm.com \
--cc=ionela.voinescu@arm.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pierre.gondois@arm.com \
--cc=rafael@kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=sudeep.holla@arm.com \
--cc=sumitg@nvidia.com \
--cc=viresh.kumar@linaro.org \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.com \
--cc=zhongqiu.han@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox