]> xenbits.xensource.com Git - seabios.git/log
seabios.git
9 years agotpm: Implement tpm20_startup and tpm20_s3_resume
Stefan Berger [Tue, 2 Feb 2016 18:09:12 +0000 (13:09 -0500)]
tpm: Implement tpm20_startup and tpm20_s3_resume

Implement tpm20_startup and tpm20_s3_resume and their dependencies.

We follow this specification:

TCG PC Client Specific Platform Firmware Profile for TPM 2.0 Systems Revision 1.0 Version 21

It can be found on this page:

http://www.trustedcomputinggroup.org/resources/specifications_in_public_review

Power on: Figure 7 & 7.3.2 item 4.
S3: Figure 9 & 7.3.2 item 4.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Prepare code for TPM 2 functions
Stefan Berger [Tue, 2 Feb 2016 18:09:11 +0000 (13:09 -0500)]
tpm: Prepare code for TPM 2 functions

This patch prepares the tcgbios.c file for extension with TPM 2
specific code by:

 o prefixing all TPM 1.2 specific functions with tpm12_
 o where necessary, introduce switch statements in tpm_ - prefixed functions;
   here we branch into TPM versions specific code
 o introduce tpm_ - prefixed functions where necessary; mostly in those
   cases where tpm12_ functions are too large and where the tpm_ function
   then only holds the switch statement
 o leave FIXMEs where we need to write TPM 2 specific code; subsequent patches
   will replace those FIXMEs

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Factor out tpm_extend
Stefan Berger [Tue, 2 Feb 2016 18:09:10 +0000 (13:09 -0500)]
tpm: Factor out tpm_extend

In preparation for TPM 2 code support, factor out the TPM 1.2 specific
code from tpm_log_extend_event and put it into tpm_extend().

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Extend TPM TIS with TPM 2 support.
Stefan Berger [Tue, 2 Feb 2016 18:09:09 +0000 (13:09 -0500)]
tpm: Extend TPM TIS with TPM 2 support.

Extend the probing of the interface with TPM 2 specifics.

Use the new interface ID register of the TIS to check whether
a TPM 1.2 or a TPM 2 is underneath.

We select the TIS if possible and lock it so we can issue commands
during S3 for example and prevent the OS from changing to CRB type
of interface.

The register is described in table 13 here:

http://www.trustedcomputinggroup.org/resources/pc_client_platform_tpm_profile_ptp_specification

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agoblock: Move drive setup to new function block_setup()
Kevin O'Connor [Wed, 3 Feb 2016 16:00:17 +0000 (11:00 -0500)]
block: Move drive setup to new function block_setup()

Move the list of drive setup calls from post.c to a new function in
block.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoscsi: Always use MAXDESCSIZE when building drive description
Kevin O'Connor [Wed, 3 Feb 2016 08:27:36 +0000 (03:27 -0500)]
scsi: Always use MAXDESCSIZE when building drive description

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agopci: Split low-level pci code from higher-level 'struct pci_device' code
Kevin O'Connor [Wed, 3 Feb 2016 06:28:20 +0000 (01:28 -0500)]
pci: Split low-level pci code from higher-level 'struct pci_device' code

Split pci.c into pci.c and pcidevice.c.  The low-level code that
interacts directly with the PCI devices remains in pci.c, while
functions dealing with the higher level pci_device cache move to
pcidevice.c.  Only pci.c is needed in 16bit mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agopci: Move code in pci.c that is specific to pciinit.c to pciinit.c
Kevin O'Connor [Wed, 3 Feb 2016 05:47:27 +0000 (00:47 -0500)]
pci: Move code in pci.c that is specific to pciinit.c to pciinit.c

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agopci: Implement '%pP' printf handler for 'struct pci_device' pointers
Kevin O'Connor [Wed, 3 Feb 2016 08:03:15 +0000 (03:03 -0500)]
pci: Implement '%pP' printf handler for 'struct pci_device' pointers

Handle '%pP' format descriptions as a pointer to a 'struct pci_device'
and display it in bus:device.function (%02x:%02x.%x) format.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agopci: Consistently set pci->have_drivers for devices with internal drivers
Kevin O'Connor [Wed, 3 Feb 2016 03:50:33 +0000 (22:50 -0500)]
pci: Consistently set pci->have_drivers for devices with internal drivers

Set the pci->have_drivers flag for any device that calls
pci_enable_x() to ensure that the flag is consistently set on any
device with an internal driver.  Setting this flag prevents an option
rom on the device from being executed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agovirtio: Convert to new PCI BAR helper functions
Kevin O'Connor [Wed, 3 Feb 2016 03:34:27 +0000 (22:34 -0500)]
virtio: Convert to new PCI BAR helper functions

Use the pci_enable_x() functions.

This patch also converts cap->addr from a 'u32' to a union storing a
'u32' or a 'void*'.  This makes it more clear when the address is a
virtual memory address.

