haxm: fix future incompatibility warning
use of `unaligned_references` will be blocked soon and spits out a
warning during compiling. fix it in haxm.
Test: Compiled and ran with haxm enabled.
Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Change-Id: Ia887cff1ce01e6c14a9cf4978bf49835e996dd5a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4324279
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
diff --git a/hypervisor/src/haxm/vcpu.rs b/hypervisor/src/haxm/vcpu.rs
index 551043a..6c7a721 100644
--- a/hypervisor/src/haxm/vcpu.rs
+++ b/hypervisor/src/haxm/vcpu.rs
@@ -233,18 +233,11 @@
operation: IoOperation::Read,
}) {
// Safe because we know this is an mmio read, so we need to put data into the
- // "value" field of the hax_fastmmio. The "value" field is a u64, so casting
- // as a &mut [u8] of len 8 is safe.
- // TODO(b/250085118): remove this clippy allow as it's allowing potentially
- // problematic behavior.
- #[allow(unaligned_references)]
- let buffer = unsafe {
- std::slice::from_raw_parts_mut(
- &mut (*mmio).__bindgen_anon_1.value as *mut u64 as *mut u8,
- 8,
- )
- };
- buffer[..size].copy_from_slice(&data[..size]);
+ // "value" field of the hax_fastmmio.
+ let data = u64::from_ne_bytes(data);
+ unsafe {
+ (*mmio).__bindgen_anon_1.value = data;
+ }
}
Ok(())
}