tools/include/nolibc/arch-mips.h | 117 +++++++++++++++++++++------- tools/testing/selftests/nolibc/Makefile | 28 ++++++- tools/testing/selftests/nolibc/run-tests.sh | 2 +- 3 files changed, 118 insertions(+), 29 deletions(-)
Introduce support for the N32 and N64 ABIs. As preparation, the
entrypoint is first simplified significantly. Thanks to Maciej for all
the valuable information.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Changes in v2:
- Clean up entrypoint first
- Annotate #endifs
- Link to v1: https://lore.kernel.org/r/20250212-nolibc-mips-n32-v1-1-6892e58d1321@weissschuh.net
---
Thomas Weißschuh (4):
tools/nolibc: MIPS: drop $gp setup
tools/nolibc: MIPS: drop manual stack pointer alignment
tools/nolibc: MIPS: drop noreorder option
tools/nolibc: MIPS: add support for N64 and N32 ABIs
tools/include/nolibc/arch-mips.h | 117 +++++++++++++++++++++-------
tools/testing/selftests/nolibc/Makefile | 28 ++++++-
tools/testing/selftests/nolibc/run-tests.sh | 2 +-
3 files changed, 118 insertions(+), 29 deletions(-)
---
base-commit: 9c812b01f13d37410ea103e00bc47e5e0f6d2bad
change-id: 20231105-nolibc-mips-n32-234901bd910d
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
On 2025-02-25 18:02:34 [+0100], Thomas Weißschuh wrote: > Introduce support for the N32 and N64 ABIs. As preparation, the > entrypoint is first simplified significantly. Thanks to Maciej for all > the valuable information. > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Tested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> [ICT Loongson-3] mips32le works as-is. For mips64le I had to s/-march=mips64r6/-march=mips64r2 to match the ABI. Which makes me wonder: Why do do we need to pass -march here and can't rely on toolchain defaults? Sebastian
On 2025-03-26 21:54:34+0100, Sebastian Andrzej Siewior wrote: > On 2025-02-25 18:02:34 [+0100], Thomas Weißschuh wrote: > > Introduce support for the N32 and N64 ABIs. As preparation, the > > entrypoint is first simplified significantly. Thanks to Maciej for all > > the valuable information. > > > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > Tested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> [ICT Loongson-3] Thanks! > mips32le works as-is. > For mips64le I had to s/-march=mips64r6/-march=mips64r2 to match the > ABI. Which makes me wonder: Why do do we need to pass -march here and > can't rely on toolchain defaults? The goal here is to have an as-wide-as-possible test matrix for nolibc-test, which will mostly be running on QEMU anyways. Also we need to run the correct QEMU user variant; by fixing the architecture this is easy to do. Thomas
On 2025-03-26 22:51:54 [+0100], Thomas Weißschuh wrote: > > mips32le works as-is. > > For mips64le I had to s/-march=mips64r6/-march=mips64r2 to match the > > ABI. Which makes me wonder: Why do do we need to pass -march here and > > can't rely on toolchain defaults? > > The goal here is to have an as-wide-as-possible test matrix for > nolibc-test, which will mostly be running on QEMU anyways. > Also we need to run the correct QEMU user variant; by fixing the > architecture this is easy to do. I would prefer to make distro users as in real hardware first class citizen and not QEMU users. If you run qemu you can specify the ABI anyway. > Thomas Sebastian
On 2025-03-26 23:04:30+0100, Sebastian Andrzej Siewior wrote:
> On 2025-03-26 22:51:54 [+0100], Thomas Weißschuh wrote:
> > > mips32le works as-is.
> > > For mips64le I had to s/-march=mips64r6/-march=mips64r2 to match the
> > > ABI. Which makes me wonder: Why do do we need to pass -march here and
> > > can't rely on toolchain defaults?
> >
> > The goal here is to have an as-wide-as-possible test matrix for
> > nolibc-test, which will mostly be running on QEMU anyways.
> > Also we need to run the correct QEMU user variant; by fixing the
> > architecture this is easy to do.
>
> I would prefer to make distro users as in real hardware first class
> citizen and not QEMU users. If you run qemu you can specify the ABI
> anyway.
Does the following work for you when running kust "make nolibc-test"?
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 58bcbbd029bc..27d5ceb20858 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -174,10 +174,13 @@ CFLAGS_s390x = -m64
CFLAGS_s390 = -m31
CFLAGS_mips32le = -EL -mabi=32 -fPIC
CFLAGS_mips32be = -EB -mabi=32
+ifeq ($(origin XARCH),command line)
+CFLAGS_ARCH = $(CFLAGS_$(XARCH))
+endif
CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all))
CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra \
$(call cc-option,-fno-stack-protector) $(call cc-option,-Wmissing-prototypes) \
- $(CFLAGS_$(XARCH)) $(CFLAGS_STACKPROTECTOR) $(CFLAGS_EXTRA)
+ $(CFLAGS_ARCH) $(CFLAGS_STACKPROTECTOR) $(CFLAGS_EXTRA)
LDFLAGS :=
LIBGCC := -lgcc
@@ -232,7 +235,7 @@ all: run
sysroot: sysroot/$(ARCH)/include
-sysroot/$(ARCH)/include: | defconfig
+sysroot/$(ARCH)/include:
$(Q)rm -rf sysroot/$(ARCH) sysroot/sysroot
$(QUIET_MKDIR)mkdir -p sysroot
$(Q)$(MAKE) -C $(srctree) outputmakefile
On 2025-03-29 10:51:47 [+0100], Thomas Weißschuh wrote: > > Does the following work for you when running kust "make nolibc-test"? I had to manually apply this on top of b4/nolibc-mips-n32. The resulting make produced the native 64bit binary. Sebastian
Hi Thomas! On Tue, Feb 25, 2025 at 06:02:34PM +0100, Thomas Weißschuh wrote: > Introduce support for the N32 and N64 ABIs. As preparation, the > entrypoint is first simplified significantly. Thanks to Maciej for all > the valuable information. > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > --- > Changes in v2: > - Clean up entrypoint first > - Annotate #endifs > - Link to v1: https://lore.kernel.org/r/20250212-nolibc-mips-n32-v1-1-6892e58d1321@weissschuh.net OK I tested this series on my glinet (MIPS 24Kc, XARCH=mips32be) and it worked fine, confirming that the stack alignments were not needed and that the cleanup is quite welcome! Tested-by: Willy Tarreau <w@1wt.eu> Willy
On Sat, 1 Mar 2025, Willy Tarreau wrote: > > Introduce support for the N32 and N64 ABIs. As preparation, the > > entrypoint is first simplified significantly. Thanks to Maciej for all > > the valuable information. > > > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > --- > > Changes in v2: > > - Clean up entrypoint first > > - Annotate #endifs > > - Link to v1: https://lore.kernel.org/r/20250212-nolibc-mips-n32-v1-1-6892e58d1321@weissschuh.net > > OK I tested this series on my glinet (MIPS 24Kc, XARCH=mips32be) and > it worked fine, confirming that the stack alignments were not needed > and that the cleanup is quite welcome! I do hope it can wait two weeks until I'm back from my holiday. I mean to double-check the code visually and verify it with my R3000 and R4000 hardware (the latter for n64/n32 too), both of which are less forgiving when it comes to instruction scheduling (I can check with a 74Kf too). Maciej
On Sat, Mar 01, 2025 at 03:47:52PM +0000, Maciej W. Rozycki wrote: > On Sat, 1 Mar 2025, Willy Tarreau wrote: > > > > Introduce support for the N32 and N64 ABIs. As preparation, the > > > entrypoint is first simplified significantly. Thanks to Maciej for all > > > the valuable information. > > > > > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > > --- > > > Changes in v2: > > > - Clean up entrypoint first > > > - Annotate #endifs > > > - Link to v1: https://lore.kernel.org/r/20250212-nolibc-mips-n32-v1-1-6892e58d1321@weissschuh.net > > > > OK I tested this series on my glinet (MIPS 24Kc, XARCH=mips32be) and > > it worked fine, confirming that the stack alignments were not needed > > and that the cleanup is quite welcome! > > I do hope it can wait two weeks until I'm back from my holiday. I mean > to double-check the code visually and verify it with my R3000 and R4000 > hardware (the latter for n64/n32 too), both of which are less forgiving > when it comes to instruction scheduling (I can check with a 74Kf too). Oh that would be great, thank you Maciej! Willy
On 2025-03-01 15:47:52+0000, Maciej W. Rozycki wrote: > On Sat, 1 Mar 2025, Willy Tarreau wrote: > > > > Introduce support for the N32 and N64 ABIs. As preparation, the > > > entrypoint is first simplified significantly. Thanks to Maciej for all > > > the valuable information. > > > > > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > > --- > > > Changes in v2: > > > - Clean up entrypoint first > > > - Annotate #endifs > > > - Link to v1: https://lore.kernel.org/r/20250212-nolibc-mips-n32-v1-1-6892e58d1321@weissschuh.net > > > > OK I tested this series on my glinet (MIPS 24Kc, XARCH=mips32be) and > > it worked fine, confirming that the stack alignments were not needed > > and that the cleanup is quite welcome! > > I do hope it can wait two weeks until I'm back from my holiday. Absolutely. > I mean > to double-check the code visually and verify it with my R3000 and R4000 > hardware (the latter for n64/n32 too), both of which are less forgiving > when it comes to instruction scheduling (I can check with a 74Kf too). Your testing and feedback is very valuable, I'm happy to wait for it. Thanks, Thomas
© 2016 - 2026 Red Hat, Inc.