From 4bd8439b9e565f3f0b43c5d7db3e9bed794ccb5b Mon Sep 17 00:00:00 2001 From: Jiaqi Gao Date: Thu, 2 Jan 2025 01:30:59 -0500 Subject: [PATCH] virtio: fix fuzz test Signed-off-by: Jiaqi Gao --- src/devices/virtio/fuzz/fuzz_targets/fuzz-virtio.rs | 2 +- src/devices/virtio/src/mem.rs | 4 ++-- src/devices/vsock/fuzz/fuzz_targets/fuzz-vsock.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/devices/virtio/fuzz/fuzz_targets/fuzz-virtio.rs b/src/devices/virtio/fuzz/fuzz_targets/fuzz-virtio.rs index 3a022202..483d5d8a 100644 --- a/src/devices/virtio/fuzz/fuzz_targets/fuzz-virtio.rs +++ b/src/devices/virtio/fuzz/fuzz_targets/fuzz-virtio.rs @@ -15,7 +15,7 @@ fuzz_target!(|data: &[u8]| { let ptr = (ptr_vec.as_ptr() as u64 & PTR_ALIGN_VAR) + PTR_OFFSET as u64; let tmp = unsafe { core::slice::from_raw_parts_mut(ptr as *mut u8, DATA_LEN) }; - let common_addr = ptr + 0x10c; + let common_addr = ptr + 0x100; let paddr = ptr + PAGE_SIZE as u64; init(paddr as usize, TD_PAYLOAD_DMA_SIZE); // COMMON_HEADER.try_init_once(|| ptr).expect("init error"); diff --git a/src/devices/virtio/src/mem.rs b/src/devices/virtio/src/mem.rs index d25c686b..ca47efeb 100644 --- a/src/devices/virtio/src/mem.rs +++ b/src/devices/virtio/src/mem.rs @@ -181,7 +181,7 @@ impl MemoryRegion { fn mmio_read(&self, offset: u64) -> Result { unsafe { Ok(core::ptr::read_volatile( - (pci::get_fuzz_seed_address() + 0x10c + offset) as *const T, + (pci::get_fuzz_seed_address() + 0x100 + offset) as *const T, )) } } @@ -235,7 +235,7 @@ impl MemoryRegion { fn mmio_write(&self, offset: u64, value: T) -> Result<(), MemoryRegionError> { unsafe { core::ptr::write_volatile( - (pci::get_fuzz_seed_address() + 0x10c + offset) as *mut T, + (pci::get_fuzz_seed_address() + 0x100 + offset) as *mut T, value, ); } diff --git a/src/devices/vsock/fuzz/fuzz_targets/fuzz-vsock.rs b/src/devices/vsock/fuzz/fuzz_targets/fuzz-vsock.rs index d4da03e6..96e5b35e 100644 --- a/src/devices/vsock/fuzz/fuzz_targets/fuzz-vsock.rs +++ b/src/devices/vsock/fuzz/fuzz_targets/fuzz-vsock.rs @@ -229,7 +229,7 @@ fuzz_target!(|data: &[u8]| { let ptr = (ptr.as_ptr() as u64 & PTR_ALIGN_VAR) + PTR_OFFSET as u64; let data = unsafe { core::slice::from_raw_parts_mut(ptr as *mut u8, DATA_LEN) }; data[..tmp.len()].copy_from_slice(&tmp); - let common_addr = ptr + 0x10c; + let common_addr = ptr + 0x100; let paddr = ptr + PAGE_SIZE as u64; init(paddr as usize, TD_PAYLOAD_DMA_SIZE); COMMON_HEADER.try_init_once(|| ptr).expect("init error");