mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] tools/nolibc: add support for microblaze
@ 2026-12-02 17:20 Thomas Weißschuh
  2026-12-02 17:20 ` [PATCH 1/2] microblaze: Add a PetaLogix ML605 configuration snippet Thomas Weißschuh
  2026-12-02 17:20 ` [PATCH 2/2] tools/nolibc: add support for microblaze Thomas Weißschuh
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2026-12-02 17:20 UTC (permalink / raw)
  To: Michal Simek, Willy Tarreau; +Cc: linux-kernel, Thomas Weißschuh

Add support for microblaze to nolibc.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Thomas Weißschuh (2):
      microblaze: Add a PetaLogix ML605 configuration snippet
      tools/nolibc: add support for microblaze

 arch/microblaze/configs/petalogix-ml605.config |  12 ++
 tools/include/nolibc/Makefile                  |   1 +
 tools/include/nolibc/arch-microblaze.h         | 156 +++++++++++++++++++++++++
 tools/include/nolibc/arch.h                    |   2 +
 tools/testing/selftests/nolibc/Makefile.nolibc |   7 ++
 tools/testing/selftests/nolibc/run-tests.sh    |   3 +-
 6 files changed, 180 insertions(+), 1 deletion(-)
---
base-commit: 90c1d31dd9f1aa06759d39472c12ef00e11b6420
change-id: 20260429-nolibc-microblaze-2759f5f297fb

Best regards,
--  
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] microblaze: Add a PetaLogix ML605 configuration snippet
  2026-12-02 17:20 [PATCH 0/2] tools/nolibc: add support for microblaze Thomas Weißschuh
@ 2026-12-02 17:20 ` Thomas Weißschuh
  2026-12-02 17:20 ` [PATCH 2/2] tools/nolibc: add support for microblaze Thomas Weißschuh
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2026-12-02 17:20 UTC (permalink / raw)
  To: Michal Simek, Willy Tarreau; +Cc: linux-kernel, Thomas Weißschuh

On microblaze the kernel configuration needs to closely match the
hardware one, otherwise the kernel will not even boot.

Add a configuration which is bootable on QEMU's petalogix-ml605 machine.

Link: https://lore.kernel.org/all/5cd8df03-ad51-460c-9b20-3bf288831b5a@amd.com/
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 arch/microblaze/configs/petalogix-ml605.config | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/microblaze/configs/petalogix-ml605.config b/arch/microblaze/configs/petalogix-ml605.config
new file mode 100644
index 000000000000..e7550f16d24c
--- /dev/null
+++ b/arch/microblaze/configs/petalogix-ml605.config
@@ -0,0 +1,12 @@
+CONFIG_KERNEL_BASE_ADDR=0x50000000
+CONFIG_XILINX_MICROBLAZE0_FAMILY="virtex5"
+CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR=1
+CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR=1
+CONFIG_XILINX_MICROBLAZE0_USE_BARREL=1
+CONFIG_XILINX_MICROBLAZE0_USE_DIV=1
+CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL=2
+CONFIG_XILINX_MICROBLAZE0_USE_FPU=1
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_16550A_VARIANTS=y
+CONFIG_SERIAL_OF_PLATFORM=y

