From: Marc Zyngier <maz@kernel.org>
To: Marek Vasut <marek.vasut@mailbox.org>
Cc: linux-arm-kernel@lists.infradead.org,
Anshuman Khandual <anshuman.khandual@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Ryan Roberts <ryan.roberts@arm.com>,
Will Deacon <will@kernel.org>,
Yicong Yang <yangyicong@hisilicon.com>,
linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] arm64: guard AMU register access with ARM64_HAS_AMU_EXTN
Date: Thu, 23 Oct 2025 15:19:22 +0100 [thread overview]
Message-ID: <87y0p13dlh.wl-maz@kernel.org> (raw)
In-Reply-To: <24c8da41-37db-4e69-b9aa-e33b2154acb0@mailbox.org>
On Wed, 22 Oct 2025 16:29:55 +0100,
Marek Vasut <marek.vasut@mailbox.org> wrote:
>
> On 10/22/25 5:02 PM, Marc Zyngier wrote:
>
> Hello Marc,
>
> >>> We ensure that the AMU is available in the macro itself by checking
> >>> for ID_AA64PFR0_EL1.AMU. If the AMu isn't present on this CPU, we skip
> >>> the offending sysreg access. This is similar to what we do for the
> >>> PMU.
> >>>
> >>> Does your HW advertise an AMU, but doesn't actually have one?
> >>
> >> The hardware does have AMU, but it is currently blocked in old TFA
> >> version and access to this AMU register here causes a fault. That's
> >> why I have to disable ARM64_HAS_AMU_EXTN until the TFA is updated and
> >> the AMU access is made available on this hardware. But even if I do
> >> disable ARM64_HAS_AMU_EXTN=n , I get a fault.
> >
> > Well, I would tend to say that you are trying to update the wrong
> > piece of SW here. Crashing kernels should be a good incentive for the
> > board manufacturer to update their firmware pronto, specially when we
> > are talking of code that has been in the tree for over 5 years...
>
> I do agree with this, and the update already exists. The upstream TFA
> MR for this platform also has this fixed.
>
> >> This patch is mainly meant to prevent a surprise in case someone does
> >> set ARM64_HAS_AMU_EXTN=n , and the system still faults on AMU register
> >> access.
> >
> > But that doesn't really fix anything if you have a buggy firmware,
> > because you can't tell which CPUs have been correctly configured, and
> > which have not.
>
> I also agree.
>
> > I also don't really get why this hack works for you,
> > because the feature will be set as soon as one CPU advertises the
> > feature.
>
> For this old firmware, during development, ARM64_HAS_AMU_EXTN is
> disabled in kernel config to avoid triggering the AMU faults.
>
> Except right now, I still trigger the AMU faults even with
> ARM64_HAS_AMU_EXTN=n , which I think should not happen ?
ARM64_HAS_AMU_EXTN is a *capability*, not a configuration.
CONFIG_ARM64_AMU_EXTN is the configuration. I have the feeling you're
mixing the two.
Irrespective of the configuration, we access the AMU registers
depending on the what is advertised, because we *must* make these
registers inaccessible from EL0, no matter what.
> > In any case, this sort of terminally broken stuff should be handled as
> > an IDreg override, for which we have a whole infrastructure already.
> > There are countless examples in the tree already for similar purposes.
>
> I would much rather not support the old firmware for this new platform
> in upstream and pollute the kernel with unnecessary workarounds.
>
> I would much rather be able to disable ARM64_HAS_AMU_EXTN in kernel
> config for the old devices with old firmware, without triggering the
> faults ... and say that everything which is going to be upstream will
> always use new firmware that has proper working AMU support.
No, that's the wrong approach. If you leave the AMU accessible to EL0,
you're leaking data to userspace, and that's pretty wrong, no matter
how you look at it.
I also think your hack works by pure luck, because at the point where
your CPUs are booting, the alternatives are yet not in place (the
kernel patching happens much later). In short, this breaks
*everything*.
As I indicated before, you have two options:
- either you update your firmware and leave the kernel alone
- or you implement the workaround as ID register override so that you
*must* pass something on the kernel command line to boot, and by
then accept that you will leak critical timing information to
userspace.
Any other option, including guarding the macro with a config option is
*not* acceptable.
Thanks,
M.
--
Jazz isn't dead. It just smells funny.
next prev parent reply other threads:[~2025-10-23 14:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 13:35 [PATCH] arm64: guard AMU register access with ARM64_HAS_AMU_EXTN Marek Vasut
2025-10-22 14:20 ` Marc Zyngier
2025-10-22 14:33 ` Marek Vasut
2025-10-22 15:02 ` Marc Zyngier
2025-10-22 15:19 ` Catalin Marinas
2025-10-22 15:31 ` Marek Vasut
2025-10-22 15:29 ` Marek Vasut
2025-10-23 14:19 ` Marc Zyngier [this message]
2025-10-23 15:58 ` Marek Vasut
2025-10-24 9:27 ` Marc Zyngier
2025-12-30 2:00 ` Marek Vasut
2025-10-23 12:01 ` Yicong Yang
2025-10-23 13:16 ` Marek Vasut
2025-10-23 14:21 ` Marc Zyngier
2025-10-23 14:44 ` Yicong Yang
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=87y0p13dlh.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=anshuman.khandual@arm.com \
--cc=catalin.marinas@arm.com \
--cc=geert+renesas@glider.be \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=marek.vasut@mailbox.org \
--cc=ryan.roberts@arm.com \
--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).