Re: [PATCH] tools/nolibc: MIPS: fix clobbers of 'lo' and 'hi' registers on different ISAs
From: Thomas Weißschuh
Date: Tue Mar 17 2026 - 04:11:12 EST
On Sat, Mar 14, 2026 at 06:01:20PM +0000, Maciej W. Rozycki wrote:
> On Wed, 18 Feb 2026, Thomas Weißschuh wrote:
>
> > Earlier MIPS64 ISAs still provide the 'lo' and 'hi' special registers.
> > These are clobbered by system calls and need to be marked as such to
> > avoid miscompilations.
>
> Correct.
>
> > Also 32-bit ISAs from r6 on do not define the 'lo' and 'hi' registers.
>
> There's no MIPS ISA beyond R6 (nanoMIPS is a completely different ISA).
> Also MIPS64r6 is the same in this respect as MIPS32r6 is.
I'll reword this.
> > diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h
> > index a72506ceec6b..210bd907b51f 100644
> > --- a/tools/include/nolibc/arch-mips.h
> > +++ b/tools/include/nolibc/arch-mips.h
> > @@ -41,23 +41,44 @@
(...)
> #if __mips_isa_rev < 6
> #define _NOLIBC_SYSCALL_CLOBBER_HI "hi"
> #define _NOLIBC_SYSCALL_CLOBBER_LO "lo"
> #else
> #define _NOLIBC_SYSCALL_CLOBBER_HI "$0"
> #define _NOLIBC_SYSCALL_CLOBBER_LO "$0"
> #endif
Ack, will use this.
> and then used the macros rather than duplicating the clobber lists. Or
> you could reuse the approach taken with VDSO_SYSCALL_CLOBBERS, perhaps a
> bit messy, also when it comes to the name of the macro.
Reusing code from the core kernel in nolibc is problematic,
as nolibc is licensed more liberally.
Thomas