Commit Graph

2654 Commits

Author SHA1 Message Date
Stefan Berger ba949f5522 tcgbios: Fix details in log entries
Fix two details of the logs:

- Set the field 'SpecErrata' to 2 as required by specs.
- Write the separator into the log entry's event field.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-30 16:58:48 -04:00
Volker Rümelin e3c3079582 stacks: call check_irqs() after switch_next()
In function run_thread() the function check_irqs() gets called
after the thread switch for atomic handoff reasons. In yield()
it's the other way round.

If check_irqs() is called after run_thread() and check_irqs()
is called before switch_next() in yield(), it can happen in a
constructed case that a background thread runs twice without
a check_irqs() call in between. Call check_irqs() after
switch_next() in yield() to prevent this.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
2021-06-09 11:05:19 -04:00
Volker Rümelin f501bcbeef stacks: call check_irqs() in run_thread()
The comment above the yield() function suggests that yield()
allows interrupts for a short time. But yield() only briefly
enables interrupts if seabios was built without CONFIG_THREADS
or if yield() is called from the main thread. In order to
guarantee that the interrupts were enabled once before yield()
returns in a background thread, the main thread must call
check_irqs() before or after every thread switch. The function
run_thread() also switches threads, but the call to check_irqs()
was forgotten. Add the missing check_irqs() call.

This fixes PS/2 keyboard initialization failures.

The code in src/hw/ps2port.c relies on yield() to briefly enable
interrupts. There is a comment above the yield() function in
__ps2_command(), where the author left a remark why the call to
yield() is actually needed.

Here is one of the call sequences leading to a PS/2 keyboard
initialization failure.

ps2_keyboard_setup()
  |
  ret = i8042_command(I8042_CMD_CTL_TEST, param);
  # This command will register an interrupt if the PS/2 device
  # controller raises interrupts for replies to a controller
  # command.
  |
  ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
    |
    ps2_command(0, command, param);
      |
      ret = __ps2_command(aux, command, param);
        |
        // Flush any interrupts already pending.
        yield();
        # yield() doesn't flush interrupts if the main thread
        # hasn't reached wait_threads().
        |
        ret = ps2_sendbyte(aux, command, 1000);
        # Reset the PS/2 keyboard controller and wait for
        # PS2_RET_ACK.
        |
        ret = ps2_recvbyte(aux, 0, 4000);
          |
          for (;;) {
            |
            status = inb(PORT_PS2_STATUS);
            # I8042_STR_OBF isn't set because the keyboard self
            # test reply is still on wire.
            |
            yield();
            # After a few yield()s the keyboard interrupt fires
            # and clears the I8042_STR_OBF status bit. If the
            # keyboard self test reply arrives before the
            # interrupt fires the keyboard reply is lost and
            # ps2_recvbyte() returns after the timeout.
          }

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
2021-06-09 11:05:18 -04:00
Gerd Hoffmann 7292e4a0a8 Increase BUILD_MIN_BIOSTABLE for large roms
BUILD_MIN_BIOSTABLE reserves space in the f-segment.  Some data
structures -- for example disk drives known to seabios -- must be
stored there, so the space available here limits the number of
devices seabios is able to manage.

This patch sets BUILD_MIN_BIOSTABLE to 8k for bios images being 256k or
larger in size.  32bit code is moved off in that case, so we have more
room in the f-segment then.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-06-04 08:05:08 +02:00
Gerd Hoffmann 81433aa8a1 nvme: drive desc should not include the newline
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-05-31 07:34:34 +02:00
Gerd Hoffmann 9bb1203b35 nvme: improve namespace allocation
Instead of allocating a big array upfront go probe the namespaces and
only allocate an nvme_namespace struct for those namespaces which are
actually active.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-05-31 07:34:34 +02:00
Sergei Trofimovich 6eff808598 vgasrc: ignore .node.gnu.property (binutils-2.36 support)
Modern binutils unconditionally tracks x86_64 ISA levels in intermediate
files in .note.gnu.property. Custom liker script does not handle the
section and complains about it:

    ld --gc-sections -T out/vgasrc/vgalayout.lds out/vgaccode16.o \
        out/vgaentry.o out/vgaversion.o -o out/vgarom.o
    ld: section .note.gnu.property LMA [0000000000000000,0000000000000027] \
        overlaps section .text LMA [0000000000000000,00000000000098af]

