aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-04-14[xen] Support scatter-gather to allow for jumbo framesxen-sgMichael Brown3-57/+154
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-13[int13] Do not report INT 13 extension support for emulated floppiesMichael Brown1-2/+2
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-10[cloud] Enable "poweroff" command in cloud imagesMichael Brown1-0/+5
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-04-10[netdevice] Ensure driver transmit() and poll() will not be re-enteredMichael Brown2-7/+38
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[pci] Avoid scanning nonexistent buses when using PCIAPI_DIRECTMichael Brown3-4/+30
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[intel] Add additional PCI device ID to tableTyler J. Stachecki1-0/+1
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[efi] Mark PE .reloc and .debug sections as discardableMarvin Häuser1-0/+2
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[efi] Align EFI image sections by page sizeMarvin Häuser2-20/+33
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[efi] Discard .pci_devlist.* sections for EFI imagestmpMarvin Häuser1-0/+1
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-03-11[dhcp] Handle DHCPNAK by returning to discovery stateMichael Brown1-9/+31
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[linux] Fail at link time if building slirp.linux without libslirpMichael Brown1-29/+3
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-03[linux] Do not assume that stat() works on sysfs filesMichael Brown1-29/+20
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[linux] Validate length of ACPI table read from sysfsMichael Brown2-0/+11
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[linux] Place -lslirp at end of linker search listMichael Brown1-3/+2
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-03[linux] Use fstat() rather than statx()Michael Brown3-11/+8
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-02[linux] Use generic sysfs mechanism to read SMBIOS tableMichael Brown3-64/+87
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02[linux] Use generic sysfs mechanism to read ACPI tablesMichael Brown1-78/+21
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02[linux] Add a generic function for reading files from sysfsMichael Brown5-0/+143
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02[linux] Free cached ACPI tables on shutdownMichael Brown1-0/+22
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[dns] Reduce debug verbosity for DNS server listMichael Brown1-9/+9
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[linux] Allow arbitrary settings to be applied to Linux devicesMichael Brown1-13/+37
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[linux] Add missing pci_num_bus() stubMichael Brown1-0/+11
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02[build] Fix building on older versions of gccMichael Brown1-0/+3
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[slirp] Add libslirp driver for LinuxMichael Brown6-2/+900
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[build] Allow __asmcall to be used as a type attributeMichael Brown6-8/+9
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-01[linux] Provide ACPI settings via /sys/firmware/acpi/tablesMichael Brown4-0/+193
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-01[acpi] Allow for platforms that provide ACPI tables individuallykexec3kexec2kexecMichael Brown8-6/+46
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-02-28[acpi] Eliminate redundant acpi_find_rsdt() in acpi_sx()Michael Brown1-10/+2
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[acpi] Use a fixed colour for debug messagesMichael Brown1-9/+12
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-28[linux] Use host glibc system call wrappersMichael Brown29-601/+553
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-27[linux] Add a prefix to all symbols to avoid future name collisionsMichael Brown3-2/+8
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[bitops] Provide an explicit operand size for bit test instructionsMichael Brown1-4/+4
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-19[efi] Compress EFI ROM imageseficompressMichael Brown4-6/+1652
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-18[librm] Test for FXSAVE/FXRSTOR instruction supportfxsrMichael Brown3-6/+36
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[librm] Add missing __asmcall on init_idt()Michael Brown1-1/+1
The __asmcall declaration has no effect on a void function with no parameters, but should be included for completeness since the function is called directly from assembly code. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-18[prefix] Add a generic raw image prefixrplMichael Brown1-0/+53
Provide a generic raw image prefix, which assumes that the iPXE image has been loaded in its entirety on a paragraph boundary. The resulting .raw image can be loaded via RPL using an rpld.conf file such as: HOST { ethernet = 00:00:00:00:00:00/6; FILE { path="ipxe.raw"; load=0x2000; }; execute=0x2000; }; Debugged-by: Johannes Heimansberg <git@jhe.dedyn.io> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-18[initrd] Allow for zero-length initrd filesMichael Brown1-6/+6
A zero-length initrd file will currently cause an endless loop during reshuffling as the empty image is repeatedly swapped with itself. Fix by terminating the inner loop before considering an image as a candidate to be swapped with itself. Reported-by: Pico Mitchell <pico@randomapplications.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-17[cloud] Do not enable serial console on EFI platformsMichael Brown1-0/+5
Most EFI firmware builds (including those found on ARM64 instances in AWS EC2) will already send console output to the serial port. Do not enable direct serial console output in EFI builds using CONFIG=cloud. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-17[efi] Record cached DHCPACK from loaded image's device handle, if presentcachedhcpMichael Brown4-0/+115
Record the cached DHCPACK obtained from the EFI_PXE_BASE_CODE_PROTOCOL instance installed on the loaded image's device handle, if present. This allows a chainloaded UEFI iPXE to reuse the IPv4 address and DHCP options previously obtained by the built-in PXE stack, as is already done for a chainloaded BIOS iPXE. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-17[efi] Defer autoboot link-layer address and autoexec script probingMichael Brown1-6/+20
The code to detect the autoboot link-layer address and to load the autoexec script currently runs before the call to initialise() and so has to function without a working heap. This requirement can be relaxed by deferring this code to run via an initialisation function. This gives the code a normal runtime environment, but still invokes it early enough to guarantee that the original loaded image device handle has not yet been invalidated. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-17[efi] Split out autoexec script portions of efi_autoboot.cMichael Brown6-190/+234
The "autoboot device" and "autoexec script" functionalities in efi_autoboot.c are unrelated except in that they both need to be invoked by efiprefix.c before device drivers are loaded. Split out the autoexec script portions to a separate file to avoid potential confusion. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-17[pxe] Split out platform-independent portions of cachedhcp.cMichael Brown4-37/+110
Split out the portions of cachedhcp.c that can be shared between BIOS and UEFI (both of which can provide a buffer containing a previously obtained DHCP packet, and neither of which provide a means to determine the length of this DHCP packet). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-16[ath5k] Add missing AR5K_EEPROM_READ in ath5k_eeprom_read_turbo_modesBruce Rogers1-0/+1
The GCC11 compiler pointed out something that apparently no previous compiler noticed: in ath5k_eeprom_pread_turbo_modes, local variable val is used uninitialized. From what I can see, the code is just missing an initial AR5K_EEPROM_READ. Add it right before the switch statement. Signed-off-by: Bruce Rogers <brogers@suse.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-16[cloud] Enable IPv6 and HTTPS in cloud boot imagesMichael Brown1-0/+4
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-16[cloud] Add utility for importing images to AWS EC2Michael Brown1-0/+100
Add a utility that can be used to upload an iPXE disk image to AWS EC2 as an Amazon Machine Image (AMI). For example: make CONFIG=cloud EMBED=config/cloud/aws.ipxe bin/ipxe.usb ../contrib/cloud/aws-import -p -n "iPXE 1.21.1" bin/ipxe.usb Uploads are performed in parallel across all regions, and use the EBS direct APIs to avoid the need to store temporary files in S3 or to run VM import tasks. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-15[build] Work around stray sections introduced by some binutils versionsusbdiskMichael Brown2-7/+33
Some versions of GNU ld (observed with binutils 2.36 on Arch Linux) introduce a .note.gnu.property section marked as loadable at a high address and with non-empty contents. This adds approximately 128MB of garbage to the BIOS .usb disk images. Fix by using a custom linker script for the prefix-only binaries such as the USB disk partition table and MBR, in order to allow unwanted sections to be explicitly discarded. Reported-by: Christian Hesse <mail@eworm.de> Tested-by: Christian Hesse <mail@eworm.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-13[cloud] Use PCIAPI_DIRECT for cloud imagesMichael Brown5-0/+10
The version of SeaBIOS found on some AWS EC2 instances (observed with t3a.nano in eu-west-1) has no support for the INT 1A PCI BIOS calls. Bring config/ioapi.h into the named-configuration set of headers, and specify the use of PCIAPI_DIRECT for CONFIG=cloud, to work around the missing PCI BIOS support. Switching to a different named configuration will now unfortunately cause an almost complete rebuild of iPXE. As described in commit c801cb2 ("[build] Allow for named configurations at build time"), this is the reason why config/ioapi.h was not originally in the named-configuration set of header files. This rebuild cost is acceptable given that build times are substantially faster now than seven years ago, and that very few people are likely to be switching named configurations on a regular basis. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-13[ena] Switch to two-phase reset mechanismMichael Brown2-9/+33
The Linux and FreeBSD drivers for the (totally undocumented) ENA adapters use a two-phase reset mechanism: first set ENA_CTRL.RESET and wait for this to be reflected in ENA_STAT.RESET, then clear ENA_CTRL.RESET and again wait for it to be reflected in ENA_STAT.RESET. The iPXE driver currently assumes a self-clearing reset mechanism, which appeared to work at the time that the driver was created but seems no longer to function, at least on the t3.nano and t3a.nano instance types found in eu-west-1. Switch to a simplified version of the two-phase reset mechanism as used by Linux and FreeBSD. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-12[build] Use .balign directive instead of .alignMichael Brown11-18/+18
The semantics of the assembler's .align directive vary by CPU architecture. For the ARM builds, it specifies a power of two rather than a number of bytes. This currently leads to the .einfo entries (which do not appear in the final binary) having an alignment of 256 bytes for the ARM builds. Fix by switching to the GNU-specific directive .balign, which is consistent across architectures Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-12[build] Remove support for building with the Intel C compilerMichael Brown6-287/+5
Support for building with the Intel C compiler (icc) was added in 2009 in the expectation that UEFI support would eventually involve compiling iPXE to EFI Byte Code. EFI Byte Code has never found any widespread use: no widely available compilers can emit it, Microsoft refuses to sign EFI Byte Code binaries for UEFI Secure Boot, and I have personally never encountered any examples of EFI Byte Code in the wild. The support for using the Intel C compiler has not been tested in over a decade, and would almost certainly require modification to work with current releases of the compiler. Simplify the build process by removing this old legacy code. Signed-off-by: Michael Brown <mcb30@ipxe.org>