From: Jared Rossi <[email protected]>

The length of the PCI IPLB is calculated by size of the IplBlockPci struct
plus the number of bytes used for common IPLB fields.

Fix the S390_IPLB_MIN_PCI_LEN to reflect this, and assign a valid blk0_len
while we are at it.

Cc: [email protected]
Fixes: 395116781df5 ("s390x: Build IPLB for virtio-pci devices")
Signed-off-by: Jared Rossi <[email protected]>
Reviewed-by: Matthew Rosato <[email protected]>
Reviewed-by: Jason J. Herne <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Link: 
https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Eric Farman <[email protected]>
(cherry picked from commit 8435aadbb9add09c4c2e16f803b37441b4c6a32f)
(Mjt: S390_IPLB_MIN_PCI_LEN is in hw/s390x/ipl.h across 
v11.1.0-600-g854de451f21c
 "hw/s390x/ipl: Add IPIB flags to IPL Parameter Block")
Signed-off-by: Michael Tokarev <[email protected]>

diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 1babcd2b7dd..a844b5daecf 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -525,6 +525,8 @@ static bool s390_build_iplb(DeviceState *dev_st, 
IplParameterBlock *iplb)
         switch (devtype) {
         case PCI_DEVTYPE_VIRTIO:
             iplb->len = cpu_to_be32(S390_IPLB_MIN_PCI_LEN);
+            iplb->blk0_len =
+                cpu_to_be32(S390_IPLB_MIN_PCI_LEN - S390_IPLB_HEADER_LEN);
             iplb->pbt = S390_IPL_TYPE_PCI;
             iplb->pci.fid = cpu_to_be32(pbdev->fid);
             break;
diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h
index 33729d4be5a..ad79b000367 100644
--- a/hw/s390x/ipl.h
+++ b/hw/s390x/ipl.h
@@ -107,7 +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_PCI_LEN (offsetof(IplParameterBlock, pci) + 
sizeof(IplBlockPci))
 #define S390_IPLB_MIN_QEMU_SCSI_LEN 200
 
 static inline bool iplb_valid_len(IplParameterBlock *iplb)
-- 
2.47.3


Reply via email to