The change ignores .note* sections.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2021-05-26 10:07:01 -04:00
Stefan Ott via SeaBIOS b0d61ecef6 usb-hid: Increase MAX_KBD_EVENT
Some USB keyboards use max packet sizes beyond the current maximum
supported by SeaBIOS.

This increases the available size to support keyboards such as the
Matias Ergo Pro.

Signed-off-by: Stefan Ott <stefan@ott.net>
2021-03-10 10:22:17 -05:00
Mike Banon ef88eeaf05 Support booting USB drives with a write protect switch enabled
At least some USB drives with a write protect switch (e.g. Netac U335)
could report "MEDIUM NOT PRESENT" for a while if a write protection is
enabled. Instead of stopping the initialization attempts immediately,
stop only after getting this report for 3 times, to ensure the
successful initialization of such a "broken hardware".

Signed-off-by: Mike Banon <mikebdp2@gmail.com>
2020-12-21 10:59:39 -05:00
David Woodhouse 748d619be3 nvme: Clean up nvme_cmd_readwrite()
This ended up with an odd mix of recursion (albeit *mostly*
tail-recursion) and interation that could have been prettier. In
addition, while recursing it potentially adjusted op->count which is
used by callers to see the amount of I/O actually performed.

Fix it by bringing nvme_build_prpl() into the normal loop using 'i'
as the offset in the op.

Fixes: 94f0510dc ("nvme: Split requests by maximum allowed size")
Reviewed-by: Alexander Graf <graf@amazon.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
2020-11-16 10:22:19 -05:00
Alexander Graf 94f0510dc7 nvme: Split requests by maximum allowed size
Some NVMe controllers only support small maximum request sizes, such as
the AWS EBS NVMe implementation which only supports NVMe requests of up
to 32 pages (256kb) at once.

BIOS callers can exceed those request sizes by defining sector counts
above this threshold. Currently we fall back to the bounce buffer
implementation for those. This is slow.

This patch introduces splitting logic to the NVMe I/O request code so
that every NVMe I/O request gets handled in a chunk size that is
consumable by the NVMe adapter, while maintaining the fast path PRPL
logic we just introduced.

Signed-off-by: Alexander Graf <graf@amazon.com>
2020-10-28 15:18:29 -04:00
Alexander Graf 01f2736cc9 nvme: Pass large I/O requests as PRP lists
Today, we split every I/O request into at most 4kb chunks and wait for these
requests to finish. We encountered issues where the backing storage is network
based, so every I/O request needs to go over the network with associated
latency cost. A few ms of latency when loading 100MB initrd in 4kb chunks
does add up.

NVMe implements a feature to allow I/O requests spanning multiple pages,
called PRP lists. This patch takes larger I/O operations and checks if
they can be directly passed to the NVMe backing device as PRP list.
At least for grub, read operations can always be mapped directly into
PRP list items.

This reduces the number of I/O operations required during a typical boot
path by roughly a factor of 5.

Signed-off-by: Alexander Graf <graf@amazon.com>
2020-10-28 15:18:29 -04:00
Alexander Graf 23258d39ff nvme: Allow to set PRP2
When creating a PRP based I/O request, we pass in the pointer to operate
on. Going forward, we will want to be able to pass additional pointers
though for mappings above 4k.

This patch adds a parameter to nvme_get_next_sqe() to pass in the PRP2
value of an NVMe I/O request, paving the way for a future patch to
implement PRP lists.

Signed-off-by: Alexander Graf <graf@amazon.com>
Reviewed-by: Filippo Sironi <sironi@amazon.de>
2020-10-28 15:18:29 -04:00
Alexander Graf b68f313c91 nvme: Record maximum allowed request size
NVMe has a limit on how many sectors it can handle at most within a single
request. Remember that number, so that in a follow-up patch, we can verify
that we don't exceed it.

