]> xenbits.xensource.com Git - seabios.git/log
seabios.git
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>
9 years agosdcard: Enable extra debugging on sdcard_waitw() timeout
Kevin O'Connor [Tue, 17 Nov 2015 19:56:04 +0000 (14:56 -0500)]
sdcard: Enable extra debugging on sdcard_waitw() timeout

On a timeout, report what register failed to update.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: fix typo causing 32bit write to 16bit block_size field
Kevin O'Connor [Tue, 17 Nov 2015 19:54:11 +0000 (14:54 -0500)]
sdcard: fix typo causing 32bit write to 16bit block_size field

The block_size field is 16bits and only 16bit writes should be used
with it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agosdcard: Only enable error_irq_enable for bits defined in SDHCI v1 spec
Kevin O'Connor [Tue, 17 Nov 2015 19:52:23 +0000 (14:52 -0500)]
sdcard: Only enable error_irq_enable for bits defined in SDHCI v1 spec

The SDHCI v1 spec only defines the first 9 error_irq_enable bits and
reserves other bits in the field.  Don't enable the 10th bit (which
was defined in the v2 spec) as it's not needed anyway.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoxhci: Check for device disconnects during USB2 reset polling
Kevin O'Connor [Tue, 10 Nov 2015 13:50:52 +0000 (08:50 -0500)]
xhci: Check for device disconnects during USB2 reset polling

Some XHCI controllers register super-speed devices on high-speed ports
and then disconnect them when the super-speed detection completes.
Make sure to recognize these disconnect events during the reset
process.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agousb: Allow configuration of sigatt time (in etc/usb-time-sigatt)
Kevin O'Connor [Mon, 9 Nov 2015 17:00:52 +0000 (12:00 -0500)]
usb: Allow configuration of sigatt time (in etc/usb-time-sigatt)

Several users have reported devices that take more than 100ms to
announce their presence on a USB port.  Allow the sigatt timeout to be
specified at runtime as a way to extend the default timeout.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agodocs: Note v1.9.0 release rel-1.9.0
Kevin O'Connor [Tue, 17 Nov 2015 14:18:44 +0000 (09:18 -0500)]
docs: Note v1.9.0 release

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuildversion: Add debugging messages
Kevin O'Connor [Tue, 10 Nov 2015 14:26:52 +0000 (09:26 -0500)]
buildversion: Add debugging messages

Add ability to output debug messages from the buildversion.py build
script.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuildversion: Avoid subprocess.check_output() as that requires python2.7
Kevin O'Connor [Mon, 9 Nov 2015 14:23:26 +0000 (09:23 -0500)]
buildversion: Avoid subprocess.check_output() as that requires python2.7

Don't require python2.7 in buildversion.py.  Also, ignore only those
exceptions that are known to be possible.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoPCI SDHCI driver: Fix base address
Kyösti Mälkki [Wed, 4 Nov 2015 05:40:12 +0000 (07:40 +0200)]
PCI SDHCI driver: Fix base address

MMIO register space was off by 4 bytes, bottom bits of
PCI BAR registers are not part of the address.

Test boot on real hardware:

PCI device 00:14.7 (vd=3D1022:7813 c=3D0805)

