From: D Scott Phillips <scott@os.amperecomputing.com>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
James Clark <james.clark@linaro.org>,
James Morse <james.morse@arm.com>,
Joey Gouly <joey.gouly@arm.com>,
Kevin Brodsky <kevin.brodsky@arm.com>,
Marc Zyngier <maz@kernel.org>, Mark Brown <broonie@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
"Rob Herring (Arm)" <robh@kernel.org>,
Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
Shiqi Liu <shiqiliu@hust.edu.cn>, Will Deacon <will@kernel.org>,
Yicong Yang <yangyicong@hisilicon.com>,
kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] arm64: errata: Work around AmpereOne's erratum AC03_CPU_36
Date: Tue, 15 Apr 2025 10:30:36 -0700 [thread overview]
Message-ID: <86cyddgwn7.fsf@scott-ph-mail.amperecomputing.com> (raw)
In-Reply-To: <Z_6Te1TjMqyXChvQ@linux.dev>
Oliver Upton <oliver.upton@linux.dev> writes:
> On Tue, Apr 15, 2025 at 08:47:10AM -0700, D Scott Phillips wrote:
>> AC03_CPU_36 can cause asynchronous exceptions to be routed to the wrong
>> exception level if an async exception coincides with an update to the
>> controls for the target exception level in HCR_EL2. On affected
>> machines, always do writes to HCR_EL2 with async exceptions blocked.
>>
>> Signed-off-by: D Scott Phillips <scott@os.amperecomputing.com>
>> ---
>> arch/arm64/Kconfig | 17 +++++++++++++++++
>> arch/arm64/include/asm/sysreg.h | 18 ++++++++++++++++--
>> arch/arm64/kernel/cpu_errata.c | 14 ++++++++++++++
>> arch/arm64/tools/cpucaps | 1 +
>> 4 files changed, 48 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index a182295e6f08b..e5fd87446a3b8 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -445,6 +445,23 @@ menu "Kernel Features"
>>
>> menu "ARM errata workarounds via the alternatives framework"
>>
>> +config AMPERE_ERRATUM_AC03_CPU_36
>> + bool "AmpereOne: AC03_CPU_36: CPU can take an invalid exception, if an asynchronous exception to EL2 occurs while EL2 software is changing the EL2 exception controls."
>> + default y
>> + help
>> + This option adds an alternative code sequence to work around Ampere
>> + errata AC03_CPU_36 on AmpereOne.
>> +
>> + If an async exception happens at the same time as an update to the
>> + controls for the target EL for async exceptions, an exception can be
>> + delivered to the wrong EL. For example, an EL may be routed from EL2
>> + to EL1.
>> +
>> + The workaround masks all asynchronous exception types when writing
>> + to HCR_EL2.
>> +
>> + If unsure, say Y.
>> +
>> config AMPERE_ERRATUM_AC03_CPU_38
>> bool "AmpereOne: AC03_CPU_38: Certain bits in the Virtualization Translation Control Register and Translation Control Registers do not follow RES0 semantics"
>> default y
>> diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
>> index 2639d3633073d..e7781f7e7f7a7 100644
>> --- a/arch/arm64/include/asm/sysreg.h
>> +++ b/arch/arm64/include/asm/sysreg.h
>> @@ -1136,14 +1136,28 @@
>> __val; \
>> })
>>
>> +#define __sysreg_is_hcr_el2(r) \
>> + (__builtin_strcmp("hcr_el2", __stringify(r)) == 0)
>
> This looks fragile. What about:
>
> write_sysreg(hcr, HCR_EL2);
>
> or:
>
> write_sysreg_s(hcr, SYS_HCR_EL2);
I had also thought about changing the users of write_sysreg(..hcr_el2)
to some new function write_hcr_el2() or something, but I guess that
would have the same fragility. Any suggestions on a better way? Trying
harder with the string stuff, or do something totally else?
next prev parent reply other threads:[~2025-04-15 17:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 15:47 [PATCH 1/2] arm64: errata: Work around AmpereOne's erratum AC03_CPU_36 D Scott Phillips
2025-04-15 15:47 ` [PATCH 2/2] arm64: errata: Work around AmpereOne's erratum AC04_CPU_23 D Scott Phillips
2025-04-15 17:06 ` Oliver Upton
2025-04-15 22:13 ` D Scott Phillips
2025-04-16 0:29 ` Oliver Upton
2025-04-16 23:05 ` D Scott Phillips
2025-04-16 7:11 ` Marc Zyngier
2025-04-16 23:06 ` D Scott Phillips
2025-04-15 18:38 ` Marc Zyngier
2025-04-15 17:12 ` [PATCH 1/2] arm64: errata: Work around AmpereOne's erratum AC03_CPU_36 Oliver Upton
2025-04-15 17:30 ` D Scott Phillips [this message]
2025-04-15 18:12 ` Oliver Upton
2025-04-15 18:17 ` D Scott Phillips
2025-04-16 7:19 ` Marc Zyngier
2025-04-16 23:14 ` D Scott Phillips
2025-04-25 2:02 ` D Scott Phillips
2025-04-27 12:21 ` Marc Zyngier
2025-04-28 16:35 ` D Scott Phillips
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=86cyddgwn7.fsf@scott-ph-mail.amperecomputing.com \
--to=scott@os.amperecomputing.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=james.clark@linaro.org \
--cc=james.morse@arm.com \
--cc=joey.gouly@arm.com \
--cc=kevin.brodsky@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=robh@kernel.org \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shiqiliu@hust.edu.cn \
--cc=will@kernel.org \
--cc=yangyicong@hisilicon.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;
as well as URLs for NNTP newsgroup(s).