The virtio controller code will now explicitly set PCI_COMMAND_MEMORY
and/or PCI_COMMAND_IO instead of assuming it has already been enabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoxhci: Convert to new PCI BAR helper functions
Kevin O'Connor [Wed, 3 Feb 2016 03:33:17 +0000 (22:33 -0500)]
xhci: Convert to new PCI BAR helper functions

Use the pci_enable_x() functions.

The xhci controller code will now explicitly set PCI_COMMAND_MEMORY
instead of assuming it has already been enabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agouhci: Convert to new PCI BAR helper functions
Kevin O'Connor [Wed, 3 Feb 2016 03:29:49 +0000 (22:29 -0500)]
uhci: Convert to new PCI BAR helper functions

Use the pci_enable_x() functions.

The uhci controller code will now explicitly set PCI_COMMAND_IO
instead of assuming it has already been enabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoohci: Convert to new PCI BAR helper functions
Kevin O'Connor [Wed, 3 Feb 2016 03:29:14 +0000 (22:29 -0500)]
ohci: Convert to new PCI BAR helper functions

Use the pci_enable_x() functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoehci: Convert to new PCI BAR helper functions
Kevin O'Connor [Wed, 3 Feb 2016 03:28:06 +0000 (22:28 -0500)]
ehci: Convert to new PCI BAR helper functions

Use the pci_enable_x() functions.

The ehci controller code will now explicitly set PCI_COMMAND_MEMORY
instead of assuming it has already been enabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Convert to new PCI BAR helper functions
Kevin O'Connor [Wed, 3 Feb 2016 03:23:55 +0000 (22:23 -0500)]
sdcard: Convert to new PCI BAR helper functions

Use the pci_enable_x() functions.

After this change, the sdcard driver will no longer enable
PCI_COMMAND_IO or PCI_COMMAND_MASTER accesses, as the sdcard driver
doesn't actually use IO BARs or implement DMA.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agopvscsi: Convert to new PCI BAR helper functions
Kevin O'Connor [Wed, 3 Feb 2016 03:21:49 +0000 (22:21 -0500)]
pvscsi: Convert to new PCI BAR helper functions

Use the pci_enable_x() functions.

The pvscsi controller code will now explicitly set PCI_COMMAND_MEMORY
instead of assuming it has already been enabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomegasas: Convert to new PCI BAR helper functions
Kevin O'Connor [Wed, 3 Feb 2016 03:19:35 +0000 (22:19 -0500)]
megasas: Convert to new PCI BAR helper functions

Use the pci_enable_x() functions.

After this change, the megasas driver will no longer enable
PCI_COMMAND_MEMORY accesses, as the megasas driver doesn't actually
map any BARs as memory.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agolsi-scsi: Convert to new PCI BAR helper functions
Kevin O'Connor [Wed, 3 Feb 2016 03:18:54 +0000 (22:18 -0500)]
lsi-scsi: Convert to new PCI BAR helper functions

Use the pci_enable_x() functions.

The lsi-scsi controller code will now explicitly set PCI_COMMAND_IO
instead of assuming it has already been enabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoesp-scsi: Convert to new PCI BAR helper functions
Kevin O'Connor [Wed, 3 Feb 2016 03:17:01 +0000 (22:17 -0500)]
esp-scsi: Convert to new PCI BAR helper functions

Use the pci_enable_x() functions.

The esp-scsi controller code will now explicitly set PCI_COMMAND_IO
instead of assuming it has already been enabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoata: Convert to new PCI BAR helper functions
Kevin O'Connor [Wed, 3 Feb 2016 03:14:49 +0000 (22:14 -0500)]
ata: Convert to new PCI BAR helper functions

Use the pci_enable_x() functions.

The ATA controller code will now explicitly set PCI_COMMAND_IO instead
of assuming it has already been enabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoahci: Convert to new PCI BAR helper functions
Kevin O'Connor [Wed, 3 Feb 2016 03:11:30 +0000 (22:11 -0500)]
ahci: Convert to new PCI BAR helper functions

Use the pci_enable_x() functions.

This patch also converts cntl->iobase from a 'u32' to a 'void*' so
that it is clear that the address is a virtual memory address.

After this change, the AHCI driver will no longer enable
PCI_COMMAND_IO io accesses, as the AHCI driver doesn't actually
attempt IO accesses to the device.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agopci: Add helper functions for internal driver BAR handling
Kevin O'Connor [Wed, 3 Feb 2016 03:09:57 +0000 (22:09 -0500)]
pci: Add helper functions for internal driver BAR handling

Add functions to verify and obtain PCI BARs (Base Address Registers).
These new functions check that the requested BAR is of the right type
and appears valid.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agousb: Eliminate USB controller setup thread
Kevin O'Connor [Tue, 2 Feb 2016 19:35:55 +0000 (14:35 -0500)]
usb: Eliminate USB controller setup thread

There are no longer any sleep or yield calls during the usb controller
device scans, so there is no need to run these device scans in a
separate thread.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoehci: Only delay UHCI/OHCI port scan until after EHCI setup completes
Kevin O'Connor [Tue, 2 Feb 2016 19:28:13 +0000 (14:28 -0500)]
ehci: Only delay UHCI/OHCI port scan until after EHCI setup completes

