2 weeks agotcgbios: Implement TPM 2.0 menu item to activate and deactivate PCR banks master github/master
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.


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 <>
2 weeks agotcgbios: Use table to convert hash to buffer size
Stefan Berger [Wed, 30 Jan 2019 19:06:06 +0000 (14:06 -0500)] 
tcgbios: Use table to convert hash to buffer size

Use a table to convert the hash to the buffer size it needs.

Signed-off-by: Stefan Berger <>
2 weeks agousb-ehci: Clear pipe token on pipe reallocate
Kevin O'Connor [Tue, 5 Feb 2019 02:22:15 +0000 (21:22 -0500)] 
usb-ehci: Clear pipe token on pipe reallocate

Make sure to clear the token before reuse as it may otherwise have an
incorrect toggle setting.

Signed-off-by: Kevin O'Connor <>
2 weeks agobootsplash: Added support for 16/24/32bpp in one function
Joseph Pacheco-Corwin [Tue, 29 Jan 2019 23:00:00 +0000 (23:00 +0000)] 
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 <>
4 weeks agodocs: Fix cut-and-paste error in archive link
Kevin O'Connor [Mon, 21 Jan 2019 18:17:11 +0000 (13:17 -0500)] 
docs: Fix cut-and-paste error in archive link

Signed-off-by: Kevin O'Connor <>
4 weeks agodocs: Update mailing list archive links
Kevin O'Connor [Sun, 20 Jan 2019 16:55:10 +0000 (11:55 -0500)] 
docs: Update mailing list archive links

Signed-off-by: Kevin O'Connor <>
2 months agooutput: Avoid thunking to 16bit mode in printf() if no vgabios
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 <>
2 months agoqemu: avoid debug prints if debugcon is not enabled
Stefano Garzarella [Sun, 2 Dec 2018 13:10:13 +0000 (14:10 +0100)] 
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 <>
Signed-off-by: Kevin O'Connor <>
2 months agopvscsi: ring_desc do not have to be page aligned
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 <>
Signed-off-by: Liran Alon <>
2 months agotpm: Check for TPM related ACPI tables before attempting hw probe
Stephen Douthit [Wed, 7 Mar 2018 18:17:36 +0000 (13:17 -0500)] 
tpm: Check for TPM related ACPI tables before attempting hw probe

Signed-off-by: Stephen Douthit <>
3 months agodocs: Note v1.12.0 release rel-1.12.0
Kevin O'Connor [Sat, 17 Nov 2018 16:05:59 +0000 (11:05 -0500)] 
docs: Note v1.12.0 release

Signed-off-by: Kevin O'Connor <>
3 months agoshadow: Rework bios copy code to prevent gcc array-bounds warning
Kevin O'Connor [Sat, 10 Nov 2018 18:47:56 +0000 (13:47 -0500)] 
shadow: Rework bios copy code to prevent gcc array-bounds warning

Signed-off-by: Kevin O'Connor <>
3 months agopvscsi: Scan all 64 possible targets
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 <>
Reviewed-by: Mark Kanda <>
Signed-off-by: Shmuel Eiderman <>
4 months agopretty boot menu entry for cdrom drives
Gerd Hoffmann [Fri, 21 Sep 2018 07:35:03 +0000 (09:35 +0200)] 
pretty boot menu entry for cdrom drives

Show the volume label of bootable cdroms.

Signed-off-by: Gerd Hoffmann <>
5 months agoSeaVGABios/cbvga: Fix bpp for coreboot framebuffer
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 <>
5 months agopci: recognize RH PCI legacy bridge resource reservation capability
Jing Liu [Fri, 24 Aug 2018 08:53:01 +0000 (16:53 +0800)] 
pci: recognize RH PCI legacy bridge resource reservation capability

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 <>
Reviewed-by: Laszlo Ersek <>
Reviewed-by: Marcel Apfelbaum<>
Signed-off-by: Gerd Hoffmann <>
5 months agopci: clean up the debug message for pci capability found
Jing Liu [Fri, 24 Aug 2018 08:53:00 +0000 (16:53 +0800)] 
pci: clean up the debug message for pci capability found

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 <>
Signed-off-by: Gerd Hoffmann <>
5 months agopci: fix the return value for truncated capability
Jing Liu [Fri, 24 Aug 2018 08:52:59 +0000 (16:52 +0800)] 
pci: fix the return value for truncated capability

Return zero when finding truncated capability.

Signed-off-by: Jing Liu <>
Signed-off-by: Gerd Hoffmann <>
5 months agosdcard: Increase SDHCI_POWER_ON_TIME to 5ms
Kevin O'Connor [Mon, 3 Sep 2018 21:32:44 +0000 (17:32 -0400)] 
sdcard: Increase SDHCI_POWER_ON_TIME to 5ms

