mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 03:12:27 +00:00
vhost_user_backend: Update vmm_va_to_gpa with adding offset
The original logic does not has any problem without offset, since the current offset is zero. However, if offset is not zero, while convert vmm address to backend process address, it needs to consider the offset. Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
This commit is contained in:
parent
4a1af7f63c
commit
527dd68ce1
@ -172,6 +172,7 @@ impl<S: VhostUserBackend> VhostUserDaemon<S> {
|
||||
struct AddrMapping {
|
||||
vmm_addr: u64,
|
||||
size: u64,
|
||||
offset: u64,
|
||||
}
|
||||
|
||||
struct Memory {
|
||||
@ -538,7 +539,7 @@ impl<S: VhostUserBackend> VhostUserHandler<S> {
|
||||
if let Some(memory) = &self.memory {
|
||||
for mapping in memory.mappings.iter() {
|
||||
if vmm_va >= mapping.vmm_addr && vmm_va < mapping.vmm_addr + mapping.size {
|
||||
return Ok(vmm_va - mapping.vmm_addr);
|
||||
return Ok(vmm_va - mapping.vmm_addr + mapping.offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -625,7 +626,8 @@ impl<S: VhostUserBackend> VhostUserSlaveReqHandler for VhostUserHandler<S> {
|
||||
regions.push((g_addr, len, Some(f_off)));
|
||||
mappings.push(AddrMapping {
|
||||
vmm_addr: region.user_addr,
|
||||
size: region.memory_size + region.mmap_offset,
|
||||
size: region.memory_size,
|
||||
offset: region.mmap_offset,
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user