[PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64
Alice Ryhl
alice at ryhl.io
Sat Oct 21 05:50:39 PDT 2023
On 10/20/23 20:33, Boqun Feng wrote:
> 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.
For what it's worth, I have some experience with big endian Rust in
userspace, and it generally works without issues. I would expect that it
doesn't need any special support beyond setting the target architecture
properly.
Alice
More information about the linux-arm-kernel
mailing list