From 7527d20d2533de1895857847d83f44b40c66861f Mon Sep 17 00:00:00 2001 From: Hsy-Intel Date: Fri, 9 Aug 2024 18:35:41 +0800 Subject: [PATCH] Avoid generating Cmp_rm32_imm32 instruction --- ostd/src/bus/mmio/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ostd/src/bus/mmio/mod.rs b/ostd/src/bus/mmio/mod.rs index 8518e8c72..80c4c57bf 100644 --- a/ostd/src/bus/mmio/mod.rs +++ b/ostd/src/bus/mmio/mod.rs @@ -63,8 +63,8 @@ fn iter_range(range: Range) { while current > range.start { current -= 0x100; // SAFETY: It only read the value and judge if the magic value fit 0x74726976 - let value = unsafe { *(paddr_to_vaddr(current) as *const u32) }; - if value == VIRTIO_MMIO_MAGIC { + let magic = unsafe { core::ptr::read_volatile(paddr_to_vaddr(current) as *const u32) }; + if magic == VIRTIO_MMIO_MAGIC { // SAFETY: It only read the device id let device_id = unsafe { *(paddr_to_vaddr(current + 8) as *const u32) }; device_count += 1;