summaryrefslogtreecommitdiffstats
path: root/pc-bios/s390-ccw/virtio.c
Commit message (Collapse)AuthorAgeFilesLines
* pc-bios: s390x: Consolidate timing functions into time.hJanosch Frank2020-07-021-15/+3Star
| | | | | | | | | | 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>
* s390-bios: Use control unit type to determine boot methodJason J. Herne2019-04-121-1/+0Star
| | | | | | | | | | | | | | | | | | 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>
* s390-bios: Refactor virtio to run channel programs via cioJason J. Herne2019-04-121-30/+27Star
| | | | | | | | | | | 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>
* s390-bios: Decouple channel i/o logic from virtioJason J. Herne2019-04-121-25/+2Star
| | | | | | | | | | | | 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>
* pc-bios/s390-ccw: Increase virtio timeout to 30 secondsThomas Huth2018-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | The current timeout is set to only three seconds - and considering that vring_wait_reply() or rather get_second() is not doing any rounding, the real timeout is likely rather 2 seconds in most cases. When the host is really badly loaded, it's possible that we hit this timeout by mistake; it's even more likely if we run the guest in TCG mode instead of KVM. So let's increase the timeout to 30 seconds instead to ease this situation (30 seconds is also the timeout that is used by the Linux SCSI subsystem for example, so this seems to be a sane value for block IO timeout). Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1549079 Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <1522316251-16399-1-git-send-email-thuth@redhat.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> [CH: tweaked commit message] Signed-off-by: Cornelia Huck <cohuck@redhat.com>
* s390-ccw: read user input for boot index via the SCLP consoleCollin L. Walling2018-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Implements an sclp_read function to capture input from the console and a wrapper function that handles parsing certain characters and adding input to a buffer. The input is checked for any erroneous values and is handled appropriately. A prompt will persist until input is entered or the timeout expires (if one was set). Example: Please choose (default will boot in 10 seconds): Correct input will boot the respective boot index. If the user's input is empty, 0, or if the timeout expires, then the default zipl entry will be chosen. If the input is within the range of available boot entries, then the selection will be booted. Any erroneous input will cancel the timeout and re-prompt the user. Signed-off-by: Collin L. Walling <walling@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
* pc-bios/s390-ccw: Add virtio-net driver codeThomas Huth2017-07-141-0/+5
| | | | | | | | | | | The driver provides the recv() and send() functions which will be required by SLOF's libnet code for receiving and sending packets. Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <1499863793-18627-11-git-send-email-thuth@redhat.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* pc-bios/s390-ccw: Add code for virtio feature negotiationThomas Huth2017-07-141-6/+17
| | | | | | | | | | The upcoming virtio-net driver needs to negotiate some features, so we need the possibility to do this in the core virtio code. Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <1499863793-18627-8-git-send-email-thuth@redhat.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* pc-bios/s390-ccw: Move virtio-block related functions into a separate fileThomas Huth2017-07-141-271/+6Star
| | | | | | | | | | | The netboot code is going to link against the code from virtio.c, too, so we've got to move the virtio-block and -scsi related code out of the way. Reviewed-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <1499863793-18627-4-git-send-email-thuth@redhat.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* pc-bios/s390-ccw: Move libc functions to separate headerThomas Huth2017-07-141-0/+1
| | | | | | | | | | | | | | The upcoming netboot code will use the libc from SLOF. To be able to still use s390-ccw.h there, the libc related functions in this header have to be moved to a different location. And while we're at it, remove the duplicate memcpy() function from sclp.c. Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <1499863793-18627-2-git-send-email-thuth@redhat.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* pc-bios/s390-ccw: Use the ccw bios to start the network bootFarhan Ali2017-02-281-0/+1
| | | | | | | | | | | We want to use the ccw bios to start final network boot. To do this we use ccw bios to detect if the boot device is a virtio network device and retrieve the start address of the network boot image. Signed-off-by: Farhan Ali <alifm@linux.vnet.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* pc-bios/s390-ccw: enable subchannel for IPL I/O devicesDong Jia Shi2016-09-281-1/+2
| | | | | | | | | | | | | | | | | | IPL should cause the IPL I/O device to become enabled. So when handling the IPL program, we should set the E (Enable) bit. However, virtio-ccw does not know whether it's dealing with an IPL device or not. Since trying to perform I/O on a disabled device doesn't make any sense, let's just always enable it. At the same time we can remove the SCSW_FCTL_START_FUNC flag as it is ignored for msch anyway and did not enable the device as intended. Reported-by: Farhan Ali <alifm@linux.vnet.ibm.com> Signed-off-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com> Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com> [remove superfluous flag] Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* pc-bios/s390-ccw: enable virtio-scsiEugene (jno) Dvurechenski2016-03-231-32/+81
| | | | | | | Make the code added before to work. Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* pc-bios/s390-ccw: add simplified virtio callEugene (jno) Dvurechenski2016-03-231-0/+17
| | | | | | | Add virtio_run(VirtioCmd) call to use simple declarative approach. Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* pc-bios/s390-ccw: make provisions for different backendsEugene (jno) Dvurechenski2016-03-231-38/+92
| | | | | | | Add dispatching code to make room for non virtio-blk boot devices. Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* pc-bios/s390-ccw: add vdev object to store all device detailsEugene (jno) Dvurechenski2016-03-231-83/+98
| | | | | | | | | | | Add VDev "object" as a container for all device-related items. The default object is static. Leverage dependency on many different device-related globals. Make them syntactically visible. Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* pc-bios/s390-ccw: update virtio implementation to allow up to 3 vringsEugene (jno) Dvurechenski2016-03-231-54/+86
| | | | | | | | | | | Add ability to work with up to 3 vrings, which is required for virtio-scsi implementation. Implement the optional cookie to speed up processing of virtio notifications. Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* pc-bios/s390-ccw: qemuize typesEugene (jno) Dvurechenski2016-03-231-23/+23
| | | | | | | | | | | | | | | Turn [the most of] existing declarations from struct type_name { ... }; into struct TypeName { ... }; typedef struct TypeName TypeName; and make use of them. Also switch u{8,16,32,64} to uint{8,16,32,64}_t. Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* pc-bios/s390-ccw: add utility functions and "export" some othersEugene (jno) Dvurechenski2016-03-231-1/+1
| | | | | | | | | Add several utility functions, make IPL_check and IPL_assert generally available, etc. Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* pc-bios/s390-ccw: virtio_panic -> panicEugene (jno) Dvurechenski2016-03-231-4/+4
| | | | | | | | | This function has nothing to do with virtio. Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* pc-bios/s390-ccw: ISO-9660 El Torito boot implementationMaxim Samoylov2015-11-111-0/+7
| | | | | | | | | | | | | | | This patch enables boot from media formatted according to ISO-9660 and El Torito bootable CD specification. We try to boot from device as ISO-9660 media when SCSI IPL failed. The first boot catalog entry with bootable flag is used. ISO-9660 media with default 2048-bytes sector size only is supported. Signed-off-by: Maxim Samoylov <max7255@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* s390-ccw.img: Reinitialize guessing on rebootChristian Borntraeger2015-03-101-0/+1
| | | | | | | | | | | | | guessed_disk_nature is a static zero variable. As the QEMU ELF loader does not zero the BSS section, lets do it explicitely here. This fixes reboot for some corner cases (like FCP flash devices with logical_block_size=512, physical_block_size=4096) Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Tested-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Message-Id: <1425310029-53396-3-git-send-email-borntraeger@de.ibm.com>
* s390-ccw.img: Allow bigger ramdisk sizes or offsetsChristian Borntraeger2015-03-101-2/+2
| | | | | | | | | | | | | | | | | The s390-ccw bios creates the the virtqueue at 100MB. For big ramdisks or offsets (via zipl) this gets overwritten. As a quick band-aid, lets move the virtqueue into the bss section, which is at 0x7f00000. As the bios code (text) is at 0x7e00000 we can now handle ramdisk which are ~27MB bigger. Long term we want to make the s390-ccw bios position independent and load of at the end of memory. Reported-by: Alexander Graf <agraf@suse.de> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Message-Id: <1425310029-53396-2-git-send-email-borntraeger@de.ibm.com>
* pc-bios/s390-ccw: fix sparse warningsChristian Borntraeger2015-02-031-1/+1
| | | | | | | Fix some sparse warnings in the s390-ccw bios. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* pc-bios/s390-ccw Really big EAV ECKD DASD handlingEugene (jno) Dvurechenski2014-09-011-5/+6
| | | | | | | | | | | | | For EAV ECKD DASD, the cylinder count will have the magic value 0xfffeU. Therefore, use the block number to test for valid eckd addresses instead. Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* pc-bios/s390-ccw: handle more ECKD DASD block sizesEugene (jno) Dvurechenski2014-09-011-3/+24
| | | | | | | | | | | | | | | Using dasdfmt(8) to format a DASD allows to choose a block size. There are four supported values: 512, 1024, 2048, and 4096 bytes per block. Each block size leads to selection of new count of sectors per track. The head count remains always the same: 15. This empiric knowledge is used to detect ECKD DASD to IPL from. Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* pc-bios/s390-ccw: support all virtio block sizeEugene (jno) Dvurechenski2014-09-011-6/+8
| | | | | | | | | | | | | | | | | | The block size value may be given "as is" OR as a base value and a shift count (exponent). So, we have to use calculation to get the proper number in the code. The main expression reads as (blk_cfg.blk_size << blk_cfg.physical_block_exp) E.g., various combinations between blk_size=1/physical_block_exp=12 and blk_size=4096/physical_block_exp=0 are valid for 4K blocks. Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* pc-bios/s390-ccw: handle different sector sizesEugene (jno) Dvurechenski2014-06-271-5/+91
| | | | | | | | | | | Use the virtio device's configuration to figure out the disk geometry and use a sector size based upon the layout. [CH: s/SECTOR_SIZE/MAX_SECTOR_SIZE/g] Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* pc-bios/s390-ccw: make checkpatch happyEugene (jno) Dvurechenski2014-06-271-13/+13
| | | | | | | | | Remove tabs, tweak whitespace and comments. Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* pc-bios/s390-ccw: virtio_load_direct() can't load max number of sectorsDavid Hildenbrand2014-06-231-1/+1
| | | | | | | | | | | | | | | The number of sectors to read is given by the last 16 bit of rec_list2. 1 is added in order to get to the real number of sectors to read (0x0000 -> read 1 block). For now, the maximum number (0xffff) led to 0 sectors being read. This fixes a bug where a large initrd (62MB) could not be ipled anymore. Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Alexander Graf <agraf@suse.de> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* s390-ccw.img: Fix sporadic reboot hangs: Initialize next_idxChristian Borntraeger2014-02-271-0/+1
| | | | | | | | | | The current code does not initialize next_idx in the virtio ring. As the ccw bios will always use guest memory at a fixed location, this queue might != 0 after a reboot. Lets make the initialization explicit. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* s390/ipl: Fix waiting for virtio processingCornelia Huck2013-09-201-3/+4
| | | | | | | | | The guest side must not manipulate the index for the used buffers. Instead, remember the state of the used buffer locally and wait until it has moved. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
* s390/IPL: Allow boot from other ssid than 0Dominik Dingel2013-07-291-0/+18
| | | | | | | | | | We now take the subchannel set id also into account to find the boot device. If we want to use a subchannel set other than the default set 0, we first need to enable the mss facility. Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>
* s390/ipl: Fix spurious errors in virtioChristian Borntraeger2013-05-311-0/+5
| | | | | | | | | | | | | | | | With the ccw ipl code sometimes an error message like "virtio: trying to map MMIO memory" or "Guest moved used index from %u to %u" appeared. Turns out that the ccw bios did not zero out the vring, which might cause stale values in avail->idx and friends, especially on reboot. Lets zero out the relevant fields. To activate the patch we need to rebuild s390-ccw.img as well. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Message-id: 1369309901-418-1-git-send-email-borntraeger@de.ibm.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* s390-ccw.img: Get queue config from host.Cornelia Huck2013-04-261-3/+7
| | | | | | | Ask the host about the configuration instead of guessing it. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>
* s390-ccw.img: Rudimentary error checking.Cornelia Huck2013-04-261-6/+15
| | | | | | | Try to handle at least some of the errors that may happen. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>
* s390-ccw.img: Enhance drain_irqs().Cornelia Huck2013-04-261-2/+11
| | | | | | | | - Use tpi + tsch to get interrupts. - Return an error if the irb indicates problems. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>
* s390-ccw.img: Fix compile warning in s390 ccw virtio codeChristian Borntraeger2013-04-261-1/+3
| | | | | | | | | | | Lets fix this gcc warning: virtio.c: In function ‘vring_send_buf’: virtio.c:125:35: error: operation on ‘vr->next_idx’ may be undefined [-Werror=sequence-point] Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>
* S390: ccw firmware: Add virtio device driversAlexander Graf2013-04-261-0/+274
In order to boot, we need to be able to access a virtio-blk device through the CCW bus. Implement support for this. Signed-off-by: Alexander Graf <agraf@suse.de>