Enhance s390 BIOS to enable boot device selection
PATCH v2 3/5 S390: BIOS create link to src folder for .img file
In reply to Dominik DingelFor *.img files, there will be a link created directly to the src folder, like for all other blobs.
configure +1 -0
@@ -4389,6 +4389,7 @@ for bios_file in \ $source_path/pc-bios/*.aml \ $source_path/pc-bios/*.rom \ $source_path/pc-bios/*.dtb \ + $source_path/pc-bios/*.img \ $source_path/pc-bios/openbios-* \ $source_path/pc-bios/palcode-* do
Signature · 1 line
1.7.9.5
PATCH v2 1/5 S390: Add virtio-blk boot
In reply to Dominik DingelCheck for a kernel IPL entry and load kernel image if one was specified. If no kernel image was supplied and no boot device was specified or the boot device is not of type virtio-blk-ccw, print an error message and exit.
hw/s390x/ipl.c +23 -3
@@ -16,6 +16,8 @@#include "elf.h" #include "hw/loader.h" #include "hw/sysbus.h" +#include "hw/s390x/virtio-ccw.h" +#include "hw/s390x/css.h" #define KERN_IMAGE_START 0x010000UL#define KERN_PARM_AREA 0x010480UL
@@ -57,13 +59,22 @@ typedef struct S390IPLState { } S390IPLState; -static void s390_ipl_cpu (uint64_t pswaddr) +static void s390_ipl_cpu (uint64_t pswaddr,VirtioCcwDevice *dev) {S390CPU *cpu =S390_CPU (qemu_get_cpu (0 ));CPUS390XState *env = &cpu->env; env->psw.addr = pswaddr; env->psw.mask =IPL_PSW_MASK ; + +if (dev) { + env->regs[7 ] = dev->sch->cssid <<24 | + dev->sch->ssid <<16 | + dev->sch->devno; + }else { + env->regs[7 ] =-1 ; + } +s390_add_running_cpu (cpu); }
@@ -151,8 +162,17 @@ static Property s390_ipl_properties[] = {static void s390_ipl_reset (DeviceState *dev) {S390IPLState *ipl =S390_IPL (dev); - -s390_ipl_cpu (ipl->start_addr); + +if (ipl->kernel) { +s390_ipl_cpu (ipl->start_addr,NULL ); + }else { +/* is there a bootable device? */ +DeviceState *dev_st =get_boot_device (0 ); +VirtioCcwDevice *ccw_dev = (VirtioCcwDevice *)object_dynamic_cast ( +OBJECT (&(dev_st->parent_obj)),"virtio-blk-ccw" ); + +s390_ipl_cpu (ipl->start_addr, ccw_dev); + } }static void s390_ipl_class_init (ObjectClass *klass,void *data)
Signature · 1 line
1.7.9.5
PATCH v2 2/5 S390: BIOS check for file
In reply to Dominik DingelAdd a check if the BIOS blob exists before trying to load.
hw/s390x/ipl.c +4 -0
@@ -93,6 +93,10 @@ static int s390_ipl_init(SysBusDevice *dev) } bios_filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name); +if (bios_filename ==NULL ) { +hw_error ("could not find stage1 bootloader\n" ); + } + bios_size =load_elf (bios_filename,NULL ,NULL , &ipl->start_addr,NULL ,NULL ,1 ,ELF_MACHINE ,0 );if (bios_size ==-1UL ) {
Signature · 1 line
1.7.9.5
PATCH v2 4/5 S390: BIOS boot from given device
In reply to Dominik DingelUse the passed device, if there is no device, use the first applicable device.
pc-bios/s390-ccw/main.c +19 -6
@@ -12,6 +12,7 @@struct subchannel_id blk_schid; char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); +uint64_t boot_value;void virtio_panic (const char *string) {
@@ -20,15 +21,20 @@ void virtio_panic(const char *string)while (1 ) { } } -static void virtio_setup (void ) +static void virtio_setup (uint64_t dev_info) {struct schib schib;int i;int r;bool found = false; - +uint16_t dev_no; blk_schid.one =1 ; +if (dev_info !=-1 ) { + dev_no = dev_info &0xffff ; +debug_print_int ("device no. " , dev_no); + } +for (i =0 ; i <0x10000 ; i++) { blk_schid.sch_no = i; r =stsch_err (blk_schid, &schib);
@@ -36,9 +42,14 @@ static void virtio_setup(void)break ; }if (schib.pmcw.dnv) { -if (virtio_is_blk (blk_schid)) { - found = true; -break ; +if (dev_info !=-1 && schib.pmcw.dev != dev_no) { +continue ; + } +else { +if (virtio_is_blk (blk_schid)) { + found = true; +break ; + } } } }
@@ -53,7 +64,9 @@ static void virtio_setup(void)int main (void ) {sclp_setup (); -virtio_setup (); +debug_print_int ("boot reg[7]\n" , boot_value); +virtio_setup (boot_value); +if (zipl_load () <0 )sclp_print ("Failed to load OS from hard disk\n" );disabled_wait ();
pc-bios/s390-ccw/start.S +2 -0
@@ -14,6 +14,8 @@ _start: larl %r15, stack + 0x8000 /* Set up stack */ +larl %r6, boot_value +stg %r7, 0(%r6) /* save the boot_value before any function calls */ j main /* And call C */ /*
Signature · 1 line
1.7.9.5
v2 cover Enhance s390 BIOS to enable boot device selection
This patchset allows the s390 platform to boot from a specified virtio-ccw-blk device, passed on the commandline.
v1 -> v2
- no loadparm will be used
- the virtio devices will not be automatically inserted in the boot order
- if there is no boot device in the boot order we will fallback to the first device
- assign the boot value in the start block
- refactoring of the s390_ipl_cpu function
Dominik Dingel (5):
S390: Add virtio-blk boot
S390: BIOS check for file
S390: BIOS create link to src folder for .img file
S390: BIOS boot from given device
S390: Sync Blob with source changes
configure | 1 + hw/s390x/ipl.c | 30 +++++++++++++++++++++++++++--- pc-bios/s390-ccw.img | Bin 9432 -> 17528 bytes pc-bios/s390-ccw/main.c | 25 +++++++++++++++++++------ pc-bios/s390-ccw/start.S | 2 ++ 5 files changed, 49 insertions(+), 9 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v2 5/5 S390: Sync Blob with source changes
pc-bios/s390-ccw.img binary +0 -0
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v2 1/5] S390: Add virtio-blk boot
In reply to Dominik DingelQuoted 29 lines · Dominik Dingel
Check for a kernel IPL entry and load kernel image if one was specified. If no kernel image was supplied and no boot device was specified or the boot device is not of type virtio-blk-ccw, print an error message and exit.
Signed-off-by Christian Paro <[email protected]>Signed-off-by Dominik Dingel <[email protected]>hw/s390x/ipl.c +3
-1@@ -16,6 +16,8 @@#include "elf.h" #include "hw/loader.h" #include "hw/sysbus.h" +#include "hw/s390x/virtio-ccw.h" +#include "hw/s390x/css.h" #define KERN_IMAGE_START 0x010000UL#define KERN_PARM_AREA 0x010480UL@@ -57,13 +59,22 @@ typedef struct S390IPLState { } S390IPLState; -static void s390_ipl_cpu (uint64_t pswaddr) +static void s390_ipl_cpu (uint64_t pswaddr,VirtioCcwDevice *dev) {S390CPU *cpu =S390_CPU (qemu_get_cpu (0 ));CPUS390XState *env = &cpu->env;
hw/s390x/ipl.c typedef struct S390IPLState { · line 75
Quoted 10 lines
hw/s390x/ipl.c +7
-0env->psw.addr = pswaddr; env->psw.mask =IPL_PSW_MASK ; + +if (dev) { + env->regs[7 ] = dev->sch->cssid <<24 | + dev->sch->ssid <<16 | + dev->sch->devno; + }else { + env->regs[7 ] =-1 ;
R7 has nothing to do with the IPL. Please move it into the reset path.
Quoted 12 lines
hw/s390x/ipl.c +3
-2+ } +s390_add_running_cpu (cpu); }@@ -151,8 +162,17 @@ static Property s390_ipl_properties[] = {static void s390_ipl_reset (DeviceState *dev) {S390IPLState *ipl =S390_IPL (dev); - -s390_ipl_cpu (ipl->start_addr); +
hw/s390x/ipl.c static Property s390_ipl_properties[] = { · line 175
Quoted 10 lines
hw/s390x/ipl.c +10
-0+if (ipl->kernel) { +s390_ipl_cpu (ipl->start_addr,NULL ); + }else { +/* is there a bootable device? */ +DeviceState *dev_st =get_boot_device (0 ); +VirtioCcwDevice *ccw_dev = (VirtioCcwDevice *)object_dynamic_cast ( +OBJECT (&(dev_st->parent_obj)),"virtio-blk-ccw" ); + +s390_ipl_cpu (ipl->start_addr, ccw_dev); + }
Please move s390_ipl_cpu() out of the branches. How about writing it like this?
if (!ipl->kernel) {
/* booting firmware, tell it what device to boot off of */
DeviceState *dev_st = get_boot_device(0);
VirtioCcwDevice *ccw_dev = ...
if (ccw_dev) {
env->regs[7] = <devid calculation>;
} else {
env->regs[7] = -1;
}
}
s390_ipl_cpu(ipl->start_addr);Alex
Re: [Qemu-devel] [PATCH v2 4/5] S390: BIOS boot from given device
In reply to Dominik DingelQuoted 24 lines · Dominik Dingel
Use the passed device, if there is no device, use the first applicable device.
Signed-off-by Dominik Dingel <[email protected]>pc-bios/s390-ccw/main.c +2
-1@@ -12,6 +12,7 @@struct subchannel_id blk_schid; char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); +uint64_t boot_value;void virtio_panic (const char *string) {@@ -20,15 +21,20 @@ void virtio_panic(const char *string)while (1 ) { } } -static void virtio_setup (void ) +static void virtio_setup (uint64_t dev_info) {struct schib schib;
pc-bios/s390-ccw/main.c void virtio_panic(const char *string) · line 35
Quoted 10 lines
pc-bios/s390-ccw/main.c +4
-1int i;int r;bool found = false; - +uint16_t dev_no; blk_schid.one =1 ; +if (dev_info !=-1 ) { + dev_no = dev_info &0xffff ; +debug_print_int ("device no. " , dev_no);
It'd be nice if you could make this a bit more obvious.
bool check_devno = false
if (dev_info != -1) {
check_devno = true;
...
}pc-bios/s390-ccw/main.c static void virtio_setup(void) · line 45
Quoted 13 lines
pc-bios/s390-ccw/main.c +3
-3+ } +for (i =0 ; i <0x10000 ; i++) { blk_schid.sch_no = i; r =stsch_err (blk_schid, &schib);@@ -36,9 +42,14 @@ static void virtio_setup(void)break ; }if (schib.pmcw.dnv) { -if (virtio_is_blk (blk_schid)) { - found = true; -break ; +if (dev_info !=-1 && schib.pmcw.dev != dev_no) {
if (check_devno && ...)
pc-bios/s390-ccw/main.c static void virtio_setup(void) · line 48
Quoted 3 lines
pc-bios/s390-ccw/main.c +3
-0+continue ; + } +else {
} else {
But really in this case there's no need for that either, since the branch will have continue'd anyway. Just close the branch.
pc-bios/s390-ccw/main.c static void virtio_setup(void) · line 67
Quoted 13 lines
pc-bios/s390-ccw/main.c +5
-1+if (virtio_is_blk (blk_schid)) { + found = true; +break ; + } } } }@@ -53,7 +64,9 @@ static void virtio_setup(void)int main (void ) {sclp_setup (); -virtio_setup (); +debug_print_int ("boot reg[7]\n" , boot_value);
\n?
Alex
Quoted 21 lines
pc-bios/s390-ccw/main.c +2
-0+virtio_setup (boot_value); +if (zipl_load () <0 )sclp_print ("Failed to load OS from hard disk\n" );disabled_wait ();pc-bios/s390-ccw/start.S +0
-0@@ -14,6 +14,8 @@
_start:larl %r15, stack +
0x8000/* Set up stack */pc-bios/s390-ccw/start.S +2
-0+larl %r6, boot_value +stg %r7, 0(%r6) /* save the boot_value before any function calls */j main /* And call C */
/*
Signature · 1 line
1.7.9.5
Alexander Graf
AppliedRe: [Qemu-devel] [PATCH v2 3/5] S390: BIOS create link to src folder for .img file
In reply to Dominik DingelQuoted 4 lines · Dominik Dingel
For *.img files, there will be a link created directly to the src folder, like for all other blobs.
Signed-off-by Dominik Dingel <[email protected]>
Thanks, applied to s390-next.
Alex
Quoted 16 lines
configure +1
-0@@ -4389,6 +4389,7 @@ for bios_file in \ $source_path/pc-bios/*.aml \ $source_path/pc-bios/*.rom \ $source_path/pc-bios/*.dtb \ + $source_path/pc-bios/*.img \ $source_path/pc-bios/openbios-* \ $source_path/pc-bios/palcode-*do
Signature · 1 line
1.7.9.5
Alexander Graf
AppliedRe: [Qemu-devel] [PATCH v2 2/5] S390: BIOS check for file
In reply to Dominik DingelQuoted 3 lines · Dominik Dingel
Add a check if the BIOS blob exists before trying to load.
Signed-off-by Dominik Dingel <[email protected]>
Thanks, applied to s390-next.
Alex
Quoted 19 lines
hw/s390x/ipl.c +4
-0@@ -93,6 +93,10 @@ static int s390_ipl_init(SysBusDevice *dev) } bios_filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name); +if (bios_filename ==NULL ) { +hw_error ("could not find stage1 bootloader\n" ); + } + bios_size =load_elf (bios_filename,NULL ,NULL , &ipl->start_addr,NULL ,NULL ,1 ,ELF_MACHINE ,0 );if (bios_size ==-1UL ) {Signature · 1 line
1.7.9.5