@samitouri / QOSamiQemu / commits / a8fe09be7c

pc-bios/s390-ccw: Introduce ZiplBootMode enum for IPL mode selection

Add ZiplBootMode enumeration to support multiple IPL boot configurations. Boot modes differentiate between normal boot and secure IPL operations, enabled based on boot certificates specified via the boot-certs option. Normal Mode: IPL when no certificates are provided. No signature verification is performed. This prepares for future secure IPL modes requiring signature verification. Signed-off-by: Zhuoying Cai <zycai@linux.ibm.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-23-zycai@linux.ibm.com Signed-off-by: Eric Farman <farman@linux.ibm.com>

Zhuoying Cai committed Jul 30, 2026 at 17:46 UTC a8fe09be7cca54ed989c7be56e9499b9ea26860f
4 files changed +48 -1
docs/system/s390x/secure-ipl.rst
+21
@@ -18,3 +18,24 @@ Note: certificate files must have a .pem extension.
18 .. code-block:: shell
19
20 qemu-system-s390x -machine s390-ccw-virtio,boot-certs.0.path=/.../qemu/certs,boot-certs.1.path=/another/path/cert.pem ...
21 +
22 +
23 +IPL Modes
24 +---------
25 +
26 +Multiple IPL modes are available to differentiate between the various IPL
27 +configurations. These modes are mutually exclusive and enabled based on the
28 +``boot-certs`` option on the QEMU command line.
29 +
30 +Normal Mode
31 +^^^^^^^^^^^
32 +
33 +The absence of certificates will attempt to IPL a guest without secure IPL
34 +operations. No checks are performed, and no warnings/errors are reported.
35 +This is the default mode.
36 +
37 +Configuration:
38 +
39 +.. code-block:: shell
40 +
41 + qemu-system-s390x -machine s390-ccw-virtio ...
pc-bios/s390-ccw/bootmap.c
+15 -1
@@ -332,6 +332,9 @@ static int run_eckd_boot_script(block_number_t bmt_block_nr,
332 /* The S1B block number is NULL_BLOCK_NR if and only if it's an LD-IPL */
333 bool ldipl = (s1b_block_nr == NULL_BLOCK_NR);
334
335 + IPL_assert((boot_mode == ZIPL_BOOT_MODE_NORMAL),
336 + "Secure boot with the ECKD scheme is not supported!");
337 +
338 if (menu_is_enabled_zipl() && !ldipl) {
339 loadparm = eckd_get_boot_menu_index(s1b_block_nr);
340 }
@@ -731,7 +734,14 @@ static int zipl_run(ScsiBlockPtr *pte)
734 /* Load image(s) into RAM */
735 entry = (ComponentEntry *)(&header[1]);
736
734 - rc = zipl_run_normal(&entry, tmp_sec);
737 + switch (boot_mode) {
738 + case ZIPL_BOOT_MODE_NORMAL:
739 + rc = zipl_run_normal(&entry, tmp_sec);
740 + break;
741 + default:
742 + panic("Unknown boot mode");
743 + }
744 +
745 if (rc) {
746 return rc;
747 }
@@ -1102,12 +1112,16 @@ void zipl_load(void)
1112 VDev *vdev = virtio_get_device();
1113
1114 if (vdev->is_cdrom) {
1115 + IPL_assert((boot_mode == ZIPL_BOOT_MODE_NORMAL),
1116 + "Secure boot from ISO image is not supported!");
1117 ipl_iso_el_torito();
1118 puts("Failed to IPL this ISO image!");
1119 return;
1120 }
1121
1122 if (virtio_get_device_type() == VIRTIO_ID_NET) {
1123 + IPL_assert((boot_mode == ZIPL_BOOT_MODE_NORMAL),
1124 + "Virtio net boot device does not support secure boot!");
1125 netmain();
1126 puts("Failed to IPL from this network!");
1127 return;
pc-bios/s390-ccw/main.c
+6
@@ -30,6 +30,7 @@ IplParameterBlock *iplb;
30 bool have_iplb;
31 static uint16_t cutype;
32 LowCore *lowcore; /* Yes, this *is* a pointer to address 0 */
33 +ZiplBootMode boot_mode;
34
35 #define LOADPARM_PROMPT "PROMPT "
36 #define LOADPARM_EMPTY " "
@@ -306,6 +307,9 @@ static void ipl_ccw_device(void)
307 switch (cutype) {
308 case CU_TYPE_DASD_3990:
309 case CU_TYPE_DASD_2107:
310 + IPL_assert((boot_mode == ZIPL_BOOT_MODE_NORMAL),
311 + "Passthrough (vfio) CCW device does not support secure boot!");
312 +
313 dasd_ipl(blk_schid, cutype);
314 break;
315 case CU_TYPE_VIRTIO:
@@ -393,6 +397,8 @@ void main(void)
397 probe_boot_device();
398 }
399
400 + boot_mode = ZIPL_BOOT_MODE_NORMAL;
401 +
402 while (have_iplb) {
403 boot_setup();
404 if (have_iplb && find_boot_device()) {
pc-bios/s390-ccw/s390-ccw.h
+6
@@ -69,6 +69,12 @@ int sclp_read(char *str, size_t count);
69 /* bootmap.c */
70 void zipl_load(void);
71
72 +typedef enum ZiplBootMode {
73 + ZIPL_BOOT_MODE_NORMAL = 0,
74 +} ZiplBootMode;
75 +
76 +extern ZiplBootMode boot_mode;
77 +
78 /* jump2ipl.c */
79 void write_reset_psw(uint64_t psw);
80 int jump_to_IPL_code(uint64_t address);