It appears some sd cards need additional time to initialize after
power on.

Reported-by: Chris <>.
Signed-off-by: Kevin O'Connor <>
5 months agonvme: fix I/O queue length calculation overflow
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 <>
6 months agodocs: Update download file link
Kevin O'Connor [Thu, 9 Aug 2018 12:29:20 +0000 (08:29 -0400)] 
docs: Update download file link

Released versions are now at:

Signed-off-by: Kevin O'Connor <>
7 months agossdt: Fix building of legacy acpi tables on current iasl compiler
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 <>
7 months agocbvga_set_mode: refine clear display logic
Gerd Hoffmann [Fri, 22 Jun 2018 06:43:04 +0000 (08:43 +0200)] 
cbvga_set_mode: refine clear display logic

There is no need to skip text mode clearing.
Clearing the framebuffer should be safe on legacy calls too.

Signed-off-by: Gerd Hoffmann <>
7 months agoqemu: add qemu ramfb support
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

Signed-off-by: Gerd Hoffmann <>
7 months agovgasrc: add allocate_pmm()
Gerd Hoffmann [Fri, 15 Jun 2018 05:55:47 +0000 (07:55 +0200)] 
vgasrc: add allocate_pmm()

Factor out pmm allocation function from stack allocator.

Signed-off-by: Gerd Hoffmann <>
7 months agopmm: use tmp zone on oom
Gerd Hoffmann [Fri, 15 Jun 2018 10:07:34 +0000 (12:07 +0200)] 
pmm: use tmp zone on oom

Signed-off-by: Gerd Hoffmann <>
7 months agobochs_display_setup: return error on failure
Gerd Hoffmann [Fri, 15 Jun 2018 06:18:45 +0000 (08:18 +0200)] 
bochs_display_setup: return error on failure

Signed-off-by: Gerd Hoffmann <>
7 months agocbvga_set_mode: disable clearmem in windows x86 emulator.
Gerd Hoffmann [Wed, 30 May 2018 21:57:06 +0000 (23:57 +0200)] 
cbvga_set_mode: disable clearmem in windows x86 emulator.

Signed-off-by: Gerd Hoffmann <>
7 months agocbvga_list_modes: don't list current mode twice
Gerd Hoffmann [Wed, 30 May 2018 14:19:02 +0000 (16:19 +0200)] 
cbvga_list_modes: don't list current mode twice

In case we've already added the framebuffer video mode
to the list do not add number 0x140.

Signed-off-by: Gerd Hoffmann <>
7 months agocbvga_setup_modes: use real mode number instead of 0x140
Gerd Hoffmann [Wed, 30 May 2018 20:52:04 +0000 (22:52 +0200)] 
cbvga_setup_modes: use real mode number instead of 0x140

In case the framebuffer size matches one of the cbvga video modes
just use that mode number instead of 0x140.

Signed-off-by: Gerd Hoffmann <>
7 months agoqemu: add bochs-display support
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.

Signed-off-by: Gerd Hoffmann <>
7 months agocbvga: factor out cbvga_setup_modes()
Gerd Hoffmann [Wed, 30 May 2018 20:50:42 +0000 (22:50 +0200)] 
cbvga: factor out cbvga_setup_modes()

Factor out generic data structure setup code from cbvga_setup().

Signed-off-by: Gerd Hoffmann <>
7 months agooptionrom: enable non-vga display devices
Gerd Hoffmann [Wed, 30 May 2018 11:49:06 +0000 (13:49 +0200)] 
optionrom: enable non-vga display devices

In case no VGA device was found look for other display devices.

Signed-off-by: Gerd Hoffmann <>
8 months agodocs: Update to use git clone via https
Kevin O'Connor [Mon, 11 Jun 2018 16:05:31 +0000 (12:05 -0400)] 
docs: Update to use git clone via https

Signed-off-by: Kevin O'Connor <>
10 months agotpm: Request access to locality 0
Stefan Berger [Wed, 28 Mar 2018 19:37:44 +0000 (15:37 -0400)] 
tpm: Request access to locality 0

The CRB driver has to request access to locality 0. Our QEMU
CRB model will enforce that as well.

Signed-off-by: Stefan Berger <>
11 months agotpm: when CRB is active, select, lock it, and check addresses
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 <>
11 months agotpm: revert return values for successful/failed CRB probing
Stefan Berger [Mon, 19 Mar 2018 16:00:28 +0000 (12:00 -0400)] 
tpm: revert return values for successful/failed CRB probing

The return values for successful/failed CRB probing were reverted.
Fix it.

