[PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64
Boqun Feng
boqun.feng at gmail.com
Fri Oct 20 11:33:10 PDT 2023
On Fri, Oct 20, 2023 at 07:21:08PM +0200, Andrew Lunn wrote:
> > +``arm64`` Maintained Little Endian only.
>
> This question is just out of curiosity, not the patchset itself.
>
> What is missing to make big endian work?
>
FWIW, I tried the following:
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 8784284988e5..b697c2d7da68 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -227,7 +227,7 @@ config ARM64
select HAVE_FUNCTION_ARG_ACCESS_API
select MMU_GATHER_RCU_TABLE_FREE
select HAVE_RSEQ
- select HAVE_RUST if CPU_LITTLE_ENDIAN
+ select HAVE_RUST
select HAVE_STACKPROTECTOR
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_KPROBES
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 4562a8173e90..4621f1e00e06 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -41,7 +41,11 @@ KBUILD_CFLAGS += -mgeneral-regs-only \
KBUILD_CFLAGS += $(call cc-disable-warning, psabi)
KBUILD_AFLAGS += $(compat_vdso)
+ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
+KBUILD_RUSTFLAGS += --target aarch64_be-unknown-linux-gnu -C target-feature="-neon"
+else
KBUILD_RUSTFLAGS += --target aarch64-unknown-none -C target-feature="-neon"
+endif
KBUILD_CFLAGS += $(call cc-option,-mabi=lp64)
KBUILD_AFLAGS += $(call cc-option,-mabi=lp64)
and ran the following kunit command (it will run a few tests in a qemu
emulated VM):
./tools/testing/kunit/kunit.py run --make_options LLVM=1 --arch arm64 --kconfig_add CONFIG_RUST=y --kconfig_add CONFIG_CPU_BIG_ENDIAN=y
The kernel was built successfully, and all Rust related tests passed.
Of course this doesn't mean a lot, we still need people with deep
Rust compiler knowledge to confirm whether the support is completed or
not. But I think if people want to do experiments, the tool is there.
P.S. An unrelated topic: I found a few clk related tests (in
drivers/clk/clk-gate_test.c IIUC) don't pass (mostly due to that the
expected values don't handle big endian), a sample failure output:
[11:13:26] # clk_gate_test_enable: EXPECTATION FAILED at drivers/clk/clk-gate_test.c:169
[11:13:26] Expected enable_val == ctx->fake_reg, but
[11:13:26] enable_val == 32 (0x20)
[11:13:26] ctx->fake_reg == 536870912 (0x20000000)
[11:13:26] clk_unregister: unregistering prepared clock: test_gate
[11:13:26] clk_unregister: unregistering prepared clock: test_parent
[11:13:26] [FAILED] clk_gate_test_enable
(Cc clk folks)
Regards,
Boqun
> Network developers have expressed an interesting in testing Rust code
> on big endian systems, since the code should work on both endians. It
> might be easier to get an ARM board running big endian than get access
> to an S390x machine.
>
> Andrew
More information about the linux-arm-kernel
mailing list