gasp_map_vdma()

Updated: October 28, 2024

Map a guest-physical address range into the qvm process address space for virtual hardware access

Synopsis:

#include <qvm/gasp.h>
void* gasp_map_vdma(const vdev_t *vdev,
                    int prot,
                    uint64_t guest_paddr,
                    size_t length)

Arguments:

vdev
A pointer to a structure for a vdev that will make DMA-like transactions.
prot
PROT_* protection bits for the mappings, optionally GMF_MAP_ANY.
guest_paddr
The starting guest-physical address to be mapped in.
length
The number of bytes to be mapped in.

Description:

Use this function to map a guest-physical address range into the qvm process (guest-physical) address space to provide virtual hardware access for vdevs that will make DMA-like transactions. Use this function if your vdev argument is not NULL. If your vdev argument is NULL, use gasp_map_sys().

If you need to obtain information about the host-physical addresses, use gasp_map_contig().

When deciding whether to use gasp_map_sys() or gasp_map_vdma(), consider the following:
  • If you have allocated the guest-physical address, you should use gasp_map_sys(), unless you're in a context where it makes sense to allow the guest to decide if mapping is permitted.
  • If the guest has provided the guest-physical address you want to map, you should use gasp_map_vdma(), because with this function the mapping goes through the guest-controlled simulated IOMMU.

The above are guidelines, and your design may require that you use the function not recommended here. If you don't follow the guidelines, though, be sure that you can justify your decision, and understand the implications of not following them.

Call gasp_unmap() to unmap the address range.

Returns:

A qvm process pointer that maps the guest-physical address range, or NULL if unsuccessful.

  翻译: