seabios.git
2 days agooptionrom: disallow int19 redirect for pnp roms. master github/master
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.

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>
7 days agobootmenu: add support for more than 9 entries
Gerd Hoffmann [Thu, 11 Apr 2019 19:46:33 +0000 (21:46 +0200)] 
bootmenu: add support for more than 9 entries

10th and following entries can be selected using letters.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 days agoadd get_keystroke_full() helper
Gerd Hoffmann [Wed, 15 May 2019 07:53:25 +0000 (09:53 +0200)] 
add get_keystroke_full() helper

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>
9 days agobochsdisplay: parse resolution from edid.
Gerd Hoffmann [Tue, 19 Mar 2019 11:20:52 +0000 (12:20 +0100)] 
bochsdisplay: parse resolution from edid.

Then use the resolution for the framebuffer.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 days agobochsdisplay: add edid support.
Gerd Hoffmann [Tue, 19 Mar 2019 10:48:04 +0000 (11:48 +0100)] 
bochsdisplay: add edid support.

Read EDID blob from mmio bar, store in VBE_edid.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 days agobochsvga: add edid support.
Gerd Hoffmann [Tue, 19 Mar 2019 10:48:13 +0000 (11:48 +0100)] 
bochsvga: add edid support.

Read EDID blob from mmio bar, store in VBE_edid.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 days agoati: add edid support.
Gerd Hoffmann [Mon, 18 Mar 2019 14:43:53 +0000 (15:43 +0100)] 
ati: add edid support.

Read EDID blob via i2c, store in VBE_edid.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 days agovbe: add edid support.
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.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2 weeks agosmbios: Add missing zero byte to Type 0
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>
2 months agovga: add ati bios tables
Gerd Hoffmann [Fri, 8 Mar 2019 10:42:25 +0000 (11:42 +0100)] 
vga: add ati bios tables

Needed to make drivers happy which try to gather
informations from these tables.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2 months agovga: add atiext driver
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.

Available models:
 * ati rage 128 pro
 * ati rv100

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2 months agovga: make memcpy_high() public
Gerd Hoffmann [Fri, 8 Mar 2019 11:34:38 +0000 (12:34 +0100)] 
vga: make memcpy_high() public

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2 months agovga: move modelist from bochsvga.c to new svgamodes.c
Gerd Hoffmann [Fri, 8 Mar 2019 10:10:59 +0000 (11:10 +0100)] 
vga: move modelist from bochsvga.c to new svgamodes.c

So other drivers can simply use the same list too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
3 months agotcgbios: Implement TPM 2.0 menu item to activate and deactivate PCR banks
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>
3 months 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 <stefanb@linux.ibm.com>
3 months 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 <kevin@koconnor.net>
3 months 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 <hammersamatom@gmail.com>
4 months agodocs: Fix cut-and-paste error in Mailinglist.md archive link
Kevin O'Connor [Mon, 21 Jan 2019 18:17:11 +0000 (13:17 -0500)] 
docs: Fix cut-and-paste error in Mailinglist.md archive link

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
4 months 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 <kevin@koconnor.net>
5 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 <kevin@koconnor.net>
5 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 <sgarzare@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
5 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 <mark.kanda@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
5 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 <stephend@silicom-usa.com>
6 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 <kevin@koconnor.net>
6 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 <kevin@koconnor.net>
6 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 <liran.alon@oracle.com>
Reviewed-by: Mark Kanda <mark.kanda@oracle.com>
Signed-off-by: Shmuel Eiderman <shmuel.eiderman@oracle.com>
7 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 <kraxel@redhat.com>
8 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 <matt.devillier@puri.sm>
8 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 <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>
8 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 <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>
8 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 <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>
8 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 <coderight@gmail.com>.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 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 <matt.devillier@puri.sm>
9 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: https://www.seabios.org/downloads/

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
10 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 <kevin@koconnor.net>
10 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 <kraxel@redhat.com>
11 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
here.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 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 <kraxel@redhat.com>
11 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 <kraxel@redhat.com>
11 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 <kraxel@redhat.com>
11 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 <kraxel@redhat.com>
11 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 <kraxel@redhat.com>
11 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 <kraxel@redhat.com>
11 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 <kraxel@redhat.com>
11 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 <kraxel@redhat.com>
11 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 <kraxel@redhat.com>
11 months agodocs: Update Download.md to use git clone via https
Kevin O'Connor [Mon, 11 Jun 2018 16:05:31 +0000 (12:05 -0400)] 
docs: Update Download.md to use git clone via https

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
13 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 <stefanb@linux.vnet.ibm.com>
14 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 <stefanb@linux.vnet.ibm.com>
14 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 <stefanb@linux.vnet.ibm.com>
14 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 <stephend@silicom-usa.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
14 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 <stephend@silicom-usa.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
14 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 <stephend@silicom-usa.com>
Tested-by: Stephen Douthit <stephend@silicom-usa.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
14 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 <stephend@silicom-usa.com>
Tested-by: Stephen Douthit <stephend@silicom-usa.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
14 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 <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
14 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 <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
14 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 <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
14 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 <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
14 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 <kevin@koconnor.net>
14 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é <berrange@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
15 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
datasheet.

Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
15 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 <nickysn@users.sourceforge.net>
15 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 <nickysn@users.sourceforge.net>
15 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 <nickysn@users.sourceforge.net>
15 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 <nickysn@users.sourceforge.net>
15 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 <nickysn@users.sourceforge.net>
15 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 <nickysn@users.sourceforge.net>
15 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 <nickysn@users.sourceforge.net>
15 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 <nickysn@users.sourceforge.net>
15 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 <nickysn@users.sourceforge.net>
15 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 <nickysn@users.sourceforge.net>
16 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 <mst@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
17 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 <pmenzel@molgen.mpg.de>
18 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:

https://trustedcomputinggroup.org/tcg-acpi-specification/

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
18 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 <kevin@koconnor.net>
18 months agodocs: Add sercon-port to Runtime_config.md documentation
Kevin O'Connor [Fri, 10 Nov 2017 17:16:36 +0000 (12:16 -0500)] 
docs: Add sercon-port to Runtime_config.md documentation

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
18 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 <kevin@koconnor.net>
18 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 <kraxel@redhat.com>
18 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 <stefanb@linux.vnet.ibm.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
19 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 <sironi@amazon.de>
19 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 <kevin@koconnor.net>
19 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 <jsteckli@amazon.de>
19 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 <kevin@koconnor.net>
19 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 <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
19 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 <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
19 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 <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
19 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
pointer.

Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
20 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 <kraxel@redhat.com>
20 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 <kraxel@redhat.com>
20 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 <kraxel@redhat.com>
20 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 <kraxel@redhat.com>
20 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 <kraxel@redhat.com>
20 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 <zuban32s@gmail.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
20 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 <zuban32s@gmail.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
20 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 <zuban32s@gmail.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
20 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 <stefanb@linux.vnet.ibm.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
20 months agodocs: Fix typos in Memory_Model.md
Kevin O'Connor [Tue, 11 Jul 2017 17:35:40 +0000 (13:35 -0400)] 
docs: Fix typos in Memory_Model.md

Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
20 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 <kevin@koconnor.net>
21 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 <kraxel@redhat.com>
21 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 <kraxel@redhat.com>