diff --git a/usr.sbin/bhyve/pci_gvt-d.c b/usr.sbin/bhyve/pci_gvt-d.c --- a/usr.sbin/bhyve/pci_gvt-d.c +++ b/usr.sbin/bhyve/pci_gvt-d.c @@ -7,13 +7,42 @@ #include +#include + #include "pci_gvt-d.h" #include "pci_passthru.h" +#define PCIR_BDSM 0x5C /* Base of Data Stolen Memory register */ + +/* GVT-d definitions */ +#define GVT_D_MAP_GSM 0 + +static int +gvt_d_setup_gsm(struct pci_devinst *const pi) +{ + struct passthru_softc *sc; + + sc = pi->pi_arg; + + pci_set_cfgdata32(pi, PCIR_BDSM, + read_config(passthru_get_sel(sc), PCIR_BDSM, 4)); + + return (set_pcir_handler(sc, PCIR_BDSM, 4, passthru_cfgread_emulate, + passthru_cfgwrite_emulate)); +} + int -gvt_d_init(struct pci_devinst *const pi __unused, nvlist_t *const nvl __unused) +gvt_d_init(struct pci_devinst *const pi, nvlist_t *const nvl __unused) { - return (0); + int error; + + if ((error = gvt_d_setup_gsm(pi)) != 0) { + warnx("%s: Unable to setup Graphics Stolen Memory", __func__); + goto done; + } + +done: + return (error); } void