mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-01-12 16:45:31 +00:00
kvm: fix and test set_identity_map_addr
The kernel expects a pointer to a physical address, not a physical address directly in the ioctl argument. TEST=cargo test -p kvm BUG=chromium:800626 Change-Id: I4a7298149373c00b5b9c634cd1dead7053d053c3 Reviewed-on: https://chromium-review.googlesource.com/893215 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
This commit is contained in:
parent
e0983c7625
commit
e07bd96ea9
1 changed files with 9 additions and 1 deletions
|
@ -342,7 +342,7 @@ impl Vm {
|
|||
pub fn set_identity_map_addr(&self, addr: GuestAddress) -> Result<()> {
|
||||
// Safe because we know that our file is a VM fd and we verify the return result.
|
||||
let ret = unsafe {
|
||||
ioctl_with_val(self, KVM_SET_IDENTITY_MAP_ADDR(), addr.offset() as u64)
|
||||
ioctl_with_ref(self, KVM_SET_IDENTITY_MAP_ADDR(), &(addr.offset() as u64))
|
||||
};
|
||||
if ret == 0 {
|
||||
Ok(())
|
||||
|
@ -1097,4 +1097,12 @@ mod tests {
|
|||
assert!(mmap_size >= page_size);
|
||||
assert!(mmap_size % page_size == 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_identity_map_addr() {
|
||||
let kvm = Kvm::new().unwrap();
|
||||
let gm = GuestMemory::new(&vec![(GuestAddress(0), 0x10000)]).unwrap();
|
||||
let vm = Vm::new(&kvm, gm).unwrap();
|
||||
vm.set_identity_map_addr(GuestAddress(0x20000)).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue