Skip to content

Commit

Permalink
Fix asserts in x86_64/hypercalls
Browse files Browse the repository at this point in the history
  • Loading branch information
jaszczyk-grzegorz authored and qwandor committed Jan 30, 2025
1 parent cb0c61a commit b47d59a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transport/x86_64/hypercalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ pub struct HypIoRegion {
impl HypIoRegion {
pub fn read<T: FromBytes>(self, offset: usize) -> T {
assert!(offset + size_of::<T>() <= self.size);
assert!(size_of::<T>() < HYP_IO_MAX);
assert!(size_of::<T>() <= HYP_IO_MAX);

let data = hyp_io_read(self.paddr + offset, size_of::<T>());
T::read_from_prefix(data.as_bytes()).unwrap().0
}

pub fn write<T: IntoBytes + Immutable>(self, offset: usize, value: T) {
assert!(offset + size_of::<T>() <= self.size);
assert!(size_of::<T>() < HYP_IO_MAX);
assert!(size_of::<T>() <= HYP_IO_MAX);

let mut data = 0;
data.as_mut_bytes()[..size_of::<T>()].copy_from_slice(value.as_bytes());
Expand Down

0 comments on commit b47d59a

Please sign in to comment.