s390-ccw bios update
The following changes since commit 6f625ce2f21d6a1243065d236298277c56f972d5:
Merge tag 'pull-request-2024-10-21' of https://gitlab.com/thuth/qemu into staging (2024-10-21 17:12:59 +0100)
are available in the Git repository at:
https://gitlab.com/thuth/qemu.git tags/pull-request-2024-10-23
for you to fetch changes up to 239e351ec415ff3673d9da70d70ca3a5dd95a2f0:
pc-bios/s390-ccw: Update s390-ccw.img with the full boot order support feature (2024-10-23 06:53:44 +0200)
----------------------------------------------------------------
* Allow multiple boot devices (via bootindex properties) on s390x
* Avoid TEXTREL relocations in the s390-ccw.img firmware
----------------------------------------------------------------
Jared Rossi (16):
pc-bios/s390-ccw: Use the libc from SLOF and remove sclp prints pc-bios/s390-ccw: Link the netboot code into the main s390-ccw.img binary docs/system/s390x/bootdevices: Update the documentation about network booting pc-bios/s390-ccw: Remove panics from ISO IPL path pc-bios/s390-ccw: Remove panics from ECKD IPL path pc-bios/s390-ccw: Remove panics from SCSI IPL path pc-bios/s390-ccw: Remove panics from DASD IPL path pc-bios/s390-ccw: Remove panics from Netboot IPL path pc-bios/s390-ccw: Enable failed IPL to return after error include/hw/s390x: Add include files for common IPL structs
s390x: Add individual loadparm assignment to CCW device hw/s390x: Build an IPLB for each boot device
s390x: Rebuild IPLB for SCSI device directly from DIAG308 pc-bios/s390x: Enable multi-device boot loop
docs/system: Update documentation for s390x IPL
tests/qtest: Add s390x boot order tests to cdrom-test.c
Jens Remus (2):
pc-bios/s390-ccw: Clarify alignment is in bytes pc-bios/s390-ccw: Don't generate TEXTRELs
Marc Hartmayer (1):
pc-bios/s390-ccw: Introduce EXTRA_LDFLAGS
Thomas Huth (4):
hw/s390x/ipl: Provide more memory to the s390-ccw.img firmware hw/s390x: Remove the possibility to load the s390-netboot.img binary pc-bios/s390-ccw: Merge netboot.mak into the main Makefile pc-bios/s390-ccw: Update s390-ccw.img with the full boot order support feature
docs/system/bootindex.rst | 7 +- docs/system/s390x/bootdevices.rst | 29 +- pc-bios/s390-ccw/netboot.mak | 62 ----- hw/s390x/ccw-device.h | 2 + hw/s390x/ipl.h | 123 +-------- include/hw/s390x/ipl/qipl.h | 127 +++++++++ pc-bios/s390-ccw/bootmap.h | 20 +- pc-bios/s390-ccw/cio.h | 2 + pc-bios/s390-ccw/dasd-ipl.h | 2 +- pc-bios/s390-ccw/iplb.h | 108 ++------ pc-bios/s390-ccw/libc.h | 89 ------- pc-bios/s390-ccw/s390-ccw.h | 36 +-- pc-bios/s390-ccw/virtio.h | 3 +- hw/s390x/ccw-device.c | 46 ++++ hw/s390x/ipl.c | 282 ++++++++++---------- hw/s390x/s390-virtio-ccw.c | 28 +- hw/s390x/sclp.c | 9 +- pc-bios/s390-ccw/bootmap.c | 455 ++++++++++++++++++++++---------- pc-bios/s390-ccw/cio.c | 81 +++--- pc-bios/s390-ccw/dasd-ipl.c | 71 ++--- pc-bios/s390-ccw/jump2ipl.c | 22 +- pc-bios/s390-ccw/libc.c | 88 ------ pc-bios/s390-ccw/main.c | 97 ++++--- pc-bios/s390-ccw/menu.c | 51 ++-- pc-bios/s390-ccw/netmain.c | 38 ++- pc-bios/s390-ccw/sclp.c | 7 +- pc-bios/s390-ccw/virtio-blkdev.c | 12 +- pc-bios/s390-ccw/virtio-net.c | 7 +- pc-bios/s390-ccw/virtio-scsi.c | 160 +++++++---- pc-bios/s390-ccw/virtio.c | 67 +++-- target/s390x/diag.c | 9 +- tests/qtest/cdrom-test.c | 24 ++ tests/tcg/s390x/console.c | 3 + pc-bios/meson.build | 1 - pc-bios/s390-ccw.img | Bin 42608 -> 79608 bytes pc-bios/s390-ccw/Makefile | 72 ++++- pc-bios/s390-ccw/start.S | 11 +- pc-bios/s390-netboot.img | Bin 67232 -> 0 bytes tests/tcg/s390x/Makefile.softmmu-target | 2 +- 39 files changed, 1171 insertions(+), 1082 deletions(-) delete mode 100644 pc-bios/s390-ccw/netboot.mak create mode 100644 include/hw/s390x/ipl/qipl.h delete mode 100644 pc-bios/s390-ccw/libc.h delete mode 100644 pc-bios/s390-ccw/libc.c delete mode 100644 pc-bios/s390-netboot.img
[PULL 01/23] hw/s390x/ipl: Provide more memory to the s390-ccw.img firmware
We are going to link the SLOF libc into the s390-ccw.img, and this libc needs more memory for providing space for malloc() and friends. Thus bump the memory size that we reserve for the bios to 3 MiB instead of only 2 MiB. While we're at it, add a proper check that there is really enough memory assigned to the machine before blindly using it.
Message-ID: <[email protected]>
--- hw/s390x/ipl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
hw/s390x/ipl.c +9 -1
@@ -45,6 +45,7 @@#define INITRD_PARM_START 0x010408UL#define PARMFILE_START 0x001000UL#define ZIPL_IMAGE_START 0x009000UL +#define BIOS_MAX_SIZE 0x300000UL#define IPL_PSW_MASK (PSW_MASK_32 | PSW_MASK_64)static bool iplb_extended_needed (void *opaque)
@@ -144,7 +145,14 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)* even if an external kernel has been defined. */ if (!ipl->kernel || ipl->enforce_bios) { -uint64_t fwbase = (MIN (ms->ram_size,0x80000000U ) -0x200000 ) & ~0xffffUL ; +uint64_t fwbase; + +if (ms->ram_size <BIOS_MAX_SIZE ) { +error_setg (errp,"not enough RAM to load the BIOS file" ); +return ; + } + + fwbase = (MIN (ms->ram_size,0x80000000U ) -BIOS_MAX_SIZE ) & ~0xffffUL ; bios_filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , ipl->firmware);if (bios_filename ==NULL ) {
Signature · 1 line
2.47.0
[PULL 15/23] hw/s390x: Build an IPLB for each boot device
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Build an IPLB for any device with a bootindex (up to a maximum of 8 devices).
The IPLB chain is placed immediately before the BIOS in memory. 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 possible later access by the guest during IPL.
Message-ID: <[email protected]>
--- hw/s390x/ipl.h | 1 + include/hw/s390x/ipl/qipl.h | 4 +- hw/s390x/ipl.c | 129 ++++++++++++++++++++++++++++-------- 3 files changed, 105 insertions(+), 29 deletions(-)
hw/s390x/ipl.h +1 -0
@@ -20,6 +20,7 @@#include "qom/object.h" #define DIAG308_FLAGS_LP_VALID 0x80 +#define MAX_BOOT_DEVS 8/* Max number of devices that may have a bootindex */ void s390_ipl_convert_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
@@ -32,7 +32,9 @@ struct QemuIplParameters {uint8_t reserved1[3 ];uint64_t reserved2;uint32_t boot_menu_timeout; -uint8_t reserved3[12 ]; +uint8_t reserved3[2 ]; +uint16_t chain_len; +uint64_t next_iplb; }QEMU_PACKED ;typedef struct QemuIplParameters QemuIplParameters ;
hw/s390x/ipl.c +101 -28
195 lines not on this page · raw message
Signature · 1 line
2.47.0
Re: [PULL 15/23] hw/s390x: Build an IPLB for each boot device
Hi,
Quoted 24 lines · Thomas Huth
From: Jared Rossi <[email protected]>
Build an IPLB for any device with a bootindex (up to a maximum of 8 devices).
The IPLB chain is placed immediately before the BIOS in memory. 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 possible later access by the guest during IPL.
Signed-off-by Jared Rossi <[email protected]>Reviewed-by Thomas Huth <[email protected]>Message-ID: <[email protected]>
[thuth: Fix endianness problem when accessing the qipl structure]Signed-off-by Thomas Huth <[email protected]>--- hw/s390x/ipl.h | 1 + include/hw/s390x/ipl/qipl.h | 4 +- hw/s390x/ipl.c | 129 ++++++++++++++++++++++++++++-------- 3 files changed, 105 insertions(+), 29 deletions(-)hw/s390x/ipl.c +0
-0
hw/s390x/ipl.c static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) · line 415
Quoted 10 lines
hw/s390x/ipl.c +8
-0+static uint64_t s390_ipl_map_iplb_chain (IplParameterBlock *iplb_chain) +{ +S390IPLState *ipl =get_ipl_device (); +uint16_t count =be16_to_cpu (ipl->qipl.chain_len); +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, len);
This patch introduces a call to a legacy API (documented since at least 2017 in commit b7ecba0f6f6: "docs/devel/loads-stores.rst: Document our various load and store APIs"). Can we access the device address space instead?
Quoted 2 lines
hw/s390x/ipl.c +2
-0+return chain_addr; +}
Re: [PULL 15/23] hw/s390x: Build an IPLB for each boot device
Hi Philippe,
I update this to use the proper API call.
Regards,
Jared Rossi
Quoted 46 lines · Philippe Mathieu-Daudé
Hi,
Quoted 32 lines · Thomas Huth
From: Jared Rossi <[email protected]>
Build an IPLB for any device with a bootindex (up to a maximum of 8 devices).
The IPLB chain is placed immediately before the BIOS in memory. 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 possible later access by the guest during IPL.
Signed-off-by Jared Rossi <[email protected]>Reviewed-by Thomas Huth <[email protected]>Message-ID: <[email protected]>
[thuth: Fix endianness problem when accessing the qipl structure]Signed-off-by Thomas Huth <[email protected]>---
hw/s390x/ipl.h | 1 +include/hw/s390x/ipl/qipl.h| 4 +-
hw/s390x/ipl.c | 129 ++++++++++++++++++++++++++++--------3 files changed, 105 insertions(+), 29 deletions(-)hw/s390x/ipl.c +6
-0+static uint64_t s390_ipl_map_iplb_chain (IplParameterBlock *iplb_chain) +{ + S390IPLState *ipl = get_ipl_device(); + uint16_t count = be16_to_cpu(ipl->qipl.chain_len); + uint64_t len = sizeof(IplParameterBlock) * count; + uint64_t chain_addr = find_iplb_chain_addr(ipl->bios_start_addr,Quoted 3 lines
count);
+
+cpu_physical_memory_write(chain_addr, iplb_chain, len);This patch introduces a call to a legacy API (documented since at least 2017 in commit
b7ecba0f6f6: "docs/devel/loads-stores.rst: Document our various load and store APIs"). Can we access the device address space instead?Quoted 2 lines
+ return
chain_addr;
+}
[PULL 16/23] s390x: Rebuild IPLB for SCSI device directly from DIAG308
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Because virtio-scsi type devices use a non-architected IPLB pbt code they cannot be set and stored normally. Instead, the IPLB must be rebuilt during re-ipl.
As s390x does not natively support multiple boot devices, the devno field is used to store the position in the boot order for the device.
Handling the rebuild as part of DIAG308 removes the need to check the devices for invalid IPLBs later in the IPL.
Message-ID: <[email protected]>
--- hw/s390x/ipl.h | 11 ++++-- include/hw/s390x/ipl/qipl.h | 3 +- hw/s390x/ipl.c | 74 ++++++------------------------------- pc-bios/s390-ccw/jump2ipl.c | 11 ++++-- target/s390x/diag.c | 9 ++++- 5 files changed, 38 insertions(+), 70 deletions(-)
hw/s390x/ipl.h +8 -3
@@ -24,6 +24,7 @@void s390_ipl_convert_loadparm (char *ascii_lp,uint8_t *ebcdic_lp);void s390_ipl_fmt_loadparm (uint8_t *loadparm,char *str,Error **errp); +void s390_rebuild_iplb (uint16_t index,IplParameterBlock *iplb);void s390_ipl_update_diag308 (IplParameterBlock *iplb);int s390_ipl_prepare_pv_header (Error **errp);int s390_ipl_pv_unpack (void );
@@ -65,7 +66,8 @@ struct S390IPLState {bool enforce_bios;bool iplb_valid;bool iplb_valid_pv; -bool netboot; +bool rebuilt_iplb; +uint16_t iplb_index;/* reset related properties don't have to be migrated or reset */ enum s390_reset reset_type;int reset_cpu_index;
@@ -172,11 +174,14 @@ static inline bool iplb_valid_pv(IplParameterBlock *iplb)static inline bool iplb_valid (IplParameterBlock *iplb) { +uint32_t len =be32_to_cpu (iplb->len); +switch (iplb->pbt) {case S390_IPL_TYPE_FCP : -return be32_to_cpu (iplb->len) >=S390_IPLB_MIN_FCP_LEN ; +return len >=S390_IPLB_MIN_FCP_LEN ;case S390_IPL_TYPE_CCW : -return be32_to_cpu (iplb->len) >=S390_IPLB_MIN_CCW_LEN ; +return len >=S390_IPLB_MIN_CCW_LEN ; +case S390_IPL_TYPE_QEMU_SCSI :default :return false; }
include/hw/s390x/ipl/qipl.h +2 -1
@@ -29,7 +29,8 @@*/ struct QemuIplParameters {uint8_t qipl_flags; -uint8_t reserved1[3 ]; +uint8_t index; +uint8_t reserved1[2 ];uint64_t reserved2;uint32_t boot_menu_timeout;uint8_t reserved3[2 ];
hw/s390x/ipl.c +12 -62
117 lines not on this page · raw message
pc-bios/s390-ccw/jump2ipl.c +8 -3
@@ -39,10 +39,15 @@ int jump_to_IPL_code(uint64_t address)write_subsystem_identification ();write_iplb_location (); -/* prevent unknown IPL types in the guest */ +/* +* The IPLB for QEMU SCSI type devices must be rebuilt during re-ipl. The +* iplb.devno is set to the boot position of the target SCSI device. +*/ if (iplb.pbt ==S390_IPL_TYPE_QEMU_SCSI ) { - iplb.pbt =S390_IPL_TYPE_CCW ; -set_iplb (&iplb); + iplb.devno = qipl.index; +if (!set_iplb (&iplb)) { +panic ("Failed to set IPLB" ); + } }/*
target/s390x/diag.c +8 -1
@@ -133,7 +133,14 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra) valid = subcode ==DIAG308_PV_SET ?iplb_valid_pv (iplb) :iplb_valid (iplb);if (!valid) { - env->regs[r1 +1 ] =DIAG_308_RC_INVALID ; +if (subcode ==DIAG308_SET && iplb->pbt ==S390_IPL_TYPE_QEMU_SCSI ) { +s390_rebuild_iplb (iplb->devno, iplb); +s390_ipl_update_diag308 (iplb); + env->regs[r1 +1 ] =DIAG_308_RC_OK ; + }else { + env->regs[r1 +1 ] =DIAG_308_RC_INVALID ; + } + goto out; }
Signature · 1 line
2.47.0
[PULL 12/23] pc-bios/s390-ccw: Enable failed IPL to return after error
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Remove panic-on-error from IPL functions such that a return code is propagated back to the main IPL calling function (rather than terminating immediately), which facilitates possible error recovery in the future.
A select few panics remain, which indicate fatal non-devices errors that must result in termination.
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/s390-ccw.h | 2 +- pc-bios/s390-ccw/virtio.h | 2 +- pc-bios/s390-ccw/bootmap.c | 53 ++++++++++++++++++-------- pc-bios/s390-ccw/cio.c | 3 +- pc-bios/s390-ccw/jump2ipl.c | 5 ++- pc-bios/s390-ccw/main.c | 32 +++++++++------- pc-bios/s390-ccw/virtio-blkdev.c | 2 +- pc-bios/s390-ccw/virtio.c | 65 +++++++++++++++++++++----------- 8 files changed, 108 insertions(+), 56 deletions(-)
pc-bios/s390-ccw/s390-ccw.h +1 -1
@@ -78,7 +78,7 @@ void zipl_load(void);/* jump2ipl.c */ void write_reset_psw (uint64_t psw); -void jump_to_IPL_code (uint64_t address); +int jump_to_IPL_code (uint64_t address);void jump_to_low_kernel (void );/* menu.c */
pc-bios/s390-ccw/virtio.h +1 -1
@@ -274,7 +274,7 @@ void vring_send_buf(VRing *vr, void *p, int len, int flags);int vr_poll (VRing *vr);int vring_wait_reply (void );int virtio_run (VDev *vdev,int vqid,VirtioCmd *cmd); -void virtio_setup_ccw (VDev *vdev); +int virtio_setup_ccw (VDev *vdev);int virtio_net_init (void *mac_addr);
pc-bios/s390-ccw/bootmap.c +38 -15
85 lines not on this page · raw message
pc-bios/s390-ccw/cio.c +2 -1
@@ -59,7 +59,8 @@ uint16_t cu_type(SubChannelId schid) };if (do_cio (schid,CU_TYPE_UNKNOWN ,ptr2u32 (&sense_id_ccw),CCW_FMT1 )) { -panic ("Failed to run SenseID CCw\n" ); +puts ("Failed to run SenseID CCW" ); +return CU_TYPE_UNKNOWN ; }return sense_data.cu_type;
pc-bios/s390-ccw/jump2ipl.c +3 -2
@@ -33,7 +33,7 @@ static void jump_to_IPL_addr(void)/* should not return */ } -void jump_to_IPL_code (uint64_t address) +int jump_to_IPL_code (uint64_t address) {/* store the subsystem information _after_ the bootmap was loaded */ write_subsystem_identification ();
@@ -68,7 +68,8 @@ void jump_to_IPL_code(uint64_t address) asmvolatile ("lghi %%r1,1\n\t" "diag %%r1,%%r1,0x308\n\t" : : :"1" ,"memory" ); -panic ("\n! IPL returns !\n" ); +puts ("IPL code jump failed" ); +return -1 ; }void jump_to_low_kernel (void )
pc-bios/s390-ccw/main.c +18 -14
@@ -77,6 +77,9 @@ static int is_dev_possibly_bootable(int dev_no, int sch_no)enable_subchannel (blk_schid); cutype =cu_type (blk_schid); +if (cutype ==CU_TYPE_UNKNOWN ) { +return -EIO ; + }/* * Note: we always have to run virtio_is_supported() here to make
@@ -194,10 +197,10 @@ static void boot_setup(void) have_iplb =store_iplb (&iplb); } -static void find_boot_device (void ) +static bool find_boot_device (void ) {VDev *vdev =virtio_get_device (); -bool found; +bool found = false;switch (iplb.pbt) {case S390_IPL_TYPE_CCW :
@@ -215,10 +218,10 @@ static void find_boot_device(void) found =find_subch (iplb.scsi.devno);break ;default : -panic ("List-directed IPL not supported yet!\n" ); +puts ("Unsupported IPLB" ); } -IPL_assert (found,"Boot device not found\n" ); +return found; }static int virtio_setup (void )
@@ -244,11 +247,13 @@ static int virtio_setup(void) ret =virtio_scsi_setup_device (blk_schid);break ;default : -panic ("\n! No IPL device available !\n" ); +puts ("\n! No IPL device available !\n" ); +return -1 ; } -if (!ret) { -IPL_assert (virtio_ipl_disk_is_valid (),"No valid IPL device detected" ); +if (!ret && !virtio_ipl_disk_is_valid ()) { +puts ("No valid IPL device detected" ); +return -ENODEV ; }return ret;
@@ -259,16 +264,16 @@ static void ipl_boot_device(void)switch (cutype) {case CU_TYPE_DASD_3990 :case CU_TYPE_DASD_2107 : -dasd_ipl (blk_schid, cutype);/* no return */ +dasd_ipl (blk_schid, cutype);break ;case CU_TYPE_VIRTIO : -if (virtio_setup () ==0 ) { -zipl_load ();/* Only returns in case of errors */ +if (virtio_setup ()) { +return ;/* Only returns in case of errors */ } +zipl_load ();break ;default :printf ("Attempting to boot from unexpected device type 0x%X\n" , cutype); -panic ("\nBoot failed.\n" ); } }
@@ -301,12 +306,11 @@ void main(void)sclp_setup ();css_setup ();boot_setup (); -if (have_iplb) { -find_boot_device (); +if (have_iplb &&find_boot_device ()) {ipl_boot_device (); }else {probe_boot_device (); } -panic ("Failed to load OS from hard disk\n" ); +panic ("Failed to IPL. Halting..." ); }
pc-bios/s390-ccw/virtio-blkdev.c +1 -1
@@ -59,7 +59,7 @@ int virtio_read_many(unsigned long sector, void *load_addr, int sec_num)case VIRTIO_ID_SCSI :return virtio_scsi_read_many (vdev, sector, load_addr, sec_num); } -panic ("\n! No readable IPL device !\n" ); +return -1 ; }
pc-bios/s390-ccw/virtio.c +44 -21
114 lines not on this page · raw message
Signature · 1 line
2.47.0
[PULL 18/23] docs/system: Update documentation for s390x IPL
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Update docs to show that s390x PC BIOS can support more than one boot device.
Message-ID: <[email protected]>
--- docs/system/bootindex.rst | 7 ++++--- docs/system/s390x/bootdevices.rst | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-)
docs/system/bootindex.rst +4 -3
@@ -49,10 +49,11 @@ 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 +booting. For instance, the x86 PC BIOS boot specification allows only one +disk to be bootable. If boot from disk fails for some reason, the x86 BIOS won't retry booting from other disk. It can still try to boot from -floppy or net, though. +floppy or net, though. In the case of s390x BIOS, 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::
Signature · 1 line
2.47.0
[PULL 03/23] pc-bios/s390-ccw: Link the netboot code into the main s390-ccw.img binary
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
We originally built a separate binary for the netboot code since it was considered as experimental and we could not be sure that the necessary SLOF module had been checked out. Time passed, the code proved its usefulness, and the build system nowadays makes sure that the SLOF module is checked out if you have a s390x compiler available for building the s390-ccw bios. So there is no real compelling reason anymore to keep the netboot code in a separate binary. Linking the code together with the main s390-ccw.img will make future enhancements much easier, like supporting more than one boot device.
Co-authored by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/netboot.mak | 14 -------------- pc-bios/s390-ccw/cio.h | 2 ++ pc-bios/s390-ccw/iplb.h | 4 ++-- pc-bios/s390-ccw/s390-ccw.h | 3 +++ pc-bios/s390-ccw/virtio.h | 1 - pc-bios/s390-ccw/bootmap.c | 2 +- pc-bios/s390-ccw/main.c | 10 +++++++--- pc-bios/s390-ccw/netmain.c | 15 ++------------- pc-bios/s390-ccw/Makefile | 13 +++++++------ 9 files changed, 24 insertions(+), 40 deletions(-)
pc-bios/s390-ccw/netboot.mak +0 -14
@@ -1,18 +1,4 @@ -NETOBJS := start.o sclp.o cio.o virtio.o virtio-net.o jump2ipl.o netmain.o - -LIBNET_INC := -I$(SLOF_DIR)/lib/libnet - -NETLDFLAGS := $(LDFLAGS) -Wl,-Ttext=0x7800000 - -$(NETOBJS): EXTRA_CFLAGS += $(LIBC_INC) $(LIBNET_INC) - -s390-netboot.elf: $(NETOBJS) libnet.a libc.a - $(call quiet-command,$(CC) $(NETLDFLAGS) -o $@ $^,Linking) - -s390-netboot.img: s390-netboot.elf - $(call quiet-command,$(STRIP) --strip-unneeded $< -o $@,Stripping $< into) - # libc files: LIBC_CFLAGS = $(EXTRA_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \
pc-bios/s390-ccw/cio.h +2 -0
@@ -361,6 +361,8 @@ typedef struct CcwSearchIdData {uint8_t record; } __attribute__((packed)) CcwSearchIdData; +extern SubChannelId net_schid; +int enable_mss_facility (void );void enable_subchannel (SubChannelId schid);uint16_t cu_type (SubChannelId schid);
pc-bios/s390-ccw/iplb.h +2 -2
@@ -87,9 +87,9 @@ extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE)));struct QemuIplParameters {uint8_t qipl_flags;uint8_t reserved1[3 ]; -uint64_t netboot_start_addr; +uint64_t reserved2;uint32_t boot_menu_timeout; -uint8_t reserved2[12 ]; +uint8_t reserved3[12 ]; } __attribute__ ((packed));typedef struct QemuIplParameters QemuIplParameters ;
pc-bios/s390-ccw/s390-ccw.h +3 -0
@@ -55,6 +55,9 @@ void write_iplb_location(void);unsigned int get_loadparm_index (void );void main (void ); +/* netmain.c */ +void netmain (void ); +/* sclp.c */ void sclp_print (const char *string);void sclp_set_write_mask (uint32_t receive_mask,uint32_t send_mask);
pc-bios/s390-ccw/virtio.h +0 -1
@@ -253,7 +253,6 @@ struct VDev {uint8_t scsi_dev_heads;bool scsi_device_selected;ScsiDevice selected_scsi_device; -uint64_t netboot_start_addr;uint32_t max_transfer;uint32_t guest_features[2 ]; };
pc-bios/s390-ccw/bootmap.c +1 -1
@@ -929,7 +929,7 @@ void zipl_load(void) }if (virtio_get_device_type () ==VIRTIO_ID_NET ) { -jump_to_IPL_code (vdev->netboot_start_addr); +netmain (); }ipl_scsi ();
pc-bios/s390-ccw/main.c +7 -3
@@ -38,8 +38,13 @@ LowCore *lowcore; /* Yes, this *is* a pointer to address 0 */*/ void write_subsystem_identification (void ) { - lowcore->subchannel_id = blk_schid.sch_id; - lowcore->subchannel_nr = blk_schid.sch_no; +if (cutype ==CU_TYPE_VIRTIO &&virtio_get_device_type () ==VIRTIO_ID_NET ) { + lowcore->subchannel_id = net_schid.sch_id; + lowcore->subchannel_nr = net_schid.sch_no; + }else { + lowcore->subchannel_id = blk_schid.sch_id; + lowcore->subchannel_nr = blk_schid.sch_no; + } lowcore->io_int_parm =0 ; }
@@ -231,7 +236,6 @@ static int virtio_setup(void)switch (vdev->senseid.cu_model) {case VIRTIO_ID_NET :puts ("Network boot device detected" ); - vdev->netboot_start_addr = qipl.netboot_start_addr;return 0 ;case VIRTIO_ID_BLOCK : ret =virtio_blk_setup_device (blk_schid);
pc-bios/s390-ccw/netmain.c +2 -13
@@ -41,7 +41,6 @@#define DEFAULT_TFTP_RETRIES 20extern char _start[]; -void write_iplb_location (void ) {}#define KERNEL_ADDR ((void *)0L)#define KERNEL_MAX_SIZE ((long)_start)
@@ -50,10 +49,9 @@ void write_iplb_location(void) {}/* STSI 3.2.2 offset of first vmdb + offset of uuid inside vmdb */ #define STSI322_VMDB_UUID_OFFSET ((8 + 12) * 4) -IplParameterBlock iplb __attribute__((aligned(PAGE_SIZE)));static char cfgbuf[2048 ]; -static SubChannelId net_schid = { .one =1 }; +SubChannelId net_schid = { .one =1 };static uint8_t mac[6 ];static uint64_t dest_timer;
@@ -438,15 +436,6 @@ static int net_try_direct_tftp_load(filename_ip_t *fn_ip)return rc; } -void write_subsystem_identification (void ) -{ -SubChannelId *schid = (SubChannelId *)184 ; -uint32_t *zeroes = (uint32_t *)188 ; - - *schid = net_schid; - *zeroes =0 ; -} -static bool find_net_dev (Schib *schib,int dev_no) {int i, r;
@@ -509,7 +498,7 @@ static void virtio_setup(void)IPL_assert (found,"No virtio net device found" ); } -void main (void ) +void netmain (void ) {filename_ip_t fn_ip;int rc, fnlen;
pc-bios/s390-ccw/Makefile +7 -6
@@ -32,19 +32,20 @@ QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d .PHONY : all clean build-all distclean -OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ - virtio.o virtio-scsi.o virtio-blkdev.o cio.o dasd-ipl.o +OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o netmain.o \ + virtio.o virtio-net.o virtio-scsi.o virtio-blkdev.o cio.o dasd-ipl.o SLOF_DIR := $(SRC_PATH)/../../roms/SLOF LIBC_INC := -nostdinc -I$(SLOF_DIR)/lib/libc/include +LIBNET_INC := -I$(SLOF_DIR)/lib/libnet EXTRA_CFLAGS += -Wall EXTRA_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE EXTRA_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables EXTRA_CFLAGS += -msoft-float EXTRA_CFLAGS += -std=gnu99 -EXTRA_CFLAGS += $(LIBC_INC) +EXTRA_CFLAGS += $(LIBC_INC) $(LIBNET_INC) LDFLAGS += -Wl,-pie -nostdlib -z noexecstack cc-test = $(CC) -Werror $1 -c -o /dev/null -xc /dev/null >/dev/null 2>/dev/null
@@ -62,9 +63,9 @@ config-cc.mak: Makefile include $(SRC_PATH)/netboot.mak -build-all: s390-ccw.img s390-netboot.img +build-all: s390-ccw.img -s390-ccw.elf: $(OBJECTS) libc.a +s390-ccw.elf: $(OBJECTS) libnet.a libc.a $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^,Linking) s390-ccw.img: s390-ccw.elf
@@ -72,7 +73,7 @@ s390-ccw.img: s390-ccw.elf $(OBJECTS): Makefile -ALL_OBJS = $(sort $(OBJECTS) $(NETOBJS) $(LIBCOBJS) $(LIBNETOBJS)) +ALL_OBJS = $(sort $(OBJECTS) $(LIBCOBJS) $(LIBNETOBJS)) -include $(ALL_OBJS:%.o=%.d) clean:
Signature · 1 line
2.47.0
[PULL 05/23] pc-bios/s390-ccw: Merge netboot.mak into the main Makefile
In reply to Thomas HuthNow that the netboot code has been merged into the main s390-ccw.img, it also does not make sense to keep the build rules in a separate file. Thus let's merge netboot.mak into the main Makefile.
Message-Id: <[email protected]>
--- pc-bios/s390-ccw/netboot.mak | 45 ---------------------------------- pc-bios/s390-ccw/Makefile | 47 +++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 46 deletions(-) delete mode 100644 pc-bios/s390-ccw/netboot.mak
pc-bios/s390-ccw/netboot.mak deleted +0 -45
@@ -1,45 +0,0 @@ - -# libc files: - -LIBC_CFLAGS = $(EXTRA_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \ - -MMD -MP -MT $@ -MF $(@:%.o=%.d) - -CTYPE_OBJS = isdigit.o isxdigit.o toupper.o -%.o : $(SLOF_DIR)/lib/libc/ctype/%.c - $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,Compiling) - -STRING_OBJS = strcat.o strchr.o strrchr.o strcpy.o strlen.o strncpy.o \ - strcmp.o strncmp.o strcasecmp.o strncasecmp.o strstr.o \ - memset.o memcpy.o memmove.o memcmp.o -%.o : $(SLOF_DIR)/lib/libc/string/%.c - $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,Compiling) - -STDLIB_OBJS = atoi.o atol.o strtoul.o strtol.o rand.o malloc.o free.o -%.o : $(SLOF_DIR)/lib/libc/stdlib/%.c - $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,Compiling) - -STDIO_OBJS = sprintf.o snprintf.o vfprintf.o vsnprintf.o vsprintf.o fprintf.o \ - printf.o putc.o puts.o putchar.o stdchnls.o fileno.o -%.o : $(SLOF_DIR)/lib/libc/stdio/%.c - $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,Compiling) - -sbrk.o: $(SLOF_DIR)/slof/sbrk.c - $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,Compiling) - -LIBCOBJS := $(STRING_OBJS) $(CTYPE_OBJS) $(STDLIB_OBJS) $(STDIO_OBJS) sbrk.o - -libc.a: $(LIBCOBJS) - $(call quiet-command,$(AR) -rc $@ $^,Creating static library) - -# libnet files: - -LIBNETOBJS := args.o dhcp.o dns.o icmpv6.o ipv6.o tcp.o udp.o bootp.o \ - dhcpv6.o ethernet.o ipv4.o ndp.o tftp.o pxelinux.o -LIBNETCFLAGS = $(EXTRA_CFLAGS) $(CFLAGS) $(LIBC_INC) $(LIBNET_INC) \ - -DDHCPARCH=0x1F -MMD -MP -MT $@ -MF $(@:%.o=%.d) - -%.o : $(SLOF_DIR)/lib/libnet/%.c - $(call quiet-command,$(CC) $(LIBNETCFLAGS) -c -o $@ $<,Compiling) - -libnet.a: $(LIBNETOBJS) - $(call quiet-command,$(AR) -rc $@ $^,Creating static library)
pc-bios/s390-ccw/Makefile +46 -1
53 lines not on this page · raw message
Signature · 1 line
2.47.0
[PULL 06/23] docs/system/s390x/bootdevices: Update the documentation about network booting
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Remove the information about the separate s390-netboot.img from the documentation.
Co-authored by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
--- docs/system/s390x/bootdevices.rst | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
docs/system/s390x/bootdevices.rst +7 -13
@@ -82,23 +82,17 @@ Note that ``0`` can be used to boot the default entry. Booting from a network device ----------------------------- -Beside the normal guest firmware (which is loaded from the file ``s390-ccw.img`` -in the data directory of QEMU, or via the ``-bios`` option), QEMU ships with -a small TFTP network bootloader firmware for virtio-net-ccw devices, too. This -firmware is loaded from a file called ``s390-netboot.img`` in the QEMU data -directory. In case you want to load it from a different filename instead, -you can specify it via the ``-global s390-ipl.netboot_fw=filename`` -command line option. - -The ``bootindex`` property is especially important for booting via the network. -If you don't specify the ``bootindex`` property here, the network bootloader -firmware code won't get loaded into the guest memory so that the network boot -will fail. For a successful network boot, try something like this:: +The firmware that ships with QEMU includes a small TFTP network bootloader +for virtio-net-ccw devices. The ``bootindex`` property is especially +important for booting via the network. If you don't specify the ``bootindex`` +property here, the network bootloader won't be taken into consideration and +the network boot will fail. For a successful network boot, try something +like this:: qemu-system-s390x -netdev user,id=n1,tftp=...,bootfile=... \ -device virtio-net-ccw,netdev=n1,bootindex=1 -The network bootloader firmware also has basic support for pxelinux.cfg-style +The network bootloader also has basic support for pxelinux.cfg-style configuration files. See the `PXELINUX Configuration page <https://wiki.syslinux.org/wiki/index.php?title=PXELINUX#Configuration>`__ for details how to set up the configuration file on your TFTP server.
Signature · 1 line
2.47.0
[PULL 21/23] pc-bios/s390-ccw: Don't generate TEXTRELs
In reply to Thomas HuthFrom: Jens Remus <[email protected]>
Commit 7cd50cbe4ca3 ("pc-bios/s390-ccw: Don't use __bss_start with the "larl" instruction") introduced the address constant bss_start_literal for __bss_start in the .text section, which introduced a relocation in code (i.e. TEXTREL). The dedicated constant is required, as __bss_start may not necessarily be aligned on a 2-byte boundary (see subject commit for details).
Move the constant to the .data section to get rid of the relocation in the .text section. Add the linker option -z text to prevent TEXTRELs to get introduced in the future.
Note that the R_390_RELATIVE relocations are taken care of by function glue() in include/hw/elf_ops.h.inc introduced by commit 5dce07e1cb67 ("elf-loader: Provide the possibility to relocate s390 ELF files").
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/start.S | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-)
pc-bios/s390-ccw/Makefile +1 -1
@@ -46,7 +46,7 @@ EXTRA_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables EXTRA_CFLAGS += -msoft-float EXTRA_CFLAGS += -std=gnu99 EXTRA_CFLAGS += $(LIBC_INC) $(LIBNET_INC) -LDFLAGS += -Wl,-pie -nostdlib -z noexecstack +LDFLAGS += -Wl,-pie -nostdlib -z noexecstack -z text cc-test = $(CC) -Werror $1 -c -o /dev/null -xc /dev/null >/dev/null 2>/dev/null cc-option = if $(call cc-test, $1); then \
pc-bios/s390-ccw/start.S +5 -2
@@ -113,8 +113,6 @@ io_new_code: br %r14 .balign 8 -bss_start_literal: - .quad __bss_start disabled_wait_psw: .quad 0x0002000180000000,0x0000000000000000 enabled_wait_psw:
@@ -124,6 +122,11 @@ external_new_mask: io_new_mask: .quad 0x0000000180000000 +.data + .balign 8 +bss_start_literal: + .quad __bss_start + .bss .balign 8 stack:
Signature · 1 line
2.47.0
[PULL 04/23] hw/s390x: Remove the possibility to load the s390-netboot.img binary
In reply to Thomas HuthSince the netboot code has now been merged into the main s390-ccw.img binary, we don't need the separate s390-netboot.img anymore. Remove it and the code that was responsible for loading it.
Message-Id: <[email protected]>
--- hw/s390x/ipl.h | 12 +++----- hw/s390x/ipl.c | 55 ------------------------------------- hw/s390x/s390-virtio-ccw.c | 10 ++----- pc-bios/meson.build | 1 - pc-bios/s390-netboot.img | Bin 67232 -> 0 bytes 5 files changed, 6 insertions(+), 72 deletions(-) delete mode 100644 pc-bios/s390-netboot.img
hw/s390x/ipl.h +4 -8
@@ -134,11 +134,8 @@ void s390_ipl_clear_reset_request(void);/* * 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. +* double-word aligned. Placement of 64-bit data fields in this +* area must account for their alignment needs. * 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.
@@ -146,9 +143,9 @@ void s390_ipl_clear_reset_request(void);struct QemuIplParameters {uint8_t qipl_flags;uint8_t reserved1[3 ]; -uint64_t netboot_start_addr; +uint64_t reserved2;uint32_t boot_menu_timeout; -uint8_t reserved2[12 ]; +uint8_t reserved3[12 ]; }QEMU_PACKED ;typedef struct QemuIplParameters QemuIplParameters ;
@@ -178,7 +175,6 @@ struct S390IPLState {char *initrd;char *cmdline;char *firmware; -char *netboot_fw;uint8_t cssid;uint8_t ssid;uint16_t devno;
hw/s390x/ipl.c +0 -55
73 lines not on this page · raw message
hw/s390x/s390-virtio-ccw.c +2 -8
@@ -197,11 +197,10 @@ static void s390_memory_init(MemoryRegion *ram)static void s390_init_ipl_dev (const char *kernel_filename,const char *kernel_cmdline,const char *initrd_filename,const char *firmware, -const char *netboot_fw,bool enforce_bios) +bool enforce_bios) {Object *new =object_new (TYPE_S390_IPL );DeviceState *dev =DEVICE (new); -char *netboot_fw_prop;if (kernel_filename) {qdev_prop_set_string (dev,"kernel" , kernel_filename);
@@ -212,11 +211,6 @@ static void s390_init_ipl_dev(const char *kernel_filename,qdev_prop_set_string (dev,"cmdline" , kernel_cmdline);qdev_prop_set_string (dev,"firmware" , firmware);qdev_prop_set_bit (dev,"enforce_bios" , enforce_bios); - netboot_fw_prop =object_property_get_str (new,"netboot_fw" , &error_abort); -if (!strlen (netboot_fw_prop)) { -qdev_prop_set_string (dev,"netboot_fw" , netboot_fw); - } -g_free (netboot_fw_prop);object_property_add_child (qdev_get_machine (),TYPE_S390_IPL , new);object_unref (new);
@@ -284,7 +278,7 @@ static void ccw_init(MachineState *machine)s390_init_ipl_dev (machine->kernel_filename, machine->kernel_cmdline, machine->initrd_filename, machine->firmware ?:"s390-ccw.img" , -"s390-netboot.img" , true); + true); dev =qdev_new (TYPE_S390_PCI_HOST_BRIDGE ); object_property_add_child(qdev_get_machine(), TYPE_S390_PCI_HOST_BRIDGE,
pc-bios/meson.build +0 -1
@@ -68,7 +68,6 @@ blobs = [ 'kvmvapic.bin', 'pvh.bin', 's390-ccw.img', - 's390-netboot.img', 'slof.bin', 'skiboot.lid', 'palcode-clipper',
pc-bios/s390-netboot.img deleted binary +0 -0
Signature · 1 line
2.47.0
[PULL 11/23] pc-bios/s390-ccw: Remove panics from Netboot IPL path
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Remove panic-on-error from Netboot specific functions so that error recovery may be possible in the future.
Functions that would previously panic now provide a return code.
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/s390-ccw.h | 2 +- pc-bios/s390-ccw/bootmap.c | 1 + pc-bios/s390-ccw/netmain.c | 17 +++++++++++------ pc-bios/s390-ccw/virtio-net.c | 7 +++++-- 4 files changed, 18 insertions(+), 9 deletions(-)
pc-bios/s390-ccw/s390-ccw.h +1 -1
@@ -57,7 +57,7 @@ unsigned int get_loadparm_index(void);void main (void );/* netmain.c */ -void netmain (void ); +int netmain (void );/* sclp.c */ void sclp_print (const char *string);
pc-bios/s390-ccw/bootmap.c +1 -0
@@ -1072,6 +1072,7 @@ void zipl_load(void)if (virtio_get_device_type () ==VIRTIO_ID_NET ) {netmain (); +panic ("\n! Cannot IPL from this network !\n" ); }if (ipl_scsi ()) {
pc-bios/s390-ccw/netmain.c +11 -6
@@ -464,7 +464,7 @@ static bool find_net_dev(Schib *schib, int dev_no)return false; } -static void virtio_setup (void ) +static bool virtio_setup (void ) {Schib schib;int ssid;
@@ -495,10 +495,10 @@ static void virtio_setup(void) } } -IPL_assert (found,"No virtio net device found" ); +return found; } -void netmain (void ) +int netmain (void ) {filename_ip_t fn_ip;int rc, fnlen;
@@ -506,11 +506,15 @@ void netmain(void)sclp_setup ();puts ("Network boot starting..." ); -virtio_setup (); +if (!virtio_setup ()) { +puts ("No virtio net device found." ); +return -1 ; + } rc =net_init (&fn_ip);if (rc) { -panic ("Network initialization failed. Halting." ); +puts ("Network initialization failed." ); +return -1 ; } fnlen =strlen (fn_ip.filename);
@@ -528,5 +532,6 @@ void netmain(void)jump_to_low_kernel (); } -panic ("Failed to load OS from network." ); +puts ("Failed to load OS from network." ); +return -1 ; }
pc-bios/s390-ccw/virtio-net.c +5 -2
@@ -54,8 +54,11 @@ int virtio_net_init(void *mac_addr) vdev->guest_features[0 ] =VIRTIO_NET_F_MAC_BIT ;virtio_setup_ccw (vdev); -IPL_assert (vdev->guest_features[0 ] &VIRTIO_NET_F_MAC_BIT , -"virtio-net device does not support the MAC address feature" ); +if (!(vdev->guest_features[0 ] &VIRTIO_NET_F_MAC_BIT )) { +puts ("virtio-net device does not support the MAC address feature" ); +return -1 ; + } +memcpy (mac_addr, vdev->config.net.mac,ETH_ALEN );for (i =0 ; i <64 ; i++) {
Signature · 1 line
2.47.0
[PULL 13/23] include/hw/s390x: Add include files for common IPL structs
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Currently, structures 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.
Message-ID: <[email protected]>
--- hw/s390x/ipl.h | 104 +----------------------------- include/hw/s390x/ipl/qipl.h | 123 ++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/iplb.h | 84 ++---------------------- pc-bios/s390-ccw/Makefile | 2 +- 4 files changed, 130 insertions(+), 183 deletions(-) create mode 100644 include/hw/s390x/ipl/qipl.h
hw/s390x/ipl.h +1 -103
@@ -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);
@@ -131,24 +47,6 @@ void s390_ipl_clear_reset_request(void);#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 64-bit data fields in this -* area must account for their alignment needs. -* 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 reserved2; -uint32_t boot_menu_timeout; -uint8_t reserved3[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 +123 -0
123 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.47.0
[PULL 14/23] s390x: Add individual loadparm assignment to CCW device
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Add a loadparm property to the VirtioCcwDevice object so that different loadparms can be defined on a per-device basis for CCW 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.
It is invalid to assign a loadparm to a non-boot device.
Message-ID: <[email protected]>
--- hw/s390x/ccw-device.h | 2 ++ hw/s390x/ipl.h | 3 +- include/hw/s390x/ipl/qipl.h | 1 + hw/s390x/ccw-device.c | 46 +++++++++++++++++++++++++ hw/s390x/ipl.c | 68 ++++++++++++++++++++++--------------- hw/s390x/s390-virtio-ccw.c | 18 +--------- hw/s390x/sclp.c | 9 ++--- pc-bios/s390-ccw/main.c | 10 ++++-- 8 files changed, 102 insertions(+), 55 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_convert_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 );
include/hw/s390x/ipl/qipl.h +1 -0
@@ -18,6 +18,7 @@#define QIPL_ADDRESS 0xcc#define LOADPARM_LEN 8 +#define NO_LOADPARM "\0\0\0\0\0\0\0\0"/* * The QEMU IPL Parameters will be stored at absolute address
hw/s390x/ccw-device.c +46 -0
62 lines not on this page · raw message
hw/s390x/ipl.c +41 -27
112 lines not on this page · raw message
hw/s390x/s390-virtio-ccw.c +1 -17
@@ -722,28 +722,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 -7
@@ -110,7 +110,6 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)MachineState *machine =MACHINE (qdev_get_machine ());int cpu_count;int rnsize, rnmax; -IplParameterBlock *ipib =s390_ipl_get_iplb ();int required_len =SCCB_REQ_LEN (ReadInfo, machine->possible_cpus->len);int offset_cpu =s390_has_feat (S390_FEAT_EXTENDED_LENGTH_SCCB ) ? offsetof(ReadInfo, entries) :
@@ -171,12 +170,8 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->rnmax2 =cpu_to_be64 (rnmax); } -if (ipib && ipib->flags &DIAG308_FLAGS_LP_VALID ) { -memcpy (&read_info->loadparm, &ipib->loadparm, -sizeof (read_info->loadparm)); - }else { -s390_ipl_set_loadparm (read_info->loadparm); - } +s390_ipl_convert_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
@@ -183,8 +183,14 @@ static void css_setup(void)static void boot_setup (void ) {char lpmsg[] ="LOADPARM=[________]\n" ; + have_iplb =store_iplb (&iplb); + +if (memcmp (iplb.loadparm,NO_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 );puts (lpmsg);
@@ -193,8 +199,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 bool find_boot_device (void )
Signature · 1 line
2.47.0
[PULL 07/23] pc-bios/s390-ccw: Remove panics from ISO IPL path
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Remove panic-on-error from IPL ISO El Torito specific functions so that error recovery may be possible in the future.
Functions that would previously panic now provide a return code.
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/bootmap.h | 15 +++---- pc-bios/s390-ccw/s390-ccw.h | 1 + pc-bios/s390-ccw/bootmap.c | 87 ++++++++++++++++++++++++------------- 3 files changed, 65 insertions(+), 38 deletions(-)
pc-bios/s390-ccw/bootmap.h +6 -9
@@ -385,17 +385,14 @@ static inline uint32_t iso_733_to_u32(uint64_t x)#define ISO_PRIMARY_VD_SECTOR 16 -static inline void read_iso_sector (uint32_t block_offset,void *buf, -const char *errmsg) -{ -IPL_assert (virtio_read_many (block_offset, buf,1 ) ==0 , errmsg); -} - -static inline void read_iso_boot_image (uint32_t block_offset,void *load_addr, +static inline int read_iso_boot_image (uint32_t block_offset,void *load_addr,uint32_t blks_to_load) { -IPL_assert (virtio_read_many (block_offset, load_addr, blks_to_load) ==0 , -"Failed to read boot image!" ); +if (virtio_read_many (block_offset, load_addr, blks_to_load)) { +puts ("Failed to read boot image!" ); +return -1 ; + } +return 0 ; }#define ISO9660_MAX_DIR_DEPTH 8
pc-bios/s390-ccw/s390-ccw.h +1 -0
@@ -30,6 +30,7 @@ typedef unsigned long long u64;#define EIO 1#define EBUSY 2#define ENODEV 3 +#define EINVAL 4#ifndef MIN #define MIN (a, b) (((a) < (b)) ? (a) : (b))
pc-bios/s390-ccw/bootmap.c +58 -29
182 lines not on this page · raw message
Signature · 1 line
2.47.0
[PULL 09/23] pc-bios/s390-ccw: Remove panics from SCSI IPL path
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Remove panic-on-error from virtio-scsi IPL specific functions so that error recovery may be possible in the future.
Functions that would previously panic now provide a return code.
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/bootmap.c | 88 ++++++++++++++----- pc-bios/s390-ccw/virtio-blkdev.c | 4 +- pc-bios/s390-ccw/virtio-scsi.c | 143 +++++++++++++++++++++---------- 3 files changed, 164 insertions(+), 71 deletions(-)
pc-bios/s390-ccw/bootmap.c +66 -22
@@ -595,7 +595,7 @@ static int ipl_eckd(void)* IPL a SCSI disk */ -static void zipl_load_segment (ComponentEntry *entry) +static int zipl_load_segment (ComponentEntry *entry) {const int max_entries = (MAX_SECTOR_SIZE /sizeof (ScsiBlockPtr));ScsiBlockPtr *bprs = (void *)sec;
@@ -615,7 +615,10 @@ static void zipl_load_segment(ComponentEntry *entry) do { memset(bprs, FREE_SPACE_FILLER, bprs_size); fill_hex_val(blk_no, &blockno, sizeof(blockno)); - read_block(blockno, bprs, err_msg); + if (virtio_read(blockno, bprs)) { + puts(err_msg); + return -EIO; + } for (i = 0;; i++) { uint64_t *cur_desc = (void *)&bprs[i];
@@ -643,23 +646,37 @@ static void zipl_load_segment(ComponentEntry *entry) } address =virtio_load_direct (cur_desc[0 ], cur_desc[1 ],0 , (void *)address); -IPL_assert (address !=-1 ,"zIPL load segment failed" ); +if (!address) { +puts ("zIPL load segment failed" ); +return -EIO ; + } } }while (blockno); + +return 0 ; }/* Run a zipl program */ -static void zipl_run (ScsiBlockPtr *pte) +static int zipl_run (ScsiBlockPtr *pte) {ComponentHeader *header;ComponentEntry *entry;uint8_t tmp_sec[MAX_SECTOR_SIZE ]; -read_block (pte->blockno, tmp_sec,"Cannot read header" ); +if (virtio_read (pte->blockno, tmp_sec)) { +puts ("Cannot read header" ); +return -EIO ; + } header = (ComponentHeader *)tmp_sec; -IPL_assert (magic_match (tmp_sec,ZIPL_MAGIC ),"No zIPL magic in header" ); -IPL_assert (header->type ==ZIPL_COMP_HEADER_IPL ,"Bad header type" ); +if (!magic_match (tmp_sec,ZIPL_MAGIC )) { +puts ("No zIPL magic in header" ); +return -EINVAL ; + } +if (header->type !=ZIPL_COMP_HEADER_IPL ) { +puts ("Bad header type" ); +return -EINVAL ; + }dputs ("start loading images\n" );
@@ -674,22 +691,30 @@ static void zipl_run(ScsiBlockPtr *pte)continue ; } -zipl_load_segment (entry); +if (zipl_load_segment (entry)) { +return -1 ; + } entry++; -IPL_assert ((uint8_t *)(&entry[1 ]) <= (tmp_sec +MAX_SECTOR_SIZE ), -"Wrong entry value" ); +if ((uint8_t *)(&entry[1 ]) > (tmp_sec +MAX_SECTOR_SIZE )) { +puts ("Wrong entry value" ); +return -EINVAL ; + } } -IPL_assert (entry->component_type ==ZIPL_COMP_ENTRY_EXEC ,"No EXEC entry" ); +if (entry->component_type !=ZIPL_COMP_ENTRY_EXEC ) { +puts ("No EXEC entry" ); +return -EINVAL ; + }/* should not return */ write_reset_psw (entry->compdat.load_psw);jump_to_IPL_code (0 ); +return -1 ; } -static void ipl_scsi (void ) +static int ipl_scsi (void ) {ScsiMbr *mbr = (void *)sec;int program_table_entries =0 ;
@@ -700,10 +725,13 @@ static void ipl_scsi(void)/* Grab the MBR */ memset (sec,FREE_SPACE_FILLER ,sizeof (sec)); -read_block (0 , mbr,"Cannot read block 0" ); +if (virtio_read (0 , mbr)) { +puts ("Cannot read block 0" ); +return -EIO ; + }if (!magic_match (mbr->magic,ZIPL_MAGIC )) { -return ; +return 0 ; }puts ("Using SCSI scheme." );
@@ -711,11 +739,20 @@ static void ipl_scsi(void)IPL_check (mbr->version_id ==1 ,"Unknown MBR layout version, assuming version 1" );debug_print_int ("program table" , mbr->pt.blockno); -IPL_assert (mbr->pt.blockno,"No Program Table" ); +if (!mbr->pt.blockno) { +puts ("No Program Table" ); +return -EINVAL ; + }/* Parse the program table */ -read_block (mbr->pt.blockno, sec,"Error reading Program Table" ); -IPL_assert (magic_match (sec,ZIPL_MAGIC ),"No zIPL magic in PT" ); +if (virtio_read (mbr->pt.blockno, sec)) { +puts ("Error reading Program Table" ); +return -EIO ; + } +if (!magic_match (sec,ZIPL_MAGIC )) { +puts ("No zIPL magic in Program Table" ); +return -EINVAL ; + }for (i =0 ; i <MAX_BOOT_ENTRIES ; i++) {if (prog_table->entry[i].scsi.blockno) {
@@ -725,17 +762,22 @@ static void ipl_scsi(void) }debug_print_int ("program table entries" , program_table_entries); -IPL_assert (program_table_entries !=0 ,"Empty Program Table" ); +if (program_table_entries ==0 ) { +puts ("Empty Program Table" ); +return -EINVAL ; + }if (menu_is_enabled_enum ()) { loadparm =menu_get_enum_boot_index (valid_entries); }debug_print_int ("loadparm" , loadparm); -IPL_assert (loadparm <MAX_BOOT_ENTRIES ,"loadparm value greater than" -" maximum number of boot entries allowed" ); +if (loadparm >=MAX_BOOT_ENTRIES ) { +puts ("loadparm value greater than max number of boot entries allowed" ); +return -EINVAL ; + } -zipl_run (&prog_table->entry[loadparm].scsi);/* no return */ +return zipl_run (&prog_table->entry[loadparm].scsi); }/***********************************************************************
@@ -1032,7 +1074,9 @@ void zipl_load(void)netmain (); } -ipl_scsi (); +if (ipl_scsi ()) { +panic ("\n! Cannot IPL this SCSI device !\n" ); + }switch (virtio_get_device_type ()) {case VIRTIO_ID_BLOCK :
pc-bios/s390-ccw/virtio-blkdev.c +2 -2
@@ -73,13 +73,13 @@ unsigned long virtio_load_direct(unsigned long rec_list1, unsigned long rec_listunsigned long addr = (unsigned long )load_addr;if (sec_len !=virtio_get_block_size ()) { -return -1 ; +return 0 ; }printf ("." ); status =virtio_read_many (sec, (void *)addr, sec_num);if (status) { -panic ("I/O Error" ); +return 0 ; } addr += sec_num *virtio_get_block_size ();
pc-bios/s390-ccw/virtio-scsi.c +96 -47
296 lines not on this page · raw message
Signature · 1 line
2.47.0
[PULL 10/23] pc-bios/s390-ccw: Remove panics from DASD IPL path
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Remove panic-on-error from DASD IPL specific functions so that error recovery may be possible in the future.
Functions that would previously panic now provide a return code.
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/dasd-ipl.h | 2 +- pc-bios/s390-ccw/dasd-ipl.c | 66 ++++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 31 deletions(-)
pc-bios/s390-ccw/dasd-ipl.h +1 -1
@@ -11,6 +11,6 @@#ifndef DASD_IPL_H #define DASD_IPL_H -void dasd_ipl (SubChannelId schid,uint16_t cutype); +int dasd_ipl (SubChannelId schid,uint16_t cutype);#endif /* DASD_IPL_H */
pc-bios/s390-ccw/dasd-ipl.c +36 -30
126 lines not on this page · raw message
Signature · 1 line
2.47.0
[PULL 20/23] pc-bios/s390-ccw: Clarify alignment is in bytes
In reply to Thomas HuthFrom: Jens Remus <[email protected]>
The assembler directive .align [1] has architecture-dependent behavior, which may be ambiguous for the reader. Some architectures perform the alignment in bytes, others in power of two. s390 does in bytes.
Use the directive .balign [2] instead, to clarify that the alignment request is in bytes. No functional change.
[1] https://sourceware.org/binutils/docs/as/Align.html
[2] https://sourceware.org/binutils/docs/as/Balign.html
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/start.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
pc-bios/s390-ccw/start.S +2 -2
@@ -112,7 +112,7 @@ io_new_code: lctlg %c6,%c6,0(%r15) br %r14 - .align 8 + .balign 8 bss_start_literal: .quad __bss_start disabled_wait_psw:
@@ -125,7 +125,7 @@ io_new_mask: .quad 0x0000000180000000 .bss - .align 8 + .balign 8 stack: .space STACK_SIZE .size stack,STACK_SIZE
Signature · 1 line
2.47.0
[PULL 02/23] pc-bios/s390-ccw: Use the libc from SLOF and remove sclp prints
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
We are already using the libc from SLOF for the s390-netboot.img, and this libc implementation is way more complete and accurate than the simple implementation that we currently use for the s390-ccw.img binary. Since we are now always assuming that the SLOF submodule is available when building the s390-ccw bios (see commit bf6903f6944f), we can drop the simple implementation and use the SLOF libc for the s390-ccw.img binary, too.
Additionally replace sclp_print calls with puts/printf now that it is available.
Co-authored by: Thomas Huth <[email protected]>
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/netboot.mak | 3 - pc-bios/s390-ccw/bootmap.h | 4 +- pc-bios/s390-ccw/libc.h | 89 ------------------------- pc-bios/s390-ccw/s390-ccw.h | 30 +++------ pc-bios/s390-ccw/bootmap.c | 47 ++++++------- pc-bios/s390-ccw/cio.c | 78 ++++++++++------------ pc-bios/s390-ccw/dasd-ipl.c | 5 +- pc-bios/s390-ccw/jump2ipl.c | 5 +- pc-bios/s390-ccw/libc.c | 88 ------------------------ pc-bios/s390-ccw/main.c | 14 ++-- pc-bios/s390-ccw/menu.c | 51 +++++++------- pc-bios/s390-ccw/netmain.c | 10 +-- pc-bios/s390-ccw/sclp.c | 7 +- pc-bios/s390-ccw/virtio-blkdev.c | 6 +- pc-bios/s390-ccw/virtio-scsi.c | 17 ++--- pc-bios/s390-ccw/virtio.c | 2 +- tests/tcg/s390x/console.c | 3 + pc-bios/s390-ccw/Makefile | 15 +++-- tests/tcg/s390x/Makefile.softmmu-target | 2 +- 19 files changed, 140 insertions(+), 336 deletions(-) delete mode 100644 pc-bios/s390-ccw/libc.h delete mode 100644 pc-bios/s390-ccw/libc.c
pc-bios/s390-ccw/netboot.mak +0 -3
@@ -1,9 +1,6 @@ -SLOF_DIR := $(SRC_PATH)/../../roms/SLOF - NETOBJS := start.o sclp.o cio.o virtio.o virtio-net.o jump2ipl.o netmain.o -LIBC_INC := -nostdinc -I$(SLOF_DIR)/lib/libc/include LIBNET_INC := -I$(SLOF_DIR)/lib/libnet NETLDFLAGS := $(LDFLAGS) -Wl,-Ttext=0x7800000
pc-bios/s390-ccw/bootmap.h +1 -3
@@ -336,9 +336,7 @@ static inline void print_volser(const void *volser)ebcdic_to_ascii ((char *)volser, ascii,6 ); ascii[6 ] ='\0' ; -sclp_print ("VOLSER=[" ); -sclp_print (ascii); -sclp_print ("]\n" ); +printf ("VOLSER=[%s]\n" , ascii); }static inline bool unused_space (const void *p,size_t size)
pc-bios/s390-ccw/libc.h deleted +0 -89
89 lines not on this page · raw message
pc-bios/s390-ccw/s390-ccw.h +9 -21
@@ -13,6 +13,11 @@/* #define DEBUG */ +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> +typedef unsigned char u8 ;typedef unsigned short u16 ;typedef unsigned int u32 ;
@@ -26,9 +31,6 @@ typedef unsigned long long u64;#define EBUSY 2#define ENODEV 3 -#ifndef NULL -#define NULL 0 -#endif #ifndef MIN #define MIN (a, b) (((a) < (b)) ? (a) : (b))#endif
@@ -87,7 +89,7 @@ bool menu_is_enabled_enum(void); __attribute__ ((__noreturn__))static inline void panic (const char *string) { -sclp_print (string); +printf ("ERROR: %s\n " , string);disabled_wait (); }
@@ -109,20 +111,10 @@ static inline void fill_hex_val(char *out, void *ptr, unsigned size) } } -static inline void print_int (const char *desc,u64 addr) -{ -char out[] =": 0xffffffffffffffff\n" ; - -fill_hex_val (&out[4 ], &addr,sizeof (addr)); - -sclp_print (desc); -sclp_print (out); -} -static inline void debug_print_int (const char *desc,u64 addr) {#ifdef DEBUG -print_int (desc, addr); +printf ("%s 0x%X\n" , desc, addr);#endif }
@@ -147,18 +139,14 @@ static inline void debug_print_addr(const char *desc, void *p)static inline void IPL_assert (bool term,const char *message) {if (!term) { -sclp_print ("\n! " ); -sclp_print (message); -panic (" !\n" );/* no return */ +panic (message);/* no return */ } }static inline void IPL_check (bool term,const char *message) {if (!term) { -sclp_print ("\n! WARNING: " ); -sclp_print (message); -sclp_print (" !\n" ); +printf ("WARNING: %s\n" , message); } }
pc-bios/s390-ccw/bootmap.c +24 -23
160 lines not on this page · raw message
pc-bios/s390-ccw/cio.c +36 -42
152 lines not on this page · raw message
pc-bios/s390-ccw/dasd-ipl.c +3 -2
@@ -8,7 +8,8 @@* directory. */ -#include "libc.h" +#include <string.h> +#include <stdio.h> #include "s390-ccw.h" #include "s390-arch.h" #include "dasd-ipl.h"
@@ -82,7 +83,7 @@ static int run_dynamic_ccw_program(SubChannelId schid, uint16_t cutype, do { has_next = dynamic_cp_fixup(cpa, &next_cpa); - print_int("executing ccw chain at ", cpa); + printf("executing ccw chain at 0x%X\n", cpa); enable_prefixing(); rc = do_cio(schid, cutype, cpa, CCW_FMT0); disable_prefixing();
pc-bios/s390-ccw/jump2ipl.c +3 -2
@@ -6,7 +6,8 @@* directory. */ -#include "libc.h" +#include <string.h> +#include <stdio.h> #include "s390-ccw.h" #include "s390-arch.h"
@@ -57,7 +58,7 @@ void jump_to_IPL_code(uint64_t address)debug_print_int ("set IPL addr to" , address ?: *reset_psw &PSW_MASK_SHORT_ADDR );/* Ensure the guest output starts fresh */ -sclp_print ("\n" ); +printf ("\n" );/* * HACK ALERT.
pc-bios/s390-ccw/libc.c deleted +0 -88
88 lines not on this page · raw message
pc-bios/s390-ccw/main.c +8 -6
@@ -8,7 +8,9 @@* directory. */ -#include "libc.h" +#include <stdlib.h> +#include <string.h> +#include <stdio.h> #include "helper.h" #include "s390-arch.h" #include "s390-ccw.h"
@@ -50,7 +52,7 @@ void write_iplb_location(void)unsigned int get_loadparm_index (void ) { -return atoui (loadparm_str); +return atoi (loadparm_str); }static int is_dev_possibly_bootable (int dev_no,int sch_no)
@@ -176,7 +178,7 @@ static void boot_setup(void)sclp_get_loadparm_ascii (loadparm_str);memcpy (lpmsg +10 , loadparm_str,8 ); -sclp_print (lpmsg); +puts (lpmsg);/* * Clear out any potential S390EP magic (see jump_to_low_kernel()),
@@ -228,7 +230,7 @@ static int virtio_setup(void)switch (vdev->senseid.cu_model) {case VIRTIO_ID_NET : -sclp_print ("Network boot device detected\n" ); +puts ("Network boot device detected" ); vdev->netboot_start_addr = qipl.netboot_start_addr;return 0 ;case VIRTIO_ID_BLOCK :
@@ -261,7 +263,7 @@ static void ipl_boot_device(void) }break ;default : -print_int ("Attempting to boot from unexpected device type" , cutype); +printf ("Attempting to boot from unexpected device type 0x%X\n" , cutype);panic ("\nBoot failed.\n" ); } }
@@ -287,7 +289,7 @@ static void probe_boot_device(void) } } -sclp_print ("Could not find a suitable boot device (none specified)\n" ); +puts ("Could not find a suitable boot device (none specified)" ); }void main (void )
pc-bios/s390-ccw/menu.c +23 -28
134 lines not on this page · raw message
pc-bios/s390-ccw/netmain.c +5 -5
@@ -293,7 +293,7 @@ static int load_kernel_with_initrd(filename_ip_t *fn_ip,printf ("Loading pxelinux.cfg entry '%s'\n" , entry->label);if (!entry->kernel) { -printf ("Kernel entry is missing!\n" ); +puts ("Kernel entry is missing!\n" );return -1 ; }
@@ -515,13 +515,13 @@ void main(void)int rc, fnlen;sclp_setup (); -sclp_print ("Network boot starting...\n" ); +puts ("Network boot starting..." );virtio_setup (); rc =net_init (&fn_ip);if (rc) { -panic ("Network initialization failed. Halting.\n" ); +panic ("Network initialization failed. Halting." ); } fnlen =strlen (fn_ip.filename);
@@ -535,9 +535,9 @@ void main(void)net_release (&fn_ip);if (rc >0 ) { -sclp_print ("Network loading done, starting kernel...\n" ); +puts ("Network loading done, starting kernel..." );jump_to_low_kernel (); } -panic ("Failed to load OS from network\n" ); +panic ("Failed to load OS from network." ); }
pc-bios/s390-ccw/sclp.c +1 -6
@@ -8,7 +8,7 @@* directory. */ -#include "libc.h" +#include <string.h> #include "s390-ccw.h" #include "sclp.h"
@@ -101,11 +101,6 @@ long write(int fd, const void *str, size_t len)return len; } -void sclp_print (const char *str) -{ -write (1 , str,strlen (str)); -} -void sclp_get_loadparm_ascii (char *loadparm) {
pc-bios/s390-ccw/virtio-blkdev.c +3 -3
@@ -8,7 +8,7 @@* directory. */ -#include "libc.h" +#include <stdio.h> #include "s390-ccw.h" #include "virtio.h" #include "virtio-scsi.h"
@@ -76,7 +76,7 @@ unsigned long virtio_load_direct(unsigned long rec_list1, unsigned long rec_listreturn -1 ; } -sclp_print ("." ); +printf ("." ); status =virtio_read_many (sec, (void *)addr, sec_num);if (status) {panic ("I/O Error" );
@@ -230,7 +230,7 @@ int virtio_blk_setup_device(SubChannelId schid) vdev->schid = schid;virtio_setup_ccw (vdev); -sclp_print ("Using virtio-blk.\n" ); +puts ("Using virtio-blk." );return 0 ; }
pc-bios/s390-ccw/virtio-scsi.c +9 -8
@@ -9,7 +9,8 @@* directory. */ -#include "libc.h" +#include <string.h> +#include <stdio.h> #include "s390-ccw.h" #include "virtio.h" #include "scsi.h"
@@ -30,9 +31,9 @@ static inline void vs_assert(bool term, const char **msgs)if (!term) {int i =0 ; -sclp_print ("\n! " ); +printf ("\n! " );while (msgs[i]) { -sclp_print (msgs[i++]); +printf ("%s" , msgs[i++]); }panic (" !\n" ); }
@@ -236,11 +237,11 @@ static int virtio_scsi_locate_device(VDev *vdev)if (resp.response ==VIRTIO_SCSI_S_BAD_TARGET ) {continue ; } -print_int ("target" , target); +printf ("target 0x%X\n" , target);virtio_scsi_verify_response (&resp,"SCSI cannot report LUNs" ); }if (r->lun_list_len ==0 ) { -print_int ("no LUNs for target" , target); +printf ("no LUNs for target 0x%X\n" , target);continue ; } luns = r->lun_list_len /8 ;
@@ -264,7 +265,7 @@ static int virtio_scsi_locate_device(VDev *vdev) } } -sclp_print ("Warning: Could not locate a usable virtio-scsi device\n" ); +puts ("Warning: Could not locate a usable virtio-scsi device" );return -ENODEV ; }
@@ -379,7 +380,7 @@ static int virtio_scsi_setup(VDev *vdev) }if (virtio_scsi_inquiry_response_is_cdrom (scsi_inquiry_std_response)) { -sclp_print ("SCSI CD-ROM detected.\n" ); +puts ("SCSI CD-ROM detected." ); vdev->is_cdrom = true; vdev->scsi_block_size =VIRTIO_ISO_BLOCK_SIZE ; }
@@ -443,7 +444,7 @@ int virtio_scsi_setup_device(SubChannelId schid)IPL_assert (vdev->config.scsi.cdb_size ==VIRTIO_SCSI_CDB_SIZE ,"Config: CDB size mismatch" ); -sclp_print ("Using virtio-scsi.\n" ); +puts ("Using virtio-scsi." );return virtio_scsi_setup (vdev); }
pc-bios/s390-ccw/virtio.c +1 -1
@@ -8,7 +8,7 @@* directory. */ -#include "libc.h" +#include <string.h> #include "s390-ccw.h" #include "cio.h" #include "virtio.h"
tests/tcg/s390x/console.c +3 -0
@@ -4,7 +4,10 @@* * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "../../../pc-bios/s390-ccw/sclp.c" +#include "../../../roms/SLOF/lib/libc/string/memset.c" +#include "../../../roms/SLOF/lib/libc/string/memcpy.c" void __sys_outc (char c) {
pc-bios/s390-ccw/Makefile +10 -5
@@ -33,13 +33,18 @@ QEMU_DGFLAGS = -MMD -MP -MT $@ -MF $(@D)/$(*F).d .PHONY : all clean build-all distclean OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ - virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o + virtio.o virtio-scsi.o virtio-blkdev.o cio.o dasd-ipl.o + +SLOF_DIR := $(SRC_PATH)/../../roms/SLOF + +LIBC_INC := -nostdinc -I$(SLOF_DIR)/lib/libc/include EXTRA_CFLAGS += -Wall EXTRA_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE EXTRA_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables EXTRA_CFLAGS += -msoft-float EXTRA_CFLAGS += -std=gnu99 +EXTRA_CFLAGS += $(LIBC_INC) LDFLAGS += -Wl,-pie -nostdlib -z noexecstack cc-test = $(CC) -Werror $1 -c -o /dev/null -xc /dev/null >/dev/null 2>/dev/null
@@ -55,18 +60,18 @@ config-cc.mak: Makefile $(call cc-option,-march=z900,-march=z10)) 3> config-cc.mak -include config-cc.mak +include $(SRC_PATH)/netboot.mak + build-all: s390-ccw.img s390-netboot.img -s390-ccw.elf: $(OBJECTS) - $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(OBJECTS),Linking) +s390-ccw.elf: $(OBJECTS) libc.a + $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^,Linking) s390-ccw.img: s390-ccw.elf $(call quiet-command,$(STRIP) --strip-unneeded $< -o $@,Stripping $< into) $(OBJECTS): Makefile -include $(SRC_PATH)/netboot.mak - ALL_OBJS = $(sort $(OBJECTS) $(NETOBJS) $(LIBCOBJS) $(LIBNETOBJS)) -include $(ALL_OBJS:%.o=%.d)
tests/tcg/s390x/Makefile.softmmu-target +1 -1
@@ -3,7 +3,7 @@ VPATH+=$(S390X_SRC) # EXTFLAGS can be passed by the user, e.g. to override the --accel QEMU_OPTS+=-action panic=exit-failure -nographic -serial chardev:output $(EXTFLAGS) -kernel LINK_SCRIPT=$(S390X_SRC)/softmmu.ld -CFLAGS+=-ggdb -O0 +CFLAGS+=-ggdb -O0 -I$(SRC_PATH)/include/hw/s390x/ipl/ LDFLAGS=-nostdlib -static %.o: %.S
Signature · 1 line
2.47.0
[PULL 17/23] pc-bios/s390x: Enable multi-device boot loop
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Allow attempts to boot from multiple IPL devices. If the first device fails to IPL, select the pre-built IPLB for the next device in the boot order and attempt to IPL from it. Continue this process until IPL is successful or there are no devices left to try.
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/iplb.h | 24 ++++++++++++++++++++ pc-bios/s390-ccw/jump2ipl.c | 7 +++--- pc-bios/s390-ccw/main.c | 45 +++++++++++++++++++++++-------------- pc-bios/s390-ccw/netmain.c | 2 +- 4 files changed, 57 insertions(+), 21 deletions(-)
pc-bios/s390-ccw/iplb.h +24 -0
@@ -17,9 +17,11 @@#endif #include <qipl.h> +#include <string.h> extern QemuIplParameters qipl; extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE))); +extern bool have_iplb;#define S390_IPL_TYPE_FCP 0x00#define S390_IPL_TYPE_CCW 0x02
@@ -49,4 +51,26 @@ 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. +*/ +static inline bool load_next_iplb (void ) +{ +IplParameterBlock *next_iplb; + +if (qipl.chain_len <1 ) { +return false; + } + + qipl.index++; + next_iplb = (IplParameterBlock *) qipl.next_iplb; +memcpy (&iplb, next_iplb,sizeof (IplParameterBlock)); + + qipl.chain_len--; + qipl.next_iplb = qipl.next_iplb +sizeof (IplParameterBlock); + +return true; +} +#endif /* IPLB_H */
pc-bios/s390-ccw/jump2ipl.c +4 -3
@@ -45,9 +45,10 @@ int jump_to_IPL_code(uint64_t address)*/ if (iplb.pbt ==S390_IPL_TYPE_QEMU_SCSI ) { iplb.devno = qipl.index; -if (!set_iplb (&iplb)) { -panic ("Failed to set IPLB" ); - } + } + +if (have_iplb && !set_iplb (&iplb)) { +panic ("Failed to set IPLB" ); }/*
pc-bios/s390-ccw/main.c +28 -17
105 lines not on this page · raw message
pc-bios/s390-ccw/netmain.c +1 -1
@@ -478,7 +478,7 @@ static bool virtio_setup(void)*/ enable_mss_facility (); -if (store_iplb (&iplb)) { +if (have_iplb ||store_iplb (&iplb)) {IPL_assert (iplb.pbt ==S390_IPL_TYPE_CCW ,"IPL_TYPE_CCW expected" ); dev_no = iplb.ccw.devno;debug_print_int ("device no. " , dev_no);
Signature · 1 line
2.47.0
[PULL 22/23] pc-bios/s390-ccw: Introduce `EXTRA_LDFLAGS`
In reply to Thomas HuthFrom: Marc Hartmayer <[email protected]>
Some packaging tools want to override LDFLAGS when building QEMU, this will result in a build error as most likely no -nostdlib flag is passed. Introduce EXTRA_LDFLAGS so that the packager can override LDFLAGS without breaking the build.
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
pc-bios/s390-ccw/Makefile +3 -2
@@ -4,6 +4,7 @@ all: build-all include config-host.mak CFLAGS = -O2 -g -I $(SRC_PATH)/../../include/hw/s390x/ipl +LDFLAGS ?= MAKEFLAGS += -rR GIT_SUBMODULES = roms/SLOF
@@ -46,7 +47,7 @@ EXTRA_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables EXTRA_CFLAGS += -msoft-float EXTRA_CFLAGS += -std=gnu99 EXTRA_CFLAGS += $(LIBC_INC) $(LIBNET_INC) -LDFLAGS += -Wl,-pie -nostdlib -z noexecstack -z text +EXTRA_LDFLAGS += -Wl,-pie -nostdlib -z noexecstack -z text cc-test = $(CC) -Werror $1 -c -o /dev/null -xc /dev/null >/dev/null 2>/dev/null cc-option = if $(call cc-test, $1); then \
@@ -111,7 +112,7 @@ libnet.a: $(LIBNETOBJS) build-all: s390-ccw.img s390-ccw.elf: $(OBJECTS) libnet.a libc.a - $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^,Linking) + $(call quiet-command,$(CC) $(EXTRA_LDFLAGS) $(LDFLAGS) -o $@ $^,Linking) s390-ccw.img: s390-ccw.elf $(call quiet-command,$(STRIP) --strip-unneeded $< -o $@,Stripping $< into)
Signature · 1 line
2.47.0
[PULL 23/23] pc-bios/s390-ccw: Update s390-ccw.img with the full boot order support feature
In reply to Thomas HuthThis update includes the full boot order support feature from Jared Rossi and the TEXTREL fix from Jens Remus.
--- pc-bios/s390-ccw.img | Bin 42608 -> 79608 bytes 1 file changed, 0 insertions(+), 0 deletions(-)
pc-bios/s390-ccw.img binary +0 -0
Signature · 1 line
2.47.0
[PULL 08/23] pc-bios/s390-ccw: Remove panics from ECKD IPL path
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Remove panic-on-error from ECKD block device IPL specific functions so that error recovery may be possible in the future.
Functions that would previously panic now provide a return code.
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/bootmap.h | 1 + pc-bios/s390-ccw/bootmap.c | 187 +++++++++++++++++++++++++------------ 2 files changed, 130 insertions(+), 58 deletions(-)
pc-bios/s390-ccw/bootmap.h +1 -0
@@ -16,6 +16,7 @@typedef uint64_t block_number_t ;#define NULL_BLOCK_NR 0xffffffffffffffffULL +#define ERROR_BLOCK_NR 0xfffffffffffffffeULL#define FREE_SPACE_FILLER '\xAA'
pc-bios/s390-ccw/bootmap.c +129 -58
403 lines not on this page · raw message
Signature · 1 line
2.47.0
[PULL 19/23] tests/qtest: Add s390x boot order tests to cdrom-test.c
In reply to Thomas HuthFrom: Jared Rossi <[email protected]>
Add two new qtests to verify that a valid IPL device can successfully boot after failed IPL attempts from one or more invalid devices.
cdrom-test/as-fallback-device: Defines the primary boot target as a device that is invalid for IPL and a second boot target that is valid for IPL. Ensures that the valid device will be selected after the initial failed IPL.
cdrom-test/as-last-option: Defines the maximum number of boot devices (8) where only the final entry in the boot order is valid. Ensures that a valid device will be selected even after multiple failed IPL attempts from both virtio-blk and virtio-scsi device types.
Message-ID: <[email protected]>
--- tests/qtest/cdrom-test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
tests/qtest/cdrom-test.c +24 -0
@@ -213,6 +213,30 @@ static void add_s390x_tests(void)"-drive driver=null-co,read-zeroes=on,if=none,id=d1 " "-device virtio-blk,drive=d2,bootindex=1 " "-drive if=none,id=d2,media=cdrom,file=", test_cdboot); +qtest_add_data_func ("cdrom/boot/as-fallback-device" , +"-device virtio-serial -device virtio-scsi " +"-device virtio-blk,drive=d1,bootindex=1 " +"-drive driver=null-co,read-zeroes=on,if=none,id=d1 " +"-device virtio-blk,drive=d2,bootindex=2 " +"-drive if=none,id=d2,media=cdrom,file=" , test_cdboot); +qtest_add_data_func ("cdrom/boot/as-last-option" , +"-device virtio-serial -device virtio-scsi " +"-device virtio-blk,drive=d1,bootindex=1 " +"-drive driver=null-co,read-zeroes=on,if=none,id=d1 " +"-device virtio-blk,drive=d2,bootindex=2 " +"-drive driver=null-co,read-zeroes=on,if=none,id=d2 " +"-device virtio-blk,drive=d3,bootindex=3 " +"-drive driver=null-co,read-zeroes=on,if=none,id=d3 " +"-device scsi-hd,drive=d4,bootindex=4 " +"-drive driver=null-co,read-zeroes=on,if=none,id=d4 " +"-device scsi-hd,drive=d5,bootindex=5 " +"-drive driver=null-co,read-zeroes=on,if=none,id=d5 " +"-device virtio-blk,drive=d6,bootindex=6 " +"-drive driver=null-co,read-zeroes=on,if=none,id=d6 " +"-device scsi-hd,drive=d7,bootindex=7 " +"-drive driver=null-co,read-zeroes=on,if=none,id=d7 " +"-device scsi-cd,drive=d8,bootindex=8 " +"-drive if=none,id=d8,media=cdrom,file=" , test_cdboot);if (qtest_has_device ("x-terminal3270" )) {qtest_add_data_func ("cdrom/boot/without-bootindex" , "-device virtio-scsi -device virtio-serial "
Signature · 1 line
2.47.0
Peter Maydell
AppliedQuoted 9 lines · Thomas Huth
The following changes since commit
6f625ce2f21d6a1243065d236298277c56f972d5:Merge tag 'pull-request-2024-10-21' of https://gitlab.com/thuth/qemu into staging (2024-10-21 17:12:59 +0100)
are available in the Git repository at:
https://gitlab.com/thuth/qemu.git tags/pull-request-2024-10-23
Quoted 8 lines
for you to fetch changes up to
239e351ec415ff3673d9da70d70ca3a5dd95a2f0:pc-bios/s390-ccw: Update s390-ccw.img with the full boot order support feature (2024-10-23 06:53:44 +0200)
----------------------------------------------------------------
* Allow multiple boot devices (via bootindex properties) on s390x
* Avoid TEXTREL relocations in the s390-ccw.img firmware
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/9.2
for any user-visible changes.
-- PMM