Commit Graph

98403 Commits

Author SHA1 Message Date
Simon Glass
9a4aa22a70 virtio: Increase the bootdev priority
The current priority of BOOTDEVP_4_SCAN_FAST means that virtio is
scanned after SCSI. But virtio-scsi provides higher performance.

It seems better to regard virtio has an internal device, since it is
paravirtualised and thus fast. Change its bootdev priority to
BOOTDEVP_2_INTERNAL_FAST

Disable the virtio-fs feature on sandbox, since the virtio queue is not
not yet supported by the emulator.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:26 +02:00
Simon Glass
bbd1cc14c1 virtio: Provide a command to list virtio devices
U-Boot only supports a subset of the devices supported by QEMU. For
example, U-Boot does not currently support the vsock device.

It is helpful to see what devices are provided by QEMU and whether there
is a driver for it in U-Boot.

Add a new 'virtio list' command to provide this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:26 +02:00
Simon Glass
7013d9f2f1 virtio: Fill in all the QEMU device types
Even if U-Boot doesn't have a driver for all of the virtio devices
provided by QEMU, it is still useful to see what they are. Fill out the
table of device types and names, so that 'virtio list' lists them all.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:26 +02:00
Simon Glass
b82b94d6c4 virtio: doc: Document the virtio command
Add documentation for this command, including some examples.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:25 +02:00
Simon Glass
2fdacb4753 qfw: Add a subcommand to decode the QEMU E820 data
Provide a simple command to display the memory map described by this
table.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:25 +02:00
Simon Glass
d75533b613 qfw: Add a subcommand to read a QEMU file into memory
Provide a simple command to read a named file into memory.

Skip this test on sandbox for now, as it doesn't support this feature in
its emulation of QEMU.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:25 +02:00
Simon Glass
1541ec049b qfw: Add a subcommand to show QEMU arch-specific details
There are a few selectors in a different region which contain what seems
to be arch-specific information. Add a way to display this. So far it
only works on x86.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:25 +02:00
Simon Glass
6d80f5476b qfw: Add a subcommand to show ACPI-loader details
QEMU provides a table containing the ACPI tables and information on how
to relocate them to any suitable memory address. Add a command to show
this information.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:25 +02:00
Simon Glass
af7eb623d0 qfw: Add a subcommand to show the main QEMU details
There are quite a few values provided by QEMU and used by U-Boot, for
which it isn't possible to see the values. Add a new 'qfw dump' command
to support this.

Skip this test on sandbox for now, as it doesn't support this feature in
its emulation of QEMU.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:24 +02:00
Simon Glass
676abe19cb qemu: Tidy up and complete fw_cfg_selector docs
There are a few entries missing from this enum. Add them and add
comments for all items, since this doesn't seem to be clearly documented
within QEMU itself.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:26:02 +02:00
Simon Glass
92ad9c9554 emulation: Add more functions to access qfw files
Provide a few more functions to allow accessing arbitrary files easily.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:26:02 +02:00
Simon Glass
9d9f440c7a qfw: Add more fields and a heading to qfw list
Update the command to show the size and selected file, since this is
useful information at times. Add a heading so it is clear what each
field refers to.

Add a simple test as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:26:02 +02:00
Simon Glass
8ed299f3be display_options: Support printing a 32-bit value
On 64-bit machines we don't always want to show 16 hex digits,
particularly if the value is 32-bit. Add a new function to show a 32-bit
value.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:26:02 +02:00
Simon Glass
0f640f96c8 Make the bdinfo printing-functions more generic
The bdinfo command makes use of quite a few functions which show a label
followed by a value, on a single line.

This sort of thing is generally useful outside of bdinfo, so move it to
a generic place. Use 'l' (for label) as the prefix.

