]> git.ipfire.org Git - thirdparty/ipxe.git/log
thirdparty/ipxe.git
7 hours ago[riscv] Add support for detecting T-Head vendor extensions master
Michael Brown [Mon, 7 Jul 2025 12:03:07 +0000 (13:03 +0100)] 
[riscv] Add support for detecting T-Head vendor extensions

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 hours ago[iobuf] Ensure I/O buffer data sits within unshared cachelines
Michael Brown [Mon, 7 Jul 2025 12:21:24 +0000 (13:21 +0100)] 
[iobuf] Ensure I/O buffer data sits within unshared cachelines

On platforms where DMA devices are not in the same coherency domain as
the CPU cache, we must ensure that DMA I/O buffers do not share
cachelines with other data.

Align the start and end of I/O buffers to IOB_ZLEN, which is larger
than any cacheline size we expect to encounter.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 days ago[uaccess] Allow for coherent DMA mapping of the 32-bit address space coverity_scan
Michael Brown [Fri, 4 Jul 2025 12:29:44 +0000 (13:29 +0100)] 
[uaccess] Allow for coherent DMA mapping of the 32-bit address space

On platforms where DMA devices are not in the same coherency domain as
the CPU cache, it is necessary to create page table entries where the
translations are marked as uncacheable.

We choose to place iPXE within the low 4GB of memory (since 32-bit DMA
devices are still reasonably common even on systems with 64-bit CPUs).
We therefore need to cover only the low 4GB of memory with these page
table entries.

Update virt_to_phys() to allow for the existence of such a mapping,
assuming that iPXE itself will always reside within the top 4GB of the
64-bit virtual address space (and therefore that the DMA mapping must
lie somewhere below this in the negative virtual address space).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 days ago[riscv] Create coherent DMA mapping for low 4GB of address space
Michael Brown [Fri, 4 Jul 2025 13:23:37 +0000 (14:23 +0100)] 
[riscv] Create coherent DMA mapping for low 4GB of address space

Use PTEs 256-259 to create a mapping of the 32-bit physical address
space with attributes suitable for coherent DMA mappings.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 days ago[riscv] Construct invariant portions of page table outside the loop
Michael Brown [Fri, 4 Jul 2025 13:37:31 +0000 (14:37 +0100)] 
[riscv] Construct invariant portions of page table outside the loop

The page table entries for the identity map vary according to the
paging level in use, and so must be constructed within the loop used
to detect the maximum supported paging level.  Other page table
entries are invariant between paging levels, and so may be constructed
just once before entering the loop.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
4 days ago[bnxt] Update supported devices array 1491/head
Joseph Wong [Wed, 2 Jul 2025 17:29:06 +0000 (10:29 -0700)] 
[bnxt] Update supported devices array

Add support for new device IDs. Remove device IDs which were never
in use.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
5 days ago[bnxt] Update device descriptions 1489/head
Joseph Wong [Tue, 1 Jul 2025 07:24:05 +0000 (00:24 -0700)] 
[bnxt] Update device descriptions

Use human readable strings for dev_description in PCI_ROM array.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
8 days ago[bnxt] Remove VLAN stripping logic 1484/head
Joseph Wong [Thu, 26 Jun 2025 22:37:05 +0000 (15:37 -0700)] 
[bnxt] Remove VLAN stripping logic

Remove logic that programs the hardware to strip out VLAN from RX
packets.  Do not drop packets due to VLAN mismatch and allow the upper
layer to decide whether to discard the packets.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
11 days ago[github] Add sponsorship link
Michael Brown [Thu, 26 Jun 2025 15:24:01 +0000 (16:24 +0100)] 
[github] Add sponsorship link

iPXE is released under the GNU GPL and is 100% open source software.
There are no "premium editions", no in-app advertisements, and no
hidden costs.  The fully public version published to GitHub is and
always will be the definitive and only version of iPXE.

Many large features in iPXE have been commercially funded within this
open source model, with features being published upstream as soon as
they are complete and made available for the whole world to use, not
restricted for use only by the customer funding that particular piece
of development work.

There has not to date been any funding model for smaller pieces of
work, such as occasional code review or guaranteed attention to bug
reports.  The overhead of establishing a commercial relationship is
usually too high to be worthwhile for very small units of work.

The GitHub sponsorship mechanism provides a framework for efficiently
handling small commercial requests (or individual tokens of thanks).
Add a FUNDING.yml file to provide a convenient way for anyone who
wants to support the ongoing open source development of iPXE to do so.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
12 days ago[bnxt] Increase Tx descriptors 1473/head
Joseph Wong [Wed, 25 Jun 2025 13:05:33 +0000 (14:05 +0100)] 
[bnxt] Increase Tx descriptors

Increase TX and CMP descriptor counts.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
13 days ago[build] Disable use of common symbols
Michael Brown [Tue, 24 Jun 2025 12:32:49 +0000 (13:32 +0100)] 
[build] Disable use of common symbols

We no longer have any requirement for common symbols.  Disable common
symbols via the -fno-common compiler option, and simplify the test for
support of -fdata-sections (which can return a false negative when
common symbols are enabled).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
13 days ago[build] Allow for the existence of small-data sections
Michael Brown [Tue, 24 Jun 2025 13:40:18 +0000 (14:40 +0100)] 
[build] Allow for the existence of small-data sections

Signed-off-by: Michael Brown <mcb30@ipxe.org>
13 days ago[legacy] Allocate legacy driver .bss-like segments at probe time
Michael Brown [Tue, 24 Jun 2025 12:17:19 +0000 (13:17 +0100)] 
[legacy] Allocate legacy driver .bss-like segments at probe time

