* [PATCH v4 0/2] Rust enablement for AArch64 @ 2023-10-20 15:50 Jamie Cunliffe 2023-10-20 15:50 ` [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets Jamie Cunliffe ` (2 more replies) 0 siblings, 3 replies; 41+ messages in thread From: Jamie Cunliffe @ 2023-10-20 15:50 UTC (permalink / raw) To: linux-arm-kernel, rust-for-linux Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew Enable Rust support for the AArch64 architecture. Since the v3 this has been refactored to split up the x86 Makefile changes. Updated the x86-64 conditionals as suggested by Boqun and addressed the formatting issues Miguel raised. Jamie Cunliffe (2): rust: Refactor the build target to allow the use of builtin targets arm64: rust: Enable Rust support for AArch64 Documentation/rust/arch-support.rst | 1 + Makefile | 1 - arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 4 ++++ arch/x86/Makefile | 1 + rust/Makefile | 6 +++++- scripts/Makefile | 4 +++- scripts/generate_rust_target.rs | 4 +++- 8 files changed, 18 insertions(+), 4 deletions(-) -- 2.30.2 ^ permalink raw reply [flat|nested] 41+ messages in thread
* [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2023-10-20 15:50 [PATCH v4 0/2] Rust enablement for AArch64 Jamie Cunliffe @ 2023-10-20 15:50 ` Jamie Cunliffe 2023-10-22 10:55 ` Catalin Marinas ` (3 more replies) 2023-10-20 15:50 ` [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 Jamie Cunliffe 2024-02-09 17:38 ` [PATCH v4 0/2] Rust enablement " Catalin Marinas 2 siblings, 4 replies; 41+ messages in thread From: Jamie Cunliffe @ 2023-10-20 15:50 UTC (permalink / raw) To: linux-arm-kernel, rust-for-linux Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew Eventually we want all architectures to be using the target as defined by rustc. However currently some architectures can't do that and are using the target.json specification. This puts in place the foundation to allow the use of the builtin target definition or a target.json specification. Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> --- Makefile | 1 - arch/x86/Makefile | 1 + rust/Makefile | 5 ++++- scripts/Makefile | 4 +++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 88ebf6547964..23100f193da3 100644 --- a/Makefile +++ b/Makefile @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_RUSTFLAGS := $(rust_common_flags) \ - --target=$(objtree)/scripts/target.json \ -Cpanic=abort -Cembed-bitcode=n -Clto=n \ -Cforce-unwind-tables=n -Ccodegen-units=1 \ -Csymbol-mangling-version=v0 \ diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 5bfe5caaa444..0f339d4abd40 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -68,6 +68,7 @@ export BITS # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 # KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 ifeq ($(CONFIG_X86_KERNEL_IBT),y) diff --git a/rust/Makefile b/rust/Makefile index 87958e864be0..8d75a6ffe951 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 $(obj)/core.o: private skip_flags = -Dunreachable_pub $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) $(obj)/core.o: private rustc_target_flags = $(core-cfgs) -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE $(call if_changed_dep,rustc_library) +ifdef CONFIG_X86_64 +$(obj)/core.o: scripts/target.json +endif $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE diff --git a/scripts/Makefile b/scripts/Makefile index 576cf64be667..c85d130a4125 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen -always-$(CONFIG_RUST) += target.json +ifdef CONFIG_X86_64 +always-$(CONFIG_RUST) += target.json filechk_rust_target = $< < include/config/auto.conf $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE $(call filechk,rust_target) +endif hostprogs += generate_rust_target generate_rust_target-rust := y -- 2.30.2 ^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2023-10-20 15:50 ` [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets Jamie Cunliffe @ 2023-10-22 10:55 ` Catalin Marinas 2023-10-22 11:07 ` Ingo Molnar 2024-01-22 9:17 ` Trevor Gross ` (2 subsequent siblings) 3 siblings, 1 reply; 41+ messages in thread From: Catalin Marinas @ 2023-10-22 10:55 UTC (permalink / raw) To: Jamie Cunliffe Cc: linux-arm-kernel, rust-for-linux, Miguel Ojeda, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin On Fri, Oct 20, 2023 at 04:50:55PM +0100, Jamie Cunliffe wrote: > Eventually we want all architectures to be using the target as defined > by rustc. However currently some architectures can't do that and are > using the target.json specification. This puts in place the foundation > to allow the use of the builtin target definition or a target.json > specification. > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > --- > Makefile | 1 - > arch/x86/Makefile | 1 + > rust/Makefile | 5 ++++- > scripts/Makefile | 4 +++- > 4 files changed, 8 insertions(+), 3 deletions(-) Adding the x86 maintainers - no functional change for x86, any objection to this patch going in via the arm64 tree (part of the two-patch series enabling Rust for arm64)? Thanks. (keeping the rest of the patch below for your reference) > diff --git a/Makefile b/Makefile > index 88ebf6547964..23100f193da3 100644 > --- a/Makefile > +++ b/Makefile > @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing > > KBUILD_CPPFLAGS := -D__KERNEL__ > KBUILD_RUSTFLAGS := $(rust_common_flags) \ > - --target=$(objtree)/scripts/target.json \ > -Cpanic=abort -Cembed-bitcode=n -Clto=n \ > -Cforce-unwind-tables=n -Ccodegen-units=1 \ > -Csymbol-mangling-version=v0 \ > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > index 5bfe5caaa444..0f339d4abd40 100644 > --- a/arch/x86/Makefile > +++ b/arch/x86/Makefile > @@ -68,6 +68,7 @@ export BITS > # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 > # > KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx > +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json > KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 > > ifeq ($(CONFIG_X86_KERNEL_IBT),y) > diff --git a/rust/Makefile b/rust/Makefile > index 87958e864be0..8d75a6ffe951 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 > $(obj)/core.o: private skip_flags = -Dunreachable_pub > $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) > $(obj)/core.o: private rustc_target_flags = $(core-cfgs) > -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE > +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE > $(call if_changed_dep,rustc_library) > +ifdef CONFIG_X86_64 > +$(obj)/core.o: scripts/target.json > +endif > > $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' > $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE > diff --git a/scripts/Makefile b/scripts/Makefile > index 576cf64be667..c85d130a4125 100644 > --- a/scripts/Makefile > +++ b/scripts/Makefile > @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file > hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen > -always-$(CONFIG_RUST) += target.json > > +ifdef CONFIG_X86_64 > +always-$(CONFIG_RUST) += target.json > filechk_rust_target = $< < include/config/auto.conf > > $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE > $(call filechk,rust_target) > +endif > > hostprogs += generate_rust_target > generate_rust_target-rust := y > -- > 2.30.2 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2023-10-22 10:55 ` Catalin Marinas @ 2023-10-22 11:07 ` Ingo Molnar 2023-10-31 0:24 ` Trevor Gross 0 siblings, 1 reply; 41+ messages in thread From: Ingo Molnar @ 2023-10-22 11:07 UTC (permalink / raw) To: Catalin Marinas Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Masahiro Yamada * Catalin Marinas <catalin.marinas@arm.com> wrote: > On Fri, Oct 20, 2023 at 04:50:55PM +0100, Jamie Cunliffe wrote: > > Eventually we want all architectures to be using the target as defined > > by rustc. However currently some architectures can't do that and are > > using the target.json specification. This puts in place the foundation > > to allow the use of the builtin target definition or a target.json > > specification. > > > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > > --- > > Makefile | 1 - > > arch/x86/Makefile | 1 + > > rust/Makefile | 5 ++++- > > scripts/Makefile | 4 +++- > > 4 files changed, 8 insertions(+), 3 deletions(-) > > Adding the x86 maintainers - no functional change for x86, any objection > to this patch going in via the arm64 tree (part of the two-patch series > enabling Rust for arm64)? > > Thanks. > > (keeping the rest of the patch below for your reference) If Masahiro Yamada (kbuild maintainer, Cc:-ed) is fine with it, then it will be OK to me too. Thanks, Ingo ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2023-10-22 11:07 ` Ingo Molnar @ 2023-10-31 0:24 ` Trevor Gross 2023-10-31 11:58 ` Catalin Marinas 0 siblings, 1 reply; 41+ messages in thread From: Trevor Gross @ 2023-10-31 0:24 UTC (permalink / raw) To: Ingo Molnar, Catalin Marinas Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Masahiro Yamada On Sun, Oct 22, 2023 at 7:14 AM Ingo Molnar <mingo@kernel.org> wrote: > > > * Catalin Marinas <catalin.marinas@arm.com> wrote: > > > > Adding the x86 maintainers - no functional change for x86, any objection > > to this patch going in via the arm64 tree (part of the two-patch series > > enabling Rust for arm64)? > > > > Thanks. > > > > (keeping the rest of the patch below for your reference) > > If Masahiro Yamada (kbuild maintainer, Cc:-ed) is fine with it, > then it will be OK to me too. > > Thanks, > > Ingo > I don't think this has been picked up yet. Is it only waiting on Masahiro 's ack or is a new version expected? - Trevor ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2023-10-31 0:24 ` Trevor Gross @ 2023-10-31 11:58 ` Catalin Marinas 2023-10-31 19:01 ` Trevor Gross 2023-12-12 16:47 ` Will Deacon 0 siblings, 2 replies; 41+ messages in thread From: Catalin Marinas @ 2023-10-31 11:58 UTC (permalink / raw) To: Trevor Gross Cc: Ingo Molnar, Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Masahiro Yamada On Mon, Oct 30, 2023 at 08:24:39PM -0400, Trevor Gross wrote: > On Sun, Oct 22, 2023 at 7:14 AM Ingo Molnar <mingo@kernel.org> wrote: > > * Catalin Marinas <catalin.marinas@arm.com> wrote: > > > Adding the x86 maintainers - no functional change for x86, any objection > > > to this patch going in via the arm64 tree (part of the two-patch series > > > enabling Rust for arm64)? > > > > > > Thanks. > > > > > > (keeping the rest of the patch below for your reference) > > > > If Masahiro Yamada (kbuild maintainer, Cc:-ed) is fine with it, > > then it will be OK to me too. [...] > I don't think this has been picked up yet. Is it only waiting on > Masahiro 's ack or is a new version expected? I'd say Masahiro's ack only. However, it's probably too late for 6.7 now, the merging window is already open and maintainers tend to pick stuff up in the weeks before. -- Catalin ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2023-10-31 11:58 ` Catalin Marinas @ 2023-10-31 19:01 ` Trevor Gross 2023-12-12 16:47 ` Will Deacon 1 sibling, 0 replies; 41+ messages in thread From: Trevor Gross @ 2023-10-31 19:01 UTC (permalink / raw) To: Catalin Marinas Cc: Ingo Molnar, Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Masahiro Yamada On Tue, Oct 31, 2023 at 7:58 AM Catalin Marinas <catalin.marinas@arm.com> wrote: > I'd say Masahiro's ack only. However, it's probably too late for 6.7 > now, the merging window is already open and maintainers tend to pick > stuff up in the weeks before. Right, thanks for confirming. I was unsure whether the BE discussion changed anything, but that could likely come separately. - Trevor ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2023-10-31 11:58 ` Catalin Marinas 2023-10-31 19:01 ` Trevor Gross @ 2023-12-12 16:47 ` Will Deacon 1 sibling, 0 replies; 41+ messages in thread From: Will Deacon @ 2023-12-12 16:47 UTC (permalink / raw) To: Catalin Marinas, Masahiro Yamada Cc: Trevor Gross, Ingo Molnar, Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, steve.capper, Asahi Lina, boqun.feng, andrew, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin On Tue, Oct 31, 2023 at 11:58:03AM +0000, Catalin Marinas wrote: > On Mon, Oct 30, 2023 at 08:24:39PM -0400, Trevor Gross wrote: > > On Sun, Oct 22, 2023 at 7:14 AM Ingo Molnar <mingo@kernel.org> wrote: > > > * Catalin Marinas <catalin.marinas@arm.com> wrote: > > > > Adding the x86 maintainers - no functional change for x86, any objection > > > > to this patch going in via the arm64 tree (part of the two-patch series > > > > enabling Rust for arm64)? > > > > > > > > Thanks. > > > > > > > > (keeping the rest of the patch below for your reference) > > > > > > If Masahiro Yamada (kbuild maintainer, Cc:-ed) is fine with it, > > > then it will be OK to me too. > [...] > > I don't think this has been picked up yet. Is it only waiting on > > Masahiro 's ack or is a new version expected? > > I'd say Masahiro's ack only. However, it's probably too late for 6.7 > now, the merging window is already open and maintainers tend to pick > stuff up in the weeks before. Masahiro -- please can we have your Ack on this so that we can take it via the arm64 tree? Thanks, Will ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2023-10-20 15:50 ` [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets Jamie Cunliffe 2023-10-22 10:55 ` Catalin Marinas @ 2024-01-22 9:17 ` Trevor Gross 2024-01-25 3:19 ` WANG Rui 2024-01-22 9:29 ` Alice Ryhl 2024-01-24 9:12 ` Masahiro Yamada 3 siblings, 1 reply; 41+ messages in thread From: Trevor Gross @ 2024-01-22 9:17 UTC (permalink / raw) To: Jamie Cunliffe Cc: linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew, Huacai Chen, loongarch, Masahiro Yamada, linux-kbuild On Fri, Oct 20, 2023 at 10:59 AM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote: > > Eventually we want all architectures to be using the target as defined > by rustc. However currently some architectures can't do that and are > using the target.json specification. This puts in place the foundation > to allow the use of the builtin target definition or a target.json > specification. > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > --- > Makefile | 1 - > arch/x86/Makefile | 1 + > rust/Makefile | 5 ++++- > scripts/Makefile | 4 +++- > 4 files changed, 8 insertions(+), 3 deletions(-) Adding LoongArch maintainers - this patch will need a small update to arch/loongarch/Makefile similar to the change in arch/x86/Makefile (included below), since that support is now in-tree and uses generate_rust_target [1]. Also a very minor conflict in docs at patch 2/2. I believe this patchset is still waiting on an ack from the kbuild team. Series at [2] for reference. Thanks, Trevor [1]: https://lore.kernel.org/rust-for-linux/20240108032117.215171-1-wangrui@loongson.cn/ [2]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ > diff --git a/Makefile b/Makefile > index 88ebf6547964..23100f193da3 100644 > --- a/Makefile > +++ b/Makefile > @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing > > KBUILD_CPPFLAGS := -D__KERNEL__ > KBUILD_RUSTFLAGS := $(rust_common_flags) \ > - --target=$(objtree)/scripts/target.json \ > -Cpanic=abort -Cembed-bitcode=n -Clto=n \ > -Cforce-unwind-tables=n -Ccodegen-units=1 \ > -Csymbol-mangling-version=v0 \ > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > index 5bfe5caaa444..0f339d4abd40 100644 > --- a/arch/x86/Makefile > +++ b/arch/x86/Makefile > @@ -68,6 +68,7 @@ export BITS > # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 > # > KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx > +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json > KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 > > ifeq ($(CONFIG_X86_KERNEL_IBT),y) > diff --git a/rust/Makefile b/rust/Makefile > index 87958e864be0..8d75a6ffe951 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 > $(obj)/core.o: private skip_flags = -Dunreachable_pub > $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) > $(obj)/core.o: private rustc_target_flags = $(core-cfgs) > -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE > +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE > $(call if_changed_dep,rustc_library) > +ifdef CONFIG_X86_64 > +$(obj)/core.o: scripts/target.json > +endif > > $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' > $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE > diff --git a/scripts/Makefile b/scripts/Makefile > index 576cf64be667..c85d130a4125 100644 > --- a/scripts/Makefile > +++ b/scripts/Makefile > @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file > hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen > -always-$(CONFIG_RUST) += target.json > > +ifdef CONFIG_X86_64 > +always-$(CONFIG_RUST) += target.json > filechk_rust_target = $< < include/config/auto.conf > > $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE > $(call filechk,rust_target) > +endif > > hostprogs += generate_rust_target > generate_rust_target-rust := y > -- > 2.30.2 > > ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2024-01-22 9:17 ` Trevor Gross @ 2024-01-25 3:19 ` WANG Rui 2024-01-26 19:37 ` Masahiro Yamada 0 siblings, 1 reply; 41+ messages in thread From: WANG Rui @ 2024-01-25 3:19 UTC (permalink / raw) To: Trevor Gross Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew, Huacai Chen, loongarch, Masahiro Yamada, linux-kbuild Hello, On Mon, Jan 22, 2024 at 5:17 PM Trevor Gross <tmgross@umich.edu> wrote: > > On Fri, Oct 20, 2023 at 10:59 AM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote: > > > > Eventually we want all architectures to be using the target as defined > > by rustc. However currently some architectures can't do that and are > > using the target.json specification. This puts in place the foundation > > to allow the use of the builtin target definition or a target.json > > specification. > > > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > > --- > > Makefile | 1 - > > arch/x86/Makefile | 1 + > > rust/Makefile | 5 ++++- > > scripts/Makefile | 4 +++- > > 4 files changed, 8 insertions(+), 3 deletions(-) > > Adding LoongArch maintainers - this patch will need a small update to > arch/loongarch/Makefile similar to the change in arch/x86/Makefile > (included below), since that support is now in-tree and uses > generate_rust_target [1]. Also a very minor conflict in docs at patch > 2/2. > > I believe this patchset is still waiting on an ack from the kbuild > team. Series at [2] for reference. > > Thanks, > Trevor > > [1]: https://lore.kernel.org/rust-for-linux/20240108032117.215171-1-wangrui@loongson.cn/ > [2]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ I can confirm that the fix patch [2], based on patch [1], is suitable for LoongArch. LoongArch encounters no issues when using the built-in `loongarch64-unknown-none-softfloat` target. Once patch [1] is merged into the mainline, I'll send a patch to switch to using the built-in target. Thanks, Rui [1]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ [2]: https://github.com/heiher/linux/commit/c504d83a6edd963e2ba58ec538e3f06da78b187e.patch > > > diff --git a/Makefile b/Makefile > > index 88ebf6547964..23100f193da3 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing > > > > KBUILD_CPPFLAGS := -D__KERNEL__ > > KBUILD_RUSTFLAGS := $(rust_common_flags) \ > > - --target=$(objtree)/scripts/target.json \ > > -Cpanic=abort -Cembed-bitcode=n -Clto=n \ > > -Cforce-unwind-tables=n -Ccodegen-units=1 \ > > -Csymbol-mangling-version=v0 \ > > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > > index 5bfe5caaa444..0f339d4abd40 100644 > > --- a/arch/x86/Makefile > > +++ b/arch/x86/Makefile > > @@ -68,6 +68,7 @@ export BITS > > # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 > > # > > KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx > > +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json > > KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 > > > > ifeq ($(CONFIG_X86_KERNEL_IBT),y) > > diff --git a/rust/Makefile b/rust/Makefile > > index 87958e864be0..8d75a6ffe951 100644 > > --- a/rust/Makefile > > +++ b/rust/Makefile > > @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 > > $(obj)/core.o: private skip_flags = -Dunreachable_pub > > $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) > > $(obj)/core.o: private rustc_target_flags = $(core-cfgs) > > -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE > > +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE > > $(call if_changed_dep,rustc_library) > > +ifdef CONFIG_X86_64 > > +$(obj)/core.o: scripts/target.json > > +endif > > > > $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' > > $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE > > diff --git a/scripts/Makefile b/scripts/Makefile > > index 576cf64be667..c85d130a4125 100644 > > --- a/scripts/Makefile > > +++ b/scripts/Makefile > > @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file > > hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert > > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder > > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen > > -always-$(CONFIG_RUST) += target.json > > > > +ifdef CONFIG_X86_64 > > +always-$(CONFIG_RUST) += target.json > > filechk_rust_target = $< < include/config/auto.conf > > > > $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE > > $(call filechk,rust_target) > > +endif > > > > hostprogs += generate_rust_target > > generate_rust_target-rust := y > > -- > > 2.30.2 > > > > > ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2024-01-25 3:19 ` WANG Rui @ 2024-01-26 19:37 ` Masahiro Yamada 2024-01-27 5:08 ` WANG Rui 0 siblings, 1 reply; 41+ messages in thread From: Masahiro Yamada @ 2024-01-26 19:37 UTC (permalink / raw) To: WANG Rui Cc: Trevor Gross, Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew, Huacai Chen, loongarch, linux-kbuild On Thu, Jan 25, 2024 at 12:20 PM WANG Rui <wangrui@loongson.cn> wrote: > > Hello, > > On Mon, Jan 22, 2024 at 5:17 PM Trevor Gross <tmgross@umich.edu> wrote: > > > > On Fri, Oct 20, 2023 at 10:59 AM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote: > > > > > > Eventually we want all architectures to be using the target as defined > > > by rustc. However currently some architectures can't do that and are > > > using the target.json specification. This puts in place the foundation > > > to allow the use of the builtin target definition or a target.json > > > specification. > > > > > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > > > --- > > > Makefile | 1 - > > > arch/x86/Makefile | 1 + > > > rust/Makefile | 5 ++++- > > > scripts/Makefile | 4 +++- > > > 4 files changed, 8 insertions(+), 3 deletions(-) > > > > Adding LoongArch maintainers - this patch will need a small update to > > arch/loongarch/Makefile similar to the change in arch/x86/Makefile > > (included below), since that support is now in-tree and uses > > generate_rust_target [1]. Also a very minor conflict in docs at patch > > 2/2. > > > > I believe this patchset is still waiting on an ack from the kbuild > > team. Series at [2] for reference. > > > > Thanks, > > Trevor > > > > [1]: https://lore.kernel.org/rust-for-linux/20240108032117.215171-1-wangrui@loongson.cn/ > > [2]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ > > I can confirm that the fix patch [2], based on patch [1], is suitable > for LoongArch. LoongArch encounters no issues when using the built-in > `loongarch64-unknown-none-softfloat` target. Once patch [1] is merged > into the mainline, I'll send a patch to switch to using the built-in > target. But, [1] and [2] must be squashed together. Otherwise, [1] is changing the behavior of loongach, while the commit description does not mention it. > Thanks, > Rui > > [1]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ > [2]: https://github.com/heiher/linux/commit/c504d83a6edd963e2ba58ec538e3f06da78b187e.patch > > > > > > diff --git a/Makefile b/Makefile > > > index 88ebf6547964..23100f193da3 100644 > > > --- a/Makefile > > > +++ b/Makefile > > > @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing > > > > > > KBUILD_CPPFLAGS := -D__KERNEL__ > > > KBUILD_RUSTFLAGS := $(rust_common_flags) \ > > > - --target=$(objtree)/scripts/target.json \ > > > -Cpanic=abort -Cembed-bitcode=n -Clto=n \ > > > -Cforce-unwind-tables=n -Ccodegen-units=1 \ > > > -Csymbol-mangling-version=v0 \ > > > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > > > index 5bfe5caaa444..0f339d4abd40 100644 > > > --- a/arch/x86/Makefile > > > +++ b/arch/x86/Makefile > > > @@ -68,6 +68,7 @@ export BITS > > > # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 > > > # > > > KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx > > > +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json > > > KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 > > > > > > ifeq ($(CONFIG_X86_KERNEL_IBT),y) > > > diff --git a/rust/Makefile b/rust/Makefile > > > index 87958e864be0..8d75a6ffe951 100644 > > > --- a/rust/Makefile > > > +++ b/rust/Makefile > > > @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 > > > $(obj)/core.o: private skip_flags = -Dunreachable_pub > > > $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) > > > $(obj)/core.o: private rustc_target_flags = $(core-cfgs) > > > -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE > > > +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE > > > $(call if_changed_dep,rustc_library) > > > +ifdef CONFIG_X86_64 > > > +$(obj)/core.o: scripts/target.json > > > +endif > > > > > > $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' > > > $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE > > > diff --git a/scripts/Makefile b/scripts/Makefile > > > index 576cf64be667..c85d130a4125 100644 > > > --- a/scripts/Makefile > > > +++ b/scripts/Makefile > > > @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file > > > hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert > > > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder > > > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen > > > -always-$(CONFIG_RUST) += target.json > > > > > > +ifdef CONFIG_X86_64 > > > +always-$(CONFIG_RUST) += target.json > > > filechk_rust_target = $< < include/config/auto.conf > > > > > > $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE > > > $(call filechk,rust_target) > > > +endif > > > > > > hostprogs += generate_rust_target > > > generate_rust_target-rust := y > > > -- > > > 2.30.2 > > > > > > > > > > -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2024-01-26 19:37 ` Masahiro Yamada @ 2024-01-27 5:08 ` WANG Rui 2024-01-27 17:31 ` Miguel Ojeda 0 siblings, 1 reply; 41+ messages in thread From: WANG Rui @ 2024-01-27 5:08 UTC (permalink / raw) To: Masahiro Yamada Cc: Trevor Gross, Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew, Huacai Chen, loongarch, linux-kbuild On Sat, Jan 27, 2024 at 3:38 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > On Thu, Jan 25, 2024 at 12:20 PM WANG Rui <wangrui@loongson.cn> wrote: > > > > Hello, > > > > On Mon, Jan 22, 2024 at 5:17 PM Trevor Gross <tmgross@umich.edu> wrote: > > > > > > On Fri, Oct 20, 2023 at 10:59 AM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote: > > > > > > > > Eventually we want all architectures to be using the target as defined > > > > by rustc. However currently some architectures can't do that and are > > > > using the target.json specification. This puts in place the foundation > > > > to allow the use of the builtin target definition or a target.json > > > > specification. > > > > > > > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > > > > --- > > > > Makefile | 1 - > > > > arch/x86/Makefile | 1 + > > > > rust/Makefile | 5 ++++- > > > > scripts/Makefile | 4 +++- > > > > 4 files changed, 8 insertions(+), 3 deletions(-) > > > > > > Adding LoongArch maintainers - this patch will need a small update to > > > arch/loongarch/Makefile similar to the change in arch/x86/Makefile > > > (included below), since that support is now in-tree and uses > > > generate_rust_target [1]. Also a very minor conflict in docs at patch > > > 2/2. > > > > > > I believe this patchset is still waiting on an ack from the kbuild > > > team. Series at [2] for reference. > > > > > > Thanks, > > > Trevor > > > > > > [1]: https://lore.kernel.org/rust-for-linux/20240108032117.215171-1-wangrui@loongson.cn/ > > > [2]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ > > > > I can confirm that the fix patch [2], based on patch [1], is suitable > > for LoongArch. LoongArch encounters no issues when using the built-in > > `loongarch64-unknown-none-softfloat` target. Once patch [1] is merged > > into the mainline, I'll send a patch to switch to using the built-in > > target. > > But, [1] and [2] must be squashed together. > Otherwise, [1] is changing the behavior of loongach, > while the commit description does not mention it. I agree. It would be great if Jamie could squash them together. Thanks, Rui > > > > > > Thanks, > > Rui > > > > [1]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ > > [2]: https://github.com/heiher/linux/commit/c504d83a6edd963e2ba58ec538e3f06da78b187e.patch > > > > > > > > > diff --git a/Makefile b/Makefile > > > > index 88ebf6547964..23100f193da3 100644 > > > > --- a/Makefile > > > > +++ b/Makefile > > > > @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing > > > > > > > > KBUILD_CPPFLAGS := -D__KERNEL__ > > > > KBUILD_RUSTFLAGS := $(rust_common_flags) \ > > > > - --target=$(objtree)/scripts/target.json \ > > > > -Cpanic=abort -Cembed-bitcode=n -Clto=n \ > > > > -Cforce-unwind-tables=n -Ccodegen-units=1 \ > > > > -Csymbol-mangling-version=v0 \ > > > > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > > > > index 5bfe5caaa444..0f339d4abd40 100644 > > > > --- a/arch/x86/Makefile > > > > +++ b/arch/x86/Makefile > > > > @@ -68,6 +68,7 @@ export BITS > > > > # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 > > > > # > > > > KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx > > > > +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json > > > > KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 > > > > > > > > ifeq ($(CONFIG_X86_KERNEL_IBT),y) > > > > diff --git a/rust/Makefile b/rust/Makefile > > > > index 87958e864be0..8d75a6ffe951 100644 > > > > --- a/rust/Makefile > > > > +++ b/rust/Makefile > > > > @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 > > > > $(obj)/core.o: private skip_flags = -Dunreachable_pub > > > > $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) > > > > $(obj)/core.o: private rustc_target_flags = $(core-cfgs) > > > > -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE > > > > +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE > > > > $(call if_changed_dep,rustc_library) > > > > +ifdef CONFIG_X86_64 > > > > +$(obj)/core.o: scripts/target.json > > > > +endif > > > > > > > > $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' > > > > $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE > > > > diff --git a/scripts/Makefile b/scripts/Makefile > > > > index 576cf64be667..c85d130a4125 100644 > > > > --- a/scripts/Makefile > > > > +++ b/scripts/Makefile > > > > @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file > > > > hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert > > > > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder > > > > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen > > > > -always-$(CONFIG_RUST) += target.json > > > > > > > > +ifdef CONFIG_X86_64 > > > > +always-$(CONFIG_RUST) += target.json > > > > filechk_rust_target = $< < include/config/auto.conf > > > > > > > > $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE > > > > $(call filechk,rust_target) > > > > +endif > > > > > > > > hostprogs += generate_rust_target > > > > generate_rust_target-rust := y > > > > -- > > > > 2.30.2 > > > > > > > > > > > > > > > > > > -- > Best Regards > Masahiro Yamada > ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2024-01-27 5:08 ` WANG Rui @ 2024-01-27 17:31 ` Miguel Ojeda 0 siblings, 0 replies; 41+ messages in thread From: Miguel Ojeda @ 2024-01-27 17:31 UTC (permalink / raw) To: WANG Rui, Catalin Marinas Cc: Masahiro Yamada, Trevor Gross, Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew, Huacai Chen, loongarch, linux-kbuild On Sat, Jan 27, 2024 at 6:08 AM WANG Rui <wangrui@loongson.cn> wrote: > > I agree. It would be great if Jamie could squash them together. Either that or perhaps Catalin could do it at apply time with your Co-developed-by and/or Huacai's Acked-by? I could also take if needed. Thanks Masahiro & Rui! Cheers, Miguel ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2023-10-20 15:50 ` [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets Jamie Cunliffe 2023-10-22 10:55 ` Catalin Marinas 2024-01-22 9:17 ` Trevor Gross @ 2024-01-22 9:29 ` Alice Ryhl 2024-01-24 9:12 ` Masahiro Yamada 3 siblings, 0 replies; 41+ messages in thread From: Alice Ryhl @ 2024-01-22 9:29 UTC (permalink / raw) To: jamie.cunliffe Cc: andrew, boqun.feng, catalin.marinas, lina, linux-arm-kernel, ojeda, rust-for-linux, steve.capper, will, Alice Ryhl Jamie Cunliffe <Jamie.Cunliffe@arm.com> writes: > Eventually we want all architectures to be using the target as defined > by rustc. However currently some architectures can't do that and are > using the target.json specification. This puts in place the foundation > to allow the use of the builtin target definition or a target.json > specification. > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> Tested with Rust Binder. Tested-by: Alice Ryhl <aliceryhl@google.com> ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets 2023-10-20 15:50 ` [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets Jamie Cunliffe ` (2 preceding siblings ...) 2024-01-22 9:29 ` Alice Ryhl @ 2024-01-24 9:12 ` Masahiro Yamada 3 siblings, 0 replies; 41+ messages in thread From: Masahiro Yamada @ 2024-01-24 9:12 UTC (permalink / raw) To: Jamie Cunliffe Cc: linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew On Sat, Oct 21, 2023 at 12:53 AM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote: > > Eventually we want all architectures to be using the target as defined > by rustc. However currently some architectures can't do that and are > using the target.json specification. This puts in place the foundation > to allow the use of the builtin target definition or a target.json > specification. > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > --- > Makefile | 1 - > arch/x86/Makefile | 1 + > rust/Makefile | 5 ++++- > scripts/Makefile | 4 +++- > 4 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/Makefile b/Makefile > index 88ebf6547964..23100f193da3 100644 > --- a/Makefile > +++ b/Makefile > @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing > > KBUILD_CPPFLAGS := -D__KERNEL__ > KBUILD_RUSTFLAGS := $(rust_common_flags) \ > - --target=$(objtree)/scripts/target.json \ > -Cpanic=abort -Cembed-bitcode=n -Clto=n \ > -Cforce-unwind-tables=n -Ccodegen-units=1 \ > -Csymbol-mangling-version=v0 \ > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > index 5bfe5caaa444..0f339d4abd40 100644 > --- a/arch/x86/Makefile > +++ b/arch/x86/Makefile > @@ -68,6 +68,7 @@ export BITS > # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 > # > KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx > +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json > KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 > > ifeq ($(CONFIG_X86_KERNEL_IBT),y) > diff --git a/rust/Makefile b/rust/Makefile > index 87958e864be0..8d75a6ffe951 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 > $(obj)/core.o: private skip_flags = -Dunreachable_pub > $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) > $(obj)/core.o: private rustc_target_flags = $(core-cfgs) > -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE > +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE > $(call if_changed_dep,rustc_library) > +ifdef CONFIG_X86_64 > +$(obj)/core.o: scripts/target.json > +endif > > $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' > $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE > diff --git a/scripts/Makefile b/scripts/Makefile > index 576cf64be667..c85d130a4125 100644 > --- a/scripts/Makefile > +++ b/scripts/Makefile > @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file > hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen > -always-$(CONFIG_RUST) += target.json > > +ifdef CONFIG_X86_64 Sorry for the delay. I did not notice that this was waiting for my Ack. Now, Rust for loongarch is upstreamed, and it also uses the custom target. This block should be changed to: ifneq ($(CONFIG_X86_64)$(CONFIG_LOONGARCH),) ... endif With that changed, Acked-by: Masahiro Yamada <masahiroy@kernel.org> Or, if you want to make it a little bit cleaner, perhaps you can introduce a new CONFIG option. Let's say CONFIG_RUST_USE_CUSTOM_TARGET (please pick up any option name you like). In scripts/Makefile, -always-$(CONFIG_RUST) += target.json +always-$(CONFIG_RUST_USE_CUSTOM_TARGET) += target.json In the top Makefile, ifdef CONFIG_RUST_USE_CUSTOM_TARGET KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json endif > +always-$(CONFIG_RUST) += target.json > filechk_rust_target = $< < include/config/auto.conf > > $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE > $(call filechk,rust_target) > +endif > > hostprogs += generate_rust_target > generate_rust_target-rust := y > -- > 2.30.2 > > -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 41+ messages in thread
* [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 15:50 [PATCH v4 0/2] Rust enablement for AArch64 Jamie Cunliffe 2023-10-20 15:50 ` [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets Jamie Cunliffe @ 2023-10-20 15:50 ` Jamie Cunliffe 2023-10-20 16:45 ` Catalin Marinas ` (5 more replies) 2024-02-09 17:38 ` [PATCH v4 0/2] Rust enablement " Catalin Marinas 2 siblings, 6 replies; 41+ messages in thread From: Jamie Cunliffe @ 2023-10-20 15:50 UTC (permalink / raw) To: linux-arm-kernel, rust-for-linux Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew This commit provides the build flags for Rust for AArch64. The core Rust support already in the kernel does the rest. This enables the PAC ret and BTI options in the Rust build flags to match the options that are used when building C. The Rust samples have been tested with this commit. Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> Acked-by: Will Deacon <will@kernel.org> --- Documentation/rust/arch-support.rst | 1 + arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 4 ++++ rust/Makefile | 1 + scripts/generate_rust_target.rs | 4 +++- 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/rust/arch-support.rst b/Documentation/rust/arch-support.rst index b91e9ef4d0c2..6bcb3b97c5b6 100644 --- a/Documentation/rust/arch-support.rst +++ b/Documentation/rust/arch-support.rst @@ -15,6 +15,7 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file. ============ ================ ============================================== Architecture Level of support Constraints ============ ================ ============================================== +``arm64`` Maintained Little Endian only. ``um`` Maintained ``x86_64`` only. ``x86`` Maintained ``x86_64`` only. ============ ================ ============================================== diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 78f20e632712..d72618433521 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -227,6 +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_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS select HAVE_KPROBES diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 2d49aea0ff67..52d75c9483a9 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -41,6 +41,8 @@ KBUILD_CFLAGS += -mgeneral-regs-only \ KBUILD_CFLAGS += $(call cc-disable-warning, psabi) KBUILD_AFLAGS += $(compat_vdso) +KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon" + KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) @@ -65,7 +67,9 @@ endif ifeq ($(CONFIG_ARM64_BTI_KERNEL),y) KBUILD_CFLAGS += -mbranch-protection=pac-ret+bti + KBUILD_RUSTFLAGS += -Zbranch-protection=bti,pac-ret else ifeq ($(CONFIG_ARM64_PTR_AUTH_KERNEL),y) + KBUILD_RUSTFLAGS += -Zbranch-protection=pac-ret ifeq ($(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET),y) KBUILD_CFLAGS += -mbranch-protection=pac-ret else diff --git a/rust/Makefile b/rust/Makefile index 8d75a6ffe951..8ced65c9b905 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -294,6 +294,7 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \ # Derived from `scripts/Makefile.clang`. BINDGEN_TARGET_x86 := x86_64-linux-gnu +BINDGEN_TARGET_arm64 := aarch64-linux-gnu BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH)) # All warnings are inhibited since GCC builds are very experimental, diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs index 3c6cbe2b278d..ec5ef35dbe52 100644 --- a/scripts/generate_rust_target.rs +++ b/scripts/generate_rust_target.rs @@ -148,7 +148,9 @@ fn main() { let mut ts = TargetSpec::new(); // `llvm-target`s are taken from `scripts/Makefile.clang`. - if cfg.has("X86_64") { + if cfg.has("ARM64") { + panic!("arm64 uses the builtin rustc aarch64-unknown-none target"); + } else if cfg.has("X86_64") { ts.push("arch", "x86_64"); ts.push( "data-layout", -- 2.30.2 ^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 15:50 ` [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 Jamie Cunliffe @ 2023-10-20 16:45 ` Catalin Marinas 2023-10-21 13:40 ` Miguel Ojeda 2023-10-20 17:21 ` Andrew Lunn ` (4 subsequent siblings) 5 siblings, 1 reply; 41+ messages in thread From: Catalin Marinas @ 2023-10-20 16:45 UTC (permalink / raw) To: Jamie Cunliffe Cc: linux-arm-kernel, rust-for-linux, Miguel Ojeda, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew On Fri, Oct 20, 2023 at 04:50:56PM +0100, Jamie Cunliffe wrote: > This commit provides the build flags for Rust for AArch64. The core Rust > support already in the kernel does the rest. This enables the PAC ret > and BTI options in the Rust build flags to match the options that are > used when building C. > > The Rust samples have been tested with this commit. > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > Acked-by: Will Deacon <will@kernel.org> Miguel, Will acked this already so I think it's good to go. Do you plan to pick both patches via the Rust tree? Acked-by: Catalin Marinas <catalin.marinas@arm.com> Thanks. ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 16:45 ` Catalin Marinas @ 2023-10-21 13:40 ` Miguel Ojeda 2023-10-22 10:48 ` Catalin Marinas 0 siblings, 1 reply; 41+ messages in thread From: Miguel Ojeda @ 2023-10-21 13:40 UTC (permalink / raw) To: Catalin Marinas Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew On Fri, Oct 20, 2023 at 6:46 PM Catalin Marinas <catalin.marinas@arm.com> wrote: > > Miguel, Will acked this already so I think it's good to go. Do you plan > to pick both patches via the Rust tree? Thanks for taking a look! As you prefer -- ideally the changes for each architecture would go through their own trees (we are trying to get maintainers of the different parts of the kernel involved with Rust for their own bits and pieces), but if you think there is a reason to avoid that, I can also take them as fallback for the time being. > Acked-by: Catalin Marinas <catalin.marinas@arm.com> If you decide to take them: Acked-by: Miguel Ojeda <ojeda@kernel.org> I have boot tested it in aarch64 QEMU and saw the KUnit Rust tests passing and checked that the x86 side still works fine. Cheers, Miguel ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-21 13:40 ` Miguel Ojeda @ 2023-10-22 10:48 ` Catalin Marinas 2023-10-22 12:14 ` Miguel Ojeda 0 siblings, 1 reply; 41+ messages in thread From: Catalin Marinas @ 2023-10-22 10:48 UTC (permalink / raw) To: Miguel Ojeda Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew On Sat, Oct 21, 2023 at 03:40:21PM +0200, Miguel Ojeda wrote: > On Fri, Oct 20, 2023 at 6:46 PM Catalin Marinas <catalin.marinas@arm.com> wrote: > > Miguel, Will acked this already so I think it's good to go. Do you plan > > to pick both patches via the Rust tree? > > Thanks for taking a look! > > As you prefer -- ideally the changes for each architecture would go > through their own trees (we are trying to get maintainers of the > different parts of the kernel involved with Rust for their own bits > and pieces), but if you think there is a reason to avoid that, I can > also take them as fallback for the time being. The main reason I asked was that the first patch touches x86 and none of the x86 maintainers have been cc'ed or acked the patch. I thought there's some deal that Rust-related changes go via you tree. > > Acked-by: Catalin Marinas <catalin.marinas@arm.com> > > If you decide to take them: > > Acked-by: Miguel Ojeda <ojeda@kernel.org> > > I have boot tested it in aarch64 QEMU and saw the KUnit Rust tests > passing and checked that the x86 side still works fine. Thanks. I'll reply to the first patch and cc some x86 maintainers. I assume your ack applies to the first patch as well. -- Catalin ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-22 10:48 ` Catalin Marinas @ 2023-10-22 12:14 ` Miguel Ojeda 0 siblings, 0 replies; 41+ messages in thread From: Miguel Ojeda @ 2023-10-22 12:14 UTC (permalink / raw) To: Catalin Marinas Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew On Sun, Oct 22, 2023 at 12:49 PM Catalin Marinas <catalin.marinas@arm.com> wrote: > > The main reason I asked was that the first patch touches x86 and none of > the x86 maintainers have been cc'ed or acked the patch. Ah, yeah, they should have been Cc'd. > I thought > there's some deal that Rust-related changes go via you tree. I see. The initial pieces went through our tree, yeah, and we are happy to take things if needed (without the intention to bypass maintainers), but if maintainers can take things already, that is way better; e.g. some subsystems have already started to do that (Kbuild, KUnit, wq...). So thanks a lot! The only thing we ask for, for the time being, is that patches relevant to Rust or that contain Rust code are Cc'd into the rust-for-linux ML if possible (i.e. in addition to their usual lists), so that anybody that wants to follow things in the initial setup period can do so in a single place (e.g. maintainers that want to see the sort of thing to look out for in reviews). > Thanks. I'll reply to the first patch and cc some x86 maintainers. I > assume your ack applies to the first patch as well. Yeah, it does. Thanks again Catalin & Will! Cheers, Miguel ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 15:50 ` [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 Jamie Cunliffe 2023-10-20 16:45 ` Catalin Marinas @ 2023-10-20 17:21 ` Andrew Lunn 2023-10-20 18:33 ` Boqun Feng 2023-10-31 18:31 ` Matthew Maurer ` (3 subsequent siblings) 5 siblings, 1 reply; 41+ messages in thread From: Andrew Lunn @ 2023-10-20 17:21 UTC (permalink / raw) To: Jamie Cunliffe Cc: linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng > +``arm64`` Maintained Little Endian only. This question is just out of curiosity, not the patchset itself. What is missing to make big endian work? 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 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 17:21 ` Andrew Lunn @ 2023-10-20 18:33 ` Boqun Feng 2023-10-20 18:47 ` Andrew Lunn ` (4 more replies) 0 siblings, 5 replies; 41+ messages in thread From: Boqun Feng @ 2023-10-20 18:33 UTC (permalink / raw) To: Andrew Lunn Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, Michael Turquette, Stephen Boyd, linux-clk 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 ^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 18:33 ` Boqun Feng @ 2023-10-20 18:47 ` Andrew Lunn 2023-10-21 12:50 ` Alice Ryhl ` (3 subsequent siblings) 4 siblings, 0 replies; 41+ messages in thread From: Andrew Lunn @ 2023-10-20 18:47 UTC (permalink / raw) To: Boqun Feng Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, Michael Turquette, Stephen Boyd, linux-clk > 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. Thanks for testing this, its good to know. Andrew ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 18:33 ` Boqun Feng 2023-10-20 18:47 ` Andrew Lunn @ 2023-10-21 12:50 ` Alice Ryhl 2023-10-21 13:41 ` Miguel Ojeda ` (2 subsequent siblings) 4 siblings, 0 replies; 41+ messages in thread From: Alice Ryhl @ 2023-10-21 12:50 UTC (permalink / raw) To: Boqun Feng, Andrew Lunn Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, Michael Turquette, Stephen Boyd, linux-clk 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 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 18:33 ` Boqun Feng 2023-10-20 18:47 ` Andrew Lunn 2023-10-21 12:50 ` Alice Ryhl @ 2023-10-21 13:41 ` Miguel Ojeda 2023-10-21 16:03 ` Andrew Lunn 2023-10-24 0:57 ` Stephen Boyd 2023-11-01 15:04 ` Linus Walleij 4 siblings, 1 reply; 41+ messages in thread From: Miguel Ojeda @ 2023-10-21 13:41 UTC (permalink / raw) To: Boqun Feng Cc: Andrew Lunn, Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, Michael Turquette, Stephen Boyd, linux-clk On Fri, Oct 20, 2023 at 8:33 PM Boqun Feng <boqun.feng@gmail.com> wrote: > > But I think if people want to do experiments, the tool is there. Yeah. If the Arm maintainers are OK adding it, I think we should also put it in (next cycle perhaps) -- the sooner we have it in-tree, the more testing it will hopefully get over time, and we can eventually ask the CIs to add a run with it if they have the resources. Cheers, Miguel ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-21 13:41 ` Miguel Ojeda @ 2023-10-21 16:03 ` Andrew Lunn 2023-10-22 12:57 ` Miguel Ojeda 0 siblings, 1 reply; 41+ messages in thread From: Andrew Lunn @ 2023-10-21 16:03 UTC (permalink / raw) To: Miguel Ojeda Cc: Boqun Feng, Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, Michael Turquette, Stephen Boyd, linux-clk On Sat, Oct 21, 2023 at 03:41:54PM +0200, Miguel Ojeda wrote: > On Fri, Oct 20, 2023 at 8:33 PM Boqun Feng <boqun.feng@gmail.com> wrote: > > > > But I think if people want to do experiments, the tool is there. > > Yeah. If the Arm maintainers are OK adding it, I think we should also > put it in (next cycle perhaps) -- the sooner we have it in-tree, the > more testing it will hopefully get over time, and we can eventually > ask the CIs to add a run with it if they have the resources. As i said elsewhere, endiannes is interesting for networking. Maybe at the netdev conference next month, how to handle endiannes can be part of the presentation? I'm guessing, but is it part of the type system? So long as a type is marked as 'cpu endian', little endian, or big endian, the compiler will take care of adding the needed swaps? Andrew ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-21 16:03 ` Andrew Lunn @ 2023-10-22 12:57 ` Miguel Ojeda 0 siblings, 0 replies; 41+ messages in thread From: Miguel Ojeda @ 2023-10-22 12:57 UTC (permalink / raw) To: Andrew Lunn Cc: Boqun Feng, Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, Michael Turquette, Stephen Boyd, linux-clk On Sat, Oct 21, 2023 at 6:03 PM Andrew Lunn <andrew@lunn.ch> wrote: > > Maybe at the netdev conference next month, how to handle endiannes can > be part of the presentation? I'm guessing, but is it part of the type > system? So long as a type is marked as 'cpu endian', little endian, or > big endian, the compiler will take care of adding the needed swaps? Yeah, the type system can take care of ensuring that one does not forget which type of quantity one is handling. For instance, in this out-of-tree commit [1] from Wedson a `LE` generic is added, which allows you to use e.g. `LE<u32>` in your structs: struct Example { a: LE<u32>, b: LE<u32>, } fn sum(e: &Example) -> u32 { // `value` extracts the value in cpu representation. e.a.value() + e.b.value() } Relatedly, the primitive integer types also provide "raw" functionality for endianness, e.g. the `to_{le,be}` and `to_{le,be,ne}_bytes` methods [2][3], and there are third-party crates on this, e.g. [4]. [1] https://github.com/wedsonaf/linux/commit/ca4a93caff8b96a54a68fb052959801468bce01a [2] https://doc.rust-lang.org/std/primitive.u32.html#method.to_le [3] https://doc.rust-lang.org/std/primitive.u32.html#method.to_be_bytes [4] https://docs.rs/byteorder/latest/byteorder/ Cheers, Miguel ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 18:33 ` Boqun Feng ` (2 preceding siblings ...) 2023-10-21 13:41 ` Miguel Ojeda @ 2023-10-24 0:57 ` Stephen Boyd 2023-10-25 23:55 ` Boqun Feng 2023-11-01 15:04 ` Linus Walleij 4 siblings, 1 reply; 41+ messages in thread From: Stephen Boyd @ 2023-10-24 0:57 UTC (permalink / raw) To: Andrew Lunn, Boqun Feng Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, Michael Turquette, linux-clk Quoting Boqun Feng (2023-10-20 11:33:10) > 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) > Thanks for the report! We should treat it as an __le32 for now. I'll have to add tests for the big endian flag as well. Does this fix it? ---8<---- diff --git a/drivers/clk/clk-gate_test.c b/drivers/clk/clk-gate_test.c index e136aaad48bf..c96d93b19ddf 100644 --- a/drivers/clk/clk-gate_test.c +++ b/drivers/clk/clk-gate_test.c @@ -131,7 +131,7 @@ struct clk_gate_test_context { void __iomem *fake_mem; struct clk_hw *hw; struct clk_hw *parent; - u32 fake_reg; /* Keep at end, KASAN can detect out of bounds */ + __le32 fake_reg; /* Keep at end, KASAN can detect out of bounds */ }; static struct clk_gate_test_context *clk_gate_test_alloc_ctx(struct kunit *test) @@ -166,7 +166,7 @@ static void clk_gate_test_enable(struct kunit *test) KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); - KUNIT_EXPECT_EQ(test, enable_val, ctx->fake_reg); + KUNIT_EXPECT_EQ(test, enable_val, le32_to_cpu(ctx->fake_reg)); KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(hw)); KUNIT_EXPECT_TRUE(test, clk_hw_is_prepared(hw)); KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(parent)); @@ -183,10 +183,10 @@ static void clk_gate_test_disable(struct kunit *test) u32 disable_val = 0; KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); - KUNIT_ASSERT_EQ(test, enable_val, ctx->fake_reg); + KUNIT_ASSERT_EQ(test, enable_val, le32_to_cpu(ctx->fake_reg)); clk_disable_unprepare(clk); - KUNIT_EXPECT_EQ(test, disable_val, ctx->fake_reg); + KUNIT_EXPECT_EQ(test, disable_val, le32_to_cpu(ctx->fake_reg)); KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(hw)); KUNIT_EXPECT_FALSE(test, clk_hw_is_prepared(hw)); KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(parent)); @@ -246,7 +246,7 @@ static void clk_gate_test_invert_enable(struct kunit *test) KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); - KUNIT_EXPECT_EQ(test, enable_val, ctx->fake_reg); + KUNIT_EXPECT_EQ(test, enable_val, le32_to_cpu(ctx->fake_reg)); KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(hw)); KUNIT_EXPECT_TRUE(test, clk_hw_is_prepared(hw)); KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(parent)); @@ -263,10 +263,10 @@ static void clk_gate_test_invert_disable(struct kunit *test) u32 disable_val = BIT(15); KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); - KUNIT_ASSERT_EQ(test, enable_val, ctx->fake_reg); + KUNIT_ASSERT_EQ(test, enable_val, le32_to_cpu(ctx->fake_reg)); clk_disable_unprepare(clk); - KUNIT_EXPECT_EQ(test, disable_val, ctx->fake_reg); + KUNIT_EXPECT_EQ(test, disable_val, le32_to_cpu(ctx->fake_reg)); KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(hw)); KUNIT_EXPECT_FALSE(test, clk_hw_is_prepared(hw)); KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(parent)); @@ -290,7 +290,7 @@ static int clk_gate_test_invert_init(struct kunit *test) 2000000); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); - ctx->fake_reg = BIT(15); /* Default to off */ + ctx->fake_reg = cpu_to_le32(BIT(15)); /* Default to off */ hw = clk_hw_register_gate_parent_hw(NULL, "test_gate", parent, 0, ctx->fake_mem, 15, CLK_GATE_SET_TO_DISABLE, NULL); @@ -319,7 +319,7 @@ static void clk_gate_test_hiword_enable(struct kunit *test) KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); - KUNIT_EXPECT_EQ(test, enable_val, ctx->fake_reg); + KUNIT_EXPECT_EQ(test, enable_val, le32_to_cpu(ctx->fake_reg)); KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(hw)); KUNIT_EXPECT_TRUE(test, clk_hw_is_prepared(hw)); KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(parent)); @@ -336,10 +336,10 @@ static void clk_gate_test_hiword_disable(struct kunit *test) u32 disable_val = BIT(9 + 16); KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); - KUNIT_ASSERT_EQ(test, enable_val, ctx->fake_reg); + KUNIT_ASSERT_EQ(test, enable_val, le32_to_cpu(ctx->fake_reg)); clk_disable_unprepare(clk); - KUNIT_EXPECT_EQ(test, disable_val, ctx->fake_reg); + KUNIT_EXPECT_EQ(test, disable_val, le32_to_cpu(ctx->fake_reg)); KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(hw)); KUNIT_EXPECT_FALSE(test, clk_hw_is_prepared(hw)); KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(parent)); @@ -387,7 +387,7 @@ static void clk_gate_test_is_enabled(struct kunit *test) struct clk_gate_test_context *ctx; ctx = clk_gate_test_alloc_ctx(test); - ctx->fake_reg = BIT(7); + ctx->fake_reg = cpu_to_le32(BIT(7)); hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 7, 0, NULL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); @@ -402,7 +402,7 @@ static void clk_gate_test_is_disabled(struct kunit *test) struct clk_gate_test_context *ctx; ctx = clk_gate_test_alloc_ctx(test); - ctx->fake_reg = BIT(4); + ctx->fake_reg = cpu_to_le32(BIT(4)); hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 7, 0, NULL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); @@ -417,7 +417,7 @@ static void clk_gate_test_is_enabled_inverted(struct kunit *test) struct clk_gate_test_context *ctx; ctx = clk_gate_test_alloc_ctx(test); - ctx->fake_reg = BIT(31); + ctx->fake_reg = cpu_to_le32(BIT(31)); hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 2, CLK_GATE_SET_TO_DISABLE, NULL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); @@ -432,7 +432,7 @@ static void clk_gate_test_is_disabled_inverted(struct kunit *test) struct clk_gate_test_context *ctx; ctx = clk_gate_test_alloc_ctx(test); - ctx->fake_reg = BIT(29); + ctx->fake_reg = cpu_to_le32(BIT(29)); hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 29, CLK_GATE_SET_TO_DISABLE, NULL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); ^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-24 0:57 ` Stephen Boyd @ 2023-10-25 23:55 ` Boqun Feng 0 siblings, 0 replies; 41+ messages in thread From: Boqun Feng @ 2023-10-25 23:55 UTC (permalink / raw) To: Stephen Boyd Cc: Andrew Lunn, Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, Michael Turquette, linux-clk On Mon, Oct 23, 2023 at 05:57:59PM -0700, Stephen Boyd wrote: > Quoting Boqun Feng (2023-10-20 11:33:10) > > 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) > > > > Thanks for the report! We should treat it as an __le32 for now. I'll > have to add tests for the big endian flag as well. Does this fix it? Yep! I just tested with kunit, and all the tests pass. Feel free to add: Tested-by: Boqun Feng <boqun.feng@gmail.com> Regards, Boqun > > ---8<---- > diff --git a/drivers/clk/clk-gate_test.c b/drivers/clk/clk-gate_test.c > index e136aaad48bf..c96d93b19ddf 100644 > --- a/drivers/clk/clk-gate_test.c > +++ b/drivers/clk/clk-gate_test.c > @@ -131,7 +131,7 @@ struct clk_gate_test_context { > void __iomem *fake_mem; > struct clk_hw *hw; > struct clk_hw *parent; > - u32 fake_reg; /* Keep at end, KASAN can detect out of bounds */ > + __le32 fake_reg; /* Keep at end, KASAN can detect out of bounds */ > }; > > static struct clk_gate_test_context *clk_gate_test_alloc_ctx(struct kunit *test) > @@ -166,7 +166,7 @@ static void clk_gate_test_enable(struct kunit *test) > > KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); > > - KUNIT_EXPECT_EQ(test, enable_val, ctx->fake_reg); > + KUNIT_EXPECT_EQ(test, enable_val, le32_to_cpu(ctx->fake_reg)); > KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(hw)); > KUNIT_EXPECT_TRUE(test, clk_hw_is_prepared(hw)); > KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(parent)); > @@ -183,10 +183,10 @@ static void clk_gate_test_disable(struct kunit *test) > u32 disable_val = 0; > > KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); > - KUNIT_ASSERT_EQ(test, enable_val, ctx->fake_reg); > + KUNIT_ASSERT_EQ(test, enable_val, le32_to_cpu(ctx->fake_reg)); > > clk_disable_unprepare(clk); > - KUNIT_EXPECT_EQ(test, disable_val, ctx->fake_reg); > + KUNIT_EXPECT_EQ(test, disable_val, le32_to_cpu(ctx->fake_reg)); > KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(hw)); > KUNIT_EXPECT_FALSE(test, clk_hw_is_prepared(hw)); > KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(parent)); > @@ -246,7 +246,7 @@ static void clk_gate_test_invert_enable(struct kunit *test) > > KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); > > - KUNIT_EXPECT_EQ(test, enable_val, ctx->fake_reg); > + KUNIT_EXPECT_EQ(test, enable_val, le32_to_cpu(ctx->fake_reg)); > KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(hw)); > KUNIT_EXPECT_TRUE(test, clk_hw_is_prepared(hw)); > KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(parent)); > @@ -263,10 +263,10 @@ static void clk_gate_test_invert_disable(struct kunit *test) > u32 disable_val = BIT(15); > > KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); > - KUNIT_ASSERT_EQ(test, enable_val, ctx->fake_reg); > + KUNIT_ASSERT_EQ(test, enable_val, le32_to_cpu(ctx->fake_reg)); > > clk_disable_unprepare(clk); > - KUNIT_EXPECT_EQ(test, disable_val, ctx->fake_reg); > + KUNIT_EXPECT_EQ(test, disable_val, le32_to_cpu(ctx->fake_reg)); > KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(hw)); > KUNIT_EXPECT_FALSE(test, clk_hw_is_prepared(hw)); > KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(parent)); > @@ -290,7 +290,7 @@ static int clk_gate_test_invert_init(struct kunit *test) > 2000000); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); > > - ctx->fake_reg = BIT(15); /* Default to off */ > + ctx->fake_reg = cpu_to_le32(BIT(15)); /* Default to off */ > hw = clk_hw_register_gate_parent_hw(NULL, "test_gate", parent, 0, > ctx->fake_mem, 15, > CLK_GATE_SET_TO_DISABLE, NULL); > @@ -319,7 +319,7 @@ static void clk_gate_test_hiword_enable(struct kunit *test) > > KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); > > - KUNIT_EXPECT_EQ(test, enable_val, ctx->fake_reg); > + KUNIT_EXPECT_EQ(test, enable_val, le32_to_cpu(ctx->fake_reg)); > KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(hw)); > KUNIT_EXPECT_TRUE(test, clk_hw_is_prepared(hw)); > KUNIT_EXPECT_TRUE(test, clk_hw_is_enabled(parent)); > @@ -336,10 +336,10 @@ static void clk_gate_test_hiword_disable(struct kunit *test) > u32 disable_val = BIT(9 + 16); > > KUNIT_ASSERT_EQ(test, clk_prepare_enable(clk), 0); > - KUNIT_ASSERT_EQ(test, enable_val, ctx->fake_reg); > + KUNIT_ASSERT_EQ(test, enable_val, le32_to_cpu(ctx->fake_reg)); > > clk_disable_unprepare(clk); > - KUNIT_EXPECT_EQ(test, disable_val, ctx->fake_reg); > + KUNIT_EXPECT_EQ(test, disable_val, le32_to_cpu(ctx->fake_reg)); > KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(hw)); > KUNIT_EXPECT_FALSE(test, clk_hw_is_prepared(hw)); > KUNIT_EXPECT_FALSE(test, clk_hw_is_enabled(parent)); > @@ -387,7 +387,7 @@ static void clk_gate_test_is_enabled(struct kunit *test) > struct clk_gate_test_context *ctx; > > ctx = clk_gate_test_alloc_ctx(test); > - ctx->fake_reg = BIT(7); > + ctx->fake_reg = cpu_to_le32(BIT(7)); > hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 7, > 0, NULL); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); > @@ -402,7 +402,7 @@ static void clk_gate_test_is_disabled(struct kunit *test) > struct clk_gate_test_context *ctx; > > ctx = clk_gate_test_alloc_ctx(test); > - ctx->fake_reg = BIT(4); > + ctx->fake_reg = cpu_to_le32(BIT(4)); > hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 7, > 0, NULL); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); > @@ -417,7 +417,7 @@ static void clk_gate_test_is_enabled_inverted(struct kunit *test) > struct clk_gate_test_context *ctx; > > ctx = clk_gate_test_alloc_ctx(test); > - ctx->fake_reg = BIT(31); > + ctx->fake_reg = cpu_to_le32(BIT(31)); > hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 2, > CLK_GATE_SET_TO_DISABLE, NULL); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); > @@ -432,7 +432,7 @@ static void clk_gate_test_is_disabled_inverted(struct kunit *test) > struct clk_gate_test_context *ctx; > > ctx = clk_gate_test_alloc_ctx(test); > - ctx->fake_reg = BIT(29); > + ctx->fake_reg = cpu_to_le32(BIT(29)); > hw = clk_hw_register_gate(NULL, "test_gate", NULL, 0, ctx->fake_mem, 29, > CLK_GATE_SET_TO_DISABLE, NULL); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hw); > ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 18:33 ` Boqun Feng ` (3 preceding siblings ...) 2023-10-24 0:57 ` Stephen Boyd @ 2023-11-01 15:04 ` Linus Walleij 4 siblings, 0 replies; 41+ messages in thread From: Linus Walleij @ 2023-11-01 15:04 UTC (permalink / raw) To: Boqun Feng Cc: Andrew Lunn, Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, Michael Turquette, Stephen Boyd, linux-clk [Andrew wrote] > > 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. If you mean ARM32 BE I have that on the IXP4xx systems up and running mainline kernels and mainline OpenWrt now, but I haven't seen rust enablement for ARM32 yet (but it can't be that hard). Yours, Linus Walleij ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 15:50 ` [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 Jamie Cunliffe 2023-10-20 16:45 ` Catalin Marinas 2023-10-20 17:21 ` Andrew Lunn @ 2023-10-31 18:31 ` Matthew Maurer 2023-11-28 18:29 ` Boqun Feng 2023-12-13 19:00 ` Miguel Ojeda 2024-01-22 2:01 ` Fabien Parent ` (2 subsequent siblings) 5 siblings, 2 replies; 41+ messages in thread From: Matthew Maurer @ 2023-10-31 18:31 UTC (permalink / raw) To: Jamie Cunliffe Cc: linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew On Fri, Oct 20, 2023 at 8:53 AM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote: > +KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon" If I have aarch64-unknown-none target support already installed in my local Rust compiler (either build a custom compiler and enable the target, as is my real case, or as the common case, run `rustup target add aarch64-unknown-none`), this produces a build error I didn't get from the previous target.json approach: error[E0464]: multiple candidates for `rmeta` dependency `core` found | = note: candidate #1: /usr/local/google/home/mmaurer/android/linux/out/cache/65c6e8ea/common/rust/libcore.rmeta = note: candidate #2: /usr/local/google/home/mmaurer/android/linux/prebuilts/rust/linux-x86/1.72.1/lib/rustlib/aarch64-unknown-none/lib/libcore-690113bb4de6f7fb.rlib Are we sure that we want to try to use `--target=aarch64-unknown-none` rather than a custom target.json? If our libcore and their libcore may be compiled differently (and they can be, because we are controlling additional compilation options), it seems to me that we ought to be defining our own target. If we really do want to go ahead with using targets directly form rustc, this patch should add `--sysroot=/dev/null` or a similar override to `rustc_library_cmd` and `rust_common_cmd` to prevent rustc from picking up any already installed sysroot libraries. ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-31 18:31 ` Matthew Maurer @ 2023-11-28 18:29 ` Boqun Feng 2023-12-13 19:00 ` Miguel Ojeda 1 sibling, 0 replies; 41+ messages in thread From: Boqun Feng @ 2023-11-28 18:29 UTC (permalink / raw) To: Matthew Maurer Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, andrew On Tue, Oct 31, 2023 at 11:31:14AM -0700, Matthew Maurer wrote: > On Fri, Oct 20, 2023 at 8:53 AM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote: > > +KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon" > If I have aarch64-unknown-none target support already installed in my > local Rust compiler (either build a custom compiler and enable the > target, as is my real case, or as the common case, run `rustup target > add aarch64-unknown-none`), this produces a build error I didn't get > from the previous target.json approach: > > error[E0464]: multiple candidates for `rmeta` dependency `core` found > | > = note: candidate #1: > /usr/local/google/home/mmaurer/android/linux/out/cache/65c6e8ea/common/rust/libcore.rmeta > = note: candidate #2: > /usr/local/google/home/mmaurer/android/linux/prebuilts/rust/linux-x86/1.72.1/lib/rustlib/aarch64-unknown-none/lib/libcore-690113bb4de6f7fb.rlib > > Are we sure that we want to try to use `--target=aarch64-unknown-none` > rather than a custom target.json? If our libcore and their libcore may > be compiled differently (and they can be, because we are controlling > additional compilation options), it seems to me that we ought to be > defining our own target. > FWIW, the discussion around this: https://lore.kernel.org/rust-for-linux/20230126163552.GD29438@willie-the-truck/ > If we really do want to go ahead with using targets directly form > rustc, this patch should add `--sysroot=/dev/null` or a similar > override to `rustc_library_cmd` and `rust_common_cmd` to prevent rustc > from picking up any already installed sysroot libraries. > Agreed. Regards, Boqun ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-31 18:31 ` Matthew Maurer 2023-11-28 18:29 ` Boqun Feng @ 2023-12-13 19:00 ` Miguel Ojeda 1 sibling, 0 replies; 41+ messages in thread From: Miguel Ojeda @ 2023-12-13 19:00 UTC (permalink / raw) To: Matthew Maurer Cc: Jamie Cunliffe, linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew On Tue, Oct 31, 2023 at 7:31 PM Matthew Maurer <mmaurer@google.com> wrote: > > If we really do want to go ahead with using targets directly form > rustc, this patch should add `--sysroot=/dev/null` or a similar > override to `rustc_library_cmd` and `rust_common_cmd` to prevent rustc > from picking up any already installed sysroot libraries. For reference, Matthew sent the patch to do this at https://lore.kernel.org/rust-for-linux/20231031201752.1189213-1-mmaurer@google.com/ and I have picked it up in `rust-next` (with a couple extra changes noted in that thread), so this should be OK. When this series also arrives in `-next` I will be testing the combination further just in case. Cheers, Miguel ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 15:50 ` [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 Jamie Cunliffe ` (2 preceding siblings ...) 2023-10-31 18:31 ` Matthew Maurer @ 2024-01-22 2:01 ` Fabien Parent 2024-01-22 5:27 ` Behme Dirk (CM/ESO2) 2024-01-22 9:30 ` Alice Ryhl 5 siblings, 0 replies; 41+ messages in thread From: Fabien Parent @ 2024-01-22 2:01 UTC (permalink / raw) To: Jamie Cunliffe Cc: linux-arm-kernel, rust-for-linux, Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew I've been using this patch for quite some time, so: Tested-by: Fabien Parent <fabien.parent@linaro.org> ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 15:50 ` [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 Jamie Cunliffe ` (3 preceding siblings ...) 2024-01-22 2:01 ` Fabien Parent @ 2024-01-22 5:27 ` Behme Dirk (CM/ESO2) 2024-01-22 9:30 ` Alice Ryhl 5 siblings, 0 replies; 41+ messages in thread From: Behme Dirk (CM/ESO2) @ 2024-01-22 5:27 UTC (permalink / raw) To: Jamie Cunliffe, linux-arm-kernel, rust-for-linux Cc: Miguel Ojeda, Catalin Marinas, Will Deacon, steve.capper, Asahi Lina, boqun.feng, andrew On 20.10.2023 17:50, Jamie Cunliffe wrote: > This commit provides the build flags for Rust for AArch64. The core Rust > support already in the kernel does the rest. This enables the PAC ret > and BTI options in the Rust build flags to match the options that are > used when building C. > > The Rust samples have been tested with this commit. > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > Acked-by: Will Deacon <will@kernel.org> I'm using it since some weeks cross compiling from x86. Boots executing the sample code and the KUnit doctests. So: Tested-by: Dirk Behme <dirk.behme@de.bosch.com> Would be nice if we could get this merged :) Dirk > --- > Documentation/rust/arch-support.rst | 1 + > arch/arm64/Kconfig | 1 + > arch/arm64/Makefile | 4 ++++ > rust/Makefile | 1 + > scripts/generate_rust_target.rs | 4 +++- > 5 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/Documentation/rust/arch-support.rst b/Documentation/rust/arch-support.rst > index b91e9ef4d0c2..6bcb3b97c5b6 100644 > --- a/Documentation/rust/arch-support.rst > +++ b/Documentation/rust/arch-support.rst > @@ -15,6 +15,7 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file. > ============ ================ ============================================== > Architecture Level of support Constraints > ============ ================ ============================================== > +``arm64`` Maintained Little Endian only. > ``um`` Maintained ``x86_64`` only. > ``x86`` Maintained ``x86_64`` only. > ============ ================ ============================================== > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index 78f20e632712..d72618433521 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -227,6 +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_STACKPROTECTOR > select HAVE_SYSCALL_TRACEPOINTS > select HAVE_KPROBES > diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile > index 2d49aea0ff67..52d75c9483a9 100644 > --- a/arch/arm64/Makefile > +++ b/arch/arm64/Makefile > @@ -41,6 +41,8 @@ KBUILD_CFLAGS += -mgeneral-regs-only \ > KBUILD_CFLAGS += $(call cc-disable-warning, psabi) > KBUILD_AFLAGS += $(compat_vdso) > > +KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon" > + > KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) > KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) > > @@ -65,7 +67,9 @@ endif > > ifeq ($(CONFIG_ARM64_BTI_KERNEL),y) > KBUILD_CFLAGS += -mbranch-protection=pac-ret+bti > + KBUILD_RUSTFLAGS += -Zbranch-protection=bti,pac-ret > else ifeq ($(CONFIG_ARM64_PTR_AUTH_KERNEL),y) > + KBUILD_RUSTFLAGS += -Zbranch-protection=pac-ret > ifeq ($(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET),y) > KBUILD_CFLAGS += -mbranch-protection=pac-ret > else > diff --git a/rust/Makefile b/rust/Makefile > index 8d75a6ffe951..8ced65c9b905 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -294,6 +294,7 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \ > > # Derived from `scripts/Makefile.clang`. > BINDGEN_TARGET_x86 := x86_64-linux-gnu > +BINDGEN_TARGET_arm64 := aarch64-linux-gnu > BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH)) > > # All warnings are inhibited since GCC builds are very experimental, > diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs > index 3c6cbe2b278d..ec5ef35dbe52 100644 > --- a/scripts/generate_rust_target.rs > +++ b/scripts/generate_rust_target.rs > @@ -148,7 +148,9 @@ fn main() { > let mut ts = TargetSpec::new(); > > // `llvm-target`s are taken from `scripts/Makefile.clang`. > - if cfg.has("X86_64") { > + if cfg.has("ARM64") { > + panic!("arm64 uses the builtin rustc aarch64-unknown-none target"); > + } else if cfg.has("X86_64") { > ts.push("arch", "x86_64"); > ts.push( > "data-layout", ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-20 15:50 ` [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 Jamie Cunliffe ` (4 preceding siblings ...) 2024-01-22 5:27 ` Behme Dirk (CM/ESO2) @ 2024-01-22 9:30 ` Alice Ryhl 5 siblings, 0 replies; 41+ messages in thread From: Alice Ryhl @ 2024-01-22 9:30 UTC (permalink / raw) To: jamie.cunliffe Cc: andrew, boqun.feng, catalin.marinas, lina, linux-arm-kernel, ojeda, rust-for-linux, steve.capper, will, Alice Ryhl Jamie Cunliffe <Jamie.Cunliffe@arm.com> writes: > This commit provides the build flags for Rust for AArch64. The core Rust > support already in the kernel does the rest. This enables the PAC ret > and BTI options in the Rust build flags to match the options that are > used when building C. > > The Rust samples have been tested with this commit. > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > Acked-by: Will Deacon <will@kernel.org> Tested with Rust Binder. Tested-by: Alice Ryhl <aliceryhl@google.com> ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 0/2] Rust enablement for AArch64 2023-10-20 15:50 [PATCH v4 0/2] Rust enablement for AArch64 Jamie Cunliffe 2023-10-20 15:50 ` [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets Jamie Cunliffe 2023-10-20 15:50 ` [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 Jamie Cunliffe @ 2024-02-09 17:38 ` Catalin Marinas 2024-02-09 21:41 ` Miguel Ojeda 2 siblings, 1 reply; 41+ messages in thread From: Catalin Marinas @ 2024-02-09 17:38 UTC (permalink / raw) To: linux-arm-kernel, rust-for-linux, Jamie Cunliffe Cc: Will Deacon, Miguel Ojeda, steve.capper, Asahi Lina, boqun.feng, andrew, Masahiro Yamada, WANG Rui, Ingo Molnar On Fri, 20 Oct 2023 16:50:54 +0100, Jamie Cunliffe wrote: > Enable Rust support for the AArch64 architecture. > > Since the v3 this has been refactored to split up the x86 Makefile > changes. Updated the x86-64 conditionals as suggested by Boqun and > addressed the formatting issues Miguel raised. > > > [...] Applied to arm64 (for-next/rust-for-arm64), thanks! I also folded Rui's loongarch fix into the first patch to avoid breaking this arch: https://github.com/heiher/linux/commit/c504d83a6edd963e2ba58ec538e3f06da78b187e.patch [1/2] rust: Refactor the build target to allow the use of builtin targets https://git.kernel.org/arm64/c/f82811e22b48 [2/2] arm64: rust: Enable Rust support for AArch64 https://git.kernel.org/arm64/c/724a75ac9542 -- Catalin ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 0/2] Rust enablement for AArch64 2024-02-09 17:38 ` [PATCH v4 0/2] Rust enablement " Catalin Marinas @ 2024-02-09 21:41 ` Miguel Ojeda 0 siblings, 0 replies; 41+ messages in thread From: Miguel Ojeda @ 2024-02-09 21:41 UTC (permalink / raw) To: Catalin Marinas Cc: linux-arm-kernel, rust-for-linux, Jamie Cunliffe, Will Deacon, Miguel Ojeda, steve.capper, Asahi Lina, boqun.feng, andrew, Masahiro Yamada, WANG Rui, Ingo Molnar On Fri, Feb 9, 2024 at 6:38 PM Catalin Marinas <catalin.marinas@arm.com> wrote: > > Applied to arm64 (for-next/rust-for-arm64), thanks! > > I also folded Rui's loongarch fix into the first patch to avoid breaking > this arch: > > https://github.com/heiher/linux/commit/c504d83a6edd963e2ba58ec538e3f06da78b187e.patch Thanks Catalin! I tested your branch `for-next/core` at f735966ee23c with arm64 and x86_64 (and built-test loongarch64). Cheers, Miguel ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 @ 2023-10-24 14:17 Pratham Patel 2023-10-24 15:19 ` Miguel Ojeda 0 siblings, 1 reply; 41+ messages in thread From: Pratham Patel @ 2023-10-24 14:17 UTC (permalink / raw) To: boqun.feng Cc: Jamie.Cunliffe, andrew, catalin.marinas, lina, linux-arm-kernel, linux-clk, mturquette, ojeda, rust-for-linux, sboyd, steve.capper, will On Fri, 20 Oct 2023 11:33:10 -0700, Boqun Feng wrote: > 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) > This comes from a nobody (quite literally my first email on the kernel mailing list), but I would rather that the support for AArch64 BE be not added at all. My reasoning for this is because the rustc target `aarch64_be-unknown-linux-gnu` is in the tier 3 of support. More details can be found in the official documentation [0], but a few, **select** key points from that section: > At this tier, the Rust project provides no official support for a target, so we place minimal requirements on the introduction of targets. > Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions. I am not an owner of any AArch64 BE machines, but if I were, this would be concerning to _me_. I would prefer waiting for the Rust side to be a bit more stable, at least in tier 2 support, for adding AArch64 BE support. Though from the user of the Linux kernel, it may not be that much of an issue, but from a developer's and packager's perspective, this will lead to a few wasted hours until the metaphorical person figures out why said Rust code failed to build for AArch64 BE. [0]: https://doc.rust-lang.org/rustc/target-tier-policy.html#tier-3-target-policy P.S. This is my first time sending an email to a mailing list, sorry if I mucked something up. ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-24 14:17 [PATCH v4 2/2] arm64: rust: Enable Rust support " Pratham Patel @ 2023-10-24 15:19 ` Miguel Ojeda 2023-10-25 2:01 ` Pratham Patel 0 siblings, 1 reply; 41+ messages in thread From: Miguel Ojeda @ 2023-10-24 15:19 UTC (permalink / raw) To: Pratham Patel Cc: boqun.feng, Jamie.Cunliffe, andrew, catalin.marinas, lina, linux-arm-kernel, linux-clk, mturquette, ojeda, rust-for-linux, sboyd, steve.capper, will On Tue, Oct 24, 2023 at 4:18 PM Pratham Patel <thefirst1322@gmail.com> wrote: > > This comes from a nobody (quite literally my first email on the kernel > mailing list), but I would rather that the support for AArch64 BE be > not added at all. My reasoning for this is because the rustc target > `aarch64_be-unknown-linux-gnu` is in the tier 3 of support. We are aware of the tier list support, but please note that e.g. for x86, we are not even using one of the built-in targets (for the moment at least), and that we use a range of other unstable features. It is under discussion between the two projects how these details will be properly supported. > but from a developer's and packager's > perspective, this will lead to a few wasted hours until the > metaphorical person figures out why said Rust code failed to build for > AArch64 BE. Why would the code fail to build? i.e. as far as I understand, Boqun successfully compiled and QEMU-booted a BE image. If you mean that it could stop compiling at any point because it is not officially supported, then note that we pin the compiler, and that it also applies to the rest of the code due to other unstable features too, which is why we need to get the Rust project to support the kernel properly for the use cases we need (not just targets, but also features). Also please note that, even if everything else was formally supported, it would still be a good idea to add this support early (possibly with a warning or gate or similar if not intended to be used by end users yet) so that we have the first big-endian target around. > P.S. This is my first time sending an email to a mailing list, sorry > if I mucked something up. The content looks fine :) However, I think the proper `In-Reply-To` header is not there so Lore gets confused -- did you use the suggested parameters at the bottom of e.g. [1]? [1] https://lore.kernel.org/rust-for-linux/CAM+6MoE1DyOay-fMWQP0hsenz174hSuGJnKM7symh0C-y1mqZw@mail.gmail.com/ Cheers, Miguel ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 2023-10-24 15:19 ` Miguel Ojeda @ 2023-10-25 2:01 ` Pratham Patel 0 siblings, 0 replies; 41+ messages in thread From: Pratham Patel @ 2023-10-25 2:01 UTC (permalink / raw) To: Miguel Ojeda Cc: boqun.feng, Jamie.Cunliffe, andrew, catalin.marinas, lina, linux-arm-kernel, linux-clk, mturquette, ojeda, rust-for-linux, sboyd, steve.capper, will On Tue, 24 Oct 2023 at 20:49, Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote: > > but from a developer's and packager's > > perspective, this will lead to a few wasted hours until the > > metaphorical person figures out why said Rust code failed to build for > > AArch64 BE. > > Why would the code fail to build? i.e. as far as I understand, Boqun > successfully compiled and QEMU-booted a BE image. > > If you mean that it could stop compiling at any point because it is > not officially supported, then note that we pin the compiler, and that > it also applies to the rest of the code due to other unstable features > too, which is why we need to get the Rust project to support the > kernel properly for the use cases we need (not just targets, but also > features). Yes, apologies for not clarifying it. I meant exactly that: the code would stop compiling if either the target was dropped for any reason, or supporting AArch64 BE would hold back upgrading the compiler for other architectures. Though, this is from a very high level overview. If you feel like this won't be an issue, I don't have any problems with this :) > Also please note that, even if everything else was formally supported, > it would still be a good idea to add this support early (possibly with > a warning or gate or similar if not intended to be used by end users > yet) so that we have the first big-endian target around. > > P.S. This is my first time sending an email to a mailing list, sorry > > if I mucked something up. > > The content looks fine :) > > However, I think the proper `In-Reply-To` header is not there so Lore > gets confused -- did you use the suggested parameters at the bottom of > e.g. [1]? > > [1] https://lore.kernel.org/rust-for-linux/CAM+6MoE1DyOay-fMWQP0hsenz174hSuGJnKM7symh0C-y1mqZw@mail.gmail.com/ Yes, I appear to have missed copying the `In-Reply-To` header in this reply thread. Sorry about that. ^ permalink raw reply [flat|nested] 41+ messages in thread
end of thread, other threads:[~2024-02-09 21:41 UTC | newest] Thread overview: 41+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-10-20 15:50 [PATCH v4 0/2] Rust enablement for AArch64 Jamie Cunliffe 2023-10-20 15:50 ` [PATCH v4 1/2] rust: Refactor the build target to allow the use of builtin targets Jamie Cunliffe 2023-10-22 10:55 ` Catalin Marinas 2023-10-22 11:07 ` Ingo Molnar 2023-10-31 0:24 ` Trevor Gross 2023-10-31 11:58 ` Catalin Marinas 2023-10-31 19:01 ` Trevor Gross 2023-12-12 16:47 ` Will Deacon 2024-01-22 9:17 ` Trevor Gross 2024-01-25 3:19 ` WANG Rui 2024-01-26 19:37 ` Masahiro Yamada 2024-01-27 5:08 ` WANG Rui 2024-01-27 17:31 ` Miguel Ojeda 2024-01-22 9:29 ` Alice Ryhl 2024-01-24 9:12 ` Masahiro Yamada 2023-10-20 15:50 ` [PATCH v4 2/2] arm64: rust: Enable Rust support for AArch64 Jamie Cunliffe 2023-10-20 16:45 ` Catalin Marinas 2023-10-21 13:40 ` Miguel Ojeda 2023-10-22 10:48 ` Catalin Marinas 2023-10-22 12:14 ` Miguel Ojeda 2023-10-20 17:21 ` Andrew Lunn 2023-10-20 18:33 ` Boqun Feng 2023-10-20 18:47 ` Andrew Lunn 2023-10-21 12:50 ` Alice Ryhl 2023-10-21 13:41 ` Miguel Ojeda 2023-10-21 16:03 ` Andrew Lunn 2023-10-22 12:57 ` Miguel Ojeda 2023-10-24 0:57 ` Stephen Boyd 2023-10-25 23:55 ` Boqun Feng 2023-11-01 15:04 ` Linus Walleij 2023-10-31 18:31 ` Matthew Maurer 2023-11-28 18:29 ` Boqun Feng 2023-12-13 19:00 ` Miguel Ojeda 2024-01-22 2:01 ` Fabien Parent 2024-01-22 5:27 ` Behme Dirk (CM/ESO2) 2024-01-22 9:30 ` Alice Ryhl 2024-02-09 17:38 ` [PATCH v4 0/2] Rust enablement " Catalin Marinas 2024-02-09 21:41 ` Miguel Ojeda -- strict thread matches above, loose matches on Subject: below -- 2023-10-24 14:17 [PATCH v4 2/2] arm64: rust: Enable Rust support " Pratham Patel 2023-10-24 15:19 ` Miguel Ojeda 2023-10-25 2:01 ` Pratham Patel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).