From: Imre Kaloz <kaloz@kernel.org>
To: Ramin Moussavi <ramin.moussavi@yacoub.de>
Cc: Magnus Lindholm <linmag7@gmail.com>,
Andreas Larsson <andreas@gaisler.com>,
"David S . Miller" <davem@davemloft.net>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
Arnd Bergmann <arnd@arndb.de>,
sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] sparc32: emulate casa on V8 CPUs
Date: Thu, 15 Oct 2026 21:08:03 +0200 (CEST) [thread overview]
Message-ID: <2de8857e-a5ec-a1b3-cc4e-a201457e1a9b@kernel.org> (raw)
In-Reply-To: <20261015141508.3335785-1-ramin.moussavi@yacoub.de>
[-- Attachment #1: Type: text/plain, Size: 2142 bytes --]
Hi Ramin,
On Thu, 15 Oct 2026, Ramin Moussavi wrote:
> On Sun, Sep 27, 2026 at 02:58 AM Imre Kaloz wrote:
>> so a C library can use one casa for its 32-bit atomics on any V8 part.
>
> I sent a series covering part of the same ground, Magnus and Adrian
> pointed me here -- I had not seen yours, so we worked on the same
> problem in parallel:
> https://lore.kernel.org/sparclinux/20261015085545.3246951-1-ramin.moussavi@yacoub.de/
>
> Your casa emulation looks like a good approach to me. What I would
> still need is a way for a C library to find out whether the kernel
> has it: a library built for v8 needs to keep its own fallback for
> older kernels, and there casa is SIGILL. I see three ways a library
> could tell:
>
> - an AT_HWCAP bit, like HWCAP_SPARC_CASTRAP in Magnus' RFC but meaning
> "casa works, in hardware or emulated",
> - a system call it can probe for ENOSYS, like patch 4 of my series,
> - or trying casa once under a SIGILL handler at startup.
>
> I know glibc does not want arch-specific atomics: on v8 the compiler
> turns the atomic builtins into calls, and glibc would rather have
> libgcc implement those with casa. But libgcc then faces the same
> question, unless it simply requires a kernel with the emulation; and
> uClibc-ng in my case keeps a fallback for older kernels. So from the
> kernel side the question how a library can tell remains.
Thanks, glad the approach works for you too.
My own view is that moving a C library to casa means rebuilding it
anyway, and that build can simply require a kernel with the
emulation, as with any other new kernel feature a library starts to
depend on. On an older kernel it stops with SIGILL at the first
casa, which at least fails clearly. A library that wants to keep its
fallback can probe casa once under a SIGILL handler, and that works
on every kernel without new ABI. Whichever way you go, use ASI 0x0A:
it also runs natively on LEON parts that have casa.
Whether the kernel should offer an explicit way to tell is Andreas’
call, though. Andreas, if you’d like one, I’m happy to add whatever
you prefer, an AT_HWCAP bit or something else.
Thanks,
Imre
next prev parent reply other threads:[~2026-10-15 19:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 0:58 [PATCH 0/3] sparc32: SMP futexes, casa and idiv emulation Imre Kaloz
2026-09-27 0:58 ` [PATCH 1/3] sparc32: support futexes on SMP Imre Kaloz
2026-10-04 8:51 ` Magnus Lindholm
2026-09-27 0:58 ` [PATCH 2/3] sparc32: emulate casa on V8 CPUs Imre Kaloz
2026-10-04 9:02 ` Magnus Lindholm
2026-10-15 14:15 ` Ramin Moussavi
2026-10-15 14:32 ` Magnus Lindholm
2026-10-15 19:08 ` Imre Kaloz [this message]
2026-10-15 20:01 ` Ramin Moussavi
2026-09-27 0:58 ` [PATCH 3/3] sparc32: emulate integer divide taken as illegal_instruction Imre Kaloz
2026-09-27 21:25 ` Magnus Lindholm
2026-10-04 9:05 ` Magnus Lindholm
2026-09-27 21:42 ` [PATCH 0/3] sparc32: SMP futexes, casa and idiv emulation Magnus Lindholm
2026-10-04 10:04 ` Magnus Lindholm
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=2de8857e-a5ec-a1b3-cc4e-a201457e1a9b@kernel.org \
--to=kaloz@kernel.org \
--cc=andreas@gaisler.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linmag7@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ramin.moussavi@yacoub.de \
--cc=sparclinux@vger.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
all inboxes | Powered by JetHome®