Commit Graph

6352 Commits (bda2a4984cd3c64ebbe858ea15ad9429af256527)
 

Author SHA1 Message Date
Michael Brown 13c1abe10a [prefix] Specify i486 architecture for LZMA decompressor
The decompressor uses the i486 "bswap" instruction, but does not
require any instructions that exist only on i586 or above.  Update the
".arch" directive to reflect the requirements of the code as
implemented.

Reported-by: Martin Habets <habetsm.xilinx@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-12 10:09:33 +01:00
Michael Brown 866fa1ce76 [gzip] Add support for gzip archive images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-08 15:34:19 +01:00
Michael Brown d093683d93 [zlib] Add support for zlib archive images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-08 15:34:19 +01:00
Michael Brown 5c9c8d2b9b [image] Add "imgextract" command for extracting archive images
Add the concept of extracting an image from an archive (which could be
a single-file archive such as a gzip-compressed file), along with an
"imgextract" command to expose this functionality to scripts.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-08 15:34:19 +01:00
Michael Brown de4f31cdca [image] Provide image_set_len() utility function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-08 15:34:19 +01:00
Michael Brown 106f4c5391 [cloud] Allow multiple images to be imported simultaneously
Allow both x86_64 and arm64 images to be imported in a single import
command, thereby allowing for e.g.

  make CONFIG=cloud EMBED=config/cloud/aws.ipxe bin/ipxe.usb

  make CONFIG=cloud EMBED=config/cloud/aws.ipxe \
       CROSS=aarch64-linux-gnu- bin-arm64-efi/ipxe.usb

  ../contrib/cloud/aws-import -w amilist.txt -p \
       bin/ipxe.usb bin-arm64-efi/ipxe.usb

This simplifies the process of generating a single amilist.txt file
for inclusion in the documentation at https://ipxe.org/howto/ec2

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-02 12:38:03 +01:00
Michael Brown 1dfc05622d [cloud] Attempt to include CPUID_SETTINGS only for x86 builds
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-02 12:38:03 +01:00
Michael Brown 438513f6f6 [cloud] Autodetect CPU architecture from AMI disk image
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-02 09:39:10 +01:00
Michael Brown 6dad316e66 [cloud] Use a sortable default AMI name
The AWS console user interface provides no convenient way to sort AMIs
by creation date.

Provide a default AMI name constructed from the current date and CPU
architecture, to simplify the task of finding the most recent iPXE AMI
in a given AWS region.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-01 22:08:17 +01:00
Michael Brown e994237c0b [cloud] Add ability to generate Dokuwiki table of AMI images
Add an option to generate the amilist.txt list of current AMI images
as included in the EC2 documentation at https://ipxe.org/howto/ec2

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-01 21:36:19 +01:00
Michael Brown 323af9ee84 [settings] Add --timeout option to "read" command
Requested-by: Matteo Guglielmi <Matteo.Guglielmi@dalco.ch>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-23 12:30:30 +01:00
Michael Brown b2501dd122 [readline] Add an optional timeout to readline_history()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-23 12:27:57 +01:00
Michael Brown 56f7d44fde [efi] Show ACPI address space descriptor ranges in debug messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-21 16:13:02 +01:00
Michael Brown 3efdbef2f0 [efi] Always map full length of coherent DMA buffer allocation
The EFI PCI API takes a page count as the input to AllocateBuffer()
but a byte count as the input to Map().  There is nothing in the UEFI
specification that requires us to map exactly the allocated length,
and no systems have yet been observed that will fail if the map length
does not exactly match the allocated length.  However, it is plausible
that some implementations may fail if asked to map a length that does
not match the length of the corresponding allocation.

