summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2022-02-24 12:09:00 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2022-02-24 19:09:44 +0000
commitf24fee035ef9b37d5a6868aed10261da6316a6b2 (patch)
tree6b64aad3db48ff966a30e300849bed3c912d59c4
parent8cbaa6a809af7f43b3da2420c9d29a3507893284 (diff)
downloadillumos-gate-f24fee035ef9b37d5a6868aed10261da6316a6b2.tar.gz
14536 bhyve: viona uses wrong address for queue notify ioport
Reviewed by: Jason King <jason.brian.king+illumos@gmail.com> Reviewed by: Patrick Mooney <pmooney@pfmooney.com> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/cmd/bhyve/pci_virtio_viona.c43
1 files changed, 33 insertions, 10 deletions
diff --git a/usr/src/cmd/bhyve/pci_virtio_viona.c b/usr/src/cmd/bhyve/pci_virtio_viona.c
index 62f194293d..8ee3880100 100644
--- a/usr/src/cmd/bhyve/pci_virtio_viona.c
+++ b/usr/src/cmd/bhyve/pci_virtio_viona.c
@@ -35,6 +35,7 @@
*
* Copyright 2015 Pluribus Networks Inc.
* Copyright 2019 Joyent, Inc.
+ * Copyright 2022 OmniOS Community Edition (OmniOSce) Association.
*/
#include <sys/cdefs.h>
@@ -395,7 +396,6 @@ pci_viona_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
char tname[MAXCOMLEN + 1];
int error, i;
struct pci_viona_softc *sc;
- uint64_t ioport;
const char *vnic;
pthread_t tid;
@@ -482,15 +482,6 @@ pci_viona_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
return (1);
}
- /* Install ioport hook for virtqueue notification */
- ioport = pi->pi_bar[0].addr + VIRTIO_PCI_QUEUE_NOTIFY;
- error = ioctl(sc->vsc_vnafd, VNA_IOC_SET_NOTIFY_IOP, ioport);
- if (error != 0) {
- WPRINTF(("could not install ioport hook at %x\n", ioport));
- free(sc);
- return (1);
- }
-
/*
* Need a legacy interrupt for virtio compliance, even though MSI-X
* operation is _strongly_ suggested for adequate performance.
@@ -621,6 +612,37 @@ pci_viona_qnotify(struct pci_viona_softc *sc, int ring)
}
static void
+pci_viona_baraddr(struct vmctx *ctx, struct pci_devinst *pi, int baridx,
+ int enabled, uint64_t address)
+{
+ struct pci_viona_softc *sc = pi->pi_arg;
+ uint64_t ioport;
+ int error;
+
+ if (baridx != 0)
+ return;
+
+ if (enabled == 0) {
+ error = ioctl(sc->vsc_vnafd, VNA_IOC_SET_NOTIFY_IOP, 0);
+ if (error != 0)
+ WPRINTF(("uninstall ioport hook failed %d\n", errno));
+ return;
+ }
+
+ /*
+ * Install ioport hook for virtqueue notification.
+ * This is part of the virtio common configuration area so the
+ * address does not change with MSI-X status.
+ */
+ ioport = address + VIRTIO_PCI_QUEUE_NOTIFY;
+ error = ioctl(sc->vsc_vnafd, VNA_IOC_SET_NOTIFY_IOP, ioport);
+ if (error != 0) {
+ WPRINTF(("install ioport hook at %x failed %d\n",
+ ioport, errno));
+ }
+}
+
+static void
pci_viona_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
int baridx, uint64_t offset, int size, uint64_t value)
{
@@ -842,6 +864,7 @@ struct pci_devemu pci_de_viona = {
.pe_legacy_config = pci_viona_legacy_config,
.pe_barwrite = pci_viona_write,
.pe_barread = pci_viona_read,
+ .pe_baraddr = pci_viona_baraddr,
.pe_lintrupdate = pci_viona_lintrupdate
};
PCI_EMUL_SET(pci_de_viona);