-- 
2.56.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] tools/nolibc: add support for microblaze
  2026-12-02 17:20 [PATCH 0/2] tools/nolibc: add support for microblaze Thomas Weißschuh
  2026-12-02 17:20 ` [PATCH 1/2] microblaze: Add a PetaLogix ML605 configuration snippet Thomas Weißschuh
@ 2026-12-02 17:20 ` Thomas Weißschuh
  2026-12-05 14:38   ` Willy Tarreau
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Weißschuh @ 2026-12-02 17:20 UTC (permalink / raw)
  To: Michal Simek, Willy Tarreau; +Cc: linux-kernel, Thomas Weißschuh

Add support for microblaze to nolibc.

QEMU system tests are skipped by default, as there is no clean way to
signal the shutdown to QEMU. CONFIG_MB_POWER_OFF_THROUGH_UNALIGNED_PC
works but generates coredumps and ugly output.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 tools/include/nolibc/Makefile                  |   1 +
 tools/include/nolibc/arch-microblaze.h         | 156 +++++++++++++++++++++++++
 tools/include/nolibc/arch.h                    |   2 +
 tools/testing/selftests/nolibc/Makefile.nolibc |   7 ++
 tools/testing/selftests/nolibc/run-tests.sh    |   3 +-
 5 files changed, 168 insertions(+), 1 deletion(-)

diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 0880be0f6ef5..fe2e7f5cbae4 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -24,6 +24,7 @@ architectures := \
 		hexagon \
 		loongarch \
 		m68k \
+		microblaze \
 		mips \
 		openrisc \
 		parisc \
diff --git a/tools/include/nolibc/arch-microblaze.h b/tools/include/nolibc/arch-microblaze.h
new file mode 100644
index 000000000000..54f96ba1b007
--- /dev/null
+++ b/tools/include/nolibc/arch-microblaze.h
@@ -0,0 +1,156 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * Microblaze specific definitions for NOLIBC
+ * Copyright (C) 2026 Thomas Weißschuh <linux@weissschuh.net>
+ */
+
+#ifndef _NOLIBC_ARCH_MICROBLAZE_H
+#define _NOLIBC_ARCH_MICROBLAZE_H
+
+#include "compiler.h"
+#include "crt.h"
+
+/*
+ * Syscalls for Microblaze:
+ *   - syscall number is passed in r12
+ *   - arguments are in r5, r6, r7, r8, r9, r10
+ *   - the system call is performed by calling brki r14,8
+ *   - syscall return value is in r3
+ */
+
+#define __nolibc_syscall0(num)                                                \
+({                                                                            \
+	register long _num __asm__ ("r12") = (num);                           \
+	register long _ret __asm__ ("r3");                                    \
+									      \
+	__asm__ volatile (                                                    \
+		"brki r14,8\n"                                                \
+		: "=r"(_ret)                                                  \
+		: "r"(_num)                                                   \
+		: "r4", "memory"                                              \
+	);                                                                    \
+	_ret;                                                                 \
+})
+
+#define __nolibc_syscall1(num, arg1)                                          \
+({                                                                            \
+	register long _num __asm__ ("r12") = (num);                           \
+	register long _ret __asm__ ("r3");                                    \
+	register long _arg1 __asm__ ("r5") = (long)(arg1);                    \
+									      \
+	__asm__ volatile (                                                    \
+		"brki r14,8\n"                                                \
+		: "=r"(_ret)                                                  \
+		: "r"(_num), "r"(_arg1)                                       \
+		: "r4", "memory"                                              \
+	);                                                                    \
+	_ret;                                                                 \
+})
+
+#define __nolibc_syscall2(num, arg1, arg2)                                    \
+({                                                                            \
+	register long _num __asm__ ("r12") = (num);                           \
+	register long _ret __asm__ ("r3");                                    \
+	register long _arg1 __asm__ ("r5") = (long)(arg1);                    \
+	register long _arg2 __asm__ ("r6") = (long)(arg2);                    \
+									      \
+	__asm__ volatile (                                                    \
+		"brki r14,8\n"                                                \
+		: "=r"(_ret)                                                  \
+		: "r"(_num), "r"(_arg1), "r"(_arg2)                           \
+		: "r4", "memory"                                              \
+	);                                                                    \
+	_ret;                                                                 \
+})
+
+#define __nolibc_syscall3(num, arg1, arg2, arg3)                              \
+({                                                                            \
+	register long _num __asm__ ("r12") = (num);                           \
+	register long _ret __asm__ ("r3");                                    \
+	register long _arg1 __asm__ ("r5") = (long)(arg1);                    \
+	register long _arg2 __asm__ ("r6") = (long)(arg2);                    \
+	register long _arg3 __asm__ ("r7") = (long)(arg3);                    \
+									      \
+	__asm__ volatile (                                                    \
+		"brki r14,8\n"                                                \
+		: "=r"(_ret)                                                  \
+		: "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3)               \
+		: "r4", "memory"                                              \
+	);                                                                    \
+	_ret;                                                                 \
+})
+
+#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4)                        \
+({                                                                            \
+	register long _num __asm__ ("r12") = (num);                           \
+	register long _ret __asm__ ("r3");                                    \
+	register long _arg1 __asm__ ("r5") = (long)(arg1);                    \
+	register long _arg2 __asm__ ("r6") = (long)(arg2);                    \
+	register long _arg3 __asm__ ("r7") = (long)(arg3);                    \
+	register long _arg4 __asm__ ("r8") = (long)(arg4);                    \
+									      \
+	__asm__ volatile (                                                    \
+		"brki r14,8\n"                                                \
+		: "=r"(_ret)                                                  \
+		: "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4)   \
+		: "r4", "memory"                                              \
+	);                                                                    \
+	_ret;                                                                 \
+})
+
+#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5)                  \
+({                                                                            \
+	register long _num __asm__ ("r12") = (num);                           \
+	register long _ret __asm__ ("r3");                                    \
+	register long _arg1 __asm__ ("r5") = (long)(arg1);                    \
+	register long _arg2 __asm__ ("r6") = (long)(arg2);                    \
+	register long _arg3 __asm__ ("r7") = (long)(arg3);                    \
+	register long _arg4 __asm__ ("r8") = (long)(arg4);                    \
+	register long _arg5 __asm__ ("r9") = (long)(arg5);                    \
+									      \
+	__asm__ volatile (                                                    \
+		"brki r14,8\n"                                                \
+		: "=r"(_ret)                                                  \
+		: "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4),  \
+		  "r"(_arg5)                                                  \
+		: "r4", "memory"                                              \
+	);                                                                    \
+	_ret;                                                                 \
+})
+
+#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6)            \
+({                                                                            \
+	register long _num __asm__ ("r12") = (num);                           \
+	register long _ret __asm__ ("r3");                                    \
+	register long _arg1 __asm__ ("r5") = (long)(arg1);                    \
+	register long _arg2 __asm__ ("r6") = (long)(arg2);                    \
+	register long _arg3 __asm__ ("r7") = (long)(arg3);                    \
+	register long _arg4 __asm__ ("r8") = (long)(arg4);                    \
+	register long _arg5 __asm__ ("r9") = (long)(arg5);                    \
+	register long _arg6 __asm__ ("r10") = (long)(arg6);                   \
+									      \
+	__asm__ volatile (                                                    \
+		"brki r14,8\n"                                                \
+		: "=r"(_ret)                                                  \
+		: "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4),  \
+		  "r"(_arg5), "r"(_arg6)                                      \
+		: "r4", "memory"                                              \
+	);                                                                    \
+	_ret;                                                                 \
+})
+
+#ifndef NOLIBC_NO_RUNTIME
+/* startup code */
+void __attribute__((weak,noreturn))
+__nolibc_entrypoint __nolibc_no_stack_protector
+_start(void)
+{
+	__asm__ volatile (
+		"addi r5, r1, 0\n"           /* save stack pointer to r5, as arg1 of _start_c */
+		"bri _start_c\n"             /* transfer to c runtime                         */
+	);
+	__nolibc_entrypoint_epilogue();
+}
+#endif /* NOLIBC_NO_RUNTIME */
+
+#endif /* _NOLIBC_ARCH_MICROBLAZE_H */
diff --git a/tools/include/nolibc/arch.h b/tools/include/nolibc/arch.h
index 79ed5900f2a7..de8cfac5113b 100644
--- a/tools/include/nolibc/arch.h
+++ b/tools/include/nolibc/arch.h
@@ -36,6 +36,8 @@
 #include "arch-alpha.h"
 #elif defined(__hexagon__)
 #include "arch-hexagon.h"
+#elif defined(__microblaze__)
+#include "arch-microblaze.h"
 #else
 #error Unsupported Architecture
 #endif
diff --git a/tools/testing/selftests/nolibc/Makefile.nolibc b/tools/testing/selftests/nolibc/Makefile.nolibc
index 529244356280..1f903057444a 100644
--- a/tools/testing/selftests/nolibc/Makefile.nolibc
+++ b/tools/testing/selftests/nolibc/Makefile.nolibc
@@ -84,6 +84,7 @@ IMAGE_loongarch  = arch/loongarch/boot/vmlinuz.efi
 IMAGE_sparc32    = arch/sparc/boot/image
 IMAGE_sparc64    = arch/sparc/boot/image
 IMAGE_sh4        = arch/sh/boot/zImage
+IMAGE_microblaze = arch/microblaze/boot/linux.bin
 IMAGE            = $(objtree)/$(or $(IMAGE_$(XARCH)),vmlinux)
 IMAGE_NAME       = $(notdir $(IMAGE))
 
@@ -105,6 +106,7 @@ DEFCONFIG_sparc64    = sparc64_defconfig
 DEFCONFIG_m68k       = virt_defconfig
 DEFCONFIG_sh4        = rts7751r2dplus_defconfig
 DEFCONFIG_openrisc   = virt_defconfig
+DEFCONFIG_microblaze = defconfig petalogix-ml605.config
 DEFCONFIG            = $(or $(DEFCONFIG_$(XARCH)),defconfig)
 
 EXTRACONFIG_x32       = -e CONFIG_X86_X32_ABI
@@ -115,6 +117,8 @@ EXTRACONFIG_m68k      = -e CONFIG_BLK_DEV_INITRD
 EXTRACONFIG_sh4       = -e CONFIG_BLK_DEV_INITRD -e CONFIG_CMDLINE_FROM_BOOTLOADER
 EXTRACONFIG_alpha     = -e CONFIG_BLK_DEV_INITRD
 EXTRACONFIG_parisc64  = -d CONFIG_COMPAT
+EXTRACONFIG_microblaze= -e CONFIG_BLK_DEV_INITRD -e CONFIG_NAMESPACES -d CONFIG_CMDLINE_BOOL \
+			-e CONFIG_MB_POWER_OFF_THROUGH_UNALIGNED_PC
 EXTRACONFIG           = $(EXTRACONFIG_$(XARCH))
 
 # optional tests to run (default = all)
@@ -142,6 +146,7 @@ QEMU_ARCH            = $(or $(QEMU_ARCH_$(XARCH)),$(XARCH))
 QEMU_ARCH_USER_ppc64le = ppc64le
 QEMU_ARCH_USER_mipsn32le = mipsn32el
 QEMU_ARCH_USER_mipsn32be = mipsn32
+QEMU_ARCH_USER_microblaze = microblazeel
 QEMU_ARCH_USER         = $(or $(QEMU_ARCH_USER_$(XARCH)),$(QEMU_ARCH))
 
 QEMU_BIOS_DIR = /usr/share/edk2/
@@ -180,6 +185,7 @@ QEMU_ARGS_openrisc   = -M virt -m 512M -append "console=ttyS0 panic=-1 $(TEST:%=
 QEMU_ARGS_parisc32   = -M B160L -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
 QEMU_ARGS_parisc64   = -M C3700 -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
 QEMU_ARGS_alpha      = -M clipper -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
+QEMU_ARGS_microblaze = -M petalogix-ml605 -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
 QEMU_ARGS            = -m 1G $(QEMU_ARGS_$(XARCH)) $(QEMU_ARGS_BIOS) $(QEMU_ARGS_EXTRA)
 
 # OUTPUT is only set when run from the main makefile, otherwise
@@ -213,6 +219,7 @@ CFLAGS_sparc32 = $(call cc-option,-m32) -mcpu=v8
 CFLAGS_sh4 = -ml -m4
 # github.com/llvm/llvm-project/issues/216765
 CFLAGS_hexagon = -fno-sanitize=undefined
+CFLAGS_microblaze = -mlittle-endian -mno-xl-soft-mul -mno-xl-soft-div -mxl-multiply-high
 ifeq ($(origin XARCH),command line)
 CFLAGS_XARCH = $(CFLAGS_$(XARCH))
 endif
diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/selftests/nolibc/run-tests.sh
index cc91b8656b20..30dc022b20b7 100755
--- a/tools/testing/selftests/nolibc/run-tests.sh
+++ b/tools/testing/selftests/nolibc/run-tests.sh
@@ -32,6 +32,7 @@ all_archs=(
 	parisc32 parisc64
 	alpha
 	hexagon
+	microblaze
 )
 archs="${all_archs[@]}"
 
@@ -221,7 +222,7 @@ test_arch() {
 		echo "Unsupported configuration"
 		return
 	fi
-	if [ -z "$llvm" -o "$test_mode" = "system" ] && [ "$arch" = "hexagon" ]; then
+	if [ -z "$llvm" -o "$test_mode" = "system" ] && [ "$arch" = "hexagon"  -o "$arch" = "microblaze" ]; then
 		echo "Unsupported configuration"
 		return
 	fi

-- 
2.56.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] tools/nolibc: add support for microblaze
  2026-12-02 17:20 ` [PATCH 2/2] tools/nolibc: add support for microblaze Thomas Weißschuh