Some legacy drivers use large static allocations for transmit and
receive buffers.  To avoid bloating the .bss segment, we currently
implement these as a single common symbol named "_shared_bss" (which
is permissible since only one legacy driver may be active at any one
time).

Switch to dynamic allocation of these .bss-like segments, to avoid the
requirement for using common symbols.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
13 days ago[legacy] Rename the global legacy NIC to "legacy_nic"
Michael Brown [Tue, 24 Jun 2025 12:10:53 +0000 (13:10 +0100)] 
[legacy] Rename the global legacy NIC to "legacy_nic"

We currently have contexts in which the local variable "nic" is a
pointer to the global variable also called "nic".  This complicates
the creation of macros.

Rename the global variable to "legacy_nic" to reduce pollution of the
global namespace and to allow for the creation of macros referring to
fields within this global variable.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
13 days ago[legacy] Allocate extra padding in receive buffers
Michael Brown [Tue, 24 Jun 2025 12:40:50 +0000 (13:40 +0100)] 
[legacy] Allocate extra padding in receive buffers

Allow for legacy drivers that include VLAN tags or CRCs within their
received packets.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
13 days ago[pxe] Use a weak symbol for isapnp_read_port
Michael Brown [Tue, 24 Jun 2025 12:26:57 +0000 (13:26 +0100)] 
[pxe] Use a weak symbol for isapnp_read_port

Use a weak symbol for isapnp_read_port used in pxe_preboot.c, rather
than relying on a common symbol.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[fdtcon] Add basic support for FDT-based system serial console
Michael Brown [Mon, 23 Jun 2025 15:25:19 +0000 (16:25 +0100)] 
[fdtcon] Add basic support for FDT-based system serial console

Add support for probing a device based on the path or alias found in
the "/chosen/stdout-path" node, and using a consequently instantiated
UART as the default serial console.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[dwuart] Read input clock frequency from the device tree
Michael Brown [Mon, 23 Jun 2025 21:40:04 +0000 (22:40 +0100)] 
[dwuart] Read input clock frequency from the device tree

The 16550 design includes a programmable 16-bit clock divider for an
arbitrary input clock, requiring knowledge of the input clock
frequency in order to calculate the divider value for a given baud
rate.  The 16550 UARTs in an x86 PC will always have a 1.8432 MHz
input clock.  Non-x86 systems may have other input clock frequencies.

Define the input clock frequency as a property of a 16550 UART, and
read the value from the device tree "clock-frequency" property.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[uart] Wait for 16550 UART to become idle before modifying LCR
Michael Brown [Mon, 23 Jun 2025 21:37:32 +0000 (22:37 +0100)] 
[uart] Wait for 16550 UART to become idle before modifying LCR

Some implementations of 16550-compatible UARTs (e.g. the DesignWare
UART) are known to ignore writes to the line control register while
the transmitter is active.

Wait for the transmitter to become empty before attempting to write to
the line control register.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[serial] Allow platform to specify mechanism for identifying console
Michael Brown [Mon, 23 Jun 2025 15:19:07 +0000 (16:19 +0100)] 
[serial] Allow platform to specify mechanism for identifying console

Allow the platform configuration to provide a mechanism for
identifying the serial console UART.  Provide two globally available
mechanisms: "null" (i.e. no serial console), and "fixed" (i.e. use
whatever is specified by COMCONSOLE in config/serial.h).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[dwuart] Add "ns16550a" compatible device ID
Michael Brown [Mon, 23 Jun 2025 14:10:27 +0000 (15:10 +0100)] 
[dwuart] Add "ns16550a" compatible device ID

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[riscv] Inhibit SBI console when a serial console is active
Michael Brown [Mon, 23 Jun 2025 14:07:07 +0000 (15:07 +0100)] 
[riscv] Inhibit SBI console when a serial console is active

When a native serial driver is enabled for the system console device
specified via "/chosen/stdout-path", it is very likely that this will
correspond to the same physical serial port used for the SBI debug
console.

Inhibit input and output via the SBI console whenever a serial console
is active, to avoid duplicated output characters and unpredictable
input behaviour.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[riscv] Serialise MMIO accesses with respect to each other
Michael Brown [Sun, 22 Jun 2025 08:26:36 +0000 (09:26 +0100)] 
[riscv] Serialise MMIO accesses with respect to each other

iPXE drivers have been written with the implicit assumption that MMIO
writes are allowed to be posted but that an MMIO register read or
write after another MMIO register write will always observe the
effects of the first write.

For example: after having written a byte to the transmit holding
register (THR) of a 16550 UART, it is expected that any subsequent
read of the line status register (LSR) will observe a value consistent
with the occurrence of the write.

RISC-V does not seem to provide any ordering guarantees between
accesses to different registers within the same MMIO device.  Add
fences as part of the MMIO accessors to provide the assumed
guarantees.

Use "fence io, io" before each MMIO read or write to enforce full
serialisation of MMIO accesses with respect to each other.  This is
almost certainly more conservative than is strictly necessary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[dwuart] Add a basic driver for the Synopsys DesignWare UART
Michael Brown [Sat, 21 Jun 2025 22:13:58 +0000 (23:13 +0100)] 
[dwuart] Add a basic driver for the Synopsys DesignWare UART

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[uart] Allow for dynamically registered 16550 UARTs
Michael Brown [Sat, 21 Jun 2025 22:11:56 +0000 (23:11 +0100)] 
[uart] Allow for dynamically registered 16550 UARTs

Use the generic UART driver-private data pointer, rather than
embedding the generic UART within the 16550 UART structure.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[uart] Add support for MMIO-accessible 16550 UARTs
Michael Brown [Thu, 19 Jun 2025 11:57:28 +0000 (12:57 +0100)] 
[uart] Add support for MMIO-accessible 16550 UARTs