EHCI controller setup needs to occur prior to checking any UHCI or
OHCI ports to ensure a high speed device is not mistakenly configured
on a full speed "companion" controller.  However, only the UHCI/OHCI
port scan needs to be delayed, not the full UHCI/OHCI controller init.

This change moves back the ehci controller setup check until port
scan in UHCI/OHCI.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoFix comment typo
Cao jin [Sat, 30 Jan 2016 07:50:38 +0000 (15:50 +0800)]
Fix comment typo

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
9 years agobiostables: Support SMBIOS 2.6+ UUID format
Cole Robinson [Fri, 15 Jan 2016 15:49:32 +0000 (10:49 -0500)]
biostables: Support SMBIOS 2.6+ UUID format

SMBIOS 2.6+ stores the UUID in a different format, with the first 3
fields in little endian format. This is what modern qemu delivers
and what dmidecode also handles, so let's follow suit too.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
9 years agokbd: Refactor capslock and numlock handling
Kevin O'Connor [Sun, 10 Jan 2016 18:26:26 +0000 (13:26 -0500)]
kbd: Refactor capslock and numlock handling

Simplify the scan_to_keycode[] table by implementing numlock and
capslock checking in the code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agokbd: Don't treat scancode and asciicode as separate values
Kevin O'Connor [Sun, 10 Jan 2016 18:01:48 +0000 (13:01 -0500)]
kbd: Don't treat scancode and asciicode as separate values

The scancode/asciicode pair can be more easily handled as a single
16bit value.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agopost: Always set HaveRunPost prior to setting any other global variable
Kevin O'Connor [Tue, 12 Jan 2016 19:22:33 +0000 (14:22 -0500)]
post: Always set HaveRunPost prior to setting any other global variable

The HaveRunPost flag controls whether post or reboot handling is
entered on a reset signal.  The flag needs to be set before any other
global variable because an external reboot signal could occur at any
time.  (If any global variable is modified prior to setting
HaveRunPost then the code might enter post with global variables in a
dirty state.)

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoresume: Make KVM soft reboot loop detection more flexible
Kevin O'Connor [Mon, 9 Nov 2015 20:00:19 +0000 (15:00 -0500)]
resume: Make KVM soft reboot loop detection more flexible

Move the check for soft reboot loops from resume.c to shadow.c and
directly check for the case where the copy of the BIOS in flash
appears to be a memory alias instead.  This prevents a hang if an
external reboot request occurs during the BIOS memcpy.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agocoreboot: Check for unaligned cbfs header
Kevin O'Connor [Tue, 12 Jan 2016 18:36:50 +0000 (13:36 -0500)]
coreboot: Check for unaligned cbfs header

If the CBFS header is invalid and points to 0xffffffff it could cause
SeaBIOS to read past the 4GB boundary and cause an exception.  Check
the alignment of the header pointer before attempting to access fields
within the header.

Reported-by: "Alex G." <mr.nuke.me@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Do not set TPM in failure mode if menu command fails
Stefan Berger [Thu, 7 Jan 2016 17:02:51 +0000 (12:02 -0500)]
tpm: Do not set TPM in failure mode if menu command fails

Since we may detect that HW physical presence is enabled but we do not detect
whether it is actually asserted, we may fail on the TPM menu commands that
require the assertion of physical presence. We therefore cannot set the TPM
into failure mode if we hit this case. Failure should never occur in these
cases if SW physical presence has been asserted.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Remove usage of PP_CMD_ENABLE from all but one place
Stefan Berger [Thu, 7 Jan 2016 17:02:50 +0000 (12:02 -0500)]
tpm: Remove usage of PP_CMD_ENABLE from all but one place

Remove the usage of PhysicalPresence_CMD_ENABLE from all but
the assert_physical_presence function.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Rework the assertion of physical presence
Stefan Berger [Thu, 7 Jan 2016 17:02:49 +0000 (12:02 -0500)]
tpm: Rework the assertion of physical presence

Rework the assertion of physical presence by calling assert_physical_presence
in tpm_setup. This call will assert physical presence if SW assertion is
possible or by checking whether HW physical presence is enabled.
The TPM menu will only be shown if physical presence is asserted or HW
physical presence is enabled after this call.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Add support for harware physical presence
Stefan Berger [Thu, 7 Jan 2016 17:02:48 +0000 (12:02 -0500)]
tpm: Add support for harware physical presence

Extend assert_physical_presence with checks for hardware physical presence
support. If hardware physical presence is enabled, we return 0.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Move assert_physical_presence and dependencies
Stefan Berger [Thu, 7 Jan 2016 17:02:47 +0000 (12:02 -0500)]
tpm: Move assert_physical_presence and dependencies

