diff --git a/usr.sbin/bhyve/pci_passthru.h b/usr.sbin/bhyve/pci_passthru.h --- a/usr.sbin/bhyve/pci_passthru.h +++ b/usr.sbin/bhyve/pci_passthru.h @@ -11,6 +11,14 @@ #include "pci_emul.h" +struct passthru_mmio_mapping { + vm_paddr_t gpa; /* guest physical address */ + void *gva; /* guest virtual address */ + vm_paddr_t hpa; /* host physical address */ + void *hva; /* guest virtual address */ + vm_paddr_t len; +}; + struct passthru_softc; typedef int (*cfgread_handler)(struct passthru_softc *sc, @@ -24,6 +32,8 @@ int coff, int bytes, uint32_t *rv); int passthru_cfgwrite_emulate(struct passthru_softc *sc, struct pci_devinst *pi, int coff, int bytes, uint32_t val); +struct passthru_mmio_mapping *passthru_get_mmio(struct passthru_softc *sc, + int num); struct pcisel *passthru_get_sel(struct passthru_softc *sc); int set_pcir_handler(struct passthru_softc *sc, int reg, int len, cfgread_handler rhandler, cfgwrite_handler whandler); diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c --- a/usr.sbin/bhyve/pci_passthru.c +++ b/usr.sbin/bhyve/pci_passthru.c @@ -78,6 +78,8 @@ #define MSIX_TABLE_COUNT(ctrl) (((ctrl) & PCIM_MSIXCTRL_TABLE_SIZE) + 1) #define MSIX_CAPLEN 12 +#define PASSTHRU_MMIO_MAX 2 + static int pcifd = -1; struct passthru_softc { @@ -94,6 +96,7 @@ } psc_msix; struct pcisel psc_sel; + struct passthru_mmio_mapping psc_mmio_map[PASSTHRU_MMIO_MAX]; cfgread_handler psc_pcir_rhandler[PCI_REGMAX + 1]; cfgwrite_handler psc_pcir_whandler[PCI_REGMAX + 1]; }; @@ -660,6 +663,15 @@ return (error); } +struct passthru_mmio_mapping * +passthru_get_mmio(struct passthru_softc *sc, int num) +{ + assert(sc != NULL); + assert(num < PASSTHRU_MMIO_MAX); + + return (&sc->psc_mmio_map[num]); +} + struct pcisel * passthru_get_sel(struct passthru_softc *sc) {