From: Bradley Morgan <include@grrlz.net>
To: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Bradley Morgan <include@grrlz.net>
Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] arm64: sleep: assert compute_mpidr_hash registers are distinct
Date: Sun, 5 Jul 2026 19:23:30 +0000 [thread overview]
Message-ID: <20260705192331.23150-2-include@grrlz.net> (raw)
In-Reply-To: <20260705192331.23150-1-include@grrlz.net>
Turn the documented register distinctness requirement into an error
at build time instead of silent corruption.
Signed-off-by: Bradley Morgan <include@grrlz.net>
---
arch/arm64/kernel/sleep.S | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/arm64/kernel/sleep.S b/arch/arm64/kernel/sleep.S
index f093cdf71be1..e112b8537f10 100644
--- a/arch/arm64/kernel/sleep.S
+++ b/arch/arm64/kernel/sleep.S
@@ -35,8 +35,22 @@
* Output register: dst
* Note: input and output registers must be disjoint register sets
(eg: a macro instance with mpidr = x1 and dst = x1 is invalid)
+ This is enforced at build time by the assertions below.
*/
+ .macro mpidr_hash_assert_distinct reg, regs:vararg
+ .irp r, \regs
+ .ifc \reg, \r
+ .error "compute_mpidr_hash: register arguments must be distinct"
+ .endif
+ .endr
+ .endm
+
.macro compute_mpidr_hash dst, rs0, rs1, rs2, rs3, mpidr, mask
+ /* \dst is written before any input is consumed */
+ mpidr_hash_assert_distinct \dst, \rs0, \rs1, \rs2, \rs3, \mpidr, \mask
+ /* \mpidr and \mask are clobbered while other inputs are still live */
+ mpidr_hash_assert_distinct \mpidr, \rs0, \rs1, \rs2, \rs3, \mask
+ mpidr_hash_assert_distinct \mask, \rs1, \rs2, \rs3
and \mpidr, \mpidr, \mask // mask out MPIDR bits
and \dst, \mpidr, #0xff // mask=aff0
lsr \dst ,\dst, \rs0 // dst=aff0>>rs0
--
2.53.0
next prev parent reply other threads:[~2026-07-05 19:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-05 19:23 [PATCH 0/2] arm64: sleep: two small compute_mpidr_hash cleanups Bradley Morgan
2026-07-05 19:23 ` Bradley Morgan [this message]
2026-07-05 19:23 ` [PATCH 2/2] arm64: sleep: dedup the sleep_save_stash slot lookup Bradley Morgan
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=20260705192331.23150-2-include@grrlz.net \
--to=include@grrlz.net \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=will@kernel.org \
/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