Move assert_physical_presence and dependencies in front of tpm_startup
so that the next patches can assert physical presence after TPM_ORD_Startup
ran.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Copy digest into HashLogExentEvent response
Stefan Berger [Thu, 7 Jan 2016 17:02:46 +0000 (12:02 -0500)]
tpm: Copy digest into HashLogExentEvent response

Copy the digest into the response of a HashLogExtendEvent API call.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agousb: Remove usbdev->slotid field
Kevin O'Connor [Tue, 5 Jan 2016 18:41:09 +0000 (13:41 -0500)]
usb: Remove usbdev->slotid field

The usbdev->slotid field is xhci specific and on xhci it is always
reachable from usbdev->defpipe->slotid.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Don't use 16bit BIOS return codes in TPM menu functions
Kevin O'Connor [Wed, 30 Dec 2015 04:04:15 +0000 (23:04 -0500)]
tpm: Don't use 16bit BIOS return codes in TPM menu functions

Don't use the return codes from the 16bit BIOS spec in the internal
menu functions.  Only the 16bit BIOS interface code should need to
handle the details of that spec.  For functions that need to return
the TIS command status, return those codes directly instead of via a
pointer parameter.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Don't use 16bit BIOS return codes in tpmhw_* functions
Kevin O'Connor [Wed, 30 Dec 2015 17:51:27 +0000 (12:51 -0500)]
tpm: Don't use 16bit BIOS return codes in tpmhw_* functions

Don't use the return codes from the 16bit BIOS spec in the internal
tpmhw functions.  Only the 16bit BIOS interface code should need to
handle the details of that spec.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Don't use 16bit BIOS return codes in tpm_log_event()
Kevin O'Connor [Wed, 30 Dec 2015 17:40:11 +0000 (12:40 -0500)]
tpm: Don't use 16bit BIOS return codes in tpm_log_event()

Don't use the return codes from the 16bit BIOS spec in the internal
tpm_log_event() and tpm_log_extend_event() functions.  Only the 16bit
BIOS interface code should need to handle the details of that spec.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Don't use 16bit BIOS return codes in build_and_send_cmd()
Kevin O'Connor [Tue, 29 Dec 2015 22:54:37 +0000 (17:54 -0500)]
tpm: Don't use 16bit BIOS return codes in build_and_send_cmd()

Don't use the return codes from the 16bit BIOS spec in the internal
function build_and_send_cmd().  Instead, return the TIS command status
code of the command or -1 if there was a command transmission failure.
This eliminates the need for a returnCode pointer parameter.

Also, implement debugging dprintf() in build_and_send_cmd() instead of
in every caller.  This replaces the command name with the integer
command id, but it does make the debugging more consistent.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Don't call tpm_set_failure() from tpm_log_extend_event()
Kevin O'Connor [Wed, 30 Dec 2015 05:48:57 +0000 (00:48 -0500)]
tpm: Don't call tpm_set_failure() from tpm_log_extend_event()

The 16bit BIOS interface shouldn't be able to shutdown the TPM.  Move
the check for tpm_is_working() and tpm_set_failure() to the only
caller of tpm_log_extend_event() that may shutdown the TPM.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: No need to check the return status of measurements
Kevin O'Connor [Wed, 30 Dec 2015 05:15:10 +0000 (00:15 -0500)]
tpm: No need to check the return status of measurements

The low-level measurement functions already handle error conditions,
there is no need to check for the errors in the high level measurement
functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Don't return a status from external bios measurement functions
Kevin O'Connor [Wed, 30 Dec 2015 04:14:22 +0000 (23:14 -0500)]
tpm: Don't return a status from external bios measurement functions

The callers of the measurements don't care what happens, so no need to
return a status.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Eliminate response buffer parameter from build_and_send_cmd()
Kevin O'Connor [Tue, 29 Dec 2015 19:32:19 +0000 (14:32 -0500)]
tpm: Eliminate response buffer parameter from build_and_send_cmd()

There are no longer any callers that use the response buffer.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Introduce tpm_get_capability() helper function
Kevin O'Connor [Tue, 29 Dec 2015 19:21:29 +0000 (14:21 -0500)]
tpm: Introduce tpm_get_capability() helper function

Introduce helper function to call the TPM_ORD_GetCapability command.
Update all get capability callers to use this helper.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Simplify tcpa probe
Kevin O'Connor [Sat, 28 Nov 2015 19:25:41 +0000 (14:25 -0500)]
tpm: Simplify tcpa probe

The TPM ACPI tables are only scanned once at startup and the code can
rely on that.  Merge find_tcpa_table() into find_tcpa_by_rsdp(), merge
get_lasa_base_ptr() into reset_acpi_log(), and merge tpm_acpi_init()
into tpm_setup().

The tpm_state structure is now only used for TCPA tracking.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Rework TPM interface shutdown support
Kevin O'Connor [Sat, 28 Nov 2015 18:55:09 +0000 (13:55 -0500)]
tpm: Rework TPM interface shutdown support

The 16bit BIOS interface should only shutdown on request from that
interface - errors from the tcp or acpi log setup should not shutdown
the interface.  (Errors from those functions will cause the TPM to be
in a "not working" state which will cause all the 16bit interface
functions to fail.)

