From: jrossi@linux.ibm.com
To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com,
mjrosato@linux.ibm.com
Cc: jrossi@linux.ibm.com, zycai@linux.ibm.com, jdaley@linux.ibm.com,
jjherne@linux.ibm.com, farman@linux.ibm.com, nrb@linux.ibm.com
Subject: [PATCH v2 4/6] pc-bios/s390-ccw: Verify virtio support when booting from virtio PCI device on s390x
Date: Tue, 30 Jun 2026 10:19:15 -0400 [thread overview]
Message-ID: <20260630141917.673995-5-jrossi@linux.ibm.com> (raw)
In-Reply-To: <20260630141917.673995-1-jrossi@linux.ibm.com>
From: Jared Rossi <jrossi@linux.ibm.com>
The virtio specification requires that each PCI device has a vendor ID of
0x1af4. Verify this value before continuing with boot process.
Signed-off-by: Jared Rossi <jrossi@linux.ibm.com>
---
pc-bios/s390-ccw/main.c | 1 +
pc-bios/s390-ccw/virtio-pci.c | 19 +++++++++++++++++++
pc-bios/s390-ccw/virtio-pci.h | 3 +++
pc-bios/s390-ccw/virtio.c | 2 ++
pc-bios/s390-ccw/virtio.h | 1 +
5 files changed, 26 insertions(+)
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
index 26287cfd81..fb47d29bb1 100644
--- a/pc-bios/s390-ccw/main.c
+++ b/pc-bios/s390-ccw/main.c
@@ -163,6 +163,7 @@ static bool find_fid(uint32_t fid)
}
vdev->pci_fh = entry.fh;
+ vdev->vendor_id = entry.vendor_id;
virtio_pci_id2type(vdev, entry.device_id);
return vdev->dev_type != 0;
diff --git a/pc-bios/s390-ccw/virtio-pci.c b/pc-bios/s390-ccw/virtio-pci.c
index 2c83ec4f13..f501252c81 100644
--- a/pc-bios/s390-ccw/virtio-pci.c
+++ b/pc-bios/s390-ccw/virtio-pci.c
@@ -325,6 +325,20 @@ static int enable_pci_bus_master(void)
return 0;
}
+bool virtio_pci_is_supported(VDev *vdev)
+{
+ if (vdev->vendor_id == PCI_VENDOR_VIRTIO) {
+ switch (vdev->dev_type) {
+ case VIRTIO_ID_BLOCK:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ return false;
+}
+
int virtio_pci_setup(VDev *vdev)
{
VRing *vr;
@@ -335,6 +349,11 @@ int virtio_pci_setup(VDev *vdev)
vdev->guessed_disk_nature = VIRTIO_GDN_NONE;
vdev->cmd_vr_idx = 0;
+ if (!virtio_pci_is_supported(vdev)) {
+ puts("Virtio PCI unsupported for this device ID");
+ return -ENODEV;
+ }
+
if (virtio_pci_read_pci_cap_config()) {
puts("Invalid virtio PCI capabilities");
return -EIO;
diff --git a/pc-bios/s390-ccw/virtio-pci.h b/pc-bios/s390-ccw/virtio-pci.h
index 2494df1619..33b683bd92 100644
--- a/pc-bios/s390-ccw/virtio-pci.h
+++ b/pc-bios/s390-ccw/virtio-pci.h
@@ -56,6 +56,8 @@
#define VIRTIO_F_VERSION_1 1 /* Feature bit 32 */
+#define PCI_VENDOR_VIRTIO 0x1af4
+
struct VirtioPciCap {
uint8_t bar; /* Which PCIAS it's in */
uint32_t off; /* Offset within bar */
@@ -65,6 +67,7 @@ typedef struct VirtioPciCap VirtioPciCap;
void virtio_pci_id2type(VDev *vdev, uint16_t device_id);
int virtio_pci_reset(VDev *vdev);
long virtio_pci_notify(VRing *vr);
+bool virtio_pci_is_supported(VDev *vdev);
int virtio_pci_setup(VDev *vdev);
int virtio_pci_setup_device(void);
diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index df04479aa6..a0d249db24 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -247,6 +247,8 @@ bool virtio_is_supported(VDev *vdev)
case S390_IPL_TYPE_QEMU_SCSI:
case S390_IPL_TYPE_CCW:
return virtio_ccw_is_supported(vdev);
+ case S390_IPL_TYPE_PCI:
+ return virtio_pci_is_supported(vdev);
default:
return false;
}
diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
index 75ae5bdbc2..aa307025e0 100644
--- a/pc-bios/s390-ccw/virtio.h
+++ b/pc-bios/s390-ccw/virtio.h
@@ -259,6 +259,7 @@ struct VDev {
bool scsi_device_selected;
ScsiDevice selected_scsi_device;
uint32_t pci_fh;
+ uint16_t vendor_id;
uint32_t max_transfer;
uint32_t guest_features[2];
};
--
2.54.0
next prev parent reply other threads:[~2026-06-30 14:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 14:19 [PATCH v2 0/6] s390x: Fix intermittent errors with IPL from PCI devices on s390x jrossi
2026-06-30 14:19 ` [PATCH v2 1/6] pc-bios/s390-ccw: Refactor byte swapping jrossi
2026-06-30 14:19 ` [PATCH v2 2/6] pc-bios/s390-ccw/virtio.c: Fix missing break for PCI notifications jrossi
2026-07-02 1:44 ` Eric Farman
2026-07-02 2:12 ` Matthew Rosato
2026-06-30 14:19 ` [PATCH v2 3/6] pc-bios/s390-ccw: Add per-queue notification offset for multi-queue virtio configurations jrossi
2026-07-02 1:49 ` Eric Farman
2026-06-30 14:19 ` jrossi [this message]
2026-07-02 2:03 ` [PATCH v2 4/6] pc-bios/s390-ccw: Verify virtio support when booting from virtio PCI device on s390x Eric Farman
2026-06-30 14:19 ` [PATCH v2 5/6] pc-bios/s390-ccw: write IPLB location for non-net virtio devices jrossi
2026-07-02 2:04 ` Eric Farman
2026-06-30 14:19 ` [PATCH v2 6/6] s390x: Enable boot menu for virtio pci device jrossi
2026-07-02 2:08 ` Matthew Rosato
2026-07-02 2:12 ` [PATCH v2 0/6] s390x: Fix intermittent errors with IPL from PCI devices on s390x Matthew Rosato
2026-07-07 11:59 ` Cornelia Huck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260630141917.673995-5-jrossi@linux.ibm.com \
--to=jrossi@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=farman@linux.ibm.com \
--cc=jdaley@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=nrb@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=zycai@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.