@ 2026-12-05 14:38   ` Willy Tarreau
  0 siblings, 0 replies; 4+ messages in thread
From: Willy Tarreau @ 2026-12-05 14:38 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: Michal Simek, linux-kernel

Hi Thomas!

On Wed, Dec 02, 2026 at 06:20:32PM +0100, Thomas Weißschuh wrote:
> Add support for microblaze to nolibc.
> 
> QEMU system tests are skipped by default, as there is no clean way to
> signal the shutdown to QEMU. CONFIG_MB_POWER_OFF_THROUGH_UNALIGNED_PC
> works but generates coredumps and ugly output.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
>  tools/include/nolibc/Makefile                  |   1 +
>  tools/include/nolibc/arch-microblaze.h         | 156 +++++++++++++++++++++++++
>  tools/include/nolibc/arch.h                    |   2 +
>  tools/testing/selftests/nolibc/Makefile.nolibc |   7 ++
>  tools/testing/selftests/nolibc/run-tests.sh    |   3 +-
>  5 files changed, 168 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
> index 0880be0f6ef5..fe2e7f5cbae4 100644
> --- a/tools/include/nolibc/Makefile
> +++ b/tools/include/nolibc/Makefile
> @@ -24,6 +24,7 @@ architectures := \
>  		hexagon \
>  		loongarch \
>  		m68k \
> +		microblaze \
>  		mips \
>  		openrisc \
>  		parisc \
> diff --git a/tools/include/nolibc/arch-microblaze.h b/tools/include/nolibc/arch-microblaze.h
> new file mode 100644
> index 000000000000..54f96ba1b007
> --- /dev/null
> +++ b/tools/include/nolibc/arch-microblaze.h
> @@ -0,0 +1,156 @@
> +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
> +/*
> + * Microblaze specific definitions for NOLIBC
> + * Copyright (C) 2026 Thomas Weißschuh <linux@weissschuh.net>
> + */
> +
> +#ifndef _NOLIBC_ARCH_MICROBLAZE_H
> +#define _NOLIBC_ARCH_MICROBLAZE_H
> +
> +#include "compiler.h"
> +#include "crt.h"
> +
> +/*
> + * Syscalls for Microblaze:
> + *   - syscall number is passed in r12
> + *   - arguments are in r5, r6, r7, r8, r9, r10
> + *   - the system call is performed by calling brki r14,8
> + *   - syscall return value is in r3
> + */
> +
> +#define __nolibc_syscall0(num)                                                \
> +({                                                                            \
> +	register long _num __asm__ ("r12") = (num);                           \
> +	register long _ret __asm__ ("r3");                                    \
> +									      \
> +	__asm__ volatile (                                                    \
> +		"brki r14,8\n"                                                \
> +		: "=r"(_ret)                                                  \
> +		: "r"(_num)                                                   \
> +		: "r4", "memory"                                              \
> +	);                                                                    \
> +	_ret;                                                                 \
> +})
> +
> +#define __nolibc_syscall1(num, arg1)                                          \
> +({                                                                            \
> +	register long _num __asm__ ("r12") = (num);                           \
> +	register long _ret __asm__ ("r3");                                    \
> +	register long _arg1 __asm__ ("r5") = (long)(arg1);                    \
> +									      \
> +	__asm__ volatile (                                                    \
> +		"brki r14,8\n"                                                \
> +		: "=r"(_ret)                                                  \
> +		: "r"(_num), "r"(_arg1)                                       \
> +		: "r4", "memory"                                              \
> +	);                                                                    \
> +	_ret;                                                                 \
> +})
> +
> +#define __nolibc_syscall2(num, arg1, arg2)                                    \
> +({                                                                            \
> +	register long _num __asm__ ("r12") = (num);                           \
> +	register long _ret __asm__ ("r3");                                    \
> +	register long _arg1 __asm__ ("r5") = (long)(arg1);                    \
> +	register long _arg2 __asm__ ("r6") = (long)(arg2);                    \
> +									      \
> +	__asm__ volatile (                                                    \
> +		"brki r14,8\n"                                                \
> +		: "=r"(_ret)                                                  \
> +		: "r"(_num), "r"(_arg1), "r"(_arg2)                           \
> +		: "r4", "memory"                                              \
> +	);                                                                    \
> +	_ret;                                                                 \
> +})
> +
> +#define __nolibc_syscall3(num, arg1, arg2, arg3)                              \
> +({                                                                            \
> +	register long _num __asm__ ("r12") = (num);                           \
> +	register long _ret __asm__ ("r3");                                    \
> +	register long _arg1 __asm__ ("r5") = (long)(arg1);                    \
> +	register long _arg2 __asm__ ("r6") = (long)(arg2);                    \
> +	register long _arg3 __asm__ ("r7") = (long)(arg3);                    \
> +									      \
> +	__asm__ volatile (                                                    \
> +		"brki r14,8\n"                                                \
> +		: "=r"(_ret)                                                  \
> +		: "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3)               \
> +		: "r4", "memory"                                              \
> +	);                                                                    \
> +	_ret;                                                                 \
> +})
> +
> +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4)                        \
> +({                                                                            \
> +	register long _num __asm__ ("r12") = (num);                           \
> +	register long _ret __asm__ ("r3");                                    \
> +	register long _arg1 __asm__ ("r5") = (long)(arg1);                    \
> +	register long _arg2 __asm__ ("r6") = (long)(arg2);                    \
> +	register long _arg3 __asm__ ("r7") = (long)(arg3);                    \
> +	register long _arg4 __asm__ ("r8") = (long)(arg4);                    \
> +									      \
> +	__asm__ volatile (                                                    \
> +		"brki r14,8\n"                                                \
> +		: "=r"(_ret)                                                  \
> +		: "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4)   \
> +		: "r4", "memory"                                              \
> +	);                                                                    \
> +	_ret;                                                                 \
> +})
> +
> +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5)                  \
> +({                                                                            \
> +	register long _num __asm__ ("r12") = (num);                           \
> +	register long _ret __asm__ ("r3");                                    \
> +	register long _arg1 __asm__ ("r5") = (long)(arg1);                    \
> +	register long _arg2 __asm__ ("r6") = (long)(arg2);                    \
> +	register long _arg3 __asm__ ("r7") = (long)(arg3);                    \
> +	register long _arg4 __asm__ ("r8") = (long)(arg4);                    \
> +	register long _arg5 __asm__ ("r9") = (long)(arg5);                    \
> +									      \
> +	__asm__ volatile (                                                    \
> +		"brki r14,8\n"                                                \
> +		: "=r"(_ret)                                                  \
> +		: "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4),  \
> +		  "r"(_arg5)                                                  \
> +		: "r4", "memory"                                              \
> +	);                                                                    \
> +	_ret;                                                                 \
> +})
> +
> +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6)            \
> +({                                                                            \
> +	register long _num __asm__ ("r12") = (num);                           \
> +	register long _ret __asm__ ("r3");                                    \
> +	register long _arg1 __asm__ ("r5") = (long)(arg1);                    \
> +	register long _arg2 __asm__ ("r6") = (long)(arg2);                    \
> +	register long _arg3 __asm__ ("r7") = (long)(arg3);                    \
> +	register long _arg4 __asm__ ("r8") = (long)(arg4);                    \
> +	register long _arg5 __asm__ ("r9") = (long)(arg5);                    \
> +	register long _arg6 __asm__ ("r10") = (long)(arg6);                   \
> +									      \
> +	__asm__ volatile (                                                    \
> +		"brki r14,8\n"                                                \
> +		: "=r"(_ret)                                                  \
> +		: "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4),  \
> +		  "r"(_arg5), "r"(_arg6)                                      \
> +		: "r4", "memory"                                              \
> +	);                                                                    \
> +	_ret;                                                                 \
> +})
> +
> +#ifndef NOLIBC_NO_RUNTIME
> +/* startup code */
> +void __attribute__((weak,noreturn))
> +__nolibc_entrypoint __nolibc_no_stack_protector
> +_start(void)
> +{
> +	__asm__ volatile (
> +		"addi r5, r1, 0\n"           /* save stack pointer to r5, as arg1 of _start_c */
> +		"bri _start_c\n"             /* transfer to c runtime                         */
> +	);
> +	__nolibc_entrypoint_epilogue();
> +}
> +#endif /* NOLIBC_NO_RUNTIME */
> +
> +#endif /* _NOLIBC_ARCH_MICROBLAZE_H */
> diff --git a/tools/include/nolibc/arch.h b/tools/include/nolibc/arch.h
> index 79ed5900f2a7..de8cfac5113b 100644
> --- a/tools/include/nolibc/arch.h
> +++ b/tools/include/nolibc/arch.h
> @@ -36,6 +36,8 @@
>  #include "arch-alpha.h"
>  #elif defined(__hexagon__)
>  #include "arch-hexagon.h"
> +#elif defined(__microblaze__)
> +#include "arch-microblaze.h"
>  #else
>  #error Unsupported Architecture
>  #endif
> diff --git a/tools/testing/selftests/nolibc/Makefile.nolibc b/tools/testing/selftests/nolibc/Makefile.nolibc
> index 529244356280..1f903057444a 100644
> --- a/tools/testing/selftests/nolibc/Makefile.nolibc
> +++ b/tools/testing/selftests/nolibc/Makefile.nolibc
> @@ -84,6 +84,7 @@ IMAGE_loongarch  = arch/loongarch/boot/vmlinuz.efi
>  IMAGE_sparc32    = arch/sparc/boot/image
>  IMAGE_sparc64    = arch/sparc/boot/image
>  IMAGE_sh4        = arch/sh/boot/zImage
> +IMAGE_microblaze = arch/microblaze/boot/linux.bin
>  IMAGE            = $(objtree)/$(or $(IMAGE_$(XARCH)),vmlinux)
>  IMAGE_NAME       = $(notdir $(IMAGE))
>  
> @@ -105,6 +106,7 @@ DEFCONFIG_sparc64    = sparc64_defconfig
>  DEFCONFIG_m68k       = virt_defconfig
>  DEFCONFIG_sh4        = rts7751r2dplus_defconfig
>  DEFCONFIG_openrisc   = virt_defconfig
> +DEFCONFIG_microblaze = defconfig petalogix-ml605.config
>  DEFCONFIG            = $(or $(DEFCONFIG_$(XARCH)),defconfig)
>  
>  EXTRACONFIG_x32       = -e CONFIG_X86_X32_ABI
> @@ -115,6 +117,8 @@ EXTRACONFIG_m68k      = -e CONFIG_BLK_DEV_INITRD
>  EXTRACONFIG_sh4       = -e CONFIG_BLK_DEV_INITRD -e CONFIG_CMDLINE_FROM_BOOTLOADER
>  EXTRACONFIG_alpha     = -e CONFIG_BLK_DEV_INITRD
>  EXTRACONFIG_parisc64  = -d CONFIG_COMPAT
> +EXTRACONFIG_microblaze= -e CONFIG_BLK_DEV_INITRD -e CONFIG_NAMESPACES -d CONFIG_CMDLINE_BOOL \
> +			-e CONFIG_MB_POWER_OFF_THROUGH_UNALIGNED_PC
>  EXTRACONFIG           = $(EXTRACONFIG_$(XARCH))
>  
>  # optional tests to run (default = all)
> @@ -142,6 +146,7 @@ QEMU_ARCH            = $(or $(QEMU_ARCH_$(XARCH)),$(XARCH))
>  QEMU_ARCH_USER_ppc64le = ppc64le
>  QEMU_ARCH_USER_mipsn32le = mipsn32el
>  QEMU_ARCH_USER_mipsn32be = mipsn32
> +QEMU_ARCH_USER_microblaze = microblazeel
>  QEMU_ARCH_USER         = $(or $(QEMU_ARCH_USER_$(XARCH)),$(QEMU_ARCH))
>  
>  QEMU_BIOS_DIR = /usr/share/edk2/
> @@ -180,6 +185,7 @@ QEMU_ARGS_openrisc   = -M virt -m 512M -append "console=ttyS0 panic=-1 $(TEST:%=
>  QEMU_ARGS_parisc32   = -M B160L -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
>  QEMU_ARGS_parisc64   = -M C3700 -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
>  QEMU_ARGS_alpha      = -M clipper -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
> +QEMU_ARGS_microblaze = -M petalogix-ml605 -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
>  QEMU_ARGS            = -m 1G $(QEMU_ARGS_$(XARCH)) $(QEMU_ARGS_BIOS) $(QEMU_ARGS_EXTRA)
>  
>  # OUTPUT is only set when run from the main makefile, otherwise
> @@ -213,6 +219,7 @@ CFLAGS_sparc32 = $(call cc-option,-m32) -mcpu=v8
>  CFLAGS_sh4 = -ml -m4
>  # github.com/llvm/llvm-project/issues/216765
>  CFLAGS_hexagon = -fno-sanitize=undefined
> +CFLAGS_microblaze = -mlittle-endian -mno-xl-soft-mul -mno-xl-soft-div -mxl-multiply-high
>  ifeq ($(origin XARCH),command line)
>  CFLAGS_XARCH = $(CFLAGS_$(XARCH))
>  endif
> diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/selftests/nolibc/run-tests.sh
> index cc91b8656b20..30dc022b20b7 100755
> --- a/tools/testing/selftests/nolibc/run-tests.sh
> +++ b/tools/testing/selftests/nolibc/run-tests.sh
> @@ -32,6 +32,7 @@ all_archs=(
>  	parisc32 parisc64
>  	alpha
>  	hexagon
> +	microblaze
>  )
>  archs="${all_archs[@]}"
>  
> @@ -221,7 +222,7 @@ test_arch() {
>  		echo "Unsupported configuration"
>  		return
>  	fi
> -	if [ -z "$llvm" -o "$test_mode" = "system" ] && [ "$arch" = "hexagon" ]; then
> +	if [ -z "$llvm" -o "$test_mode" = "system" ] && [ "$arch" = "hexagon"  -o "$arch" = "microblaze" ]; then
>  		echo "Unsupported configuration"
>  		return
>  	fi

While I don't have any opinion on the microblaze-specific details, from
a nolibc perspective, this look good!

Acked-by: Willy Tarreau <w@1wt.eu>

Thanks!
Willy

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-05 14:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-02 17:20 [PATCH 0/2] tools/nolibc: add support for microblaze Thomas Weißschuh
2026-12-02 17:20 ` [PATCH 1/2] microblaze: Add a PetaLogix ML605 configuration snippet Thomas Weißschuh
2026-12-02 17:20 ` [PATCH 2/2] tools/nolibc: add support for microblaze Thomas Weißschuh
2026-12-05 14:38   ` Willy Tarreau

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®