Avoid potential future problems by always mapping the full allocated
length.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-20 14:37:08 +01:00
Matya e4afaa2246 [build] Fix genfsimg to build ISO with long filenames
Commit 79c0173 ("[build] Create util/genfsimg for building
filesystem-based images") introduced the new genfsimg, which lacks the
-l option when building ISO files.  This option is required to build
level 2 (long plain) ISO9660 filenames, which are required when using
the .lkrn extensions on older versions of ISOLINUX.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-20 13:39:39 +01:00
Michael Brown 614d99eba1 [xen] Avoid infinite loop on allocation failure in xenstore_response()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-20 13:28:57 +01:00
Michael Brown 85d179f2c6 [xen] Support scatter-gather to allow for jumbo frames
The use of jumbo frames for the Xen netfront virtual NIC requires the
use of scatter-gather ("feature-sg"), with the receive descriptor ring
becoming a list of page-sized buffers and the backend using as many
page buffers as required for each packet.

Since iPXE's abstraction of an I/O buffer does not include any sort of
scatter-gather list, this requires an extra allocation and copy on the
receive datapath for any packet that spans more than a single page.

This support is required in order to successfully boot an AWS EC2
virtual machine (with non-enhanced networking) via iSCSI if jumbo
frames are enabled, since the netback driver used in EC2 seems not to
allow "feature-sg" to be renegotiated once the Linux kernel driver
takes over.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-14 16:33:41 +01:00
Michael Brown 8ca43ccbc1 [int13] Do not report INT 13 extension support for emulated floppies
The INT 13 extensions provide a mechanism for accessing disks using
linear (LBA) rather than C/H/S addressing.  SAN protocols such as
iSCSI invariably support only linear addresses and so iPXE currently
provides LBA access to all SAN disks (with autodetection and emulation
of an appropriate geometry for C/H/S accesses).

Most BIOSes will not report support for INT 13 extensions for floppy
disk drives, and some operating systems may be confused by a floppy
drive that claims such support.

Minimise surprise by reporting the existence of support for INT 13
extensions only for non-floppy drive numbers.  Continue to provide
support for all drive numbers, to avoid breaking operating systems
that may unconditionally use the INT 13 extensions without first
checking for support.

Reported-by: Valdo Toost <vtoost@hot.ee>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-13 20:42:55 +01:00
Michael Brown 3ae83222ce [cloud] Enable "poweroff" command in cloud images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-10 20:03:32 +01:00
Michael Brown 78749542fc [netdevice] Ensure driver transmit() and poll() will not be re-entered
When CONSOLE_SYSLOG is used, a DBG() from within a network device
driver may cause its transmit() or poll() methods to be unexpectedly
re-entered.  Since these methods are not intended to be re-entrant,
this can lead to undefined behaviour.

Add an explicit re-entrancy guard to both methods.  Note that this
must operate at a per-netdevice level, since there are legitimate
circumstances under which the netdev_tx() or netdev_poll() functions
may be re-entered (e.g. when using VLAN devices).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-10 16:53:52 +01:00
Michael Brown 0be8491b71 [pci] Avoid scanning nonexistent buses when using PCIAPI_DIRECT
There is no method for obtaining the number of PCI buses when using
PCIAPI_DIRECT, and we therefore currently scan all possible bus
numbers.  This can cause a several-second startup delay in some
virtualised environments, since PCI configuration space access will
necessarily require the involvement of the hypervisor.

Ameliorate this situation by defaulting to scanning only a single bus,
and expanding the number of PCI buses to accommodate any subordinate
buses that are detected during enumeration.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-10 15:05:05 +01:00
Tyler J. Stachecki c0346dbb49 [intel] Add additional PCI device ID to table
Adding this missing identifier allows the X557-AT2 chipset seen on (at
least) Super Micro A2SDI-H-TF motherboards to function with iPXE.

Signed-off-by: Tyler J. Stachecki <stachecki.tyler@gmail.com>
2021-04-10 14:56:00 +01:00
Marvin Häuser 94245624e4 [efi] Mark PE .reloc and .debug sections as discardable
After a PE image is fully loaded and relocated, the loader code may
opt to zero discardable sections for security reasons.  This includes
relocation and debug information, as both contain hints about specific
locations within the binary.  Mark both generated sections as
discardable, which follows the PE specification.

Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2021-04-10 14:13:05 +01:00
Marvin Häuser f1e9e2b062 [efi] Align EFI image sections by page size
For optimal memory permission management, PE sections need to be
aligned by the platform's minimum page size.  Currently, the PE
section alignment is fixed to 32 bytes, which is below the typical 4kB
page size.  Align all sections to 4kB and adjust ELF to PE image
conversion accordingly.

Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2021-04-10 13:43:47 +01:00
Marvin Häuser 1cc8756511 [efi] Discard .pci_devlist.* sections for EFI images
As per https://github.com/ipxe/ipxe/pull/313#issuecomment-816018398,
these sections are not required for EFI execution.  Discard them to
avoid implementation-defined alignment malforming binaries.

Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2021-04-10 13:22:31 +01:00
Michael Brown 1192edf394 [dhcp] Handle DHCPNAK by returning to discovery state
Handle a DHCPNAK by returning to the discovery state to allow iPXE to
attempt to obtain a replacement IPv4 address.

Reuse the existing logic for deferring discovery when the link is
blocked: this avoids hammering a misconfigured DHCP server with a
non-stop stream of requests and allows the DHCP process to eventually
time out and fail.

Originally-implemented-by: Blake Rouse <blake.rouse@canonical.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-11 16:04:19 +00:00
Michael Brown 7c8fc2cae8 [linux] Fail at link time if building slirp.linux without libslirp
The iPXE build system is constructed for a standalone codebase with no
external dependencies, and does not have any equivalent of the
standard userspace ./configure script.  We currently check for the
ability to include slirp/libslirp.h and conditionalise portions of
linux_api.c on its presence.  The actual slirp driver code is built
unconditionally, as with all iPXE drivers.

This currently leads to a silent runtime failure if attempting to use
slirp.linux built on a system that was missing slirp/libslirp.h.

Convert this to a link-time failure by deliberately omitting the
relevant symbols from linux_api.c when slirp/libslirp.h is not
present.  This allows other builds (e.g. tap.linux or tests.linux) to
succeed: the link-time failure will occur only if the slirp driver is
included within the build target.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-11 15:25:33 +00:00
Michael Brown 65bd5c05db [linux] Do not assume that stat() works on sysfs files
Linux kernel 3.12 and earlier report a zero size via stat() for all
ACPI table files in sysfs.  There is no way to determine the file size
other than by reading the file until EOF.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-03 02:26:42 +00:00
Michael Brown 1c4917b6a7 [linux] Validate length of ACPI table read from sysfs
Consumers of acpi_find() will assume that returned structures include
a valid table header and that the length in the table header is
correct.  These assumptions are necessary when dealing with raw ACPI
tables, since there exists no independent source of length
information.

Ensure that these assumptions are also valid for ACPI tables read from
sysfs.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-03 01:55:07 +00:00
Michael Brown 50d13907c4 [linux] Place -lslirp at end of linker search list
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-03 01:09:33 +00:00
Michael Brown 69ecab2634 [linux] Use fstat() rather than statx()
The statx() system call has a clean header file and a consistent
layout, but was unfortunately added only in kernel 4.11.

Using stat() or fstat() directly is extremely messy since glibc does
not necessarily use the kernel native data structures.  However, as
the only current use case is to obtain the length of an open file, we
can merely provide a wrapper that does precisely this.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-03 01:01:58 +00:00
Michael Brown 2a2909cd1f [linux] Use generic sysfs mechanism to read SMBIOS table
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02 23:59:48 +00:00
Michael Brown 6816006808 [linux] Use generic sysfs mechanism to read ACPI tables
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02 23:59:46 +00:00
Michael Brown 5c8a9905ce [linux] Add a generic function for reading files from sysfs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02 23:59:30 +00:00
Michael Brown 976839ae4c [linux] Free cached ACPI tables on shutdown
Free any cached ACPI tables for the sake of neatness (and a clean
report from Valgrind).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02 23:59:27 +00:00
Michael Brown 3a58400121 [dns] Reduce debug verbosity for DNS server list
The DNS server list is currently printed as a debug message whenever
settings are applied.  This can result in some very noisy debug logs
when a script makes extensive use of settings.

Move the DNS server list debug messages to DBGLVL_EXTRA.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02 20:03:21 +00:00
Michael Brown 7b963310aa [linux] Allow arbitrary settings to be applied to Linux devices
Allow arbitrary settings to be specified on the Linux command line.
For example:

    ./bin-x86_64-linux/slirp.linux \
          --net slirp,testserver=qa-test.ipxe.org

This can be useful when using the Linux userspace build to test
embedded scripts, since it allows arbitrary parameters to be passed
directly on the command line.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02 19:35:11 +00:00
Michael Brown 8055d5c48b [linux] Add missing pci_num_bus() stub
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02 18:02:33 +00:00
Michael Brown 3b8aff94bf [build] Fix building on older versions of gcc
Versions of gcc prior to 9.1 do not support the single-argument form
of static_assert().  Fix by unconditionally defining a compatibility
macro for the single file that uses this.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02 16:47:22 +00:00
Michael Brown 2b5d3f582f [slirp] Add libslirp driver for Linux
Add a driver using libslirp to provide a virtual network interface
without requiring root permissions on the host.  This simplifies the
process of running iPXE as a Linux userspace application with network
access.  For example:

  make bin-x86_64-linux/slirp.linux
  ./bin-x86_64-linux/slirp.linux --net slirp

libslirp will provide a built-in emulated DHCP server and NAT router.
Settings such as the boot filename may be controlled via command-line
options.  For example:

  ./bin-x86_64-linux/slirp.linux \
      --net slirp,filename=http://192.168.0.1/boot.ipxe

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02 11:09:57 +00:00
Michael Brown 916ebef198 [build] Allow __asmcall to be used as a type attribute
The "used" attribute can be applied only to functions or variables,
which prevents the use of __asmcall as a type attribute.

Fix by removing "used" from the definition of __asmcall for i386 and
x86_64 architectures, and adding explicit __used annotations where
necessary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02 10:15:23 +00:00
Michael Brown c09b627973 [linux] Provide ACPI settings via /sys/firmware/acpi/tables
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-01 01:38:54 +00:00
Michael Brown 9776f6ece1 [acpi] Allow for platforms that provide ACPI tables individually
The ACPI API currently expects platforms to provide access to a single
contiguous ACPI table.  Some platforms (e.g. Linux userspace) do not
provide a convenient way to obtain the entire ACPI table, but do
provide access to individual tables.

All iPXE consumers of the ACPI API require access only to individual
tables.

Redefine the internal API to make acpi_find() an API method, with all
existing implementations delegating to the current RSDT-based
implementation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-01 00:08:23 +00:00
Michael Brown d175936b78 [acpi] Eliminate redundant acpi_find_rsdt() in acpi_sx()
The result from acpi_find_rsdt() is used only for the debug message.
Simplify the debug message and remove the otherwise redundant call to
acpi_find_rsdt().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-28 23:59:15 +00:00
Michael Brown 0956fb52c4 [acpi] Use a fixed colour for debug messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-28 23:58:06 +00:00
Michael Brown f309d7a7b7 [linux] Use host glibc system call wrappers
When building as a Linux userspace application, iPXE currently
implements its own system calls to the host kernel rather than relying
on the host's C library.  The output binary is statically linked and
has no external dependencies.

This matches the general philosophy of other platforms on which iPXE
runs, since there are no external libraries available on either BIOS
or UEFI bare metal.  However, it would be useful for the Linux
userspace application to be able to link against host libraries such
as libslirp.

Modify the build process to perform a two-stage link: first picking
out the requested objects in the usual way from blib.a but with
relocations left present, then linking again with a helper object to
create a standard hosted application.  The helper object provides the
standard main() entry point and wrappers for the Linux system calls
required by the iPXE Linux drivers and interface code.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-28 23:28:23 +00:00
Michael Brown 040cdd0c65 [linux] Add a prefix to all symbols to avoid future name collisions
Allow for the possibility of linking to platform libraries for the
Linux userspace build by adding an iPXE-specific symbol prefix.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-27 19:25:02 +00:00
Michael Brown 16d95227a4 [bitops] Provide an explicit operand size for bit test instructions
Recent versions of the GNU assembler (observed with GNU as 2.35 on
Fedora 33) will produce a warning message

  Warning: no instruction mnemonic suffix given and no register
  operands; using default for `bts'

The operand size affects only the potential range for the bit number.
Since we pass the bit number as an unsigned int, it is already
constrained to 32 bits for both i386 and x86_64.

Silence the assembler warning by specifying an explicit 32-bit operand
size (and thereby matching the choice that the assembler would
otherwise make automatically).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-27 15:45:31 +00:00
Michael Brown b76281a885 [efi] Compress EFI ROM images
Use the reference implementation of the EFI compression algorithm
(taken from the EDK2 codebase, with minor bugfixes to allow
compilation with -Werror) to compress EFI ROM images.

Inspired-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-19 19:58:04 +00:00
Michael Brown 900f1f98d3 [librm] Test for FXSAVE/FXRSTOR instruction support
Assume that preservation of the %xmm registers is unnecessary during
installation of iPXE into memory, since this is an operation that by
its nature substantially disrupts large portions of the system anyway
(such as the E820 memory map).  This assumption allows us to utilise
the existing CPUID code to check that FXSAVE/FXRSTOR are supported.

Test for support during the call to init_librm and store the flag for
use during subsequent calls to virt_call.

Reduce the scope of TIVOLI_VMM_WORKAROUND to affecting only the call
to check_fxsr(), to reduce #ifdef pollution in the remaining code.

Debugged-by: Johannes Heimansberg <git@jhe.dedyn.io>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-18 15:38:56 +00:00