@samitouri / QOSamiQemu / commits / fbf92af49a

pc-bios/s390-ccw: Rework zipl_load_segment function

Change zipl_load_segment() to accept explicit blockno and address parameters instead of ComponentEntry pointer and return segment length. Modify this function to allow the caller to specify a memory address where segment data should be loaded into. seg_len variable is necessary to store the calculated segment length and is used during signature verification. Return the length on success, or a negative return code on failure. Remove static qualifier and add function declaration to bootmap.h to make it accessible to other modules. Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Collin Walling <walling@linux.ibm.com> Reviewed-by: Jared Rossi <jrossi@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260730214624.2328883-22-zycai@linux.ibm.com Signed-off-by: Eric Farman <farman@linux.ibm.com>

Zhuoying Cai committed Jul 30, 2026 at 17:46 UTC fbf92af49a37ec586755405843a6ce884a7b94d5
2 files changed +19 -8
pc-bios/s390-ccw/bootmap.c
+6 -8
@@ -615,19 +615,15 @@ static int ipl_eckd(void)
615 * IPL a SCSI disk
616 */
617
618 -static int zipl_load_segment(ComponentEntry *entry)
618 +int zipl_load_segment(block_number_t blockno, uint64_t address)
619 {
620 const int max_entries = (MAX_SECTOR_SIZE / sizeof(ScsiBlockPtr));
621 ScsiBlockPtr *bprs = (void *)sec;
622 const int bprs_size = sizeof(sec);
623 - block_number_t blockno;
624 - uint64_t address;
623 int i;
624 char err_msg[] = "zIPL failed to read BPRS at 0xZZZZZZZZZZZZZZZZ";
625 char *blk_no = &err_msg[30]; /* where to print blockno in (those ZZs) */
628 -
629 - blockno = entry->data.blockno;
630 - address = entry->compdat.load_addr;
626 + int seg_len = 0;
627
628 debug_print_int("loading segment at block", blockno);
629 debug_print_int("addr", address);
@@ -670,10 +666,12 @@ static int zipl_load_segment(ComponentEntry *entry)
666 puts("zIPL load segment failed");
667 return -EIO;
668 }
669 +
670 + seg_len += bprs->size * (bprs[i].blockct + 1);
671 }
672 } while (blockno);
673
676 - return 0;
674 + return seg_len;
675 }
676
677 static int zipl_run_normal(ComponentEntry **entry_ptr, const uint8_t *tmp_sec)
@@ -689,7 +687,7 @@ static int zipl_run_normal(ComponentEntry **entry_ptr, const uint8_t *tmp_sec)
687 continue;
688 }
689
692 - if (zipl_load_segment(entry)) {
690 + if (zipl_load_segment(entry->data.blockno, entry->compdat.load_addr) < 0) {
691 return -1;
692 }
693
pc-bios/s390-ccw/bootmap.h
+13
@@ -113,6 +113,19 @@ typedef struct ScsiMbr {
113 ScsiBlockPtr pt; /* block pointer to program table */
114 } __attribute__ ((packed)) ScsiMbr;
115
116 +/**
117 + * zipl_load_segment
118 + * @blockno: block number of the first BPRS describing the segment.
119 + * @address: guest physical address at which to load the segment.
120 + *
121 + * Walks the BPRS chain starting at @blockno, loading each data block
122 + * into guest memory at @address.
123 + *
124 + * Returns: length of the segment on success,
125 + * negative value on error.
126 + */
127 +int zipl_load_segment(block_number_t blockno, uint64_t address);
128 +
129 #define ZIPL_MAGIC "zIPL"
130 #define ZIPL_MAGIC_EBCDIC "\xa9\xc9\xd7\xd3"
131 #define IPL1_MAGIC "\xc9\xd7\xd3\xf1" /* == "IPL1" in EBCDIC */