s390x: Add Full Boot Order Support
v5 cover s390x: Add Full Boot Order Support
From: Jared Rossi <[email protected]>
changes v4 -> v5:
- Fix a bug with per-deice loadparm support:
The machine loadparm is no longer overwritten by device values, which now allows an empty machine loadparm to propagate to later devices even if the primary boot device set an initial loadparm
- Fix two instances where changes were squashed into wrong patch
- Fix an instance where NULL_BLOCK_NR was returned instead of ERROR_BLOCK_NR
- Fix an instance of logical AND being used instead of bitwise AND
- Standardize all error values to be negative in all device type paths
- Minor stylistic changes and code simplification
changes v3 -> v4:
- Ensure signed-ness of return values is appropriate
- Add missing newline character in replacements of sclp_print_int()
- Add a missing return in a SCSI error path
- Restore break that was incorrectly removed for Virtio CU devices
- Remove an extra/early return that caused probing to end early
- Convert "good" device to scsi-cd in a cdrom-test for better coverage
- Minor stylistic clean-ups and variable name clarifications
Jared Rossi (19):
hw/s390x/ipl: Provide more memory to the s390-ccw.img firmware 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
hw/s390x: Remove the possibility to load the s390-netboot.img binary pc-bios/s390-ccw: Merge netboot.mak into the main Makefile 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
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 ++ pc-bios/meson.build | 1 - pc-bios/s390-ccw/Makefile | 69 ++++- pc-bios/s390-netboot.img | Bin 67232 -> 0 bytes 35 files changed, 1158 insertions(+), 1076 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
Signature · 1 line
2.45.1
PATCH v5 1/19 hw/s390x/ipl: Provide more memory to the s390-ccw.img firmware
From: Jared Rossi <[email protected]>
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.
Co-authored by: Thomas Huth <[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.45.1
PATCH v5 2/19 pc-bios/s390-ccw: Use the libc from SLOF and remove sclp prints
In reply to [email protected]From: 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 avaliable.
Co-authored by: Thomas Huth <[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 +- pc-bios/s390-ccw/Makefile | 15 ++++-- 17 files changed, 136 insertions(+), 335 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"
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)
Signature · 1 line
2.45.1
Re: [PATCH v5 02/19] pc-bios/s390-ccw: Use the libc from SLOF and remove sclp prints
Quoted 10 lines · On 20/10/2024 03.29, [email protected] wrote:
From: 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.
Quoted 8 lines
Additionally replace
sclp_printcalls with puts/printf now that it is avaliable.Co-authored by: Thomas Huth <[email protected]>
Signed-off-by Jared Rossi <[email protected]>--- pc-bios/s390-ccw/netboot.mak | 3 -- pc-bios/s390-ccw/bootmap.h | 4 +- pc-bios/s390-ccw/libc.h | 89 --------------------------------
I just had to discover that the removal of the old libc breaks "make check-tcg" since it uses the sclp.c from the firmware for printing.
I'll squash this patch to fix it:
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) {
tests/tcg/s390x/Makefile.softmmu-target +0 -0
@@ -3,7 +3,9 @@ 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)/roms/SLOF/lib/libc/include/ \
+ -I$(SRC_PATH)/include/hw/s390x/ipl/
LDFLAGS=-nostdlib -static
%.o: %.S
Thomas
Re: [PATCH v5 02/19] pc-bios/s390-ccw: Use the libc from SLOF and remove sclp prints
Quoted 45 lines · Thomas Huth
Quoted 10 lines · On 20/10/2024 03.29, [email protected] wrote:
From: 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.Quoted 8 lines
Additionally replace
sclp_printcalls with puts/printf now that it is avaliable.Co-authored by: Thomas Huth <[email protected]>
Signed-off-by Jared Rossi <[email protected]>---
pc-bios/s390-ccw/netboot.mak | 3 -- pc-bios/s390-ccw/bootmap.h | 4 +- pc-bios/s390-ccw/libc.h | 89 --------------------------------I just had to discover that the removal of the old libc breaks "make check-tcg" since it uses the
sclp.cfrom the firmware for printing.I'll squash this patch to fix it:
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) {tests/tcg/s390x/Makefile.softmmu-target +0
-0@@ -3,7 +3,9 @@ VPATH+=$(S390X_SRC) # EXTFLAGS can be passed by the user, e.g. to override the --accelQEMU_OPTS+=-action panic=exit-failure -nographic -serial chardev:output $(EXTFLAGS) -kernel LINK_SCRIPT=$(S390X_SRC)/softmmu.ld
tests/tcg/s390x/Makefile.softmmu-target
Quoted 3 lines
tests/tcg/s390x/Makefile.softmmu-target +2
-1-CFLAGS+=-ggdb -O0 +CFLAGS+=-ggdb -O0 \ + -I$(SRC_PATH)/roms/SLOF/lib/libc/include/ \
I'm not sure if it is just a problem with my setup, but with this patch applied I hit an error when running "make check-tcg --always-make"
In file included from /root/staging/qemu/tests/tcg/multiarch/system/memory.c:17:
/usr/include/inttypes.h:351:8: error: unknown type name ‘intmax_t’ 351 | extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__));
It seems to be cause by including the SLOF libc, because it works for me without that.
For what it's worth, it worked until used I "--always-make", so if you aren't building all targets some change might not be picked up here.
Quoted 5 lines
+ -I$(SRC_PATH)/include/hw/s390x/ipl/
LDFLAGS=-nostdlib -static%.o: %.S
Re: [PATCH v5 02/19] pc-bios/s390-ccw: Use the libc from SLOF and remove sclp prints
Quoted 60 lines · Jared Rossi
Quoted 45 lines · Thomas Huth
Quoted 10 lines · On 20/10/2024 03.29, [email protected] wrote:
From: 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.Quoted 8 lines
Additionally replace
sclp_printcalls with puts/printf now that it is avaliable.Co-authored by: Thomas Huth <[email protected]>
Signed-off-by Jared Rossi <[email protected]>---
pc-bios/s390-ccw/netboot.mak | 3 -- pc-bios/s390-ccw/bootmap.h | 4 +- pc-bios/s390-ccw/libc.h | 89 --------------------------------I just had to discover that the removal of the old libc breaks "make check-tcg" since it uses the
sclp.cfrom the firmware for printing.I'll squash this patch to fix it:
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) {tests/tcg/s390x/Makefile.softmmu-target +0
-0@@ -3,7 +3,9 @@ VPATH+=$(S390X_SRC) # EXTFLAGS can be passed by the user, e.g. to override the --accelQEMU_OPTS+=-action panic=exit-failure -nographic -serial chardev:output $(EXTFLAGS) -kernel LINK_SCRIPT=$(S390X_SRC)/softmmu.ld
tests/tcg/s390x/Makefile.softmmu-target
Quoted 3 lines
tests/tcg/s390x/Makefile.softmmu-target +2
-1-CFLAGS+=-ggdb -O0 +CFLAGS+=-ggdb -O0 \ + -I$(SRC_PATH)/roms/SLOF/lib/libc/include/ \I'm not sure if it is just a problem with my setup, but with this patch applied I hit an error when running "make check-tcg --always-make"
In file included from
/root/staging/qemu/tests/tcg/multiarch/system/memory.c:17:
/usr/include/inttypes.h:351:8: error: unknown type name ‘intmax_t’ 351 | externintmax_timaxabs (intmax_t__n)__THROW__attribute__((__const__));
Quoted 3 lines
It seems to be cause by including the SLOF libc, because it works for me without that.
For what it's worth, it worked until used I "--always-make", so if you aren't building all targets some change might not be picked up here.
I don't see it locally, but I've hit the same problem in the CI:
https://gitlab.com/thuth/qemu/-/jobs/8156508094#L6090
It seems to work for me, if I simply drop that "-I$(SRC_PATH)/roms/SLOF/lib/libc/include/" line again and only use the other -I line. I initially struggled a little bit with my cross-compiler setup, that's why I thought I'd need the line, but I think it is not required with a proper setup. Could you please check whether it works for you if you remove that line?
Thanks,
Thomas
Re: [PATCH v5 02/19] pc-bios/s390-ccw: Use the libc from SLOF and remove sclp prints
Quoted 66 lines · Thomas Huth
Quoted 55 lines · Jared Rossi
Quoted 46 lines · Thomas Huth
Quoted 12 lines · On 20/10/2024 03.29, [email protected] wrote:
From: 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_printcalls with puts/printf now that it is avaliable.Quoted 7 lines
Co-authored by: Thomas Huth <[email protected]>
Signed-off-by Jared Rossi <[email protected]>---
pc-bios/s390-ccw/netboot.mak | 3 --
pc-bios/s390-ccw/bootmap.h | 4 +-
pc-bios/s390-ccw/libc.h | 89
--------------------------------I just had to discover that the removal of the old libc breaks "make check-tcg" since it uses the
sclp.cfrom the firmware for printing.I'll squash this patch to fix it:
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) {tests/tcg/s390x/Makefile.softmmu-target +0
-0@@ -3,7 +3,9 @@ VPATH+=$(S390X_SRC) # EXTFLAGS can be passed by the user, e.g. to override the --accelQEMU_OPTS+=-action panic=exit-failure -nographic -serial chardev:output $(EXTFLAGS) -kernel LINK_SCRIPT=$(S390X_SRC)/softmmu.ld
tests/tcg/s390x/Makefile.softmmu-target
Quoted 3 lines
tests/tcg/s390x/Makefile.softmmu-target +2
-1-CFLAGS+=-ggdb -O0 +CFLAGS+=-ggdb -O0 \ + -I$(SRC_PATH)/roms/SLOF/lib/libc/include/ \I'm not sure if it is just a problem with my setup, but with this patch applied I hit an error when running "make check-tcg --always-make"
Quoted 7 lines
In file included from
/root/staging/qemu/tests/tcg/multiarch/system/memory.c:17:
/usr/include/inttypes.h:351:8: error: unknown type name ‘intmax_t’ 351 | externintmax_timaxabs (intmax_t__n)__THROW__attribute__((__const__));It seems to be cause by including the SLOF libc, because it works for me without that.
For what it's worth, it worked until used I "--always-make", so if you aren't building all targets some change might not be picked up here.
I don't see it locally, but I've hit the same problem in the CI:
Quoted 8 lines
https://gitlab.com/thuth/qemu/-/jobs/8156508094#L6090
It seems to work for me, if I simply drop that "-I$(SRC_PATH)/roms/SLOF/lib/libc/include/" line again and only use the other -I line. I initially struggled a little bit with my cross-compiler setup, that's why I thought I'd need the line, but I think it is not required with a proper setup. Could you please check whether it works for you if you remove that line?
Thanks,
Thomas
Yes, it works for me too if I remove "-I$(SRC_PATH)/roms/SLOF/lib/libc/include/" and keep the other changes.
Regards,
Jared Rossi
PATCH v5 3/19 pc-bios/s390-ccw: Link the netboot code into the main s390-ccw.img binary
In reply to [email protected]From: 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]>
--- 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.45.1
PATCH v5 4/19 hw/s390x: Remove the possibility to load the s390-netboot.img binary
In reply to [email protected]From: Jared Rossi <[email protected]>
Since 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.
Co-authored by: Thomas Huth <[email protected]>
--- hw/s390x/ipl.h | 12 +++------ hw/s390x/ipl.c | 55 -------------------------------------- hw/s390x/s390-virtio-ccw.c | 10 ++----- pc-bios/meson.build | 1 - 4 files changed, 6 insertions(+), 72 deletions(-)
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',
Signature · 1 line
2.45.1
PATCH v5 5/19 pc-bios/s390-ccw: Merge netboot.mak into the main Makefile
In reply to [email protected]From: Jared Rossi <[email protected]>
Now 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.
Co-authored by: Thomas Huth <[email protected]>
--- pc-bios/s390-ccw/netboot.mak | 45 --------------------------------- pc-bios/s390-ccw/Makefile | 47 ++++++++++++++++++++++++++++++++++- pc-bios/s390-netboot.img | Bin 67232 -> 0 bytes 3 files changed, 46 insertions(+), 46 deletions(-) delete mode 100644 pc-bios/s390-ccw/netboot.mak delete mode 100644 pc-bios/s390-netboot.img
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
pc-bios/s390-netboot.img deleted binary +0 -0
Signature · 1 line
2.45.1
PATCH v5 6/19 docs/system/s390x/bootdevices: Update the documentation about network booting
In reply to [email protected]From: Jared Rossi <[email protected]>
Remove the information about the separate s390-netboot.img from the documentation.
Co-authored by: Thomas Huth <[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.45.1
PATCH v5 7/19 pc-bios/s390-ccw: Remove panics from ISO IPL path
In reply to [email protected]From: 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.
--- 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.45.1
Re: [PATCH v5 07/19] pc-bios/s390-ccw: Remove panics from ISO IPL path
Quoted 5 lines · On 20/10/2024 03.29, [email protected] wrote:
From: 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.
Quoted 8 lines
Functions that would previously panic now provide a return code.
Signed-off-by Jared Rossi <[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(-)
PATCH v5 8/19 pc-bios/s390-ccw: Remove panics from ECKD IPL path
In reply to [email protected]From: 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.
--- 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.45.1
Re: [PATCH v5 08/19] pc-bios/s390-ccw: Remove panics from ECKD IPL path
Quoted 5 lines · On 20/10/2024 03.29, [email protected] wrote:
From: 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.
Quoted 7 lines
Functions that would previously panic now provide a return code.
Signed-off-by Jared Rossi <[email protected]>--- pc-bios/s390-ccw/bootmap.h | 1 + pc-bios/s390-ccw/bootmap.c | 187 +++++++++++++++++++++++++------------ 2 files changed, 130 insertions(+), 58 deletions(-)
PATCH v5 9/19 pc-bios/s390-ccw: Remove panics from SCSI IPL path
In reply to [email protected]From: 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.
--- 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.45.1
Re: [PATCH v5 09/19] pc-bios/s390-ccw: Remove panics from SCSI IPL path
Quoted 5 lines · On 20/10/2024 03.29, [email protected] wrote:
From: Jared Rossi <[email protected]>
Remove panic-on-error from virtio-scsi IPL specific functions so that error recovery may be possible in the future.
Quoted 8 lines
Functions that would previously panic now provide a return code.
Signed-off-by Jared Rossi <[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(-)
PATCH v5 10/19 pc-bios/s390-ccw: Remove panics from DASD IPL path
In reply to [email protected]From: 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.
--- 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.45.1
PATCH v5 11/19 pc-bios/s390-ccw: Remove panics from Netboot IPL path
In reply to [email protected]From: 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.
--- 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.45.1
Re: [PATCH v5 11/19] pc-bios/s390-ccw: Remove panics from Netboot IPL path
Quoted 7 lines · On 20/10/2024 03.29, [email protected] wrote:
From: 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.
Quoted 7 lines
Signed-off-by Jared Rossi <[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(-)
PATCH v5 12/19 pc-bios/s390-ccw: Enable failed IPL to return after error
In reply to [email protected]From: 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.
--- 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.45.1
PATCH v5 13/19 include/hw/s390x: Add include files for common IPL structs
In reply to [email protected]From: 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.
--- 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.45.1
PATCH v5 14/19 s390x: Add individual loadparm assignment to CCW device
In reply to [email protected]From: 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.
--- 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.45.1
Re: [PATCH v5 14/19] s390x: Add individual loadparm assignment to CCW device
Quoted 10 lines · On 20/10/2024 03.29, [email protected] wrote:
From: 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.
Quoted 4 lines
It is invalid to assign a loadparm to a non-boot device.
Signed-off-by Jared Rossi <[email protected]>---
Re: [PATCH v5 14/19] s390x: Add individual loadparm assignment to CCW device
In reply to [email protected]Quoted 120 lines · On 20/10/2024 03.29, [email protected] wrote:
From: 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.
Signed-off-by Jared Rossi <[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 +42
-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) {@@ -37,10 +41,52 @@ static bool ccw_device_realize(CcwDevice *dev, Error **errp)return true; } +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, +Error **errp) +{ +CcwDevice *dev =CCW_DEVICE (obj); +char *val; +int index; + + index =object_property_get_int (obj,"bootindex" ,NULL ); + +if (index <0 ) { +error_setg (errp,"LOADPARM is only valid for boot devices!" ); + } + +if (!visit_type_str (v, name, &val, errp)) { +return ; + } + +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. ] to pass" +" to the guest loader/kernel" , + .get = ccw_device_get_loadparm, + .set = ccw_device_set_loadparm,
hw/s390x/ccw-device.c static bool ccw_device_realize(CcwDevice *dev, Error **errp) · line 91
Quoted 10 lines
hw/s390x/ccw-device.c +4
-0+}; +static 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 ("loadparm" , CcwDevice, loadparm, ccw_loadparm, +typeof (uint8_t[8 ])),DEFINE_PROP_END_OF_LIST (), };
Hi Jared,
while doing more tests with these new boot order patches, I realized that really *all* virtio-ccw devices now have a "loadparm" property, also devices like virtio-gpu and virtio-tablet, where it does not make sense at all.
Wouldn't it be better to add this property only to the virtio-ccw-blk device?
Also, is there a way to specify the "loadparm" property for virtio-scsi devices? It does not seem to be available for "scsi-hd" ?
Thomas
Re: [PATCH v5 14/19] s390x: Add individual loadparm assignment to CCW device
Quoted 129 lines · Thomas Huth
Quoted 124 lines · On 20/10/2024 03.29, [email protected] wrote:
From: 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.
Signed-off-by Jared Rossi <[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;diff --git
a/hw/s390x/ipl.hb/hw/s390x/ipl.h
indexfa394c339d..b670bad551100644hw/s390x/ipl.h +2
-0@@ -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 +45
-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) {@@ -37,10 +41,52 @@ static bool ccw_device_realize(CcwDevice *dev, Error **errp) return true; } +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, + Error **errp) +{ + CcwDevice *dev = CCW_DEVICE(obj); + char *val; + int index; + + index = object_property_get_int(obj, "bootindex", NULL); + + if (index < 0) { + error_setg(errp, "LOADPARM is only valid for boot devices!"); + } + + if (!visit_type_str(v, name, &val, errp)) { + return; + } + + 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. ] to pass" + " to the guest loader/kernel", + .get = ccw_device_get_loadparm, + .set = ccw_device_set_loadparm, +}; + static 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("loadparm", CcwDevice, loadparm, ccw_loadparm, + typeof(uint8_t[8])), DEFINE_PROP_END_OF_LIST(),Quoted 1 line
};
Hi Jared,
Quoted 8 lines
while doing more tests with these new boot order patches, I realized that really *all* virtio-ccw devices now have a "loadparm" property, also devices like virtio-gpu and virtio-tablet, where it does not make sense at all.
Wouldn't it be better to add this property only to the virtio-ccw-blk device?
Also, is there a way to specify the "loadparm" property for virtio-scsi devices? It does not seem to be available for "scsi-hd" ?
Thomas
Hi Thomas,
Yes, the loadparm applies to all CCW devices. I tried to point this out in the cover letter of V2, but I guess it wasn’t clear what I meant, so I apologize for not bringing more attention to it. But also yes, as a result of this, non-CCW type devices do not have the loadparm attribute, which is why scsi-hd is not included.
The attribute could be implemented on a device-type basis, but it would not be *only* virtio-blk-ccw. Any device that can generate an IPLB could set the loadparm. I agree, though, that it doesn’t really make sense for some device types like virtio-gpu since they cannot have the prerequisite bootindex.
I’ll try to quickly put together a more efficient implementation of the loadparm that isn't too disruptive.
Regards,
Jared Rossi
PATCH v5 15/19 hw/s390x: Build an IPLB for each boot device
In reply to [email protected]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.
--- 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.45.1
Re: [PATCH v5 15/19] hw/s390x: Build an IPLB for each boot device
Quoted 11 lines · On 20/10/2024 03.29, [email protected] wrote:
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]>---
Re: [PATCH v5 15/19] hw/s390x: Build an IPLB for each boot device
In reply to [email protected]Quoted 11 lines · On 20/10/2024 03.29, [email protected] wrote:
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]>---
...
Quoted 19 lines
hw/s390x/ipl.c +7
-0@@ -56,6 +56,13 @@ static bool iplb_extended_needed(void *opaque)return ipl->iplbext_migration; } +/* Place the IPLB chain immediately before the BIOS in memory */ +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 ,
hw/s390x/ipl.c static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) · line 411
Quoted 7 lines
hw/s390x/ipl.c +4
-0@@ -398,6 +405,17 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype)return ccw_dev; } +static uint64_t s390_ipl_map_iplb_chain (IplParameterBlock *iplb_chain) +{ +S390IPLState *ipl =get_ipl_device (); +uint16_t count = ipl->qipl.chain_len;
I ran into problems when running the cdrom-test on my x86 laptop.
I think the above line needs to be changed into this to get it working on little endian hosts:
uint16_t count = be16_to_cpu(ipl->qipl.chain_len)
Quoted 129 lines
hw/s390x/ipl.c +58
-26+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); +return chain_addr; +} +void s390_ipl_fmt_loadparm (uint8_t *loadparm,char *str,Error **errp) {int i;@@ -428,54 +446,51 @@ void s390_ipl_convert_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 : 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 true 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 ; }@@ -484,8 +499,8 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) lp =S390_CCW_MACHINE (qdev_get_machine ())->loadparm; } -s390_ipl_convert_loadparm ((char *)lp, ipl->iplb.loadparm); - ipl->iplb.flags |=DIAG308_FLAGS_LP_VALID ; +s390_ipl_convert_loadparm ((char *)lp, iplb->loadparm); + iplb->flags |=DIAG308_FLAGS_LP_VALID ;return true; }@@ -493,6 +508,62 @@ 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 ); +Object *machine =qdev_get_machine (); + +/* +* Parse the boot devices. Generate an IPLB for only the first boot device +* which will later be set with DIAG308. +*/ +if (!dev_st) { + ipl->qipl.chain_len =0 ; +return false; + } + +/* If no machine loadparm was defined fill it with spaces */ +if (memcmp (S390_CCW_MACHINE (machine)->loadparm,NO_LOADPARM ,8 ) ==0 ) { +object_property_set_str (machine,"loadparm" ," " ,NULL ); + } + + iplb_num =1 ; +s390_build_iplb (dev_st, &ipl->iplb); + +/* Index any fallback boot devices */ +while (get_boot_device (iplb_num)) { + iplb_num++; + }
hw/s390x/ipl.c static bool s390_gen_initial_iplb(S390IPLState *ipl) · line 548
Quoted 10 lines
hw/s390x/ipl.c +10
-0+ +if (iplb_num >MAX_BOOT_DEVS ) { +warn_report ("Excess boot devices defined! %d boot devices found, " +"but only the first %d will be considered." , + iplb_num,MAX_BOOT_DEVS ); + + iplb_num =MAX_BOOT_DEVS ; + } + + ipl->qipl.chain_len = iplb_num -1 ;
... and this needs to be changed into:
ipl->qipl.chain_len = cpu_to_be16(iplb_num - 1);
hw/s390x/ipl.c static bool s390_gen_initial_iplb(S390IPLState *ipl) · line 561
Quoted 12 lines
hw/s390x/ipl.c +12
-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 ) { +/* Start at 1 because the IPLB for boot index 0 is not chained */ +for (int i =1 ; i < iplb_num; i++) { + dev_st =get_boot_device (i); +s390_build_iplb (dev_st, &iplb_chain[i -1 ]); + } + + ipl->qipl.next_iplb =s390_ipl_map_iplb_chain (iplb_chain);
And this needs to be change into:
ipl->qipl.next_iplb = cpu_to_be64(s390_ipl_map_iplb_chain(iplb_chain));
I am already in progress of picking up your patches, so if you agree with my suggestions, I can fix it on my side, too.
Thomas
Quoted 4 lines
hw/s390x/ipl.c +4
-0+ } + +return iplb_num; +}
Re: [PATCH v5 15/19] hw/s390x: Build an IPLB for each boot device
Quoted 206 lines · Thomas Huth
Quoted 11 lines · On 20/10/2024 03.29, [email protected] wrote:
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]>---
...
Quoted 19 lines
hw/s390x/ipl.c +0
-0@@ -56,6 +56,13 @@ static bool iplb_extended_needed(void *opaque) return ipl->iplbext_migration; }+/* Place the IPLB chain immediately before the BIOS in memory */ +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 static CcwDevice · line 411
Quoted 7 lines
hw/s390x/ipl.c +3
-0@@ -398,6 +405,17 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) return ccw_dev; } +static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain) +{ + S390IPLState *ipl = get_ipl_device(); + uint16_t count = ipl->qipl.chain_len;I ran into problems when running the cdrom-test on my x86 laptop.
I think the above line needs to be changed into this to get it working on little endian hosts:
uint16_tcount =be16_to_cpu(ipl->qipl.chain_len)Quoted 135 lines
hw/s390x/ipl.c +7
-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, len); + return chain_addr; +} + void s390_ipl_fmt_loadparm(uint8_t *loadparm, char *str, Error **errp){
int i;hw/s390x/ipl.c +3
-5@@ -428,54 +446,51 @@ void s390_ipl_convert_loadparm(char *ascii_lp, uint8_t *ebcdic_lp) } } -static bool s390_gen_initial_iplb(S390IPLState *ipl) +static bools390_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:
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;
caseCCW_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;
caseCCW_DEVTYPE_VIRTIO_NET:
+ /* The S390IPLState netboot is true if ANY IPLB may use netboot */
ipl->netboot= true;
/* Fall through toCCW_DEVTYPE_VIRTIOcase */
caseCCW_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;
}
@@ -484,8 +499,8 @@ static bools390_gen_initial_iplb(S390IPLState *ipl)lp = S390_CCW_MACHINE(qdev_get_machine())->loadparm;
}
-s390_ipl_convert_loadparm((char *)lp, ipl->iplb.loadparm); -ipl->iplb.flags|=DIAG308_FLAGS_LP_VALID;
+s390_ipl_convert_loadparm((char *)lp, iplb->loadparm);
+iplb->flags|=DIAG308_FLAGS_LP_VALID;
return true;
}hw/s390x/ipl.c +8
-0@@ -493,6 +508,62 @@ 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); + Object *machine = qdev_get_machine(); + + /* +* Parse the boot devices. Generate an IPLB for only the first boot device
+ * which will later be set with DIAG308.
+ */
+ if (!dev_st) {
+ipl->qipl.chain_len= 0;
+ return false;
+ }
+
+ /* If no machine loadparm was defined fill it with spaces */ + if (memcmp(S390_CCW_MACHINE(machine)->loadparm, NO_LOADPARM, 8)== 0) {
+object_property_set_str(machine, "loadparm", " ", NULL); + }hw/s390x/ipl.c +11
-0+ + iplb_num = 1; + s390_build_iplb(dev_st, &ipl->iplb); + + /* Index any fallback boot devices */ + while (get_boot_device(iplb_num)) { + iplb_num++; + } + + if (iplb_num > MAX_BOOT_DEVS) { + warn_report("Excess boot devices defined! %d boot devicesfound, "
+ "but only the first %d will be considered.", +iplb_num,MAX_BOOT_DEVS);hw/s390x/ipl.c static bool s390_gen_initial_iplb(S390IPLState *ipl) · line 548
Quoted 5 lines
hw/s390x/ipl.c +5
-0+ + iplb_num = MAX_BOOT_DEVS; + } + + ipl->qipl.chain_len = iplb_num - 1;... and this needs to be changed into:
ipl->qipl.chain_len=cpu_to_be16(iplb_num - 1);Quoted 5 lines
+ /*
+ * Build fallback IPLBs for any boot devices above index 0, up to a + * maximum amount as defined inipl.h
+ */
+ if (iplb_num> 1) {Quoted 8 lines
+ /* Start at 1 because the IPLB for boot index 0 is not chained */
+ for (int i = 1; i <iplb_num; i++) {
+dev_st=get_boot_device(i);
+s390_build_iplb(dev_st, &iplb_chain[i - 1]); + }
+
+ipl->qipl.next_iplb=s390_ipl_map_iplb_chain(iplb_chain);
Quoted 8 lines
And this needs to be change into:
ipl->qipl.next_iplb= cpu_to_be64(s390_ipl_map_iplb_chain(iplb_chain));I am already in progress of picking up your patches, so if you agree with my suggestions, I can fix it on my side, too.
Thomas
This is agreeable to me. Thank you for handling it on your side.
Regards,
Jared Rossi
PATCH v5 16/19 s390x: Rebuild IPLB for SCSI device directly from DIAG308
In reply to [email protected]From: 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.
--- 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.45.1
PATCH v5 17/19 pc-bios/s390x: Enable multi-device boot loop
In reply to [email protected]From: 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.
--- 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.45.1
Re: [PATCH v5 17/19] pc-bios/s390x: Enable multi-device boot loop
Quoted 7 lines · On 20/10/2024 03.29, [email protected] wrote:
From: 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.
Quoted 7 lines
Signed-off-by Jared Rossi <[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(-)
PATCH v5 18/19 docs/system: Update documentation for s390x IPL
In reply to [email protected]From: Jared Rossi <[email protected]>
Update docs to show that s390x PC BIOS can support more than one boot device.
--- 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.45.1
PATCH v5 19/19 tests/qtest: Add s390x boot order tests to cdrom-test.c
In reply to [email protected]From: 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.
--- 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.45.1
Re: [PATCH v5 19/19] tests/qtest: Add s390x boot order tests to cdrom-test.c
Quoted 9 lines · On 20/10/2024 03.29, [email protected] wrote:
From: 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.
Quoted 7 lines
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.
Signed-off-by Jared Rossi <[email protected]>---
Quoted 12 lines · On 20/10/2024 03.29, [email protected] wrote:
From: Jared Rossi <[email protected]>
changes v4 -> v5:
- Fix a bug with per-deice loadparm support:
The machine loadparm is no longer overwritten by device values, which now allows an empty machine loadparm to propagate to later devices even if the primary boot device set an initial loadparm
- Fix two instances where changes were squashed into wrong patch
- Fix an instance whereNULL_BLOCK_NRwas returned instead ofERROR_BLOCK_NR
- Fix an instance of logical AND being used instead of bitwise AND
- Standardize all error values to be negative in all device type paths
- Minor stylistic changes and code simplification
Hi Jared!
Our QE Sebastian also had a try with the patches today, and discovered some non-working scenarios:
Try to boot from non-working CD image first, then from a working HD image:
dd if=/dev/zero of=/tmp/zero.dat bs=1M count=10 qemu-system-s390x -nographic -accel kvm -m 2G \
-drive if=none,id=d1,file=/tmp/zero.dat,format=raw,media=cdrom \
-device virtio-scsi -device scsi-cd,drive=d1,bootindex=1 \
-drive if=none,file=good-image.qcow2,id=d2 \
-device virtio-blk,drive=d2,bootindex=2
This outputs something like the following text, then aborts:
LOADPARM=[ ]
Using virtio-scsi.
SCSI CD-ROM detected.
Failed to IPL this ISO image!
LOADPARM=[ ]
Using virtio-blk.
Failed to IPL this ISO image!
ERROR: No suitable device for IPL. Halting...
Looks like the s390-ccw bios is treating the virtio-blk device as CD-ROM in this case?
Almost the same setup, first device is again a non-working CD image, but the second device is a virtio-net device - results in the same error message (so it's likely the same or at least a very similar problem).
Could you please have a look?
Thanks!
Thomas
Hi Thomas, Sebastian,
It looks like this is simply caused by the "is_cdrom" value only ever being set to true. I think it is a one-line fix that just makes sure to initialize the value to false each time we try a new device:
pc-bios/s390-ccw/main.c +0 -0
@@ -214,6 +214,7 @@ static void boot_setup(void)
static bool find_boot_device(void)
{
VDev *vdev = virtio_get_device();
+ vdev->is_cdrom = false;
bool found = false;
switch (iplb.pbt) {
I tested it with the two scenarios you mention and with the existing qtests, and it seems to work correctly now.
Thanks for finding the mistake,
Jared Rossi
Quoted 50 lines · Thomas Huth
Quoted 13 lines · On 20/10/2024 03.29, [email protected] wrote:
From: Jared Rossi <[email protected]>
changes v4 -> v5:
- Fix a bug with per-deice loadparm support:
The machine loadparm is no longer overwritten by device values, which now allows an empty machine loadparm to propagate to later devices even if the primary boot device set an initial loadparm
- Fix two instances where changes were squashed into wrong patch
- Fix an instance whereNULL_BLOCK_NRwas returned instead ofERROR_BLOCK_NR
- Fix an instance of logical AND being used instead of bitwise AND
- Standardize all error values to be negative in all device type paths
- Minor stylistic changes and code simplificationHi Jared!
Our QE Sebastian also had a try with the patches today, and discovered some non-working scenarios:
Try to boot from non-working CD image first, then from a working HD image:
dd if=/dev/zero of=/tmp/zero.dat bs=1M count=10 qemu-system-s390x -nographic -accel kvm -m 2G \
-drive if=none,id=d1,file=/tmp/zero.dat,format=raw,media=cdrom \
-device virtio-scsi -device scsi-cd,drive=d1,bootindex=1 \
-drive if=none,file=good-image.qcow2,id=d2 \
-device virtio-blk,drive=d2,bootindex=2This outputs something like the following text, then aborts:
LOADPARM=[ ]
Using virtio-scsi.
SCSI CD-ROM detected.
Failed to IPL this ISO image!
LOADPARM=[ ]Using virtio-blk.
Failed to IPL this ISO image!
ERROR: No suitable device for IPL. Halting...Looks like the s390-ccw bios is treating the virtio-blk device as CD-ROM in this case?
Almost the same setup, first device is again a non-working CD image, but the second device is a virtio-net device - results in the same error message (so it's likely the same or at least a very similar problem).
Could you please have a look?
Thanks!
Thomas
Quoted 19 lines · Jared Rossi
Hi Thomas, Sebastian,
It looks like this is simply caused by the "
is_cdrom" value only ever being set to true. I think it is a one-line fix that just makes sure to initialize the value to false each time we try a new device:pc-bios/s390-ccw/main.c +1
-0@@ -214,6 +214,7 @@ static void boot_setup(void) static bool find_boot_device(void) { VDev *vdev = virtio_get_device(); + vdev->is_cdrom = false; bool found = false; switch (iplb.pbt) {
Quoted 2 lines
I tested it with the two scenarios you mention and with the existing qtests, and it seems to work correctly now.
Agreed, this seems to fix the issue when all devices are properly marked with bootindex properties. But it still persists in case the BIOS has to scan for the boot device, e.g.:
qemu-system-s390x -accel kvm -m 2G -nographic \
-drive if=none,id=d1,file=/tmp/bad.dat,format=raw,media=cdrom \
-device virtio-scsi -device scsi-cd,drive=d1 \
-drive if=none,id=d2,file=good.qcow2 -device virtio-blk,drive=d2
Isn't there a better place to set the is_cdrom variable?
Thomas
Quoted 25 lines · Thomas Huth
Quoted 19 lines · Jared Rossi
Hi Thomas, Sebastian,
It looks like this is simply caused by the "
is_cdrom" value only ever being set to true. I think it is a one-line fix that just makes sure to initialize the value to false each time we try a new device:pc-bios/s390-ccw/main.c +1
-0@@ -214,6 +214,7 @@ static void boot_setup(void) static bool find_boot_device(void) { VDev *vdev = virtio_get_device(); + vdev->is_cdrom = false; bool found = false; switch (iplb.pbt) {Quoted 2 lines
I tested it with the two scenarios you mention and with the existing qtests, and it seems to work correctly now.
Agreed, this seems to fix the issue when all devices are properly marked with bootindex properties. But it still persists in case the BIOS has to scan for the boot device, e.g.:
Quoted 9 lines
qemu-system-s390x -accel kvm -m 2G -nographic \
-drive if=none,id=d1,file=/tmp/bad.dat,format=raw,media=cdrom \
-device virtio-scsi -device scsi-cd,drive=d1 \
-drive if=none,id=d2,file=good.qcow2 -device virtio-blk,drive=d2Isn't there a better place to set the
is_cdromvariable?Thomas
Hi Thomas,
What I found is that the original issue with clearing the "is_cdrom" value is just as easily fixed for both indexed devices and probed devices by moving where "is_cdrom" is set to false:
pc-bios/s390-ccw/main.c +0 -0
@@ -242,6 +242,7 @@ static bool find_boot_device(void)
static int virtio_setup(void)
{
VDev *vdev = virtio_get_device();
+ vdev->is_cdrom = false;
int ret;
switch (vdev->senseid.cu_model) {
Unfortunately when verifying the fix I found another unrelated issue with probing, which is that only the first device attached to the scsi controller will be found. This is because virtio_scsi_setup() itself contains a probing loop to find a LUN when none is specified, and, unsurprisingly, it returns the first thing it finds attached to the controller. As a result, the main device probing loop will move on after trying only one LUN per controller.
Fixing this won't be a simple one-liner because it will require implementation of nested probing for scsi devices, such that all LUNS on the controller are probed before moving to the next device.
Regards,
Jared Rossi
Quoted 49 lines · Jared Rossi
Quoted 25 lines · Thomas Huth
Quoted 19 lines · Jared Rossi
Hi Thomas, Sebastian,
It looks like this is simply caused by the "
is_cdrom" value only ever being set to true. I think it is a one-line fix that just makes sure to initialize the value to false each time we try a new device:pc-bios/s390-ccw/main.c +1
-0@@ -214,6 +214,7 @@ static void boot_setup(void) static bool find_boot_device(void) { VDev *vdev = virtio_get_device(); + vdev->is_cdrom = false; bool found = false; switch (iplb.pbt) {Quoted 2 lines
I tested it with the two scenarios you mention and with the existing qtests, and it seems to work correctly now.
Agreed, this seems to fix the issue when all devices are properly marked with bootindex properties. But it still persists in case the BIOS has to scan for the boot device, e.g.:
Quoted 9 lines
qemu-system-s390x -accel kvm -m 2G -nographic \
-drive if=none,id=d1,file=/tmp/bad.dat,format=raw,media=cdrom \
-device virtio-scsi -device scsi-cd,drive=d1 \
-drive if=none,id=d2,file=good.qcow2 -device virtio-blk,drive=d2Isn't there a better place to set the
is_cdromvariable?Thomas
Hi Thomas,
What I found is that the original issue with clearing the "
is_cdrom" value is just as easily fixed for both indexed devices and probed devices by moving where "is_cdrom" is set to false:pc-bios/s390-ccw/main.c +0
-0
pc-bios/s390-ccw/main.c static bool find_boot_device(void) · line 246
Quoted 5 lines
pc-bios/s390-ccw/main.c +1
-0@@ -242,6 +242,7 @@ static bool find_boot_device(void) static int virtio_setup(void) { VDev *vdev = virtio_get_device(); + vdev->is_cdrom = false; int ret;
That looks like a good spot, indeed! Could you please send it as a proper patch (i.e. with a Signed-off-by line)? I think that would still be a good fix for QEMU 9.2.
Quoted 10 lines
Unfortunately when verifying the fix I found another unrelated issue with probing, which is that only the first device attached to the scsi controller will be found. This is because
virtio_scsi_setup()itself contains a probing loop to find a LUN when none is specified, and, unsurprisingly, it returns the first thing it finds attached to the controller. As a result, the main device probing loop will move on after trying only one LUN per controller.Fixing this won't be a simple one-liner because it will require implementation of nested probing for scsi devices, such that all LUNS on the controller are probed before moving to the next device.
Ok, maybe that change will be too big for QEMU 9.2 anyway (we're in freeze now), so it's ok to include this later, I think.
And in case you're interested (it's maybe not so important since it's rather unlikely that the users will do this), there is another issue when trying to boot from multiple network devices where the first one has a DHCP server but no bootfile:
qemu-system-s390x -nographic -accel kvm -m 2G -netdev user,id=n1 \
-device virtio-net-ccw,netdev=n1,bootindex=1 \
-netdev user,id=n2,tftp=/boot,bootfile=vmlinuz \
-device virtio-net-ccw,netdev=n2,bootindex=2 -d guest_errors
The firmware seems to panic while trying to request DHCP information from the second boot device.
Thomas
On 08/11/2024 15.37, Thomas Huth wrote:
...
Quoted 8 lines
And in case you're interested (it's maybe not so important since it's rather unlikely that the users will do this), there is another issue when trying to boot from multiple network devices where the first one has a DHCP server but no bootfile:
qemu-system-s390x -nographic -accel kvm -m 2G -netdev user,id=n1 \
-device virtio-net-ccw,netdev=n1,bootindex=1 \
-netdev user,id=n2,tftp=/boot,bootfile=vmlinuz \
-device virtio-net-ccw,netdev=n2,bootindex=2 -dguest_errorsThe firmware seems to panic while trying to request DHCP information from the second boot device.
I had a look at this problem now, and the solution is as simple as this:
pc-bios/s390-ccw/virtio-net.c +2 -0
@@ -51,6 +51,8 @@ int virtio_net_init(void *mac_addr)void *buf;int i; + rx_last_idx =0 ; + vdev->guest_features[0 ] =VIRTIO_NET_F_MAC_BIT ;virtio_setup_ccw (vdev);
Otherwise the rx_last_idx does not get reset to 0 when starting the 2nd network boot, so the code tries to access some ring data that contains garbage later. I'll send it as a proper patch...
Thomas