aboutsummaryrefslogtreecommitdiff
path: root/pc-bios/s390-ccw
AgeCommit message (Collapse)Author
2020-09-01build: fix recurse-all targetPaolo Bonzini
The missing "/all" suffix prevents the pc-bios/ parts of the build from running. In the meanwhile, -Wall has moved from QEMU_CFLAGS to CFLAGS. Simplify everything by not passing down CFLAGS, and add -Wall in the recursive Makefiles. Reported-by: Miroslav Rezanina <mrezanin@redhat.com> Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com> Tested-by: Thomas Huth <thuth@redhat.com> Fixes: 5e6d1573b4 ("remove Makefile.target", 2020-08-21) Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-08-21pc-bios/s390-ccw: do not use rules.makThomas Huth
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-07-02pc-bios/s390-ccw: Generate and include dependency files in the MakefileThomas Huth
The Makefile of the s390-ccw bios does not handle dependencies of the *.c files from the headers yet, so that you often have to run a "make clean" to get the build right when one of the headers has been changed. Let's make sure that we generate and include dependency files for all *.c files now to avoid this problem in the future. Acked-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <20200630142955.7662-1-thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-02pc-bios: s390x: Make u32 ptr check explicitJanosch Frank
Let's make it a bit more clear that we check the full 64 bits to fit into the 32 we return. Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Suggested-by: David Hildenbrand <david@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20200624075226.92728-11-frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-02pc-bios: s390x: Use ebcdic2ascii tableJanosch Frank
Why should we do conversion of a ebcdic value if we have a handy table where we could look up the ascii value instead? Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20200624075226.92728-10-frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-02pc-bios: s390x: Move panic() into header and add infinite loopJanosch Frank
panic() was defined for the ccw and net bios, i.e. twice, so it's cleaner to rather put it into the header. Also let's add an infinite loop into the assembly of disabled_wait() so the caller doesn't need to take care of it. Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.ibm.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20200624075226.92728-9-frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-02pc-bios: s390x: Use PSW masks where possible and introduce PSW_MASK_SHORT_ADDRJanosch Frank
Let's move some of the PSW mask defines into s390-arch.h and use them in jump2ipl.c. Also let's introduce a new constant for the address mask of 8 byte (short) PSWs. Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20200624075226.92728-8-frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-02pc-bios: s390x: Rename PSW_MASK_ZMODE to PSW_MASK_64Janosch Frank
This constant enables 64 bit addressing, not the ESAME architecture, so it shouldn't be named ZMODE. Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20200624075226.92728-7-frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-02pc-bios: s390x: Get rid of magic offsets into the lowcoreJanosch Frank
If we have a lowcore struct that has members for offsets that we want to touch, why not use it? Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <20200624075226.92728-5-frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-02pc-bios: s390x: Move sleep and yield to helper.hJanosch Frank
They are definitely helper functions. Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Message-Id: <20200624075226.92728-4-frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-02pc-bios: s390x: Consolidate timing functions into time.hJanosch Frank
Let's consolidate timing related functions into one header. Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Acked-by: Thomas Huth <thuth@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Message-Id: <20200624075226.92728-3-frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-07-02pc-bios: s390x: cio.c cleanup and compile fixJanosch Frank
Let's initialize the structs at the beginning to ease reading and also zeroing all other fields. This also makes the compiler stop complaining about sense_id_ccw.flags being ored into when it's not initialized. Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <20200624075226.92728-2-frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2020-03-16misc: Replace zero-length arrays with flexible array member (automatic)Philippe Mathieu-Daudé
Description copied from Linux kernel commit from Gustavo A. R. Silva (see [3]): --v-- description start --v-- The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member [1], introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being unadvertenly introduced [2] to the Linux codebase from now on. --^-- description end --^-- Do the similar housekeeping in the QEMU codebase (which uses C99 since commit 7be41675f7cb). All these instances of code were found with the help of the following Coccinelle script: @@ identifier s, m, a; type t, T; @@ struct s { ... t m; - T a[0]; + T a[]; }; @@ identifier s, m, a; type t, T; @@ struct s { ... t m; - T a[0]; + T a[]; } QEMU_PACKED; [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=76497732932f [3] https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/commit/?id=17642a2fbd2c1 Inspired-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-03-10pc-bios: s390x: Save iplb location in lowcoreJanosch Frank
The POP states that for a list directed IPL the IPLB is stored into memory by the machine loader and its address is stored at offset 0x14 of the lowcore. ZIPL currently uses the address in offset 0x14 to access the IPLB and acquire flags about secure boot. If the IPLB address points into memory which has an unsupported mix of flags set, ZIPL will panic instead of booting the OS. As the lowcore can have quite a high entropy for a guest that did drop out of protected mode (i.e. rebooted) we encountered the ZIPL panic quite often. Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Tested-by: Marc Hartmayer <mhartmay@linux.ibm.com> Message-Id: <20200304114231.23493-19-frankja@linux.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
2019-12-18pc-bios/s390x: Fix reset psw maskJanosch Frank
We need to set the short psw indication bit in the reset psw, as it is a short psw. Exposed by "s390x: Properly fetch and test the short psw on diag308 subc 0/1". Fixes: 962982329029 ("pc-bios/s390-ccw: do a subsystem reset before running the guest") Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Message-Id: <20191203132813.2734-5-frankja@linux.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2019-11-29pc-bios/s390-ccw: fix sclp_get_loadparm_asciiClaudio Imbrenda
The existing s390 bios gets the LOADPARM information from the system using an SCLP call that specifies a buffer length too small to contain all the output. The recent fixes in the SCLP code have exposed this bug, since now the SCLP call will return an error (as per architecture) instead of writing partially and completing successfully. The solution is simply to specify the full page length as the SCCB length instead of a smaller size. Fixes: 832be0d8a3bb ("s390x: sclp: Report insufficient SCCB length") Fixes: 9a22473c70f3 ("pc-bios/s390-ccw: get LOADPARM stored in SCP Read Info") Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Message-Id: <1574944437-31182-1-git-send-email-imbrenda@linux.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Tested-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Tested-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-09-18pc-bios/s390-ccw/net: fix a possible memory leak in get_uuid()Yifan Luo
There is a possible memory leak in get_uuid(). Should free allocated mem before return NULL. Signed-off-by: Yifan Luo <luoyifan@cmss.chinamobile.com> Message-Id: <02cf01d55267$86cf2850$946d78f0$@cmss.chinamobile.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-09-18pc-bios/s390-ccw: Do not pre-initialize empty arrayThomas Huth
Since commit 339686a358b11a231aa5b6d1424e7a1460d7f277 ("pc-bios/s390-ccw: zero out bss section"), we are clearing now the BSS in start.S, so there is no need to pre-initialize the loadparm_str array with zeroes anymore. Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-05-08s390-bios: Skip bootmap signature entriesJason J. Herne
Newer versions of zipl have the ability to write signature entries to the boot script for secure boot. We don't yet support secure boot, but we need to skip over signature entries while reading the boot script in order to maintain our ability to boot guest operating systems that have a secure bootloader. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Reviewed-by: Farhan Ali <alifm@linux.ibm.com> Message-Id: <1556543381-12671-1-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-05-08pc-bios/s390-ccw: Clean up harmless misuse of isdigit()Markus Armbruster
atoui() and get_index() pass char values to isdigit(). With a standard isdigit(), we'd get undefined behavior when the value is negative. Can't happen as char is unsigned on s390x. Even if it ould, we're actually using isdigit() from pc-bios/s390-ccw/libc.h here, which works fine for negative values. Clean up anyway, just to avoid setting a bad example. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20190418145355.21100-6-armbru@redhat.com> [thuth: updated the commit message] Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: Use control unit type to find bootable devicesJason J. Herne
When the user does not specify which device to boot from then we end up guessing. Instead of simply grabbing the first available device let's be a little bit smarter and only choose devices that might be bootable like disk, and not console devices. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Message-Id: <1554388475-18329-17-git-send-email-jjherne@linux.ibm.com> [thuth: Added fix for virtio_is_supported() not being called anymore] Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: Support booting from real dasd deviceJason J. Herne
Allows guest to boot from a vfio configured real dasd device. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <1554388475-18329-16-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: Add channel command codes/structs needed for dasd-iplJason J. Herne
The dasd IPL procedure needs to execute a few previously unused channel commands. Let's define them and their associated data structures. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Acked-by: Cornelia Huck <cohuck@redhat.com> Acked-by: Thomas Huth <thuth@redhat.com> Message-Id: <1554388475-18329-15-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: Use control unit type to determine boot methodJason J. Herne
The boot method is different depending on which device type we are booting from. Let's examine the control unit type to determine if we're a virtio device. We'll eventually add a case to check for a real dasd device here as well. Since we have to call enable_subchannel() in main now, might as well remove that call from virtio.c : run_ccw(). This requires adding some additional enable_subchannel calls to not break calls to virtio_is_supported(). Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <1554388475-18329-14-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: Refactor virtio to run channel programs via cioJason J. Herne
Now that we have a Channel I/O library let's modify virtio boot code to make use of it for running channel programs. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Acked-by: Thomas Huth <thuth@redhat.com> Message-Id: <1554388475-18329-13-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: Factor finding boot device out of virtio code pathJason J. Herne
Make a new routine find_boot_device to locate the boot device for all cases, not just virtio. The error message for the case where no boot device has been specified and a suitable boot device cannot be auto detected was specific to virtio devices. We update this message to remove virtio specific wording. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Reviewed-by: Farhan Ali <alifm@linux.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <1554388475-18329-12-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: Extend find_dev() for non-virtio devicesJason J. Herne
We need a method for finding the subchannel of a dasd device. Let's modify find_dev to handle this since it mostly does what we need. Up to this point find_dev has been specific to only virtio devices. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Acked-by: Halil Pasic <pasic@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <1554388475-18329-11-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: cio error handlingJason J. Herne
Add verbose error output for when unexpected i/o errors happen. This eases the burden of debugging and reporting i/o errors. No error information is printed in the success case, here is an example of what is output on error: cio device error ssid : 0x0000000000000000 cssid : 0x0000000000000000 sch_no: 0x0000000000000000 Interrupt Response Block Data: Function Ctrl : [Start] Activity Ctrl : [Start-Pending] Status Ctrl : [Alert] [Primary] [Secondary] [Status-Pending] Device Status : [Unit-Check] Channel Status : cpa=: 0x000000007f8d6038 prev_ccw=: 0x0000000000000000 this_ccw=: 0x0000000000000000 Eckd Dasd Sense Data (fmt 32-bytes): Sense Condition Flags : Residual Count =: 0x0000000000000000 Phys Drive ID =: 0x000000000000009e low cyl address =: 0x0000000000000000 head addr & hi cyl =: 0x0000000000000000 format/message =: 0x0000000000000008 fmt-dependent[0-7] =: 0x0000000000000004 fmt-dependent[8-15]=: 0xe561282305082fff prog action code =: 0x0000000000000016 Configuration info =: 0x00000000000040e0 mcode / hi-cyl =: 0x0000000000000000 cyl & head addr [0]=: 0x0000000000000000 cyl & head addr [1]=: 0x0000000000000000 cyl & head addr [2]=: 0x0000000000000000 The Sense Data section is currently only printed for ECKD DASD. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <1554388475-18329-10-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: Support for running format-0/1 channel programsJason J. Herne
Introduce a library function for executing format-0 and format-1 channel programs and waiting for their completion before continuing execution. Add cu_type() to channel io library. This will be used to query control unit type which is used to determine if we are booting a virtio device or a real dasd device. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Farhan Ali <alifm@linux.ibm.com> Message-Id: <1554388475-18329-9-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: ptr2u32 and u32toptrJason J. Herne
Introduce inline functions to convert between pointers and unsigned 32-bit ints. These are used to hide the ugliness required to avoid compiler warnings. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Acked-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <1554388475-18329-8-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: Map low core memoryJason J. Herne
Create a new header for basic architecture specific definitions and add a mapping of low core memory. This mapping will be used by the real dasd boot process. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Acked-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <1554388475-18329-7-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: Decouple channel i/o logic from virtioJason J. Herne
Create a separate library for channel i/o related code. This decouples channel i/o operations from virtio and allows us to make use of them for the real dasd boot path. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <1554388475-18329-6-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: Clean up cio.hJason J. Herne
Add proper typedefs to all structs and modify all bit fields to use consistent formatting. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Reviewed-by: Collin Walling <walling@linux.ibm.com> Reviewed-by: Farhan Ali <alifm@linux.ibm.com> Acked-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <1554388475-18329-5-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: decouple common boot logic from virtioJason J. Herne
Create a boot_setup function to handle getting boot information from the machine/hypervisor. This decouples common boot logic from the virtio code path and allows us to make use of it for the real dasd boot scenario. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Acked-by: Halil Pasic <pasic@linux.vnet.ibm.com> Reviewed-by: Collin Walling <walling@linux.ibm.com Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Farhan Ali <alifm@linux.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <1554388475-18329-4-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-04-12s390-bios: decouple cio setup from virtioJason J. Herne
Move channel i/o setup code out to a separate function. This decouples cio setup from the virtio code path and allows us to make use of it for booting dasd devices. Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com> Acked-by: Halil Pasic <pasic@linux.vnet.ibm.com> Reviewed-by: Collin Walling <walling@linux.ibm.com> Reviewed-by: Farhan Ali <alifm@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <1554388475-18329-3-git-send-email-jjherne@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2019-01-18pc-bios/s390-ccw: Use proper register names for ClangThomas Huth
When compiling the s390-ccw firmware with Clang 7.0.1, I get the following errors: pc-bios/s390-ccw/start.S:62:19: error: invalid use of length addressing stctg 0,0,0(15) ^ pc-bios/s390-ccw/start.S:63:12: error: invalid use of length addressing oi 6(15), 0x2 ^ pc-bios/s390-ccw/start.S:64:19: error: invalid use of length addressing lctlg 0,0,0(15) ^ pc-bios/s390-ccw/start.S:76:19: error: invalid use of length addressing stctg 0,0,0(15) ^ pc-bios/s390-ccw/start.S:77:12: error: invalid use of length addressing ni 6(15), 0xfd ^ pc-bios/s390-ccw/start.S:78:19: error: invalid use of length addressing lctlg 0,0,0(15) ^ pc-bios/s390-ccw/start.S:79:12: error: invalid operand for instruction br 14 ^ Let's use proper register names like in the rest of this file to fix it. Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <1547123559-30476-1-git-send-email-thuth@redhat.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2018-06-18pc-bios/s390-ccw: Optimize the s390-netboot.img for sizeThomas Huth
The -O2 optimization flag is passed via CFLAGS to the firmware Makefile, but in netbook.mak, we've got some rules that only use QEMU_CFLAGS for compiling the libc and libnet from SLOF, so these files get compiled without optimization so far. Use CFLAGS here, too, to create faster and smaller code. We can additionally save some more bytes in the firmware images by compi- ling the code with -fno-asynchronous-unwind-tables. This will omit some ELF sections (used for stack unwinding for example) from the image that we do not need in the firmware. Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-06-18pc-bios/s390-ccw/net: Try to load pxelinux.cfg file accoring to the UUIDThomas Huth
With the STSI instruction, we can get the UUID of the current VM instance, so we can support loading pxelinux config files via UUID in the file name, too. Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Tested-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-06-18pc-bios/s390-ccw/net: Add support for pxelinux-style config filesThomas Huth
Since it is quite cumbersome to manually create a combined kernel with initrd image for network booting, we now support loading via pxelinux configuration files, too. In these files, the kernel, initrd and command line parameters can be specified seperately, and the firmware then takes care of glueing everything together in memory after the files have been downloaded. See this URL for details about the config file layout: https://www.syslinux.org/wiki/index.php?title=PXELINUX The user can either specify a config file directly as bootfile via DHCP (but in this case, the file has to start either with "default" or a "#" comment so we can distinguish it from binary kernels), or a folder (i.e. the bootfile name must end with "/") where the firmware should look for the typical pxelinux.cfg file names, e.g. based on MAC or IP address. We also support the pxelinux.cfg DHCP options 209 and 210 from RFC 5071. Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Tested-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-06-18pc-bios/s390-ccw/net: Update code for the latest changes in SLOFThomas Huth
The ip_version information now has to be stored in the filename_ip_t structure, and there is now a common function called tftp_get_error_info() which can be used to get the error string for a TFTP error code. We can also get rid of some superfluous "(char *)" casts now. Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Tested-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-06-18pc-bios/s390-ccw: define loadparm lengthCollin Walling
Loadparm is defined by the s390 architecture to be 8 bytes in length. Let's define this size in the s390-ccw bios. Suggested-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Collin Walling <walling@linux.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-05-14pc-bios/s390-ccw: struct tpi_info must be declared as aligned(4)Thomas Huth
I've run into a compilation error today with the current version of GCC 8: In file included from s390-ccw.h:49, from main.c:12: cio.h:128:1: error: alignment 1 of 'struct tpi_info' is less than 4 [-Werror=packed-not-aligned] } __attribute__ ((packed)); ^ cc1: all warnings being treated as errors Since the struct tpi_info contains an element ("struct subchannel_id schid") which is marked as aligned(4), we've got to mark the struct tpi_info as aligned(4), too. CC: qemu-stable@nongnu.org Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <1525774672-11913-1-git-send-email-thuth@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2018-05-02s390-ccw: force diag 308 subcode to unsigned longCornelia Huck
We currently pass an integer as the subcode parameter. However, the upper bits of the register containing the subcode need to be 0, which is not guaranteed unless we explicitly specify the subcode to be an unsigned long value. Fixes: d046c51dad3 ("pc-bios/s390-ccw: Get device address via diag 308/6") Cc: qemu-stable@nongnu.org Signed-off-by: Cornelia Huck <cohuck@redhat.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Tested-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-05-02pc-bios/s390-ccw/net: Add support for .INS config filesThomas Huth
The .INS config files can normally be found on CD-ROM ISO images, so by supporting these files, it is now possible to boot directly when the TFTP server is set up with the contents of such an CD-ROM image. Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-05-02pc-bios/s390-ccw/net: Use diag308 to reset machine before jumping to the OSThomas Huth
The netboot firmware so far simply jumped directly into the OS kernel after the download has been completed. This, however, bears the risk that the virtio-net device still might be active in the background and incoming packets are still placed into the buffers - which could destroy memory of the now-running Linux kernel in case it did not take over the device fast enough. Also the SCLP console is not put into a well-defined state here. We should hand over the system in a clean state when jumping into the kernel, so let's use the same mechanism as it's done in the main s390-ccw firmware and reset the machine with diag308 into a clean state before jumping into the OS kernel code. To be able to share the code with the main s390-ccw firmware, the related functions are now extracted from bootmap.c into a new file called jump2ipl.c. Since we now also set the boot device schid at address 184 for the network boot device, this patch also slightly changes the way how we detect the entry points for non-ELF binary images: The code now looks for the "S390EP" magic first and then jumps to 0x10000 in case it has been found. This is necessary for booting from network devices, since the normal kernel code (where the PSW at ddress 0 points to) tries to do a block load from the boot device. This of course fails for a virtio-net device and causes the kernel to abort with a panic-PSW silently. Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-05-02pc-bios/s390-ccw/net: Split up net_load() into init, load and release partsThomas Huth
When we want to support pxelinux-style network booting later, we've got to do several TFTP transfers - and we do not want to apply for a new IP address via DHCP each time. So split up net_load into three parts: 1. net_init(), which initializes virtio-net, gets an IP address via DHCP and prints out the related information. 2. The tftp_load call is now moved directly into the main() function 3. A new net_release() function which should tear down the network stack before we are done in the firmware. This will make it easier to extend the code in the next patches. Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-05-02pc-bios/s390-ccw: fix non-sequential boot entries (enum)Collin Walling
zIPL boot menu entries can be non-sequential. Let's account for this issue for the s390 enumerated boot menu. Since we can no longer print a range of available entries to the user, we have to present a list of each available entry. An example of this menu: s390-ccw Enumerated Boot Menu. [0] default [1] [2] [7] [8] [9] [11] [12] Please choose: Signed-off-by: Collin Walling <walling@linux.ibm.com> Reported-by: Vasily Gorbik <gor@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-05-02pc-bios/s390-ccw: fix non-sequential boot entries (eckd)Collin Walling
zIPL boot menu entries can be non-sequential. Let's account for this issue for the s390 zIPL boot menu. Since this boot menu is actually an imitation and is not completely capable of everything the real zIPL menu can do, let's also print a different banner to the user. Signed-off-by: Collin Walling <walling@linux.ibm.com> Reported-by: Vasily Gorbik <gor@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-05-02pc-bios/s390-ccw: fix loadparm initialization and int conversionCollin Walling
Rename the loadparm char array in main.c to loadparm_str and increased the size by one byte to account for a null termination when converting the loadparm string to an int via atoui. We also allow the boot menu to be enabled when loadparm is set to an empty string or a series of spaces. Signed-off-by: Collin Walling <walling@linux.ibm.com> Reported-by: Vasily Gorbik <gor@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-05-02pc-bios/s390-ccw: rename MAX_TABLE_ENTRIES to MAX_BOOT_ENTRIESCollin Walling
The MAX_TABLE_ENTRIES constant has a name that is too generic. As we want to declare a limit for boot menu entries, let's rename it to a more fitting MAX_BOOT_ENTRIES and set its value to 31 (30 boot entries and 1 default entry). Also we move it from bootmap.h to s390-ccw.h to make it available for menu.c in a later patch. Signed-off-by: Collin Walling <walling@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>