lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <7012a65f-d265-e510-492b-5003b512ef05@redhat.com> Date: Mon, 15 May 2023 10:53:39 +0800 From: Jason Wang <jasowang@...hat.com> To: Shannon Nelson <shannon.nelson@....com>, mst@...hat.com, virtualization@...ts.linux-foundation.org, brett.creeley@....com, netdev@...r.kernel.org Cc: simon.horman@...igine.com, drivers@...sando.io Subject: Re: [PATCH v5 virtio 01/11] virtio: allow caller to override device id in vp_modern 在 2023/5/4 02:12, Shannon Nelson 写道: > To add a bit of vendor flexibility with various virtio based devices, > allow the caller to check for a different device id. This adds a function > pointer field to struct virtio_pci_modern_device to specify an override > device id check. If defined by the driver, this function will be called > to check that the PCI device is the vendor's expected device, and will > return the found device id to be stored in mdev->id.device. This allows > vendors with alternative vendor device ids to use this library on their > own device BAR. > > Note: A lot of the diff in this is simply indenting the existing code > into an else block. > > Signed-off-by: Shannon Nelson <shannon.nelson@....com> Acked-by: Jason Wang <jasowang@...hat.com> Thanks > --- > drivers/virtio/virtio_pci_modern_dev.c | 30 ++++++++++++++++---------- > include/linux/virtio_pci_modern.h | 3 +++ > 2 files changed, 22 insertions(+), 11 deletions(-) > > diff --git a/drivers/virtio/virtio_pci_modern_dev.c b/drivers/virtio/virtio_pci_modern_dev.c > index 869cb46bef96..9b2d6614de67 100644 > --- a/drivers/virtio/virtio_pci_modern_dev.c > +++ b/drivers/virtio/virtio_pci_modern_dev.c > @@ -218,21 +218,29 @@ int vp_modern_probe(struct virtio_pci_modern_device *mdev) > int err, common, isr, notify, device; > u32 notify_length; > u32 notify_offset; > + int devid; > > check_offsets(); > > - /* We only own devices >= 0x1000 and <= 0x107f: leave the rest. */ > - if (pci_dev->device < 0x1000 || pci_dev->device > 0x107f) > - return -ENODEV; > - > - if (pci_dev->device < 0x1040) { > - /* Transitional devices: use the PCI subsystem device id as > - * virtio device id, same as legacy driver always did. > - */ > - mdev->id.device = pci_dev->subsystem_device; > + if (mdev->device_id_check) { > + devid = mdev->device_id_check(pci_dev); > + if (devid < 0) > + return devid; > + mdev->id.device = devid; > } else { > - /* Modern devices: simply use PCI device id, but start from 0x1040. */ > - mdev->id.device = pci_dev->device - 0x1040; > + /* We only own devices >= 0x1000 and <= 0x107f: leave the rest. */ > + if (pci_dev->device < 0x1000 || pci_dev->device > 0x107f) > + return -ENODEV; > + > + if (pci_dev->device < 0x1040) { > + /* Transitional devices: use the PCI subsystem device id as > + * virtio device id, same as legacy driver always did. > + */ > + mdev->id.device = pci_dev->subsystem_device; > + } else { > + /* Modern devices: simply use PCI device id, but start from 0x1040. */ > + mdev->id.device = pci_dev->device - 0x1040; > + } > } > mdev->id.vendor = pci_dev->subsystem_vendor; > > diff --git a/include/linux/virtio_pci_modern.h b/include/linux/virtio_pci_modern.h > index c4eeb79b0139..e7b1db1dd0bb 100644 > --- a/include/linux/virtio_pci_modern.h > +++ b/include/linux/virtio_pci_modern.h > @@ -38,6 +38,9 @@ struct virtio_pci_modern_device { > int modern_bars; > > struct virtio_device_id id; > + > + /* optional check for vendor virtio device, returns dev_id or -ERRNO */ > + int (*device_id_check)(struct pci_dev *pdev); > }; > > /*
Powered by blists - more mailing lists