Re: [PATCH 2/3] sparc32: emulate casa on V8 CPUs

From: Magnus Lindholm

Date: Thu Oct 15 2026 - 10:38:13 EST


Hi Ramin,

On Thu, Oct 15, 2026 at 4:15 PM Ramin Moussavi <ramin.moussavi@xxxxxxxxx> wrote:
>
> Hi Imre,
>
> 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@xxxxxxxxx/
>
> 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.
>

I've put together a small patch series that lets me build glibc and install a
gentoo-based userland on my sparcstation. The glibc fix is based on
Imres kernel fix. Not sure if glibc ever wants to carry those patches.
or if I'm even on the right track, but at least it works. I think Imre
also has some *libc project for sparc32 user land?


Regards

Magnus