public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: Richard Earnshaw <Richard.Earnshaw@foss.arm.com>,
	Victor Do Nascimento <victor.donascimento@arm.com>,
	gcc-patches@gcc.gnu.org
Cc: kyrylo.tkachov@arm.com, richard.sandiford@arm.com,
	Richard.Earnshaw@arm.com
Subject: Re: [PATCH v2 2/2] libatomic: Enable LSE128 128-bit atomics for armv9.4-a
Date: Fri, 8 Dec 2023 14:51:15 +0000	[thread overview]
Message-ID: <ZXMtYxk8mFUL9YFv@arm.com> (raw)
In-Reply-To: <2e582d48-fcde-4e60-9024-5184cd6792a3@foss.arm.com>

The 11/29/2023 15:15, Richard Earnshaw wrote:
> On 13/11/2023 11:37, Victor Do Nascimento wrote:
> > +/* LSE128 atomic support encoded in ID_AA64ISAR0_EL1.Atomic,
> > +   bits[23:20].  The expected value is 0b0011.  Check that.  */
> > +#define HAS_LSE128() ({						\
> > +  unsigned long val;						\
> > +  asm volatile ("mrs %0, ID_AA64ISAR0_EL1" : "=r" (val));	\
> > +  (val & 0xf00000) >= 0x300000;					\
> > +    })
> > +
> 
> The pseudo-code for this register reads:
> 
> if PSTATE.EL == EL0 then
>   if IsFeatureImplemented(FEAT_IDST) then
>     if EL2Enabled() && HCR_EL2.TGE == '1' then
>       AArch64.SystemAccessTrap(EL2, 0x18);
>     else
>       AArch64.SystemAccessTrap(EL1, 0x18);
>   else
>     UNDEFINED;
> ...
> 
> So this instruction may result in SIGILL if run on cores without FEAT_IDST.
> SystemAccessTrap just punts the problem up to the kernel or hypervisor as
> well.

yes, HWCAP_CPUID has to be checked to see if
linux traps and emulates the mrs for userspace.

> I think we need a hwcap bit to work this out, which is the preferred way on

yes, use hwcap instead of id reg (hwcap2 is
passed to aarch64 ifuncs or __getauxval works)

> Linux anyway.  Something like this? :) https://lore.kernel.org/linux-arm-kernel/20231003124544.858804-2-joey.gouly@arm.com/T/

note that there was no linux release since this
got added.

we can add the hwcap values tentatively, but
there is a risk of revert on the kernel side
(which means libatomic vs linux abi break) so
i would only commit the patch into gcc after
a linux release is tagged.

      reply	other threads:[~2023-12-08 14:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13 11:37 [PATCH v2 0/2] Libatomic: Add LSE128 atomics support for AArch64 Victor Do Nascimento
2023-11-13 11:37 ` [PATCH v2 1/2] libatomic: atomic_16.S: Improve ENTRY, END and ALIAS macro interface Victor Do Nascimento
2023-11-29 13:44   ` Richard Earnshaw
2023-11-13 11:37 ` [PATCH v2 2/2] libatomic: Enable LSE128 128-bit atomics for armv9.4-a Victor Do Nascimento
2023-11-29 15:15   ` Richard Earnshaw
2023-12-08 14:51     ` Szabolcs Nagy [this message]

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=ZXMtYxk8mFUL9YFv@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=Richard.Earnshaw@foss.arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kyrylo.tkachov@arm.com \
    --cc=richard.sandiford@arm.com \
    --cc=victor.donascimento@arm.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 read-only IMAP folder(s) and NNTP newsgroup(s).