sync with OpenBSD -current

This commit is contained in:
purplerain 2024-08-27 19:23:27 +00:00
parent 84a7643638
commit bf0d2e284c
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
48 changed files with 439 additions and 307 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: virtio_mmio.c,v 1.14 2024/08/20 07:04:29 sf Exp $ */
/* $OpenBSD: virtio_mmio.c,v 1.16 2024/08/27 19:01:11 sf Exp $ */
/* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
/*
@ -133,7 +133,7 @@ const struct cfattach virtio_mmio_fdt_ca = {
NULL
};
struct virtio_ops virtio_mmio_ops = {
const struct virtio_ops virtio_mmio_ops = {
virtio_mmio_kick,
virtio_mmio_read_device_config_1,
virtio_mmio_read_device_config_2,
@ -241,6 +241,7 @@ virtio_mmio_attach(struct device *parent, struct device *self, void *aux)
struct virtio_mmio_softc *sc = (struct virtio_mmio_softc *)self;
struct virtio_softc *vsc = &sc->sc_sc;
uint32_t id, magic;
struct virtio_attach_args va = { 0 };
if (faa->fa_nreg < 1) {
printf(": no register data\n");
@ -289,10 +290,10 @@ virtio_mmio_attach(struct device *parent, struct device *self, void *aux)
virtio_mmio_set_status(vsc, VIRTIO_CONFIG_DEVICE_STATUS_ACK);
virtio_mmio_set_status(vsc, VIRTIO_CONFIG_DEVICE_STATUS_DRIVER);
/* XXX: use softc as aux... */
vsc->sc_childdevid = id;
va.va_devid = id;
va.va_nintr = 1;
vsc->sc_child = NULL;
config_found(self, sc, NULL);
config_found(self, &va, NULL);
if (vsc->sc_child == NULL) {
printf("%s: no matching child driver; not configured\n",
vsc->sc_dev.dv_xname);

View file

@ -3103,7 +3103,7 @@ amdgpu_attach(struct device *parent, struct device *self, void *aux)
if (PCI_MAPREG_TYPE(type) != PCI_MAPREG_TYPE_MEM ||
pci_mapreg_info(pa->pa_pc, pa->pa_tag, AMDGPU_PCI_MEM,
type, &adev->fb_aper_offset, &adev->fb_aper_size, NULL)) {
printf(": can't get frambuffer info\n");
printf(": can't get framebuffer info\n");
return;
}

View file

@ -1009,7 +1009,7 @@ radeondrm_attach_kms(struct device *parent, struct device *self, void *aux)
if (PCI_MAPREG_TYPE(type) != PCI_MAPREG_TYPE_MEM ||
pci_mapreg_info(pa->pa_pc, pa->pa_tag, RADEON_PCI_MEM,
type, &rdev->fb_aper_offset, &rdev->fb_aper_size, NULL)) {
printf(": can't get frambuffer info\n");
printf(": can't get framebuffer info\n");
return;
}
if (rdev->fb_aper_offset == 0) {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: virtio_pci.c,v 1.38 2024/06/26 01:40:49 jsg Exp $ */
/* $OpenBSD: virtio_pci.c,v 1.40 2024/08/27 19:01:11 sf Exp $ */
/* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
/*
@ -53,6 +53,7 @@
#define MAX_MSIX_VECS 8
struct virtio_pci_softc;
struct virtio_pci_attach_args;
int virtio_pci_match(struct device *, void *, void *);
void virtio_pci_attach(struct device *, struct device *, void *);
@ -78,8 +79,8 @@ int virtio_pci_negotiate_features(struct virtio_softc *, const struct virtio_fe
int virtio_pci_negotiate_features_10(struct virtio_softc *, const struct virtio_feature_name *);
void virtio_pci_set_msix_queue_vector(struct virtio_pci_softc *, uint32_t, uint16_t);
void virtio_pci_set_msix_config_vector(struct virtio_pci_softc *, uint16_t);
int virtio_pci_msix_establish(struct virtio_pci_softc *, struct pci_attach_args *, int, int (*)(void *), void *);
int virtio_pci_setup_msix(struct virtio_pci_softc *, struct pci_attach_args *, int);
int virtio_pci_msix_establish(struct virtio_pci_softc *, struct virtio_pci_attach_args *, int, int (*)(void *), void *);
int virtio_pci_setup_msix(struct virtio_pci_softc *, struct virtio_pci_attach_args *, int);
void virtio_pci_free_irqs(struct virtio_pci_softc *);
int virtio_pci_poll_intr(void *);
int virtio_pci_legacy_intr(void *);
@ -136,6 +137,12 @@ struct virtio_pci_softc {
enum irq_type sc_irq_type;
};
struct virtio_pci_attach_args {
struct virtio_attach_args vpa_va;
struct pci_attach_args *vpa_pa;
};
const struct cfattach virtio_pci_ca = {
sizeof(struct virtio_pci_softc),
virtio_pci_match,
@ -144,7 +151,7 @@ const struct cfattach virtio_pci_ca = {
NULL
};
struct virtio_ops virtio_pci_ops = {
const struct virtio_ops virtio_pci_ops = {
virtio_pci_kick,
virtio_pci_read_device_config_1,
virtio_pci_read_device_config_2,
@ -577,6 +584,8 @@ virtio_pci_attach(struct device *parent, struct device *self, void *aux)
pcireg_t id;
char const *intrstr;
pci_intr_handle_t ih;
struct virtio_pci_attach_args vpa = { { 0 }, pa };
int n;
revision = PCI_REVISION(pa->pa_class);
switch (revision) {
@ -608,6 +617,10 @@ virtio_pci_attach(struct device *parent, struct device *self, void *aux)
virtio_pci_dump_caps(sc);
#endif
n = MIN(MAX_MSIX_VECS, pci_intr_msix_count(pa));
n = MAX(n, 1);
vpa.vpa_va.va_nintr = n;
vsc->sc_ops = &virtio_pci_ops;
if ((vsc->sc_dev.dv_cfdata->cf_flags & VIRTIO_CF_NO_VERSION_1) == 0 &&
(revision == 1 ||
@ -633,9 +646,9 @@ virtio_pci_attach(struct device *parent, struct device *self, void *aux)
virtio_set_status(vsc, VIRTIO_CONFIG_DEVICE_STATUS_DRIVER);
printf("\n");
vsc->sc_childdevid = id;
vpa.vpa_va.va_devid = id;
vsc->sc_child = NULL;
config_found(self, sc, NULL);
config_found(self, &vpa, NULL);
if (vsc->sc_child == NULL) {
printf("%s: no matching child driver; not configured\n",
vsc->sc_dev.dv_xname);
@ -647,10 +660,10 @@ virtio_pci_attach(struct device *parent, struct device *self, void *aux)
goto fail_1;
}
if (virtio_pci_setup_msix(sc, pa, 0) == 0) {
if (virtio_pci_setup_msix(sc, &vpa, 0) == 0) {
sc->sc_irq_type = IRQ_MSIX_PER_VQ;
intrstr = "msix per-VQ";
} else if (virtio_pci_setup_msix(sc, pa, 1) == 0) {
} else if (virtio_pci_setup_msix(sc, &vpa, 1) == 0) {
sc->sc_irq_type = IRQ_MSIX_SHARED;
intrstr = "msix shared";
} else {
@ -910,12 +923,13 @@ virtio_pci_write_device_config_8(struct virtio_softc *vsc,
int
virtio_pci_msix_establish(struct virtio_pci_softc *sc,
struct pci_attach_args *pa, int idx, int (*handler)(void *), void *ih_arg)
struct virtio_pci_attach_args *vpa, int idx,
int (*handler)(void *), void *ih_arg)
{
struct virtio_softc *vsc = &sc->sc_sc;
pci_intr_handle_t ih;
if (pci_intr_map_msix(pa, idx, &ih) != 0) {
if (pci_intr_map_msix(vpa->vpa_pa, idx, &ih) != 0) {
#if VIRTIO_DEBUG
printf("%s[%d]: pci_intr_map_msix failed\n",
vsc->sc_dev.dv_xname, idx);
@ -983,27 +997,27 @@ virtio_pci_free_irqs(struct virtio_pci_softc *sc)
}
int
virtio_pci_setup_msix(struct virtio_pci_softc *sc, struct pci_attach_args *pa,
int shared)
virtio_pci_setup_msix(struct virtio_pci_softc *sc,
struct virtio_pci_attach_args *vpa, int shared)
{
struct virtio_softc *vsc = &sc->sc_sc;
int i;
/* Shared needs config + queue */
if (shared && pci_intr_msix_count(pa) < 1 + 1)
if (shared && vpa->vpa_va.va_nintr < 1 + 1)
return 1;
/* Per VQ needs config + N * queue */
if (!shared && pci_intr_msix_count(pa) < 1 + vsc->sc_nvqs)
if (!shared && vpa->vpa_va.va_nintr < 1 + vsc->sc_nvqs)
return 1;
if (virtio_pci_msix_establish(sc, pa, 0, virtio_pci_config_intr, vsc))
if (virtio_pci_msix_establish(sc, vpa, 0, virtio_pci_config_intr, vsc))
return 1;
sc->sc_devcfg_offset = VIRTIO_CONFIG_DEVICE_CONFIG_MSI;
virtio_pci_adjust_config_region(sc);
virtio_pci_set_msix_config_vector(sc, 0);
if (shared) {
if (virtio_pci_msix_establish(sc, pa, 1,
if (virtio_pci_msix_establish(sc, vpa, 1,
virtio_pci_shared_queue_intr, vsc)) {
goto fail;
}
@ -1012,7 +1026,7 @@ virtio_pci_setup_msix(struct virtio_pci_softc *sc, struct pci_attach_args *pa,
virtio_pci_set_msix_queue_vector(sc, i, 1);
} else {
for (i = 0; i < vsc->sc_nvqs; i++) {
if (virtio_pci_msix_establish(sc, pa, i + 1,
if (virtio_pci_msix_establish(sc, vpa, i + 1,
virtio_pci_queue_intr, &vsc->sc_vqs[i])) {
goto fail;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_vio.c,v 1.46 2024/08/16 13:02:44 jan Exp $ */
/* $OpenBSD: if_vio.c,v 1.50 2024/08/27 19:11:20 sf Exp $ */
/*
* Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg.
@ -330,9 +330,9 @@ void vio_dump(struct vio_softc *);
int
vio_match(struct device *parent, void *match, void *aux)
{
struct virtio_softc *va = aux;
struct virtio_attach_args *va = aux;
if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_NETWORK)
if (va->va_devid == PCI_PRODUCT_VIRTIO_NETWORK)
return 1;
return 0;
@ -443,7 +443,7 @@ vio_alloc_mem(struct vio_softc *sc)
if (vio_alloc_dmamem(sc) != 0) {
printf("unable to allocate dma region\n");
return -1;
return -1;
}
kva = sc->sc_dma_kva;
@ -588,7 +588,7 @@ vio_attach(struct device *parent, struct device *self, void *aux)
ether_fakeaddr(ifp);
vio_put_lladdr(&sc->sc_ac, vsc);
}
printf(": address %s\n", ether_sprintf(sc->sc_ac.ac_enaddr));
printf(", address %s\n", ether_sprintf(sc->sc_ac.ac_enaddr));
if (virtio_has_feature(vsc, VIRTIO_NET_F_MRG_RXBUF) ||
vsc->sc_version_1) {
@ -599,14 +599,13 @@ vio_attach(struct device *parent, struct device *self, void *aux)
if (virtio_has_feature(vsc, VIRTIO_NET_F_MRG_RXBUF))
ifp->if_hardmtu = MAXMCLBYTES;
else
ifp->if_hardmtu = MAXMCLBYTES - sc->sc_hdr_size - ETHER_HDR_LEN;
ifp->if_hardmtu = MCLBYTES - sc->sc_hdr_size - ETHER_HDR_LEN;
if (virtio_alloc_vq(vsc, &sc->sc_vq[VQRX], 0, MCLBYTES, 2, "rx") != 0)
if (virtio_alloc_vq(vsc, &sc->sc_vq[VQRX], 0, 2, "rx") != 0)
goto err;
vsc->sc_nvqs = 1;
sc->sc_vq[VQRX].vq_done = vio_rx_intr;
if (virtio_alloc_vq(vsc, &sc->sc_vq[VQTX], 1,
sc->sc_hdr_size + ifp->if_hardmtu + ETHER_HDR_LEN,
VIRTIO_NET_TX_MAXNSEGS + 1, "tx") != 0) {
goto err;
}
@ -618,7 +617,7 @@ vio_attach(struct device *parent, struct device *self, void *aux)
else
virtio_stop_vq_intr(vsc, &sc->sc_vq[VQTX]);
if (virtio_has_feature(vsc, VIRTIO_NET_F_CTRL_VQ)) {
if (virtio_alloc_vq(vsc, &sc->sc_vq[VQCTL], 2, NBPG, 1,
if (virtio_alloc_vq(vsc, &sc->sc_vq[VQCTL], 2, 1,
"control") == 0) {
sc->sc_vq[VQCTL].vq_done = vio_ctrleof;
virtio_start_vq_intr(vsc, &sc->sc_vq[VQCTL]);
@ -1503,8 +1502,8 @@ vio_ctrl_guest_offloads(struct vio_softc *sc, uint64_t features)
if (sc->sc_ctrl_status->ack == VIRTIO_NET_OK) {
r = 0;
} else {
printf("%s: features 0x%llx failed\n", sc->sc_dev.dv_xname,
features);
printf("%s: offload features 0x%llx failed\n",
sc->sc_dev.dv_xname, features);
r = EIO;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vioblk.c,v 1.41 2024/08/01 11:13:19 sf Exp $ */
/* $OpenBSD: vioblk.c,v 1.43 2024/08/27 18:44:12 sf Exp $ */
/*
* Copyright (c) 2012 Stefan Fritsch.
@ -156,8 +156,8 @@ const struct scsi_adapter vioblk_switch = {
int
vioblk_match(struct device *parent, void *match, void *aux)
{
struct virtio_softc *va = aux;
if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_BLOCK)
struct virtio_attach_args *va = aux;
if (va->va_devid == PCI_PRODUCT_VIRTIO_BLOCK)
return 1;
return 0;
}
@ -208,8 +208,8 @@ vioblk_attach(struct device *parent, struct device *self, void *aux)
sc->sc_capacity = virtio_read_device_config_8(vsc,
VIRTIO_BLK_CONFIG_CAPACITY);
if (virtio_alloc_vq(vsc, &sc->sc_vq[0], 0, MAXPHYS, ALLOC_SEGS,
"I/O request") != 0) {
if (virtio_alloc_vq(vsc, &sc->sc_vq[0], 0, ALLOC_SEGS, "I/O request")
!= 0) {
printf("\nCan't alloc virtqueue\n");
goto err;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: viocon.c,v 1.13 2024/08/01 11:13:19 sf Exp $ */
/* $OpenBSD: viocon.c,v 1.15 2024/08/27 18:44:12 sf Exp $ */
/*
* Copyright (c) 2013-2015 Stefan Fritsch <sf@sfritsch.de>
@ -162,8 +162,8 @@ dev2port(dev_t dev)
int
viocon_match(struct device *parent, void *match, void *aux)
{
struct virtio_softc *va = aux;
if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_CONSOLE)
struct virtio_attach_args *va = aux;
if (va->va_devid == PCI_PRODUCT_VIRTIO_CONSOLE)
return 1;
return 0;
}
@ -235,8 +235,7 @@ viocon_port_create(struct viocon_softc *sc, int portidx)
txidx = rxidx + 1;
snprintf(name, sizeof(name), "p%drx", portidx);
if (virtio_alloc_vq(vsc, &vsc->sc_vqs[rxidx], rxidx, BUFSIZE, 1,
name) != 0) {
if (virtio_alloc_vq(vsc, &vsc->sc_vqs[rxidx], rxidx, 1, name) != 0) {
printf("\nCan't alloc %s virtqueue\n", name);
goto err;
}
@ -246,8 +245,7 @@ viocon_port_create(struct viocon_softc *sc, int portidx)
DPRINTF("%s: rx: %p\n", __func__, vp->vp_rx);
snprintf(name, sizeof(name), "p%dtx", portidx);
if (virtio_alloc_vq(vsc, &vsc->sc_vqs[txidx], txidx, BUFSIZE, 1,
name) != 0) {
if (virtio_alloc_vq(vsc, &vsc->sc_vqs[txidx], txidx, 1, name) != 0) {
printf("\nCan't alloc %s virtqueue\n", name);
goto err;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: viogpu.c,v 1.7 2024/08/01 11:13:19 sf Exp $ */
/* $OpenBSD: viogpu.c,v 1.9 2024/08/27 18:44:12 sf Exp $ */
/*
* Copyright (c) 2021-2023 joshua stein <jcs@openbsd.org>
@ -137,9 +137,9 @@ struct cfdriver viogpu_cd = {
int
viogpu_match(struct device *parent, void *match, void *aux)
{
struct virtio_softc *va = aux;
struct virtio_attach_args *va = aux;
if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_GPU)
if (va->va_devid == PCI_PRODUCT_VIRTIO_GPU)
return 1;
return 0;
@ -173,15 +173,13 @@ viogpu_attach(struct device *parent, struct device *self, void *aux)
/* allocate command and cursor virtqueues */
vsc->sc_vqs = sc->sc_vqs;
if (virtio_alloc_vq(vsc, &sc->sc_vqs[VQCTRL], VQCTRL, NBPG, 1,
"control")) {
if (virtio_alloc_vq(vsc, &sc->sc_vqs[VQCTRL], VQCTRL, 1, "control")) {
printf(": alloc_vq failed\n");
return;
}
sc->sc_vqs[VQCTRL].vq_done = viogpu_vq_done;
if (virtio_alloc_vq(vsc, &sc->sc_vqs[VQCURS], VQCURS, NBPG, 1,
"cursor")) {
if (virtio_alloc_vq(vsc, &sc->sc_vqs[VQCURS], VQCURS, 1, "cursor")) {
printf(": alloc_vq failed\n");
return;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: viomb.c,v 1.10 2024/05/24 10:05:55 jsg Exp $ */
/* $OpenBSD: viomb.c,v 1.12 2024/08/27 18:44:12 sf Exp $ */
/* $NetBSD: viomb.c,v 1.1 2011/10/30 12:12:21 hannken Exp $ */
/*
@ -124,8 +124,8 @@ struct cfdriver viomb_cd = {
int
viomb_match(struct device *parent, void *match, void *aux)
{
struct virtio_softc *va = aux;
if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_BALLOON)
struct virtio_attach_args *va = aux;
if (va->va_devid == PCI_PRODUCT_VIRTIO_BALLOON)
return (1);
return (0);
}
@ -161,12 +161,12 @@ viomb_attach(struct device *parent, struct device *self, void *aux)
if (virtio_negotiate_features(vsc, viomb_feature_names) != 0)
goto err;
if ((virtio_alloc_vq(vsc, &sc->sc_vq[VQ_INFLATE], VQ_INFLATE,
sizeof(u_int32_t) * PGS_PER_REQ, 1, "inflate") != 0))
if ((virtio_alloc_vq(vsc, &sc->sc_vq[VQ_INFLATE], VQ_INFLATE, 1,
"inflate") != 0))
goto err;
vsc->sc_nvqs++;
if ((virtio_alloc_vq(vsc, &sc->sc_vq[VQ_DEFLATE], VQ_DEFLATE,
sizeof(u_int32_t) * PGS_PER_REQ, 1, "deflate") != 0))
if ((virtio_alloc_vq(vsc, &sc->sc_vq[VQ_DEFLATE], VQ_DEFLATE, 1,
"deflate") != 0))
goto err;
vsc->sc_nvqs++;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: viornd.c,v 1.9 2024/06/26 01:40:49 jsg Exp $ */
/* $OpenBSD: viornd.c,v 1.11 2024/08/27 18:44:12 sf Exp $ */
/*
* Copyright (c) 2014 Stefan Fritsch <sf@sfritsch.de>
@ -72,8 +72,8 @@ struct cfdriver viornd_cd = {
int
viornd_match(struct device *parent, void *match, void *aux)
{
struct virtio_softc *va = aux;
if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_ENTROPY)
struct virtio_attach_args *va = aux;
if (va->va_devid == PCI_PRODUCT_VIRTIO_ENTROPY)
return 1;
return 0;
}
@ -125,8 +125,7 @@ viornd_attach(struct device *parent, struct device *self, void *aux)
goto err2;
}
if (virtio_alloc_vq(vsc, &sc->sc_vq, 0, VIORND_BUFSIZE, 1,
"Entropy request") != 0) {
if (virtio_alloc_vq(vsc, &sc->sc_vq, 0, 1, "Entropy request") != 0) {
printf(": Can't alloc virtqueue\n");
goto err2;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vioscsi.c,v 1.32 2023/05/29 08:13:35 sf Exp $ */
/* $OpenBSD: vioscsi.c,v 1.34 2024/08/27 18:44:12 sf Exp $ */
/*
* Copyright (c) 2013 Google Inc.
*
@ -93,9 +93,9 @@ const char *const vioscsi_vq_names[] = {
int
vioscsi_match(struct device *parent, void *self, void *aux)
{
struct virtio_softc *va = (struct virtio_softc *)aux;
struct virtio_attach_args *va = aux;
if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_SCSI)
if (va->va_devid == PCI_PRODUCT_VIRTIO_SCSI)
return (1);
return (0);
}
@ -134,8 +134,8 @@ vioscsi_attach(struct device *parent, struct device *self, void *aux)
}
for (i = 0; i < nitems(sc->sc_vqs); i++) {
rv = virtio_alloc_vq(vsc, &sc->sc_vqs[i], i, MAXPHYS,
ALLOC_SEGS, vioscsi_vq_names[i]);
rv = virtio_alloc_vq(vsc, &sc->sc_vqs[i], i, ALLOC_SEGS,
vioscsi_vq_names[i]);
if (rv) {
printf(": failed to allocate virtqueue %d\n", i);
goto err;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: virtio.c,v 1.30 2024/08/13 08:47:28 sf Exp $ */
/* $OpenBSD: virtio.c,v 1.31 2024/08/27 18:44:12 sf Exp $ */
/* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
/*
@ -329,7 +329,7 @@ virtio_init_vq(struct virtio_softc *sc, struct virtqueue *vq)
*/
int
virtio_alloc_vq(struct virtio_softc *sc, struct virtqueue *vq, int index,
int maxsegsize, int maxnsegs, const char *name)
int maxnsegs, const char *name)
{
int vq_size, allocsize1, allocsize2, allocsize3, allocsize = 0;
int rsegs, r, hdrlen;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: virtiovar.h,v 1.18 2024/05/17 16:37:10 sf Exp $ */
/* $OpenBSD: virtiovar.h,v 1.21 2024/08/27 19:01:11 sf Exp $ */
/* $NetBSD: virtiovar.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */
/*
@ -85,6 +85,11 @@
#define VIRTIO_CF_PREFER_VERSION_1 4
#define VIRTIO_CF_NO_VERSION_1 8
struct virtio_attach_args {
int va_devid; /* virtio device id */
unsigned int va_nintr; /* number of intr vectors */
};
struct vq_entry {
SLIST_ENTRY(vq_entry) qe_list; /* free list */
uint16_t qe_index; /* index in vq_desc array */
@ -122,14 +127,11 @@ struct virtqueue {
/* free entry management */
struct vq_entry *vq_entries;
SLIST_HEAD(, vq_entry) vq_freelist;
struct mutex *vq_freelist_lock;
/* enqueue/dequeue status */
uint16_t vq_avail_idx;
uint16_t vq_used_idx;
int vq_queued;
struct mutex *vq_aring_lock;
struct mutex *vq_uring_lock;
/* interrupt handler */
int (*vq_done)(struct virtqueue*);
@ -165,7 +167,7 @@ struct virtio_ops {
struct virtio_softc {
struct device sc_dev;
bus_dma_tag_t sc_dmat; /* set by transport */
struct virtio_ops *sc_ops; /* set by transport */
const struct virtio_ops *sc_ops; /* set by transport */
int sc_ipl; /* set by child */
@ -177,7 +179,6 @@ struct virtio_softc {
int sc_nvqs; /* set by child */
struct virtqueue *sc_vqs; /* set by child */
int sc_childdevid; /* set by transport */
struct device *sc_child; /* set by child,
* VIRTIO_CHILD_ERROR on error
*/
@ -212,7 +213,7 @@ virtio_has_feature(struct virtio_softc *sc, uint64_t fbit)
return 0;
}
int virtio_alloc_vq(struct virtio_softc*, struct virtqueue*, int, int, int,
int virtio_alloc_vq(struct virtio_softc*, struct virtqueue*, int, int,
const char*);
int virtio_free_vq(struct virtio_softc*, struct virtqueue*);
void virtio_reset(struct virtio_softc *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmmci.c,v 1.11 2024/05/24 10:05:55 jsg Exp $ */
/* $OpenBSD: vmmci.c,v 1.12 2024/08/26 19:37:54 sf Exp $ */
/*
* Copyright (c) 2017 Reyk Floeter <reyk@openbsd.org>
@ -78,8 +78,8 @@ struct cfdriver vmmci_cd = {
int
vmmci_match(struct device *parent, void *match, void *aux)
{
struct virtio_softc *va = aux;
if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_VMMCI)
struct virtio_attach_args *va = aux;
if (va->va_devid == PCI_PRODUCT_VIRTIO_VMMCI)
return (1);
return (0);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: usb_quirks.c,v 1.78 2021/03/24 02:49:57 jcs Exp $ */
/* $OpenBSD: usb_quirks.c,v 1.79 2024/08/27 12:41:18 sthen Exp $ */
/* $NetBSD: usb_quirks.c,v 1.45 2003/05/10 17:47:14 hamajima Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.30 2003/01/02 04:15:55 imp Exp $ */
@ -154,12 +154,24 @@ const struct usbd_quirk_entry {
ANY, { UQ_MS_VENDOR_BUTTONS }},
/* Devices that need their data pipe held open */
{ USB_VENDOR_CHICONY, USB_PRODUCT_CHICONY_OPTMOUSE,
ANY, { UQ_ALWAYS_OPEN }},
{ USB_VENDOR_HAILUCK, USB_PRODUCT_HAILUCK_KEYBOARD,
ANY, { UQ_ALWAYS_OPEN }},
{ USB_VENDOR_LENOVO, USB_PRODUCT_LENOVO_OPTUSBMOUSE,
ANY, { UQ_ALWAYS_OPEN }},
{ USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_B100_1,
ANY, { UQ_ALWAYS_OPEN }},
{ USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_B100_2,
ANY, { UQ_ALWAYS_OPEN }},
{ USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_PIXARTMOUSE,
ANY, { UQ_ALWAYS_OPEN }},
{ USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_TYPECOVER,
ANY, { UQ_ALWAYS_OPEN }},
ANY, { UQ_ALWAYS_OPEN }},
{ USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_TYPECOVER2,
ANY, { UQ_ALWAYS_OPEN }},
ANY, { UQ_ALWAYS_OPEN }},
{ USB_VENDOR_PIXART, USB_PRODUCT_PIXART_RPIMOUSE,
ANY, { UQ_ALWAYS_OPEN }},
{ 0, 0, 0, { 0 } }
};

View file

@ -1,4 +1,4 @@
$OpenBSD: usbdevs,v 1.767 2024/08/08 05:09:09 deraadt Exp $
$OpenBSD: usbdevs,v 1.768 2024/08/27 12:31:18 sthen Exp $
/* $NetBSD: usbdevs,v 1.322 2003/05/10 17:47:14 hamajima Exp $ */
/*
@ -365,6 +365,7 @@ vendor GARMIN 0x091e Garmin International
vendor GOHUBS 0x0921 GoHubs
vendor BIOMETRIC 0x0929 American Biometric Company
vendor TOSHIBA 0x0930 Toshiba Corp
vendor PIXART 0x093a PixArt
vendor INTREPIDCS 0x093c Intrepid
vendor YANO 0x094f Yano
vendor KINGSTON 0x0951 Kingston Technology
@ -1347,6 +1348,7 @@ product CHIC CYPRESS 0x0003 Cypress
/* Chicony products */
product CHICONY KB8933 0x0001 KB-8933 keyboard
product CHICONY OPTMOUSE 0x0939 Optical Mouse
product CHICONY CAMERA 0x480c Integrated Camera
product CHICONY RTL8188CUS_1 0xaff7 RTL8188CUS
product CHICONY RTL8188CUS_2 0xaff8 RTL8188CUS
@ -2638,6 +2640,7 @@ product LENOVO RTL8153B_2 0x3098 RTL8153B
product LENOVO RTL8153B_3 0x309b RTL8153B
product LENOVO RTL8153B_4 0x309c RTL8153B
product LENOVO RTL8153B_5 0x309d RTL8153B
product LENOVO OPTUSBMOUSE 0x600e Optical Mouse
product LENOVO ETHERNET 0x7203 USB 2.0 Ethernet
product LENOVO RTL8153_1 0x7205 RTL8153
product LENOVO ONELINK 0x720a OneLink
@ -2753,6 +2756,8 @@ product LOGITECH MBA47 0xc002 M-BA47 mouse
product LOGITECH WMMOUSE 0xc004 WingMan Gaming Mouse
product LOGITECH BD58 0xc00c BD58 mouse
product LOGITECH UN58A 0xc030 iFeel Mouse
product LOGITECH B100_1 0xc05a B100 mouse
product LOGITECH B100_2 0xc077 B100 mouse
product LOGITECH WMPAD 0xc208 WingMan GamePad Extreme
product LOGITECH WMRPAD 0xc20a WingMan RumblePad
product LOGITECH WMJOY 0xc281 WingMan Force joystick
@ -3139,6 +3144,7 @@ product MICROSOFT INETPRO 0x001c Internet Keyboard Pro
product MICROSOFT TBEXPLORER 0x0024 Trackball Explorer
product MICROSOFT INTELLIEYE 0x0025 IntelliEye mouse
product MICROSOFT INETPRO2 0x002b Internet Keyboard Pro
product MICROSOFT PIXARTMOUSE 0x00cb Optical Mouse
product MICROSOFT MN510 0x006e MN510 Wireless
product MICROSOFT 700WX 0x0079 Palm 700WX
product MICROSOFT MN110 0x007a 10/100 Ethernet
@ -3600,6 +3606,10 @@ product PILOTECH CRW600 0x0001 CRW-600 6-in-1
product PIONEERDJ RTL8152B 0x0007 RTL8152B
product PIONEERDJ RTL8153B 0x0031 RTL8153B
/* PixArt products */
product PIXART RPIMOUSE 0x2510 Raspberry Pi Mouse
/* Planex Communications products */
product PLANEX GW_US11H 0x14ea GW-US11H WLAN
product PLANEX2 RTL8188CUS 0x1201 RTL8188CUS

View file

@ -1,10 +1,10 @@
/* $OpenBSD: usbdevs.h,v 1.779 2024/08/08 05:09:33 deraadt Exp $ */
/* $OpenBSD: usbdevs.h,v 1.780 2024/08/27 12:31:43 sthen Exp $ */
/*
* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: usbdevs,v 1.767 2024/08/08 05:09:09 deraadt Exp
* OpenBSD: usbdevs,v 1.768 2024/08/27 12:31:18 sthen Exp
*/
/* $NetBSD: usbdevs,v 1.322 2003/05/10 17:47:14 hamajima Exp $ */
@ -372,6 +372,7 @@
#define USB_VENDOR_GOHUBS 0x0921 /* GoHubs */
#define USB_VENDOR_BIOMETRIC 0x0929 /* American Biometric Company */
#define USB_VENDOR_TOSHIBA 0x0930 /* Toshiba Corp */
#define USB_VENDOR_PIXART 0x093a /* PixArt */
#define USB_VENDOR_INTREPIDCS 0x093c /* Intrepid */
#define USB_VENDOR_YANO 0x094f /* Yano */
#define USB_VENDOR_KINGSTON 0x0951 /* Kingston Technology */
@ -1354,6 +1355,7 @@
/* Chicony products */
#define USB_PRODUCT_CHICONY_KB8933 0x0001 /* KB-8933 keyboard */
#define USB_PRODUCT_CHICONY_OPTMOUSE 0x0939 /* Optical Mouse */
#define USB_PRODUCT_CHICONY_CAMERA 0x480c /* Integrated Camera */
#define USB_PRODUCT_CHICONY_RTL8188CUS_1 0xaff7 /* RTL8188CUS */
#define USB_PRODUCT_CHICONY_RTL8188CUS_2 0xaff8 /* RTL8188CUS */
@ -2645,6 +2647,7 @@
#define USB_PRODUCT_LENOVO_RTL8153B_3 0x309b /* RTL8153B */
#define USB_PRODUCT_LENOVO_RTL8153B_4 0x309c /* RTL8153B */
#define USB_PRODUCT_LENOVO_RTL8153B_5 0x309d /* RTL8153B */
#define USB_PRODUCT_LENOVO_OPTUSBMOUSE 0x600e /* Optical Mouse */
#define USB_PRODUCT_LENOVO_ETHERNET 0x7203 /* USB 2.0 Ethernet */
#define USB_PRODUCT_LENOVO_RTL8153_1 0x7205 /* RTL8153 */
#define USB_PRODUCT_LENOVO_ONELINK 0x720a /* OneLink */
@ -2760,6 +2763,8 @@
#define USB_PRODUCT_LOGITECH_WMMOUSE 0xc004 /* WingMan Gaming Mouse */
#define USB_PRODUCT_LOGITECH_BD58 0xc00c /* BD58 mouse */
#define USB_PRODUCT_LOGITECH_UN58A 0xc030 /* iFeel Mouse */
#define USB_PRODUCT_LOGITECH_B100_1 0xc05a /* B100 mouse */
#define USB_PRODUCT_LOGITECH_B100_2 0xc077 /* B100 mouse */
#define USB_PRODUCT_LOGITECH_WMPAD 0xc208 /* WingMan GamePad Extreme */
#define USB_PRODUCT_LOGITECH_WMRPAD 0xc20a /* WingMan RumblePad */
#define USB_PRODUCT_LOGITECH_WMJOY 0xc281 /* WingMan Force joystick */
@ -3146,6 +3151,7 @@
#define USB_PRODUCT_MICROSOFT_TBEXPLORER 0x0024 /* Trackball Explorer */
#define USB_PRODUCT_MICROSOFT_INTELLIEYE 0x0025 /* IntelliEye mouse */
#define USB_PRODUCT_MICROSOFT_INETPRO2 0x002b /* Internet Keyboard Pro */
#define USB_PRODUCT_MICROSOFT_PIXARTMOUSE 0x00cb /* Optical Mouse */
#define USB_PRODUCT_MICROSOFT_MN510 0x006e /* MN510 Wireless */
#define USB_PRODUCT_MICROSOFT_700WX 0x0079 /* Palm 700WX */
#define USB_PRODUCT_MICROSOFT_MN110 0x007a /* 10/100 Ethernet */
@ -3607,6 +3613,10 @@
#define USB_PRODUCT_PIONEERDJ_RTL8152B 0x0007 /* RTL8152B */
#define USB_PRODUCT_PIONEERDJ_RTL8153B 0x0031 /* RTL8153B */
/* PixArt products */
#define USB_PRODUCT_PIXART_RPIMOUSE 0x2510 /* Raspberry Pi Mouse */
/* Planex Communications products */
#define USB_PRODUCT_PLANEX_GW_US11H 0x14ea /* GW-US11H WLAN */
#define USB_PRODUCT_PLANEX2_RTL8188CUS 0x1201 /* RTL8188CUS */

View file

@ -1,10 +1,10 @@
/* $OpenBSD: usbdevs_data.h,v 1.773 2024/08/08 05:09:33 deraadt Exp $ */
/* $OpenBSD: usbdevs_data.h,v 1.774 2024/08/27 12:31:43 sthen Exp $ */
/*
* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: usbdevs,v 1.767 2024/08/08 05:09:09 deraadt Exp
* OpenBSD: usbdevs,v 1.768 2024/08/27 12:31:18 sthen Exp
*/
/* $NetBSD: usbdevs,v 1.322 2003/05/10 17:47:14 hamajima Exp $ */
@ -1941,6 +1941,10 @@ const struct usb_known_product usb_known_products[] = {
USB_VENDOR_CHICONY, USB_PRODUCT_CHICONY_KB8933,
"KB-8933 keyboard",
},
{
USB_VENDOR_CHICONY, USB_PRODUCT_CHICONY_OPTMOUSE,
"Optical Mouse",
},
{
USB_VENDOR_CHICONY, USB_PRODUCT_CHICONY_CAMERA,
"Integrated Camera",
@ -5841,6 +5845,10 @@ const struct usb_known_product usb_known_products[] = {
USB_VENDOR_LENOVO, USB_PRODUCT_LENOVO_RTL8153B_5,
"RTL8153B",
},
{
USB_VENDOR_LENOVO, USB_PRODUCT_LENOVO_OPTUSBMOUSE,
"Optical Mouse",
},
{
USB_VENDOR_LENOVO, USB_PRODUCT_LENOVO_ETHERNET,
"USB 2.0 Ethernet",
@ -6229,6 +6237,14 @@ const struct usb_known_product usb_known_products[] = {
USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_UN58A,
"iFeel Mouse",
},
{
USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_B100_1,
"B100 mouse",
},
{
USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_B100_2,
"B100 mouse",
},
{
USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_WMPAD,
"WingMan GamePad Extreme",
@ -7605,6 +7621,10 @@ const struct usb_known_product usb_known_products[] = {
USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_INETPRO2,
"Internet Keyboard Pro",
},
{
USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_PIXARTMOUSE,
"Optical Mouse",
},
{
USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_MN510,
"MN510 Wireless",
@ -8881,6 +8901,10 @@ const struct usb_known_product usb_known_products[] = {
USB_VENDOR_PIONEERDJ, USB_PRODUCT_PIONEERDJ_RTL8153B,
"RTL8153B",
},
{
USB_VENDOR_PIXART, USB_PRODUCT_PIXART_RPIMOUSE,
"Raspberry Pi Mouse",
},
{
USB_VENDOR_PLANEX, USB_PRODUCT_PLANEX_GW_US11H,
"GW-US11H WLAN",
@ -13597,6 +13621,10 @@ const struct usb_known_vendor usb_known_vendors[] = {
USB_VENDOR_TOSHIBA,
"Toshiba Corp",
},
{
USB_VENDOR_PIXART,
"PixArt",
},
{
USB_VENDOR_INTREPIDCS,
"Intrepid",

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmm.c,v 1.2 2023/05/13 23:15:28 dv Exp $ */
/* $OpenBSD: vmm.c,v 1.3 2024/08/27 09:16:03 bluhm Exp $ */
/*
* Copyright (c) 2014-2023 Mike Larkin <mlarkin@openbsd.org>
*
@ -399,13 +399,13 @@ vm_create(struct vm_create_params *vcp, struct proc *p)
vcpu = pool_get(&vcpu_pool, PR_WAITOK | PR_ZERO);
vcpu->vc_parent = vm;
if ((ret = vcpu_init(vcpu)) != 0) {
vcpu->vc_id = vm->vm_vcpu_ct;
vm->vm_vcpu_ct++;
if ((ret = vcpu_init(vcpu, vcp)) != 0) {
printf("failed to init vcpu %d for vm %p\n", i, vm);
vm_teardown(&vm);
return (ret);
}
vcpu->vc_id = vm->vm_vcpu_ct;
vm->vm_vcpu_ct++;
/* Publish vcpu to list, inheriting the reference. */
SLIST_INSERT_HEAD(&vm->vm_vcpu_list, vcpu, vc_vcpu_link);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmm.h,v 1.6 2024/07/10 10:41:19 dv Exp $ */
/* $OpenBSD: vmm.h,v 1.7 2024/08/27 09:16:03 bluhm Exp $ */
/*
* Copyright (c) 2014-2023 Mike Larkin <mlarkin@openbsd.org>
*
@ -49,9 +49,12 @@ struct vm_create_params {
size_t vcp_ncpus;
struct vm_mem_range vcp_memranges[VMM_MAX_MEM_RANGES];
char vcp_name[VMM_MAX_NAME_LEN];
int vcp_sev;
/* Output parameter from VMM_IOC_CREATE */
uint32_t vcp_id;
uint32_t vcp_poscbit;
uint32_t vcp_asid[VMM_MAX_VCPUS];
};
struct vm_info_result {