From a88f30ece4fc92bfdc8ac3f631204a7932b4ff33 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Tue, 26 Nov 2024 17:48:15 +0000 Subject: [PATCH] Don't assume that misaligned address in error is virtual. --- src/transport/pci.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/transport/pci.rs b/src/transport/pci.rs index 59bd78d1..7c6e6e94 100644 --- a/src/transport/pci.rs +++ b/src/transport/pci.rs @@ -442,7 +442,7 @@ fn get_bar_region( let vaddr = unsafe { H::mmio_phys_to_virt(paddr, struct_info.length as usize) }; if vaddr.as_ptr() as usize % align_of::() != 0 { return Err(VirtioPciError::Misaligned { - vaddr, + address: vaddr.as_ptr() as usize, alignment: align_of::(), }); } @@ -489,13 +489,11 @@ pub enum VirtioPciError { /// The offset for some capability was greater than the length of the BAR. #[error("Capability offset greater than BAR length.")] BarOffsetOutOfRange, - /// The virtual address was not aligned as expected. - #[error( - "Virtual address {vaddr:#018?} was not aligned to a {alignment} byte boundary as expected." - )] + /// The address was not aligned as expected. + #[error("Address {address:#018} was not aligned to a {alignment} byte boundary as expected.")] Misaligned { - /// The virtual address in question. - vaddr: NonNull, + /// The address in question. + address: usize, /// The expected alignment in bytes. alignment: usize, },