Re: [PATCH 2/2] samples: rust: fix endianness issue in rust_driver_pci
From: Dirk Behme
Date: Wed Dec 10 2025 - 09:14:55 EST
On 10.12.25 12:25, Marko Turk wrote:
> MMIO backend of PCI Bar always assumes little-endian devices and
> will convert to CPU endianness automatically. Remove the u32::from_le
> conversion which would cause a bug on big-endian machines.
>
> Signed-off-by: Marko Turk <mt@xxxxxxxxxxxxxx>
> Fixes: 685376d18e9a ("samples: rust: add Rust PCI sample driver")
> ---
> samples/rust/rust_driver_pci.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci.rs
> index 5823787bea8e..fa677991a5c4 100644
> --- a/samples/rust/rust_driver_pci.rs
> +++ b/samples/rust/rust_driver_pci.rs
> @@ -48,7 +48,7 @@ fn testdev(index: &TestIndex, bar: &Bar0) -> Result<u32> {
> // Select the test.
> bar.write8(index.0, Regs::TEST);
>
> - let offset = u32::from_le(bar.read32(Regs::OFFSET)) as usize;
> + let offset = bar.read32(Regs::OFFSET) as usize;
Yes, dropping from_le() is what we talked about:
Reviewed-by: Dirk Behme <dirk.behme@xxxxxxxxxxxx>
Thanks
Dirk
P.S.: I'm not sure if the `Fixes` is required: As far as I understood
there are no big-endian machines supported by Rust, yet. On all other
supported little-endian machines this is a no-op. So I think it is at
least debatable if this is a "bug" which needs back porting.