Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151438804
D39291.id119546.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D39291.id119546.diff
View Options
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,13 @@
#include "pci_emul.h"
+struct passthru_softc;
+
+typedef int (*cfgread_handler)(struct passthru_softc *sc,
+ struct pci_devinst *pi, int coff, int bytes, uint32_t *rv);
+typedef int (*cfgwrite_handler)(struct passthru_softc *sc,
+ struct pci_devinst *pi, int coff, int bytes, uint32_t val);
+
struct passthru_softc {
struct pci_devinst *psc_pi;
/* ROM is handled like a BAR */
@@ -24,7 +31,16 @@
int capoff;
} psc_msix;
struct pcisel psc_sel;
+
+ cfgread_handler psc_pcir_rhandler[PCI_REGMAX + 1];
+ cfgwrite_handler psc_pcir_whandler[PCI_REGMAX + 1];
};
uint32_t read_config(const struct pcisel *sel, long reg, int width);
void write_config(const struct pcisel *sel, long reg, int width, uint32_t data);
+int passthru_cfgread_default(struct passthru_softc *sc, struct pci_devinst *pi,
+ int coff, int bytes, uint32_t *rv);
+int passthru_cfgwrite_default(struct passthru_softc *sc, struct pci_devinst *pi,
+ int coff, int bytes, uint32_t val);
+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
@@ -628,6 +628,21 @@
return (error);
}
+int
+set_pcir_handler(struct passthru_softc *sc, int reg, int len,
+ cfgread_handler rhandler, cfgwrite_handler whandler)
+{
+ if (reg > PCI_REGMAX || reg + len > PCI_REGMAX + 1)
+ return (-1);
+
+ for (int i = reg; i < reg + len; ++i) {
+ sc->psc_pcir_rhandler[i] = rhandler;
+ sc->psc_pcir_whandler[i] = whandler;
+ }
+
+ return 0;
+}
+
static int
passthru_legacy_config(nvlist_t *nvl, const char *opts)
{
@@ -841,6 +856,14 @@
get_config_value_node(nvl, "rom"))) != 0)
goto done;
+ /*
+ * Default PCI config register to accessing the config register of the
+ * physical device.
+ */
+ if ((error = set_pcir_handler(sc, 0, PCI_REGMAX + 1,
+ passthru_cfgread_default, passthru_cfgwrite_default)) != 0)
+ goto done;
+
error = 0; /* success */
done:
if (error) {
@@ -893,6 +916,13 @@
sc = pi->pi_arg;
+ return (sc->psc_pcir_rhandler[coff](sc, pi, coff, bytes, rv));
+}
+
+int
+passthru_cfgread_default(struct passthru_softc *sc,
+ struct pci_devinst *pi __unused, int coff, int bytes, uint32_t *rv)
+{
/*
* PCI BARs and MSI capability is emulated.
*/
@@ -933,12 +963,20 @@
static int
passthru_cfgwrite(struct pci_devinst *pi, int coff, int bytes, uint32_t val)
{
- int error, msix_table_entries, i;
struct passthru_softc *sc;
- uint16_t cmd_old;
sc = pi->pi_arg;
+ return (sc->psc_pcir_whandler[coff](sc, pi, coff, bytes, val));
+}
+
+int
+passthru_cfgwrite_default(struct passthru_softc *sc, struct pci_devinst *pi,
+ int coff, int bytes, uint32_t val)
+{
+ int error, msix_table_entries, i;
+ uint16_t cmd_old;
+
/*
* PCI BARs are emulated
*/
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 9, 10:12 AM (20 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31131712
Default Alt Text
D39291.id119546.diff (3 KB)
Attached To
Mode
D39291: bhyve: define array to protect passthru regs
Attached
Detach File
Event Timeline
Log In to Comment