When secure boot is enabled (-secure-boot on) and certificate(s) are provided, the boot operates in True Secure IPL mode.
Any verification error during True Secure IPL mode will cause the entire boot process to terminate. Secure IPL in audit mode requires at least one certificate provided in the key store along with necessary facilities. If secure boot is enabled but no certificate is provided, the boot process will also terminate, as this is not a valid secure boot configuration. Note: True Secure IPL mode is implemented for the SCSI scheme of virtio-blk/virtio-scsi devices. Signed-off-by: Zhuoying Cai <zy...@linux.ibm.com> --- pc-bios/s390-ccw/bootmap.c | 16 +++++++++++++--- pc-bios/s390-ccw/main.c | 6 +++++- pc-bios/s390-ccw/s390-ccw.h | 2 ++ pc-bios/s390-ccw/secure-ipl.c | 5 +++++ pc-bios/s390-ccw/secure-ipl.h | 2 ++ 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 24356820ca..395d52c65c 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -933,6 +933,9 @@ static int zipl_run(ScsiBlockPtr *pte) entry = (ComponentEntry *)(&header[1]); switch (boot_mode) { + case ZIPL_SECURE_INVALID_MODE: + return -1; + case ZIPL_SECURE_MODE: case ZIPL_SECURE_AUDIT_MODE: if (zipl_run_secure(entry, tmp_sec)) { return -1; @@ -1305,9 +1308,16 @@ ZiplBootMode zipl_mode(uint8_t hdr_flags) { bool sipl_set = hdr_flags & DIAG308_IPIB_FLAGS_SIPL; bool iplir_set = hdr_flags & DIAG308_IPIB_FLAGS_IPLIR; + VCStorageSizeBlock *vcssb; if (!sipl_set && iplir_set) { return ZIPL_SECURE_AUDIT_MODE; + } else if (sipl_set && iplir_set) { + vcssb = zipl_secure_get_vcssb(); + if (vcssb == NULL || vcssb->length == 4) { + return ZIPL_SECURE_INVALID_MODE; + } + return ZIPL_SECURE_MODE; } return ZIPL_NORMAL_MODE; @@ -1318,7 +1328,7 @@ void zipl_load(void) VDev *vdev = virtio_get_device(); if (vdev->is_cdrom) { - if (boot_mode == ZIPL_SECURE_AUDIT_MODE) { + if (boot_mode == ZIPL_SECURE_AUDIT_MODE || boot_mode == ZIPL_SECURE_MODE) { panic("Secure boot from ISO image is not supported!"); } ipl_iso_el_torito(); @@ -1327,7 +1337,7 @@ void zipl_load(void) } if (virtio_get_device_type() == VIRTIO_ID_NET) { - if (boot_mode == ZIPL_SECURE_AUDIT_MODE) { + if (boot_mode == ZIPL_SECURE_AUDIT_MODE || boot_mode == ZIPL_SECURE_MODE) { panic("Virtio net boot device does not support secure boot!"); } netmain(); @@ -1340,7 +1350,7 @@ void zipl_load(void) return; } - if (boot_mode == ZIPL_SECURE_AUDIT_MODE) { + if (boot_mode == ZIPL_SECURE_AUDIT_MODE || boot_mode == ZIPL_SECURE_MODE) { panic("ECKD boot device does not support secure boot!"); } diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 38962da1dd..3e17550854 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -277,10 +277,14 @@ static void ipl_boot_device(void) boot_mode = zipl_mode(iplb->hdr_flags); } + if (boot_mode == ZIPL_SECURE_INVALID_MODE) { + panic("Need at least one certificate for secure boot!"); + } + switch (cutype) { case CU_TYPE_DASD_3990: case CU_TYPE_DASD_2107: - if (boot_mode == ZIPL_SECURE_AUDIT_MODE) { + if (boot_mode == ZIPL_SECURE_AUDIT_MODE || boot_mode == ZIPL_SECURE_MODE) { panic("Passthrough (vfio) device does not support secure boot!"); } diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h index 85f92685f6..bf20efe88e 100644 --- a/pc-bios/s390-ccw/s390-ccw.h +++ b/pc-bios/s390-ccw/s390-ccw.h @@ -83,8 +83,10 @@ int virtio_read(unsigned long sector, void *load_addr); void zipl_load(void); typedef enum ZiplBootMode { + ZIPL_SECURE_INVALID_MODE = -1, ZIPL_NORMAL_MODE = 1, ZIPL_SECURE_AUDIT_MODE = 2, + ZIPL_SECURE_MODE = 3, } ZiplBootMode; extern ZiplBootMode boot_mode; diff --git a/pc-bios/s390-ccw/secure-ipl.c b/pc-bios/s390-ccw/secure-ipl.c index 6e91ec95a8..7d02622c37 100644 --- a/pc-bios/s390-ccw/secure-ipl.c +++ b/pc-bios/s390-ccw/secure-ipl.c @@ -248,6 +248,11 @@ static void valid_sclab_check(SclabOriginLocator *sclab_locator, comps->device_entries[comp_index].cei |= S390_IPL_COMPONENT_CEI_INVALID_SCLAB; /* a missing SCLAB will not be reported in audit mode */ + if (boot_mode == ZIPL_SECURE_MODE) { + zipl_secure_print_func(is_magic_match, + "Magic is not matched. SCLAB does not exist"); + } + return; } diff --git a/pc-bios/s390-ccw/secure-ipl.h b/pc-bios/s390-ccw/secure-ipl.h index 713491671f..9a3b3f016b 100644 --- a/pc-bios/s390-ccw/secure-ipl.h +++ b/pc-bios/s390-ccw/secure-ipl.h @@ -52,6 +52,8 @@ static inline ipl_print_func_t zipl_secure_get_print_func(ZiplBootMode boot_mode { if (boot_mode == ZIPL_SECURE_AUDIT_MODE) { return &IPL_check; + } else if (boot_mode == ZIPL_SECURE_MODE) { + return &IPL_assert; } return NULL; -- 2.49.0