Signed-off-by: Stefan Berger <>
11 months agotpm: Wait for tpmRegValidSts flag on CRB interface before probing
Stefan Berger [Mon, 19 Mar 2018 16:00:27 +0000 (12:00 -0400)] 
tpm: Wait for tpmRegValidSts flag on CRB interface before probing

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 <>
Signed-off-by: Stefan Berger <>
11 months agotpm: Handle unimplemented TIS_REG_IFACE_ID in tis_get_tpm_version()
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 <>
Tested-by: Stefan Berger <>
Reviewed-by: Stefan Berger <>
11 months agotpm: Wait for interface startup when probing
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 <>
Tested-by: Stephen Douthit <>
Reviewed-by: Stefan Berger <>
11 months agotpm: Refactor duplicated wait code in tis_wait_sts() & crb_wait_reg()
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 <>
Tested-by: Stephen Douthit <>
Reviewed-by: Stefan Berger <>
11 months agotpm: add TPM CRB device support
Marc-André Lureau [Mon, 26 Feb 2018 14:12:14 +0000 (09:12 -0500)] 
tpm: add TPM CRB device support

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 <>
Reviewed-by: Stefan Berger <>
Tested-by: Stefan Berger <>
11 months agotpm: use get_tpm_version() callback
Marc-André Lureau [Mon, 26 Feb 2018 14:12:13 +0000 (09:12 -0500)] 
tpm: use get_tpm_version() callback

As originally intended.

Signed-off-by: Marc-André Lureau <>
Reviewed-by: Stefan Berger <>
Tested-by: Stefan Berger <>
11 months agotpm: generalize init_timeout()
Marc-André Lureau [Mon, 26 Feb 2018 14:12:12 +0000 (09:12 -0500)] 
tpm: generalize init_timeout()

It seems both TIS & CRB devices share the same timeout. Make
initialization function generic now.

Signed-off-by: Marc-André Lureau <>
Reviewed-by: Stefan Berger <>
Tested-by: Stefan Berger <>
11 months agox86: add readq()
Marc-André Lureau [Mon, 26 Feb 2018 14:12:11 +0000 (09:12 -0500)] 
x86: add readq()

Signed-off-by: Marc-André Lureau <>
Reviewed-by: Stefan Berger <>
Tested-by: Stefan Berger <>
11 months agobuild: Use git describe --always
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 <>
11 months agoshadow: Don't invoke a shutdown on reboot unless in a reboot loop
Kevin O'Connor [Fri, 23 Feb 2018 01:29:27 +0000 (20:29 -0500)] 
shadow: Don't invoke a shutdown on reboot unless in a reboot loop

Old versions of KVM would map the same writable copy of the BIOS at
both 0x000f0000 and 0xffff0000.  As a result, a reboot on these
machines would result in a reboot loop.  So, the code attempts to
check for that situation and invoke a shutdown instead.

Commit b837e68d changed the check to run prior to the first reboot.
However, this broke reboots on the QEMU isapc machine type.  Change
the reboot loop check to only be invoked after at least one reboot has
been attempted.

Reported-by: Daniel P. Berrangé <>
Signed-off-by: Kevin O'Connor <>
12 months agofloppy: Send 4 sense interrupt commands during controller initialization
Nikolay Nikolov [Sat, 10 Feb 2018 11:52:17 +0000 (13:52 +0200)] 
floppy: Send 4 sense interrupt commands during controller initialization

During initialization, real floppy controllers need 4 sense interrupt commands
to clear the interrupt status (this represents the transition from "not ready"
to "ready" for each of the four virtual floppy drives), instead of just one.

This is described in detail in section 7.4 - Drive Polling of the Intel 82077AA

Signed-off-by: Nikolay Nikolov <>
12 months agofloppy: Wait for the floppy motor to reach a stable speed, after starting
Nikolay Nikolov [Sat, 10 Feb 2018 11:52:16 +0000 (13:52 +0200)] 
floppy: Wait for the floppy motor to reach a stable speed, after starting

When starting up the floppy motor, wait for a certain amount of time, so
that it can spin up and reach a stable speed. This delay is skipped, if the
motor was already running (which can happen, since the floppy motor is
intentionally kept spinning for 2 seconds after the previous floppy
operation completes).

Signed-off-by: Nikolay Nikolov <>
12 months agofloppy: Support up to 4 floppy drives when turning on the floppy motor
Nikolay Nikolov [Sat, 10 Feb 2018 11:52:15 +0000 (13:52 +0200)] 
floppy: Support up to 4 floppy drives when turning on the floppy motor

The previous version allowed for only two floppies.

Signed-off-by: Nikolay Nikolov <>
12 months agofloppy: Execute a SPECIFY command after sensing the media type
Nikolay Nikolov [Sat, 10 Feb 2018 11:52:14 +0000 (13:52 +0200)] 
floppy: Execute a SPECIFY command after sensing the media type