The margin is still hard-coded to 12, which seems a reasonable limit for
a label.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:26:02 +02:00
Simon Glass
6ab28ecf2a test: Increase console-recording size if UNIT_TEST
Some unit tests generate more than 1K of output. Use a higher default
limit by default.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:26:02 +02:00
Simon Glass
c6a4651fa6 x86: Enable console-recording on qemu-x86_64
Some tests are skipped without console recording. Enable to improve test
coverage on this target.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:25:35 +02:00
Simon Glass
32863b34a4 x86: Update msr test to run on qemu-x86_64
This test is not currently enabled. Update it so that it can be enabled
on the qemu-x86_64 target.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:25:25 +02:00
Simon Glass
2d2057f4d5 test: fdt: Make fdt-overlay test depend on overlays
This test requires FDT-overlay support so skip it if this is not
present.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:11:33 +02:00
Simon Glass
7363d1517d test: Disable truetype and meminfo tests on QEMU
These tests are designed to work on sandbox only. The truetype font
changes the current font, which QEMU targets may not support. The
meminfo test assumes a particular memory size.

Mark them as sandbox-only.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:11:33 +02:00
Simon Glass
8170ab591f x86: bdinfo: Update test for output of tsc
The bdinfo command on x86 now outputs the TSC value, do update the tests
to account for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:11:33 +02:00
Simon Glass
c1949994d3 test: Fix the return value when a test fails
When a unit test fails, it returns the error code, which results in a
warning:

   exit not allowed from main input shell.

Fix it by returning a failure code instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:11:33 +02:00
Simon Glass
5814f040a7 qconfig: Ignore defconfigs containing #include
Running "tools/qconfig.py -s" will re-sync files with #include in them
and so un-#include them.

Ignore these and mark them as failures.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/28
2025-07-09 23:11:33 +02:00
Simon Glass
4da27e4529 qconfig: Add an way to select defconfigs without stdin
Sometimes it is useful to process just one or two defconfigs and it is
convenient to do this just by listing them in the arguments. Add a -D
option for this.

Update the docs to avoid mentioning boards which have been removed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2025-07-09 23:11:33 +02:00
Simon Glass
1492937d63 scripts: Allow -d to specify multiple disks in build_helper
Sometimes it is useful to provide several disks to QEMU. Update the -d
flag to support this. It can be used like this:

   scripts/build-qemu -d root.img mmc6.img -r

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:11:32 +02:00
Simon Glass
0280f7f8be Merge branch 'qemg' into 'master'
emulation: Restructure the Kconfig

See merge request u-boot/u-boot!114
2025-07-09 04:20:56 +00:00
Simon Glass
87161abea6 emulation: Move common qfw file in with other code
This file provide common functions related to QFW, so move it into
driver/qfw with the other code.

Series-to: concept
Cover-letter:
emulation: Restructure the Kconfig
At present ARM and x86 use differently named symbols to mean similar
things. For x86, board/emulation/Kconfig contains the targets, but ARM
has them in a different file. While ARM uses ARCH_QEMU to mean QEMU,
x86 uses VENDOR_EMULATION.

This series adjusts the Kconfig for emulation targets on x86 and ARM, to
improve consistency.

A new arch-neutral MACH_QEMU is introduced. This is enabled for all
ARM/x86 emulation targets. Furture work could add this for other archs
too.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 05:22:09 +02:00
Simon Glass
f00c74d474 emulation: Rename the uclass file to qfw-uclass.c
The qfw.c file mostly contains the uclass implementation, so rename it
to fit with other uclass files.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 05:22:09 +02:00
Simon Glass
20959f5c4a emulation: Move QFW drivers to drivers/qfw
There seems to be enough QFW code now to have its own directory. Move
the files there before adding more.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 05:22:09 +02:00
Simon Glass
17c152fc7f arm: Move inclusion of board/emulation into board/
Now that ARM is using board/emulation/Kconfig, put the includes for the
board-specific Kconfig into this file too.