Signed-off-by: Alexander Graf <graf@amazon.com>
2020-10-28 15:18:29 -04:00
Gerd Hoffmann 58a44be024 usb boot: add xhci mmio example
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20201013091019.22029-1-kraxel@redhat.com
2020-10-15 11:16:26 +02:00
Gerd Hoffmann c685fe3ff2 usb/xhci: add support for mmio host adapters (via acpi).
Add xhci_controller_setup_acpi() function to initialize usb host
adapters declared in the DSDT table.  Search the acpi devices list
for xhci controllers.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200930111433.21533-4-kraxel@redhat.com
2020-10-13 11:04:03 +02:00
Gerd Hoffmann b95a199610 usb/xhci: split xhci setup into generic and pci parts
Split the pci-specific code into a separate xhci_controller_setup_pci()
function, turn xhci_controller_setup() to a generic xhci setup function
which only needs the mmio address if the control registers.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200930111433.21533-3-kraxel@redhat.com
2020-10-13 11:04:03 +02:00
Gerd Hoffmann eff73e2818 usb: add boot prio support for mmio host adapters
Add mmio field to usb controller struct, add support for mmio-mapped
usb host adapters to boot order handling.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200930111433.21533-2-kraxel@redhat.com
2020-10-13 11:04:03 +02:00
Gerd Hoffmann dfac05be20 dsdt: add support for pnp ids as strings
PNP devices can be declared using eisaid encoding ...

	Name (_HID, EisaId ("PNP0103"))

... or as string ...

	Name (_HID, "PNP0A06")

.. so lets support both variants.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200930111222.6020-3-kraxel@redhat.com
2020-10-13 11:01:08 +02:00
Gerd Hoffmann cf16c3b2ea output: add support for uppercase hex numbers
... via "%X" format string.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200930111222.6020-2-kraxel@redhat.com
2020-10-13 11:01:08 +02:00
weitaowang-oc@zhaoxin.com 849c5e50b6 USB:Fix xHCI initail fail by using longer reset and CNR clear timeout value
Some xHCI controller's reset time than 100ms,such as 120ms.
On the on hand, xHCI spec has not specified a timeout value.
Maybe setting xHCI HCRST and CNR bit clear timeout value larger
is a nice thing.As a compromise between compatibility and
latency,we can take 1000ms as a timeout value.

Signed-off-by: WeitaoWangoc <WeitaoWang-oc@zhaoxin.com>
Message-Id: <159698294308.14.13067234241650533818@b63950293ec5>
2020-09-30 12:52:57 +02:00
Matt DeVillier 41289b83ed usb.c: Fix devices using non-primary interface descriptor
A fair number of USB devices (keyboards in particular) use an
interface descriptor
other than the first available, making them non-functional currently.
To correct this, iterate through all available interface descriptors
until one with the correct class/subclass is found, then proceed to set the
configuration and setup the driver.

Tested on an ultimate hacking keyboard (UHK 60)

Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
2020-09-25 11:59:42 -04:00
Daniel P. Berrangé 4ea6aa9471 smbios: avoid integer overflow when adding SMBIOS type 0 table
SeaBIOS implements the SMBIOS 2.1 entry point which is limited to a
maximum length of 0xffff. If the SMBIOS data received from QEMU is large
enough, then adding the type 0 table will cause integer overflow. This
results in fun behaviour such as KVM crash, or hangs in SeaBIOS.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-09-08 16:16:53 +01:00
Kevin O'Connor 155821a199 docs: Note v1.14.0 release
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-10 10:53:07 -04:00
Paul Menzel d9c812dda5 nvme: Increase `nvme_cmd_readwrite()` message log level from 3 to 5
Currently, setting SeaBIOS debug level to 3, the log is filled with
messages like below.

    ns 1 read lba 11346288+8: 0
    ns 1 read lba 11346296+4: 0
    ns 1 read lba 11346300+4: 0
    ns 1 read lba 11346304+8: 0
    ns 1 read lba 11346312+8: 0
    ns 1 read lba 11346320+8: 0
    ns 1 read lba 11346328+8: 0
    ns 1 read lba 11346336+8: 0

With SeaBIOS as coreboot payload, this fills up the CBMEM console
buffer.

So, increase the debug level to 5, so possible console buffer do not
overflow.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
2020-07-28 11:36:18 -04:00
Stefan Reiter f3ca59c6f3 virtio-scsi: fix boot prio detection by using correct lun
Commits

  d6bdb85eb0 virtio-scsi: skip initializing non-bootable devices
  f82e82a5ab virtio-mmio: add support for scsi devices.

