s390x: Add support for virtio-blk-pci IPL device
v5 cover s390x: Add support for virtio-blk-pci IPL device
From: Jared Rossi <[email protected]>
This patch series introduces an IPLB subtype to support PCI devices, which may be built if a device has been assigned a boot index and is identified as a PCI device with a corresponding s390 PCI Bus device.
Boot support is only added for virtio-blk-pci at this time and is limited to devices with an assigned bootindex.
A "loadparm" property is added to virtio-blk-pci boot devices on s390x.
A simple test to check basic functionality is added to the cdrom-tests in qtest.
Changes v4 -> v5:
- Fix incorrect switch/case for virtio block device ID
- Use target_s390x() instead of qemu_arch_available(QEMU_ARCH_S390X)
- Properly denote switch fallthrough
- Remove reduntant RC checks in PCI read/write
Jared Rossi (15):
pc-bios/s390-ccw: Fix misattributed function prototypes pc-bios/s390-ccw: Remove redundant vring schid attribute pc-bios/s390-ccw: Always reset virtio device on failed boot attempt
s390x: Remove duplicate definitions of IPL types pc-bios/s390-ccw: Store device type independent of sense data pc-bios/s390-ccw: Split virtio-ccw and generic virtio include/hw/s390x: Move CLP definitions for easier BIOS access pc-bios/s390-ccw: Introduce CLP Architecture
s390x: Add definitions for PCI IPL type pc-bios/s390-ccw: Introduce PCI device
pc-bios/s390-ccw: Introduce virtio-pci functions pc-bios/s390-ccw: Add support for virtio-blk-pci IPL
s390x: Build IPLB for virtio-pci devices
hw: Add "loadparm" property to virtio block PCI devices booting on
s390x
tests/qtest: Add s390x PCI boot test to cdrom-test.c
MAINTAINERS | 1 +
hw/pci/pci.c | 38 ++
hw/s390x/ipl.c | 63 +++-
hw/s390x/ipl.h | 8 +-
hw/s390x/s390-pci-bus.c | 3 +-
hw/s390x/s390-pci-vfio.c | 2 +-
hw/virtio/virtio-blk-pci.c | 1 +
include/hw/pci/pci.h | 1 +
include/hw/pci/pci_device.h | 3 +
include/hw/s390x/ipl/qipl.h | 20 +
include/hw/s390x/{ => ipl}/s390-pci-clp.h | 0
include/hw/s390x/s390-pci-bus.h | 4 +-
pc-bios/s390-ccw/Makefile | 3 +-
pc-bios/s390-ccw/bootmap.c | 2 +-
pc-bios/s390-ccw/clp.c | 99 +++++
pc-bios/s390-ccw/clp.h | 24 ++
pc-bios/s390-ccw/iplb.h | 4 -
pc-bios/s390-ccw/main.c | 88 ++++-
pc-bios/s390-ccw/netmain.c | 2 +-
pc-bios/s390-ccw/pci.c | 118 ++++++
pc-bios/s390-ccw/pci.h | 42 +++
pc-bios/s390-ccw/s390-ccw.h | 7 -
pc-bios/s390-ccw/virtio-blkdev.c | 76 ++--
pc-bios/s390-ccw/virtio-ccw.c | 241 ++++++++++++
pc-bios/s390-ccw/virtio-ccw.h | 24 ++
pc-bios/s390-ccw/virtio-net.c | 5 +-
pc-bios/s390-ccw/virtio-pci.c | 432 ++++++++++++++++++++++
pc-bios/s390-ccw/virtio-pci.h | 82 ++++
pc-bios/s390-ccw/virtio-scsi.c | 8 +-
pc-bios/s390-ccw/virtio-scsi.h | 2 +-
pc-bios/s390-ccw/virtio.c | 293 +++++----------
pc-bios/s390-ccw/virtio.h | 19 +-
tests/qtest/cdrom-test.c | 7 +
33 files changed, 1449 insertions(+), 273 deletions(-)
rename include/hw/s390x/{ => ipl}/s390-pci-clp.h (100%)
create mode 100644 pc-bios/s390-ccw/clp.c
create mode 100644 pc-bios/s390-ccw/clp.h
create mode 100644 pc-bios/s390-ccw/pci.c
create mode 100644 pc-bios/s390-ccw/pci.h
create mode 100644 pc-bios/s390-ccw/virtio-ccw.c
create mode 100644 pc-bios/s390-ccw/virtio-ccw.h
create mode 100644 pc-bios/s390-ccw/virtio-pci.c
create mode 100644 pc-bios/s390-ccw/virtio-pci.hSignature · 1 line
2.52.0
PATCH v5 1/15 pc-bios/s390-ccw: Fix misattributed function prototypes
From: Jared Rossi <[email protected]>
The virtio-blkdev functions are incorrectly listed in s390-ccw.h as belonging to virtio.c. Additionally, virtio_load_direct() has an unused subchan_id argument.
Remove the unused argument and move the prototypes to virtio.h so that they are independent from the CCW bus.
--- pc-bios/s390-ccw/bootmap.c | 2 +- pc-bios/s390-ccw/s390-ccw.h | 4 ---- pc-bios/s390-ccw/virtio-blkdev.c | 2 +- pc-bios/s390-ccw/virtio.h | 7 +++++++ 4 files changed, 9 insertions(+), 6 deletions(-)
pc-bios/s390-ccw/bootmap.c +1 -1
@@ -662,7 +662,7 @@ static int zipl_load_segment(ComponentEntry *entry)*/ break ; } - address =virtio_load_direct (cur_desc[0 ], cur_desc[1 ],0 , + address =virtio_load_direct (cur_desc[0 ], cur_desc[1 ], (void *)address);if (!address) {puts ("zIPL load segment failed" );
pc-bios/s390-ccw/s390-ccw.h +0 -4
@@ -67,11 +67,7 @@ void sclp_get_loadparm_ascii(char *loadparm);int sclp_read (char *str,size_t count);/* virtio.c */ -unsigned long virtio_load_direct (unsigned long rec_list1,unsigned long rec_list2, -unsigned long subchan_id,void *load_addr);bool virtio_is_supported (SubChannelId schid); -int virtio_blk_setup_device (SubChannelId schid); -int virtio_read (unsigned long sector,void *load_addr);/* bootmap.c */ void zipl_load (void );
pc-bios/s390-ccw/virtio-blkdev.c +1 -1
@@ -64,7 +64,7 @@ int virtio_read_many(unsigned long sector, void *load_addr, int sec_num) }unsigned long virtio_load_direct (unsigned long rec_list1,unsigned long rec_list2, -unsigned long subchan_id,void *load_addr) +void *load_addr) {u8 status;int sec = rec_list1;
pc-bios/s390-ccw/virtio.h +7 -0
@@ -277,7 +277,14 @@ int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd);int virtio_reset (VDev *vdev);int virtio_setup_ccw (VDev *vdev); +/* virtio-net.c */ int virtio_net_init (void *mac_addr);void virtio_net_deinit (void ); +/* virtio-blkdev.c */ +int virtio_blk_setup_device (SubChannelId schid); +int virtio_read (unsigned long sector,void *load_addr); +unsigned long virtio_load_direct (unsigned long rec_list1,unsigned long rec_list2, +void *load_addr); +#endif /* VIRTIO_H */
Signature · 1 line
2.52.0
PATCH v5 2/15 pc-bios/s390-ccw: Remove redundant vring schid attribute
In reply to [email protected]From: Jared Rossi <[email protected]>
The schid is already stored as an attribute of the VDev itself and any other instances are copies of this same value. To avoid CCW specific attributes in the VRing let's just access the existing VDev schid attribute as needed.
--- pc-bios/s390-ccw/virtio-blkdev.c | 2 +- pc-bios/s390-ccw/virtio-net.c | 2 +- pc-bios/s390-ccw/virtio.c | 9 ++++----- pc-bios/s390-ccw/virtio.h | 3 +-- 4 files changed, 7 insertions(+), 9 deletions(-)
pc-bios/s390-ccw/virtio-blkdev.c +1 -1
@@ -42,7 +42,7 @@ static int virtio_blk_read_many(VDev *vdev, unsigned long sector, void *load_add/* Now we can tell the host to read */ vring_wait_reply (); -if (drain_irqs (vr->schid)) { +if (drain_irqs ()) {/* Well, whatever status is supposed to contain... */ status =1 ; }
pc-bios/s390-ccw/virtio-net.c +1 -1
@@ -88,7 +88,7 @@ int send(int fd, const void *buf, int len, int flags)while (!vr_poll (txvq)) {yield (); } -if (drain_irqs (txvq->schid)) { +if (drain_irqs ()) {puts ("send: drain irqs failed" );return -1 ; }
pc-bios/s390-ccw/virtio.c +4 -5
@@ -72,14 +72,14 @@ static long virtio_notify(SubChannelId schid, int vq_idx, long cookie)* Virtio functions * ***********************************************/ -int drain_irqs (SubChannelId schid) +int drain_irqs (void ) {Irb irb = {};int r =0 ;while (1 ) {/* FIXME: make use of TPI, for that enable subchannel and isc */ -if (tsch (schid, &irb)) { +if (tsch (vdev.schid, &irb)) {/* Might want to differentiate error codes later on. */ if (irb.scsw.cstat) { r = -EIO ;
@@ -134,7 +134,7 @@ static void vring_init(VRing *vr, VqInfo *info)bool vring_notify (VRing *vr) { - vr->cookie =virtio_notify (vr->schid, vr->id, vr->cookie); + vr->cookie =virtio_notify (vdev.schid, vr->id, vr->cookie);return vr->cookie >=0 ; }
@@ -211,7 +211,7 @@ int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd) }while (cmd[i++].flags &VRING_DESC_F_NEXT );vring_wait_reply (); -if (drain_irqs (vr->schid)) { +if (drain_irqs ()) {return -1 ; }return 0 ;
@@ -316,7 +316,6 @@ int virtio_setup_ccw(VDev *vdev) } info.num = config.num;vring_init (&vdev->vrings[i], &info); - vdev->vrings[i].schid = vdev->schid;if (run_ccw (vdev,CCW_CMD_SET_VQ , &info,sizeof (info), false)) {puts ("Cannot set VQ info" );return -EIO ;
pc-bios/s390-ccw/virtio.h +1 -2
@@ -103,7 +103,6 @@ struct VRing {VRingDesc *desc;VRingAvail *avail;VRingUsed *used; -SubChannelId schid;long cookie;int id; };
@@ -269,7 +268,7 @@ struct VirtioCmd {typedef struct VirtioCmd VirtioCmd ;bool vring_notify (VRing *vr); -int drain_irqs (SubChannelId schid); +int drain_irqs (void );void vring_send_buf (VRing *vr,void *p,int len,int flags);int vr_poll (VRing *vr);int vring_wait_reply (void );
Signature · 1 line
2.52.0
PATCH v5 3/15 pc-bios/s390-ccw: Always reset virtio device on failed boot attempt
In reply to [email protected]From: Jared Rossi <[email protected]>
The virtio spec necessitates that live virtqueues must not be altered. Reset the failed device so that the queues are not live before we attempt to boot any fallback devices.
--- pc-bios/s390-ccw/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
pc-bios/s390-ccw/main.c +2 -1
@@ -277,7 +277,8 @@ static void ipl_boot_device(void)break ;case CU_TYPE_VIRTIO :if (virtio_setup () ==0 ) { -zipl_load (); +zipl_load ();/* only return on error */ +virtio_reset (virtio_get_device ()); }break ;default :
Signature · 1 line
2.52.0
PATCH v5 4/15 s390x: Remove duplicate definitions of IPL types
In reply to [email protected]From: Jared Rossi <[email protected]>
Remove the duplicate definitions from hw/s390x/ipl.h and pc-bios/s390-ccw/iplb.h and add a shared definition. The new definition is an enum to enforce default handling in switches.
Because the IPL type is determined by the IPLB, and because an IPLB is not strictly necessary, the IPL type is set to a default value if not otherwise specified. A default IPL type is required so future functionality may add IPL new bus and/or device types that dictate specific behavior during IPL.
--- hw/s390x/ipl.h | 5 ----- include/hw/s390x/ipl/qipl.h | 10 ++++++++++ pc-bios/s390-ccw/iplb.h | 4 ---- pc-bios/s390-ccw/main.c | 14 ++++++++++---- pc-bios/s390-ccw/virtio.h | 1 + 5 files changed, 21 insertions(+), 13 deletions(-)
hw/s390x/ipl.h +0 -5
@@ -103,11 +103,6 @@ QEMU_BUILD_BUG_MSG(offsetof(S390IPLState, iplb) & 3, "alignment of iplb wrong");#define DIAG308_PV_STORE 9#define DIAG308_PV_START 10 -#define S390_IPL_TYPE_FCP 0x00 -#define S390_IPL_TYPE_CCW 0x02 -#define S390_IPL_TYPE_PV 0x05 -#define S390_IPL_TYPE_QEMU_SCSI 0xff -#define S390_IPLB_HEADER_LEN 8#define S390_IPLB_MIN_PV_LEN 148#define S390_IPLB_MIN_CCW_LEN 200
include/hw/s390x/ipl/qipl.h +10 -0
@@ -20,6 +20,16 @@#define LOADPARM_LEN 8#define NO_LOADPARM "\0\0\0\0\0\0\0\0" +enum S390IplType { +S390_IPL_TYPE_FCP =0x00 , +S390_IPL_TYPE_CCW =0x02 , +S390_IPL_TYPE_PV =0x05 , +S390_IPL_TYPE_QEMU_SCSI =0xff +}; +typedef enum S390IplType S390IplType ; + +#define QEMU_DEFAULT_IPL S390_IPL_TYPE_CCW +/* * The QEMU IPL Parameters will be stored at absolute address * 204 (0xcc) which means it is 32-bit word aligned but not
pc-bios/s390-ccw/iplb.h +0 -4
@@ -23,10 +23,6 @@ extern QemuIplParameters qipl; extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE)));extern bool have_iplb; -#define S390_IPL_TYPE_FCP 0x00 -#define S390_IPL_TYPE_CCW 0x02 -#define S390_IPL_TYPE_QEMU_SCSI 0xff -static inline bool manage_iplb (IplParameterBlock *iplb,bool store) { register unsigned long addr asm("0") = (unsigned long) iplb;
pc-bios/s390-ccw/main.c +10 -4
@@ -149,7 +149,7 @@ static bool find_subch(int dev_no)return false; } -static void menu_setup (void ) +static void menu_setup (VDev *vdev) {if (memcmp (loadparm_str,LOADPARM_PROMPT ,LOADPARM_LEN ) ==0 ) {menu_set_parms (QIPL_FLAG_BM_OPTS_CMD ,0 );
@@ -162,11 +162,13 @@ static void menu_setup(void)return ; } -switch (iplb.pbt) { +switch (vdev->ipl_type) {case S390_IPL_TYPE_CCW :case S390_IPL_TYPE_QEMU_SCSI :menu_set_parms (qipl.qipl_flags &BOOT_MENU_FLAG_MASK , qipl.boot_menu_timeout); +/* fall through */ +default :return ; } }
@@ -190,6 +192,7 @@ static void css_setup(void)static void boot_setup (void ) {char lpmsg[] ="LOADPARM=[________]\n" ; +VDev *vdev =virtio_get_device ();if (have_iplb &&memcmp (iplb.loadparm,NO_LOADPARM ,LOADPARM_LEN ) !=0 ) {ebcdic_to_ascii ((char *) iplb.loadparm, loadparm_str,LOADPARM_LEN );
@@ -198,7 +201,10 @@ static void boot_setup(void) }if (have_iplb) { -menu_setup (); + vdev->ipl_type = iplb.pbt; +menu_setup (vdev); + }else { + vdev->ipl_type =QEMU_DEFAULT_IPL ; }memcpy (lpmsg +10 , loadparm_str,8 );
@@ -216,7 +222,7 @@ static bool find_boot_device(void)VDev *vdev =virtio_get_device ();bool found = false; -switch (iplb.pbt) { +switch (vdev->ipl_type) {case S390_IPL_TYPE_CCW : vdev->scsi_device_selected = false;debug_print_int ("device no. " , iplb.ccw.devno);
pc-bios/s390-ccw/virtio.h +1 -0
@@ -238,6 +238,7 @@ struct VDev {VirtioGDN guessed_disk_nature;SubChannelId schid;SenseId senseid; +S390IplType ipl_type;union {VirtioBlkConfig blk;VirtioScsiConfig scsi;
Signature · 1 line
2.52.0
PATCH v5 5/15 pc-bios/s390-ccw: Store device type independent of sense data
In reply to [email protected]From: Jared Rossi <[email protected]>
Store the device type (e.g. block) directly as an attribute of the VDev rather than assume all devices can be identified by accessing CCW specific sense data.
--- pc-bios/s390-ccw/main.c | 2 +- pc-bios/s390-ccw/virtio-blkdev.c | 39 +++++++++++++++++++------------- pc-bios/s390-ccw/virtio.c | 11 ++++++--- pc-bios/s390-ccw/virtio.h | 1 + 4 files changed, 33 insertions(+), 20 deletions(-)
pc-bios/s390-ccw/main.c +1 -1
@@ -251,7 +251,7 @@ static int virtio_setup(void) vdev->is_cdrom = false;int ret; -switch (vdev->senseid.cu_model) { +switch (vdev->dev_type) {case VIRTIO_ID_NET :puts ("Network boot device detected" );return 0 ;
pc-bios/s390-ccw/virtio-blkdev.c +23 -16
@@ -53,14 +53,14 @@ int virtio_read_many(unsigned long sector, void *load_addr, int sec_num) {VDev *vdev =virtio_get_device (); -switch (vdev->senseid.cu_model) { +switch (vdev->dev_type) {case VIRTIO_ID_BLOCK :return virtio_blk_read_many (vdev, sector, load_addr, sec_num);case VIRTIO_ID_SCSI :return virtio_scsi_read_many (vdev, sector, load_addr, sec_num); +default : +return -1 ; } - -return -1 ; } unsigned long virtio_load_direct(unsigned long rec_list1, unsigned long rec_list2,
@@ -119,7 +119,7 @@ void virtio_assume_iso9660(void) {VDev *vdev =virtio_get_device (); -switch (vdev->senseid.cu_model) { +switch (vdev->dev_type) {case VIRTIO_ID_BLOCK : vdev->guessed_disk_nature =VIRTIO_GDN_SCSI ; vdev->config.blk.blk_size =VIRTIO_ISO_BLOCK_SIZE ;
@@ -129,6 +129,8 @@ void virtio_assume_iso9660(void)case VIRTIO_ID_SCSI : vdev->scsi_block_size =VIRTIO_ISO_BLOCK_SIZE ;break ; +default : +return ; } }
@@ -139,13 +141,15 @@ void virtio_assume_eckd(void) vdev->guessed_disk_nature =VIRTIO_GDN_DASD ; vdev->blk_factor =1 ; vdev->config.blk.physical_block_exp =0 ; -switch (vdev->senseid.cu_model) { +switch (vdev->dev_type) {case VIRTIO_ID_BLOCK : vdev->config.blk.blk_size =VIRTIO_DASD_DEFAULT_BLOCK_SIZE ;break ;case VIRTIO_ID_SCSI : vdev->config.blk.blk_size = vdev->scsi_block_size;break ; +default : +break ; } vdev->config.blk.geometry.heads =15 ; vdev->config.blk.geometry.sectors =
@@ -162,50 +166,52 @@ bool virtio_ipl_disk_is_valid(void)return true; } -return (vdev->senseid.cu_model ==VIRTIO_ID_BLOCK || - vdev->senseid.cu_model ==VIRTIO_ID_SCSI ) && - blksize >=512 && blksize <=4096 ; +return (vdev->dev_type ==VIRTIO_ID_BLOCK || vdev->dev_type ==VIRTIO_ID_SCSI ) + && blksize >=512 && blksize <=4096 ; }int virtio_get_block_size (void ) {VDev *vdev =virtio_get_device (); -switch (vdev->senseid.cu_model) { +switch (vdev->dev_type) {case VIRTIO_ID_BLOCK :return vdev->config.blk.blk_size;case VIRTIO_ID_SCSI :return vdev->scsi_block_size; +default : +return 0 ; } -return 0 ; }uint8_t virtio_get_heads (void ) {VDev *vdev =virtio_get_device (); -switch (vdev->senseid.cu_model) { +switch (vdev->dev_type) {case VIRTIO_ID_BLOCK :return vdev->config.blk.geometry.heads;case VIRTIO_ID_SCSI :return vdev->guessed_disk_nature ==VIRTIO_GDN_DASD ? vdev->config.blk.geometry.heads :255 ; +default : +return 0 ; } -return 0 ; }uint8_t virtio_get_sectors (void ) {VDev *vdev =virtio_get_device (); -switch (vdev->senseid.cu_model) { +switch (vdev->dev_type) {case VIRTIO_ID_BLOCK :return vdev->config.blk.geometry.sectors;case VIRTIO_ID_SCSI :return vdev->guessed_disk_nature ==VIRTIO_GDN_DASD ? vdev->config.blk.geometry.sectors :63 ; +default : +return 0 ; } -return 0 ; }uint64_t virtio_get_blocks (void )
@@ -213,13 +219,14 @@ uint64_t virtio_get_blocks(void)VDev *vdev =virtio_get_device ();const uint64_t factor =virtio_get_block_size () /VIRTIO_SECTOR_SIZE ; -switch (vdev->senseid.cu_model) { +switch (vdev->dev_type) {case VIRTIO_ID_BLOCK :return vdev->config.blk.capacity / factor;case VIRTIO_ID_SCSI :return vdev->scsi_last_block / factor; +default : +return 0 ; } -return 0 ; }int virtio_blk_setup_device (SubChannelId schid)
pc-bios/s390-ccw/virtio.c +8 -3
@@ -41,7 +41,7 @@ VDev *virtio_get_device(void)VirtioDevType virtio_get_device_type (void ) { -return vdev.senseid.cu_model; +return vdev.dev_type; }/* virtio spec v1.0 para 4.3.3.2 */
@@ -248,7 +248,7 @@ int virtio_setup_ccw(VDev *vdev)return -EIO ; } -switch (vdev->senseid.cu_model) { +switch (vdev->dev_type) {case VIRTIO_ID_NET : vdev->nr_vqs =2 ; vdev->cmd_vr_idx =0 ;
@@ -346,12 +346,17 @@ bool virtio_is_supported(SubChannelId schid) true)) {return false; } + + vdev.dev_type = vdev.senseid.cu_model; +if (vdev.senseid.cu_type ==0x3832 ) { -switch (vdev.senseid.cu_model) { +switch (vdev.dev_type) {case VIRTIO_ID_BLOCK :case VIRTIO_ID_SCSI :case VIRTIO_ID_NET :return true; +default : +return false; } }return false;
pc-bios/s390-ccw/virtio.h +1 -0
@@ -239,6 +239,7 @@ struct VDev {SubChannelId schid;SenseId senseid;S390IplType ipl_type; +VirtioDevType dev_type;union {VirtioBlkConfig blk;VirtioScsiConfig scsi;
Signature · 1 line
2.52.0
PATCH v5 6/15 pc-bios/s390-ccw: Split virtio-ccw and generic virtio
In reply to [email protected]From: Jared Rossi <[email protected]>
Separate the CCW specific virtio routines and create generic wrappers for easier reuse of existing virtio functions with non-CCW devices.
--- pc-bios/s390-ccw/Makefile | 3 +- pc-bios/s390-ccw/main.c | 8 +- pc-bios/s390-ccw/netmain.c | 2 +- pc-bios/s390-ccw/s390-ccw.h | 3 - pc-bios/s390-ccw/virtio-blkdev.c | 15 +- pc-bios/s390-ccw/virtio-ccw.c | 241 +++++++++++++++++++++++++++++++ pc-bios/s390-ccw/virtio-ccw.h | 24 +++ pc-bios/s390-ccw/virtio-net.c | 3 +- pc-bios/s390-ccw/virtio-scsi.c | 8 +- pc-bios/s390-ccw/virtio-scsi.h | 2 +- pc-bios/s390-ccw/virtio.c | 239 +++++------------------------- pc-bios/s390-ccw/virtio.h | 5 +- 12 files changed, 332 insertions(+), 221 deletions(-) create mode 100644 pc-bios/s390-ccw/virtio-ccw.c create mode 100644 pc-bios/s390-ccw/virtio-ccw.h
pc-bios/s390-ccw/Makefile +2 -1
@@ -34,7 +34,8 @@ QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d .PHONY : all clean build-all distclean OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o netmain.o \ - virtio.o virtio-net.o virtio-scsi.o virtio-blkdev.o cio.o dasd-ipl.o + virtio.o virtio-net.o virtio-scsi.o virtio-blkdev.o cio.o dasd-ipl.o \ + virtio-ccw.o SLOF_DIR := $(SRC_PATH)/../../roms/SLOF
pc-bios/s390-ccw/main.c +5 -3
@@ -71,6 +71,7 @@ static int is_dev_possibly_bootable(int dev_no, int sch_no)bool is_virtio;Schib schib;int r; +VDev *vdev =virtio_get_device (); blk_schid.sch_no = sch_no; r =stsch_err (blk_schid, &schib);
@@ -91,7 +92,8 @@ static int is_dev_possibly_bootable(int dev_no, int sch_no)* Note: we always have to run virtio_is_supported() here to make * sure that the vdev.senseid data gets pre-initialized correctly */ - is_virtio =virtio_is_supported (blk_schid); + vdev->schid = blk_schid; + is_virtio =virtio_is_supported (vdev);/* No specific devno given, just return whether the device is possibly bootable */ if (dev_no <0 ) {
@@ -256,10 +258,10 @@ static int virtio_setup(void)puts ("Network boot device detected" );return 0 ;case VIRTIO_ID_BLOCK : - ret =virtio_blk_setup_device (blk_schid); + ret =virtio_blk_setup_device (vdev);break ;case VIRTIO_ID_SCSI : - ret =virtio_scsi_setup_device (blk_schid); + ret =virtio_scsi_setup_device (vdev);break ;default :puts ("\n! No IPL device available !\n" );
pc-bios/s390-ccw/netmain.c +1 -1
@@ -500,7 +500,7 @@ static bool find_net_dev(Schib *schib, int dev_no)continue ; }enable_subchannel (net_schid); -if (!virtio_is_supported (net_schid)) { +if (!virtio_is_supported (virtio_get_device ())) {continue ; }if (virtio_get_device_type () !=VIRTIO_ID_NET ) {
pc-bios/s390-ccw/s390-ccw.h +0 -3
@@ -66,9 +66,6 @@ void sclp_setup(void);void sclp_get_loadparm_ascii (char *loadparm);int sclp_read (char *str,size_t count); -/* virtio.c */ -bool virtio_is_supported (SubChannelId schid); -/* bootmap.c */ void zipl_load (void );
pc-bios/s390-ccw/virtio-blkdev.c +9 -6
@@ -12,6 +12,7 @@#include "s390-ccw.h" #include "virtio.h" #include "virtio-scsi.h" +#include "virtio-ccw.h" #define VIRTIO_BLK_F_GEOMETRY (1 << 4)#define VIRTIO_BLK_F_BLK_SIZE (1 << 6)
@@ -229,15 +230,17 @@ uint64_t virtio_get_blocks(void) } } -int virtio_blk_setup_device (SubChannelId schid) +int virtio_blk_setup_device (VDev *vdev) { -VDev *vdev =virtio_get_device (); - vdev->guest_features[0 ] =VIRTIO_BLK_F_GEOMETRY |VIRTIO_BLK_F_BLK_SIZE ; - vdev->schid = schid; -virtio_setup_ccw (vdev);puts ("Using virtio-blk." ); -return 0 ; +switch (vdev->ipl_type) { +case S390_IPL_TYPE_QEMU_SCSI : +case S390_IPL_TYPE_CCW : +return virtio_ccw_setup (vdev); +default : +return 1 ; + } }
pc-bios/s390-ccw/virtio-ccw.c new file +241 -0
241 lines not on this page · raw message
pc-bios/s390-ccw/virtio-ccw.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Virtio definitions for CCW devices +* +* Copyright 2025 IBM Corp. +* Author(s): Jared Rossi <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef VIRTIO_CCW_H +#define VIRTIO_CCW_H + +/* main.c */ +extern SubChannelId blk_schid; + +/* virtio-ccw.c */ +int drain_irqs_ccw (SubChannelId schid); +bool virtio_ccw_is_supported (VDev *vdev); +int virtio_ccw_run (VDev *vdev,int vqid,VirtioCmd *cmd); +long virtio_ccw_notify (SubChannelId schid,int vq_idx,long cookie); +int virtio_ccw_setup (VDev *vdev); +int virtio_ccw_reset (VDev *vdev); + +#endif
pc-bios/s390-ccw/virtio-net.c +2 -1
@@ -19,6 +19,7 @@#include <ethernet.h> #include "s390-ccw.h" #include "virtio.h" +#include "virtio-ccw.h" #include "s390-time.h" #include "helper.h"
@@ -54,7 +55,7 @@ int virtio_net_init(void *mac_addr) rx_last_idx =0 ; vdev->guest_features[0 ] =VIRTIO_NET_F_MAC_BIT ; -virtio_setup_ccw (vdev); +virtio_ccw_setup (vdev);if (!(vdev->guest_features[0 ] &VIRTIO_NET_F_MAC_BIT )) {puts ("virtio-net device does not support the MAC address feature" );
pc-bios/s390-ccw/virtio-scsi.c +3 -5
@@ -15,6 +15,7 @@#include "virtio.h" #include "scsi.h" #include "virtio-scsi.h" +#include "virtio-ccw.h" #include "s390-time.h" #include "helper.h"
@@ -476,12 +477,9 @@ static int virtio_scsi_setup(VDev *vdev)return 0 ; } -int virtio_scsi_setup_device (SubChannelId schid) +int virtio_scsi_setup_device (VDev *vdev) { -VDev *vdev =virtio_get_device (); - - vdev->schid = schid; -virtio_setup_ccw (vdev); +virtio_ccw_setup (vdev);if (vdev->config.scsi.sense_size !=VIRTIO_SCSI_SENSE_SIZE ) {puts ("Config: sense size mismatch" );
pc-bios/s390-ccw/virtio-scsi.h +1 -1
@@ -69,6 +69,6 @@ static inline bool virtio_scsi_response_ok(const VirtioScsiCmdResp *r)int virtio_scsi_read_many (VDev *vdev,unsigned long sector,void *load_addr,int sec_num); -int virtio_scsi_setup_device (SubChannelId schid); +int virtio_scsi_setup_device (VDev *vdev);#endif /* VIRTIO_SCSI_H */
pc-bios/s390-ccw/virtio.c +40 -199
290 lines not on this page · raw message
pc-bios/s390-ccw/virtio.h +4 -1
@@ -108,6 +108,7 @@ struct VRing { };typedef struct VRing VRing ; +char *virtio_get_ring_area (int ring_num);/*********************************************** * Virtio block *
@@ -269,6 +270,8 @@ struct VirtioCmd { };typedef struct VirtioCmd VirtioCmd ; +void vring_init (VRing *vr,VqInfo *info); +bool virtio_is_supported (VDev *vdev);bool vring_notify (VRing *vr);int drain_irqs (void );void vring_send_buf (VRing *vr,void *p,int len,int flags);
@@ -283,7 +286,7 @@ int virtio_net_init(void *mac_addr);void virtio_net_deinit (void );/* virtio-blkdev.c */ -int virtio_blk_setup_device (SubChannelId schid); +int virtio_blk_setup_device (VDev *vdev);int virtio_read (unsigned long sector,void *load_addr);unsigned long virtio_load_direct (unsigned long rec_list1,unsigned long rec_list2,void *load_addr);
Signature · 1 line
2.52.0
Re: [PATCH v5 06/15] pc-bios/s390-ccw: Split virtio-ccw and generic virtio
Quoted 9 lines · On 09/03/2026 01.35, [email protected] wrote:
From: Jared Rossi <[email protected]>
Separate the CCW specific virtio routines and create generic wrappers for easier reuse of existing virtio functions with non-CCW devices.
Reviewed-by Thomas Huth <[email protected]>Reviewed-by Eric Farman <[email protected]>Signed-off-by Jared Rossi <[email protected]>---
...
Quoted 8 lines
pc-bios/s390-ccw/virtio-ccw.c new file +2
-0@@ -0,0 +1,241 @@ +/* +* Virtio functionality for CCW devices
pc-bios/s390-ccw/virtio-ccw.c line 12
Quoted 10 lines
pc-bios/s390-ccw/virtio-ccw.c new file +10
-0+* +* Copyright (c) 2013 Alexander Graf <[email protected]> +* Copyright 2025 IBM Corp. +* +* Author(s): Jared Rossi <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at +* your option) any later version. See the COPYING file in the top-level +* directory. +*/
checkpatch.pl complains here:
ERROR: New file 'pc-bios/s390-ccw/virtio-ccw.c' requires
'SPDX-License-Identifier'
ERROR: New file 'pc-bios/s390-ccw/virtio-ccw.c' must not have license
boilerplate header text, only the SPDX-License-Identifier, unless this file was copied from existing code already having such text.
==> I'll add the SPDX tag to this patch.
Thomas
...
Quoted 14 lines
pc-bios/s390-ccw/virtio-ccw.h new file +8
-0@@ -0,0 +1,24 @@ +/* +* Virtio definitions for CCW devices +* +* Copyright 2025 IBM Corp. +* Author(s): Jared Rossi <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later + */...
PATCH v5 7/15 include/hw/s390x: Move CLP definitions for easier BIOS access
In reply to [email protected]From: Jared Rossi <[email protected]>
Move the s390-pci-clp definitions into the "ipl" sub-directory, which is visible to the s390-bios. This allows the bios to reuse the architected definitions and prevents code duplication.
---
MAINTAINERS | 1 +
hw/s390x/s390-pci-vfio.c | 2 +-
include/hw/s390x/{ => ipl}/s390-pci-clp.h | 0
include/hw/s390x/s390-pci-bus.h | 2 +-
4 files changed, 3 insertions(+), 2 deletions(-)
rename include/hw/s390x/{ => ipl}/s390-pci-clp.h (100%)MAINTAINERS +1 -0
@@ -1882,6 +1882,7 @@ R: Eric Farman <[email protected]> S: Supported F: hw/s390x/s390-pci* F: include/hw/s390x/s390-pci* +F: include/hw/s390x/ipl/s390-pci* F: util/s390x_pci_mmio.c L: [email protected]
hw/s390x/s390-pci-vfio.c +1 -1
@@ -17,7 +17,7 @@#include "trace.h" #include "hw/s390x/s390-pci-bus.h" -#include "hw/s390x/s390-pci-clp.h" +#include "hw/s390x/ipl/s390-pci-clp.h" #include "hw/s390x/s390-pci-vfio.h" #include "hw/vfio/pci.h" #include "hw/vfio/vfio-container-legacy.h"
include/hw/s390x/ipl/s390-pci-clp.h renamed from include/hw/s390x/s390-pci-clp.h +0 -0
include/hw/s390x/s390-pci-bus.h +1 -1
@@ -19,7 +19,7 @@#include "hw/s390x/sclp.h" #include "hw/s390x/s390_flic.h" #include "hw/s390x/css.h" -#include "hw/s390x/s390-pci-clp.h" +#include "hw/s390x/ipl/s390-pci-clp.h" #include "qom/object.h" #define TYPE_S390_PCI_HOST_BRIDGE "s390-pcihost"
Signature · 1 line
2.52.0
PATCH v5 8/15 pc-bios/s390-ccw: Introduce CLP Architecture
In reply to [email protected]From: Jared Rossi <[email protected]>
Call Logical Processor (CLP) Architecture is used for managing PCI functions on s390x. Define and include the structures and routines needed to interact with PCI devices during IPL.
--- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/clp.c | 99 +++++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/clp.h | 24 ++++++++++ 3 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 pc-bios/s390-ccw/clp.c create mode 100644 pc-bios/s390-ccw/clp.h
pc-bios/s390-ccw/Makefile +1 -1
@@ -35,7 +35,7 @@ QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o netmain.o \ virtio.o virtio-net.o virtio-scsi.o virtio-blkdev.o cio.o dasd-ipl.o \ - virtio-ccw.o + virtio-ccw.o clp.o SLOF_DIR := $(SRC_PATH)/../../roms/SLOF
pc-bios/s390-ccw/clp.c new file +99 -0
99 lines not on this page · raw message
pc-bios/s390-ccw/clp.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Call Logical Processor (CLP) architecture definitions +* +* Copyright 2025 IBM Corp. +* Author(s): Jared Rossi <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef CLP_H +#define CLP_H + +#ifndef QEMU_PACKED +#define QEMU_PACKED __attribute__((packed)) +#endif + +#include <stdint.h> +#include <s390-pci-clp.h> + +int clp_pci (void *data); +int find_pci_function (uint32_t fid,ClpFhListEntry *entry); +int enable_pci_function (uint32_t *fhandle); + +#endif
Signature · 1 line
2.52.0
Re: [PATCH v5 08/15] pc-bios/s390-ccw: Introduce CLP Architecture
Quoted 9 lines · On 3/8/26 8:35 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Call Logical Processor (CLP) Architecture is used for managing PCI functions on s390x. Define and include the structures and routines needed to interact with PCI devices during IPL.
Acked-by Thomas Huth <[email protected]>Reviewed-by Eric Farman <[email protected]>Signed-off-by Jared Rossi <[email protected]>
Quoted 156 lines
--- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/clp.c | 99 +++++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/clp.h | 24 ++++++++++ 3 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 pc-bios/s390-ccw/clp.c create mode 100644 pc-bios/s390-ccw/clp.hpc-bios/s390-ccw/Makefile +1
-1@@ -35,7 +35,7 @@ QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o netmain.o \ virtio.o virtio-net.o virtio-scsi.o virtio-blkdev.o cio.o dasd-ipl.o \ - virtio-ccw.o + virtio-ccw.o clp.o SLOF_DIR := $(SRC_PATH)/../../roms/SLOFpc-bios/s390-ccw/clp.c new file +99
-0@@ -0,0 +1,99 @@ +/* +* Call Logical Processor (CLP) architecture +* +* Copyright 2025 IBM Corp. +* Author(s): Jared Rossi <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "clp.h" +#include <stdio.h> +#include <string.h> + +int clp_pci (void *data) +{ +struct {uint8_t _[CLP_BLK_SIZE ]; } *req = data; +int cc =3 ; + + asmvolatile ( +" .insn rrf,0xb9a00000,0,%[req],0,2\n" +" ipm %[cc]\n" +" srl %[cc],28\n" + : [cc]"+d" (cc),"+m" (*req) + : [req]"a" (req) + :"cc" ); +if (cc) { +printf ("CLP returned with non-zero condition code %d\n" , cc); + } +return cc; +} + +/* +* Get the PCI function entry for a given function ID +* Return 0 on success, 1 if the FID is not found, or a negative RC on error +*/ +int find_pci_function (uint32_t fid,ClpFhListEntry *entry) +{ +int count =0 ; +int limit =PCI_MAX_FUNCTIONS ; +ClpReqRspListPci rrb; + + rrb.request.hdr.len =sizeof (ClpReqListPci); + rrb.request.hdr.cmd =0x02 ; + rrb.request.resume_token =0 ; + rrb.response.hdr.len =sizeof (ClpRspListPci); + +do { +if (clp_pci (&rrb) || rrb.response.hdr.rsp !=0x0010 ) { +puts ("Failed to list PCI functions" ); +return -1 ; + } + +/* Resume token set when max enteries are returned */ +if (rrb.response.resume_token) { + count =CLP_FH_LIST_NR_ENTRIES ; + rrb.request.resume_token = rrb.response.resume_token; + }else { + count = (rrb.response.hdr.len -32 ) /sizeof (ClpFhListEntry); + } + + limit -= count; + +for (int i =0 ; i < count; i++) { +if (rrb.response.fh_list[i].fid == fid) { +memcpy (entry, &rrb.response.fh_list[i],sizeof (ClpFhListEntry)); +return 0 ; + } + } + + }while (rrb.request.resume_token && limit >0 ); + +puts ("No function entry found for FID!" ); + +return 1 ; +} + +/* +* Enable the PCI function associated with a given handle +* Return 0 on success or a negative RC on error +*/ +int enable_pci_function (uint32_t *fhandle) +{ +ClpReqRspSetPci rrb; + + rrb.request.hdr.len =sizeof (ClpReqSetPci); + rrb.request.hdr.cmd =0x05 ; + rrb.request.fh = *fhandle; + rrb.request.oc =0 ; + rrb.request.ndas =1 ; + rrb.response.hdr.len =sizeof (ClpRspSetPci); + +if (clp_pci (&rrb) || rrb.response.hdr.rsp !=0x0010 ) { +puts ("Failed to enable PCI function" ); +return -1 ; + } + + *fhandle = rrb.response.fh; +return 0 ; +}pc-bios/s390-ccw/clp.h new file +24
-0@@ -0,0 +1,24 @@ +/* +* Call Logical Processor (CLP) architecture definitions +* +* Copyright 2025 IBM Corp. +* Author(s): Jared Rossi <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef CLP_H +#define CLP_H + +#ifndef QEMU_PACKED +#define QEMU_PACKED __attribute__((packed)) +#endif + +#include <stdint.h> +#include <s390-pci-clp.h> + +int clp_pci (void *data); +int find_pci_function (uint32_t fid,ClpFhListEntry *entry); +int enable_pci_function (uint32_t *fhandle); + +#endif
Re: [PATCH v5 08/15] pc-bios/s390-ccw: Introduce CLP Architecture
In reply to [email protected]Quoted 9 lines · On 3/8/2026 5:35 PM, [email protected] wrote:
From: Jared Rossi<[email protected]>
Call Logical Processor (CLP) Architecture is used for managing PCI functions on s390x. Define and include the structures and routines needed to interact with PCI devices during IPL.
Acked-by Thomas Huth<[email protected]>Reviewed-by Eric Farman<[email protected]>Signed-off-by Jared Rossi<[email protected]>
Quoted 7 lines
--- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/clp.c | 99 +++++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/clp.h | 24 ++++++++++ 3 files changed, 124 insertions(+), 1 deletion(-)create mode 100644
pc-bios/s390-ccw/clp.c
create mode 100644pc-bios/s390-ccw/clp.h
PATCH v5 9/15 s390x: Add definitions for PCI IPL type
In reply to [email protected]From: Jared Rossi <[email protected]>
Define a new PBT code and IPLB layout in preparation for supporting PCI device IPL on s390x.
--- include/hw/s390x/ipl/qipl.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/hw/s390x/ipl/qipl.h +10 -0
@@ -23,6 +23,7 @@enum S390IplType {S390_IPL_TYPE_FCP =0x00 ,S390_IPL_TYPE_CCW =0x02 , +S390_IPL_TYPE_PCI =0x04 ,S390_IPL_TYPE_PV =0x05 ,S390_IPL_TYPE_QEMU_SCSI =0xff };
@@ -108,6 +109,14 @@ struct IplBlockQemuScsi { }QEMU_PACKED ;typedef struct IplBlockQemuScsi IplBlockQemuScsi ; +struct IplBlockPci { +uint32_t reserved0[76 ]; +uint8_t opt; +uint8_t reserved1[3 ]; +uint32_t fid; +}QEMU_PACKED ; +typedef struct IplBlockPci IplBlockPci ; + union IplParameterBlock { struct { uint32_t len;
@@ -123,6 +132,7 @@ union IplParameterBlock {IplBlockFcp fcp;IPLBlockPV pv;IplBlockQemuScsi scsi; +IplBlockPci pci; }; }QEMU_PACKED ;struct {
Signature · 1 line
2.52.0
PATCH v5 10/15 pc-bios/s390-ccw: Introduce PCI device
In reply to [email protected]From: Jared Rossi <[email protected]>
Define selected s390x PCI instructions.
--- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/pci.c | 118 ++++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/pci.h | 39 +++++++++++++ 3 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 pc-bios/s390-ccw/pci.c create mode 100644 pc-bios/s390-ccw/pci.h
pc-bios/s390-ccw/Makefile +1 -1
@@ -35,7 +35,7 @@ QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o netmain.o \ virtio.o virtio-net.o virtio-scsi.o virtio-blkdev.o cio.o dasd-ipl.o \ - virtio-ccw.o clp.o + virtio-ccw.o clp.o pci.o SLOF_DIR := $(SRC_PATH)/../../roms/SLOF
pc-bios/s390-ccw/pci.c new file +118 -0
118 lines not on this page · raw message
pc-bios/s390-ccw/pci.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* s390x PCI definitions +* +* Copyright 2025 IBM Corp. +* Author(s): Jared Rossi <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef PCI_H +#define PCI_H + +#include <stdint.h> +#include <stdbool.h> +#include "clp.h" + +#define ZPCI_CREATE_REQ (handle, space, len) \ + ((uint64_t) handle << 32 | space << 16 | len) + +union register_pair { +unsigned __int128 pair; +struct { +unsigned long even; +unsigned long odd; + }; +}; + +#define PCIST_DISABLED 0x0 +#define PCIST_ENABLED 0x1 + +#define PCI_CFGBAR 0xF/* Base Address Register for config space */ +#define PCI_CAPABILITY_LIST 0x34/* Offset of first capability list entry */ + +int pci_write (uint32_t fhandle,uint64_t offset,uint8_t pcias,uint64_t data, +uint8_t len); +int pci_read (uint32_t fhandle,uint64_t offset,uint8_t pcias,void *buf, +uint8_t len); + +#endif
Signature · 1 line
2.52.0
Re: [PATCH v5 10/15] pc-bios/s390-ccw: Introduce PCI device
Quoted 4 lines · On 09/03/2026 01.35, [email protected] wrote:
From: Jared Rossi <[email protected]>
Define selected s390x PCI instructions.
Quoted 8 lines
Signed-off-by Jared Rossi <[email protected]>--- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/pci.c | 118 ++++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/pci.h | 39 +++++++++++++ 3 files changed, 158 insertions(+), 1 deletion(-)create mode 100644
pc-bios/s390-ccw/pci.c
create mode 100644pc-bios/s390-ccw/pci.h
Re: [PATCH v5 10/15] pc-bios/s390-ccw: Introduce PCI device
In reply to [email protected]Quoted 5 lines · On 3/8/26 8:35 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Define selected s390x PCI instructions.
Signed-off-by Jared Rossi <[email protected]>
Re: [PATCH v5 10/15] pc-bios/s390-ccw: Introduce PCI device
In reply to [email protected]Quoted 25 lines · On 3/8/2026 5:35 PM, [email protected] wrote:
pc-bios/s390-ccw/pci.h new file +19
-0@@ -0,0 +1,39 @@ +/* +* s390x PCI definitions +* +* Copyright 2025 IBM Corp. +* Author(s): Jared Rossi<[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef PCI_H +#define PCI_H + +#include <stdint.h> +#include <stdbool.h> +#include "clp.h" + +#define ZPCI_CREATE_REQ (handle, space, len) \ + ((uint64_t) handle << 32 | space << 16 | len) +
pc-bios/s390-ccw/pci.h line 29
Quoted 10 lines
pc-bios/s390-ccw/pci.h new file +10
-0+union register_pair { +unsigned __int128 pair; +struct { +unsigned long even; +unsigned long odd; + }; +}; + +#define PCIST_DISABLED 0x0 +#define PCIST_ENABLED 0x1
Where are we using these #defines? I couldn't find it in the code. So maybe we should remove them? Apart from this the patch looks good to me.
Thanks
Farhan
Quoted 10 lines
pc-bios/s390-ccw/pci.h new file +10
-0+ +#define PCI_CFGBAR 0xF/* Base Address Register for config space */ +#define PCI_CAPABILITY_LIST 0x34/* Offset of first capability list entry */ + +int pci_write (uint32_t fhandle,uint64_t offset,uint8_t pcias,uint64_t data, +uint8_t len); +int pci_read (uint32_t fhandle,uint64_t offset,uint8_t pcias,void *buf, +uint8_t len); + +#endif
PATCH v5 11/15 pc-bios/s390-ccw: Introduce virtio-pci functions
In reply to [email protected]From: Jared Rossi <[email protected]>
Define common functionality for interacting with virtio-pci devices.
--- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/virtio-pci.c | 167 ++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/virtio-pci.h | 80 ++++++++++++++++ pc-bios/s390-ccw/virtio.h | 3 + 4 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 pc-bios/s390-ccw/virtio-pci.c create mode 100644 pc-bios/s390-ccw/virtio-pci.h
pc-bios/s390-ccw/Makefile +1 -1
@@ -35,7 +35,7 @@ QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o netmain.o \ virtio.o virtio-net.o virtio-scsi.o virtio-blkdev.o cio.o dasd-ipl.o \ - virtio-ccw.o clp.o pci.o + virtio-ccw.o clp.o pci.o virtio-pci.o SLOF_DIR := $(SRC_PATH)/../../roms/SLOF
pc-bios/s390-ccw/virtio-pci.c new file +167 -0
167 lines not on this page · raw message
pc-bios/s390-ccw/virtio-pci.h new file +80 -0
80 lines not on this page · raw message
pc-bios/s390-ccw/virtio.h +3 -0
@@ -18,6 +18,8 @@#define VIRTIO_CONFIG_S_DRIVER 2/* Driver has used its parts of the config, and is happy */ #define VIRTIO_CONFIG_S_DRIVER_OK 4 +/* Feature negotiation complete */ +#define VIRTIO_CONFIG_S_FEATURES_OK 8/* We've given up on this device. */ #define VIRTIO_CONFIG_S_FAILED 0x80
@@ -255,6 +257,7 @@ struct VDev {uint8_t scsi_dev_heads;bool scsi_device_selected;ScsiDevice selected_scsi_device; +uint32_t pci_fh;uint32_t max_transfer;uint32_t guest_features[2 ]; };
Signature · 1 line
2.52.0
Re: [PATCH v5 11/15] pc-bios/s390-ccw: Introduce virtio-pci functions
Quoted 5 lines · On 09/03/2026 01.35, [email protected] wrote:
From: Jared Rossi <[email protected]>
Define common functionality for interacting with virtio-pci devices.
Signed-off-by Jared Rossi <[email protected]>
Quoted 8 lines
--- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/virtio-pci.c | 167 ++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/virtio-pci.h | 80 ++++++++++++++++ pc-bios/s390-ccw/virtio.h | 3 + 4 files changed, 251 insertions(+), 1 deletion(-)create mode 100644
pc-bios/s390-ccw/virtio-pci.ccreate mode 100644pc-bios/s390-ccw/virtio-pci.h
Re: [PATCH v5 11/15] pc-bios/s390-ccw: Introduce virtio-pci functions
In reply to [email protected]Quoted 5 lines · On 3/8/26 8:35 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Define common functionality for interacting with virtio-pci devices.
Signed-off-by Jared Rossi <[email protected]>
pc-bios/s390-ccw/virtio-pci.c line 4
Quoted 10 lines
pc-bios/s390-ccw/virtio-pci.c new file +4
-0@@ -0,0 +1,167 @@ +/* +* Functionality for virtio-pci +* +* Copyright 2025 IBM Corp.
Nit: 2026
Quoted 12 lines
pc-bios/s390-ccw/virtio-pci.c new file +5
-0+* Author(s): Jared Rossi <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +pc-bios/s390-ccw/virtio-pci.h new file +0
-0
pc-bios/s390-ccw/virtio-pci.h line 4
Quoted 4 lines
pc-bios/s390-ccw/virtio-pci.h new file +4
-0@@ -0,0 +1,80 @@ +/* +* Definitions for virtio-pci +* +* Copyright 2025 IBM Corp.
Here too
Quoted 5 lines
pc-bios/s390-ccw/virtio-pci.h new file +5
-0+* Author(s): Jared Rossi <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +
Re: [PATCH v5 11/15] pc-bios/s390-ccw: Introduce virtio-pci functions
In reply to [email protected]Quoted 5 lines · On Sun, 2026-03-08 at 20:35 -0400, [email protected] wrote:
From: Jared Rossi <[email protected]>
Define common functionality for interacting with virtio-pci devices.
Signed-off-by Jared Rossi <[email protected]>
Quoted 8 lines
--- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/virtio-pci.c | 167 ++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/virtio-pci.h | 80 ++++++++++++++++ pc-bios/s390-ccw/virtio.h | 3 + 4 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 pc-bios/s390-ccw/virtio-pci.c create mode 100644 pc-bios/s390-ccw/virtio-pci.h
PATCH v5 12/15 pc-bios/s390-ccw: Add support for virtio-blk-pci IPL
In reply to [email protected]From: Jared Rossi <[email protected]>
Add little-endian virt-queue configuration and support for virtio-blk-pci IPL devices.
--- pc-bios/s390-ccw/main.c | 61 ++++++- pc-bios/s390-ccw/pci.h | 3 + pc-bios/s390-ccw/virtio-blkdev.c | 18 +++ pc-bios/s390-ccw/virtio-pci.c | 265 +++++++++++++++++++++++++++++++ pc-bios/s390-ccw/virtio-pci.h | 2 + pc-bios/s390-ccw/virtio.c | 54 ++++++- pc-bios/s390-ccw/virtio.h | 1 + 7 files changed, 399 insertions(+), 5 deletions(-)
pc-bios/s390-ccw/main.c +59 -2
@@ -18,6 +18,8 @@#include "virtio.h" #include "virtio-scsi.h" #include "dasd-ipl.h" +#include "clp.h" +#include "virtio-pci.h" static SubChannelId blk_schid = { .one =1 };static char loadparm_str[LOADPARM_LEN +1 ];
@@ -151,6 +153,21 @@ static bool find_subch(int dev_no)return false; } +static bool find_fid (uint32_t fid) +{ +ClpFhListEntry entry; +VDev *vdev =virtio_get_device (); + +if (find_pci_function (fid, &entry)) { +return false; + } + + vdev->pci_fh = entry.fh; +virtio_pci_id2type (vdev, entry.device_id); + +return vdev->dev_type !=0 ; +} +static void menu_setup (VDev *vdev) {if (memcmp (loadparm_str,LOADPARM_PROMPT ,LOADPARM_LEN ) ==0 ) {
@@ -240,6 +257,9 @@ static bool find_boot_device(void) blk_schid.ssid = iplb.scsi.ssid &0x3 ; found =find_subch (iplb.scsi.devno);break ; +case S390_IPL_TYPE_PCI : + found =find_fid (iplb.pci.fid); +break ;default :puts ("Unsupported IPLB" ); }
@@ -276,7 +296,7 @@ static int virtio_setup(void)return ret; } -static void ipl_boot_device (void ) +static void ipl_ccw_device (void ) {switch (cutype) {case CU_TYPE_DASD_3990 :
@@ -290,7 +310,44 @@ static void ipl_boot_device(void) }break ;default : -printf ("Attempting to boot from unexpected device type 0x%X\n" , cutype); +printf ("Cannot boot CCW device with cu type 0x%X\n" , cutype); + } +} + +static void ipl_pci_device (void ) +{ +VDev *vdev =virtio_get_device (); + vdev->is_cdrom = false; + vdev->scsi_device_selected = false; + +if (virtio_pci_setup_device ()) { +return ; + } + +switch (vdev->dev_type) { +case VIRTIO_ID_BLOCK : +if (virtio_setup () ==0 ) { +zipl_load ();/* only return on error */ +virtio_reset (virtio_get_device ()); + } +break ; +default : +printf ("Cannot boot PCI device type 0x%X\n" , vdev->dev_type); + } +} + +static void ipl_boot_device (void ) +{ +switch (virtio_get_device ()->ipl_type) { +case S390_IPL_TYPE_QEMU_SCSI : +case S390_IPL_TYPE_CCW : +ipl_ccw_device (); +break ; +case S390_IPL_TYPE_PCI : +ipl_pci_device (); +break ; +default : +puts ("Unrecognized IPL type!" ); } }
pc-bios/s390-ccw/pci.h +3 -0
@@ -29,8 +29,11 @@ union register_pair {#define PCIST_ENABLED 0x1#define PCI_CFGBAR 0xF/* Base Address Register for config space */ +#define PCI_CMD_REG 0x4/* Offset of command register */ #define PCI_CAPABILITY_LIST 0x34/* Offset of first capability list entry */ +#define PCI_BUS_MASTER_MASK 0x0020/* LE bit 3 of 16 bit register */ +int pci_write (uint32_t fhandle,uint64_t offset,uint8_t pcias,uint64_t data,uint8_t len); int pci_read(uint32_t fhandle, uint64_t offset, uint8_t pcias, void *buf,
pc-bios/s390-ccw/virtio-blkdev.c +18 -0
@@ -13,10 +13,22 @@#include "virtio.h" #include "virtio-scsi.h" #include "virtio-ccw.h" +#include "virtio-pci.h" +#include "bswap.h" #define VIRTIO_BLK_F_GEOMETRY (1 << 4)#define VIRTIO_BLK_F_BLK_SIZE (1 << 6) +/* +* Format header for little endian IPL +*/ +static void fmt_blk_hdr_le (VirtioBlkOuthdr *hdr) +{ + hdr->type =bswap32 (hdr->type); + hdr->ioprio =bswap32 (hdr->ioprio); + hdr->sector =bswap64 (hdr->sector); +} +static int virtio_blk_read_many (VDev *vdev,unsigned long sector,void *load_addr,int sec_num) {
@@ -29,6 +41,10 @@ static int virtio_blk_read_many(VDev *vdev, unsigned long sector, void *load_add out_hdr.ioprio =99 ; out_hdr.sector =virtio_sector_adjust (sector); +if (!be_ipl ()) { +fmt_blk_hdr_le (&out_hdr); + } +vring_send_buf (vr, &out_hdr,sizeof (out_hdr),VRING_DESC_F_NEXT );/* This is where we want to receive data */
@@ -240,6 +256,8 @@ int virtio_blk_setup_device(VDev *vdev)case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :return virtio_ccw_setup (vdev); +case S390_IPL_TYPE_PCI : +return virtio_pci_setup (vdev);default :return 1 ; }
pc-bios/s390-ccw/virtio-pci.c +265 -0
268 lines not on this page · raw message
pc-bios/s390-ccw/virtio-pci.h +2 -0
@@ -65,6 +65,8 @@ typedef struct VirtioPciCap VirtioPciCap;void virtio_pci_id2type (VDev *vdev,uint16_t device_id);int virtio_pci_reset (VDev *vdev);long virtio_pci_notify (int vq_id); +int virtio_pci_setup (VDev *vdev); +int virtio_pci_setup_device (void );int vpci_read_flex (uint64_t offset,uint8_t pcias,void *buf,int len);int vpci_read_bswap64 (uint64_t offset,uint8_t pcias,uint64_t *buf);
pc-bios/s390-ccw/virtio.c +51 -3
106 lines not on this page · raw message
pc-bios/s390-ccw/virtio.h +1 -0
@@ -273,6 +273,7 @@ struct VirtioCmd { };typedef struct VirtioCmd VirtioCmd ; +bool be_ipl (void );void vring_init (VRing *vr,VqInfo *info);bool virtio_is_supported (VDev *vdev);bool vring_notify (VRing *vr);
Signature · 1 line
2.52.0
PATCH v5 13/15 s390x: Build IPLB for virtio-pci devices
In reply to [email protected]From: Jared Rossi <[email protected]>
Search for a corresponding S390PCIBusDevice and build an IPLB if a device has been indexed for boot but does not identify as a CCW device,
PCI devices are not yet included in boot probing (they must have a boot index).
--- hw/s390x/ipl.c | 56 ++++++++++++++++++++++++++++++--- hw/s390x/ipl.h | 3 ++ hw/s390x/s390-pci-bus.c | 3 +- include/hw/s390x/s390-pci-bus.h | 2 ++ 4 files changed, 57 insertions(+), 7 deletions(-)
hw/s390x/ipl.c +51 -5
@@ -28,6 +28,8 @@#include "hw/s390x/ebcdic.h" #include "hw/scsi/scsi.h" #include "hw/virtio/virtio-net.h" +#include "hw/virtio/virtio-pci.h" +#include "hw/s390x/s390-pci-bus.h" #include "exec/cpu-common.h" #include "ipl.h" #include "qemu/error-report.h"
@@ -340,7 +342,8 @@ static void s390_ipl_set_boot_menu(S390IPLState *ipl) ipl->qipl.boot_menu_timeout =cpu_to_be32 (splash_time); } -#define CCW_DEVTYPE_NONE 0x00 +#define S390_DEVTYPE_NONE 0x00 +#define CCW_DEVTYPE_VIRTIO 0x01#define CCW_DEVTYPE_VIRTIO_NET 0x02#define CCW_DEVTYPE_SCSI 0x03
@@ -349,7 +352,7 @@ static void s390_ipl_set_boot_menu(S390IPLState *ipl)static CcwDevice *s390_get_ccw_device (DeviceState *dev_st,int *devtype) {CcwDevice *ccw_dev =NULL ; -int tmp_dt =CCW_DEVTYPE_NONE ; +int tmp_dt =S390_DEVTYPE_NONE ;if (dev_st) { VirtIONet *virtio_net_dev = (VirtIONet *)
@@ -396,6 +399,31 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype)return ccw_dev; } +#define PCI_DEVTYPE_VIRTIO 0x05 + +static S390PCIBusDevice *s390_get_pci_device (DeviceState *dev_st,int *devtype) +{ +S390PCIBusDevice *pbdev =NULL ; +int tmp_dt =S390_DEVTYPE_NONE ; + +if (dev_st) { +PCIDevice *pci_dev = (PCIDevice *) +object_dynamic_cast (OBJECT (qdev_get_parent_bus (dev_st)->parent), +TYPE_VIRTIO_PCI ); +if (pci_dev) { + pbdev =s390_pci_find_dev_by_pci (s390_get_phb (), pci_dev); +if (pbdev) { + tmp_dt =PCI_DEVTYPE_VIRTIO ; + } + } + } +if (devtype) { + *devtype = tmp_dt; + } + +return pbdev; +} +static uint64_t s390_ipl_map_iplb_chain (IplParameterBlock *iplb_chain) {S390IPLState *ipl =get_ipl_device ();
@@ -428,14 +456,12 @@ void s390_ipl_convert_loadparm(char *ascii_lp, uint8_t *ebcdic_lp)static bool s390_build_iplb (DeviceState *dev_st,IplParameterBlock *iplb) {CcwDevice *ccw_dev =NULL ; +S390PCIBusDevice *pbdev =NULL ;SCSIDevice *sd;int devtype;uint8_t *lp; g_autofree void *scsi_lp = NULL; -/* -* Currently allow IPL only from CCW devices. -*/ ccw_dev =s390_get_ccw_device (dev_st, &devtype);if (ccw_dev) { lp = ccw_dev->loadparm;
@@ -485,6 +511,26 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb)return true; } + pbdev =s390_get_pci_device (dev_st, &devtype); +if (pbdev) { +switch (devtype) { +case PCI_DEVTYPE_VIRTIO : + iplb->len =S390_IPLB_MIN_PCI_LEN ; + iplb->pbt =S390_IPL_TYPE_PCI ; + iplb->pci.fid = pbdev->fid; +break ; +default : +return false; + } + +/* Per-device loadparm not yet supported for non-ccw IPL */ + lp =S390_CCW_MACHINE (qdev_get_machine ())->loadparm; +s390_ipl_convert_loadparm ((char *)lp, iplb->loadparm); + iplb->flags |=DIAG308_FLAGS_LP_VALID ; + +return true; + } +return false; }
hw/s390x/ipl.h +3 -0
@@ -107,6 +107,7 @@ QEMU_BUILD_BUG_MSG(offsetof(S390IPLState, iplb) & 3, "alignment of iplb wrong");#define S390_IPLB_MIN_PV_LEN 148#define S390_IPLB_MIN_CCW_LEN 200#define S390_IPLB_MIN_FCP_LEN 384 +#define S390_IPLB_MIN_PCI_LEN 376#define S390_IPLB_MIN_QEMU_SCSI_LEN 200static inline bool iplb_valid_len (IplParameterBlock *iplb)
@@ -179,6 +180,8 @@ static inline bool iplb_valid(IplParameterBlock *iplb)return len >=S390_IPLB_MIN_FCP_LEN ;case S390_IPL_TYPE_CCW :return len >=S390_IPLB_MIN_CCW_LEN ; +case S390_IPL_TYPE_PCI : +return len >=S390_IPLB_MIN_PCI_LEN ;case S390_IPL_TYPE_QEMU_SCSI :default :return false;
hw/s390x/s390-pci-bus.c +1 -2
@@ -250,8 +250,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_target(S390pciState *s,return NULL ; } -static S390PCIBusDevice *s390_pci_find_dev_by_pci (S390pciState *s, -PCIDevice *pci_dev) +S390PCIBusDevice *s390_pci_find_dev_by_pci (S390pciState *s,PCIDevice *pci_dev) {S390PCIBusDevice *pbdev;
include/hw/s390x/s390-pci-bus.h +2 -0
@@ -402,6 +402,8 @@ S390PCIBusDevice *s390_pci_find_dev_by_fh(S390pciState *s, uint32_t fh);S390PCIBusDevice *s390_pci_find_dev_by_fid (S390pciState *s,uint32_t fid);S390PCIBusDevice *s390_pci_find_dev_by_target (S390pciState *s,const char *target); +S390PCIBusDevice *s390_pci_find_dev_by_pci (S390pciState *s, +PCIDevice *pci_dev);S390PCIBusDevice *s390_pci_find_next_avail_dev (S390pciState *s,S390PCIBusDevice *pbdev);void s390_pci_ism_reset (void );
Signature · 1 line
2.52.0
PATCH v5 14/15 hw: Add "loadparm" property to virtio block PCI devices booting on s390x
In reply to [email protected]From: Jared Rossi <[email protected]>
The loadparm is required on s390x to pass the information to the boot loader such as which kernel should be started or whether the boot menu should be shown.
Because PCI devices do not naturally allocate space for this, the property is added on an architecture specific basis for supported device types.
--- hw/pci/pci.c | 38 +++++++++++++++++++++++++++++++++++++ hw/s390x/ipl.c | 11 +++++++++-- hw/virtio/virtio-blk-pci.c | 1 + include/hw/pci/pci.h | 1 + include/hw/pci/pci_device.h | 3 +++ 5 files changed, 52 insertions(+), 2 deletions(-)
hw/pci/pci.c +38 -0
@@ -36,6 +36,7 @@#include "migration/qemu-file-types.h" #include "migration/vmstate.h" #include "net/net.h" +#include "system/arch_init.h" #include "system/numa.h" #include "system/runstate.h" #include "system/system.h"
@@ -2843,6 +2844,43 @@ int pci_qdev_find_device(const char *id, PCIDevice **pdev)return rc; } +static char *pci_qdev_property_get_loadparm (Object *obj,Error **errp) +{ +return g_strdup (PCI_DEVICE (obj)->loadparm); +} + +static void pci_qdev_property_set_loadparm (Object *obj,const char *value, +Error **errp) +{ +void *lp_str; + +if (object_property_get_int (obj,"bootindex" ,NULL ) <0 ) { +error_setg (errp,"'loadparm' is only valid for boot devices" ); +return ; + } + + lp_str =g_malloc0 (strlen (value) +1 ); +if (!qdev_prop_sanitize_s390x_loadparm (lp_str, value, errp)) { +g_free (lp_str); +return ; + } +PCI_DEVICE (obj)->loadparm = lp_str; +} + +void pci_qdev_property_add_specifics (DeviceClass *dc) +{ +ObjectClass *oc =OBJECT_CLASS (dc); + +/* The loadparm property is only supported on s390x */ +if (target_s390x ()) { +object_class_property_add_str (oc,"loadparm" , + pci_qdev_property_get_loadparm, + pci_qdev_property_set_loadparm); +object_class_property_set_description (oc,"loadparm" , +"load parameter (s390x only)" ); + } +} +MemoryRegion *pci_address_space (PCIDevice *dev) {return pci_get_bus (dev)->address_space_mem;
hw/s390x/ipl.c +9 -2
@@ -461,6 +461,7 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb)int devtype;uint8_t *lp; g_autofree void *scsi_lp = NULL; + g_autofree void *pci_lp = NULL; ccw_dev =s390_get_ccw_device (dev_st, &devtype);if (ccw_dev) {
@@ -513,6 +514,14 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb) pbdev =s390_get_pci_device (dev_st, &devtype);if (pbdev) { + pci_lp =object_property_get_str (OBJECT (pbdev->pdev),"loadparm" ,NULL ); +if (pci_lp &&strlen (pci_lp) >0 ) { + lp = pci_lp; + }else { +/* Use machine loadparm as a place holder if PCI LP is unset */ + lp =S390_CCW_MACHINE (qdev_get_machine ())->loadparm; + } +switch (devtype) {case PCI_DEVTYPE_VIRTIO : iplb->len =S390_IPLB_MIN_PCI_LEN ;
@@ -523,8 +532,6 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb)return false; } -/* Per-device loadparm not yet supported for non-ccw IPL */ - lp =S390_CCW_MACHINE (qdev_get_machine ())->loadparm;s390_ipl_convert_loadparm ((char *)lp, iplb->loadparm); iplb->flags |=DIAG308_FLAGS_LP_VALID ;
hw/virtio/virtio-blk-pci.c +1 -0
@@ -71,6 +71,7 @@ static void virtio_blk_pci_class_init(ObjectClass *klass, const void *data)set_bit (DEVICE_CATEGORY_STORAGE , dc->categories);device_class_set_props (dc, virtio_blk_pci_properties); +pci_qdev_property_add_specifics (dc); k->realize = virtio_blk_pci_realize; pcidev_k->vendor_id =PCI_VENDOR_ID_REDHAT_QUMRANET ; pcidev_k->device_id =PCI_DEVICE_ID_VIRTIO_BLOCK ;
include/hw/pci/pci.h +1 -0
@@ -380,6 +380,7 @@ const char *pci_root_bus_path(PCIDevice *dev);bool pci_bus_bypass_iommu (PCIBus *bus);PCIDevice *pci_find_device (PCIBus *bus,int bus_num,uint8_t devfn);int pci_qdev_find_device (const char *id,PCIDevice **pdev); +void pci_qdev_property_add_specifics (DeviceClass *dc);void pci_bus_get_w64_range (PCIBus *bus,Range *range);void pci_device_deassert_intx (PCIDevice *dev);
include/hw/pci/pci_device.h +3 -0
@@ -62,6 +62,9 @@ struct PCIDevice {bool partially_hotplugged;bool enabled; +/* only for s390x */ +char *loadparm; +/* PCI config space */ uint8_t *config;
Signature · 1 line
2.52.0
PATCH v5 15/15 tests/qtest: Add s390x PCI boot test to cdrom-test.c
In reply to [email protected]From: Jared Rossi <[email protected]>
Add a rudimentary test for s390x IPL to verify that a guest may boot using virtio-blk-pci device.
--- tests/qtest/cdrom-test.c | 7 +++++++ 1 file changed, 7 insertions(+)
tests/qtest/cdrom-test.c +7 -0
@@ -246,6 +246,13 @@ static void add_s390x_tests(void)"-drive if=none,id=d2,media=cdrom,file=" , test_cdboot); } +if (qtest_has_device ("virtio-blk-pci" )) { +qtest_add_data_func ("cdrom/boot/pci-bus-with-bootindex" , +"-device virtio-scsi -device virtio-serial " +"-device virtio-blk-pci,drive=d1,bootindex=1 " +"-drive if=none,id=d1,media=cdrom,file=" , + test_cdboot); + } }int main (int argc,char **argv)
Signature · 1 line
2.52.0
Re: [PATCH v5 15/15] tests/qtest: Add s390x PCI boot test to cdrom-test.c
Quoted 17 lines · On 09/03/2026 01.36, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add a rudimentary test for s390x IPL to verify that a guest may boot using virtio-blk-pci device.
Reviewed-by Thomas Huth <[email protected]>Signed-off-by Jared Rossi <[email protected]>--- tests/qtest/cdrom-test.c | 7 +++++++ 1 file changed, 7 insertions(+)tests/qtest/cdrom-test.c +0
-0@@ -246,6 +246,13 @@ static void add_s390x_tests(void) "-drive if=none,id=d2,media=cdrom,file=",
tests/qtest/cdrom-test.c static void add_s390x_tests(void) · line 256
Quoted 10 lines
tests/qtest/cdrom-test.c +7
-0test_cdboot); } +if (qtest_has_device ("virtio-blk-pci" )) { +qtest_add_data_func ("cdrom/boot/pci-bus-with-bootindex" , +"-device virtio-scsi -device virtio-serial " +"-device virtio-blk-pci,drive=d1,bootindex=1 " +"-drive if=none,id=d1,media=cdrom,file=" , + test_cdboot); + } }
Hi Jared!
While testing your series, it seems like the cdrom-test is now triggering a segmentation fault in QEMU here ... not sure whether I did something wrong on my side while building the bios, or whether there is a bug somewhere? Does this qtest work for you with this v5 series?
Thomas
Re: [PATCH v5 15/15] tests/qtest: Add s390x PCI boot test to cdrom-test.c
Quoted 31 lines · Thomas Huth
Quoted 17 lines · On 09/03/2026 01.36, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add a rudimentary test for s390x IPL to verify that a guest may boot using virtio-blk-pci device.
Reviewed-by Thomas Huth <[email protected]>Signed-off-by Jared Rossi <[email protected]>---
tests/qtest/cdrom-test.c| 7 +++++++1 file changed, 7 insertions(+)tests/qtest/cdrom-test.c +0
-0@@ -246,6 +246,13 @@ static void add_s390x_tests(void) "-drive if=none,id=d2,media=cdrom,file=",tests/qtest/cdrom-test.c static void add_s390x_tests(void) · line 256
Quoted 10 lines
tests/qtest/cdrom-test.c +7
-0test_cdboot); } + if (qtest_has_device("virtio-blk-pci")) { + qtest_add_data_func("cdrom/boot/pci-bus-with-bootindex", + "-device virtio-scsi -device virtio-serial " + "-device virtio-blk-pci,drive=d1,bootindex=1 " + "-drive if=none,id=d1,media=cdrom,file=", + test_cdboot); + } }Hi Jared!
Quoted 1 line
While testing your series, it seems like the cdrom-test is now triggering a segmentation fault in QEMU here ... not sure whether I did something wrong on my side while building the bios, or whether there is a bug somewhere? Does this qtest work for you with this v5 series?
Ah, it's working on my s390x LPAR, but it's failing on my x86 laptop ... maybe there is some endianness issue left somewhere?
Thomas
Re: [PATCH v5 15/15] tests/qtest: Add s390x PCI boot test to cdrom-test.c
Quoted 32 lines · Thomas Huth
Quoted 31 lines · Thomas Huth
Quoted 17 lines · On 09/03/2026 01.36, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add a rudimentary test for s390x IPL to verify that a guest may boot using virtio-blk-pci device.
Reviewed-by Thomas Huth <[email protected]>Signed-off-by Jared Rossi <[email protected]>---
tests/qtest/cdrom-test.c| 7 +++++++1 file changed, 7 insertions(+)tests/qtest/cdrom-test.c +0
-0@@ -246,6 +246,13 @@ static void add_s390x_tests(void) "-drive if=none,id=d2,media=cdrom,file=",tests/qtest/cdrom-test.c static void add_s390x_tests(void) · line 256
Quoted 10 lines
tests/qtest/cdrom-test.c +7
-0test_cdboot); } + if (qtest_has_device("virtio-blk-pci")) { + qtest_add_data_func("cdrom/boot/pci-bus-with-bootindex", + "-device virtio-scsi -device virtio-serial " + "-device virtio-blk-pci,drive=d1,bootindex=1 " + "-drive if=none,id=d1,media=cdrom,file=", + test_cdboot); + } }Hi Jared!
Quoted 3 lines
Quoted 1 line
While testing your series, it seems like the cdrom-test is now triggering a segmentation fault in QEMU here ... not sure whether I did something wrong on my side while building the bios, or whether there is a bug somewhere? Does this qtest work for you with this v5 series?
Ah, it's working on my s390x LPAR, but it's failing on my x86 laptop ... maybe there is some endianness issue left somewhere?
Yes, it's a missing swap of endianness data, this patch fixes it:
hw/s390x/ipl.c +2 -2
@@ -524,9 +524,9 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb)switch (devtype) {case PCI_DEVTYPE_VIRTIO : - iplb->len =S390_IPLB_MIN_PCI_LEN ; + iplb->len =cpu_to_be32 (S390_IPLB_MIN_PCI_LEN ); iplb->pbt =S390_IPL_TYPE_PCI ; - iplb->pci.fid = pbdev->fid; + iplb->pci.fid =cpu_to_be32 (pbdev->fid);break ;default :return false;
If you agree, I can squash this into patch 13.
Thomas
Re: [PATCH v5 15/15] tests/qtest: Add s390x PCI boot test to cdrom-test.c
Quoted 58 lines · Thomas Huth
Quoted 34 lines · Thomas Huth
Quoted 33 lines · Thomas Huth
Quoted 22 lines · On 09/03/2026 01.36, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add a rudimentary test for s390x IPL to verify that a guest may boot using virtio-blk-pci device.
Reviewed-by Thomas Huth <[email protected]>Signed-off-by Jared Rossi <[email protected]>---
tests/qtest/cdrom-test.c| 7 +++++++1 file changed, 7 insertions(+)tests/qtest/cdrom-test.c +3
-0@@ -246,6 +246,13 @@ static void add_s390x_tests(void) "-drive if=none,id=d2,media=cdrom,file=", test_cdboot); } + if (qtest_has_device("virtio-blk-pci")) { + qtest_add_data_func("cdrom/boot/pci-bus-with-bootindex", + "-device virtio-scsi -deviceQuoted 7 lines
virtio-serial "
+ "-device virtio-blk-pci,drive=d1,bootindex=1 "
+ "-drive if=none,id=d1,media=cdrom,file=", +test_cdboot);
+ }
}Hi Jared!
Quoted 3 lines
Quoted 1 line
While testing your series, it seems like the cdrom-test is now triggering a segmentation fault in QEMU here ... not sure whether I did something wrong on my side while building the bios, or whether there is a bug somewhere? Does this qtest work for you with this v5 series?
Ah, it's working on my s390x LPAR, but it's failing on my x86 laptop ... maybe there is some endianness issue left somewhere?
Yes, it's a missing swap of endianness data, this patch fixes it:
hw/s390x/ipl.c +0
-0@@ -524,9 +524,9 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb) switch (devtype) {case
PCI_DEVTYPE_VIRTIO:
-iplb->len=S390_IPLB_MIN_PCI_LEN;
+iplb->len=cpu_to_be32(S390_IPLB_MIN_PCI_LEN);iplb->pbt=S390_IPL_TYPE_PCI;
-iplb->pci.fid=pbdev->fid;
+iplb->pci.fid=cpu_to_be32(pbdev->fid); break;
default:
return false;
Quoted 2 lines
If you agree, I can squash this into patch 13.
Hi Thomas,
Thanks for identifying the problem. Yes, please do squash it into patch 13.
Regards,
Jared Rossi
Quoted 11 lines · On 3/8/26 8:35 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
This patch series introduces an IPLB subtype to support PCI devices, which may be built if a device has been assigned a boot index and is identified as a PCI device with a corresponding s390 PCI Bus device.
Boot support is only added for virtio-blk-pci at this time and is limited to devices with an assigned bootindex.
A "loadparm" property is added to virtio-blk-pci boot devices on s390x.
Quoted 8 lines
A simple test to check basic functionality is added to the cdrom-tests in qtest.
Changes v4 -> v5:
- Fix incorrect switch/case for virtio block device ID
- Usetarget_s390x()instead ofqemu_arch_available(QEMU_ARCH_S390X)
- Properly denote switch fallthrough
- Remove reduntant RC checks in PCI read/write
Rather than reply to individual patches, I noticed new copyright lines with 2025 dates on the following patches that should be updated to 2026:
6: pc-bios/s390-ccw: Split virtio-ccw and generic virtio 8: pc-bios/s390-ccw: Introduce CLP Architecture 10: pc-bios/s390-ccw: Introduce PCI device
11: pc-bios/s390-ccw: Introduce virtio-pci functions
Thomas, if there are no further comments would you still like Jared to respin for that kind of change or would you just fix up when you pick up the series?
Thanks,
Matt
Quoted 21 lines · Matthew Rosato
Quoted 11 lines · On 3/8/26 8:35 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
This patch series introduces an IPLB subtype to support PCI devices, which may be built if a device has been assigned a boot index and is identified as a PCI device with a corresponding s390 PCI Bus device.
Boot support is only added for virtio-blk-pci at this time and is limited to devices with an assigned bootindex.
A "loadparm" property is added to virtio-blk-pci boot devices on s390x.
Quoted 8 lines
A simple test to check basic functionality is added to the cdrom-tests in qtest.
Changes v4 -> v5:
- Fix incorrect switch/case for virtio block device ID
- Usetarget_s390x()instead ofqemu_arch_available(QEMU_ARCH_S390X)
- Properly denote switch fallthrough
- Remove reduntant RC checks in PCI read/write
Quoted 8 lines
Rather than reply to individual patches, I noticed new copyright lines with 2025 dates on the following patches that should be updated to 2026:
6: pc-bios/s390-ccw: Split virtio-ccw and generic virtio 8: pc-bios/s390-ccw: Introduce CLP Architecture 10: pc-bios/s390-ccw: Introduce PCI device
11: pc-bios/s390-ccw: Introduce virtio-pci functionsThomas, if there are no further comments would you still like Jared to respin for that kind of change or would you just fix up when you pick up the series?
I've seen different opinions on the year in copyright statements in the past (also from various people from IBM) - some say, it should be the year when the code was written/initially posted, some say, it should be the year when the code gets merged ... I personally don't mind too much anymore. For me, it's also ok if we keep the 2025.
Anyway, tomorrow (Tuesday) is softfreeze, so I'm going to send a pull request for this series tomorrow - let me know by then if you want me to fix up the year, or if you rather prefer to keep 2025.
Thomas
Quoted 29 lines · Thomas Huth
Quoted 28 lines · Matthew Rosato
Quoted 11 lines · On 3/8/26 8:35 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
This patch series introduces an IPLB subtype to support PCI devices, which may be built if a device has been assigned a boot index and is identified as a PCI device with a corresponding s390 PCI Bus device.
Boot support is only added for virtio-blk-pci at this time and is limited to devices with an assigned bootindex.
A "loadparm" property is added to virtio-blk-pci boot devices on s390x.
Quoted 8 lines
A simple test to check basic functionality is added to the cdrom-tests in qtest.
Changes v4 -> v5:
- Fix incorrect switch/case for virtio block device ID
- Usetarget_s390x()instead ofqemu_arch_available(QEMU_ARCH_S390X)
- Properly denote switch fallthrough
- Remove reduntant RC checks in PCI read/writeRather than reply to individual patches, I noticed new copyright lines with 2025 dates on the following patches that should be updated to 2026:
6: pc-bios/s390-ccw: Split virtio-ccw and generic virtio 8: pc-bios/s390-ccw: Introduce CLP Architecture 10: pc-bios/s390-ccw: Introduce PCI device
11: pc-bios/s390-ccw: Introduce virtio-pci functions
Quoted 6 lines
Quoted 1 line
Thomas, if there are no further comments would you still like Jared to respin for that kind of change or would you just fix up when you pick up the series?
I've seen different opinions on the year in copyright statements in the past (also from various people from IBM) - some say, it should be the year when the code was written/initially posted, some say, it should be the year when the code gets merged ... I personally don't mind too much anymore. For me, it's also ok if we keep the 2025.
Anyway, tomorrow (Tuesday) is softfreeze, so I'm going to send a pull request for this series tomorrow - let me know by then if you want me to fix up the year, or if you rather prefer to keep 2025.
I actually wonder why we have the year at all (besides convention)... But I do not have a strong opinion about it and was checking about a re-spin exactly because of soft freeze.
If you are OK with 2025 then that is also fine by me, leave it as-is.
Thanks,
Matt
Quoted 5 lines · On 09/03/2026 01.35, [email protected] wrote:
From: Jared Rossi <[email protected]>
This patch series introduces an IPLB subtype to support PCI devices, which may be built if a device has been assigned a boot index and is identified as a PCI device with a corresponding s390 PCI Bus device.
Hi Jared,
FYI, today I noticed that in some rare cases (maybe 1 out of 50 boots), the loading of the Linux kernel from a PCI device still fails. I filed a ticket with a reproducer here:
https://gitlab.com/qemu-project/qemu/-/work_items/3350
Maybe there is another virtio_reset() missing somewhere?
Thomas
Quoted 9 lines · Thomas Huth
Quoted 5 lines · On 09/03/2026 01.35, [email protected] wrote:
From: Jared Rossi <[email protected]>
This patch series introduces an IPLB subtype to support PCI devices, which may be built if a device has been assigned a boot index and is identified as a PCI device with a corresponding s390 PCI Bus device.
Hi Jared,
Quoted 8 lines
FYI, today I noticed that in some rare cases (maybe 1 out of 50 boots), the loading of the Linux kernel from a PCI device still fails. I filed a ticket with a reproducer here:
https://gitlab.com/qemu-project/qemu/-/work_items/3350
Maybe there is another
virtio_reset()missing somewhere?Thomas
Hi Thomas,
Thanks for identifying this. I will investigate.
Regards,
Jared Rossi