Centralize the checking for the interface shutdown condition in
tpm_interrupt_handler32().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Move TPM hardware functions from tcgbios.c to hw/tpm_drivers.c
Kevin O'Connor [Sat, 28 Nov 2015 18:43:22 +0000 (13:43 -0500)]
tpm: Move TPM hardware functions from tcgbios.c to hw/tpm_drivers.c

Move the hardware interface functions (tpmhw_probe, tpmhw_is_present,
tpmhw_transmit, and tpmhw_set_timeouts) to tpm_drivers.c code, and
only export those functions.  This simplifies the hardware interface.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Add wrapper function tpmhw_set_timeouts()
Kevin O'Connor [Thu, 19 Nov 2015 23:03:35 +0000 (18:03 -0500)]
tpm: Add wrapper function tpmhw_set_timeouts()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Simplify hardware probe and detection checks
Kevin O'Connor [Sat, 28 Nov 2015 13:35:26 +0000 (08:35 -0500)]
tpm: Simplify hardware probe and detection checks

Perform the hardware probe once during setup instead of checking if
the probe has been completed on each measurement event.

Don't probe for hardware during BIOS interface detection.  Just check
if the previous probe found the hardware.

Unify has_working_tpm() with similar tpm_is_working().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Avoid macro expansion of tpm request / response structs
Kevin O'Connor [Sat, 28 Nov 2015 13:08:57 +0000 (08:08 -0500)]
tpm: Avoid macro expansion of tpm request / response structs

Avoid macros and use regular struct definitions for the request and
response headers.  This simplifies the header and reduces the need for
casts in the code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Add banner separating the TCG bios interface code from TCG menu code
Kevin O'Connor [Tue, 29 Dec 2015 17:20:23 +0000 (12:20 -0500)]
tpm: Add banner separating the TCG bios interface code from TCG menu code

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuild: fix typo in buildversion.py
Roger Pau Monne [Mon, 28 Dec 2015 12:50:41 +0000 (13:50 +0100)]
build: fix typo in buildversion.py

Fixes the following build error:

  Building ld scripts
Traceback (most recent call last):
  File "./scripts/buildversion.py", line 134, in <module>
    main()
  File "./scripts/buildversion.py", line 114, in main
    cleanbuild, toolstr = tool_versions(options.tools)
  File "./scripts/buildversion.py", line 90, in tool_versions
    vers[isbinutils] = "mixed"
NameError: global name 'vers' is not defined
Makefile:160: recipe for target 'out/romlayout16.lds' failed

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
9 years agoblock: Report drive->sectors using "%u" instead of "%d"
Kevin O'Connor [Wed, 23 Dec 2015 20:42:35 +0000 (15:42 -0500)]
block: Report drive->sectors using "%u" instead of "%d"

The sector count is a 64bit number that is often reported as a 32bit
number (due to limitations in dprintf).  Consistently use "%u"
reporting to avoid confusing negative numbers.

Reported-by: Tobias Diedrich <tobiasdiedrich@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoscsi: Do not call printf() from scsi_is_ready()
Kevin O'Connor [Wed, 23 Dec 2015 20:37:51 +0000 (15:37 -0500)]
scsi: Do not call printf() from scsi_is_ready()

The scsi_is_ready() function may be called from a thread, and it is
not valid to call printf() from a thread.  Convert printf() to
dprintf() to avoid this possibility.

This does mean that cdrom detection (from cdrom_boot() ) may not give
notification of slow cdrom drives to a user.  However, the extra
medium detection time is unlikely to be large anyway.

Reported-by: Tobias Diedrich <tobiasdiedrich@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agonmi: Don't try to switch onto extra stack in NMI handler
Kevin O'Connor [Wed, 23 Dec 2015 20:33:02 +0000 (15:33 -0500)]
nmi: Don't try to switch onto extra stack in NMI handler

The NMI could occur when already on the extra stack, which would
corrupt it.  Always use the current stack on an NMI to avoid this.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoxhci: Disable slot on failed set_address command
Kevin O'Connor [Sun, 20 Dec 2015 20:50:10 +0000 (15:50 -0500)]
xhci: Disable slot on failed set_address command

If the set_address command fails, attempt to free up the slot resource
associated with the attempt.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoxhci: Improve port status change debugging
Kevin O'Connor [Fri, 18 Dec 2015 17:56:33 +0000 (12:56 -0500)]
xhci: Improve port status change debugging

Report the port state on a port status change notification.  Clear the
change bits so further change notifications are delivered.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoxhci: Wait for port enable even for USB3 devices
Kevin O'Connor [Sun, 13 Dec 2015 19:49:41 +0000 (14:49 -0500)]
xhci: Wait for port enable even for USB3 devices

