* [PATCH 1/2] rust: arch/um: use 'static' relocation model for uml modules [not found] <20240903130606.292935-1-zig@iorw.io> @ 2024-09-03 13:06 ` Zigit Zo 2024-09-04 9:30 ` Geert Stappers 2024-09-03 13:06 ` [PATCH 2/2] rust: arch/um: use 'large' code model for uml Zigit Zo 1 sibling, 1 reply; 4+ messages in thread From: Zigit Zo @ 2024-09-03 13:06 UTC (permalink / raw) To: ojeda, bjorn3_gh, richard, anton.ivanov, johannes, tglx, mingo, nathan, ndesaulniers, gary Cc: zig, rust-for-linux, linux-um, llvm, x86, linux-kernel In the x86_64 UML, kernel modules compiled with Rust will currently generate some R_X86_64_GOTPCREL relocations, which will then be rejected by the kernel. And because of the kernel modules of UML are only got handled by the UML itself, relocation model 'static' can work as expected other than 'pie'. --- arch/um/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/um/Makefile b/arch/um/Makefile index 00b63bac5eff..b04b1d4d6dfe 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -63,7 +63,7 @@ KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \ -Din6addr_loopback=kernel_in6addr_loopback \ -Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr -KBUILD_RUSTFLAGS += -Crelocation-model=pie +KBUILD_RUSTFLAGS_KERNEL += -Crelocation-model=pie KBUILD_AFLAGS += $(ARCH_INCLUDE) -- 2.46.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] rust: arch/um: use 'static' relocation model for uml modules 2024-09-03 13:06 ` [PATCH 1/2] rust: arch/um: use 'static' relocation model for uml modules Zigit Zo @ 2024-09-04 9:30 ` Geert Stappers 2024-09-04 12:28 ` Zigit Zo 0 siblings, 1 reply; 4+ messages in thread From: Geert Stappers @ 2024-09-04 9:30 UTC (permalink / raw) To: Zigit Zo Cc: ojeda, bjorn3_gh, richard, anton.ivanov, johannes, tglx, mingo, nathan, ndesaulniers, gary, rust-for-linux, linux-um, llvm, x86, linux-kernel On Tue, Sep 03, 2024 at 09:06:05PM +0800, Zigit Zo wrote: > In the x86_64 UML, kernel modules compiled with Rust will currently > generate some R_X86_64_GOTPCREL relocations, which will then be rejected > by the kernel. > > And because of the kernel modules of UML are only got handled by the UML > itself, relocation model 'static' can work as expected other than 'pie'. > --- > diff --git a/arch/um/Makefile b/arch/um/Makefile > index 00b63bac5eff..b04b1d4d6dfe 100644 > --- a/arch/um/Makefile > +++ b/arch/um/Makefile > @@ -63,7 +63,7 @@ KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \ > -Din6addr_loopback=kernel_in6addr_loopback \ > -Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr > > -KBUILD_RUSTFLAGS += -Crelocation-model=pie > +KBUILD_RUSTFLAGS_KERNEL += -Crelocation-model=pie > > KBUILD_AFLAGS += $(ARCH_INCLUDE) > > -- I failed to match the actual change with the commit message. Consider that ignorance on my side. I see a problem in just renaming a variable, might be my problem. Thing is that removal of 'KBUILD_RUSTFLAG += ' feels wrong, hence this posting. Groeten Geert Stappers -- Silence is hard to parse ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] rust: arch/um: use 'static' relocation model for uml modules 2024-09-04 9:30 ` Geert Stappers @ 2024-09-04 12:28 ` Zigit Zo 0 siblings, 0 replies; 4+ messages in thread From: Zigit Zo @ 2024-09-04 12:28 UTC (permalink / raw) To: stappers Cc: anton.ivanov, bjorn3_gh, gary, johannes, linux-kernel, linux-um, llvm, mingo, nathan, ndesaulniers, ojeda, richard, rust-for-linux, tglx, x86, zig On Wed, Sep 04, 2024 at 11:30:12AM +0200, Geert Stappers wrote: > I failed to match the actual change with the commit message. Consider > that ignorance on my side. FYI, I'm using the master branch of the upstream, but yes it's in the 'rust-next' or other branches as well, so maybe not a big deal IMO. Of what 'https://rust-for-linux.com/branches' says, maybe I'll use the 'rust-next' branch for the next time, thanks for pointing out! > I see a problem in just renaming a variable, might be my problem. Thing > is that removal of 'KBUILD_RUSTFLAG += ' feels wrong, hence this posting. I think this is fine, the 'KBUILD_RUSTFLAG' controls the 'PIE' flag for both the kernel itself and the loadable modules. And yes, that's the only way I can make the 'PIE' flag out of the modules while keeping the UML kernel itself works, and the 'scripts/Makefile.lib' I tought has placed those flags correctly. What about adding a 'static' flag to the 'arch/um/Makefile' explicitly, --- KBUILD_RUSTFLAGS_KERNEL += -Crelocation-model=pie KBUILD_RUSTFLAGS_MODULE += -Crelocation-model=static --- but that's just a redundant of the already defined 'KBUILD_RUSTFLAGS'. Have no more ideas what can this flag goes wrong :( ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] rust: arch/um: use 'large' code model for uml [not found] <20240903130606.292935-1-zig@iorw.io> 2024-09-03 13:06 ` [PATCH 1/2] rust: arch/um: use 'static' relocation model for uml modules Zigit Zo @ 2024-09-03 13:06 ` Zigit Zo 1 sibling, 0 replies; 4+ messages in thread From: Zigit Zo @ 2024-09-03 13:06 UTC (permalink / raw) To: ojeda, bjorn3_gh, richard, anton.ivanov, johannes, tglx, mingo, nathan, ndesaulniers, gary Cc: zig, rust-for-linux, linux-um, llvm, x86, linux-kernel The Rust modules compiled against UML should be 'large', without this the compiler will generate some R_X86_64_32S relocations, but UML is running at userspace with signed-address larger than zero, therefore makes '__write_relocate_add' treating the relocation as overflowed. --- arch/um/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/um/Makefile b/arch/um/Makefile index b04b1d4d6dfe..c2a9f2102ba7 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -32,6 +32,7 @@ endif ifdef CONFIG_64BIT KBUILD_CFLAGS += -mcmodel=large + KBUILD_RUSTFLAGS += -Ccode-model=large endif HOST_DIR := arch/$(HEADER_ARCH) -- 2.46.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-04 12:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20240903130606.292935-1-zig@iorw.io>
2024-09-03 13:06 ` [PATCH 1/2] rust: arch/um: use 'static' relocation model for uml modules Zigit Zo
2024-09-04 9:30 ` Geert Stappers
2024-09-04 12:28 ` Zigit Zo
2024-09-03 13:06 ` [PATCH 2/2] rust: arch/um: use 'large' code model for uml Zigit Zo
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).