Alexey Kirillov [Tue, 7 Jan 2020 17:19:17 +0000 (20:19 +0300)]
virtio: Do not init non-bootable devices
Because initializing a virtio-blk or virtio-scsi device requires a large
amount of memory, you cannot create more than about 10 virtio devices.
Since initialization is required for booting from media, we will not
initialize those devices that are not in the boot order list.
We use these values in get_translation() and setup_translation() by
introducing a new translation type: "TRANSLATION_HOST".
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: <20190626123816.8907-6-shmuel.eiderman@oracle.com>
Sam Eiderman [Wed, 26 Jun 2019 12:38:12 +0000 (15:38 +0300)]
geometry: Read LCHS from fw_cfg
Read bios geometry for boot devices from fw_cfg.
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.
Boot device information is serialized in the following way:
* device_path lcyls lheads lsecs\n
...
* device_path lcyls lheads lsecs\0
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: <20190626123816.8907-2-shmuel.eiderman@oracle.com>
Stefan Berger [Wed, 6 Nov 2019 21:36:00 +0000 (16:36 -0500)]
tcgbios: Check for enough bytes returned from TPM2_GetCapability
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>
Gerd Hoffmann [Wed, 13 Nov 2019 09:13:02 +0000 (10:13 +0100)]
ahci: zero-initialize port struct
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.
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>
Sam Eiderman [Wed, 12 Jun 2019 09:37:03 +0000 (12:37 +0300)]
config: Add toggle for bootdevice information
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>
Sam Eiderman [Wed, 12 Jun 2019 09:37:01 +0000 (12:37 +0300)]
boot: Reorder functions in boot.c
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>
Sam Eiderman [Wed, 12 Jun 2019 09:37:00 +0000 (12:37 +0300)]
geometry: Read LCHS from fw_cfg
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>
Uwe Kleine-König [Sun, 20 Oct 2019 20:07:26 +0000 (22:07 +0200)]
Remove dos line endings introduced in the last two commits
These were added somewhere between the mailing list server and Gerd's
working copy (as the patch I got via the mailing list is fine). These
don't disturb the compiler, but they look ugly so remove them.
Denis Plotnikov [Thu, 17 Oct 2019 14:01:00 +0000 (17:01 +0300)]
virtio: extend virtio queue size to 256
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:
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.
Kevin O'Connor [Wed, 21 Aug 2019 13:18:25 +0000 (09:18 -0400)]
Makefile: Build with -Wno-address-of-packed-member
Building with gcc v9 causes lots of warnings about pointers to packed
variables. However, SeaBIOS is limited to x86 where unaligned
reads/writes are supported by the cpu. So, disable that warning.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
David Woodhouse [Fri, 28 Jun 2019 13:57:47 +0000 (14:57 +0100)]
csm: Fix boot priority translation
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>
David Woodhouse [Thu, 13 Jun 2019 15:25:13 +0000 (16:25 +0100)]
csm: Sanitise alignment constraint in Legacy16GetTableAddress
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>
Gerd Hoffmann [Tue, 20 Nov 2018 07:06:55 +0000 (08:06 +0100)]
optionrom: disallow int19 redirect for pnp roms.
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.
Gerd Hoffmann [Tue, 19 Mar 2019 10:09:33 +0000 (11:09 +0100)]
vbe: add edid support.
VBE subfunction 0x15, read ddc data.
Add VBE_edid where drivers can fill in a EDID data blob.
If we find valid data there (checking the first two header
bytes), then report the function as supported and hand out
the data.
Sam Eiderman [Wed, 24 Apr 2019 14:04:09 +0000 (17:04 +0300)]
smbios: Add missing zero byte to Type 0
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>
Gerd Hoffmann [Mon, 25 Feb 2019 09:51:37 +0000 (10:51 +0100)]
vga: add atiext driver
Supports qemu emulated ati cards. They have been added in qemu 4.0.
Acceleration support (in qemu) is pretty rough still. A simple
framebuffer works fine though.
Stefan Berger [Wed, 30 Jan 2019 19:06:07 +0000 (14:06 -0500)]
tcgbios: Implement TPM 2.0 menu item to activate and deactivate PCR banks
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>
bootsplash: Added support for 16/24/32bpp in one function
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>
Kevin O'Connor [Mon, 17 Dec 2018 15:23:49 +0000 (10:23 -0500)]
output: Avoid thunking to 16bit mode in printf() if no vgabios
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>
qemu: avoid debug prints if debugcon is not enabled
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>
Liran Alon [Tue, 13 Nov 2018 15:53:40 +0000 (17:53 +0200)]
pvscsi: ring_desc do not have to be page aligned
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>
Shmuel Eiderman [Thu, 1 Nov 2018 15:14:42 +0000 (17:14 +0200)]
pvscsi: Scan all 64 possible targets
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>
Matt DeVillier [Tue, 11 Sep 2018 21:54:53 +0000 (16:54 -0500)]
SeaVGABios/cbvga: Fix bpp for coreboot framebuffer
Commit 4b42cc4 [SeaVGABios/cbvga: Advertise correct pixel format] neglected
to wrap the cbfb mask size components in GET_FARVAR(), which resulted in a
bogus value for bpp, breaking output on most/all devices. Fix this by
adding GET_FARVAR() as appropriate.
Additionally, some newer ChromeOS devices still fail even with this fix,
so fall back to using the coreboot reported bit depth if the calculated
valid is invalid.
TEST: build/boot a variety of devices (google/[reef,eve], purism/librem_skl)
using coreboot framebuffer init, verify SeaBIOS boot menu prompt visible.
Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
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.
Matt DeVillier [Tue, 21 Aug 2018 15:00:53 +0000 (10:00 -0500)]
nvme: fix I/O queue length calculation overflow
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>
Kevin O'Connor [Sun, 15 Jul 2018 14:05:14 +0000 (10:05 -0400)]
ssdt: Fix building of legacy acpi tables on current iasl compiler
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>
Gerd Hoffmann [Wed, 15 Nov 2017 13:43:10 +0000 (14:43 +0100)]
qemu: add qemu ramfb support
Add support for qemu ramfb. This is a simple boot framebuffer device,
with normal ram being used to back the framebuffer and fw_cfg being used
to configure the device.
Use case (on x86): boot display for vgpu devices (which neither emulate
vga nor have a vgabios).
Sharing fw_cfg code with seabios turned out to be difficuilt due to
various dependencies the code has on infrastructure which only seabios
has. So include a copy of the code here, with those dependencies
removed and also stripped down because we don't need a non-dma fallback
here.
Gerd Hoffmann [Wed, 15 Nov 2017 13:43:10 +0000 (14:43 +0100)]
qemu: add bochs-display support
Use coreboot text mode emulation to also support the qemu bochs-display
device. This is a new display device supporting simple linear
framebuffers, using the bochs register interface. No support for legacy
vga (text modes, planar modes, cga modes, 8bpp palette modes all
dropped). The bochs interface is compatible with the qemu stdvga.
Stefan Berger [Mon, 19 Mar 2018 16:00:29 +0000 (12:00 -0400)]
tpm: when CRB is active, select, lock it, and check addresses
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>
Stephen Douthit [Tue, 27 Feb 2018 19:17:11 +0000 (14:17 -0500)]
tpm: Handle unimplemented TIS_REG_IFACE_ID in tis_get_tpm_version()
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>
Stephen Douthit [Tue, 27 Feb 2018 19:17:10 +0000 (14:17 -0500)]
tpm: Wait for interface startup when probing
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>
Stephen Douthit [Tue, 27 Feb 2018 19:17:09 +0000 (14:17 -0500)]
tpm: Refactor duplicated wait code in tis_wait_sts() & crb_wait_reg()
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>
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>
Kevin O'Connor [Tue, 27 Feb 2018 16:27:59 +0000 (11:27 -0500)]
build: Use git describe --always
Add --always flag to "git describe" command to get a build identifier
even if one checks out the repo with a depth parameter that prunes out
the last tagged version.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>