From: Catalin Marinas <catalin.marinas@arm.com>
To: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Sascha Bischoff <sascha.bischoff@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Marc Zyngier <maz@kernel.org>
Subject: Re: [PATCH v2] arm64/sysreg: Fix GIC CDEOI instruction encoding
Date: Tue, 7 Oct 2025 16:06:53 +0100 [thread overview]
Message-ID: <aOUsjRkq4DTcLujW@arm.com> (raw)
In-Reply-To: <20251007102600.879337-1-lpieralisi@kernel.org>
On Tue, Oct 07, 2025 at 12:26:00PM +0200, Lorenzo Pieralisi wrote:
> The GIC CDEOI system instruction requires the Rt field to be set to 0b11111
> otherwise the instruction behaviour becomes CONSTRAINED UNPREDICTABLE.
>
> Currenly, its usage is encoded as a system register write, with a constant
> 0 value:
>
> write_sysreg_s(0, GICV5_OP_GIC_CDEOI)
>
> While compiling with GCC, the 0 constant value, through these asm
> constraints and modifiers ('x' modifier and 'Z' constraint combo):
>
> asm volatile(__msr_s(r, "%x0") : : "rZ" (__val));
>
> forces the compiler to issue the XZR register for the MSR operation (ie
> that corresponds to Rt == 0b11111) issuing the right instruction encoding.
>
> Unfortunately LLVM does not yet understand that modifier/constraint
> combo so it ends up issuing a different register from XZR for the MSR
> source, which in turns means that it encodes the GIC CDEOI instruction
> wrongly and the instruction behaviour becomes CONSTRAINED UNPREDICTABLE
> that we must prevent.
>
> Add a conditional to write_sysreg_s() macro that detects whether it
> is passed a constant 0 value and issues an MSR write with XZR as source
> register - explicitly doing what the asm modifier/constraint is meant to
> achieve through constraints/modifiers, fixing the LLVM compilation issue.
>
> Fixes: 7ec80fb3f025 ("irqchip/gic-v5: Add GICv5 PPI support")
> Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Acked-by: Marc Zyngier <maz@kernel.org>
> Cc: stable@vger.kernel.org
> Cc: Sascha Bischoff <sascha.bischoff@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Marc Zyngier <maz@kernel.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
(unless Will sends another pull request before -rc1, I'll pick this
patch shortly after)
next prev parent reply other threads:[~2025-10-07 15:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 10:26 [PATCH v2] arm64/sysreg: Fix GIC CDEOI instruction encoding Lorenzo Pieralisi
2025-10-07 15:06 ` Catalin Marinas [this message]
2025-10-08 8:55 ` Will Deacon
2025-10-17 17:29 ` Catalin Marinas
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=aOUsjRkq4DTcLujW@arm.com \
--to=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=sascha.bischoff@arm.com \
--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