both use the lun value from tmpl_drv, which is always 0, instead of the
correct one passed as a separate parameter. This causes systems where
LUNs other than 0 are set as bootable, but 0 is not, to not boot.

Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-07-28 11:35:59 -04:00
Kevin O'Connor 699a4e5d69 ldnoexec: Add script to remove ET_EXEC flag from intermediate build objects
Add a script to remove the ET_EXEC flag from the 16bit and "32bit
segmented" intermediate objects.  This avoids build failures with some
linkers that will not allow linking these objects again.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-07-24 11:01:47 -04:00
Kevin O'Connor 6ada2285d9 vgabios: Fix preserve memory flag in handle_1000
Commit 5108c69c made a change to the ordering of some code which broke
the check for the MF_NOCLEARMEM flag.

Reported by felix.von.s@posteo.de

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-07-13 18:50:52 -04:00
Roman Bolshakov 88ab0c1552 timer: Handle decrements of PIT counter
There's a fallback to PIT if TSC is not present but it doesn't work
properly. It prevents boot from floppy on isapc and 486 cpu [1][2].

SeaBIOS configures PIT in Mode 2. PIT counter is decremented in the mode
but timer_adjust_bits() thinks that the counter overflows and increases
32-bit tick counter on each detected "overflow". Invalid overflow
detection results in 55ms time advance (1 / 18.2Hz) on each read from
PIT counter. So all timers expire much faster and 5-second floppy
timeout expires in 83 real microseconds (or just a bit longer).

It can be fixed by making the counter recieved from PIT an increasing
value so it can be passed to timer_adjust_bits():
0, 1, 2 and up to 65535 and then the counter is re-loaded with 0.

1. https://bugs.launchpad.net/seabios/+bug/1840719
2. https://lists.gnu.org/archive/html/qemu-devel/2019-08/msg03924.html

Fixes: eac1194401 ("Unify pmtimer_read() and pittimer_read() code.")
Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
2020-06-26 14:18:23 -04:00
Gerd Hoffmann d11c751852 vga: fix cirrus bios
Little mistake, big effect.  The patch adding the ati driver broke
cirrus due to a missing "else", which effectively downgrades cirrus
to standard vga.

Fixes: 34b6ecc160 ("vga: add atiext driver")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-06-25 10:21:28 -04:00
Jason Andryuk dd6a7e99b1 serialio: Preserve Xen DebugOutputPort
xen_preinit() runs early and changes DebugOutputPort.  qemu_preinit() runs
soon after.  inb on DebugOutputPort doesn't work on Xen, so the check
will always fail and DebugOutputPort will be cleared to 0 disabling
output.

Quick exit the function when running on Xen to preserve the modified
DebugOutputPort.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
2020-06-24 11:44:06 -04:00
Gerd Hoffmann 2e3de62534 pci: fix mmconfig support
The MODESEGMENT condition is backwards, with the effect that
mmconfig mode is not used to configure pci bars during POST.

Oops.  Fix it.

The only real mode pci config space access seems to come from the
ipxe option rom initialiation.  Which happens to work via mmconfig
because it runs in big real mode so this went unnoticed ...

Fixes: 6a3b59ab9c ("pci: add mmconfig support")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-25 11:27:12 -04:00
Kevin O'Connor d9aea4a7cd boot: Fixup check for only one item in boot list
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-24 21:57:19 -04:00
Matt DeVillier 926fd4e05e boot: Fix logic for boot menu display
Commit c61193d3 [boot: Extend `etc/show-boot-menu`...] changed the
logic surrounding the use of show_boot_menu incorrectly, leading the
boot menu to be skipped by default with no way to override. Correct
the logic error so that show_boot_menu works as documented.

Test: build/boot SeaBIOS, verify boot menu option shown by default.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2020-05-24 21:50:09 -04:00
Kevin O'Connor 7e9db04923 Revert "ps2port: adjust init routine to fix PS/2 keyboard issues"
It is believed that the underlying problem was fixed in commit
dbf9dd27f and therefore this commit is not necessary.