With this, both ARM and x86 use board/emulation/Kconfig to list the
targets.
2025-07-09 05:22:09 +02:00
Simon Glass
be47cbc296 arm: x86: Move Kconfig from arch/ to board/
Set up a single place in Kconfig where board/emulation/Kconfig is
included, removing the two sites in arch/arm and arch/x86

Move the ARM-specific Kconfig into this file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 05:22:09 +02:00
Simon Glass
cd93381ec5 emulation: x86: Rename VENDOR_EMULATION to ARCH_QEMU_X86
This name matches the ARM name and 'emulation' is not really a vendor.
Use ARCH_QEMU_X86 instead, moving that option from its existing location.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 05:21:59 +02:00
Simon Glass
537e97237e x86: Rename QEMU to ARCH_QEMU_X86
CONFIG_QEMU is too generic for an x86-specific option. Rename it to
ARCH_QEMU_X86

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-05 05:48:28 -06:00
Simon Glass
50d0aeeeff emulation: efi_loader: Set MACH_QEMU with ARCH_QEMU_ARM
Define MACH_QEMU whenever ARCH_QEMU_ARM is used.

Some of the uses of ARCH_QEMU_ARM with efi_loader should clearly apply
to all QEMU variables, so update these.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-05 05:48:28 -06:00
Simon Glass
ab3b9d1d88 emulation: Rename ARCH_QEMU to ARCH_QEMU_ARM
This option looks generic but in fact is specific to ARM. Rename it to
reflect this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-05 05:48:28 -06:00
Simon Glass
a9d552407a emulation: Introduction MACH_QEMU
We have QEMU targets across various architecture. So there is not really
a QEMU archicture. So 'ARCH_QEMU' seems a bit peculiar.

We have a board/emulation directory where much of the arch-specific code
is kept. But QEMU is not really a board; in fact many boards use QEMU.

While 'emulation' is a useful concept, QEMU is only one of the emulators
available. so MACH_EMULATION seems too vague to capture QEMU-specific
features.

On ARM the code is in the arch/arm/mach-qemu directory and it seems
reasonable to go with this approach and consider QEMU to be a machine.

So add a MACH_QEMU option. For now nothing uses it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-05 05:48:28 -06:00
Simon Glass
9feeb1e60a Merge branch 'qeme' into 'master'
virtio: Support SCSI over virtio

See merge request u-boot/u-boot!112
2025-07-04 12:30:05 +00:00
Simon Glass
33d80a2b25 virtio: Add debugging of driver features and device type
When a device type is not supported by U-Boot it is silently ignored.
Add some debugging for this.

Also show the driver features to provide a fuller picture of feature
negotiation.

Series-to: concept
Cover-letter:
virtio: Add support for virtio-scsi
It is often possible to use virtio-blk for block devices, but it is
less flexible than SCSI. SCSI provides a means to probe for multiple
disks through the same interface. It also supports hotplug and other
features.

This series adds a simple virtio-scsi driver for use with QEMU. The new
driver creates a SCSI bus when the virtio buses are scanned. That can be
scanned in turn, using 'scsi scan', to find the available virtio disks.

For this to work, quite a few minor updates are needed in the SCSI
implementation:

- Increase the buffer sizes for commands and sense buffer
- Fix off-by-one error when scanning for devices
- Use REPORT LUN to determine what LUNs are present for a target
- Clean up some open-coded constants
- Make use of a struct to decode the IDENTIFY response
- Clean up of the confusing and error-prone SCSI read/write functions
- Add support for using a scsi disk to the build-qemu/efi scripts

When a SCSI disk is inaccessible (e.g. the LUN is wrong), this is seldom
reported as an error. For example 'part list' does not say 'read error'
but 'unsupported partition type'. Probing the block device results in
each partition-type driver reading blocks, none of which reports the
error. So an attempt is made here to clean this up, so that bad LUNs
show an error.

Another clean-up is to show partition numbers in hex with 'part list',
since the current approach conflicts with the 'part' command.

