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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>