mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
hypervisor: mshv: support reading and writing guest memory in emulator
We don't have an easy way to figure out if a GPA points to normal memory or device memory, but the guest's normal memory regions shouldn't overlap with device regions. We can simply try to do a normal memory read / write, and proceed to do device memory read / write if that fails. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
07a09eda27
commit
b59243f6cf
@ -586,10 +586,12 @@ impl<'a> PlatformEmulator for MshvEmulatorContext<'a> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if let Some(vmmops) = &self.vcpu.vmmops {
|
if let Some(vmmops) = &self.vcpu.vmmops {
|
||||||
|
if vmmops.guest_mem_read(gpa, data).is_err() {
|
||||||
vmmops
|
vmmops
|
||||||
.mmio_read(gpa, data)
|
.mmio_read(gpa, data)
|
||||||
.map_err(|e| PlatformError::MemoryReadFailure(e.into()))?;
|
.map_err(|e| PlatformError::MemoryReadFailure(e.into()))?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -604,10 +606,12 @@ impl<'a> PlatformEmulator for MshvEmulatorContext<'a> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if let Some(vmmops) = &self.vcpu.vmmops {
|
if let Some(vmmops) = &self.vcpu.vmmops {
|
||||||
|
if vmmops.guest_mem_write(gpa, data).is_err() {
|
||||||
vmmops
|
vmmops
|
||||||
.mmio_write(gpa, data)
|
.mmio_write(gpa, data)
|
||||||
.map_err(|e| PlatformError::MemoryWriteFailure(e.into()))?;
|
.map_err(|e| PlatformError::MemoryWriteFailure(e.into()))?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user