16550 UARTs exist on non-x86 platforms but will be accessible via MMIO
rather than port I/O.  It is possible to encounter MMIO-mapped 16550
UARTs on x86 platforms, but there is no real requirement to support
them in iPXE since the standard COM1, COM2, etc ports have been
present on every PC-compatible machine since 1981.

Assume for now that accessing 16550 UART registers requires
inb()/outb() on x86 and readb()/writeb() on other architectures.

Allow for the existence of a register shift on MMIO-mapped 16550
UARTs, since modern SoCs tend to treat register addresses as being
aligned to either 32-bit or 64-bit boundaries.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[uart] Allow for the existence of non-16550 UARTs
Michael Brown [Tue, 17 Jun 2025 13:28:18 +0000 (14:28 +0100)] 
[uart] Allow for the existence of non-16550 UARTs

Remove the assumption that all platforms use a fixed number of 16550
UARTs identifiable by a simple numeric index.  Create an abstraction
allowing for dynamic instantiation and registration of any number of
arbitrary UART models.

The common case of the serial console on x86 uses a single fixed UART
specified at compile time.  Avoid unnecessarily dragging in the
dynamic instantiation code in this use case by allowing COMCONSOLE to
refer to a single static UART object representing the relevant port.

When selecting a UART by command-line argument (as used in the
"gdbstub serial <port>" command), allow the UART to be specified as
either a numeric index (to retain backwards compatiblity) or a
case-insensitive port name such as "COM2".

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[uart] Remove ability to use frame formats other than 8n1
Michael Brown [Tue, 17 Jun 2025 14:44:12 +0000 (15:44 +0100)] 
[uart] Remove ability to use frame formats other than 8n1

In the context of serial consoles, the use of any frame formats other
than the standard 8 data bits, no parity, and one stop bit is so rare
as to be nonexistent.

Remove the almost certainly unused support for custom frame formats.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[riscv] Write SBI console output to early UART, if enabled
Michael Brown [Thu, 12 Jun 2025 11:57:26 +0000 (12:57 +0100)] 
[riscv] Write SBI console output to early UART, if enabled

The early UART is an optional feature used to obtain debug output from
the prefix before iPXE is able to parse the device tree.

Extend this feature to also cover any console output that iPXE
attempts to send to the SBI console, on the basis that the purpose of
the early UART is to provide an output-only device for situations in
which there is no functional SBI console.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[riscv] Maximise barrier effects of memory fences
Michael Brown [Thu, 12 Jun 2025 11:26:11 +0000 (12:26 +0100)] 
[riscv] Maximise barrier effects of memory fences

The RISC-V "fence" instruction encoding includes bits for predecessor
and successor input and output operations, separate from read and
write operations.  It is up to the CPU implementation to decide what
counts as I/O space rather than memory space for the purposes of this
instruction.

Since we do not expect fencing to be performance-critical, keep
everything as simple and reliable as possible by using the unadorned
"fence" instruction (equivalent to "fence iorw, iorw").