The SPECIFY command sets the Step Rate Time, Head Load Time, Head Unload Time
and the DMA enable/disable bit.

Signed-off-by: Nikolay Nikolov <>
12 months agofloppy: hold the DOR reset bit low for 4 microseconds, when resetting
Nikolay Nikolov [Sat, 10 Feb 2018 11:52:13 +0000 (13:52 +0200)] 
floppy: hold the DOR reset bit low for 4 microseconds, when resetting

Signed-off-by: Nikolay Nikolov <>
12 months agofloppy: Use timer_check() in floppy_wait_irq()
Nikolay Nikolov [Sun, 4 Feb 2018 15:27:01 +0000 (17:27 +0200)] 
floppy: Use timer_check() in floppy_wait_irq()

Use timer_check() instead of using floppy_motor_counter in BDA for the
timeout check in floppy_wait_irq().

The problem with using floppy_motor_counter was that, after it reaches
0, it immediately stops the floppy motors, which is not what is
supposed to happen on real hardware. Instead, after a timeout (like in
the end of every floppy operation, regardless of the result - success,
timeout or error), the floppy motors must be kept spinning for
additional 2 seconds (the FLOPPY_MOTOR_TICKS). So, now the
floppy_motor_counter is initialized to 255 (the max value) in the
beginning of the floppy operation. For IRQ timeouts, a different
timeout is used, specified by the new FLOPPY_IRQ_TIMEOUT constant
(currently set to 5 seconds - a fairly conservative value, but should
work reliably on most floppies).

After the floppy operation, floppy_drive_pio() resets the
floppy_motor_counter to 2 seconds (FLOPPY_MOTOR_TICKS).

This is also consistent with what other PC BIOSes do.

Signed-off-by: Nikolay Nikolov <>
12 months agofloppy: Reset the floppy motor count in floppy_drive_pio()
Nikolay Nikolov [Sun, 4 Feb 2018 15:27:00 +0000 (17:27 +0200)] 
floppy: Reset the floppy motor count in floppy_drive_pio()

Reset the floppy motor count, so the motor keeps spinning 2 seconds
after a floppy operation, performed by floppy_drive_pio().

Signed-off-by: Nikolay Nikolov <>
12 months agofloppy: Preserve motor and drive sel bits when resetting the floppy controller
Nikolay Nikolov [Sun, 4 Feb 2018 15:26:59 +0000 (17:26 +0200)] 
floppy: Preserve motor and drive sel bits when resetting the floppy controller

In case of read or write errors, the floppy system is usually reset and the
operation is retried. In that case, the floppy motor state must be preserved
in order to avoid creating jitter and keep the floppy motor spinning smoothly
at a constant speed. Additionally, the drive select bits should probably also
be preserved, because some systems might need a small delay after selecting a
new drive. In that case, the operation would be retried, without changing
the currently selected drive.

In floppy_enable_controller(), the IRQ bit is now enabled first, before the
reset bit is set. I'm not completely sure whether this is necessary. It is
done just in case some hardware introduces a delay between setting this bit
and actually enabling the IRQ, which would cause us to miss the IRQ, sent by
the controller immediately after reset.

Signed-off-by: Nikolay Nikolov <>
12 months agofloppy: Introduce FLOPPY_DOR_XXX constants
Nikolay Nikolov [Sun, 4 Feb 2018 15:26:58 +0000 (17:26 +0200)] 
floppy: Introduce FLOPPY_DOR_XXX constants

Signed-off-by: Nikolay Nikolov <>
12 months agofloppy: Introduce floppy_dor_mask()
Nikolay Nikolov [Sun, 4 Feb 2018 15:26:57 +0000 (17:26 +0200)] 
floppy: Introduce floppy_dor_mask()

Signed-off-by: Nikolay Nikolov <>
12 months agofloppy: Introduce the floppy_dor_read() function
Nikolay Nikolov [Sun, 4 Feb 2018 15:26:56 +0000 (17:26 +0200)] 
floppy: Introduce the floppy_dor_read() function

Signed-off-by: Nikolay Nikolov <>
13 months agopci: fix 'io hints' capability for RedHat PCI bridges
Marcel Apfelbaum [Thu, 11 Jan 2018 20:15:12 +0000 (22:15 +0200)] 
pci: fix 'io hints' capability for RedHat PCI bridges

Commit ec6cb17f (pci: enable RedHat PCI bridges to reserve additional
                 resources on PCI init)
added a new vendor specific PCI capability for RedHat PCI bridges
allowing them to reserve additional buses and/or IO/MEM space.

When adding the IO hints PCI capability to the pcie-root-port
without specifying a value for bus reservation, the subordinate bus
computation is wrong and the guest kernel gets messed up.

Fix it by returning to prev code if the value for bus
reservation is not set.

