Kevin O'Connor [Thu, 23 Jul 2015 13:19:23 +0000 (09:19 -0400)]
ramdisk: Allow ramdisk support (CONFIG_FLASH_FLOPPY) under QEMU
Don't require coreboot to use CONFIG_FLASH_FLOPPY - with the latest
QEMU, it's possible to place a floppy image into fw_cfg using the qemu
command line (eg, "-fw_cfg name=floppyimg/MyFloppy,file=file.img").
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Thu, 23 Jul 2015 12:36:01 +0000 (08:36 -0400)]
timer: Add CONFIG_TSC_TIMER build option to disable the CPU TSC timer
Allow users to remove the CPU timestamp counter support at compile
time. The PMTIMER is frequently used instead of the TSC and this
compile time option allows one to strip a few bytes from the final
binary. This change also defaults the internal timer to use the PIT
based timer until the PMTIMER or TSC is detected.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 22 Jul 2015 20:06:27 +0000 (16:06 -0400)]
timer: Delay timestamp counter init until after pmtimer is probed
Delay call to timer_setup() until after the xxx_platform_setup() calls
so that the pmtimer can be detected first. Most modern machines will
have a pmtimer and calibrating the timestamp counter is frequently
unnecessary.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 22 Jul 2015 18:32:28 +0000 (14:32 -0400)]
ps2: Don't wait 100ms to discard possible extra reset receive byte
The existing PS2 port code waits 100ms to see if the device attached
to the keyboard port responds to a reset command with two bytes
(instead of the normal one byte). If an extra byte is received, it is
discarded.
Receiving two bytes would be unusual and waiting to check for that
event is unnecessary because the next command in the keyboard init
sequence already seamlessly discards any extra bytes in the command
queue.
This patch eliminates the 100ms wait, which notably reduces the
SeaBIOS boot time on QEMU. This patch also forces PS2 mice to always
respond with two bytes during a reset sequence (instead of just one
byte), which is a good sanity check.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 14 Jul 2015 19:44:26 +0000 (15:44 -0400)]
Don't enable interrupts prior to IVT and PIC setup
The machine may crash if an interrupt occurs prior to the setup of the
interrupt vector table (IVT) and programmable interrupt controller
(PIC). This patch makes sure that interrupts remain disabled until
these components are setup.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 14 Jul 2015 19:12:25 +0000 (15:12 -0400)]
ata: Make sure "chanid" is relative to PCI device for bootorder file
When specifying drives in the bootorder file, the "drive@x" parameter
should be relative to the given PCI device and not relative to the
total number of ATA controllers in the machine. This patch separates
the tracking of "chanid" (channel number relative to a given PCI
devices) from the "ataid" (channel number relative to the total number
of ATA channels).
Reported-by: Jonathan A. Kollasch <jakllsch@kollasch.net> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 12 Nov 2014 17:15:34 +0000 (12:15 -0500)]
ps2: Support mode for polling the PS2 port instead of using irqs
Some recent hardware has trouble with routing PS2 port interrupts
while the interrupt controller is in legacy routing mode. This patch
adds a config mechanism (via "etc/ps2-poll-only") to force the PS2
code into a polling only mode so that interrupts are not required.
It is not recommended to use this polling mode on hardware that does
properly support PS2 irqs, because some very old (DOS-era) programs
depend on the BIOS PS2 irq behavior.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Wed, 8 Jul 2015 23:05:54 +0000 (19:05 -0400)]
coreboot: Try to auto-detect if the CBFS anchor pointer is a relative pointer
If CONFIG_CBFS_LOCATION is set to a non-zero value then it means the
CBFS flash is not at the very end of memory. In this case, it's
unclear if the anchor pointer is an absolute pointer or if it is
relative to CONFIG_CBFS_LOCATION. Some devices have been using
absolute pointers, but it appears some devices are now using relative
pointers there. Since the anchor pointer almost always points to a
structure in the last 64K of the rom, it should be possible to
auto-detect if the pointer is relative or not.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 7 Jul 2015 13:53:54 +0000 (09:53 -0400)]
block: Route scsi style commands through 'struct disk_op_s'
Support sending scsi style "command data block" commands (cdbcmd)
through the 'struct disk_op_s' command request structure. And change
the blockcmd.c and cdrom.c code to route these commands through the
process_op() code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 7 Jul 2015 13:01:52 +0000 (09:01 -0400)]
block: Introduce default_process_op() with common command handling codes
Most disk drivers only implement a couple of the available bios
commands. Unify the common fallback handling code into a new function
default_process_op() to reduce boiler-plate code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 7 Jul 2015 12:35:51 +0000 (08:35 -0400)]
block: Split process_op() command dispatch up into multiple functions
Introduce process_op_32(), process_op_16(), and process_op_both() and
split the disk driver command dispatch by its runtime mode
requirements. This makes it more clear which modes each driver runs
in. It also reduces the call32() boiler-plate code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Gerd Hoffmann [Thu, 25 Jun 2015 07:36:16 +0000 (09:36 +0200)]
virtio: add struct vp_device
For virtio 1.0 support we will need more state than just the (legacy
mode) ioaddr for each virtio-pci device. Prepare for that by adding
a new struct for it. For now it carries the ioaddr only.
Gerd Hoffmann [Fri, 26 Jun 2015 07:44:00 +0000 (09:44 +0200)]
virtio: run drivers in 32bit mode
virtio version 1.0 registers can (and actually do in the qemu
implementation) live in mmio space. So we must run the blk and
scsi virtio drivers in 32bit mode, otherwise we can't access them.
This also allows to drop a bunch of GET_LOWFLAT calls from the virtio
code in the following patches.
Gerd Hoffmann [Thu, 25 Jun 2015 08:49:10 +0000 (10:49 +0200)]
pci: allow to loop over capabilities
Add a parameter to pci_find_capability, to specify the start point.
This allows to find multiple capabilities of the same type, by calling
pci_find_capability again with the offset of the last capability found.
Unlike planned earlier virtio-vga will be compatible with
the qemu stdvga, with the framebuffer in bar 0. Drop the
virtio-vga chunk, update comment accordingly.
Kevin O'Connor [Wed, 3 Jun 2015 23:17:12 +0000 (19:17 -0400)]
build: Support "make VERSION=xyz" to override the default build version
Add a build option to explicitly set the version information compiled
into the seabios and seavgabios binaries. This may assist in
reproducible builds or to better link builds to distribution packages.
If the new "VERSION=" parameter is not provided then the default build
version remains unchanged.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Stefan Berger [Tue, 26 May 2015 19:48:33 +0000 (15:48 -0400)]
Add 'measurement' code to the BIOS
This patch adds invocations of functions that measure various parts of the
code and data through various parts of the BIOS code. It follows TCG
specifications on what needs to be measured. It also adds the implementation
of the called functions.
Reference for what needs to be measured can be found in specs found here:
The first measurements are done once the ACPI tables have been initialized.
Once booted into Linux, the current measurements produce the following logs
which can be found in /sys/kernel/security/tpm0/ascii_bios_measurements.
The below log also shows measurements from trusted grub.
I've been successfully using SeaBIOS as secondary bootloader. In more details
I have GRUB2-as-payload in flash together with coreboot. SeaBIOS binary is on
the HDD and loaded by GRUB when needed. This has an unfortunate consequence
that I have to keep vga oprom in flash even if usually I boot without it. This
patches makes bios.bin.elf multiboot executable with files passed as modules.
Example:
Stefan Berger [Mon, 23 Mar 2015 18:22:17 +0000 (14:22 -0400)]
Support for BIOS interrupt handler
This patch implements the TCG BIOS interrupt handler 1ah. It is for
example used by trusted grub.
This patch adds an implementation of SHA1 (following NIST specs., IETF RFC 3147
and Wikipedia) for speeding up measurements of code. Trusted Grub for example
makes use of this interface and measures (calculates SHA1) of the Linux kernel
and initrd. Those files can be rather large and hunting their bytes through
the TIS interface as part of the int handler commands invoked by trusted grub
does take quite some time due to the many vmexits the interface is creating
(one per byte).
There is also a threshold for the size of data to hash (100k) below which
the TPM is used and above the internal faster SHA1 algorithm is used.
This patch for example enables trusted grub to interact with the TPM
and take additional measurements.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Stefan Berger [Mon, 23 Mar 2015 18:22:16 +0000 (14:22 -0400)]
Implementation of the TCG BIOS extensions
This patch implements the main part of the TCG BIOS extensions. It provides
the following functionality:
- initialization of the TCPA ACPI table used for logging of measurements
- initialization of the TPM by sending a sequence of commands to it
- proper setup of the TPM before the BIOS hands over control to the bootloader
- support for S3 resume; BIOS sends TPM_Startup(ST_STATE) to TPM
- enable configuration of SeaBIOS to be built with TCGBIOS extensions
All TCG BIOS extensions are activated with CONFIG_TCGBIOS.
Structures that are needed in subsequent patches are also included in
tcgbios.h at this point.
The effect of this patch is that it initialized the TPM upon VM start
and S3 resume.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Stefan Berger [Mon, 23 Mar 2015 18:22:15 +0000 (14:22 -0400)]
Add an implementation of a TPM TIS driver
This patch adds an implementation of a TPM TIS driver for the TPM TIS
emulation supported by QEMU. The driver is broken up into several
small functions that have to be called in proper sequence. The driver is
cleanly separated from the rest of the code through an interface holding
pointers to the driver's functions.
A client using this driver first probes whether the TPM TIS
interface is available (probe function) and then invokes the interface
function to initialze the interface and send requests and receive responses.
Possible future extensions *could* include a virtio interface for the TPM
with a corresponding driver here.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
At least AHCI on Intel on some machines claim to support only 6 ports
while in fact higher port numbers are present and work.
This is needed to access CD-ROM on PackardBell MS2290.
Both GRUB and Linux have a similar workaround.
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Paolo Bonzini [Wed, 6 May 2015 10:38:29 +0000 (12:38 +0200)]
smm: ignore bits 16,18-31 of SMM revision ID
Bits 16-31 of the SMM revision ID are feature bits. We only need to
check that SMBASE relocation is supported, but do not care about other
features. In particular, this allows the SMM I/O instruction restart
feature to be present.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Kevin O'Connor [Thu, 9 Apr 2015 21:15:23 +0000 (17:15 -0400)]
vgabios: Add config option for assembler fixups
Add a kconfig build option (CONFIG_VGA_FIXUP_ASM) to allow users to
build the vgabios without the complex assembler fixups that work
around emulator bugs.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Thu, 9 Apr 2015 16:24:18 +0000 (12:24 -0400)]
vgabios: Don't use "smsww" instruction - it confuses x86emu
Commit 251e2638 introduced the "smsww" instruction to the vgabios.
Unfortunately, it appears at least some versions of x86emu crash when
executing that instruction (eg, FC13 installer crashes). That
instruction wasn't required to work around the problem fixed in 251e2638, so just avoid it.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Thu, 9 Apr 2015 15:57:44 +0000 (11:57 -0400)]
smbios: Use integer signature instead of string signature
Change the smbios structure to use a 4 byte u32 signature field
instead of a 4 byte character string field. In practice, this allows
the compiler to place the signature in the initialize code segment and
thus makes it less likely the signature would be found in the
f-segment. (If the smbios signature is found in the f-segment it can
confuse some table scans.)
Reviewed-by: Bruce Rogers <brogers@suse.com> Tested-by: Bruce Rogers <brogers@suse.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor [Tue, 17 Mar 2015 15:37:25 +0000 (11:37 -0400)]
vgabios: Don't use extra stack if it appears a modern OS is in use
If the last mode set (while not in vm86 mode) was done from a VBE mode
set call then disable the extra stack. This works under the premise
that only a modern OS would invoke the VBE mode changing facilities
and a modern OS would always call the vgabios with sufficient stack
space.
This is an ugly hack to work around a problem Windows Vista (and
possibly later Windows releases) has with the VGA BIOS using a stack
in the e-segment.
Reported-by: Richard Laager <rlaager@wiktel.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Paolo Bonzini [Thu, 12 Mar 2015 17:12:24 +0000 (18:12 +0100)]
boot: switch default menu key to ESC
On some platforms, F12 may be hard to access; for example, on OS X
machines F9-F12 have been intercepted by the OS for a long time, and
on newer OS X releases function keys are basically gone for good.
Which keys are and are not available depends on the client, not on
the server, but only function keys are usually trapped by terminals.
Hence, using ESC for the boot menu avoids the problems associated
with F12.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo Bonzini [Thu, 12 Mar 2015 17:12:23 +0000 (18:12 +0100)]
boot.c: delay exiting boot if menu key is ESC
If the menu key is ESC, do not restart boot unless
1.5 seconds have passed. Otherwise users (trained by years of
repeatedly hitting keys to enter the BIOS) will end up hitting ESC
multiple times and immediately booting the primary boot device.
Suggested-by: Matt DeVillier <matt.devillier@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
In 0673b787 the QEMU SMP init code was changed to run in 32bit mode.
Unfortunately, the transition32 assembler function is not
multi-processor safe, because it modifies the global RTC index
register. This race condition led to sporadic failures when emulating
machines with a large number of processors.
This patch changes the entry_smp code to use a variant of transition32
that does not touch the RTC registers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>