rust-vmm / mshv

Crates for Microsoft Hypervisor ioctls and bindings
Apache License 2.0
29 stars 11 forks source link

Derive zerocopy::{AsBytes, FromBytes} for all structs #65

Open smmalis37 opened 1 year ago

smmalis37 commented 1 year ago

It would be very helpful, and allow us to reduce the amount of unsafe code we have, if more structs could derive AsBytes and FromBytes, specifically those in https://github.com/rust-vmm/mshv/blob/main/mshv-bindings/src/bindings.rs and https://github.com/rust-vmm/mshv/blob/main/mshv-bindings/src/regs.rs.

liuw commented 1 year ago

CC @russell-islam

liuw commented 1 year ago

@smmalis37 I've gone through regs.rs and added those where I can. However bindings.rs is generated by bindgen. I'm a bit hesitant to modify it by hand and only to be overwritten later.

liuw commented 1 year ago

This looks interesting https://github.com/rust-lang/rust-bindgen/pull/2059 but there is no CLI option exposed in bindgen.

smmalis37 commented 1 year ago

There's also https://github.com/rust-lang/rust-bindgen/issues/2168

russell-islam commented 1 year ago

For generating bindings we need to have the support to derive these fields. We can not manually do it every time.

liuw commented 1 year ago

It looks like the issue on bindgen's side is progressing. I'm going to leave this issue open for now.