aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-11-12[xhci] Avoid DMA during shutdown if firmware has disabled bus masteringthunderbolt_workaroundMichael Brown1-0/+22
On some systems (observed with the Thunderbolt ports on a ThinkPad X1 Extreme Gen3 and a ThinkPad P53), the system firmware will disable bus mastering on the xHCI controller and all PCI bridges at the point that ExitBootServices() is called if the IOMMU is enabled. This leaves the xHCI controller unable to shut down cleanly since all commands will fail with a timeout. Commit 85eb961 ("[xhci] Allow for permanent failure of the command mechanism") allows us to detect that this has happened and respond cleanly. However, some unidentified hardware component (either the xHCI controller or one of the PCI bridges) seems to manage to enqueue the attempted DMA operation and eventually complete it after the operating system kernel has reenabled bus mastering. This results in a DMA operation to an area of memory that the hardware is no longer permitted to access. On Windows with the Driver Verifier enabled, this will result in a STOP 0xE6 (DRIVER_VERIFIER_DMA_VIOLATION). Work around this problem by detecting when bus mastering has been disabled, and immediately failing the device to avoid initiating any further DMA attempts. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-11-12[uri] Retain original encodings for path, query, and fragment fieldsuriMichael Brown5-75/+148
iPXE decodes any percent-encoded characters during the URI parsing stage, thereby allowing protocol implementations to consume the raw field values directly without further decoding. When reconstructing a URI string for use in an HTTP request line, the percent-encoding is currently reapplied in a reversible way: we guarantee that our reconstructed URI string could be decoded to give the same raw field values. This technically violates RFC3986, which states that "URIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent". Experiments show that several HTTP server applications will attach meaning to the choice of whether or not a particular character was percent-encoded, even when the percent-encoding is unnecessary from the perspective of parsing the URI into its component fields. Fix by storing the originally encoded substrings for the path, query, and fragment fields and using these original encoded versions when reconstructing a URI string. The path field is also stored as a decoded string, for use by protocols such as TFTP that communicate using raw strings rather than URI-encoded strings. All other fields (such as the username and password) continue to be stored only in their decoded versions since nothing ever needs to know the originally encoded versions of these fields. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-10-28[xhci] Allow for permanent failure of the command mechanismxhci_failMichael Brown2-2/+51
Some xHCI controllers (observed with the Thunderbolt ports on a ThinkPad X1 Extreme Gen3 and a ThinkPad P53) seem to suffer a catastrophic failure at the point that ExitBootServices() is called if the IOMMU is enabled. The symptoms appear to be consistent with another UEFI driver (e.g. the IOMMU driver, or the Thunderbolt driver) having torn down the DMA mappings, leaving the xHCI controller unable to write to host memory. The observable effect is that all commands fail with a timeout, and attempts to abort command execution similarly fail since the xHCI controller is unable to report the abort completion. Check for failure to abort a command, and respond by performing a full device reset (as recommended by the xHCI specification) and by marking the device as permanently failed. Reported-by: Andreas Hammarskjöld <junior@2PintSoftware.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-10-28[virtio] Update driver to use DMA APIAaron Young5-31/+69
Signed-off-by: Aaron Young <aaron.young@oracle.com>
2021-09-10[readline] Extend maximum read line length to 1024 charactersMichael Brown1-7/+17
Realistic Linux kernel command lines may exceed our current 256 character limit for interactively edited commands or settings. Switch from stack allocation to heap allocation, and increase the limit to 1024 characters. Requested-by: Matteo Guglielmi <Matteo.Guglielmi@dalco.ch> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-09-09[ecm] Use ACPI-provided system-specific MAC address if presentMichael Brown1-0/+9
Use the "system MAC address" provided within the DSDT/SSDT if such an address is available and has not already been assigned to a network device. Tested-by: Andreas Hammarskjöld <junior@2PintSoftware.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-09-09[ecm] Expose USB vendor/device information to ecm_fetch_mac()Michael Brown3-7/+8
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-09-09[acpi] Allow for extraction of a MAC address from the DSDT/SSDTMichael Brown3-0/+169
Some vendors provide a "system MAC address" within the DSDT/SSDT, to be used to override the MAC address for a USB docking station. A full implementation would require an ACPI bytecode interpreter, since at least one OEM allows the MAC address to be constructed by executable ACPI bytecode (rather than a fixed data structure). We instead attempt to extract a plausible-looking "_AUXMAC_#.....#" string that appears shortly after an "AMAC" or "MACA" signature. This should work for most implementations encountered in practice. Debugged-by: Andreas Hammarskjöld <junior@2PintSoftware.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-09-08[acpi] Generalise DSDT/SSDT data extraction logicMichael Brown3-69/+99
Allow for the DSDT/SSDT signature-scanning and value extraction code to be reused for extracting a pass-through MAC address. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-07-27[efi] Record cached ProxyDHCPOFFER and PXEBSACK, if presentMichael Brown5-51/+167
Commit cd3de55 ("[efi] Record cached DHCPACK from loaded image's device handle, if present") added the ability for a chainloaded UEFI iPXE to reuse an IPv4 address and DHCP options previously obtained by a built-in PXE stack, without needing to perform a second DHCP request. Extend this to also record the cached ProxyDHCPOFFER and PXEBSACK 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 a boot filename or other options that were provided via a ProxyDHCP or PXE boot server mechanism, rather than by standard DHCP. Tested-by: Andreas Hammarskjöld <junior@2PintSoftware.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-07-26[efi] Use zero for PCI vendor/device IDs when no applicable ID existsMichael Brown1-1/+2
When building an EFI ROM image for which no PCI vendor/device ID is applicable (e.g. bin-x86_64-efi/ipxe.efirom), the build process will currently construct a command such as ./util/efirom -v -d -c bin-x86_64-efi/ipxe.efidrv \ bin-x86_64-efi/ipxe.efirom which gets interpreted as a vendor ID of "-0xd" (i.e. 0xfff3, after truncation to 16 bits). Fix by using an explicit zero ID when no applicable ID exists, as is already done when constructing BIOS ROM images. Reported-by: Konstantin Aladyshev <aladyshev22@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-07-26[build] Fix genfsimg to work with FATDIR with spaceJuniorJPDJ1-1/+1
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-07-20[cloud] Retry DHCP aggressively in AWS EC2Michael Brown1-1/+16
The DHCP service in EC2 has been observed to occasionally stop responding for bursts of several seconds. This can easily result in a failed boot, since the current cloud boot script will attempt DHCP only once. Work around this problem by retrying DHCP in a fairly tight cycle within the cloud boot script, and falling back to a reboot after several failed DHCP attempts. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-07-15[efi] Match signtool expectations for file alignmentMichael Brown1-1/+15
As of commit f1e9e2b ("[efi] Align EFI image sections by page size"), our SectionAlignment has been increased to 4kB in order to allow for page-level memory protection to be applied by the UEFI firmware, with FileAlignment left at 32 bytes. The PE specification states that the value for FileAlignment "should be a power of 2 between 512 and 64k, inclusive", and that "if the SectionAlignment is less than the architecture's page size, then FileAlignment must match SectionAlignment". Testing shows that signtool.exe will reject binaries where FileAlignment is less than 512, unless FileAlignment is equal to SectionAlignment. This indicates a somewhat zealous interpretation of the word "should" in the PE specification. Work around this interpretation by increasing FileAlignment from 32 bytes to 512 bytes, and add explanatory comments for both FileAlignment and SectionAlignment. Debugged-by: Andreas Hammarskjöld <junior@2PintSoftware.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-07-15[libc] Allow for externally-defined LITTLE_ENDIAN and BIG_ENDIAN constantsMichael Brown1-0/+4
When building the Linux userspace binaries, the external system headers may have already defined values for the __LITTLE_ENDIAN and __BIG_ENDIAN constants. Fix by retaining the existing values if already defined, since the actual values of these constants do not matter. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-07-01[uri] Make URI schemes case-insensitiveMichael Brown2-2/+4
RFC 3986 section 3.1 defines URI schemes as case-insensitive (though the canonical form is always lowercase). Use strcasecmp() rather than strcmp() to allow for case insensitivity in URI schemes. Requested-by: Andreas Hammarskjöld <junior@2PintSoftware.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-28[rdc] Add driver for RDC R6040 embedded NICMichael Brown3-0/+889
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-24[realtek] Work around hardware bug on RTL8211Brealtek_hackMichael Brown2-0/+12
The RTL8211B seems to have a bug that prevents the link from coming up unless the MII_MMD_DATA register is cleared. The Linux kernel driver applies this workaround (in rtl8211b_resume()) only to the specific RTL8211B PHY model, along with a matching workaround to set bit 9 of MII_MMD_DATA when suspending the PHY. Since we have no need to ever suspend the PHY, and since writing a zero ought to be harmless, we just clear the register unconditionally. Debugged-by: Nikolay Pertsev <nikolay.p@cos.flag.org> Tested-by: Nikolay Pertsev <nikolay.p@cos.flag.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-23[cloud] Show ifstat output after a failed boot attemptMichael Brown2-2/+4
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-22[peerdist] Assume that most recently discovered peer can be reusedMichael Brown1-0/+23
The peer discovery time has a significant impact on the overall PeerDist download speed, since each block requires an individual discovery attempt. In most cases, a peer that responds for block N will turn out to also respond for block N+1. Assume that the most recently discovered peer (for any block) probably has a copy of the next block to be discovered, thereby allowing the peer download attempt to begin immediately. In the case that this assumption is incorrect, the existing error recovery path will allow for fallback to newly discovered peers (or to the origin server). Suggested-by: Andreas Hammarskjöld <junior@2PintSoftware.com> Tested-by: Andreas Hammarskjöld <junior@2PintSoftware.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-17[build] Fix building on broken versions of GNU binutilsMichael Brown1-1/+2
Some versions of GNU objcopy (observed with binutils 2.23.52.0.1 on CentOS 7.0.1406) document the -D/--enable-deterministic-archives option but fail to recognise the short form of the option. Work around this problem by using the long form of the option. Reported-by: Olaf Hering <olaf@aepfle.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-14[build] Ensure build ID is deterministicBernhard M. Wiedemann1-1/+1
Commit 040cdd0 ("[linux] Add a prefix to all symbols to avoid future name collisions") unintentionally reintroduced an element of non-determinism into the build ID, by omitting the -D option when manipulating the blib.a archive. Fix by adding the -D option to restore determinism. Reworded-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-11[efi] Veto the Itautec Ip4ConfigDxe driveritautecMichael Brown1-8/+10
The Ip4ConfigDxe driver bug that was observed on Dell systems in commit 64b4452 ("[efi] Blacklist the Dell Ip4ConfigDxe driver") has also been observed on systems with a manufacturer name of "Itautec S.A.". The symptoms of the bug are identical: an attempt to call DisconnectController() on the LOM device handle will lock up the system. Fix by extending the veto to cover the Ip4ConfigDxe driver for this manufacturer. Debugged-by: Celso Viana <celso.vianna@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-07[libc] Match standard prototype for putchar()Michael Brown2-2/+5
Reported-by: Bernhard M. Wiedemann <bwiedemann@suse.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-07[base64] Include terminating NUL within base64 character arrayMichael Brown1-1/+1
Reported-by: Bernhard M. Wiedemann <bwiedemann@suse.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-07[rndis] Fix size of reserved fieldsrndis_paddingMichael Brown1-2/+2
Most RNDIS data structures include a trailing 4-byte reserved field. For the REMOTE_NDIS_PACKET_MSG and REMOTE_NDIS_INITIALIZE_CMPLT structures, this is an 8-byte field instead. iPXE currently uses incorrect structure definitions with a 4-byte reserved field in all data structures, resulting in data payloads that overlap the last 4 bytes of the 8-byte reserved field. RNDIS uses explicit offsets to locate any data payloads beyond the message header, and so liberal RNDIS parsers (such as those used in Hyper-V and in the Linux USB Ethernet gadget driver) are still able to parse the malformed structures. A stricter RNDIS parser (such as that found in some older Android builds that seem to use an out-of-tree USB Ethernet gadget driver) may reject the malformed structures since the data payload offset is less than the header length, causing iPXE to be unable to transmit packets. Fix by correcting the length of the reserved fields. Debugged-by: Martin Nield <pmn1492@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-04[ath5k] Avoid returning uninitialised data on EEPROM read errorsMichael Brown1-0/+3
Originally-implemented-by: Bernhard M. Wiedemann <bwiedemann@suse.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-06-03[crypto] Add memory output constraints for big-integer inline assemblybigint_output_constraintsMichael Brown2-22/+43
The ARM versions of the big-integer inline assembly functions include constraints to indicate that the output value is modified by the assembly code. These constraints are not present in the equivalent code for the x86 versions. As of GCC 11, this results in the compiler reporting that the output values may be uninitialized. Fix by including the relevant memory output constraints. Reported-by: Christian Hesse <mail@eworm.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-24[build] Use SOURCE_DATE_EPOCH for isohybrid MBR ID if it existsMichael Brown1-1/+5
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-24[build] Use SOURCE_DATE_EPOCH for .iso timestamps if it existsMichael Brown1-0/+10
Originally-implemented-by: Bernhard M. Wiedemann <bwiedemann@suse.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-21[efi] Provide an "initrd.magic" file for use by UEFI kernelsMichael Brown1-0/+88
Provide a file "initrd.magic" via the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL that contains the initrd file as constructed for BIOS bzImage kernels (including injected files with CPIO headers constructed by iPXE). This allows BIOS and UEFI kernels to obtain the exact same initramfs image, by adding "initrd=initrd.magic" to the kernel command line. For example: #!ipxe kernel boot/vmlinuz initrd=initrd.magic initrd boot/initrd.img initrd boot/modules/e1000.ko /lib/modules/e1000.ko initrd boot/modules/af_packet.ko /lib/modules/af_packet.ko boot Do not include the "initrd.magic" file within the root directory listing, since doing so would break software such as wimboot that processes all files within the root directory. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-21[efi] Allow for non-image-backed virtual filesMichael Brown1-69/+221
Restructure the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL implementation to allow for the existence of virtual files that are not simply backed by a single underlying image. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-21[cpio] Split out bzImage initrd CPIO header constructionMichael Brown5-56/+110
iPXE will construct CPIO headers for images that have a non-empty command line, thereby allowing raw images (without CPIO headers) to be injected into a dynamically constructed initrd. This feature is currently implemented within the BIOS-only bzImage format support. Split out the CPIO header construction logic to allow for reuse in other contexts such as in a UEFI build. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-18[x509] Use case-insensitive comparison for certificate namesMichael Brown2-1/+3
DNS names are case-insensitive, and RFC 5280 (unlike RFC 3280) mandates support for case-insensitive name comparison in X.509 certificates. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-18[libc] Add strncasecmp()Michael Brown3-1/+26
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-17[bnxt] Use hexadecimal values in PCI_ROM entriesJoseph2-141/+64
Use hexadecimal values instead of macros in PCI_ROM entries so Perl script can parse them correctly. Move PCI_ROM entries from header file to C file. Integrate bnxt_vf_nics array into PCI_ROM entries by introducing BNXT_FLAG_PCI_VF flag into driver_data field. Add whitespaces in PCI_ROM entries for style consistency. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-17[intel] Add PCI ID for I219-V and -LM 10 to 15Christian Nilsson1-0/+12
Signed-off-by: Christian Nilsson <nikize@gmail.com>
2021-05-12[image] Support archive image formats independently of "imgextract" commandMichael Brown3-11/+11
Support for the zlib and gzip archive image formats is currently included only if the IMAGE_ARCHIVE_CMD is used to enable the "imgextract" command. The ability to transparently execute a single-member archive image without using the "imgextract" command renders this unintuitive: a user wanting to gain the ability to boot a gzip-compressed kernel image would expect to have to enable IMAGE_GZIP rather than IMAGE_ARCHIVE_CMD. Reverse the inclusion logic, so that archive image formats must now be enabled explicitly (via IMAGE_GZIP and/or IMAGE_ZLIB), with the archive image management commands dragged in as needed if any archive image formats are enabled. The archive image management commands may be explicitly disabled via IMAGE_ARCHIVE_CMD if necessary. This matches the behaviour of IBMGMT_CMD and similar options, where the relevant commands are included only when something else already drags in the underlying feature. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-12[image] Propagate trust flag to extracted archive imagesMichael Brown1-0/+4
An extracted image is wholly derived from the original archive image. If the original archive image has been verified and marked as trusted, then this trust logically extends to any image extracted from it. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-12[image] Allow single-member archive images to be executed transparentlyMichael Brown4-0/+33
Provide image_extract_exec() as a helper method to allow single-member archive images (such as gzip compressed images) to be executed without an explicit "imgextract" step. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-12[undi] Read TSC only when profilingMichael Brown1-2/+9
Avoid using the "rdtsc" instruction unless profiling is enabled. This allows the non-debug build of the UNDI driver to be used on a CPU such as a 486 that does not support the TSC. Reported-by: Nikolai Zhubr <n-a-zhubr@yandex.ru> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-12[rng] Check for TSC support before using RTC entropy sourceMichael Brown2-0/+14
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-12[prefix] Specify i486 architecture for LZMA decompressorMichael Brown1-1/+1
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-08[gzip] Add support for gzip archive imagesimgextractMichael Brown7-0/+403
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-08[zlib] Add support for zlib archive imagesMichael Brown7-0/+345
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-08[image] Add "imgextract" command for extracting archive imagesMichael Brown9-0/+326
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[image] Provide image_set_len() utility functionMichael Brown2-4/+22
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-02[cloud] Allow multiple images to be imported simultaneouslyMichael Brown1-19/+19
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[cloud] Attempt to include CPUID_SETTINGS only for x86 buildsMichael Brown1-0/+2
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-05-02[cloud] Autodetect CPU architecture from AMI disk imageMichael Brown1-6/+17
Signed-off-by: Michael Brown <mcb30@ipxe.org>