[PATCH 0/2] rust: arch/um: Rust modules support for UML

Zigit Zo posted 2 patches 1 year, 3 months ago
Only 0 patches received!
arch/um/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH 0/2] rust: arch/um: Rust modules support for UML
Posted by Zigit Zo 1 year, 3 months ago
The series make Rust modules running under x86_64 UML, as a supplement
for the previous work:
- https://lore.kernel.org/rust-for-linux/20221217044436.4138642-1-davidgow@google.com/

The previous work by David (many thanks!) has made the Rust UML compiles,
and for the builtin modules, it works as expected. But for loadable
modules, the UML will complain

  'Unknown rela relocation: 9'

when we try to 'insmod rust_print.ko'. That's because the modules are
compiled against '-Crelocation-model=pie', makes the LLVM treat the
modules as PIE executables, but they are just static modules.

Besides, the Rust's code model for x86_64 UML is still 'kernel', leading
some relocations "overflowed", we keep it the same as 'KBUILD_CFLAGS'
set in UML ('large' here) to address it.

Now we can test our Rust modules in UML.

Regards,
-- Zigit

Zigit Zo (2):
  rust: arch/um: use 'static' relocation model for uml modules
  rust: arch/um: use 'large' code model for uml

 arch/um/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


base-commit: 431c1646e1f86b949fa3685efc50b660a364c2b6
-- 
2.46.0
Re: [PATCH 0/2] rust: arch/um: Rust modules support for UML
Posted by Trevor Gross 1 year, 3 months ago
On Tue, Sep 3, 2024 at 9:10 AM Zigit Zo <zig@iorw.io> wrote:
>
> The series make Rust modules running under x86_64 UML, as a supplement
> for the previous work:
> - https://lore.kernel.org/rust-for-linux/20221217044436.4138642-1-davidgow@google.com/
>
> The previous work by David (many thanks!) has made the Rust UML compiles,
> and for the builtin modules, it works as expected. But for loadable
> modules, the UML will complain
>
>   'Unknown rela relocation: 9'
>
> when we try to 'insmod rust_print.ko'. That's because the modules are
> compiled against '-Crelocation-model=pie', makes the LLVM treat the
> modules as PIE executables, but they are just static modules.
>
> Besides, the Rust's code model for x86_64 UML is still 'kernel', leading
> some relocations "overflowed", we keep it the same as 'KBUILD_CFLAGS'
> set in UML ('large' here) to address it.
>
> Now we can test our Rust modules in UML.
>
> Regards,
> -- Zigit
>
> Zigit Zo (2):
>   rust: arch/um: use 'static' relocation model for uml modules
>   rust: arch/um: use 'large' code model for uml

Hi Zigit,

Thanks for sending this. It looks like the patches may have gotten
split from the cover letter because the In-Reply-To header isn't exact
for whatever reason (the two patches reply to
<20240903130606.292935-1-zig@iorw.io>, but the original has ID
<62F5EEA0B866E9E0+20240903130606.292935-1-zig@iorw.io>).

No worries for this initial rev, but just double check this if there
is a v2 :) archive links of the individual patches for reference:

[1/2]: https://lore.kernel.org/lkml/FD7D773099A0C7EC+20240903130606.292935-2-zig@iorw.io/
[2/2]: https://lore.kernel.org/lkml/54FC087D02C52990+20240903130606.292935-3-zig@iorw.io/

- Trevor