Some USB3 controllers (and/or devices) need additional time after the
device is detected to place the port in an enabled state.  Wait for
the controller to report enabled before proceeding.  This fixes
several reports of devices that showed a "stall" error (cc 4) during
set address.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agofw/pci: do not automatically allocate IO region for PCIe bridges
Marcel Apfelbaum [Mon, 7 Dec 2015 12:05:14 +0000 (14:05 +0200)]
fw/pci: do not automatically allocate IO region for PCIe bridges

PCIe downstream ports (Root Ports and switches Downstream Ports) appear
to firmware as PCI-PCI bridges and a 4K IO space is allocated for them
even if there is no device behind them requesting IO space,
all that for hotplug purpose.

However, PCIe devices can work without IO, so there is no need
to allocate IO space for hotplug.

Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
9 years agotpm: Add a menu for TPM configuration
Stefan Berger [Mon, 30 Nov 2015 16:14:19 +0000 (11:14 -0500)]
tpm: Add a menu for TPM configuration

This patch adds an new menu entry to the main menu. This menu item enables
the user to enter a TPM control menu which allows control of those aspects
of the TPM's state that can only be controlled while in the firmware
and while physical presence can be asserted.

If the machine has a TPM, the boot menu will look as follows, with
the new menu item accessible by pressing the 't' key.

Select boot device:

1. ata0-1: QEMU HARDDISK ATA-7 Hard-Disk (6144 MiBytes)
2. Legacy option rom
3. iPXE (PCI 00:03.0)

t. TPM Menu

Upon pressing t the TPM submenu will be shown:

The Trusted Platform Module (TPM) is a hardware device in this machine.
It can help verify the integrity of system software.

The current state of the TPM is:
  Enabled and active
  Ownership has not been taken
  A user can take ownership of the TPM

Available options are:
 d. Disable the TPM
 v. Deactivate the TPM
 p. Prevent installation of an owner

If no change is desired or if this menu was reached by mistake, press ESC to
reboot the machine.

The TPM menu only shows those options that are currently accessible considering
the state of the TPM.

The patch adds several functions for sending those messages to the TPM
required for supporting those menu items.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Check length parameter of the array
Stefan Berger [Mon, 30 Nov 2015 16:14:18 +0000 (11:14 -0500)]
tpm: Check length parameter of the array

Check the length parameter that indicates the length of the array
for whether it has a minimum value of 0x200.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Remove check for working TPM from TPM interrupt handler
Stefan Berger [Mon, 30 Nov 2015 16:14:17 +0000 (11:14 -0500)]
tpm: Remove check for working TPM from TPM interrupt handler

Remove the check for a working TPM from the TPM interrupt handler. This then
allows the individual API calls to return information even if the TPM was not
working correctly. Some API calls will still run into the check.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Merge tpm_log_extend_event() and tpm_extend(); extend before logging
Kevin O'Connor [Mon, 23 Nov 2015 00:16:16 +0000 (19:16 -0500)]
tpm: Merge tpm_log_extend_event() and tpm_extend(); extend before logging

Merge tpm_extend() into tpm_log_extend_event().  Also, the spec states
that a log entry should only be added if the extend succeeds, so
attempt the extend prior to adding to the log.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Merge tpm_log_event() and tpm_extend_acpi_log()
Kevin O'Connor [Sun, 22 Nov 2015 23:51:31 +0000 (18:51 -0500)]
tpm: Merge tpm_log_event() and tpm_extend_acpi_log()

Merge tpm_extend_acpi_log() and tpm_log_event().  Move error checking
and handling to callers.  Don't shutdown the TPM on a failure from the
16bit BIOS interface.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Don't implement scatter-gather in transmit()
Kevin O'Connor [Sun, 22 Nov 2015 23:21:45 +0000 (18:21 -0500)]
tpm: Don't implement scatter-gather in transmit()

There are no longer any callers to transmit() that use multiple
buffers.  Simplify transmit() so that it takes a single request
buffer.

The pass_through_to_tpm() wrapper around transmit() is no longer
needed.  Remove the function and have all callers use transmit()
directly.

Now that tpm_extend() function calls transmit directly, it can use
TPM_DURATION_TYPE_SHORT duration.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Avoid scatter-gather copying in build_and_send_cmd()
Kevin O'Connor [Sun, 22 Nov 2015 22:56:53 +0000 (17:56 -0500)]
tpm: Avoid scatter-gather copying in build_and_send_cmd()

Setup the tpm hardware request in a linear area of memory.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: There is no need to pass event_length to hash/extend functions
Kevin O'Connor [Sun, 22 Nov 2015 22:28:36 +0000 (17:28 -0500)]
tpm: There is no need to pass event_length to hash/extend functions

The event_length field is already in pcpes->eventdatasize.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Perform hashing separately from logging
Kevin O'Connor [Sun, 22 Nov 2015 21:54:18 +0000 (16:54 -0500)]
tpm: Perform hashing separately from logging

Instead of calculating the hash in hash_log_event(), create a new
function (tpm_fill_hash) that will create the hash, and update all
callers to use tpm_fill_hash() before calling hash_log_event().  This
reduce the number of parameters to hash_log_event().