Add a memory clobber to ensure that the compiler does not reorder the
barrier.  (The volatile qualifier seems to already prevent reordering
in practice, but this is not guaranteed according to the compiler
documentation.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[fdt] Allow paths and aliases to be terminated with separator characters
Michael Brown [Wed, 11 Jun 2025 15:08:42 +0000 (16:08 +0100)] 
[fdt] Allow paths and aliases to be terminated with separator characters

Non-permitted name characters such as a colon are sometimes used to
separate alias names or paths from additional metadata, such as the
baud rate for a UART in the "/chosen/stdout-path" property.

Support the use of such alias names and paths by allowing any
character not permitted in a property name to terminate a property or
node name match.  (This is a very relaxed matching rule that will
produce false positive matches on invalid input, but this is unlikely
to cause problems in practice.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[bnxt] Remove TX padding
Joseph Wong [Wed, 11 Jun 2025 14:07:16 +0000 (15:07 +0100)] 
[bnxt] Remove TX padding

Remove unnecessary TX padding.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
3 weeks ago[fdtmem] Limit relocation to 32-bit address space
Michael Brown [Wed, 11 Jun 2025 12:48:12 +0000 (13:48 +0100)] 
[fdtmem] Limit relocation to 32-bit address space

Devices with only 32-bit DMA addressing are relatively common even on
systems with 64-bit CPUs.  Limit relocation of iPXE to 32-bit address
space so that I/O buffers and other DMA allocations will be accessible
by 32-bit devices.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[dt] Allow for creation of standalone devices
Michael Brown [Wed, 11 Jun 2025 11:51:56 +0000 (12:51 +0100)] 
[dt] Allow for creation of standalone devices

We will want to be able to create the console device as early as
possible.  Refactor devicetree probing to remove the assumption that a
devicetree device must have a devicetree parent, and expose functions
to allow a standalone device to be created given only the offset of a
node within the tree.

The full device path is no longer trivial to construct with this
assumption removed.  The full path is currently used only for debug
messages.  Remove the stored full path, use just the node name for
debug messages, and ensure that the topology information previously
visible in the full path is reconstructible from the combined debug
output if needed.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[ipv4] Add support for classless static routes
Michael Brown [Tue, 10 Jun 2025 15:55:18 +0000 (16:55 +0100)] 
[ipv4] Add support for classless static routes

Add support for RFC 3442 classless static routes provided via DHCP
option 121.

Originally-implemented-by: Hazel Smith <hazel.smith@leicester.ac.uk>
Originally-implemented-by: Raphael Pour <raphael.pour@hetzner.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[ipv4] Extend routing mechanism to handle non-default routes
Michael Brown [Thu, 5 Jun 2025 15:49:42 +0000 (16:49 +0100)] 
[ipv4] Extend routing mechanism to handle non-default routes

Extend the definition of an IPv4 routing table entry to allow for the
expression of non-default gateways for specified off-link subnets, and
of on-link secondary subnets (where we can send directly to the
destination address even though our source address is not within the
subnet).

This more precise definition also allows us to correctly handle
routing in the (uncommon for iPXE) case when multiple network
interfaces are open concurrently and more than one interface has a
default gateway.

The common case of a single IPv4 address/netmask and a default gateway
now results in two routing table entries.  To retain backwards
compatibility with existing documentation (and to avoid on-screen
clutter), the "route" command prints default gateways on the same line
as the locally assigned address.  There is therefore no change in
output from the "route" command unless explicit additional (off-link
or on-link) routes are present.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[ipv4] Add self-tests for IPv4 routing
Michael Brown [Tue, 10 Jun 2025 12:37:31 +0000 (13:37 +0100)] 
[ipv4] Add self-tests for IPv4 routing

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[test] Add infrastructure for test network devices
Michael Brown [Tue, 10 Jun 2025 12:32:10 +0000 (13:32 +0100)] 
[test] Add infrastructure for test network devices

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[riscv] Support T-Head CPUs using non-standard Memory Attribute Extension
Michael Brown [Mon, 2 Jun 2025 12:57:03 +0000 (13:57 +0100)] 
[riscv] Support T-Head CPUs using non-standard Memory Attribute Extension

Xuantie/T-Head processors such as the C910 (as used in the Sipeed
Lichee Pi 4A) use the high bits of the PTE in a very non-standard way
that is incompatible with the RISC-V specification.

As per the "Memory Attribute Extension (XTheadMae)", bits 62 and 61
represent cacheability and "bufferability" (write-back cacheability)
respectively.  If we do not enable these bits, then the processor gets
incredibly confused at the point that paging is enabled.  The symptom
is that cache lines will occasionally fail to fill, and so reads from
any address may return unrelated data from a previously read cache
line for a different address.

Work around these hardware flaws by detecting T-Head CPUs (via the
"get machine vendor ID" SBI call), then reading the vendor-specific
SXSTATUS register to determine whether or not the vendor-specific
Memory Attribute Extension has been enabled by the M-mode firmware.
If it has, then set bits 61 and 62 in each page table entry that is
used to access normal memory.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[riscv] Do not set executable bit in early UART page mapping
Michael Brown [Mon, 2 Jun 2025 07:59:54 +0000 (08:59 +0100)] 
[riscv] Do not set executable bit in early UART page mapping

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[riscv] Add fences around early UART writes
Michael Brown [Mon, 2 Jun 2025 07:36:22 +0000 (08:36 +0100)] 
[riscv] Add fences around early UART writes

Add a fence between the write to the UART transmit register and the
subsequent read from the transmit status register, to ensure that the
status correctly reflects the occurrence of the write.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[riscv] Zero SATP after any failed attempt to enable paging
Michael Brown [Mon, 2 Jun 2025 07:08:02 +0000 (08:08 +0100)] 
[riscv] Zero SATP after any failed attempt to enable paging

The RISC-V specification states that "if SATP is written with an
unsupported mode, the entire write has no effect; no fields in SATP
are modified".  We currently rely on this specified behaviour when
calculating the early UART base address: if SATP has a non-zero value
then we assume that paging must be enabled.

The XuanTie C910 CPU (as used in the Lichee Pi 4A) does not conform to
this specified behaviour.  Writing SATP with an unsupported mode will
leave SATP.MODE as zero (i.e. bare physical addressing) but the write
to SATP.PPN will still take effect, leaving SATP with an illegal
non-zero value.

Work around this misbehaviour by explicitly writing zero to SATP if we
detect that the mode change has not taken effect (e.g. because the CPU
does not support the requested paging mode).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[dt] Locate parent node at point of use in dt_ioremap()
Michael Brown [Fri, 30 May 2025 15:39:10 +0000 (16:39 +0100)] 
[dt] Locate parent node at point of use in dt_ioremap()

We currently rely on the recursive nature of devicetree bus probing to
obtain the region cell size specification from the parent device.
This blocks the possibility of creating a standalone console device
based on /chosen/stdout-path before probing the whole bus.

Fix by using fdt_parent() to locate the parent device at the point of
use within dt_ioremap().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[fdt] Provide ability to locate the parent device node
Michael Brown [Fri, 30 May 2025 15:37:28 +0000 (16:37 +0100)] 
[fdt] Provide ability to locate the parent device node

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[fdt] Add tests for device tree creation
Michael Brown [Fri, 30 May 2025 13:15:43 +0000 (14:15 +0100)] 
[fdt] Add tests for device tree creation

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[riscv] Add support for a SiFive-compatible early UART
Michael Brown [Tue, 27 May 2025 16:21:01 +0000 (17:21 +0100)] 
[riscv] Add support for a SiFive-compatible early UART

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[riscv] Support mapping early UARTs outside of the identity map
Michael Brown [Tue, 27 May 2025 15:18:17 +0000 (16:18 +0100)] 
[riscv] Support mapping early UARTs outside of the identity map

Some platforms (such as the Sipeed Lichee Pi 4A) choose to make early
debugging entertainingly cumbersome for the programmer.  These
platforms not only fail to provide a functional SBI debug console, but
also choose to place the UART at a physical address that cannot be
identity-mapped under the only paging model supported by the CPU.

Support such platforms by creating a virtual address mapping for the
early UART (in the 2MB megapage immediately below iPXE itself), and
using this as the UART base address whenever paging is enabled.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[riscv] Add support for writing prefix debug messages direct to a UART
Michael Brown [Tue, 27 May 2025 13:49:06 +0000 (14:49 +0100)] 
[riscv] Add support for writing prefix debug messages direct to a UART

Some platforms (such as the Sipeed Lichee Pi 4A) do not provide a
functional SBI debug console.  We can obtain early debug messages on
these systems by writing directly to the UART used by the vendor
firmware.

There is no viable way to parse the UART address from the device tree,
since the prefix debug messages occur extremely early, before the C
runtime environment is available and therefore before any information
has been parsed from the device tree.  The early UART model and
register addresses must be configured by editing config/serial.h if
needed.  (This is an acceptable limitation, since prefix debugging is
an extremely specialised use case.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[riscv] Create macros for writing characters to the debug console
Michael Brown [Mon, 26 May 2025 22:33:35 +0000 (23:33 +0100)] 
[riscv] Create macros for writing characters to the debug console

Abstract out the SBI debug console calls into macros that can be
shared between print_message and print_hex_value.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[riscv] Ignore riscv,isa property in favour of direct CSR testing
Michael Brown [Mon, 26 May 2025 20:12:12 +0000 (21:12 +0100)] 
[riscv] Ignore riscv,isa property in favour of direct CSR testing

The riscv,isa devicetree property appears not to be fully populated on
some real-world systems.  For example, the Sipeed Lichee Pi 4A
(running the vendor U-Boot) reports itself as "rv64imafdcvsu", which
does not include the "zicntr" extension even though the time CSR is
present and functional.

Ignore the riscv,isa property and rely solely on CSR testing to
determine whether or not extensions are present.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[image] Use image name rather than pointer value in all debug messages
Michael Brown [Mon, 26 May 2025 17:22:07 +0000 (18:22 +0100)] 
[image] Use image name rather than pointer value in all debug messages

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[riscv] Support mapping I/O devices outside of the identity map
Michael Brown [Mon, 26 May 2025 14:45:27 +0000 (15:45 +0100)] 
[riscv] Support mapping I/O devices outside of the identity map

With the 64-bit paging schemes (Sv39, Sv48, and Sv57), we identity-map
as much of the physical address space as is possible.  Experimentation
shows that this is not sufficient to provide access to all I/O
devices.  For example: the Sipeed Lichee Pi 4A includes a CPU that
supports only Sv39, but places I/O devices at the top of a 40-bit
address space.

Add support for creating I/O page table entries on demand to map I/O
devices, based on the existing design used for x86_64 BIOS.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[fdtmem] Ignore reservation regions with no fixed addresses
Michael Brown [Sun, 25 May 2025 23:22:52 +0000 (00:22 +0100)] 
[fdtmem] Ignore reservation regions with no fixed addresses

Do not print an error message for unused reservation regions that have
no fixed reserved address ranges.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[riscv] Include carriage returns in libprefix.S debug messages
Michael Brown [Sun, 25 May 2025 23:07:09 +0000 (00:07 +0100)] 
[riscv] Include carriage returns in libprefix.S debug messages

Support debug consoles that do not automatically convert LF to CRLF by
including the CR character within the debug message strings.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[memmap] Allow explicit colour selection for memory map debug messages
Michael Brown [Sun, 25 May 2025 11:06:53 +0000 (12:06 +0100)] 
[memmap] Allow explicit colour selection for memory map debug messages

Provide DBGC_MEMMAP() as a replacement for memmap_dump(), allowing the
colour used to match other messages within the same message group.

Retain a dedicated colour for output from memmap_dump_all(), on the
basis that it is generally most useful to visually compare full memory
dumps against previous full memory dumps.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[riscv] Support older SBI implementations
Michael Brown [Sun, 25 May 2025 08:28:11 +0000 (09:28 +0100)] 
[riscv] Support older SBI implementations

Fall back to attempting the legacy SBI console and shutdown calls if
the standard calls fail.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[memmap] Rename addr/last fields to min/max for clarity
Michael Brown [Fri, 23 May 2025 15:55:42 +0000 (16:55 +0100)] 
[memmap] Rename addr/last fields to min/max for clarity

Use the terminology "min" and "max" for addresses covered by a memory
region descriptor, since this is sufficiently intuitive to generally
not require further explanation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[lkrn] Support initrd construction for RISC-V bare-metal kernels
Michael Brown [Fri, 23 May 2025 15:14:45 +0000 (16:14 +0100)] 
[lkrn] Support initrd construction for RISC-V bare-metal kernels

Use the shared initrd reshuffling and CPIO header construction code
for RISC-V bare-metal kernels.  This allows for files to be injected
into the constructed ("magic") initrd image in exactly the same way as
is done for bzImage and UEFI kernels.

We append a dummy image encompassing the FDT to the end of the
reshuffle list, so that it ends up directly following the constructed
initrd in memory (but excluded from the initrd length, which was
recorded before constructing the FDT).

We also temporarily prepend the kernel binary itself to the reshuffle
list.  This is guaranteed to be safe (since reshuffling is designed to
be unable to fail), and avoids the requirement for the kernel segment
to be available before reshuffling.  This is useful since current
RISC-V bare-metal kernels tend to be distributed as EFI zboot images,
which require large temporary allocations from the external heap for
the intermediate images created during archive extraction.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[initrd] Squash and shuffle only initrds within the external heap
Michael Brown [Thu, 22 May 2025 13:57:22 +0000 (14:57 +0100)] 
[initrd] Squash and shuffle only initrds within the external heap

Any initrd images that are not within the external heap (e.g. embedded
images) do not need to be copied to the external heap for reshuffling,
and can just be left in their original locations.

Ignore any images that are not already within the external heap (or,
more precisely, that are wholly outside of the reshuffle region within
the external heap) when squashing and swapping images.

This reduces the maximum additional storage required by squashing and
swapping to zero, and so ensures that the reshuffling step is
guaranteed to succeed under all circumstances.  (This is unrelated to
the post-reshuffle load region check, which is still required.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[initrd] Split out initrd construction from bzimage.c
Michael Brown [Fri, 23 May 2025 11:13:02 +0000 (12:13 +0100)] 
[initrd] Split out initrd construction from bzimage.c

Provide a reusable function initrd_load_all() to load all initrds
(including any constructed CPIO headers) into a contiguous memory
region, and support functions to find the constructed total length and
permissible post-reshuffling load address range.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[initrd] Allow for images straddling the top of the reshuffle region
Michael Brown [Thu, 22 May 2025 13:12:12 +0000 (14:12 +0100)] 
[initrd] Allow for images straddling the top of the reshuffle region

It is hypothetically possible for external heap memory allocated
during driver startup to have been freed before an image was
downloaded, which could therefore leave an image straddling the
address recorded as the top of the reshuffle region.

Allow for this possibility by skipping squashing for any images
already straddling (or touching) the top of the reshuffle region.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[initrd] Rename bzimage_align() to initrd_align()
Michael Brown [Thu, 22 May 2025 12:41:21 +0000 (13:41 +0100)] 
[initrd] Rename bzimage_align() to initrd_align()

Alignment of initrd lengths is applicable to all Linux kernels, not
just those in the x86 bzImage format.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[initrd] Swap initrds entirely in-place via triple reversal
Michael Brown [Thu, 22 May 2025 12:27:03 +0000 (13:27 +0100)] 
[initrd] Swap initrds entirely in-place via triple reversal

Eliminate the requirement for free space when reshuffling initrds by
swapping adjacent initrds using an in-place triple reversal.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[uheap] Expose external heap region directly
Michael Brown [Thu, 22 May 2025 10:58:11 +0000 (11:58 +0100)] 
[uheap] Expose external heap region directly

We currently rely on implicit detection of the external heap region.
The INT 15 memory map mangler relies on examining the corresponding
in-use memory region, and the initrd reshuffler relies on performing a
separate detection of the largest free memory block after startup has
completed.

Replace these with explicit public symbols to describe the external
heap region.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[uheap] Prevent allocation of blocks with zero physical addresses
Michael Brown [Thu, 22 May 2025 15:05:37 +0000 (16:05 +0100)] 
[uheap] Prevent allocation of blocks with zero physical addresses

If the external heap ends up at the top of the system memory map then
leave a gap after the heap to ensure that no block ends up being
allocated with either a start or end address of zero, since this is
frequently confusing to both code and humans.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[fdtmem] Allow iPXE to be relocated to the top of the address space
Michael Brown [Thu, 22 May 2025 15:13:36 +0000 (16:13 +0100)] 
[fdtmem] Allow iPXE to be relocated to the top of the address space

Allow for relocation to a region at the very end of the physical
address space (where the next address wraps to zero).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[riscv] Speed up memmove() when copying in forwards direction
Michael Brown [Wed, 21 May 2025 15:12:56 +0000 (16:12 +0100)] 
[riscv] Speed up memmove() when copying in forwards direction

Use the word-at-a-time variable-length memcpy() implementation when
performing an overlapping copy in the forwards direction, since this
is guaranteed to be safe and likely to be substantially faster than
the existing bytewise copy.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[lkrn] Shut down devices before jumping to kernel entry point
Michael Brown [Wed, 21 May 2025 13:22:36 +0000 (14:22 +0100)] 
[lkrn] Shut down devices before jumping to kernel entry point

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[lkrn] Allow a single initrd to be passed to the booted kernel
Michael Brown [Wed, 21 May 2025 13:28:29 +0000 (14:28 +0100)] 
[lkrn] Allow a single initrd to be passed to the booted kernel

Allow a single initrd image to be passed verbatim to the booted RISC-V
kernel, as a proof of concept.

We do not yet support reshuffling to make optimal use of available
memory, or dynamic construction of CPIO headers, but this is
sufficient to allow iPXE to start up the Fedora 42 kernel with its
matching initrd image.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[fdt] Allow an initrd to be specified when creating a device tree
Michael Brown [Wed, 21 May 2025 13:26:56 +0000 (14:26 +0100)] 
[fdt] Allow an initrd to be specified when creating a device tree

Allow an initrd location to be specified in our constructed device
tree via the "linux,initrd-start" and "linux,initrd-end" properties.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[initrd] Move initrd reshuffling to be architecture-independent code
Michael Brown [Wed, 21 May 2025 11:07:24 +0000 (12:07 +0100)] 
[initrd] Move initrd reshuffling to be architecture-independent code

There is nothing x86-specific in initrd.c, and a variant of the
reshuffling logic will be required for executing bare-metal kernels on
RISC-V and AArch64.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[image] Use image replacement when executing extracted images
Michael Brown [Tue, 20 May 2025 14:27:49 +0000 (15:27 +0100)] 
[image] Use image replacement when executing extracted images

Use image_replace() to transfer execution to the extracted image,
rather than calling image_exec() directly.  This allows the original
archive image to be freed immediately if it was marked as an
automatically freeable image (e.g. via "chain --autofree").

In particular, this ensures that in the case of an archive image
containing another archive image (such as an EFI zboot kernel wrapper
image containing a gzip-compressed kernel image), the intermediate
extracted image will be freed as early as possible, since extracted
images are always marked as automatically freeable.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[lkrn] Add support for EFI zboot compressed kernel images
Michael Brown [Tue, 20 May 2025 13:14:26 +0000 (14:14 +0100)] 
[lkrn] Add support for EFI zboot compressed kernel images

Current RISC-V and AArch64 kernels found in the wild tend not to be in
the documented kernel format, but are instead "EFI zboot" kernels
comprising a small EFI executable that decompresses and executes the
inner payload (which is a kernel in the expected format).

The EFI zboot header includes a recognisable magic value "zimg" along
with two fields describing the offset and length of the compressed
payload.  We can therefore treat this as an archive image format,
extracting the payload as-is and then relying on our existing ability
to execute compressed images.

This is sufficient to allow iPXE to execute the Fedora 42 RISC-V
kernel binary as currently published.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[lkrn] Add basic support for the RISC-V Linux kernel image format
Michael Brown [Mon, 19 May 2025 23:26:08 +0000 (00:26 +0100)] 
[lkrn] Add basic support for the RISC-V Linux kernel image format

The RISC-V and AArch64 bare-metal kernel images share a common header
format, and require essentially the same execution environment: loaded
close to the start of RAM, entered with paging disabled, and passed a
pointer to a flattened device tree that describes the hardware and any
boot arguments.

Implement basic support for executing bare-metal RISC-V and AArch64
kernel images.  The (trivial) AArch64-specific code path is untested
since we do not yet have the ability to build for any bare-metal
AArch64 platforms.  Constructing and passing an initramfs image is not
yet supported.

Rename the IMAGE_BZIMAGE build configuration option to IMAGE_LKRN,
since "bzImage" is specific to x86.  To retain backwards compatibility
with existing local build configurations, we leave IMAGE_BZIMAGE as
the enabled option in config/default/pcbios.h and treat IMAGE_LKRN as
a synonym for IMAGE_BZIMAGE when building for x86 BIOS.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[bios] Use generic external heap based on the system memory map
Michael Brown [Mon, 19 May 2025 17:55:49 +0000 (18:55 +0100)] 
[bios] Use generic external heap based on the system memory map

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[riscv] Use generic external heap based on the system memory map
Michael Brown [Mon, 19 May 2025 15:16:33 +0000 (16:16 +0100)] 
[riscv] Use generic external heap based on the system memory map

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[uheap] Add a generic external heap based on the system memory map
Michael Brown [Mon, 19 May 2025 15:11:59 +0000 (16:11 +0100)] 
[uheap] Add a generic external heap based on the system memory map

Add an implementation of umalloc() using the generalised model of a
heap, placing the external heap in the largest usable region obtained
from the system memory map.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[malloc] Allow heap to specify block and pointer alignments
Michael Brown [Mon, 19 May 2025 15:07:27 +0000 (16:07 +0100)] 
[malloc] Allow heap to specify block and pointer alignments

Size-tracked pointers allocated via umalloc() have historically been
aligned to a page boundary, as have the edges of the hidden memory
region covering the external heap.

Allow the block and size-tracked pointer alignments to be specified as
heap configuration parameters.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[malloc] Allow for the existence of multiple heaps
Michael Brown [Mon, 19 May 2025 11:01:58 +0000 (12:01 +0100)] 
[malloc] Allow for the existence of multiple heaps

Create a generic model of a heap as a list of free blocks with
optional methods for growing and shrinking the heap.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[memmap] Remove now-obsolete get_memmap()
Michael Brown [Fri, 16 May 2025 17:13:38 +0000 (18:13 +0100)] 
[memmap] Remove now-obsolete get_memmap()

All memory map users have been updated to use the new system memory
map API.  Remove get_memmap() and its associated definitions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[bios] Use memmap_describe() to find an external heap location
Michael Brown [Fri, 16 May 2025 17:04:27 +0000 (18:04 +0100)] 
[bios] Use memmap_describe() to find an external heap location

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[settings] Use memmap_describe() to construct memory map settings
Michael Brown [Fri, 16 May 2025 14:47:51 +0000 (15:47 +0100)] 
[settings] Use memmap_describe() to construct memory map settings

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[bios] Use memmap_describe() to find a relocation address
Michael Brown [Thu, 15 May 2025 23:07:19 +0000 (00:07 +0100)] 
[bios] Use memmap_describe() to find a relocation address

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[comboot] Use memmap_describe() to obtain available memory
Michael Brown [Thu, 15 May 2025 22:45:55 +0000 (23:45 +0100)] 
[comboot] Use memmap_describe() to obtain available memory

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[multiboot] Use memmap_describe() to construct Multiboot memory map
Michael Brown [Thu, 15 May 2025 22:34:39 +0000 (23:34 +0100)] 
[multiboot] Use memmap_describe() to construct Multiboot memory map

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[image] Use memmap_describe() to check loadable image segments
Michael Brown [Thu, 15 May 2025 22:02:06 +0000 (23:02 +0100)] 
[image] Use memmap_describe() to check loadable image segments

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[memmap] Use memmap_dump_all() to dump debug memory maps
Michael Brown [Thu, 15 May 2025 16:09:35 +0000 (17:09 +0100)] 
[memmap] Use memmap_dump_all() to dump debug memory maps

There are several places where get_memmap() is called solely to
produce debug output.  Replace these with calls to memmap_dump_all()
(which will be a no-op unless debugging is enabled).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[bios] Describe umalloc() heap as an in-use memory area
Michael Brown [Thu, 15 May 2025 14:35:27 +0000 (15:35 +0100)] 
[bios] Describe umalloc() heap as an in-use memory area

Use the concept of an in-use memory region defined as part of the
system memory map API to describe the umalloc() heap.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[bios] Update to use the generic system memory map API
Michael Brown [Thu, 15 May 2025 00:21:48 +0000 (01:21 +0100)] 
[bios] Update to use the generic system memory map API

Provide an implementation of the system memory map API based on the
assorted BIOS INT 15 calls, and a temporary implementation of the
legacy get_memmap() function using the new API.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[fdtmem] Update to use the generic system memory map API
Michael Brown [Wed, 14 May 2025 21:30:13 +0000 (22:30 +0100)] 
[fdtmem] Update to use the generic system memory map API

Provide an implementation of the system memory map API based on the
system device tree, excluding any memory outside the size of the
accessible physical address space and defining an in-use region to
cover the relocated copy of iPXE and the system device tree.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[memmap] Define an API for managing the system memory map
Michael Brown [Wed, 14 May 2025 21:19:54 +0000 (22:19 +0100)] 
[memmap] Define an API for managing the system memory map

Define a generic system memory map API, based on the abstraction
created for parsing the FDT memory map and adding a concept of hidden
in-use memory regions as required to support patching the BIOS INT 15
memory map.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[tests] Remove prehistoric umalloc() test code
Michael Brown [Thu, 15 May 2025 14:46:02 +0000 (15:46 +0100)] 
[tests] Remove prehistoric umalloc() test code

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[fdtmem] Record size of accessible physical address space
Michael Brown [Wed, 14 May 2025 21:09:51 +0000 (22:09 +0100)] 
[fdtmem] Record size of accessible physical address space

The size of accessible physical address space will be required for the
runtime memory map, not just at relocation time.  Make this size an
additional parameter to fdt_register() (matching the prototype for
fdt_relocate()), and record the value for future reference.

Note that we cannot simply store the limit in fdt_relocate() since it
is called before .data is writable and before .bss is zeroed.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[bios] Rename memmap.c to int15.c
Michael Brown [Wed, 14 May 2025 21:01:00 +0000 (22:01 +0100)] 
[bios] Rename memmap.c to int15.c

Create namespace for an architecture-independent memmap.c by renaming
the BIOS-specific memmap.c to int15.c.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[bnxt] Use updated DMA APIs 1403/head
Joseph Wong [Wed, 14 May 2025 13:21:02 +0000 (14:21 +0100)] 
[bnxt] Use updated DMA APIs

Replace malloc_phys with dma_alloc, free_phys with dma_free, alloc_iob
with alloc_rx_iob, free_iob with free_rx_iob, virt_to_bus with dma or
iob_dma.  Replace dma_addr_t with physaddr_t.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
7 weeks ago[bnxt] Return proper error codes in probe 1445/head
Joseph Wong [Wed, 14 May 2025 13:08:27 +0000 (14:08 +0100)] 
[bnxt] Return proper error codes in probe

Return the proper error codes in bnxt_init_one, to indicate the
correct return status upon completion.  Failure paths could
incorrectly indicate a success.  Correct assertion condition to check
for non-NULL pointer.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
7 weeks ago[crypto] Remove redundant null pointer check
Michael Brown [Wed, 14 May 2025 11:34:27 +0000 (12:34 +0100)] 
[crypto] Remove redundant null pointer check

Coverity reports a spurious potential null pointer dereference in
cms_decrypt(), since the null pointer check takes place after the
pointer has already been dereferenced.  The pointer can never be null,
since it is initialised to point to cipher_null at the point that the
containing structure is allocated.

Remove the redundant null pointer check, and for symmetry ensure that
the digest and public-key algorithm pointers are similarly initialised
at the point of allocation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[riscv] Add a .pf32 build target for padded parallel flash images
Michael Brown [Tue, 13 May 2025 17:25:24 +0000 (18:25 +0100)] 
[riscv] Add a .pf32 build target for padded parallel flash images

QEMU's -pflash option requires an image that has been padded to the
exact expected size (32MB for all of the supported RISC-V virtual
machines).

Add a .pf32 build target which is simply the equivalent .sbi target
padded to 32MB in size, to simplify testing.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[riscv] Perform a writability test before applying relocations
Michael Brown [Tue, 13 May 2025 16:36:53 +0000 (17:36 +0100)] 
[riscv] Perform a writability test before applying relocations

If paging is not supported, then we will attempt to apply dynamic
relocations to fix up the runtime addresses.  If the image is
currently executing directly from flash memory, this can result in
effectively sending an undefined sequence of commands to the flash
device, which can cause unwanted side effects.

Perform an explicit writability test before applying relocations,
using a write value chosen to be safe for at least any devices
conforming to the JEDEC Common Flash Interface (CFI01).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[riscv] Avoid potentially overwriting the scratch area during relocation
Michael Brown [Tue, 13 May 2025 12:46:35 +0000 (13:46 +0100)] 
[riscv] Avoid potentially overwriting the scratch area during relocation

We do not currently describe the temporary page table or the temporary
stack as areas to be avoided during relocation of the iPXE image to a
new physical address.

Perform the copy of the iPXE image and zeroing of the .bss within
libprefix.S, after we have no futher use for the temporary page table
or the temporary initial stack.  Perform the copy and registration of
the system device tree in C code after relocation is complete and the
new stack (within .bss) has been set up.

This provides a clean separation of responsibilities between the
RISC-V libprefix.S and the architecture-independent fdtmem.c.  The
prefix is responsible only for relocating iPXE to the new physical
address returned from fdtmem_relocate(), and doesn't need to know or
care where fdtmem.c is planning to place the copy of the device tree.

Signed-off-by: Michael Brown <mcb30@ipxe.org>