Mapping guest physical memory to host virtual memory

Discussions related to using the OSE version of VirtualBox.
Post Reply
matthiasp
Posts: 3
Joined: 28. Feb 2019, 09:40

Mapping guest physical memory to host virtual memory

Post 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
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Mapping guest physical memory to host virtual memory

Post by noteirak »

Moved to "VirtualBox OSE".
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
flyee6
Posts: 1
Joined: 19. Sep 2019, 04:35

Re: Mapping guest physical memory to host virtual memory

Post 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)' .
Post Reply