aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2019-11-18Revert "config: Add toggle for bootdevice information"Gerd Hoffmann2-16/+0
This reverts commit cb56f61c109985ad71078b1fb2e65bd4d6ed1a59.
2019-11-18Revert "geometry: Apply LCHS values for boot devices"Gerd Hoffmann11-42/+1
This reverts commit 9caa19be0e534c687081fbdfcd301406e728c98c.
2019-11-13tcgbios: Check for enough bytes returned from TPM2_GetCapabilityStefan Berger1-2/+11
When querying a TPM 2.0 for its PCRs, make sure that we get enough bytes from it in a response that did not indicate a failure. Basically we are defending against a TPM 2.0 sending responses that are not compliant to the specs. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-11-13tpm: Require a response to have minimum size of a valid response headerStefan Berger1-1/+2
Defend against a broken TPM 1.2 or TPM 2.0 that doesn't send at least a full response header in the response but less than 10 bytes. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-11-13ahci: zero-initialize port structGerd Hoffmann1-0/+1
Specifically port->drive.lchs needs clearing, otherwise seabios will try interpret whatever random crap happens to be there as disk geometry, which may or may not break boot depending on how lucky you are. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2019-11-06geometry: Apply LCHS values for boot devicesSam Eiderman11-1/+42
Boot devices which use overriden LCHS values are: * ata * ahci * scsi * esp * lsi * megasas * mpt * pvscsi * virtio * virtio-blk We use these values in get_translation() and setup_translation() by introducing a new translation type: "TRANSLATION_MACHINE". We treat this translation as TRANSLATION_NONE in fill_ata_edd(), although this does not really matter since now the translation between physical and logical geometry does not exist. Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> Message-Id: <20190612093704.47175-6-shmuel.eiderman@oracle.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-11-06config: Add toggle for bootdevice informationSam Eiderman2-0/+16
Add the "BOOTDEVICES" toggle to remove boot device information received through fw_cfg. We will use this toggle in QEMU to reduce the size of the 128k SeaBIOS rom, which is only used in old compat versions, where this boot device information does not exist. Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> Message-Id: <20190612093704.47175-5-shmuel.eiderman@oracle.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-11-06geometry: Add boot_lchs_find_*() utility functionsSam Eiderman2-0/+88
Adding the following utility functions: * boot_lchs_find_pci_device * boot_lchs_find_scsi_device * boot_lchs_find_ata_device These will be used to apply LCHS values received through fw_cfg. Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> Message-Id: <20190612093704.47175-4-shmuel.eiderman@oracle.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-11-06boot: Reorder functions in boot.cSam Eiderman1-45/+49
Currently glob_prefix() and build_pci_path() are under the "Boot priority ordering" section. Move them to a new "Helper search functions" section since we will reuse them in the next commit. Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> Message-Id: <20190612093704.47175-3-shmuel.eiderman@oracle.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-11-06geometry: Read LCHS from fw_cfgSam Eiderman1-0/+87
Read boot device information from fw_cfg. Boot device information will contain logical geometry (LCHS) values, but it is implemented in a manner which allows extension. By receiving LCHS values directly from QEMU through fw_cfg we will be able to support logical geometries which can not be inferred by SeaBIOS itself. (For instance: A 8GB virtio-blk hard drive which was originally created as an IDE and must report LCHS of */32/63 for its operating system to function will always break under SeaBIOS since a LARGE/LBA translation will be used, causing the number of reported logical heads to be > 32.) The only LCHS paravirtual interface available at the moment is for IDE disks (rtc_read() in get_translation()) and it's limited to a maximum of 4 disks (this code existed in SeaBIOS's translation function before SCSI and VirtIO were even introduced). This is why we create a new interface which allows passing LCHS information per hdd. As mentioned, this interface may be easily extended to support more information per hdd. Boot device information is serialized in the following way: * struct_size (u32) * device path (sz string) * device information (struct_size) ... * device path (sz string) * device information (struct_size) Device path is a null terminated string in the "Open Firmware" device path format, the same path as used in bootorder. Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> Message-Id: <20190612093704.47175-2-shmuel.eiderman@oracle.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-10-28cp437: add license to cp437.cGerd Hoffmann1-0/+2
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-10-18virtio: extend virtio queue size to 256Denis Plotnikov1-1/+1
The goal of the patch is to work around a performance bug in guest linux kernels. Old linux kernels has a performance flaw in virtio block device access: on some frequent disk access patterns, e.g. 1M read, the kernel produces more block requests than needed. This happens because of virtio seg_max parameter set to 126 (virtqueue_size - 2) which limits the maximum block request to 516096 (126 * 4096_PAGE_SIZE) bytes. Setting seg_max > 126 fixes the issue, however, not all linux kernels allow that without increasing virtio virtqueue size. The old kernels have a restriction: virtqueue_size >= seg_max. In case of the restriction violation the old kernels crash. The restriction is relaxed in the recent linux kernels (ver >= 4.13) with: commit 44ed8089e991a60d614abe0ee4b9057a28b364e4 Author: Richard W.M. Jones Date: Thu Aug 10 17:56:51 2017 +0100 scsi: virtio: Reduce BUG if total_sg > virtqueue size to WARN. and the recent linux kernels don't crash if total_sg > virtqueue size allowing to set seg_max to the needed value without virtqueue size increasing. To fix the performance flaw in the old linux kernels, it's needed to increse seg_max to 254, and comply the restriction by setting virtqueue_size to 256. This is achievable if seabios can support virtqueue size > 128 which this patch actually does. Windows kernels don't have virtqueue_size >= seg_max restriction and isn't affected with this kind of the performance bug. Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-06-28csm: Fix boot priority translationDavid Woodhouse1-3/+20
Explicitly handle the BBS_DO_NOT_BOOT_FROM and BBS_IGNORE_ENTRY values. Also add one to the other priority values, as find_prio() does for entries from bootorder. SeaBIOS uses zero for an item explicitly selected in interactive_bootmenu(). Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2019-06-18csm: Sanitise alignment constraint in Legacy16GetTableAddressDavid Woodhouse1-2/+12
The alignment constraint is defined in the CSM specifications as "Bit mapped. First non-zero bit from the right is the alignment." Use __fls() to sanitise the alignment given that definition, since passing a non-power-of-two alignment to _malloc() isn't going to work well. And cope with being passed zero, which was happening for the E820 table allocation from EDK2. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2019-05-23virtio-pci: Use %pP format in dprintf() callsKevin O'Connor1-6/+4
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-05-23pciinit: Use %pP shorthand for printing device ids in intel_igd_setup()Kevin O'Connor1-12/+9
The hardcoded device names can cause false-positives on Windows bios version checks. Use the %pP format to avoid that. Reported-by: Sam Eiderman <shmuel.eiderman@oracle.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-05-22optionrom: disallow int19 redirect for pnp roms.Gerd Hoffmann1-0/+24
Check whenever pnp roms attempt to redirect int19, and in case it does log a message and undo the redirect. A pnp rom should not need this, we have BEVs and BCVs for that. Nevertheless there are roms in the wild which are redirecting int19. At least some BIOS implementations for physical hardware have a config option in the setup to allow/disallow int19 redirections, so just not allowing this seems to be the way to deal with this situation. Buglink: https://bugzilla.redhat.com//show_bug.cgi?id=1642135 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Tested-by: Matt DeVillier <matt.devillier@gmail.com>
2019-05-17bootmenu: add support for more than 9 entriesGerd Hoffmann1-18/+42
10th and following entries can be selected using letters. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-05-17add get_keystroke_full() helperGerd Hoffmann2-2/+15
Switch get_raw_keystroke() to return ax instead of ah, so it returns both scan code and ascii code of the key pressed. Add get_keystroke_full() function which passes up ax to the caller. The get_keystroke() function continues to return the scancode only like it did before. It is a thin wrapper around get_keystroke_full() now though. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-05-07smbios: Add missing zero byte to Type 0Sam Eiderman1-0/+4
According to SMBIOS Specification, section 6.1.3 Text Strings: "Text strings associated with a given SMBIOS structure are returned in the dmiStructBuffer, appended directly after the formatted portion of the structure. This method of returning string information eliminates the need for application software to deal with pointers embedded in the SMBIOS structure. Each string is terminated with a null (00h) BYTE and the set of strings is terminated with an additional null (00h) BYTE” Furthermore: "If the formatted portion of the structure contains string-reference fields and all the string fields are set to 0 (no string references), the formatted section of the structure is followed by two null (00h) BYTES" From the above it can be seen that any SMBIOS type which contains string references should end with an additional zero byte. This is currently handled in all SMBIOS types which use load_str_field_with_default() besides type0. Therefore, add the missing zero byte to SMBIOS Type 0. Running QEMU with: -machine pc-i440fx-2.0 (for legacy smbios) -smbios type=0,vendor=,version=,date= (for zero str_index) Will cause SMBIOS type0 entry to overrun type1 entry. Reviewed-by: Mark Kanda <mark.kanda@oracle.com> Reviewed-by: Ross Philipson <ross.philipson@oracle.com> Reviewed-By: Liran Alon <liran.alon@oracle.com> Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com>
2019-02-04tcgbios: Implement TPM 2.0 menu item to activate and deactivate PCR banksStefan Berger2-0/+240
Implement a TPM 2.0 menu item that allows a user to toggle the activation of PCR banks of the TPM 2.0. After successful activation we shut down the TPM 2.0 and reset the machine. Background: A TPM 2.0 may have multiple PCR banks, such as for SHA1, SHA256, SHA384, SHA512, and SM3-256. One or multiple of those banks may be active (by factory for example) and modifying the set of active PCR banks is only possible while in the firmware since it requires platform authorization. Platform authorization is not possible for a user when in the OS since the firmware generates a random password for the platform authorization before booting the system and it throws that password away. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-02-04tcgbios: Use table to convert hash to buffer sizeStefan Berger1-13/+28
Use a table to convert the hash to the buffer size it needs. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-02-04usb-ehci: Clear pipe token on pipe reallocateKevin O'Connor1-0/+1
Make sure to clear the token before reuse as it may otherwise have an incorrect toggle setting. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-04bootsplash: Added support for 16/24/32bpp in one functionJoseph Pacheco-Corwin3-14/+13
Specifically added support for 16 and 32bpp files, in addition to 24bpp. The function bmp_show() in bmp.c has had the hardcoded check for 24bpp replaced with a general bpp check that uses a % to check for remainder, and returns 1 if the remainder is >0. The previous method for adjusting the BMP data (raw_data_format_adjust_24bpp) relied on a preset 3*bytes_per_line_src, this has been changed and the multiplication is now performed in the function's arguments. This change still allows someone else to reuse the same function for 1/2/4bpp support if necessary. The file util.h has been modified to reflect this decision. The changes to raw_data_format_adjust() is based on an abandoned patch by Gert Menke (submitted March 14, 2017), credit to them for that change and the addition of *bpp to bmp_get_info(). Signed-off-by: Joseph S. Pacheco-Corwin <hammersamatom@gmail.com>
2018-12-17output: Avoid thunking to 16bit mode in printf() if no vgabiosKevin O'Connor1-0/+3
It is not necessary to call the vgabios if no vgabios has been installed. This reduces the amount of hardware accesses on qemu when the bios is not initializing the display hardware, and it can reduce the boot time by a couple of milliseconds. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-12-10qemu: avoid debug prints if debugcon is not enabledStefano Garzarella4-2/+21
In order to speed up the boot phase, we can check the QEMU debugcon device, and disable the writes if it is not recognized. This patch allow us to save around 10 msec (time measured between SeaBIOS entry point and "linuxboot" entry point) when CONFIG_DEBUG_LEVEL=1 and debugcon is not enabled. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-11-27pvscsi: ring_desc do not have to be page alignedLiran Alon1-1/+1
In contrast to other allocations made by pvscsi_init_rings(), ring_desc is only used internally by SeaBIOS (not passed to device-controller) and there is not restriction which force it to be page aligned. Reviewed-by: Mark Kanda <mark.kanda@oracle.com> Signed-off-by: Liran Alon <liran.alon@oracle.com>
2018-11-27tpm: Check for TPM related ACPI tables before attempting hw probeStephen Douthit1-7/+7
Signed-off-by: Stephen Douthit <stephend@silicom-usa.com>
2018-11-10shadow: Rework bios copy code to prevent gcc array-bounds warningKevin O'Connor1-5/+6
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-11-10pvscsi: Scan all 64 possible targetsShmuel Eiderman1-1/+1
The max number of targets per PVSCSI controller is 64, not 7. This can easily be seen in QEMU PVSCSI emulation code (hw/scsi/vmw_pvscsi.c) as PVSCSI_MAX_DEVS, which defines the number of targets, have value of 64. Fixes: 83d60b3c474b ("Add pvscsi boot support") Reviewed-by: Liran Alon <liran.alon@oracle.com> Reviewed-by: Mark Kanda <mark.kanda@oracle.com> Signed-off-by: Shmuel Eiderman <shmuel.eiderman@oracle.com>
2018-10-05pretty boot menu entry for cdrom drivesGerd Hoffmann3-0/+57
Show the volume label of bootable cdroms. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-09-05pci: recognize RH PCI legacy bridge resource reservation capabilityJing Liu2-21/+30
Enable the firmware recognizing RedHat legacy PCI bridge device ID, so QEMU can reserve additional PCI bridge resource capability. Change the debug level lower to 3 when it is non-QEMU bridge. Signed-off-by: Jing Liu <jing2.liu@linux.intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Marcel Apfelbaum<marcel.apfelbaum@gmail.com> Message-id: 1535100781-3910-4-git-send-email-jing2.liu@linux.intel.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-09-05pci: clean up the debug message for pci capability foundJing Liu1-1/+3
Improve the debug message when QEMU resource reserve cap is not found and when the vendor-id or device-id does't match REDHAT special ones. Signed-off-by: Jing Liu <jing2.liu@linux.intel.com> Message-id: 1535100781-3910-3-git-send-email-jing2.liu@linux.intel.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-09-05pci: fix the return value for truncated capabilityJing Liu1-0/+1
Return zero when finding truncated capability. Signed-off-by: Jing Liu <jing2.liu@linux.intel.com> Message-id: 1535100781-3910-2-git-send-email-jing2.liu@linux.intel.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-09-03sdcard: Increase SDHCI_POWER_ON_TIME to 5msKevin O'Connor1-1/+1
It appears some sd cards need additional time to initialize after power on. Reported-by: Chris <coderight@gmail.com>. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-08-23nvme: fix I/O queue length calculation overflowMatt DeVillier1-2/+2
Commit cd47172 changed the I/O queue length calculation to use the Maximum Queue Entries Supported (MQES) value from the capabilities register, plus one, with a maximum value of NVME_PAGE_SIZE. An unintended effect from this is that due to length being an unsigned 16-bit int, a MQES value of 0xFFFF yields a length of zero, resulting in the queue allocation failing. Fix this by changing length to a u32. TEST: build/boot on a Purism Librem13v2 with a MyDigitalSSD BPX NVMe drive, which reports a MQES of 0xFFFF. Verify NVMe drive present in boot menu and OS boots successfully. Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
2018-07-15ssdt: Fix building of legacy acpi tables on current iasl compilerKevin O'Connor2-2/+2
Recent versions of the iasl compiler raise an error if the table id is longer than 8 characters. Older versions of iasl would silently truncate the table id to 8 characters. Change the ssdt-misc and ssdt-pcihp files to use an 8 character id - this should not directly impact the generated aml code as the table id was already being truncated - but may help those wishing to manually compile the tables. Reported by Michael Tokarev, Vivia Nikolaidou, and several others. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-22pmm: use tmp zone on oomGerd Hoffmann1-0/+13
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-06-22optionrom: enable non-vga display devicesGerd Hoffmann1-1/+28
In case no VGA device was found look for other display devices. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-04-12tpm: Request access to locality 0Stefan Berger1-0/+2
The CRB driver has to request access to locality 0. Our QEMU CRB model will enforce that as well. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-21tpm: when CRB is active, select, lock it, and check addressesStefan Berger1-3/+1
Do not just indicate that the probing for the CRB interface was successful if we find it active. Instead, select it, lock it, and test the addresses for whether they can be used (must be 32 bit). Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-21tpm: revert return values for successful/failed CRB probingStefan Berger1-3/+3
The return values for successful/failed CRB probing were reverted. Fix it. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-21tpm: Wait for tpmRegValidSts flag on CRB interface before probingStefan Berger1-0/+10
Wait for the tpmRegValidSts flag on the TPM_LOC_STATE_x register to be set; we expect the locAssigned flag to not be set. Real hardware seems to set the tpmRegValidSts flag without for example requesting access to a locality. Tested-by: Stephen Douthit <stephend@silicom-usa.com> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-02tpm: Handle unimplemented TIS_REG_IFACE_ID in tis_get_tpm_version()Stephen Douthit1-5/+15
If a device reports 0xf in the InterfaceType field of the TPM_INTERFACE_ID, then the rest of the fields are invalid, and the InterfaceVersion field of the TPM_INTF_CAPABILITY register must be checked instead. Signed-off-by: Stephen Douthit <stephend@silicom-usa.com> Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-02tpm: Wait for interface startup when probingStephen Douthit1-1/+12
This is based on wait_startup() from the Linux tpm_tis driver. Signed-off-by: Stephen Douthit <stephend@silicom-usa.com> Tested-by: Stephen Douthit <stephend@silicom-usa.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-03-02tpm: Refactor duplicated wait code in tis_wait_sts() & crb_wait_reg()Stephen Douthit1-47/+33
Signed-off-by: Stephen Douthit <stephend@silicom-usa.com> Tested-by: Stephen Douthit <stephend@silicom-usa.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-02-27tpm: add TPM CRB device supportMarc-André Lureau2-1/+221
The CRB device was introduced with TPM 2.0 to be physical-bus agnostic and defined in TCG PC Client Platform TPM Profile (PTP) Specification Family “2.0” Level 00 Revision 01.03 v22 It seems to be required with Windows 10. It is also a simpler device than FIFO/TIS. This patch only support locality 0 since also the CRB device in QEMU only supports this locality. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-02-27tpm: use get_tpm_version() callbackMarc-André Lureau1-1/+2
As originally intended. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-02-27tpm: generalize init_timeout()Marc-André Lureau1-10/+15
It seems both TIS & CRB devices share the same timeout. Make initialization function generic now. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-02-27x86: add readq()Marc-André Lureau1-0/+5
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>