Some additional x86 debugging is added for the jump from SPL to U-Boot
proper, since this can be confusing when it fails in QEMU.

With all of the above, virtio-scsi can be used on qemu-x86_64 for
loading an OS and associated files, including with standard boot.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:43:28 -06:00
Simon Glass
9a6d610a34 virtio: Add support for virtio-scsi
This feature can be useful where the host wants to provide more than one
block device, since it allows all of them to be under one virtio device.

Add an implementation of virtio-scsi

Series-to: concept
Cover-letter:
virtio: Support SCSI over virtio
U-Boot supports virtio-blk and in most cases this is sufficient for
providing access to a disk. However some larger users such as LXD prefer
virtio-scsi since it groups disks together and provides unified probing
of devices.

This series implements this protocol.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:43:28 -06:00
Simon Glass
cc21b53ce9 virtio: Bring in the virtio_scsi header
The file include/uapi/linux/virtio_scsi.h contains some useful
definitions for virtio-scsi so bring this in from Linux v6.15

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:43:28 -06:00
Simon Glass
e52931bd12 scsi: Adjust loop counters once in the loop
The current logic is fairly confusing. We always add to_read to start
and we always subtract it from blks. Even the place where blks is set to
0 is really just subtracting to_read.

So move these additions and subtractions out of the if() logic and to
the end of the loop. This is much easier to follow.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:43:28 -06:00
Simon Glass
690fbc83fd scsi: Move loop counters down next to the loop
Move buf_addr, start and blks down a bit so it is clear that they are
being set up ready for the loop.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:43:28 -06:00
Simon Glass
62c57729b2 scsi: Use mapmem functions
Rather than casting between addresses and pointers, use the mapmem
functions provided.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:43:28 -06:00
Simon Glass
3a2dce9d4e scsi: Reorder the local variables
Adjust the ordering of these so they are easier to read.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:43:28 -06:00
Simon Glass
fd1a6aa8d3 scsi: Use a variable for the number of blocks to process
Each time around the loop a certain number of blocks are processed. Put
this in a variable (to_read/to_write) and avoid changing the input
parameter

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:43:27 -06:00
Simon Glass
964e0c43f8 scsi: Tidy up error returns for read/write
The current code never returns an error if something goes wrong. While
it is normally useful to return the number of blocks processed, when
nothing is read/written at all, there is clearly something wrong.

Update the logic to return -EIO in this case.

Avoid changing blkcnt since it is an input parameter and this is
confusing.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:43:05 -06:00
Simon Glass
3a18b243a7 scsi: Check SCSI spec version for LUN handling
Recent versions of SCSI handle the LUN outside the command region. Check
for this and obey.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:43:05 -06:00
Simon Glass
58aaaabd8f scsi: Only add the LUN to the command if needed
Newer SCSI controllers handle the LUN in a different place from the SCSI
command. Detect this and adjust the command accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:43:05 -06:00
Simon Glass
298dd563ac scsi: Create a function to add command and LUN to the ccb
Rather than doing the same shift operation each time, create a function
which writes in the correct command and the LUN. This will allows us to
handle newer controllers which do not want the LUN in the command.

Fix checkpatch warnings about CONFIG_SYS_64BIT_LBA while here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:43:04 -06:00
Simon Glass
6cbb400bae scsi: Drop use of #ifdef with CONFIG_SYS_64BIT_LBA
Use if() for this condition. Adjust scsi_setup_read16() to use a
standard unaligned access to avoid shifting more than 32 on a 32-bit
architecture (which produces a compiler warning).

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:40:25 -06:00
Simon Glass
038a6b1cb3 scsi: Rename block_dev and dev_desc to desc
The word 'block_dev' suggests it is a device, but this struct is not the
device (now that we use driver model), only some information about it.

We use desc (for descriptor) elsewhere in the code, so update scsi to do
the same.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-02 13:08:28 -06:00