This reverts commit bfdb3f86e9.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-21 13:38:27 -04:00
Paul Menzel d53aea0241 cdrom: Demote `scsi_is_ready` return print to debug level
Printing the return value of `scsi_is_ready()` is a debug message, so
change the log level from 1 to 5.

    Booting from DVD/CD...
    Device reports MEDIUM NOT PRESENT
    scsi_is_ready returned -1
    Boot failed: Could not read from CDROM (code 0003)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
2020-05-21 13:38:27 -04:00
Paul Menzel 232b1c15c8 boot: Log, if boot menu is skipped
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
2020-05-21 13:38:27 -04:00
Paul Menzel c61193d3ec boot: Extend `etc/show-boot-menu` to configure skipping boot menu with only one device
Concerns were raised, that skipping the boot menu, if only one device is
present, might make debugging issues more difficult. So, extend the
current runtime configuration option `etc/show-boot-menu` to enable this
feature by setting it to 2.

Fixes: 29ee1fb8 ("Skip boot menu and timeout with only one boot device")
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
2020-05-21 13:38:27 -04:00
Gerd Hoffmann b8eda13195 rewrap Makefile lines.
Rewrap SRCBOTH and SRC32FLAT variables in Makefile to keep line length
below 80 chars.  No functional change.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-18 09:42:57 +02:00
Gerd Hoffmann 665dce17c0 acpi: find and register virtio-mmio devices
Seach for virtio-mmio devices in the DSDT table,
register the devices found.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15 13:55:29 +02:00
Gerd Hoffmann ea03821b1d acpi: skip kbd init if not present
Don't initialize the ps/2 keyboard in case the device is not
listed in the ACPi DSDT table.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15 13:55:29 +02:00
Gerd Hoffmann 654ba383b6 acpi: add dsdt parser
Create a list of devices found in the DSDT table.  Add helper functions
to find devices, walk the list and figure device informations like mmio
ranges and irqs.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15 13:55:29 +02:00
Gerd Hoffmann 2abf972ab6 acpi: add xsdt support
In case a xsdt table is present (and located below 4G)
prefer it over rsdt.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15 13:38:47 +02:00
Gerd Hoffmann 63565246a6 virtio-mmio: print device type 2020-05-15 13:38:05 +02:00
Gerd Hoffmann c12a1dc75e virtio-mmio: add support for block devices.
Add and use bootprio_find_mmio_device() to figure
the boot priority of virtio-mmio block devices.

Add init_virtio_blk_mmio to initialize one
virtio-mmio block device.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15 13:37:07 +02:00
Gerd Hoffmann f82e82a5ab virtio-mmio: add support for scsi devices.
Add new fields to struct virtio_lun_s for mmio support,
add mmio parameter to virtio_scsi_init_lun(), so both
pci and mmio devices can be handled.

Add and use bootprio_find_scsi_mmio_device() to figure
boot priority of devices connected to a virtio-mmio
scsi controller.

Finally add init_virtio_scsi_mmio() to initialize one
virtio-mmio scsi controller.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15 13:36:08 +02:00
Gerd Hoffmann 040b92c615 virtio-mmio: add support to vp_*() functions
Add support for virtio-mmio to the vp_*() helper functions.
Both legacy and 1.0 virto-mmio versions are supported.  They
are very simliar anyway, only the virtqueue initialization
is slightly different.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15 13:35:26 +02:00
Gerd Hoffmann 69f65a4e89 virtio-mmio: device probing and initialization.
Add virtio_mmio_setup_one() to setup virtio mmio devices.  Add
vp_init_mmio() to initialize device struct.  Because virtio-pci and
virtio-mmio are quite simliar we reuse the infrastructure we already
have for virtio-pci and just setup struct vp_cap for virtio-mmio.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15 13:34:29 +02:00
Gerd Hoffmann 51c6fc699e qemu: check rtc presence before reading cpu count from cmos
Read month register which should never have a value larger than 12.
In case the read returns 0xff assume the rtc isn't there.
Don't try to read the cpu count from cmos without rtc.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2020-05-15 13:33:17 +02:00
Gerd Hoffmann fffac0fa08 qemu: rework e820 detection
Read e820 table from fw_cfg early.  This avoids reading the cmos for ram
detection on modern qemu.  It also simplifies the ram detection logic.
We stop doing ram detecion in two steps, so we don't have to worry about
the second step overwriting the setup done by the first step.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-05-15 13:29:28 +02:00