Removed also a wrong debug print "PCI: invalid QEMU resource reserve
cap offset" which appears if the 'IO hints' capability is not present.

Acked-by: Michael S. Tsirkin <>
Signed-off-by: Marcel Apfelbaum <>
14 months agodocs/Download: Use more secure HTTPS URLs where possible
Paul Menzel [Mon, 2 Oct 2017 06:13:13 +0000 (08:13 +0200)] 
docs/Download: Use more secure HTTPS URLs where possible

Signed-off-by: Paul Menzel <>
15 months agotpm: Add support for TPM2 ACPI table
Stefan Berger [Tue, 14 Nov 2017 20:03:47 +0000 (15:03 -0500)] 
tpm: Add support for TPM2 ACPI table

Add support for the TPM2 ACPI table. If we find it and its
of the appropriate size, we can get the log_area_start_address
and log_area_minimum_size from it.

The latest version of the spec can be found here:

Signed-off-by: Stefan Berger <>
15 months agoparavirt: Only enable sercon in NOGRAPHIC mode if no other console specified
Kevin O'Connor [Fri, 10 Nov 2017 17:20:35 +0000 (12:20 -0500)] 
paravirt: Only enable sercon in NOGRAPHIC mode if no other console specified

Signed-off-by: Kevin O'Connor <>
15 months agodocs: Add sercon-port to documentation
Kevin O'Connor [Fri, 10 Nov 2017 17:16:36 +0000 (12:16 -0500)] 
docs: Add sercon-port to documentation

Signed-off-by: Kevin O'Connor <>
15 months agodocs: Note v1.11.0 release rel-1.11.0
Kevin O'Connor [Fri, 10 Nov 2017 16:49:19 +0000 (11:49 -0500)] 
docs: Note v1.11.0 release

Signed-off-by: Kevin O'Connor <>
15 months agosercon: Disable ScreenAndDebug in case both serial console and serial debug are active
Gerd Hoffmann [Fri, 3 Nov 2017 07:40:57 +0000 (08:40 +0100)] 
sercon: Disable ScreenAndDebug in case both serial console and serial debug are active

Signed-off-by: Gerd Hoffmann <>
15 months agotimer: Avoid integer overflows in usec and nsec calculations
Kevin O'Connor [Thu, 2 Nov 2017 15:21:14 +0000 (11:21 -0400)] 
timer: Avoid integer overflows in usec and nsec calculations

When timer_calc_usec() is used with large timeout values, such as 60s,
the integer math can overflow and produce different results than when
using timer_calc(time / 1000) for the same timeout.

Signed-off-by: Stefan Berger <>
Signed-off-by: Kevin O'Connor <>
16 months agonvme: Use the Maximum Queue Entries Supported (MQES) to initialize I/O queues
Filippo Sironi [Wed, 11 Oct 2017 22:42:34 +0000 (00:42 +0200)] 
nvme: Use the Maximum Queue Entries Supported (MQES) to initialize I/O queues

Use the Maximum Queue Entries Supported (MQES) to initialize I/O queues
depth rather than picking a fixed number (256) which might not be
supported by some NVMe controllers (the NVMe specification says that an
NVMe controller may support any number between 2 to 4096).

