On 3/21/25 5:19 PM, Andrew Hamilton wrote:
Hello,

Personally, I really like this idea.

I second that. One of the areas I think (I am not a Rust programmer) Rust could really help GRUB is in the many large and imposing parsing routines in modules. From what I have read and heard, Rust could improve these routines, make them safer and easier to read.

Just my $0.02 worth

Ross


I'm not yet a Rust programmer but I am happy to learn... and perhaps
there are others like me that would take this as an opportunity to
learn while doing something like porting a Grub module from C to Rust
if we had that framework in place.

It seems like a nice way to hopefully eliminate or reduce certain
kinds of bugs as well.

It may also be a nice opportunity to make some common processes with
the Rust community like perhaps using rustfmt as the coding standard
to reduce burden on developers and maintainers to deal with formatting
and focus on functionality.

I like that you have a small demo module as well in what you did, it
shows a nice starting point for people wanting to take on a module if
this gains traction like I hope it will.

Thanks!
Andrew

On Fri, Mar 21, 2025 at 3:53 PM Vladimir 'phcoder' Serbinenko
<phco...@gmail.com> wrote:

Hello, I was playing with adding Rust embedded in GRUB. I’ve pushed results to 
2 repos:
Module goes to 
https://urldefense.com/v3/__https://github.com/phcoder/grub-rust-hello/tree/master__;!!ACWV5N9M2RV99hQ!Nv5f27pVO2opFtugzq3sbD1hCuUm9TgOXiG7lgGEkT5qszUWwUpBHwyi_AhneAQ7jA3A0iAiaGvbpHlQfNqu$
Changes in GRUB are found at 
https://urldefense.com/v3/__https://github.com/phcoder/GRUB/tree/rust__;!!ACWV5N9M2RV99hQ!Nv5f27pVO2opFtugzq3sbD1hCuUm9TgOXiG7lgGEkT5qszUWwUpBHwyi_AhneAQ7jA3A0iAiaGvbpG5AqD5G$
Notes on implementation:
Only i386-pc is implemented right now but it’s not a technical limit, just 
others are not implemented yet.
I changed GRUB to use ET_DYN (.so) binaries as modules instead of ET_REL (.o).
I disabled mregparm=3. -Z regparm=3 in Rust generally works but the calls to 
memcpy() still uses regparm=0 calling convention. Perhaps it’s a bug on Rust 
side, perhaps we need an adapter on our side.
It’s compiled with panic=abort. Unwinding panics require rust_eh_personality 
that isn’t implemented yet.
src/lib.rs is an example of hello world and grub_lib.rs is a grub-rust adapter. 
Ideally they should be in separate crates
Every module now pulls in rust runtime. Idk how to switch to a shared runtime
Consider it more an experiment and request for comments than a working product. 
I would be interested to hear any comments. Especially it’s interesting to hear 
from Rust folks as to how to make it more idiomatic Rust.

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://urldefense.com/v3/__https://lists.gnu.org/mailman/listinfo/grub-devel__;!!ACWV5N9M2RV99hQ!Nv5f27pVO2opFtugzq3sbD1hCuUm9TgOXiG7lgGEkT5qszUWwUpBHwyi_AhneAQ7jA3A0iAiaGvbpGDuhTZ8$

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://urldefense.com/v3/__https://lists.gnu.org/mailman/listinfo/grub-devel__;!!ACWV5N9M2RV99hQ!Nv5f27pVO2opFtugzq3sbD1hCuUm9TgOXiG7lgGEkT5qszUWwUpBHwyi_AhneAQ7jA3A0iAiaGvbpGDuhTZ8$


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to