From: Cornelia Huck <cohuck@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, Jared Rossi <jrossi@linux.ibm.com>,
Eric Farman <farman@linux.ibm.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Cornelia Huck <cohuck@redhat.com>
Subject: [PULL 04/15] pc-bios/s390-ccw: Verify virtio support when booting from virtio PCI device on s390x
Date: Tue, 7 Jul 2026 14:58:36 +0200 [thread overview]
Message-ID: <20260707125847.1785168-5-cohuck@redhat.com> (raw)
In-Reply-To: <20260707125847.1785168-1-cohuck@redhat.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>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Tested-by: Matthew Rosato <mjrosato@linux.ibm.com>
Message-ID: <20260630141917.673995-5-jrossi@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.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 26287cfd8112..fb47d29bb1f2 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 2c83ec4f1316..f501252c8199 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 2494df161988..33b683bd922c 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 df04479aa69c..a0d249db2408 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 75ae5bdbc229..aa307025e0f5 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-07-07 12:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 12:58 [PULL 00/15] s390x updates (contains Linux headers update) Cornelia Huck
2026-07-07 12:58 ` [PULL 01/15] pc-bios/s390-ccw: Refactor byte swapping Cornelia Huck
2026-07-07 12:58 ` [PULL 02/15] pc-bios/s390-ccw/virtio.c: Fix missing break for PCI notifications Cornelia Huck
2026-07-07 12:58 ` [PULL 03/15] pc-bios/s390-ccw: Add per-queue notification offset for multi-queue virtio configurations Cornelia Huck
2026-07-07 12:58 ` Cornelia Huck [this message]
2026-07-07 12:58 ` [PULL 05/15] pc-bios/s390-ccw: write IPLB location for non-net virtio devices Cornelia Huck
2026-07-07 12:58 ` [PULL 06/15] s390x: Enable boot menu for virtio pci device Cornelia Huck
2026-07-07 12:58 ` [PULL 07/15] linux-headers: Update to Linux v7.2-rc1 with KVM_S390_VM_CPU_FEAT_ASTFLEIE2 Cornelia Huck
2026-07-07 12:58 ` [PULL 08/15] s390x/kvm: Add ASTFLE facility 2 for nested virtualization Cornelia Huck
2026-07-07 12:58 ` [PULL 09/15] target/s390x: Fix wrong address handling in address loops Cornelia Huck
2026-07-07 12:58 ` [PULL 10/15] s390x/sclp: reject invalid write event data headers Cornelia Huck
2026-07-07 12:58 ` [PULL 11/15] s390x/pci: Tighten region detection for BAR read/write Cornelia Huck
2026-07-07 12:58 ` [PULL 12/15] s390x/pci: Shrink RPCIT ranges to registered window Cornelia Huck
2026-07-07 12:58 ` [PULL 13/15] s390x/ioinst: Require strict length and format for SEI CHSC handler Cornelia Huck
2026-07-07 12:58 ` [PULL 14/15] s390x/css: limit number of CHPIDs in description Cornelia Huck
2026-07-07 12:58 ` [PULL 15/15] pc-bios/s390-ccw.img: update s390x bios Cornelia Huck
2026-07-08 5:54 ` [PULL 00/15] s390x updates (contains Linux headers update) Stefan Hajnoczi
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=20260707125847.1785168-5-cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=farman@linux.ibm.com \
--cc=jrossi@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
/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.