Rename hash_log_event() and hash_log_extent_event() to tpm_log_event()
and tpm_log_extend_event() now that these functions no longer
implement the hashing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: There is no need to pass pcrindex to hash_log_extend_event()
Kevin O'Connor [Sun, 22 Nov 2015 21:43:47 +0000 (16:43 -0500)]
tpm: There is no need to pass pcrindex to hash_log_extend_event()

The pcrindex is already in pcpes->pcrindex, so no need to pass it as a
parameter.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Don't pass entry_count around in parameters to/from tpm_extend_acpi_log()
Kevin O'Connor [Sun, 22 Nov 2015 21:39:59 +0000 (16:39 -0500)]
tpm: Don't pass entry_count around in parameters to/from tpm_extend_acpi_log()

Now that entry_count is in a global variable there is no need to pass
it around as function parameters.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: pcpes->event is a variable length array
Kevin O'Connor [Tue, 24 Nov 2015 03:32:09 +0000 (22:32 -0500)]
tpm: pcpes->event is a variable length array

The event field can be of an arbitrary length.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Move tpm_start_option_rom_scan() and tpm_calling_int19h() into callers
Kevin O'Connor [Sun, 22 Nov 2015 16:34:38 +0000 (11:34 -0500)]
tpm: Move tpm_start_option_rom_scan() and tpm_calling_int19h() into callers

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Move tpm_add_bootdevice() into callers
Kevin O'Connor [Thu, 19 Nov 2015 22:43:27 +0000 (17:43 -0500)]
tpm: Move tpm_add_bootdevice() into callers

The switch statement in tpm_add_bootdevice() corresponds with its call
sites - just perform the appropriate action in each caller.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Change tpm_add_measurement() to tpm_add_action()
Kevin O'Connor [Sun, 22 Nov 2015 16:28:14 +0000 (11:28 -0500)]
tpm: Change tpm_add_measurement() to tpm_add_action()

Make the only caller of tpm_add_measurement() with EV_SEPARATOR
directly call tpm_add_measurement_to_log().  Rename to
tpm_add_action() and change all callers with EV_ACTION to use this
function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Open code tpm_ipl() into callers
Kevin O'Connor [Sun, 22 Nov 2015 16:15:51 +0000 (11:15 -0500)]
tpm: Open code tpm_ipl() into callers

The only three callers of tpm_ipl() exactly correlate with the three
switch branches in tpm_ipl(), so just move the appropriate code into
the callers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Move error recovery from tpm_extend_acpi_log() to only caller
Kevin O'Connor [Sun, 22 Nov 2015 16:00:06 +0000 (11:00 -0500)]
tpm: Move error recovery from tpm_extend_acpi_log() to only caller

Move tpm state checking and error handling from tpm_extend_acpi_log()
to its only caller hash_log_event().  This makes tpm_extend_acpi_log()
specific to just ACPI table handling.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Move code around in tcgbios.c
Kevin O'Connor [Sun, 22 Nov 2015 15:57:52 +0000 (10:57 -0500)]
tpm: Move code around in tcgbios.c

Move like functions near each other.  Reduce forward function
declarations.  This is only code movement - no code changes.

This groups the code into six sections: TPM state tracking, TPM
hardware interface, ACPI TCPA table interface, Helper functions, Setup
and Measurements, BIOS interface.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Add "static" declaration to functions not used outside tcgbios.c
Kevin O'Connor [Thu, 19 Nov 2015 21:23:39 +0000 (16:23 -0500)]
tpm: Add "static" declaration to functions not used outside tcgbios.c

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Rename remaining interrupt functions
Stefan Berger [Sat, 21 Nov 2015 19:54:44 +0000 (14:54 -0500)]
tpm: Rename remaining interrupt functions

Rename all remaining functions called directly by the BIOS interrupt
by adding the suffix '_int' to them.

Add the check for whether the preboot interface is shut down
where missing.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Refactor pass_through_to_tpm
Stefan Berger [Sat, 21 Nov 2015 19:54:43 +0000 (14:54 -0500)]
tpm: Refactor pass_through_to_tpm

Refactor the signature of the pass_through_to_tpm function to take
individual pointers as parameters and introduce pass_through_to_tpm_int
as a function to be called with the parameters passed from the BIOS
interrupt.

Refactor existing callers that now do not have to build up the data
structure expected by the BIOS interface.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Cache all log related pointers in tpm_state
Stefan Berger [Sat, 21 Nov 2015 19:54:42 +0000 (14:54 -0500)]
tpm: Cache all log related pointers in tpm_state

Move the tpm_state to RAM area and add all log related pointers
to it so they can be cached. Remove functions that previously
determined these pointers by searching for the TCPA ACPI table
and walking the log.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Set timeouts and durations to microsecond values
Stefan Berger [Sat, 21 Nov 2015 19:54:41 +0000 (14:54 -0500)]
tpm: Set timeouts and durations to microsecond values

Fix the timeouts and durations -- they are provided in microseconds.
Adapt the TPM driver for it.