Searching bootorder for: /pci@i0cf8/*@14,7
sdhci@0xfeb25500 ver=3D1001 cap=3D31fe3fb2 2570
sdcard_set_frequency 63 400 8000
sdcard_pio command stop (code=3D1)
sdcard_set_frequency 63 25000 200
Found sdcard at 0xfeb25500: SD card SD01G 982MiB
Registering bootable: SD card SD01G 982MiB (type:2 prio:103 data:f46e0)

Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
9 years agodocs: Minor - replace seavgabios text in Build_overview.md with link
Kevin O'Connor [Mon, 26 Oct 2015 13:38:30 +0000 (09:38 -0400)]
docs: Minor - replace seavgabios text in Build_overview.md with link

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agovirtio: Minor - replace tab characters with space
Kevin O'Connor [Sun, 18 Oct 2015 15:27:50 +0000 (11:27 -0400)]
virtio: Minor - replace tab characters with space

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobiostables: Minor - fix incorrect indentation
Kevin O'Connor [Sun, 18 Oct 2015 15:25:15 +0000 (11:25 -0400)]
biostables: Minor - fix incorrect indentation

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agocoreboot: Minor - avoid K&R style function declaration
Kevin O'Connor [Sun, 18 Oct 2015 15:24:54 +0000 (11:24 -0400)]
coreboot: Minor - avoid K&R style function declaration

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuild: Allow official tarball builds to be considered "clean"
Kevin O'Connor [Thu, 22 Oct 2015 15:59:47 +0000 (11:59 -0400)]
build: Allow official tarball builds to be considered "clean"

If building from an official tarball and EXTRAVERSION info is
provided, then consider the build to be "clean" (don't include
hostname/build timestamp).  This is done on the expectation that
EXTRAVERSION will have enough information to allow developers to find
the builder and build environment should a defect be reported, and
therefore the hostname/timestamp is not necessary.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agodocs: Document 'make EXTRAVERSION=xyz' and scripts/tarball.sh
Kevin O'Connor [Thu, 22 Oct 2015 15:58:16 +0000 (11:58 -0400)]
docs: Document 'make EXTRAVERSION=xyz' and scripts/tarball.sh

Document the existence of the EXTRAVERSION field and the information
expected to be present in it.  Document the use of tarball.sh in build
environments that lack git.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuild: Be more permissive in buildversion.py tool version scan
Kevin O'Connor [Thu, 22 Oct 2015 00:35:50 +0000 (20:35 -0400)]
build: Be more permissive in buildversion.py tool version scan

There is some variation in version strings between various tool chain
builds.  Make the version tool scan more permissive to attempt to
handle these variations.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoAdd QEMU fw_cfg DMA interface
Marc Marí [Thu, 8 Oct 2015 15:03:26 +0000 (17:03 +0200)]
Add QEMU fw_cfg DMA interface

Add support for the new fw_cfg DMA interface. The protocol is explained in
QEMU documentation.

Signed-off-by: Marc Marí <markmb@redhat.com>
9 years agomalloc: Rename csm_malloc_preinit() to malloc_csm_preinit()
Kevin O'Connor [Thu, 15 Oct 2015 17:53:04 +0000 (13:53 -0400)]
malloc: Rename csm_malloc_preinit() to malloc_csm_preinit()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agostacks: Use macro wrappers for call32() and stack_hop_back()
Kevin O'Connor [Fri, 9 Oct 2015 15:53:02 +0000 (11:53 -0400)]
stacks: Use macro wrappers for call32() and stack_hop_back()

The C code only uses _cfuncX_ prefixes for parameters to the call32(),
stack_hop_back(), and call32_params() functions.  It's simpler to use
macro wrappers around those functions which provide the required
prefix.

This also changes the parameter order of stack_hop() and
stack_hop_back() to use the more natural (func, params) ordering.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuild: Generate "reproducible" version strings on "clean" builds
Kevin O'Connor [Tue, 13 Oct 2015 19:49:03 +0000 (15:49 -0400)]
build: Generate "reproducible" version strings on "clean" builds

If the build environment looks "clean" then don't add the build
hostname or build time to the version string.  This makes the default
build string reproducible across builds.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuild: Report gcc and binutils versions in debug log
Kevin O'Connor [Tue, 13 Oct 2015 19:44:25 +0000 (15:44 -0400)]
build: Report gcc and binutils versions in debug log

Attempt to extract the gcc and binutils versions.  Report that
information in the debug log.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agobuild: Rework version generation; don't allow make version override
Kevin O'Connor [Tue, 13 Oct 2015 19:09:40 +0000 (15:09 -0400)]
build: Rework version generation; don't allow make version override

Convert the script to generate the build version from a shell script
to a python script.

Remove the ability to override the version at build time via "make
VERSION=xyz".  Replace it with ability to add extra version
information at build time via "make EXTRAVERSION=xyz".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomemmap: Introduce SYMBOL() macro to access linker script symbols
Kevin O'Connor [Thu, 8 Oct 2015 15:18:17 +0000 (11:18 -0400)]
memmap: Introduce SYMBOL() macro to access linker script symbols

Use a macro to define and obtain the value of a symbol introduced by
the linker scripts (scripts/layoutrom.py).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomalloc: Don't mix virtual and physical addresses
Kevin O'Connor [Tue, 22 Sep 2015 18:45:25 +0000 (14:45 -0400)]
malloc: Don't mix virtual and physical addresses

Consistently use 'u32' for physical addresses and pointers for virtual
addresses in the malloc code.  Introduce and use memremap() where a
physical address needs to be converted to a virtual address.  Use
virt_to_phys() for the inverse.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomalloc: Add warning if free() called on invalid memory
Kevin O'Connor [Tue, 6 Oct 2015 19:37:53 +0000 (15:37 -0400)]
malloc: Add warning if free() called on invalid memory

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomalloc: Introduce common helper alloc_new_detail()
Kevin O'Connor [Tue, 29 Sep 2015 02:20:27 +0000 (22:20 -0400)]
malloc: Introduce common helper alloc_new_detail()

Introduce helper for finding temp space to hold an "allocation detail
struct" and use it in both alloc_add() and _malloc().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agomalloc: Use consistent naming for internal low-level "alloc" functions
Kevin O'Connor [Tue, 29 Sep 2015 01:45:38 +0000 (21:45 -0400)]
malloc: Use consistent naming for internal low-level "alloc" functions

Use the "alloc_" prefix for all the low-level allocation functions and
avoid camelCase naming.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agovirtio: Move standard definitions from virtio-ring.h to standard headers
Kevin O'Connor [Tue, 29 Sep 2015 14:14:58 +0000 (10:14 -0400)]
virtio: Move standard definitions from virtio-ring.h to standard headers

Move PAGE_SHIFT / virt_to_phys() to memmap.h and smp_[rw]mb() to
x86.h.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agovirtio: Simplify vring alignment code
Kevin O'Connor [Tue, 22 Sep 2015 15:46:48 +0000 (11:46 -0400)]
virtio: Simplify vring alignment code

Don't do phys_to_virt(virt_to_phys(vaddr)) for page alignment - page
alignment can be determined directly from the virtual address.

Use the ALIGN() macro to make the code more readable.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoe820: Update debugging messages to report 64bit values
Kevin O'Connor [Thu, 1 Oct 2015 03:00:43 +0000 (23:00 -0400)]
e820: Update debugging messages to report 64bit values

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoe820: Rename memmap.c to e820map.c and use consistent "e820_" prefix
Kevin O'Connor [Tue, 29 Sep 2015 13:40:46 +0000 (09:40 -0400)]
e820: Rename memmap.c to e820map.c and use consistent "e820_" prefix

Rename memmap.c to e820map.c as the code in that file only deals with
maintaining the e820 map.  Move all the e820 definitions to new file
e820map.h and use a consistent "e820_" prefix on all exported
functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoe820: Introduce e820_remove() and avoid exporting E820_HOLE
Kevin O'Connor [Tue, 29 Sep 2015 12:53:38 +0000 (08:53 -0400)]
e820: Introduce e820_remove() and avoid exporting E820_HOLE

The E820_HOLE definition is used internally in the e820 manipulation
code to remove entries from the e820 map.  Introduce the e820_remove()
function so that the E820_HOLE definition does not need to be exported
from the memmap.c code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoFix typos found by codespell
Stefan Weil [Fri, 2 Oct 2015 06:46:40 +0000 (08:46 +0200)]
Fix typos found by codespell

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoAlways enable caching on transition32; backup/restore cr0 on call32
Kevin O'Connor [Tue, 22 Sep 2015 16:35:00 +0000 (12:35 -0400)]
Always enable caching on transition32; backup/restore cr0 on call32

Always enable caching at start of 32bit code and always make sure the
paging flag is off.  Because this alters the cr0 register, perform a
backup and restore of it when using call32().

Also, rename get/setcr0() to cr0_read/write() to more closely match
other register access functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoConsolidate code16*() functions
Kevin O'Connor [Tue, 22 Sep 2015 18:38:14 +0000 (14:38 -0400)]
Consolidate code16*() functions

Introduce code16_override() for cases where call16() should not
restore the previous 16bit state.  All callers now use call16_back()
to invoke 16bit code, so rename call16_back() to call16().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoUse transition32_nmi_off from call32() and call16_back()
Kevin O'Connor [Fri, 11 Sep 2015 20:19:02 +0000 (16:19 -0400)]
Use transition32_nmi_off from call32() and call16_back()

The call32() and call16_back() functions will always disable NMI and
enable a20 (via the call32_prep() function) so it is safe to use the
_nmi_off variant of transition32.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoUnify call32_sloppy() and call32()
Kevin O'Connor [Fri, 11 Sep 2015 20:15:23 +0000 (16:15 -0400)]
Unify call32_sloppy() and call32()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
9 years agoUnify inline assembler in variants of call16 functions
Kevin O'Connor [Fri, 11 Sep 2015 20:07:59 +0000 (16:07 -0400)]
Unify inline assembler in variants of call16 functions

The assembler between call16(), call16big() and call16_sloppy() are
very similar.  Rework the functions so that a single version of the
inline assembly can be used for all variants.

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