Page 1 of 1

Mapping guest physical memory to host virtual memory

PostPosted: 15. Apr 2019, 08:40
by matthiasp
Hi all,

I'm trying to implement a basic version of the virtio 1.0 standard which only supports PCI devices.
The implementation is based on the QEMU virtio implementation.

To achieve high efficiency it's necessary to map regions of the physical guest memory to virtual host memory to avoid copying data.
In QEMU, guest physical addresses can be mapped with cpu_physical_memory_map(). This allows any address range to be mapped to host memory.
The only equivalent functions I have found in VirtualBox (PDMDevHlpPhysGCPhys2CCPtr(), MMR3HyperMapGCPhys()) require the address to be page aligned.

It would be nice, if I don't have to deal with page alignment myself. Are there any functions I'm missing which allow any address range to be mapped from guest physical to host virtual memory?

Best,
matthias

Re: Mapping guest physical memory to host virtual memory

PostPosted: 11. Jul 2019, 13:18
by noteirak
Moved to "VirtualBox OSE".

Re: Mapping guest physical memory to host virtual memory

PostPosted: 19. Sep 2019, 04:44
by flyee6
I also encountered the same problem, but I have not found a suitable solution. Does the virtualbox have a function similar to the cpu_physical_memory_map() ?
Using MMR3HyperMapGCPhys will crash when accessing 'if (pVM->mm.s.offHyperNextStatic + cbAligned >= pVM->mm.s.cbHyperArea)' .