Skip to content

Commit

Permalink
virtio: fix fuzz test
Browse files Browse the repository at this point in the history
Signed-off-by: Jiaqi Gao <[email protected]>
  • Loading branch information
gaojiaqi7 committed Jan 2, 2025
1 parent 96d9172 commit 4bd8439
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/devices/virtio/fuzz/fuzz_targets/fuzz-virtio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/devices/virtio/src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl MemoryRegion {
fn mmio_read<T: Copy + Clone>(&self, offset: u64) -> Result<T, MemoryRegionError> {
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,
))
}
}
Expand Down Expand Up @@ -235,7 +235,7 @@ impl MemoryRegion {
fn mmio_write<T>(&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,
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/devices/vsock/fuzz/fuzz_targets/fuzz-vsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 4bd8439

Please sign in to comment.