s390x: Add Full Boot Order Support
cover s390x: Add Full Boot Order Support
From: Jared Rossi <[email protected]>
This patch set primarily adds support for the specification of multiple boot devices, allowing for the guest to automatically use an alternative device on a failed boot without needing to be reconfigured. It additionally provides the ability to define the loadparm attribute on a per-device bases, which allows boot devices to use different loadparm values if needed.
In brief, an IPLB is generated for each designated boot device (up to a maximum of 8) and stored in guest memory immediately before BIOS. If a device fails to boot, the next IPLB is retrieved and we jump back to the start of BIOS.
Devices can be specified using the standard qemu device tag "bootindex" as with other architectures. Lower number indices are tried first, with "bootindex=0" indicating the first device to try.
A subsequent Libvirt patch will be necessary to allow assignment of per-device loadparms in the guest XML
Jared Rossi (5):
Create include files for s390x IPL definitions Add loadparm to CcwDevice
Build IPLB chain for multiple boot devices Add boot device fallback infrastructure Enable and document boot device fallback on panic
docs/system/bootindex.rst | 7 +- docs/system/s390x/bootdevices.rst | 9 +- hw/s390x/ccw-device.h | 2 + hw/s390x/ipl.h | 117 +------------------- include/hw/s390x/ipl/qipl.h | 128 ++++++++++++++++++++++ pc-bios/s390-ccw/bootmap.h | 5 + pc-bios/s390-ccw/iplb.h | 108 +++++-------------- pc-bios/s390-ccw/s390-ccw.h | 6 ++ hw/s390x/ccw-device.c | 49 +++++++++ hw/s390x/ipl.c | 170 ++++++++++++++++++++++-------- hw/s390x/s390-virtio-ccw.c | 18 +--- hw/s390x/sclp.c | 3 +- pc-bios/s390-ccw/bootmap.c | 41 ++++--- pc-bios/s390-ccw/main.c | 25 +++-- pc-bios/s390-ccw/netmain.c | 4 + pc-bios/s390-ccw/Makefile | 2 +- 16 files changed, 413 insertions(+), 281 deletions(-) create mode 100644 include/hw/s390x/ipl/qipl.h
Signature · 1 line
2.45.1
PATCH 1/5 s390x: Create include files for s390x IPL definitions
From: Jared Rossi <[email protected]>
Currently, stuctures defined in both hw/s390x/ipl.h and pc-bios/s390-ccw/iplb.h must be kept in sync, which is prone to error. Instead, create a new directory at include/hw/s390x/ipl/ to contain the definitions that must be shared.
--- hw/s390x/ipl.h | 113 +------------------------------- include/hw/s390x/ipl/qipl.h | 126 ++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/iplb.h | 84 ++---------------------- pc-bios/s390-ccw/Makefile | 2 +- 4 files changed, 133 insertions(+), 192 deletions(-) create mode 100644 include/hw/s390x/ipl/qipl.h
hw/s390x/ipl.h +1 -112
@@ -16,95 +16,11 @@#include "cpu.h" #include "exec/address-spaces.h" #include "hw/qdev-core.h" +#include "hw/s390x/ipl/qipl.h" #include "qom/object.h" -struct IPLBlockPVComp { -uint64_t tweak_pref; -uint64_t addr; -uint64_t size; -}QEMU_PACKED ; -typedef struct IPLBlockPVComp IPLBlockPVComp ; - -struct IPLBlockPV { -uint8_t reserved18[87 ];/* 0x18 */ -uint8_t version;/* 0x6f */ -uint32_t reserved70;/* 0x70 */ -uint32_t num_comp;/* 0x74 */ -uint64_t pv_header_addr;/* 0x78 */ -uint64_t pv_header_len;/* 0x80 */ -struct IPLBlockPVComp components[0 ]; -}QEMU_PACKED ; -typedef struct IPLBlockPV IPLBlockPV ; - -struct IplBlockCcw { -uint8_t reserved0[85 ]; -uint8_t ssid; -uint16_t devno; -uint8_t vm_flags; -uint8_t reserved3[3 ]; -uint32_t vm_parm_len; -uint8_t nss_name[8 ]; -uint8_t vm_parm[64 ]; -uint8_t reserved4[8 ]; -}QEMU_PACKED ; -typedef struct IplBlockCcw IplBlockCcw ; - -struct IplBlockFcp { -uint8_t reserved1[305 -1 ]; -uint8_t opt; -uint8_t reserved2[3 ]; -uint16_t reserved3; -uint16_t devno; -uint8_t reserved4[4 ]; -uint64_t wwpn; -uint64_t lun; -uint32_t bootprog; -uint8_t reserved5[12 ]; -uint64_t br_lba; -uint32_t scp_data_len; -uint8_t reserved6[260 ]; -uint8_t scp_data[0 ]; -}QEMU_PACKED ; -typedef struct IplBlockFcp IplBlockFcp ; - -struct IplBlockQemuScsi { -uint32_t lun; -uint16_t target; -uint16_t channel; -uint8_t reserved0[77 ]; -uint8_t ssid; -uint16_t devno; -}QEMU_PACKED ; -typedef struct IplBlockQemuScsi IplBlockQemuScsi ; -#define DIAG308_FLAGS_LP_VALID 0x80 -union IplParameterBlock { -struct { -uint32_t len; -uint8_t reserved0[3 ]; -uint8_t version; -uint32_t blk0_len; -uint8_t pbt; -uint8_t flags; -uint16_t reserved01; -uint8_t loadparm[8 ]; -union { -IplBlockCcw ccw; -IplBlockFcp fcp; -IPLBlockPV pv; -IplBlockQemuScsi scsi; - }; - } QEMU_PACKED; -struct { -uint8_t reserved1[110 ]; -uint16_t devno; -uint8_t reserved2[88 ]; -uint8_t reserved_ext[4096 -200 ]; - } QEMU_PACKED; -}QEMU_PACKED ; -typedef union IplParameterBlock IplParameterBlock ; -int s390_ipl_set_loadparm (uint8_t *loadparm);void s390_ipl_update_diag308 (IplParameterBlock *iplb);int s390_ipl_prepare_pv_header (Error **errp);
@@ -125,33 +41,6 @@ void s390_ipl_reset_request(CPUState *cs, enum s390_reset reset_type);void s390_ipl_get_reset_request (CPUState **cs,enum s390_reset *reset_type);void s390_ipl_clear_reset_request (void ); -#define QIPL_ADDRESS 0xcc - -/* Boot Menu flags */ -#define QIPL_FLAG_BM_OPTS_CMD 0x80 -#define QIPL_FLAG_BM_OPTS_ZIPL 0x40 - -/* -* The QEMU IPL Parameters will be stored at absolute address -* 204 (0xcc) which means it is 32-bit word aligned but not -* double-word aligned. -* Placement of data fields in this area must account for -* their alignment needs. E.g., netboot_start_address must -* have an offset of 4 + n * 8 bytes within the struct in order -* to keep it double-word aligned. -* The total size of the struct must never exceed 28 bytes. -* This definition must be kept in sync with the definition -* in pc-bios/s390-ccw/iplb.h. -*/ -struct QemuIplParameters { -uint8_t qipl_flags; -uint8_t reserved1[3 ]; -uint64_t netboot_start_addr; -uint32_t boot_menu_timeout; -uint8_t reserved2[12 ]; -}QEMU_PACKED ; -typedef struct QemuIplParameters QemuIplParameters ; -#define TYPE_S390_IPL "s390-ipl"OBJECT_DECLARE_SIMPLE_TYPE (S390IPLState,S390_IPL )
include/hw/s390x/ipl/qipl.h new file +126 -0
126 lines not on this page · raw message
pc-bios/s390-ccw/iplb.h +5 -79
93 lines not on this page · raw message
pc-bios/s390-ccw/Makefile +1 -1
@@ -3,7 +3,7 @@ all: build-all @true include config-host.mak -CFLAGS = -O2 -g +CFLAGS = -O2 -g -I $(SRC_PATH)/../..//include/hw/s390x/ipl MAKEFLAGS += -rR GIT_SUBMODULES = roms/SLOF
Signature · 1 line
2.45.1
Re: [PATCH 1/5] s390x: Create include files for s390x IPL definitions
Hi Jared!
Quoted 3 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
Currently, stuctures defined in both
hw/s390x/ipl.handpc-bios/s390-ccw/iplb.h
Typo: s/stuctures/structures/
Quoted 11 lines
must be kept in sync, which is prone to error. Instead, create a new directory at
include/hw/s390x/ipl/to contain the definitions that must be shared.Signed-off-by Jared Rossi <[email protected]>--- hw/s390x/ipl.h | 113 +------------------------------- include/hw/s390x/ipl/qipl.h | 126 ++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/iplb.h | 84 ++---------------------- pc-bios/s390-ccw/Makefile | 2 +- 4 files changed, 133 insertions(+), 192 deletions(-)create mode 100644
include/hw/s390x/ipl/qipl.h
...
pc-bios/s390-ccw/Makefile all: build-all · line 6
Quoted 10 lines
pc-bios/s390-ccw/Makefile +1
-1@@ -3,7 +3,7 @@ all: build-all @true include config-host.mak -CFLAGS = -O2 -g +CFLAGS = -O2 -g -I $(SRC_PATH)/../..//include/hw/s390x/ipl
Duplicate slash -----------------------^
Apart from these two nits, patch looks fine to me.
Thomas
PATCH 2/5 s390x: Add loadparm to CcwDevice
In reply to [email protected]From: Jared Rossi <[email protected]>
Add a loadparm property to the CcwDevice object so that different loadparms can be defined on a per-device basis when using multiple boot devices.
The machine/global loadparm is still supported. If both a global and per-device loadparm are defined, the per-device value will override the global value for that device, but any other devices that do not specify a per-device loadparm will still use the global loadparm.
Assigning a loadparm to a non-boot device is invalid and will be rejected.
--- hw/s390x/ccw-device.h | 2 ++ hw/s390x/ipl.h | 3 +- hw/s390x/ccw-device.c | 49 ++++++++++++++++++++++++++++ hw/s390x/ipl.c | 67 +++++++++++++++++++++++--------------- hw/s390x/s390-virtio-ccw.c | 18 +--------- hw/s390x/sclp.c | 3 +- pc-bios/s390-ccw/main.c | 10 ++++-- 7 files changed, 104 insertions(+), 48 deletions(-)
hw/s390x/ccw-device.h +2 -0
@@ -26,6 +26,8 @@ struct CcwDevice {CssDevId dev_id;/* The actual busid of the virtual subchannel. */ CssDevId subch_id; +/* If set, use this loadparm value when device is boot target */ +uint8_t loadparm[8 ]; };typedef struct CcwDevice CcwDevice ;
hw/s390x/ipl.h +2 -1
@@ -21,7 +21,8 @@#define DIAG308_FLAGS_LP_VALID 0x80 -int s390_ipl_set_loadparm (uint8_t *loadparm); +void s390_ipl_set_loadparm (char *ascii_lp,uint8_t *ebcdic_lp); +void s390_ipl_fmt_loadparm (uint8_t *loadparm,char *str,Error **errp);void s390_ipl_update_diag308 (IplParameterBlock *iplb);int s390_ipl_prepare_pv_header (Error **errp);int s390_ipl_pv_unpack (void );
hw/s390x/ccw-device.c +49 -0
65 lines not on this page · raw message
hw/s390x/ipl.c +41 -26
105 lines not on this page · raw message
hw/s390x/s390-virtio-ccw.c +1 -17
@@ -714,28 +714,12 @@ static void machine_set_loadparm(Object *obj, Visitor *v, {S390CcwMachineState *ms =S390_CCW_MACHINE (obj);char *val; -int i;if (!visit_type_str (v, name, &val, errp)) {return ; } -for (i =0 ; i <sizeof (ms->loadparm) && val[i]; i++) { -uint8_t c =qemu_toupper (val[i]);/* mimic HMC */ - -if (('A' <= c && c <='Z' ) || ('0' <= c && c <='9' ) || (c =='.' ) || - (c ==' ' )) { - ms->loadparm[i] = c; - }else { -error_setg (errp,"LOADPARM: invalid character '%c' (ASCII 0x%02x)" , - c, c); -return ; - } - } - -for (; i <sizeof (ms->loadparm); i++) { - ms->loadparm[i] =' ' ;/* pad right with spaces */ - } +s390_ipl_fmt_loadparm (ms->loadparm, val, errp); }static void ccw_machine_class_init (ObjectClass *oc,void *data)
hw/s390x/sclp.c +2 -1
@@ -175,7 +175,8 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)memcpy (&read_info->loadparm, &ipib->loadparm,sizeof (read_info->loadparm)); }else { -s390_ipl_set_loadparm (read_info->loadparm); +s390_ipl_set_loadparm ((char *)S390_CCW_MACHINE (machine)->loadparm, + read_info->loadparm); } sccb->h.response_code =cpu_to_be16 (SCLP_RC_NORMAL_READ_COMPLETION );
pc-bios/s390-ccw/main.c +7 -3
@@ -173,8 +173,14 @@ static void css_setup(void)static void boot_setup (void ) {char lpmsg[] ="LOADPARM=[________]\n" ; + have_iplb =store_iplb (&iplb); + +if (memcmp (iplb.loadparm,"@@@@@@@@" ,LOADPARM_LEN ) !=0 ) { +ebcdic_to_ascii ((char *) iplb.loadparm, loadparm_str,LOADPARM_LEN ); + }else { +sclp_get_loadparm_ascii (loadparm_str); + } -sclp_get_loadparm_ascii (loadparm_str);memcpy (lpmsg +10 , loadparm_str,8 );sclp_print (lpmsg);
@@ -183,8 +189,6 @@ static void boot_setup(void)* so we don't taint our decision-making process during a reboot. */ memset ((char *)S390EP ,0 ,6 ); - - have_iplb =store_iplb (&iplb); }static void find_boot_device (void )
Signature · 1 line
2.45.1
Re: [PATCH 2/5] s390x: Add loadparm to CcwDevice
Quoted 14 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add a loadparm property to the CcwDevice object so that different loadparms can be defined on a per-device basis when using multiple boot devices.
The machine/global loadparm is still supported. If both a global and per-device loadparm are defined, the per-device value will override the global value for that device, but any other devices that do not specify a per-device loadparm will still use the global loadparm.
Assigning a loadparm to a non-boot device is invalid and will be rejected.
Signed-off-by Jared Rossi <[email protected]>---
...
Quoted 32 lines
hw/s390x/ccw-device.c +17
-0@@ -13,6 +13,10 @@#include "ccw-device.h" #include "hw/qdev-properties.h" #include "qemu/module.h" +#include "ipl.h" +#include "qapi/visitor.h" +#include "qemu/ctype.h" +#include "qapi/error.h" static void ccw_device_refill_ids (CcwDevice *dev) {@@ -36,10 +40,55 @@ static void ccw_device_realize(CcwDevice *dev, Error **errp)ccw_device_refill_ids (dev); } +static void ccw_device_get_loadparm (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +CcwDevice *dev =CCW_DEVICE (obj); +char *str =g_strndup ((char *) dev->loadparm,sizeof (dev->loadparm)); + +visit_type_str (v, name, &str, errp); +g_free (str); +} + +static void ccw_device_set_loadparm(Object *obj, Visitor *v, + const char *name, void *opaque,
hw/s390x/ccw-device.c static void ccw_device_realize(CcwDevice *dev, Error **errp) · line 65
Quoted 10 lines
hw/s390x/ccw-device.c +10
-0+ Error **errp) +{ +CcwDevice *dev =CCW_DEVICE (obj); +char *val; +int index; + + index =object_property_get_int (obj,"bootindex" , &error_abort); + +if (index <0 ) { +error_setg (errp,"LOADPARM: non-boot device" );
If the user is not very experienced, this error message is not very helpful. Maybe: "loadparm is only supported on devices with bootindex property" ?
Quoted 4 lines
hw/s390x/ccw-device.c +4
-0+ } + +if (!visit_type_str (v, name, &val, errp)) { +return ;
hw/s390x/ccw-device.c static void ccw_device_realize(CcwDevice *dev, Error **errp) · line 79
Quoted 10 lines
hw/s390x/ccw-device.c +10
-0+ } + +s390_ipl_fmt_loadparm (dev->loadparm, val, errp); +} + +static const PropertyInfo ccw_loadparm = { + .name ="ccw_loadparm" , + .description ="Up to 8 chars in set of [A-Za-z0-9. ] (lower case" +" chars converted to upper case) to pass to machine loader," +" boot manager, and guest kernel" ,
I know, we're using the same text for the description of the machine property already, but maybe we could do better here: The string is very long, it wraps around unless you use a very huge console window when running QEMU with e.g. "-device virtio-blk-ccw,help".
What do you think about using something like this:
.description = "Up to 8 chars in set of [A-Za-z0-9. ] to pass to the guest
loader/kernel";
?
hw/s390x/ccw-device.c static void ccw_device_realize(CcwDevice *dev, Error **errp) · line 85
Quoted 6 lines
hw/s390x/ccw-device.c +6
-0+ .get = ccw_device_get_loadparm, + .set = ccw_device_set_loadparm, +}; + +#define DEFINE_PROP_CCW_LOADPARM (_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, ccw_loadparm, typeof(uint8_t[8]))
Not sure if it's worth the effort to create a macro just for this if you only need it once below. I'd maybe rather inline the DEFINE_PROP below.
Quoted 25 lines
hw/s390x/ccw-device.c +1
-0static Property ccw_device_properties[] = {DEFINE_PROP_CSS_DEV_ID ("devno" , CcwDevice, devno),DEFINE_PROP_CSS_DEV_ID_RO ("dev_id" , CcwDevice, dev_id),DEFINE_PROP_CSS_DEV_ID_RO ("subch_id" , CcwDevice, subch_id), +DEFINE_PROP_CCW_LOADPARM ("loadparm" , CcwDevice, loadparm),DEFINE_PROP_END_OF_LIST (), };hw/s390x/ipl.c +2
-0@@ -34,6 +34,7 @@#include "qemu/config-file.h" #include "qemu/cutils.h" #include "qemu/option.h" +#include "qemu/ctype.h" #include "standard-headers/linux/virtio_ids.h" #define KERN_IMAGE_START 0x010000UL@@ -390,12 +391,44 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype)return ccw_dev; } +void s390_ipl_fmt_loadparm (uint8_t *loadparm,char *str,Error **errp)
hw/s390x/ipl.c static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) · line 404
Quoted 10 lines
hw/s390x/ipl.c +10
-0+{ +int i; + +/* Initialize the loadparm with spaces */ +memset (loadparm,' ' ,LOADPARM_LEN ); +for (i =0 ; i <LOADPARM_LEN && str[i]; i++) { +uint8_t c =qemu_toupper (str[i]);/* mimic HMC */ + +if (('A' <= c && c <='Z' ) || ('0' <= c && c <='9' ) || (c =='.' ) || + (c ==' ' )) {
You could simplify it to:
if (qemu_isalpha(c) || c == '.' || c == ' ')
hw/s390x/ipl.c static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) · line 414
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ loadparm[i] = c; + }else { +error_setg (errp,"LOADPARM: invalid character '%c' (ASCII 0x%02x)" , + c, c); +return ; + } + } +} + +void s390_ipl_set_loadparm (char *ascii_lp,uint8_t *ebcdic_lp)
I'd maybe rename this function now, maybe s390_ipl_convert_loadparm() or something similar?
Quoted 32 lines
hw/s390x/ipl.c +13
-0+{ +int i; + +/* Initialize the loadparm with EBCDIC spaces (0x40) */ +memset (ebcdic_lp,'@' ,LOADPARM_LEN ); +for (i =0 ; i <LOADPARM_LEN && ascii_lp[i]; i++) { + ebcdic_lp[i] = ascii2ebcdic[(uint8_t ) ascii_lp[i]]; + } +} +static bool s390_gen_initial_iplb (S390IPLState *ipl) {DeviceState *dev_st;CcwDevice *ccw_dev =NULL ;SCSIDevice *sd;int devtype; +uint8_t *lp; dev_st =get_boot_device (0 );if (dev_st) {@@ -406,6 +439,8 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl)* Currently allow IPL only from CCW devices. */ if (ccw_dev) { + lp = ccw_dev->loadparm; +switch (devtype) {case CCW_DEVTYPE_SCSI : sd =SCSI_DEVICE (dev_st);@@ -438,40 +473,20 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl)break ; }
hw/s390x/ipl.c static bool s390_gen_initial_iplb(S390IPLState *ipl) · line 482
Quoted 10 lines
hw/s390x/ipl.c +5
-2-if (!s390_ipl_set_loadparm (ipl->iplb.loadparm)) { - ipl->iplb.flags |=DIAG308_FLAGS_LP_VALID ; +/* If the device loadparm is empty use the global machine loadparm */ +if (memcmp (lp,"\0\0\0\0\0\0\0\0" ,8 ) ==0 ) { + lp =S390_CCW_MACHINE (qdev_get_machine ())->loadparm; } +s390_ipl_set_loadparm ((char *)lp, ipl->iplb.loadparm); + ipl->iplb.flags |=DIAG308_FLAGS_LP_VALID ;
That means DIAG308_FLAGS_LP_VALID is now always set, even if no loadparm has been specified? Shouldn't it be omitted if the user did not specify the loadparm property?
hw/s390x/ipl.c static bool s390_gen_initial_iplb(S390IPLState *ipl) · line 488
Quoted 5 lines
hw/s390x/ipl.c +0
-0return true; }return false; }
Thomas
Re: [PATCH 2/5] s390x: Add loadparm to CcwDevice
Hi Thomas,
Firstly, thanks for the reviews and I agree with your suggestions about function names, info messages, simplifications, etc... I will make those changes.
As for the DIAG308_FLAGS_LP_VALID flag...
Quoted 16 lines
[snip...]
Quoted 7 lines
hw/s390x/ipl.c +1
-1@@ -438,40 +473,20 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) break; } - if (!s390_ipl_set_loadparm(ipl->iplb.loadparm)) { - ipl->iplb.flags |= DIAG308_FLAGS_LP_VALID; + /* If the device loadparm is empty use the global machineQuoted 6 lines
loadparm */
+ if (memcmp(lp, "\0\0\0\0\0\0\0\0", 8)== 0) { + lp = S390_CCW_MACHINE(qdev_get_machine())->loadparm; }
+s390_ipl_set_loadparm((char *)lp, ipl->iplb.loadparm); +ipl->iplb.flags|=DIAG308_FLAGS_LP_VALID;That means
DIAG308_FLAGS_LP_VALIDis now always set, even if no loadparm has been specified? Shouldn't it be omitted if the user did not specify the loadparm property?
No, I don't think it should be omitted if the loadparm hasn't been specified because it is optional and uses a default value if not set. My understanding is that the flag should, actually, always be set here.
As best as I can tell, the existing check is a redundant validation that cannot fail and therefore is not needed. Currently the only way s390_ipl_set_loadparm() can return non-zero is if object_property_get_str() itself returns NULL pointer when getting the loadparm; however, the loadparm is already validated at this point because the string is initialized when the loadparm property is set. If there were a problem with the loadparm string an error would have already been thrown during initialization.
Furthermore, object_property_get_str() is no longer used here. As such, s390_ipl_set_loadparm() is changed to a void function and the check is removed.
Regards,
Jared Rossi
Re: [PATCH 2/5] s390x: Add loadparm to CcwDevice
Quoted 22 lines · Jared Rossi
Hi Thomas,
Firstly, thanks for the reviews and I agree with your suggestions about function names, info messages, simplifications, etc... I will make those changes.
As for the
DIAG308_FLAGS_LP_VALIDflag...Quoted 15 lines
[snip...]
Quoted 6 lines
hw/s390x/ipl.c +1
-1@@ -438,40 +473,20 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) break; } - if (!s390_ipl_set_loadparm(ipl->iplb.loadparm)) { - ipl->iplb.flags |= DIAG308_FLAGS_LP_VALID; + /* If the device loadparm is empty use the global machineQuoted 6 lines
loadparm */
+ if (memcmp(lp, "\0\0\0\0\0\0\0\0", 8)== 0) { + lp = S390_CCW_MACHINE(qdev_get_machine())->loadparm; }
+s390_ipl_set_loadparm((char *)lp, ipl->iplb.loadparm); +ipl->iplb.flags|=DIAG308_FLAGS_LP_VALID;That means
DIAG308_FLAGS_LP_VALIDis now always set, even if no loadparm has been specified? Shouldn't it be omitted if the user did not specify the loadparm property?
Quoted 5 lines
No, I don't think it should be omitted if the loadparm hasn't been specified because it is optional and uses a default value if not set. My understanding is that the flag should, actually, always be set here.
As best as I can tell, the existing check is a redundant validation that cannot fail and therefore is not needed. Currently the only way
s390_ipl_set_loadparm()can return non-zero is ifobject_property_get_str()itself returns NULL pointer when getting the loadparm; however, the loadparm is already validated at this point because the string is initialized when the loadparm property is set. If there were a problem with the loadparm string an error would have already been thrown during initialization.Furthermore,
object_property_get_str()is no longer used here. As such,s390_ipl_set_loadparm()is changed to a void function and the check is removed.
Ok, makes sense thanks for the explanation!
Thomas
Re: [PATCH 2/5] s390x: Add loadparm to CcwDevice
In reply to [email protected]Quoted 14 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add a loadparm property to the CcwDevice object so that different loadparms can be defined on a per-device basis when using multiple boot devices.
The machine/global loadparm is still supported. If both a global and per-device loadparm are defined, the per-device value will override the global value for that device, but any other devices that do not specify a per-device loadparm will still use the global loadparm.
Assigning a loadparm to a non-boot device is invalid and will be rejected.
Signed-off-by Jared Rossi <[email protected]>---
...
Quoted 29 lines
hw/s390x/ccw-device.c +14
-0@@ -13,6 +13,10 @@#include "ccw-device.h" #include "hw/qdev-properties.h" #include "qemu/module.h" +#include "ipl.h" +#include "qapi/visitor.h" +#include "qemu/ctype.h" +#include "qapi/error.h" static void ccw_device_refill_ids (CcwDevice *dev) {@@ -36,10 +40,55 @@ static void ccw_device_realize(CcwDevice *dev, Error **errp)ccw_device_refill_ids (dev); } +static void ccw_device_get_loadparm (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +CcwDevice *dev =CCW_DEVICE (obj); +char *str =g_strndup ((char *) dev->loadparm,sizeof (dev->loadparm)); + +visit_type_str (v, name, &str, errp); +g_free (str); +}
hw/s390x/ccw-device.c static void ccw_device_realize(CcwDevice *dev, Error **errp) · line 62
Quoted 10 lines
hw/s390x/ccw-device.c +10
-0+ +static void ccw_device_set_loadparm (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +CcwDevice *dev =CCW_DEVICE (obj); +char *val; +int index; + + index =object_property_get_int (obj,"bootindex" , &error_abort);
The error_abort is rather unfortunate here, it can be used to terminate QEMU unexpectedly:
$ ./qemu-system-s390x -no-shutdown -nographic -serial none -monitor stdio QEMU 9.0.50 monitor - type 'help' for more information (qemu) device_add virtio-rng-ccw,loadparm=1 Unexpected error in object_property_find_err() at ../../devel/qemu/qom/object.c:1358: Property 'virtio-rng-ccw.bootindex' not found Aborted (core dumped)
Since you check for the error via "index" afterwards anyway, I think it's likely ok to replace &error_abort with NULL here.
But apart from that, it's also a bit ugly that each and every ccw device gets a loadparm property now. Would it be possible to add it to the devices that can be used for booting only?
Thomas
PATCH 3/5 s390x: Build IPLB chain for multiple boot devices
In reply to [email protected]From: Jared Rossi <[email protected]>
Write a chain of IPLBs into memory for future use.
The IPLB chain is placed immediately before the BIOS in memory at the highest unused page boundary providing sufficient space to fit the chain. Because this is not a fixed address, the location of the next IPLB and number of remaining boot devices is stored in the QIPL global variable for later access.
At this stage the IPLB chain is not accessed by the guest during IPL.
--- hw/s390x/ipl.h | 1 + include/hw/s390x/ipl/qipl.h | 4 +- hw/s390x/ipl.c | 129 +++++++++++++++++++++++++++--------- 3 files changed, 103 insertions(+), 31 deletions(-)
hw/s390x/ipl.h +1 -0
@@ -20,6 +20,7 @@#include "qom/object.h" #define DIAG308_FLAGS_LP_VALID 0x80 +#define MAX_IPLB_CHAIN 7void s390_ipl_set_loadparm (char *ascii_lp,uint8_t *ebcdic_lp);void s390_ipl_fmt_loadparm (uint8_t *loadparm,char *str,Error **errp);
include/hw/s390x/ipl/qipl.h +3 -1
@@ -34,7 +34,9 @@ struct QemuIplParameters {uint8_t reserved1[3 ];uint64_t netboot_start_addr;uint32_t boot_menu_timeout; -uint8_t reserved2[12 ]; +uint8_t reserved2[2 ]; +uint16_t num_iplbs; +uint64_t next_iplb; }QEMU_PACKED ;typedef struct QemuIplParameters QemuIplParameters ;
hw/s390x/ipl.c +99 -30
193 lines not on this page · raw message
Signature · 1 line
2.45.1
Re: [PATCH 3/5] s390x: Build IPLB chain for multiple boot devices
Quoted 13 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
Write a chain of IPLBs into memory for future use.
The IPLB chain is placed immediately before the BIOS in memory at the highest unused page boundary providing sufficient space to fit the chain. Because this is not a fixed address, the location of the next IPLB and number of remaining boot devices is stored in the QIPL global variable for later access.
At this stage the IPLB chain is not accessed by the guest during IPL.
Signed-off-by Jared Rossi <[email protected]>---
...
Quoted 20 lines
hw/s390x/ipl.c +2
-7@@ -422,54 +440,51 @@ void s390_ipl_set_loadparm(char *ascii_lp, uint8_t *ebcdic_lp) } } -static bool s390_gen_initial_iplb (S390IPLState *ipl) +static bool s390_build_iplb (DeviceState *dev_st,IplParameterBlock *iplb) { -DeviceState *dev_st; +S390IPLState *ipl =get_ipl_device ();CcwDevice *ccw_dev =NULL ;SCSIDevice *sd;int devtype;uint8_t *lp; - dev_st =get_boot_device (0 ); -if (dev_st) { - ccw_dev =s390_get_ccw_device (dev_st, &devtype); - } -/*
hw/s390x/ipl.c void s390_ipl_set_loadparm(char *ascii_lp, uint8_t *ebcdic_lp) · line 459
Quoted 10 lines
hw/s390x/ipl.c +3
-2* Currently allow IPL only from CCW devices. */ + ccw_dev =s390_get_ccw_device (dev_st, &devtype);if (ccw_dev) { lp = ccw_dev->loadparm; -switch (devtype) { -case CCW_DEVTYPE_SCSI : +switch (devtype) { +case CCW_DEVTYPE_SCSI :
Bad indentation?
Quoted 21 lines
hw/s390x/ipl.c +8
-9sd =SCSI_DEVICE (dev_st); - ipl->iplb.len =cpu_to_be32 (S390_IPLB_MIN_QEMU_SCSI_LEN ); - ipl->iplb.blk0_len = + iplb->len =cpu_to_be32 (S390_IPLB_MIN_QEMU_SCSI_LEN ); + iplb->blk0_len =cpu_to_be32 (S390_IPLB_MIN_QEMU_SCSI_LEN -S390_IPLB_HEADER_LEN ); - ipl->iplb.pbt =S390_IPL_TYPE_QEMU_SCSI ; - ipl->iplb.scsi.lun =cpu_to_be32 (sd->lun); - ipl->iplb.scsi.target =cpu_to_be16 (sd->id); - ipl->iplb.scsi.channel =cpu_to_be16 (sd->channel); - ipl->iplb.scsi.devno =cpu_to_be16 (ccw_dev->sch->devno); - ipl->iplb.scsi.ssid = ccw_dev->sch->ssid &3 ; + iplb->pbt =S390_IPL_TYPE_QEMU_SCSI ; + iplb->scsi.lun =cpu_to_be32 (sd->lun); + iplb->scsi.target =cpu_to_be16 (sd->id); + iplb->scsi.channel =cpu_to_be16 (sd->channel); + iplb->scsi.devno =cpu_to_be16 (ccw_dev->sch->devno); + iplb->scsi.ssid = ccw_dev->sch->ssid &3 ;break ;case CCW_DEVTYPE_VFIO : - ipl->iplb.len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN );
hw/s390x/ipl.c void s390_ipl_set_loadparm(char *ascii_lp, uint8_t *ebcdic_lp) · line 478
Quoted 10 lines
hw/s390x/ipl.c +5
-3- ipl->iplb.pbt =S390_IPL_TYPE_CCW ; - ipl->iplb.ccw.devno =cpu_to_be16 (ccw_dev->sch->devno); - ipl->iplb.ccw.ssid = ccw_dev->sch->ssid &3 ; + iplb->len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN ); + iplb->pbt =S390_IPL_TYPE_CCW ; + iplb->ccw.devno =cpu_to_be16 (ccw_dev->sch->devno); + iplb->ccw.ssid = ccw_dev->sch->ssid &3 ;break ;case CCW_DEVTYPE_VIRTIO_NET : +/* The S390IPLState netboot is ture if ANY IPLB may use netboot */
Typo: ture --> true
Thomas
Re: [PATCH 3/5] s390x: Build IPLB chain for multiple boot devices
In reply to [email protected]Quoted 50 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
Write a chain of IPLBs into memory for future use.
The IPLB chain is placed immediately before the BIOS in memory at the highest unused page boundary providing sufficient space to fit the chain. Because this is not a fixed address, the location of the next IPLB and number of remaining boot devices is stored in the QIPL global variable for later access.
At this stage the IPLB chain is not accessed by the guest during IPL.
Signed-off-by Jared Rossi <[email protected]>--- hw/s390x/ipl.h | 1 + include/hw/s390x/ipl/qipl.h | 4 +- hw/s390x/ipl.c | 129 +++++++++++++++++++++++++++--------- 3 files changed, 103 insertions(+), 31 deletions(-)hw/s390x/ipl.h +1
-0@@ -20,6 +20,7 @@#include "qom/object.h" #define DIAG308_FLAGS_LP_VALID 0x80 +#define MAX_IPLB_CHAIN 7void s390_ipl_set_loadparm (char *ascii_lp,uint8_t *ebcdic_lp);void s390_ipl_fmt_loadparm (uint8_t *loadparm,char *str,Error **errp);include/hw/s390x/ipl/qipl.h +3
-1@@ -34,7 +34,9 @@ struct QemuIplParameters {uint8_t reserved1[3 ];uint64_t netboot_start_addr;uint32_t boot_menu_timeout; -uint8_t reserved2[12 ]; +uint8_t reserved2[2 ]; +uint16_t num_iplbs; +uint64_t next_iplb; }QEMU_PACKED ;typedef struct QemuIplParameters QemuIplParameters ;hw/s390x/ipl.c +0
-0
hw/s390x/ipl.c static bool iplb_extended_needed(void *opaque) · line 58
Quoted 4 lines
hw/s390x/ipl.c +1
-0@@ -55,6 +55,13 @@ static bool iplb_extended_needed(void *opaque)return ipl->iplbext_migration; } +/* Start IPLB chain from the boundary of the first unused page before BIOS */
I'd maybe say "upper boundary" to make it clear that this is at the end of the page, not at the beginning?
Quoted 11 lines
hw/s390x/ipl.c +6
-0+static uint64_t find_iplb_chain_addr (uint64_t bios_addr,uint16_t count) +{ +return (bios_addr &TARGET_PAGE_MASK ) + - (count *sizeof (IplParameterBlock)); +} +static const VMStateDescription vmstate_iplb_extended = { .name ="ipl/iplb_extended" , .version_id =0 ,@@ -391,6 +398,17 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype)return ccw_dev;
hw/s390x/ipl.c static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) · line 408
Quoted 10 lines
hw/s390x/ipl.c +8
-0} +static void s390_ipl_map_iplb_chain (IplParameterBlock *iplb_chain) +{ +S390IPLState *ipl =get_ipl_device (); +uint16_t count = ipl->qipl.num_iplbs; +uint64_t len =sizeof (IplParameterBlock) * count; +uint64_t chain_addr =find_iplb_chain_addr (ipl->bios_start_addr, count); + +cpu_physical_memory_write (chain_addr, iplb_chain,be32_to_cpu (len));
The be32_to_cpu looks wrong here, since you just computed len in native endianness.
hw/s390x/ipl.c static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) · line 409
Quoted 1 line
hw/s390x/ipl.c +1
-0+ ipl->qipl.next_iplb = chain_addr;
Just a matter of taste, but I'd prefer to set ipl->qipl.next_iplb in the same function where you set ipl->qipl.num_iplbs ... so I'd rather return chain_addr here and then do this on the calling site:
ipl->qipl.next_iplb = s390_ipl_map_iplb_chain(...);
Quoted 112 lines
hw/s390x/ipl.c +41
-28+} +void s390_ipl_fmt_loadparm (uint8_t *loadparm,char *str,Error **errp) {int i;@@ -422,54 +440,51 @@ void s390_ipl_set_loadparm(char *ascii_lp, uint8_t *ebcdic_lp) } } -static bool s390_gen_initial_iplb (S390IPLState *ipl) +static bool s390_build_iplb (DeviceState *dev_st,IplParameterBlock *iplb) { -DeviceState *dev_st; +S390IPLState *ipl =get_ipl_device ();CcwDevice *ccw_dev =NULL ;SCSIDevice *sd;int devtype;uint8_t *lp; - dev_st =get_boot_device (0 ); -if (dev_st) { - ccw_dev =s390_get_ccw_device (dev_st, &devtype); - } -/* * Currently allow IPL only from CCW devices. */ + ccw_dev =s390_get_ccw_device (dev_st, &devtype);if (ccw_dev) { lp = ccw_dev->loadparm; -switch (devtype) { -case CCW_DEVTYPE_SCSI : +switch (devtype) { +case CCW_DEVTYPE_SCSI : sd =SCSI_DEVICE (dev_st); - ipl->iplb.len =cpu_to_be32 (S390_IPLB_MIN_QEMU_SCSI_LEN ); - ipl->iplb.blk0_len = + iplb->len =cpu_to_be32 (S390_IPLB_MIN_QEMU_SCSI_LEN ); + iplb->blk0_len =cpu_to_be32 (S390_IPLB_MIN_QEMU_SCSI_LEN -S390_IPLB_HEADER_LEN ); - ipl->iplb.pbt =S390_IPL_TYPE_QEMU_SCSI ; - ipl->iplb.scsi.lun =cpu_to_be32 (sd->lun); - ipl->iplb.scsi.target =cpu_to_be16 (sd->id); - ipl->iplb.scsi.channel =cpu_to_be16 (sd->channel); - ipl->iplb.scsi.devno =cpu_to_be16 (ccw_dev->sch->devno); - ipl->iplb.scsi.ssid = ccw_dev->sch->ssid &3 ; + iplb->pbt =S390_IPL_TYPE_QEMU_SCSI ; + iplb->scsi.lun =cpu_to_be32 (sd->lun); + iplb->scsi.target =cpu_to_be16 (sd->id); + iplb->scsi.channel =cpu_to_be16 (sd->channel); + iplb->scsi.devno =cpu_to_be16 (ccw_dev->sch->devno); + iplb->scsi.ssid = ccw_dev->sch->ssid &3 ;break ;case CCW_DEVTYPE_VFIO : - ipl->iplb.len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN ); - ipl->iplb.pbt =S390_IPL_TYPE_CCW ; - ipl->iplb.ccw.devno =cpu_to_be16 (ccw_dev->sch->devno); - ipl->iplb.ccw.ssid = ccw_dev->sch->ssid &3 ; + iplb->len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN ); + iplb->pbt =S390_IPL_TYPE_CCW ; + iplb->ccw.devno =cpu_to_be16 (ccw_dev->sch->devno); + iplb->ccw.ssid = ccw_dev->sch->ssid &3 ;break ;case CCW_DEVTYPE_VIRTIO_NET : +/* The S390IPLState netboot is ture if ANY IPLB may use netboot */ ipl->netboot = true;/* Fall through to CCW_DEVTYPE_VIRTIO case */ case CCW_DEVTYPE_VIRTIO : - ipl->iplb.len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN ); - ipl->iplb.blk0_len = + iplb->len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN ); + iplb->blk0_len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN -S390_IPLB_HEADER_LEN ); - ipl->iplb.pbt =S390_IPL_TYPE_CCW ; - ipl->iplb.ccw.devno =cpu_to_be16 (ccw_dev->sch->devno); - ipl->iplb.ccw.ssid = ccw_dev->sch->ssid &3 ; + iplb->pbt =S390_IPL_TYPE_CCW ; + iplb->ccw.devno =cpu_to_be16 (ccw_dev->sch->devno); + iplb->ccw.ssid = ccw_dev->sch->ssid &3 ;break ; }@@ -478,8 +493,8 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) lp =S390_CCW_MACHINE (qdev_get_machine ())->loadparm; } -s390_ipl_set_loadparm ((char *)lp, ipl->iplb.loadparm); - ipl->iplb.flags |=DIAG308_FLAGS_LP_VALID ; +s390_ipl_set_loadparm ((char *)lp, iplb->loadparm); + iplb->flags |=DIAG308_FLAGS_LP_VALID ;return true; }@@ -487,6 +502,58 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl)return false; } +static bool s390_init_all_iplbs (S390IPLState *ipl) +{ +int iplb_num =0 ; +IplParameterBlock iplb_chain[7 ]; +DeviceState *dev_st =get_boot_device (0 ); + +/* +* Parse the boot devices. Generate an IPLB for the first boot device, +* which will later be set with DIAG308. Index any fallback boot devices. +*/ +if (!dev_st) { + ipl->qipl.num_iplbs =0 ; +return false; + }
hw/s390x/ipl.c static bool s390_gen_initial_iplb(S390IPLState *ipl) · line 528
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ + iplb_num =1 ; +s390_build_iplb (dev_st, &ipl->iplb); + ipl->iplb.flags |=DIAG308_FLAGS_LP_VALID ; + +while (get_boot_device (iplb_num)) { + iplb_num++; + } + + ipl->qipl.num_iplbs = iplb_num -1 ;
It's somewhat confusing that ipl->qipl.num_iplbs is one less than iplb_num ... what does ipl->qipl.num_iplbs exactly define? The amount of additional chained devices beside the first one?
A comment either here or qipl.h that describes the exact meaning of num_iplbs would be helpful.
hw/s390x/ipl.c static bool s390_gen_initial_iplb(S390IPLState *ipl) · line 539
Quoted 11 lines
hw/s390x/ipl.c +11
-0+ +/* +* Build fallback IPLBs for any boot devices above index 0, up to a +* maximum amount as defined in ipl.h +*/ +if (iplb_num >1 ) { +if (iplb_num >MAX_IPLB_CHAIN ) { +warn_report ("Excess boot devices defined! %d boot devices found, " +"but only the first %d will be considered." , + iplb_num,MAX_IPLB_CHAIN +1 ); + iplb_num =MAX_IPLB_CHAIN +1 ;
What's now the real maximum number of iplb_num ? If it is MAX_IPLB_CHAIN + 1 then the if-statement above looks wrong, should it be "if (iplb_num > MAX_IPLB_CHAIN + 1)" instead?
hw/s390x/ipl.c static bool s390_gen_initial_iplb(S390IPLState *ipl) · line 528
Quoted 3 lines
hw/s390x/ipl.c +3
-0+ } + + ipl->qipl.num_iplbs = iplb_num -1 ;
You could move that into the body of the above if-statement, since otherwise the value has been set earlier in this function already.
hw/s390x/ipl.c static bool s390_gen_initial_iplb(S390IPLState *ipl) · line 545
Quoted 2 lines
hw/s390x/ipl.c +2
-0+/* Start at 1 because the IPLB for boot index 0 is not chained */ +for (int i =1 ; i < iplb_num; i++) {
Just to double-check: Is "i < iplb_num" right?
Or should it be "i <= iplb_num" instead?
BTW, have you successfully tested booting with 8 devices that all have a boot index, but only the last one is bootable?
hw/s390x/ipl.c static bool s390_gen_initial_iplb(S390IPLState *ipl) · line 555
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ dev_st =get_boot_device (i); +s390_build_iplb (dev_st, &iplb_chain[i -1 ]); + iplb_chain[i -1 ].flags |=DIAG308_FLAGS_LP_VALID ; + } + +s390_ipl_map_iplb_chain (iplb_chain); + } + +return iplb_num; +}
Thomas
Re: [PATCH 3/5] s390x: Build IPLB chain for multiple boot devices
Quoted 45 lines · Thomas Huth
Quoted 44 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
Write a chain of IPLBs into memory for future use.
The IPLB chain is placed immediately before the BIOS in memory at the highest unused page boundary providing sufficient space to fit the chain. Because this is not a fixed address, the location of the next IPLB and number of remaining boot devices is stored in the QIPL global variable for later access.
At this stage the IPLB chain is not accessed by the guest during IPL.
Signed-off-by Jared Rossi <[email protected]>---
hw/s390x/ipl.h | 1 +include/hw/s390x/ipl/qipl.h| 4 +-
hw/s390x/ipl.c | 129 +++++++++++++++++++++++++++---------3 files changed, 103 insertions(+), 31 deletions(-)hw/s390x/ipl.h +1
-0@@ -20,6 +20,7 @@ #include "qom/object.h" #define DIAG308_FLAGS_LP_VALID 0x80 +#define MAX_IPLB_CHAIN 7 void s390_ipl_set_loadparm(char *ascii_lp, uint8_t *ebcdic_lp); void s390_ipl_fmt_loadparm(uint8_t *loadparm, char *str, Error **errp);include/hw/s390x/ipl/qipl.h +3
-1@@ -34,7 +34,9 @@ struct QemuIplParameters { uint8_t reserved1[3]; uint64_t netboot_start_addr; uint32_t boot_menu_timeout; - uint8_t reserved2[12]; + uint8_t reserved2[2]; + uint16_t num_iplbs; + uint64_t next_iplb; } QEMU_PACKED; typedef struct QemuIplParameters QemuIplParameters;diff --git
a/hw/s390x/ipl.cb/hw/s390x/ipl.c
index2d4f5152b3..79429acabd100644
Quoted 8 lines
Quoted 6 lines
hw/s390x/ipl.c +0
-0@@ -55,6 +55,13 @@ static bool iplb_extended_needed(void *opaque) return ipl->iplbext_migration; }+/* Start IPLB chain from the boundary of the first unused page before BIOS */
I'd maybe say "upper boundary" to make it clear that this is at the end of the page, not at the beginning?
The chain does start at the beginning of a page. That being said, the comment still needs to be reworded, I'm just not sure exactly how. "Start the IPLB chain from the nearest page boundary providing sufficient space before BIOS?" Basically because each IPLB is 4K, the chain will occupy the N unused pages before the start of BIOS, where N is the number of chained IPLBS (assuming 4K pages).
Quoted 19 lines
Quoted 19 lines
+static
uint64_tfind_iplb_chain_addr(uint64_t bios_addr, uint16_t count)hw/s390x/ipl.c +5
-0+{ + return (bios_addr & TARGET_PAGE_MASK) + - (count * sizeof(IplParameterBlock)); +} +static const VMStateDescription
vmstate_iplb_extended= { .name = "ipl/iplb_extended",
.version_id = 0,hw/s390x/ipl.c +3
-0@@ -391,6 +398,17 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) return ccw_dev; } +static void s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain) +{ + S390IPLState *ipl = get_ipl_device(); + uint16_t count = ipl->qipl.num_iplbs;
Quoted 9 lines
hw/s390x/ipl.c static CcwDevice · line 410
Quoted 6 lines
hw/s390x/ipl.c +4
-0+ uint64_t len = sizeof(IplParameterBlock) * count; + uint64_t chain_addr = find_iplb_chain_addr(ipl->bios_start_addr, count); + + cpu_physical_memory_write(chain_addr, iplb_chain,be32_to_cpu (len));The
be32_to_cpulooks wrong here, since you just computed len in native endianness.
I'll check it out.
Quoted 5 lines
hw/s390x/ipl.c static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) · line 409
Quoted 1 line
hw/s390x/ipl.c +1
-0+ ipl->qipl.next_iplb = chain_addr;Just a matter of taste, but I'd prefer to set
ipl->qipl.next_iplbin the same function where you setipl->qipl.num_iplbs... so I'd rather returnchain_addrhere and then do this on the calling site:ipl->qipl.next_iplb =
s390_ipl_map_iplb_chain(...);
That should be doable; I'll change it for v2.
Quoted 56 lines
Quoted 22 lines
[snip...]
hw/s390x/ipl.c +8
-0@@ -487,6 +502,58 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) return false; } +static bool s390_init_all_iplbs(S390IPLState *ipl) +{ + int iplb_num = 0; + IplParameterBlock iplb_chain[7]; + DeviceState *dev_st = get_boot_device(0); + + /* +* Parse the boot devices. Generate an IPLB for the first boot device, +* which will later be set with DIAG308. Index any fallback boot devices.
+ */
+ if (!dev_st) {
+ipl->qipl.num_iplbs= 0;
+ return false;
+ }hw/s390x/ipl.c static bool s390_gen_initial_iplb(S390IPLState *ipl) · line 528
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ + iplb_num = 1; + s390_build_iplb(dev_st, &ipl->iplb); + ipl->iplb.flags |= DIAG308_FLAGS_LP_VALID; + + while (get_boot_device(iplb_num)) { + iplb_num++; + } + + ipl->qipl.num_iplbs = iplb_num - 1;It's somewhat confusing that
ipl->qipl.num_iplbsis one less thaniplb_num... what doesipl->qipl.num_iplbsexactly define? The amount of additional chained devices beside the first one?A comment either here or
qipl.hthat describes the exact meaning ofnum_iplbswould be helpful.Quoted 4 lines
+
+ /*
+ * Build fallback IPLBs for any boot devices above index 0, up to a + * maximum amount as defined inipl.hQuoted 8 lines
+ */
+ if (iplb_num> 1) {
+ if (iplb_num>MAX_IPLB_CHAIN) {
+ warn_report("Excess boot devices defined! %d boot devices found, "
+ "but only the first %d will be considered.", +iplb_num,MAX_IPLB_CHAIN+ 1);
+iplb_num=MAX_IPLB_CHAIN+ 1;What's now the real maximum number of
iplb_num? If it isMAX_IPLB_CHAIN+ 1 then the if-statement above looks wrong, should it be "if (iplb_num>MAX_IPLB_CHAIN+ 1)" instead?Quoted 3 lines
+ }
+
+ipl->qipl.num_iplbs=iplb_num- 1;
Quoted 8 lines
You could move that into the body of the above if-statement, since otherwise the value has been set earlier in this function already.
Quoted 3 lines
+ /* Start at 1 because the IPLB for boot index 0 is not chained */
+ for (int i = 1; i <iplb_num; i++) {Just to double-check: Is "i <
iplb_num" right?
Or should it be "i <=iplb_num" instead?
Sorry that I did not realize how poorly named the variables are here. I will rename them in v2, which I think will clarify all of these comments/questions (and you are correct that the warning message is off by one), but in the meantime the gist of it is that ipl->qipl.num_iplbs tracks the number of chained IPLBs only (so it is one less than the total boot devices). MAX_IPLB_CHAIN should also probably be MAX_BOOT_DEVS instead. I could change "num_iplbs" to "chained_iplbs" and similarly "iplb_num" could be changed to "num_boot_devs" to make it more clear what is going on:
ipl->qipl.chained_iplbs = num_boot_devs - 1;
Quoted 2 lines
BTW, have you successfully tested booting with 8 devices that all have a boot index, but only the last one is bootable?
Yes. I will write an automated test to include in v2 also.
Regards,
Jared Rossi
Re: [PATCH 3/5] s390x: Build IPLB chain for multiple boot devices
Quoted 56 lines · Jared Rossi
Quoted 45 lines · Thomas Huth
Quoted 44 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
Write a chain of IPLBs into memory for future use.
The IPLB chain is placed immediately before the BIOS in memory at the highest unused page boundary providing sufficient space to fit the chain. Because this is not a fixed address, the location of the next IPLB and number of remaining boot devices is stored in the QIPL global variable for later access.
At this stage the IPLB chain is not accessed by the guest during IPL.
Signed-off-by Jared Rossi <[email protected]>---
hw/s390x/ipl.h | 1 +include/hw/s390x/ipl/qipl.h| 4 +-
hw/s390x/ipl.c | 129 +++++++++++++++++++++++++++---------3 files changed, 103 insertions(+), 31 deletions(-)hw/s390x/ipl.h +1
-0@@ -20,6 +20,7 @@ #include "qom/object.h" #define DIAG308_FLAGS_LP_VALID 0x80 +#define MAX_IPLB_CHAIN 7 void s390_ipl_set_loadparm(char *ascii_lp, uint8_t *ebcdic_lp); void s390_ipl_fmt_loadparm(uint8_t *loadparm, char *str, Error **errp);include/hw/s390x/ipl/qipl.h +3
-1@@ -34,7 +34,9 @@ struct QemuIplParameters { uint8_t reserved1[3]; uint64_t netboot_start_addr; uint32_t boot_menu_timeout; - uint8_t reserved2[12]; + uint8_t reserved2[2]; + uint16_t num_iplbs; + uint64_t next_iplb; } QEMU_PACKED; typedef struct QemuIplParameters QemuIplParameters;diff --git
a/hw/s390x/ipl.cb/hw/s390x/ipl.c
index2d4f5152b3..79429acabd100644Quoted 8 lines
Quoted 6 lines
hw/s390x/ipl.c +0
-0@@ -55,6 +55,13 @@ static bool iplb_extended_needed(void *opaque) return ipl->iplbext_migration; }+/* Start IPLB chain from the boundary of the first unused page before BIOS */
I'd maybe say "upper boundary" to make it clear that this is at the end of the page, not at the beginning?
Quoted 1 line
The chain does start at the beginning of a page. That being said, the comment still needs to be reworded, I'm just not sure exactly how. "Start the IPLB chain from the nearest page boundary providing sufficient space before BIOS?" Basically because each IPLB is 4K, the chain will occupy the N unused pages before the start of BIOS, where N is the number of chained IPLBS (assuming 4K pages).
Ah, right, I missed that sizeof(IplParameterBlock) == 4096 (I guess I was looking at the old version in pc-bios/s390-ccw/iplb.h that does not seem to have the padding), sorry for the confusion! It's really good that you now unify the headers in your first patch!
Thomas
PATCH 4/5 s390x: Add boot device fallback infrastructure
In reply to [email protected]From: Jared Rossi <[email protected]>
Add a routine for loading the next IPLB if a device fails to boot.
This includes some minor changes to the List-Directed IPL routine so that the failing device may be retried using the legacy boot pointers before moving on to the next device.
--- pc-bios/s390-ccw/bootmap.h | 5 +++++ pc-bios/s390-ccw/iplb.h | 24 ++++++++++++++++++++++ pc-bios/s390-ccw/bootmap.c | 41 ++++++++++++++++++++++++++------------ pc-bios/s390-ccw/main.c | 15 +++++++++----- pc-bios/s390-ccw/netmain.c | 4 ++++ 5 files changed, 71 insertions(+), 18 deletions(-)
pc-bios/s390-ccw/bootmap.h +5 -0
@@ -366,6 +366,11 @@ static inline void read_block(block_number_t blockno,IPL_assert (virtio_read (blockno, buffer) ==0 , errmsg); } +static inline bool read_block_nonfatal (block_number_t blockno,void *buffer) +{ +return (virtio_read (blockno, buffer) ==0 ); +} +static inline bool block_size_ok (uint32_t block_size) {return block_size ==virtio_get_block_size ();
pc-bios/s390-ccw/iplb.h +24 -0
@@ -49,4 +49,28 @@ static inline bool set_iplb(IplParameterBlock *iplb) return manage_iplb(iplb, false); } +/* +* The IPL started on the device, but failed in some way. If the IPLB chain +* still has more devices left to try, use the next device in order. Set the +* next IPLB and save the current qipl parameters state. +*/ +static inline bool load_next_iplb (void ) +{ +IplParameterBlock *next_iplb; + +if (qipl.num_iplbs <1 ) { +return false; + } + + next_iplb = (IplParameterBlock *) qipl.next_iplb; +memcpy (&iplb, next_iplb,sizeof (IplParameterBlock)); +set_iplb (&iplb); + + qipl.num_iplbs--; + qipl.next_iplb = qipl.next_iplb +sizeof (IplParameterBlock); +memcpy ((QemuIplParameters *)QIPL_ADDRESS , &qipl,sizeof (QemuIplParameters)); + +return true; +} +#endif /* IPLB_H */
pc-bios/s390-ccw/bootmap.c +28 -13
87 lines not on this page · raw message
pc-bios/s390-ccw/main.c +10 -5
@@ -53,6 +53,12 @@ unsigned int get_loadparm_index(void)return atoui (loadparm_str); } +static void copy_qipl (void ) +{ +QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS ; +memcpy (&qipl, early_qipl,sizeof (QemuIplParameters)); +} +static int is_dev_possibly_bootable (int dev_no,int sch_no) {bool is_virtio;
@@ -194,7 +200,7 @@ static void boot_setup(void)static void find_boot_device (void ) {VDev *vdev =virtio_get_device (); -bool found; +bool found = false;switch (iplb.pbt) {case S390_IPL_TYPE_CCW :
@@ -221,11 +227,8 @@ static void find_boot_device(void)static int virtio_setup (void ) {VDev *vdev =virtio_get_device (); -QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS ;int ret; -memcpy (&qipl, early_qipl,sizeof (QemuIplParameters)); -if (have_iplb) {menu_setup (); }
@@ -242,7 +245,8 @@ static int virtio_setup(void) ret =virtio_scsi_setup_device (blk_schid);break ;default : -panic ("\n! No IPL device available !\n" ); + ret =1 ; +panic ("Unrecognized virtio device type!\n" ); }if (!ret) {
@@ -296,6 +300,7 @@ static void probe_boot_device(void)void main (void ) { +copy_qipl ();sclp_setup ();css_setup ();boot_setup ();
pc-bios/s390-ccw/netmain.c +4 -0
@@ -36,6 +36,7 @@#include "cio.h" #include "virtio.h" #include "s390-time.h" +#include "iplb.h" #define DEFAULT_BOOT_RETRIES 10#define DEFAULT_TFTP_RETRIES 20
@@ -51,6 +52,7 @@ void write_iplb_location(void) {}#define STSI322_VMDB_UUID_OFFSET ((8 + 12) * 4) IplParameterBlock iplb __attribute__((aligned(PAGE_SIZE))); +QemuIplParameters qipl;static char cfgbuf[2048 ];static SubChannelId net_schid = { .one =1 };
@@ -513,6 +515,8 @@ void main(void) {filename_ip_t fn_ip;int rc, fnlen; +QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS ; +memcpy (&qipl, early_qipl,sizeof (QemuIplParameters));sclp_setup ();sclp_print ("Network boot starting...\n" );
Signature · 1 line
2.45.1
Re: [PATCH 4/5] s390x: Add boot device fallback infrastructure
Quoted 10 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add a routine for loading the next IPLB if a device fails to boot.
This includes some minor changes to the List-Directed IPL routine so that the failing device may be retried using the legacy boot pointers before moving on to the next device.
Signed-off-by Jared Rossi <[email protected]>---
...
Quoted 92 lines
pc-bios/s390-ccw/bootmap.c +27
-12@@ -144,7 +144,10 @@ static block_number_t load_eckd_segments(block_number_t blk, bool ldipl,bool more_data;memset (_bprs,FREE_SPACE_FILLER ,sizeof (_bprs)); -read_block (blk, bprs,"BPRS read failed" ); +if (!read_block_nonfatal (blk, bprs)) { +IPL_assert (ldipl,"BPRS read failed" ); +return -1 ; + } do { more_data = false;@@ -188,7 +191,10 @@ static block_number_t load_eckd_segments(block_number_t blk, bool ldipl,* I.e. the next ptr must point to the unused memory area */ memset (_bprs,FREE_SPACE_FILLER ,sizeof (_bprs)); -read_block (block_nr, bprs,"BPRS continuation read failed" ); +if (!read_block_nonfatal (block_nr, bprs)) { +IPL_assert (ldipl,"BPRS continuation read failed" ); +break ; + } more_data = true;break ; }@@ -197,7 +203,10 @@ static block_number_t load_eckd_segments(block_number_t blk, bool ldipl,* to memory (address). */ rc =virtio_read_many (block_nr, (void *)(*address), count +1 ); -IPL_assert (rc ==0 ,"code chunk read failed" ); +if (rc !=0 ) { +IPL_assert (ldipl,"code chunk read failed" ); +break ; + } *address += (count +1 ) *virtio_get_block_size (); }@@ -295,13 +304,22 @@ static void run_eckd_boot_script(block_number_t bmt_block_nr, " maximum number of boot entries allowed");memset (sec,FREE_SPACE_FILLER ,sizeof (sec)); -read_block (bmt_block_nr, sec,"Cannot read Boot Map Table" ); +if (!read_block_nonfatal (bmt_block_nr, sec)) { +IPL_assert (ldipl,"Cannot read Boot Map Table" ); +return ; + } block_nr =gen_eckd_block_num (&bmt->entry[loadparm].xeckd, ldipl); -IPL_assert (block_nr !=-1 ,"Cannot find Boot Map Table Entry" ); +if (block_nr ==-1 ) { +IPL_assert (ldipl,"Cannot find Boot Map Table Entry" ); +return ; + }memset (sec,FREE_SPACE_FILLER ,sizeof (sec)); -read_block (block_nr, sec,"Cannot read Boot Map Script" ); +if (!read_block_nonfatal (block_nr, sec)) { +IPL_assert (ldipl,"Cannot read Boot Map Script" ); +return ; + }for (i =0 ; bms->entry[i].type ==BOOT_SCRIPT_LOAD || bms->entry[i].type ==BOOT_SCRIPT_SIGNATURE ; i++) {@@ -319,13 +337,10 @@ static void run_eckd_boot_script(block_number_t bmt_block_nr, }while (block_nr !=-1 ); } -if (ldipl && bms->entry[i].type !=BOOT_SCRIPT_EXEC ) { -/* Abort LD-IPL and retry as CCW-IPL */ +if (bms->entry[i].type !=BOOT_SCRIPT_EXEC ) { +IPL_assert (ldipl,"Unknown script entry type" );return ; } - -IPL_assert (bms->entry[i].type ==BOOT_SCRIPT_EXEC , -"Unknown script entry type" );write_reset_psw (bms->entry[i].address.load_address);/* no return */ jump_to_IPL_code (0 );/* no return */ }@@ -492,7 +507,7 @@ static void ipl_eckd(void)/* LD-IPL does not use the S1B bock, just make it NULL */ run_eckd_boot_script (ldipl_bmt,NULL_BLOCK_NR );/* Only return in error, retry as CCW-IPL */ -sclp_print ("Retrying IPL " ); +sclp_print ("LD-IPL failed, retrying device\n" );print_eckd_msg (); }memset (sec,FREE_SPACE_FILLER ,sizeof (sec));
pc-bios/s390-ccw/bootmap.c void zipl_load(void) · line 962
Quoted 5 lines
pc-bios/s390-ccw/bootmap.c +1
-1@@ -944,5 +959,5 @@ void zipl_load(void)panic ("\n! Unknown IPL device type !\n" ); } -sclp_print ("zIPL load failed.\n" ); +panic ("zIPL load failed.\n" );
Why replacing the sclp_print() here? Wouldn't it be nicer to continue panicking on the calling site instead?
Quoted 6 lines
pc-bios/s390-ccw/bootmap.c +0
-0}pc-bios/s390-ccw/main.c +0
-0
pc-bios/s390-ccw/main.c unsigned int get_loadparm_index(void) · line 60
Quoted 8 lines
pc-bios/s390-ccw/main.c +5
-0@@ -53,6 +53,12 @@ unsigned int get_loadparm_index(void)return atoui (loadparm_str); } +static void copy_qipl (void ) +{ +QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS ; +memcpy (&qipl, early_qipl,sizeof (QemuIplParameters)); +}
You could move this function as a static inline into iplb.h ...
...
Quoted 21 lines
pc-bios/s390-ccw/netmain.c +2
-0@@ -36,6 +36,7 @@#include "cio.h" #include "virtio.h" #include "s390-time.h" +#include "iplb.h" #define DEFAULT_BOOT_RETRIES 10#define DEFAULT_TFTP_RETRIES 20@@ -51,6 +52,7 @@ void write_iplb_location(void) {}#define STSI322_VMDB_UUID_OFFSET ((8 + 12) * 4) IplParameterBlock iplb __attribute__((aligned(PAGE_SIZE))); +QemuIplParameters qipl;static char cfgbuf[2048 ];static SubChannelId net_schid = { .one =1 };
pc-bios/s390-ccw/netmain.c void main(void) · line 519
Quoted 5 lines
pc-bios/s390-ccw/netmain.c +2
-0@@ -513,6 +515,8 @@ void main(void) {filename_ip_t fn_ip;int rc, fnlen; +QemuIplParameters *early_qipl = (QemuIplParameters *)QIPL_ADDRESS ; +memcpy (&qipl, early_qipl,sizeof (QemuIplParameters));
... then you could use copy_qipl() here, too.
Thomas
Re: [PATCH 4/5] s390x: Add boot device fallback infrastructure
Quoted 99 lines · Thomas Huth
Quoted 10 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add a routine for loading the next IPLB if a device fails to boot.
This includes some minor changes to the List-Directed IPL routine so that the failing device may be retried using the legacy boot pointers before moving on to the next device.
Signed-off-by Jared Rossi <[email protected]>---
...
Quoted 87 lines
pc-bios/s390-ccw/bootmap.c +8
-2@@ -144,7 +144,10 @@ static block_number_t load_eckd_segments(block_number_t blk, bool ldipl, bool more_data; memset(_bprs, FREE_SPACE_FILLER, sizeof(_bprs)); - read_block(blk, bprs, "BPRS read failed"); + if (!read_block_nonfatal(blk, bprs)) { + IPL_assert(ldipl, "BPRS read failed"); + return -1; + } do { more_data = false;@@ -188,7 +191,10 @@ static block_number_tload_eckd_segments(block_number_t blk, bool ldipl, * I.e. the next ptr must point to the unused memory area */ memset(_bprs, FREE_SPACE_FILLER, sizeof(_bprs)); - read_block(block_nr, bprs, "BPRS continuation read failed"); + if (!read_block_nonfatal(block_nr, bprs)) { + IPL_assert(ldipl, "BPRS continuation read failed"); + break; + } more_data = true; break;}
pc-bios/s390-ccw/bootmap.c +16
-4@@ -197,7 +203,10 @@ static block_number_tload_eckd_segments(block_number_t blk, bool ldipl, * to memory (address). */ rc = virtio_read_many(block_nr, (void *)(*address), count + 1); - IPL_assert(rc == 0, "code chunk read failed"); + if (rc != 0) { + IPL_assert(ldipl, "code chunk read failed"); + break; + } *address += (count + 1) * virtio_get_block_size(); }@@ -295,13 +304,22 @@ static void run_eckd_boot_script(block_number_t bmt_block_nr, " maximum number of boot entries allowed"); memset(sec, FREE_SPACE_FILLER, sizeof(sec)); - read_block(bmt_block_nr, sec, "Cannot read Boot Map Table"); + if (!read_block_nonfatal(bmt_block_nr, sec)) { + IPL_assert(ldipl, "Cannot read Boot Map Table"); + return; + } block_nr = gen_eckd_block_num(&bmt->entry[loadparm].xeckd, ldipl); - IPL_assert(block_nr != -1, "Cannot find Boot Map Table Entry"); + if (block_nr == -1) { + IPL_assert(ldipl, "Cannot find Boot Map Table Entry"); + return; + } memset(sec, FREE_SPACE_FILLER, sizeof(sec)); - read_block(block_nr, sec, "Cannot read Boot Map Script"); + if (!read_block_nonfatal(block_nr, sec)) { + IPL_assert(ldipl, "Cannot read Boot Map Script"); + return; + }for (i = 0; bms->entry[i].type ==
BOOT_SCRIPT_LOAD|| bms->entry[i].type ==BOOT_SCRIPT_SIGNATURE; i++) {pc-bios/s390-ccw/bootmap.c +2
-5@@ -319,13 +337,10 @@ static void run_eckd_boot_script(block_number_t bmt_block_nr, } while (block_nr != -1); } - if (ldipl && bms->entry[i].type != BOOT_SCRIPT_EXEC) { - /* Abort LD-IPL and retry as CCW-IPL */ + if (bms->entry[i].type != BOOT_SCRIPT_EXEC) { + IPL_assert(ldipl, "Unknown script entry type"); return; } - - IPL_assert(bms->entry[i].type == BOOT_SCRIPT_EXEC, - "Unknown script entry type");
write_reset_psw(bms->entry[i].address.load_address); /* no return */jump_to_IPL_code(0); /* no return */
}pc-bios/s390-ccw/bootmap.c +1
-1@@ -492,7 +507,7 @@ static void ipl_eckd(void) /* LD-IPL does not use the S1B bock, just make it NULL */ run_eckd_boot_script(ldipl_bmt, NULL_BLOCK_NR); /* Only return in error, retry as CCW-IPL */ - sclp_print("Retrying IPL "); + sclp_print("LD-IPL failed, retrying device\n"); print_eckd_msg(); }
Quoted 8 lines
pc-bios/s390-ccw/bootmap.c void zipl_load(void) · line 961
Quoted 6 lines
pc-bios/s390-ccw/bootmap.c +1
-1memset(sec, FREE_SPACE_FILLER, sizeof(sec));@@ -944,5 +959,5 @@ void zipl_load(void) panic("\n! Unknown IPL device type !\n"); } - sclp_print("zIPL load failed.\n"); + panic("zIPL load failed.\n");Why replacing the
sclp_print()here? Wouldn't it be nicer to continue panicking on the calling site instead?
Ok, after looking at the 5th patch, I think I understand it now: panic() is not fatal anymore and might restart with the next boot device... not sure whether I like that, but let's discuss that on patch 5 instead...
Thomas
PATCH 5/5 s390x: Enable and document boot device fallback on panic
In reply to [email protected]From: Jared Rossi <[email protected]>
On a panic during IPL (i.e. a device failed to boot) check for another device to boot from, as indicated by the presence of an unused IPLB.
If an IPLB is successfully loaded, then jump to the start of BIOS, restarting IPL using the updated IPLB. Otherwise enter disabled wait.
--- docs/system/bootindex.rst | 7 ++++--- docs/system/s390x/bootdevices.rst | 9 ++++++--- pc-bios/s390-ccw/s390-ccw.h | 6 ++++++ 3 files changed, 16 insertions(+), 6 deletions(-)
docs/system/bootindex.rst +4 -3
@@ -50,9 +50,10 @@ Limitations Some firmware has limitations on which devices can be considered for booting. For instance, the PC BIOS boot specification allows only one -disk to be bootable. If boot from disk fails for some reason, the BIOS -won't retry booting from other disk. It can still try to boot from -floppy or net, though. +disk to be bootable, except for on s390x machines. If boot from disk fails for +some reason, the BIOS won't retry booting from other disk. It can still try to +boot from floppy or net, though. In the case of s390x, the BIOS will try up to +8 total devices, any number of which may be disks. Sometimes, firmware cannot map the device path QEMU wants firmware to boot from to a boot method. It doesn't happen for devices the firmware
docs/system/s390x/bootdevices.rst +6 -3
@@ -6,9 +6,7 @@ Booting with bootindex parameter For classical mainframe guests (i.e. LPAR or z/VM installations), you always have to explicitly specify the disk where you want to boot from (or "IPL" from, -in s390x-speak -- IPL means "Initial Program Load"). In particular, there can -also be only one boot device according to the architecture specification, thus -specifying multiple boot devices is not possible (yet). +in s390x-speak -- IPL means "Initial Program Load"). So for booting an s390x guest in QEMU, you should always mark the device where you want to boot from with the ``bootindex`` property, for
@@ -17,6 +15,11 @@ example:: qemu-system-s390x -drive if=none,id=dr1,file=guest.qcow2 \ -device virtio-blk,drive=dr1,bootindex=1 +Multiple devices may have a bootindex. The lowest bootindex is assigned to the +device to IPL first. If the IPL fails for the first, the device with the second +lowest bootindex will be tried and so on until IPL is successful or there are no +remaining boot devices to try. + For booting from a CD-ROM ISO image (which needs to include El-Torito boot information in order to be bootable), it is recommended to specify a ``scsi-cd`` device, for example like this::
pc-bios/s390-ccw/s390-ccw.h +6 -0
@@ -43,6 +43,7 @@ typedef unsigned long long u64;#include "iplb.h" /* start.s */ +extern char _start[];void disabled_wait (void ) __attribute__ ((__noreturn__));void consume_sclp_int (void );void consume_io_int (void );
@@ -88,6 +89,11 @@ __attribute__ ((__noreturn__))static inline void panic (const char *string) {sclp_print (string); +if (load_next_iplb ()) { +sclp_print ("\nTrying next boot device..." ); +jump_to_IPL_code ((long )_start); + } +disabled_wait (); }
Signature · 1 line
2.45.1
Re: [PATCH 5/5] s390x: Enable and document boot device fallback on panic
Quoted 8 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
On a panic during IPL (i.e. a device failed to boot) check for another device to boot from, as indicated by the presence of an unused IPLB.
If an IPLB is successfully loaded, then jump to the start of BIOS, restarting IPL using the updated IPLB. Otherwise enter disabled wait.
Quoted 6 lines
Signed-off-by Jared Rossi <[email protected]>--- docs/system/bootindex.rst | 7 ++++--- docs/system/s390x/bootdevices.rst | 9 ++++++--- pc-bios/s390-ccw/s390-ccw.h | 6 ++++++ 3 files changed, 16 insertions(+), 6 deletions(-)
Could you please split the documentation changes into a separate patch in v2 ? ... I think that would be cleaner.
Quoted 5 lines
docs/system/bootindex.rst +0
-0
docs/system/bootindex.rst Limitations · line 56
Quoted 10 lines
docs/system/bootindex.rst +4
-3@@ -50,9 +50,10 @@ Limitations Some firmware has limitations on which devices can be considered for booting. For instance, the PC BIOS boot specification allows only one -disk to be bootable. If boot from disk fails for some reason, the BIOS -won't retry booting from other disk. It can still try to boot from -floppy or net, though. +disk to be bootable, except for on s390x machines. If boot from disk fails for +some reason, the BIOS won't retry booting from other disk. It can still try to +boot from floppy or net, though. In the case of s390x, the BIOS will try up to +8 total devices, any number of which may be disks.
Since the old text was already talking about "PC BIOS", I'd rather leave that paragraph as it is (maybe just replace "PC BIOS" with "x86 PC BIOS"), and add a separate paragraph afterwards about s390x instead.
Quoted 13 lines
pc-bios/s390-ccw/s390-ccw.h +1
-0@@ -43,6 +43,7 @@ typedef unsigned long long u64;#include "iplb.h" /* start.s */ +extern char _start[];void disabled_wait (void ) __attribute__ ((__noreturn__));void consume_sclp_int (void );void consume_io_int (void );
pc-bios/s390-ccw/s390-ccw.h __attribute__ ((__noreturn__)) · line 98
Quoted 10 lines
pc-bios/s390-ccw/s390-ccw.h +5
-0@@ -88,6 +89,11 @@ __attribute__ ((__noreturn__))static inline void panic (const char *string) {sclp_print (string); +if (load_next_iplb ()) { +sclp_print ("\nTrying next boot device..." ); +jump_to_IPL_code ((long )_start); + } +disabled_wait (); }
Honestly, I am unsure whether this is a really cool idea or a very ugly hack ... but I think I tend towards the latter, sorry. Jumping back to the startup code might cause various problem, e.g. pre-initialized variables don't get their values reset, causing different behavior when the s390-ccw bios runs a function a second time this way. Thus this sounds very fragile. Could we please try to get things cleaned up correctly, so that functions return with error codes instead of panicking when we can continue with another boot device? Even if its more work right now, I think this will be much more maintainable in the future.
Thomas
Re: [PATCH 5/5] s390x: Enable and document boot device fallback on panic
Quoted 26 lines
Quoted 13 lines
pc-bios/s390-ccw/s390-ccw.h +1
-0@@ -43,6 +43,7 @@ typedef unsigned long long u64; #include "iplb.h" /* start.s */ +extern char _start[]; void disabled_wait(void) __attribute__ ((__noreturn__)); void consume_sclp_int(void); void consume_io_int(void);pc-bios/s390-ccw/s390-ccw.h __attribute__ ((__noreturn__)) · line 98
Quoted 10 lines
pc-bios/s390-ccw/s390-ccw.h +5
-0@@ -88,6 +89,11 @@ __attribute__ ((__noreturn__)) static inline void panic(const char *string) { sclp_print(string); + if (load_next_iplb()) { + sclp_print("\nTrying next boot device..."); + jump_to_IPL_code((long)_start); + } + disabled_wait(); }Honestly, I am unsure whether this is a really cool idea or a very ugly hack ... but I think I tend towards the latter, sorry. Jumping back to the startup code might cause various problem, e.g. pre-initialized variables don't get their values reset, causing different behavior when the s390-ccw bios runs a function a second time this way. Thus this sounds very fragile. Could we please try to get things cleaned up correctly, so that functions return with error codes instead of panicking when we can continue with another boot device? Even if its more work right now, I think this will be much more maintainable in the future.
Quoted 2 lines
Thomas
Thanks Thomas, I appreciate your insight. Your hesitation is perfectly understandable as well. My initial design was like you suggest, where the functions return instead of panic, but the issue I ran into is that netboot uses a separate image, which we jump in to at the start of IPL from a network device (see zipl_load() in pc-bios/s390-ccw/bootmap.c). I wasn't able to come up with a simple way to return to the main BIOS code if a netboot fails other than by jumping back. So, it seems to me that netboot kind of throws a monkeywrench into the basic idea of reworking the panics into returns.
I'm open to suggestions on a better way to recover from a failed netboot, and it's certainly possible I've overlooked something, but as far as I can tell a jump is necessary in that particular case at least. Netboot could perhaps be handled as a special case where the jump back is permitted whereas other device types return, but I don't think that actually solves the main issue.
What are your thoughts on this?
Thanks,
Jared Rossi
Re: [PATCH 5/5] s390x: Enable and document boot device fallback on panic
Quoted 26 lines · Jared Rossi
Quoted 26 lines
Quoted 13 lines
pc-bios/s390-ccw/s390-ccw.h +1
-0@@ -43,6 +43,7 @@ typedef unsigned long long u64; #include "iplb.h" /* start.s */ +extern char _start[]; void disabled_wait(void) __attribute__ ((__noreturn__)); void consume_sclp_int(void); void consume_io_int(void);pc-bios/s390-ccw/s390-ccw.h __attribute__ ((__noreturn__)) · line 98
Quoted 10 lines
pc-bios/s390-ccw/s390-ccw.h +5
-0@@ -88,6 +89,11 @@ __attribute__ ((__noreturn__)) static inline void panic(const char *string) { sclp_print(string); + if (load_next_iplb()) { + sclp_print("\nTrying next boot device..."); + jump_to_IPL_code((long)_start); + } + disabled_wait(); }Honestly, I am unsure whether this is a really cool idea or a very ugly hack ... but I think I tend towards the latter, sorry. Jumping back to the startup code might cause various problem, e.g. pre-initialized variables don't get their values reset, causing different behavior when the s390-ccw bios runs a function a second time this way. Thus this sounds very fragile. Could we please try to get things cleaned up correctly, so that functions return with error codes instead of panicking when we can continue with another boot device? Even if its more work right now, I think this will be much more maintainable in the future.
Quoted 8 lines
Quoted 2 lines
Thomas
Thanks Thomas, I appreciate your insight. Your hesitation is perfectly understandable as well. My initial design was like you suggest, where the functions return instead of panic, but the issue I ran into is that netboot uses a separate image, which we jump in to at the start of IPL from a network device (see
zipl_load()inpc-bios/s390-ccw/bootmap.c). I wasn't able to come up with a simple way to return to the main BIOS code if a netboot fails other than by jumping back. So, it seems to me that netboot kind of throws a monkeywrench into the basic idea of reworking the panics into returns.I'm open to suggestions on a better way to recover from a failed netboot, and it's certainly possible I've overlooked something, but as far as I can tell a jump is necessary in that particular case at least. Netboot could perhaps be handled as a special case where the jump back is permitted whereas other device types return, but I don't think that actually solves the main issue.
What are your thoughts on this?
Yes, I agree that jumping is currently required to get back from the netboot code. So if you could rework your patches in a way that limits the jumping to a failed netboot, that would be acceptable, I think.
Apart from that: We originally decided to put the netboot code into a separate binary since the required roms/SLOF module might not always have been checked out (it needed to be done manually), so we were not able to compile it in all cases. But nowadays, this is handled in a much nicer way, the submodule is automatically checked out once you compile the s390x-softmmu target and have a s390x compiler available, so I wonder whether we should maybe do the next step and integrate the netboot code into the main s390-ccw.img now? Anybody got an opinion on this?
Thomas
Re: [PATCH 5/5] s390x: Enable and document boot device fallback on panic
Quoted 34 lines · Thomas Huth
Quoted 33 lines · Jared Rossi
Quoted 26 lines
Quoted 13 lines
pc-bios/s390-ccw/s390-ccw.h +1
-0@@ -43,6 +43,7 @@ typedef unsigned long long u64; #include "iplb.h" /* start.s */ +extern char _start[]; void disabled_wait(void) __attribute__ ((__noreturn__)); void consume_sclp_int(void); void consume_io_int(void);pc-bios/s390-ccw/s390-ccw.h __attribute__ ((__noreturn__)) · line 98
Quoted 10 lines
pc-bios/s390-ccw/s390-ccw.h +5
-0@@ -88,6 +89,11 @@ __attribute__ ((__noreturn__)) static inline void panic(const char *string) { sclp_print(string); + if (load_next_iplb()) { + sclp_print("\nTrying next boot device..."); + jump_to_IPL_code((long)_start); + } + disabled_wait(); }Honestly, I am unsure whether this is a really cool idea or a very ugly hack ... but I think I tend towards the latter, sorry. Jumping back to the startup code might cause various problem, e.g. pre-initialized variables don't get their values reset, causing different behavior when the s390-ccw bios runs a function a second time this way. Thus this sounds very fragile. Could we please try to get things cleaned up correctly, so that functions return with error codes instead of panicking when we can continue with another boot device? Even if its more work right now, I think this will be much more maintainable in the future.
Quoted 2 lines
Thomas
Thanks Thomas, I appreciate your insight. Your hesitation is perfectly understandable as well. My initial design was like you suggest, where the functions return instead of panic, but the issue I ran into is that netboot uses a separate image, which we jump in to at the start of IPL from a network device (see
zipl_load()inpc-bios/s390-ccw/bootmap.c). I wasn't able to come up with a simple way to return to the main BIOS code if a netboot fails other than by jumping back. So, it seems to me that netboot kind of throws a monkeywrench into the basic idea of reworking the panics into returns.I'm open to suggestions on a better way to recover from a failed netboot, and it's certainly possible I've overlooked something, but as far as I can tell a jump is necessary in that particular case at least. Netboot could perhaps be handled as a special case where the jump back is permitted whereas other device types return, but I don't think that actually solves the main issue.
Quoted 8 lines
Quoted 1 line
What are your thoughts on this?
Yes, I agree that jumping is currently required to get back from the netboot code. So if you could rework your patches in a way that limits the jumping to a failed netboot, that would be acceptable, I think.
Apart from that: We originally decided to put the netboot code into a separate binary since the required roms/SLOF module might not always have been checked out (it needed to be done manually), so we were not able to compile it in all cases. But nowadays, this is handled in a much nicer way, the submodule is automatically checked out once you compile the s390x-softmmu target and have a s390x compiler available, so I wonder whether we should maybe do the next step and integrate the netboot code into the main s390-ccw.img now? Anybody got an opinion on this?
Thomas
Hi Thomas,
I would generally defer the decision about integrating the netboot code to someone with more insight than me, but for what it's worth, I am of the opinion that if we want to rework all of panics into returns, then it would make the most sense to also do the integration now so that we can avoid using jump altogether. Unless I'm missing something simple, I don't think the panic/return conversion will be trivial, and actually I think it will be quite invasive since there are dozens of calls to panic and assert that will need to be changed. It doesn't seem worthwhile to do all of these conversions in order to avoid using jump, but then still being exposed to possible problems caused by jumping due to netboot requiring it anyway.
Regards,
Jared Rossi
Re: [PATCH 5/5] s390x: Enable and document boot device fallback on panic
Quoted 41 lines · Jared Rossi
Quoted 38 lines · Thomas Huth
Quoted 26 lines · Jared Rossi
Quoted 26 lines
Quoted 13 lines
pc-bios/s390-ccw/s390-ccw.h +1
-0@@ -43,6 +43,7 @@ typedef unsigned long long u64; #include "iplb.h" /* start.s */ +extern char _start[]; void disabled_wait(void) __attribute__ ((__noreturn__)); void consume_sclp_int(void); void consume_io_int(void);pc-bios/s390-ccw/s390-ccw.h __attribute__ ((__noreturn__)) · line 98
Quoted 10 lines
pc-bios/s390-ccw/s390-ccw.h +5
-0@@ -88,6 +89,11 @@ __attribute__ ((__noreturn__)) static inline void panic(const char *string) { sclp_print(string); + if (load_next_iplb()) { + sclp_print("\nTrying next boot device..."); + jump_to_IPL_code((long)_start); + } + disabled_wait(); }Honestly, I am unsure whether this is a really cool idea or a very ugly hack ... but I think I tend towards the latter, sorry. Jumping back to the startup code might cause various problem, e.g. pre-initialized variables don't get their values reset, causing different behavior when the s390-ccw bios runs a function a second time this way. Thus this sounds very fragile. Could we please try to get things cleaned up correctly, so that functions return with error codes instead of panicking when we can continue with another boot device? Even if its more work right now, I think this will be much more maintainable in the future.
Quoted 8 lines
Quoted 2 lines
Thomas
Thanks Thomas, I appreciate your insight. Your hesitation is perfectly understandable as well. My initial design was like you suggest, where the functions return instead of panic, but the issue I ran into is that netboot uses a separate image, which we jump in to at the start of IPL from a network device (see
zipl_load()inpc-bios/s390-ccw/bootmap.c). I wasn't able to come up with a simple way to return to the main BIOS code if a netboot fails other than by jumping back. So, it seems to me that netboot kind of throws a monkeywrench into the basic idea of reworking the panics into returns.I'm open to suggestions on a better way to recover from a failed netboot, and it's certainly possible I've overlooked something, but as far as I can tell a jump is necessary in that particular case at least. Netboot could perhaps be handled as a special case where the jump back is permitted whereas other device types return, but I don't think that actually solves the main issue.
What are your thoughts on this?
Yes, I agree that jumping is currently required to get back from the netboot code. So if you could rework your patches in a way that limits the jumping to a failed netboot, that would be acceptable, I think.
Quoted 8 lines
Quoted 4 lines
Apart from that: We originally decided to put the netboot code into a separate binary since the required roms/SLOF module might not always have been checked out (it needed to be done manually), so we were not able to compile it in all cases. But nowadays, this is handled in a much nicer way, the submodule is automatically checked out once you compile the s390x-softmmu target and have a s390x compiler available, so I wonder whether we should maybe do the next step and integrate the netboot code into the main s390-ccw.img now? Anybody got an opinion on this?
Thomas
Hi Thomas,
I would generally defer the decision about integrating the netboot code to someone with more insight than me, but for what it's worth, I am of the opinion that if we want to rework all of panics into returns, then it would make the most sense to also do the integration now so that we can avoid using jump altogether. Unless I'm missing something simple, I don't think the panic/return conversion will be trivial, and actually I think it will be quite invasive since there are dozens of calls to panic and assert that will need to be changed. It doesn't seem worthwhile to do all of these conversions in order to avoid using jump, but then still being exposed to possible problems caused by jumping due to netboot requiring it anyway.
Agreed, we should either do it right and merge the two binaries, or it does not make too much sense to only partly convert the code.
I can look into merging the two binaries, but it might also take some time. So for the time being, I'm fine if we include the panic-jumping hack for now, we can still then clean it up later.
Thomas
Re: [PATCH 5/5] s390x: Enable and document boot device fallback on panic
In reply to Thomas HuthAm 05.06.24 um 15:37 schrieb Thomas Huth:
Quoted 51 lines · On 29/05/2024 17.43, [email protected] wrote:
Quoted 8 lines
From: Jared Rossi <[email protected]>
On a panic during IPL (i.e. a device failed to boot) check for another device to boot from, as indicated by the presence of an unused IPLB.
If an IPLB is successfully loaded, then jump to the start of BIOS, restarting IPL using the updated IPLB. Otherwise enter disabled wait.
Quoted 6 lines
Signed-off-by Jared Rossi <[email protected]>---
docs/system/bootindex.rst | 7 ++++---
docs/system/s390x/bootdevices.rst| 9 ++++++---
pc-bios/s390-ccw/s390-ccw.h | 6 ++++++3 files changed, 16 insertions(+), 6 deletions(-)Could you please split the documentation changes into a separate patch in v2 ? ... I think that would be cleaner.
Quoted 7 lines
docs/system/bootindex.rst +0
-0@@ -50,9 +50,10 @@ LimitationsSome firmware has limitations on which devices can be considered for booting. For instance, the PC BIOS boot specification allows only one
docs/system/bootindex.rst Limitations · line 56
Quoted 7 lines
docs/system/bootindex.rst +4
-3-disk to be bootable. If boot from disk fails for some reason, the BIOS -won't retry booting from other disk. It can still try to boot from -floppy or net, though. +disk to be bootable, except for on s390x machines. If boot from disk fails for +some reason, the BIOS won't retry booting from other disk. It can still try to +boot from floppy or net, though. In the case of s390x, the BIOS will try up to +8 total devices, any number of which may be disks.Since the old text was already talking about "PC BIOS", I'd rather leave that paragraph as it is (maybe just replace "PC BIOS" with "x86 PC BIOS"), and add a separate paragraph afterwards about s390x instead.
Quoted 16 lines
pc-bios/s390-ccw/s390-ccw.h +2
-0@@ -43,6 +43,7 @@ typedef unsigned long long u64; #include "iplb.h" /* start.s */ +extern char _start[]; void disabled_wait(void) __attribute__ ((__noreturn__)); void consume_sclp_int(void); void consume_io_int(void);@@ -88,6 +89,11 @@ __attribute__ ((__noreturn__)) static inline void panic(const char *string) { sclp_print(string); + if (load_next_iplb()) {
Quoted 8 lines
pc-bios/s390-ccw/s390-ccw.h __attribute__ ((__noreturn__)) · line 98
Quoted 6 lines
pc-bios/s390-ccw/s390-ccw.h +4
-0+ sclp_print("\nTrying next boot device..."); + jump_to_IPL_code((long)_start); + } + disabled_wait(); }Honestly, I am unsure whether this is a really cool idea or a very ugly hack ... but I think I tend towards the latter, sorry. Jumping back to the startup code might cause various problem, e.g. pre-initialized variables don't get their values reset, causing different behavior when the s390-ccw bios runs a function a second time this way.
We jump back to _start and to me it looks like that this code does the resetting of bss segment. So anything that has a zero value this should be fine. But static variables != 0 are indeed tricky. As far as I can see we do have some of those :-(
So instead of jumping, is there a way that remember somewhere at which device we are and then trigger a re-ipl to reload the BIOS?
Re: [PATCH 5/5] s390x: Enable and document boot device fallback on panic
Quoted 66 lines · Christian Borntraeger
Am 05.06.24 um 15:37 schrieb Thomas Huth:
Quoted 54 lines · On 29/05/2024 17.43, [email protected] wrote:
Quoted 8 lines
From: Jared Rossi <[email protected]>
On a panic during IPL (i.e. a device failed to boot) check for another device to boot from, as indicated by the presence of an unused IPLB.
If an IPLB is successfully loaded, then jump to the start of BIOS, restarting IPL using the updated IPLB. Otherwise enter disabled wait.
Quoted 6 lines
Signed-off-by Jared Rossi <[email protected]>---
docs/system/bootindex.rst | 7 ++++---
docs/system/s390x/bootdevices.rst| 9 ++++++---
pc-bios/s390-ccw/s390-ccw.h | 6 ++++++3 files changed, 16 insertions(+), 6 deletions(-)Could you please split the documentation changes into a separate patch in v2 ? ... I think that would be cleaner.
Quoted 11 lines
docs/system/bootindex.rst +0
-0@@ -50,9 +50,10 @@ LimitationsSome firmware has limitations on which devices can be considered for booting. For instance, the PC BIOS boot specification allows only one
docs/system/bootindex.rst +1
-3-disk to be bootable. If boot from disk fails for some reason, the BIOS -won't retry booting from other disk. It can still try to boot from -floppy or net, though. +disk to be bootable, except for on s390x machines. If boot from diskQuoted 6 lines
fails for
+some reason, the BIOS won't retry booting from other disk. It can still try to
+boot from floppy or net, though. In the case of s390x, the BIOS will try up to
+8 total devices, any number of which may be disks.Since the old text was already talking about "PC BIOS", I'd rather leave that paragraph as it is (maybe just replace "PC BIOS" with "x86 PC BIOS"), and add a separate paragraph afterwards about s390x instead.
Quoted 16 lines
pc-bios/s390-ccw/s390-ccw.h +2
-0@@ -43,6 +43,7 @@ typedef unsigned long long u64; #include "iplb.h" /* start.s */ +extern char _start[]; void disabled_wait(void) __attribute__ ((__noreturn__)); void consume_sclp_int(void); void consume_io_int(void);@@ -88,6 +89,11 @@ __attribute__ ((__noreturn__)) static inline void panic(const char *string) { sclp_print(string); + if (load_next_iplb()) {Quoted 8 lines
pc-bios/s390-ccw/s390-ccw.h __attribute__ ((__noreturn__)) · line 98
Quoted 6 lines
pc-bios/s390-ccw/s390-ccw.h +4
-0+ sclp_print("\nTrying next boot device..."); + jump_to_IPL_code((long)_start); + } + disabled_wait(); }Honestly, I am unsure whether this is a really cool idea or a very ugly hack ... but I think I tend towards the latter, sorry. Jumping back to the startup code might cause various problem, e.g. pre-initialized variables don't get their values reset, causing different behavior when the s390-ccw bios runs a function a second time this way.
Quoted 5 lines
We jump back to
_startand to me it looks like that this code does the resetting of bss segment. So anything that has a zero value this should be fine. But static variables != 0 are indeed tricky. As far as I can see we do have some of those :-(So instead of jumping, is there a way that remember somewhere at which device we are and then trigger a re-ipl to reload the BIOS?
If there is an easy way, this could maybe an option, but in the long run, I'd really prefer if we'd merge the binaries and get rid of such tricks, since this makes the code flow quite hard to understand and maybe also more difficult to debug if you run into problems later.
Thomas
Quoted 26 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
This patch set primarily adds support for the specification of multiple boot devices, allowing for the guest to automatically use an alternative device on a failed boot without needing to be reconfigured. It additionally provides the ability to define the loadparm attribute on a per-device bases, which allows boot devices to use different loadparm values if needed.
In brief, an IPLB is generated for each designated boot device (up to a maximum of 8) and stored in guest memory immediately before BIOS. If a device fails to boot, the next IPLB is retrieved and we jump back to the start of BIOS.
Devices can be specified using the standard qemu device tag "bootindex" as with other architectures. Lower number indices are tried first, with "bootindex=0" indicating the first device to try.
A subsequent Libvirt patch will be necessary to allow assignment of per-device loadparms in the guest XML
Jared Rossi (5):
Create include files for s390x IPL definitions Add loadparm to CcwDevice
Build IPLB chain for multiple boot devices Add boot device fallback infrastructure Enable and document boot device fallback on panic
Quoted 16 lines
docs/system/bootindex.rst | 7 +- docs/system/s390x/bootdevices.rst | 9 +- hw/s390x/ccw-device.h | 2 + hw/s390x/ipl.h | 117 +------------------- include/hw/s390x/ipl/qipl.h | 128 ++++++++++++++++++++++ pc-bios/s390-ccw/bootmap.h | 5 + pc-bios/s390-ccw/iplb.h | 108 +++++-------------- pc-bios/s390-ccw/s390-ccw.h | 6 ++ hw/s390x/ccw-device.c | 49 +++++++++ hw/s390x/ipl.c | 170 ++++++++++++++++++++++-------- hw/s390x/s390-virtio-ccw.c | 18 +--- hw/s390x/sclp.c | 3 +- pc-bios/s390-ccw/bootmap.c | 41 ++++--- pc-bios/s390-ccw/main.c | 25 +++-- pc-bios/s390-ccw/netmain.c | 4 + pc-bios/s390-ccw/Makefile | 2 +-
Hi Jared!
For v2, could you please add at least two tests: one that check booting from the second disk and one that checks booting from the last boot disk when the previous ones are invalid?
I could think of two easy ways for adding such tests, up to you what you prefer:
- Extend the tests/qtest/cdrom-test.c - see add_s390x_tests() there
- Add an avocado test - see "grep -l s390 tests/avocado/*.py" for examples.
Thomas
Quoted 8 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
This patch set primarily adds support for the specification of multiple boot devices, allowing for the guest to automatically use an alternative device on a failed boot without needing to be reconfigured. It additionally provides the ability to define the loadparm attribute on a per-device bases, which allows boot devices to use different loadparm values if needed.
Quoted 7 lines
In brief, an IPLB is generated for each designated boot device (up to a maximum of 8) and stored in guest memory immediately before BIOS. If a device fails to boot, the next IPLB is retrieved and we jump back to the start of BIOS.
Devices can be specified using the standard qemu device tag "bootindex" as with other architectures. Lower number indices are tried first, with "bootindex=0" indicating the first device to try.
Is this supposed with multiple scsi-hd devices, too? I tried to boot a guest with two scsi disks (attached to a single virtio-scsi-ccw adapter) where only the second disk had a bootable installation, but that failed...?
Thomas
Quoted 13 lines · Thomas Huth
Quoted 12 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
This patch set primarily adds support for the specification of multiple boot devices, allowing for the guest to automatically use an alternative device on a failed boot without needing to be reconfigured. It additionally provides the ability to define the loadparm attribute on a per-device bases, which allows boot devices to use different loadparm values if needed.
In brief, an IPLB is generated for each designated boot device (up to a maximum of 8) and stored in guest memory immediately before BIOS. If a device fails to boot, the next IPLB is retrieved and we jump back to the start of BIOS.
Quoted 9 lines
Quoted 3 lines
Devices can be specified using the standard qemu device tag "bootindex" as with other architectures. Lower number indices are tried first, with "bootindex=0" indicating the first device to try.
Is this supposed with multiple scsi-hd devices, too? I tried to boot a guest with two scsi disks (attached to a single virtio-scsi-ccw adapter) where only the second disk had a bootable installation, but that failed...?
Thomas
Hi Thomas,
Yes, I would expect that to work. I tried to reproduce this using a non-bootable scsi disk as the first boot device and then a known-good bootable scsi disk as the second boot device, with one controller. In my instance the BIOS was not able to identify the first disk as bootable and so that device failed to IPL, but it did move on to the next disk after that, and the guest successfully IPL'd from the second device.
When you say it failed, do you mean the first disk failed to boot (as expected), but then the guest died without attempting to boot from the second disk? Or did something else happen? I am either not understanding your configuration or I am not understanding your error.
Regards,
Jared Rossi
Quoted 26 lines · Jared Rossi
Quoted 13 lines · Thomas Huth
Quoted 12 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
This patch set primarily adds support for the specification of multiple boot devices, allowing for the guest to automatically use an alternative device on a failed boot without needing to be reconfigured. It additionally provides the ability to define the loadparm attribute on a per-device bases, which allows boot devices to use different loadparm values if needed.
In brief, an IPLB is generated for each designated boot device (up to a maximum of 8) and stored in guest memory immediately before BIOS. If a device fails to boot, the next IPLB is retrieved and we jump back to the start of BIOS.
Quoted 9 lines
Quoted 3 lines
Devices can be specified using the standard qemu device tag "bootindex" as with other architectures. Lower number indices are tried first, with "bootindex=0" indicating the first device to try.
Is this supposed with multiple scsi-hd devices, too? I tried to boot a guest with two scsi disks (attached to a single virtio-scsi-ccw adapter) where only the second disk had a bootable installation, but that failed...?
Thomas
Quoted 5 lines
Hi Thomas,
Yes, I would expect that to work. I tried to reproduce this using a non-bootable scsi disk as the first boot device and then a known-good bootable scsi disk as the second boot device, with one controller. In my instance the BIOS was not able to identify the first disk as bootable and so that device failed to IPL, but it did move on to the next disk after that, and the guest successfully IPL'd from the second device.
When you say it failed, do you mean the first disk failed to boot (as expected), but then the guest died without attempting to boot from the second disk? Or did something else happen? I am either not understanding your configuration or I am not understanding your error.
I did this:
$ ./qemu-system-s390x -bios pc-bios/s390-ccw/s390-ccw.img -accel kvm \ -device virtio-scsi-ccw -drive if=none,id=d2,file=/tmp/bad.qcow2 \ -device scsi-hd,drive=d2,bootindex=2 \ -drive if=none,id=d8,file=/tmp/good.qcow2 \ -device scsi-hd,drive=d8,bootindex=3 -m 4G -nographic LOADPARM=[ ] Using virtio-scsi. Using guessed DASD geometry. Using ECKD scheme (block size 512), CDL No zIPL section in IPL2 record. zIPL load failed.
Trying next boot device...
LOADPARM=[ ]
Using virtio-scsi.
Using guessed DASD geometry.
Using ECKD scheme (block size 512), CDL
No zIPL section in IPL2 record.
zIPL load failed.
So it claims to try to load from the second disk, but it fails.
If I change the "bootindex=3" of the second disk to "bootindex=1", it boots perfectly fine, so I'm sure that the installation on good.qcow2 is working fine.
Thomas
Quoted 55 lines · Thomas Huth
Quoted 26 lines · Jared Rossi
Quoted 13 lines · Thomas Huth
Quoted 12 lines · On 29/05/2024 17.43, [email protected] wrote:
From: Jared Rossi <[email protected]>
This patch set primarily adds support for the specification of multiple boot devices, allowing for the guest to automatically use an alternative device on a failed boot without needing to be reconfigured. It additionally provides the ability to define the loadparm attribute on a per-device bases, which allows boot devices to use different loadparm values if needed.
In brief, an IPLB is generated for each designated boot device (up to a maximum of 8) and stored in guest memory immediately before BIOS. If a device fails to boot, the next IPLB is retrieved and we jump back to the start of BIOS.
Quoted 9 lines
Quoted 3 lines
Devices can be specified using the standard qemu device tag "bootindex" as with other architectures. Lower number indices are tried first, with "bootindex=0" indicating the first device to try.
Is this supposed with multiple scsi-hd devices, too? I tried to boot a guest with two scsi disks (attached to a single virtio-scsi-ccw adapter) where only the second disk had a bootable installation, but that failed...?
Thomas
Quoted 5 lines
Hi Thomas,
Yes, I would expect that to work. I tried to reproduce this using a non-bootable scsi disk as the first boot device and then a known-good bootable scsi disk as the second boot device, with one controller. In my instance the BIOS was not able to identify the first disk as bootable and so that device failed to IPL, but it did move on to the next disk after that, and the guest successfully IPL'd from the second device.
When you say it failed, do you mean the first disk failed to boot (as expected), but then the guest died without attempting to boot from the second disk? Or did something else happen? I am either not understanding your configuration or I am not understanding your error.
I did this:
$ ./qemu-system-s390x -bios pc-bios/s390-ccw/s390-ccw.img -accel kvm \ -device virtio-scsi-ccw -drive if=none,id=d2,file=/tmp/bad.qcow2 \ -device scsi-hd,drive=d2,bootindex=2 \ -drive if=none,id=d8,file=/tmp/good.qcow2 \ -device scsi-hd,drive=d8,bootindex=3 -m 4G -nographic LOADPARM=[ ] Using virtio-scsi. Using guessed DASD geometry. Using ECKD scheme (block size 512), CDL No zIPL section in IPL2 record. zIPL load failed.Trying next boot device...
LOADPARM=[ ]
Using virtio-scsi.
Using guessed DASD geometry.
Using ECKD scheme (block size 512), CDL
No zIPL section in IPL2 record.
zIPL load failed.
Quoted 5 lines
So it claims to try to load from the second disk, but it fails.
If I change the "bootindex=3" of the second disk to "bootindex=1", it boots perfectly fine, so I'm sure that the installation on good.qcow2 is working fine.Thomas
I am able to reproduce this now; I'll investigate the problem.