Get TPM specific timeout and duration values earlier from the device.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Drop code using the TPM for sha1
Stefan Berger [Sat, 21 Nov 2015 19:54:40 +0000 (14:54 -0500)]
tpm: Drop code using the TPM for sha1

Drop the code that is using the TPM for sha1 calculations.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agoutil.h: Minor - HaveRunPost is in misc.c not resume.c
Kevin O'Connor [Thu, 19 Nov 2015 20:29:39 +0000 (15:29 -0500)]
util.h: Minor - HaveRunPost is in misc.c not resume.c

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: Move standard definitions from tcgbios.h to new file std/tcg.h
Kevin O'Connor [Thu, 19 Nov 2015 14:24:18 +0000 (09:24 -0500)]
tpm: Move standard definitions from tcgbios.h to new file std/tcg.h

Tested-by: Stefan Berger <stefanb@us.ibm.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agotpm: fix compiler warning with older gcc versions
Stefan Berger [Tue, 17 Nov 2015 15:55:40 +0000 (10:55 -0500)]
tpm: fix compiler warning with older gcc versions

gcc v3.4 shows a warning due to "comparison is always false due to
limited range of data type". This patch fixes it.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Refactor hash_log_extend_event
Stefan Berger [Thu, 12 Nov 2015 15:14:49 +0000 (10:14 -0500)]
tpm: Refactor hash_log_extend_event

Refactor the signature of the hash_log_extend_event to take individual
pointers as parameters and introduce hash_log_extend_event_int as a
function to be called with the parameters passed from the BIOS interrupt.

Refactor existing callers to hash_log_extend_event that now do not
have to build up the data structure expected by the BIOS interface.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Refactor hash_log_event BIOS interface function
Stefan Berger [Thu, 12 Nov 2015 15:14:48 +0000 (10:14 -0500)]
tpm: Refactor hash_log_event BIOS interface function

Refactor the signature of hash_log_event to take individual pointers
as parameters and introduce hash_log_event_int as an function to
be called with the parameters passed from the BIOS interrupt.

Refactor existing callers to hash_log_event that now do not
have to build up the data structures expected by the BIOS interface.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Refactor the parameters being passed to tpm_extend_acpi_log
Stefan Berger [Thu, 12 Nov 2015 15:14:47 +0000 (10:14 -0500)]
tpm: Refactor the parameters being passed to tpm_extend_acpi_log

Refactor the parameters being passed to tpm_extend_acpi_log in such
a way that the header of the logged event is passed in separate
from the 'body'.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Refactor function building TPM commands
Stefan Berger [Thu, 12 Nov 2015 15:14:46 +0000 (10:14 -0500)]
tpm: Refactor function building TPM commands

Refactor the function building TPM commands to get rid of one of
the buffers it uses for building a command. To do that, have it use
the iovec also for the 'append' array that's being passed to the
function.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agotpm: Temporarily deactivate the TPM in case of failure
Stefan Berger [Thu, 12 Nov 2015 15:14:45 +0000 (10:14 -0500)]
tpm: Temporarily deactivate the TPM in case of failure

Temporarily deactivate the TPM in case of failure of TPM commands
and failure to log measurements. Introduce the tpm_set_failure()
function replacing occurrences of 'tpm_state.tpm_working = 0' and
invoke it in error paths.

Temporarily deactivating the TPM means that it will be active again
upon reboot.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agoacpi: Remove build check for iasl
Kevin O'Connor [Tue, 17 Nov 2015 23:52:05 +0000 (18:52 -0500)]
acpi: Remove build check for iasl

The iasl program is no longer used on a default build.  Do not require
it to be installed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoacpi: Don't build SSDT files on every build; store them in git
Kevin O'Connor [Tue, 17 Nov 2015 23:45:41 +0000 (18:45 -0500)]
acpi: Don't build SSDT files on every build; store them in git

The SSDT files are rarely modified - recent QEMU versions don't use
them at all and adding features to them in SeaBIOS has been
deprecated.  It no longer makes sense to generate them on every build.
The content will remain (for use on old machine types in QEMU) in
static files committed to the SeaBIOS git repo.  If the contents do
need to be generated a new build target (make iasl) is available.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoacpi_extract: Don't generate unused (and empty) q35-acpi-dsdt.hex file
Kevin O'Connor [Tue, 17 Nov 2015 23:39:17 +0000 (18:39 -0500)]
acpi_extract: Don't generate unused (and empty) q35-acpi-dsdt.hex file

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoacpi_extract: Make the generated .hex files more human readable
Kevin O'Connor [Tue, 17 Nov 2015 23:36:17 +0000 (18:36 -0500)]
acpi_extract: Make the generated .hex files more human readable

Add a comment to the top of the generated file indicating that is is
an automatically generated file.  Compress output so that up to eight
hex values are placed on a single line.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoacpi_extract: Move main code to new function main()
Kevin O'Connor [Tue, 17 Nov 2015 23:24:24 +0000 (18:24 -0500)]
acpi_extract: Move main code to new function main()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>