Still cap the I/O queues depth to 256 since, during my testing, SeaBIOS
was running out of memory when using something higher than 256 (4096 on
the NVMe controller that I've had a chance to try).

Signed-off-by: Filippo Sironi <>
16 months agoxhci: Verify the device is still present in xhci_cmd_submit()
Kevin O'Connor [Tue, 3 Oct 2017 15:29:12 +0000 (11:29 -0400)] 
xhci: Verify the device is still present in xhci_cmd_submit()

Make sure the USB device is still present before altering the xhci
"slot" for it.  It appears some controllers will hang if a request is
sent to a port no longer connected.

Signed-off-by: Kevin O'Connor <>
16 months agonvme: fix out of memory behavior
Julian Stecklina [Tue, 3 Oct 2017 13:47:17 +0000 (15:47 +0200)] 
nvme: fix out of memory behavior

If the allocation of I/O queues ran out of memory, the code would fail to detect
that and happily use these queues at address zero. For me this happens for
systems with more than 7 NVMe controllers.

Fix the out of memory handling to gracefully handle this case.

Signed-off-by: Julian Stecklina <>
16 months agoxhci: Build TRBs directly in xhci_trb_queue()
Kevin O'Connor [Tue, 3 Oct 2017 14:45:24 +0000 (10:45 -0400)] 
xhci: Build TRBs directly in xhci_trb_queue()

Use the logic for building a 'struct xhci_trb' that was in
xhci_xfer_queue() up so that command and ring TRBs can also use that
functionality.  This eliminates the need to manually generate the
xhci_trb struct from those code paths.

Signed-off-by: Kevin O'Connor <>
16 months agovirtio: Allocate drive_s storage in low memory
Kevin O'Connor [Tue, 11 Jul 2017 16:30:26 +0000 (12:30 -0400)] 
virtio: Allocate drive_s storage in low memory

Use the "low" memory segment instead of the f-segment for the drive_s
storage.  This can help avoid running out of memory in the f-segment.

Tested-by: Paolo Bonzini <>
Signed-off-by: Kevin O'Connor <>
16 months agoblock: Rename disk_op_s->drive_gf to drive_fl
Kevin O'Connor [Tue, 11 Jul 2017 16:24:50 +0000 (12:24 -0400)] 
block: Rename disk_op_s->drive_gf to drive_fl

Now that the drive_s struct does not need to be in the f-segment,
rename references to drive_gf in the generic drive code to drive_fl.

This is just variable renames - no code changes.

Tested-by: Paolo Bonzini <>
Signed-off-by: Kevin O'Connor <>
16 months agodisk: Don't require the 'struct drive_s' to be in the f-segment
Kevin O'Connor [Tue, 11 Jul 2017 16:09:57 +0000 (12:09 -0400)] 
disk: Don't require the 'struct drive_s' to be in the f-segment

Allow the 'struct drive_s' drive description structure to be in either
the "low" memory segment or the f-segment.

Tested-by: Paolo Bonzini <>
Signed-off-by: Kevin O'Connor <>
16 months agoboot: Rename drive_g to drive
Kevin O'Connor [Tue, 11 Jul 2017 15:55:49 +0000 (11:55 -0400)] 
boot: Rename drive_g to drive

The 'struct drive_s' pointer is a 32bit pointer (and boot.c code is
only compiled in 32bit mode), so avoid using the "_g" suffix on the

Tested-by: Paolo Bonzini <>
Signed-off-by: Kevin O'Connor <>
16 months agoadd serial console support
Gerd Hoffmann [Mon, 18 Sep 2017 08:47:23 +0000 (10:47 +0200)] 
add serial console support

Redirect int10 calls to serial console output.
Parse serial input and queue key events.
The serial console can work both as primary display
and in parallel to another vga display (splitmode).

Signed-off-by: Gerd Hoffmann <>
16 months agoparavirt: serial console configuration.
Gerd Hoffmann [Mon, 18 Sep 2017 08:47:22 +0000 (10:47 +0200)] 
paravirt: serial console configuration.

Read QEMU_CFG_NOGRAPHIC, if set add etc/sercon-port
file to enable the serial console.

Signed-off-by: Gerd Hoffmann <>
16 months agoromfile: add support for constant files.
Gerd Hoffmann [Mon, 18 Sep 2017 08:47:21 +0000 (10:47 +0200)] 
romfile: add support for constant files.

Signed-off-by: Gerd Hoffmann <>
16 months agokbd: make enqueue_key public, add ascii_to_keycode
Gerd Hoffmann [Mon, 18 Sep 2017 08:47:20 +0000 (10:47 +0200)] 
kbd: make enqueue_key public, add ascii_to_keycode

serial console wants queue key events and needs to map ascii chars to
the keycode, so make enqueue_key public and also exports a helper
function so sercon can use the scan_to_keycode mapping table.

Signed-off-by: Gerd Hoffmann <>
16 months agostd: add cp437 to unicode map
Gerd Hoffmann [Mon, 18 Sep 2017 08:47:19 +0000 (10:47 +0200)] 
std: add cp437 to unicode map

Signed-off-by: Gerd Hoffmann <>
17 months agopci: enable RedHat PCI bridges to reserve additional resources on PCI init
Aleksandr Bezzubikov [Thu, 17 Aug 2017 23:33:21 +0000 (02:33 +0300)] 
pci: enable RedHat PCI bridges to reserve additional resources on PCI init

In case of Red Hat Generic PCIE Root Port reserve additional buses
and/or IO/MEM/PREF space, which values are provided in a vendor-specific capability.

Signed-off-by: Aleksandr Bezzubikov <>
Reviewed-by: Marcel Apfelbaum <>
17 months agopci: add QEMU-specific PCI capability structure
Aleksandr Bezzubikov [Thu, 17 Aug 2017 23:33:20 +0000 (02:33 +0300)] 
pci: add QEMU-specific PCI capability structure

On PCI init PCI bridge devices may need some
extra info about bus number to reserve, IO, memory and
prefetchable memory limits. QEMU can provide this
with special vendor-specific PCI capability.

This capability is intended to be used only
for Red Hat PCI bridges, i.e. QEMU cooperation.

Signed-off-by: Aleksandr Bezzubikov <>
Reviewed-by: Marcel Apfelbaum <>
17 months agopci: refactor pci_find_capapibilty to get bdf as the first argument instead of the...
Aleksandr Bezzubikov [Thu, 17 Aug 2017 23:33:19 +0000 (02:33 +0300)] 
pci: refactor pci_find_capapibilty to get bdf as the first argument instead of the whole pci_device

Refactor pci_find_capability function to get bdf instead of
a whole pci_device* as the only necessary field for this function
is still bdf.

Signed-off-by: Aleksandr Bezzubikov <>
Reviewed-by: Marcel Apfelbaum <>
17 months agotcgbios: Fix use of unitialized variable
Kevin O'Connor [Sun, 3 Sep 2017 01:42:12 +0000 (21:42 -0400)] 
tcgbios: Fix use of unitialized variable

Review-by: Stefan Berger <>
Signed-off-by: Kevin O'Connor <>
17 months agodocs: Fix typos in
Kevin O'Connor [Tue, 11 Jul 2017 17:35:40 +0000 (13:35 -0400)] 
docs: Fix typos in

Reviewed-by: Paul Menzel <>
Signed-off-by: Kevin O'Connor <>
17 months agovga: Fix bug in stdvga_get_linesize()
Kevin O'Connor [Tue, 29 Aug 2017 18:38:19 +0000 (14:38 -0400)] 
vga: Fix bug in stdvga_get_linesize()

Add required GET_GLOBAL() macro to vmode_g access.

Signed-off-by: Kevin O'Connor <>
18 months agousb-xhci: use hub portmap
Gerd Hoffmann [Tue, 18 Jul 2017 11:15:42 +0000 (13:15 +0200)] 
usb-xhci: use hub portmap

xhci controllers have two virtual ports per (usb3 capable) physical
port, one for usb2 and one for usb3 devices.  Add a hub portmap callback
to map the virtual ports to physical ports.

Signed-off-by: Gerd Hoffmann <>
18 months agousb: add hub portmap
Gerd Hoffmann [Tue, 18 Jul 2017 11:15:25 +0000 (13:15 +0200)] 
usb: add hub portmap

Allow usb hubs to map (software) ports to physical ports via op
callback.  This is needed to make bootorder work in case there
isn't a simple linear mapping.

Signed-off-by: Gerd Hoffmann <>
19 months agovirtio: IOMMU support
Jason Wang [Wed, 5 Jul 2017 07:49:51 +0000 (15:49 +0800)] 
virtio: IOMMU support

Since we don't enable IOMMU at all, we can then simply enable the
IOMMU support by claiming the support of VIRITO_F_IOMMU_PLATFORM. This
fixes booting failure when iommu_platform is set from qemu cli.

Acked-by: Michael S. Tsirkin <>
Signed-off-by: Jason Wang <>
19 months agoahci: Disable Native Command Queueing
Zeh, Werner [Fri, 23 Jun 2017 07:18:04 +0000 (07:18 +0000)] 
ahci: Disable Native Command Queueing

The AHCI driver currently sets the NCQ bit for every command that is
issued to the SATA drive.  This is not needed as there is always only
one command active at a time and in turn can lead to a hanging AHCI
controller (true for Marvel 88SE9170). The following patch disables
the usage of NCQ completely. With this patch the Marvel AHCI
controller works just fine without any issues.

Signed-off-by: Kevin O'Connor <>
20 months agonvme: Enable NVMe support for non-qemu hardware
Youness Alaoui [Tue, 13 Jun 2017 01:09:07 +0000 (21:09 -0400)] 
nvme: Enable NVMe support for non-qemu hardware

NVMe support was tested on purism/librem13 laptops and SeaBIOS has
no problems in detecting and booting the drives.

This is a continuation of commit 235a8190 which was incomplete.

Signed-off-by: Youness Alaoui <>
Signed-off-by: Kevin O'Connor <>
20 months agoSeaVGABios/cbvga: Advertise compatible VESA modes
Patrick Rudolph [Mon, 29 May 2017 17:25:14 +0000 (19:25 +0200)] 
SeaVGABios/cbvga: Advertise compatible VESA modes

Advertise compatible VESA modes, that are smaller or equal to
coreboot's active framebuffer. Only modes that have the same Bpp
are advertise and can be selected.

Allows the Windows 7 bootloader NTLDR to show up in VESA mode.
Allows to show the Windows 7 boot logo.
Allows Windows to boot in safe mode and in normal boot using
VgaSave driver with resolution up to 1600x1200.

This fixes most likely other bootloader and operating systems as well,
in case the are relying on VESA framebuffer support.

Signed-off-by: Patrick Rudolph <>
20 months agoSeaVGABios/cbvga: Use active mode to clear screen
Patrick Rudolph [Mon, 29 May 2017 17:25:13 +0000 (19:25 +0200)] 
SeaVGABios/cbvga: Use active mode to clear screen

As coreboot framebuffer is immutable always use CBmodeinfo.

Signed-off-by: Patrick Rudolph <>
20 months agoSeaVGABIOS/vbe: Query driver for scanline pitch v2
Patrick Rudolph [Mon, 29 May 2017 17:25:12 +0000 (19:25 +0200)] 
SeaVGABIOS/vbe: Query driver for scanline pitch v2

Query the driver for the real scanline pitch in bytes.

As cbvga doesn't change the pitch on mode change, always
return the same pitch, that might exceed width times Bytes-per-pixel.

Report the default stdvga pitch for all other drivers.

Signed-off-by: Patrick Rudolph <>
20 months agoSeaVGABios/cbvga: Advertise correct pixel format
Patrick Rudolph [Mon, 29 May 2017 17:25:10 +0000 (19:25 +0200)] 
SeaVGABios/cbvga: Advertise correct pixel format

Accumulate the pixel format's bits instead relying on coreboot's
bits_per_pixel, which says nothing about the active pixel format.

Allows VBE to correctly advertise XRGB8 and BGRX8 framebuffer formats,
commonly used by coreboot.

Fixes at least Windows Bootloader and gfxboot.

Signed-off-by: Patrick Rudolph <>
20 months agoRevert "lsi-scsi: reset in case of a serious problem"
Roman Kagan [Thu, 8 Jun 2017 09:58:08 +0000 (12:58 +0300)] 
Revert "lsi-scsi: reset in case of a serious problem"

This reverts commit 11277846e819b9eef3db5ac833a6a47f95f5ef15.

It was originally introduced to deal with the case when REPORT_LUNS
caused an error in QEMU implementation of lsi53c895a and left it in a
"confused" state making further interaction impossible.

However the remedy was worse than the disease: the reset was
controller-wide causing all luns to reset, losing all in-flight requests;
upon that all luns lit up unit_attention condition, so that any
non-informational request would fail with check_condition status.  As a
result, the lun enumeration succeeded and I saw the respective entries
in the boot menu during my testing, but the read from those luns ended
with an error and booting failed, which I didn't bother to test.

So this reverts to the original error handling behavior.  The problem
with the failing REPORT_LUNS is addressed in the preceding patch, by
making it unlikely to fail.

Reported-by: Maciej Józefczyk <>
Signed-off-by: Roman Kagan <>
20 months agoblockcmd: start REPORT_LUNS with the smallest buffer
Roman Kagan [Thu, 8 Jun 2017 09:58:07 +0000 (12:58 +0300)] 
blockcmd: start REPORT_LUNS with the smallest buffer

A number of emulated SCSI devices in QEMU incorrectly return an error
to REPORT_LUNS command when the size of the data returned is smaller
than the allocation length passed in.

To work it around, start with the smallest allocation length possible:
for 1 entry.  This is a slight pessimization because it would require
another REPORT_LUNS iteration if the target has more than a single LUN,
but this appears to have negligible impact on boot times, and makes
REPORT_LUNS enumeration work for more QEMU devices (lsi53c895a,

Reported-by: Maciej Józefczyk <>
Signed-off-by: Roman Kagan <>
20 months agostacks: There is no need to disable NMI if it is already disabled
Kevin O'Connor [Tue, 16 May 2017 15:59:10 +0000 (11:59 -0400)] 
stacks: There is no need to disable NMI if it is already disabled

Don't write to the cmos index port on a mode switch if NMI is already
disabled.  This reduces the number of outb() calls.

Signed-off-by: Kevin O'Connor <>
21 months agostacks: Don't update the A20 settings if they haven't changed
Kevin O'Connor [Tue, 16 May 2017 15:47:27 +0000 (11:47 -0400)] 
stacks: Don't update the A20 settings if they haven't changed

The A20 setting is almost always enabled - only issue an outb() if the
A20 is actually changing.  This reduces the number of outb() calls.

Signed-off-by: Kevin O'Connor <>
21 months agostacks: Make sure to initialize Call16Data
Kevin O'Connor [Tue, 16 May 2017 15:36:43 +0000 (11:36 -0400)] 
stacks: Make sure to initialize Call16Data

Initialize the Call16Data at startup - otherwise some early yield()
calls may check for interrupts without using the preferred A20

Signed-off-by: Kevin O'Connor <>
21 months agosmm: Backup and restore A20 on an SMI based mode switch
Kevin O'Connor [Tue, 16 May 2017 15:32:49 +0000 (11:32 -0400)] 
smm: Backup and restore A20 on an SMI based mode switch

QEMU does not store the A20 setting in the SMM cpu environment area
(and it does not look like real CPUs do either).  So, manually backup
and restore A20 on a mode switch.

Signed-off-by: Kevin O'Connor <>