Commit Graph

6139 Commits (6733296243b8b8b88e5cb1eb7d3225fe3048541e)
 

Author SHA1 Message Date
Christian Iversen 6733296243 [cmdline] Allow "show" to display multiple settings at once
For convenience, it is now possible to display a whole set of options at once,
by specifying the scope name, including trailing slash.

Before:

    iPXE> show net0/ip
    net0/ip:ipv4 = 1.2.3.4
    iPXE> show net0/netmask
    net0/netmask:ipv4 = 255.255.255.0

After:

    iPXE> show net0/
    net0/busid = 01:80:86:10:0e
    net0/busloc = 0x10
    net0/bustype = PCI
    net0/chip = 82540em
    net0/hwaddr = 52:54:00:12:34:56
    net0/ifname = net0
    net0/mac = 52:54:00:12:34:56
    net0/ip = 1.2.3.4
    net0/netmask = 255.255.255.0
    net0/ip6 = fe80::5054:ff:fe12:3456
    net0/len6 = 64

Signed-off-by: Christian Iversen <ci@iversenit.dk>
2021-01-27 22:18:25 +01:00
Michael Brown a08244ecc4 [efi] Use EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL if available
The original EFI_SIMPLE_TEXT_INPUT_PROTOCOL is not technically
required to handle the use of the Ctrl key, and the long-obsolete EFI
1.10 specification lists only backspace, tab, linefeed, and carriage
return as required.  Some particularly brain-dead vendor UEFI firmware
implementations dutifully put in the extra effort of ensuring that all
other control characters (such as Ctrl-C) are impossible to type via
EFI_SIMPLE_TEXT_INPUT_PROTOCOL.

Current versions of the UEFI specification mandate that the console
input handle must support both EFI_SIMPLE_TEXT_INPUT_PROTOCOL and
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL, the latter of which at least
provides access to modifier key state.

Unlike EFI_SIMPLE_TEXT_INPUT_PROTOCOL, the pointer to the
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance does not appear within the
EFI system table and must therefore be opened explicitly.  The UEFI
specification provides no safe way to do so, since we cannot open the
handle BY_DRIVER or BY_CHILD_CONTROLLER and so nothing guarantees that
this pointer will remain valid for the lifetime of iPXE.  We must
simply hope that no UEFI firmware implementation ever discovers a
motivation for reinstalling the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
instance.

Use EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL if available, falling back to
the existing EFI_SIMPLE_TEXT_PROTOCOL otherwise.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-27 12:45:53 +00:00
Joe Groocock 8488c989cc [image] Implicitly trust first embedded image
iPXE when used as a NIC option ROM can sometimes be reloaded by the
UEFI/BIOS and any pre-initialised memory will remain loaded. When the
imgtrust command is run it sets `require_trusted_images'. Upon
reloading, iPXE tries to load the first embedded image but fails as it
is not marked trusted.

Setting this flag ensures that imgtrust with the first embedded script
is reentrant.

Signed-off-by: Joe Groocock <jgroocock@cloudflare.com>
2021-01-27 12:42:31 +00:00
Christian Iversen b9de7e6eda [infiniband] Require drivers to specify the number of ports
Require drivers to report the total number of Infiniband ports.  This
is necessary to report the correct number of ports on devices with
dynamic port types.

For example, dual-port Mellanox cards configured for (eth, ib) would
be rejected by the subnet manager, because they report using "port 2,
out of 1".

Signed-off-by: Christian Iversen <ci@iversenit.dk>
2021-01-27 01:15:35 +00:00
Michael Brown 4f9fbe6c16 [efi] Fix misleading debug message
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-26 22:25:18 +00:00
Christian Iversen f4c3a01470 [ifmgmt] Make "ifstat" show the link-layer protocol for each netdev
This is useful on devices that perform auto-detection for ports.
Example output:

    iPXE> ifstat
    net0: 00:11:22:33:44:55 using mt4099 on 0000:00:03.0 (Ethernet) [open]
      [Link:down, TX:0 TXE:0 RX:0 RXE:0]
      [Link status: Unknown (http://ipxe.org/1a086101)]
    net1: 00:11:22:33:44:56 using mt4099 on 0000:00:03.0 (IPoIB) [open]
      [Link:down, TX:0 TXE:0 RX:0 RXE:0]
      [Link status: Initialising (http://ipxe.org/1a136101)]

Signed-off-by: Christian Iversen <ci@iversenit.dk>
2021-01-26 21:02:10 +00:00
Michael Brown 42db0bd041 [cmdline] Expose "iflinkwait" as a command
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-26 17:07:52 +00:00
Michael Brown ade4d2b4fe [efi] Fix use of uninitialised variable
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-26 11:30:50 +00:00
Michael Brown a3f1e8fb67 [efi] Automatically load "/autoexec.ipxe" when booted from a filesystem
When booting iPXE from a filesystem (e.g. a FAT-formatted USB key) it
can be useful to have an iPXE script loaded automatically from the
same filesystem.  Compared to using an embedded script, this has the
advantage that the script can be edited without recompiling the iPXE
binary.

For the BIOS version of iPXE, loading from a filesystem is handled
using syslinux (or isolinux) which allows the script to be passed to
the iPXE .lkrn image as an initrd.

For the UEFI version of iPXE, the platform firmware loads the iPXE
.efi image directly and there is currently no equivalent of the BIOS
initrd mechanism.

Add support for automatically loading a file "autoexec.ipxe" (if
present) from the root of the filesystem containing the UEFI iPXE
binary.

A combined BIOS and UEFI image for a USB key can be created using e.g.

  ./util/genfsimg -o usbkey.img -s myscript.ipxe \
      bin-x86_64-efi/ipxe.efi bin/ipxe.lkrn

The file "myscript.ipxe" would appear as "autoexec.ipxe" on the USB
key, and would be loaded automatically on both BIOS and UEFI systems.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-25 17:04:44 +00:00
Michael Brown 989a7a8032 [image] Provide image_memory()
Consolidate the remaining logic common to initrd_init() and imgmem()
into a shared image_memory() function.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-25 17:03:56 +00:00
Michael Brown ffc41ae9d1 [travis] Update to current default build environment
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-24 12:50:50 +00:00
Michael Brown 68469d1b12 [build] Report a meaningful error message if isolinux.bin is missing
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-24 12:31:48 +00:00
Michael Brown 7c3d186a19 [build] Check that mkisofs equivalent supports the required options
The "-e" option required for creating EFI boot images is supported
only by widely used patched versions of genisoimage.

Check that the required options are supported when selecting a mkisofs
equivalent, thereby allowing a fallback to the use of xorrisofs when
building a UEFI ISO image on a system with an unpatched version of
genisoimage.

Continue to prefer the use of genisoimage over xorrisofs, since there
is apparently no way to inhibit the irritatingly useless startup
banner message printed by xorrisofs even when the "-quiet" option is
specified.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-24 12:19:48 +00:00
Michael Brown 8ef22d819b [tftp] Allow for profiling of client and server turnaround times
Provide some visibility into the turnaround times on both client and
server sides as perceived by iPXE, to assist in debugging inexplicably
slow TFTP transfers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-22 21:05:07 +00:00
Michael Brown b99477b3fa [image] Add the "imgmem" command
Provide the "imgmem" command to create an image from an existing block
of memory, for debugging purposes only.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-22 18:44:58 +00:00
Michael Brown 99ac69b8a9 [image] Provide image_set_data()
Extract part of the logic in initrd_init() to a standalone function
image_set_data().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-22 18:34:47 +00:00
Michael Brown ae73fb5aa0 [build] Allow an initrd script to be provided via genfsimg
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-22 18:34:47 +00:00
Michael Brown 34f51a0dca [build] Fail gracefully when no input files are given to genfsimg
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-22 18:34:47 +00:00
Michael Brown 05d7591a71 [build] Use explicit disk geometry for generated FAT filesystem images
For FAT filesystem images larger than a 1.44MB floppy disk, round up
the image size to a whole number of 504kB cylinders before formatting.
This avoids losing up to a cylinder's worth of expected space in the
filesystem image.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-22 12:29:25 +00:00
Michael Brown a2a6618d46 [build] Fix genfsimg incompatibility with dash shell
Reported-by: Antony Messerli <antony@mes.ser.li>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-22 09:58:37 +00:00
Michael Brown 565ca3eab0 [build] Set volume name "iPXE" on FAT filesystem images
Allow generated filesystem images to be accessed using the file:// URI
syntax by setting a defined volume name.  This allows a script placed
on the same filesystem image to be accessed using e.g.

  chain file://iPXE/script.ipxe

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-21 21:29:40 +00:00
Michael Brown 1173538155 [build] Allow genfsimg to be used on third party UEFI binaries
Extract the PE header offset from the MZ header rather than assuming a
fixed offset as used in the binaries created by the iPXE build system.

This allows genfsimg to be used to create bootable filesystem images
from third party UEFI binaries such as the UEFI shell.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-19 23:49:58 +00:00
Michael Brown 3a9621a6fb [ipv6] Defer router discovery timeout while link is blocked
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-19 14:15:56 +00:00
Michael Brown 9a341203df [dhcp] Allow for links that remained blocked for up to three minutes
With the default timeouts for Cisco MAC Authentication Bypass, the
link will remain blocked for around 90 seconds (plus a likely
subsequent delay for STP).

Extend the maximum number of DHCP discovery deferrals to allow for up
to three minutes of waiting for a link to become unblocked.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-19 13:01:46 +00:00
Michael Brown 9c2e8bad11 [eap] Treat an EAP Request-Identity as indicating a blocked link
A switch port using 802.1x authentication will send EAP
Request-Identity packets once the physical link is up, and will not be
forwarding packets until the port identity has been established.

We do not currently support 802.1x authentication.  However, a
reasonably common configuration involves using a preset list of
permitted MAC addresses, with the "authentication" taking place
between the switch and a RADIUS server.  In this configuration, the
end device does not need to perform any authentication step, but does
need to be prepared for the switch port to fail to forward packets for
a substantial time after physical link-up.  This exactly matches the
"blocked link" semantics already used when detecting a non-forwarding
switch port via LACP or STP.

Treat a received EAP Request-Identity as indicating a blocked link.
Unlike LACP or STP, there is no way to determine the expected time
until the next EAP packet and so we must choose a fixed timeout.

Erroneously assuming that the link is blocked is relatively harmless
since we will still attempt to transmit and receive data even over a
link that is marked as blocked, and so the net effect is merely to
prolong DHCP attempts.  In contrast, erroneously assuming that the
link is unblocked will potentially cause DHCP to time out and give up,
resulting in a failed boot.

The default EAP Request-Identity interval in Cisco switches (where
this is most likely to be encountered in practice) is 30 seconds, so
choose 45 seconds as a timeout that is likely to avoid gaps during
which we falsely assume that the link is unblocked.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-19 13:01:46 +00:00
Michael Brown 274ad69012 [eapol] Replace EAPoL code
Replace the GPL2+-only EAPoL code (currently used only for WPA) with
new code licensed under GPL2+-or-UBDL.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-19 13:01:43 +00:00
Michael Brown 8606204595 [dhcp] Continue transmitting DHCPDISCOVER while link is blocked
Continue to transmit DHCPDISCOVER while waiting for a blocked link, in
order to support mechanisms such as Cisco MAC Authentication Bypass
that require repeated transmission attempts in order to trigger the
action that will result in the link becoming unblocked.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-19 12:21:28 +00:00
Omgalof 0fb37a48a9 [build] Include xorrisofs as a viable mkisofs equivalent
Add support for xorrisofs, a GNU mkisofs equivalent that is available
in most distro repositories.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-18 12:48:00 +00:00
Michael Brown 8e3826aa10 [build] Inhibit spurious array bounds warning on some versions of gcc
Some versions of gcc (observed with gcc 9.3.0 on NixOS Linux) produce
a spurious warning about an out-of-bounds array access for the
isa_extra_probe_addrs[] array.

Work around this compiler bug by redefining the array index as a
signed long, which seems to somehow avoid this spurious warning.

Debugged-by: Manuel Mendez <mmendez534@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-15 20:54:27 +00:00
Manuel Mendez a5fb41873d [isa] Add missing #include <config/isa.h>
Signed-off-by: Manuel Mendez <mmendez534@gmail.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-13 23:01:27 +00:00
Michael Brown 79c0173d6d [build] Create util/genfsimg for building filesystem-based images
Generalise util/geniso, util/gensdsk, and util/genefidsk to create a
single script util/genfsimg that can be used to build either FAT
filesystem images or ISO images.

Extend the functionality to allow for building multi-architecture UEFI
bootable ISO images and combined BIOS+UEFI images.

For example:

  ./util/genfsimg -o combined.iso \
      bin-x86_64-efi/ipxe.efi \
      bin-arm64-efi/ipxe.efi \
      bin/ipxe.lkrn

would generate a hybrid image that could be used as a CDROM (or hard
disk or USB key) on legacy BIOS, x86_64 UEFI, or ARM64 UEFI.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-13 17:58:02 +00:00
Michael Brown c42f31bc8a [xhci] Avoid false positive Coverity warning
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-04 09:37:59 +00:00
Michael Brown 5aa389593d [efi] Leave asynchronous USB endpoints open until device is removed
Some UEFI device drivers will react to an asynchronous USB transfer
failure by dubiously terminating the scheduled transfer from within
the completion handler.

We already have code from commit fbb776f ("[efi] Leave USB endpoint
descriptors in existence until device is removed") that avoids freeing
memory in this situation, in order to avoid use-after-free bugs.  This
is not sufficient to avoid potential problems, since with an xHCI
controller the act of closing the endpoint requires issuing a command
and awaiting completion via the event ring, which may in turn dispatch
further USB transfer completion events.

Avoid these problems by leaving the USB endpoint open (but with the
refill timer stopped) until the device is finally removed, as is
already done for control and bulk transfers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-03 20:23:51 +00:00
Michael Brown 7ce3b84050 [xhci] Show meaningful error messages after command failures
Ensure that any command failure messages are followed up with an error
message indicating what the failed command was attempting to perform.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-03 19:12:00 +00:00
Michael Brown 017b345d5a [xhci] Fail attempts to issue concurrent commands
The xHCI driver can handle only a single command TRB in progress at
any one time.  Immediately fail any attempts to issue concurrent
commands (which should not occur in normal operation).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-03 19:08:49 +00:00
Michael Brown 988d2c13cd [efi] Use segment and bus number to identify PCI root bridge I/O protocol
There may be multiple instances of EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL for
a single PCI segment.  Use the bus number range descriptor from the
ACPI resource list to identify the correct protocol instance.

There is some discrepancy between the ACPI and UEFI specifications
regarding the interpretation of values within the ACPI resource list.

The ACPI specification defines the min/max field values to be within
the secondary (device-side) address space, and defines the offset
field value as "the offset that must be added to the address on the
secondary side to obtain the address on the primary side".

The UEFI specification states instead that the offset field value is
the "offset to apply to the starting address to convert it to a PCI
address", helpfully omitting to clarify whether "to apply" in this
context means "to add" or "to subtract".  The implication of the
wording is also that the "starting address" is not already a "PCI
address" and must therefore be a host-side address rather than the
ACPI-defined device-side address.

Code comments in the EDK2 codebase seem to support the latter
(non-ACPI) interpretation of these ACPI structures.  For example, in
the PciHostBridgeDxe driver there can be found the comment

  Macros to translate device address to host address and vice versa.
  According to UEFI 2.7, device address = host address + translation
  offset.

along with a pair of macros TO_HOST_ADDRESS() and TO_DEVICE_ADDRESS()
which similarly negate the sense of the "translation offset" from the
definition found in the ACPI specification.

The existing logic in efipci_ioremap() (based on a presumed-working
externally contributed patch) applies the non-ACPI interpretation: it
assumes that min/max field values are host-side addresses and that the
offset field value is negated.

Match this existing logic by assuming that min/max field values are
host-side bus numbers.  (The bus number offset value is therefore not
required and so can be ignored.)

As noted in commit 9b25f6e ("[efi] Fall back to assuming identity
mapping of MMIO address space"), some systems seem to fail to provide
MMIO address space descriptors.  Assume that some systems may
similarly fail to provide bus number range descriptors, and fall back
in this situation to assuming that matching on segment number alone is
sufficient.

Testing any of this is unfortunately impossible without access to
esoteric hardware that actually uses non-zero translation offsets.

Originally-implemented-by: Thomas Walker <twalker@twosigma.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-31 21:03:10 +00:00
Michael Brown dced22d6de [smbios] Add support for the 64-bit SMBIOS3 entry point
Support UEFI systems that provide only 64-bit versions of the SMBIOS
entry point.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-29 14:41:50 +00:00
b1f6c1c4 485f8ce554 [efi] Allow for longer device paths in debug messages
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-29 13:16:22 +00:00
Martin Habets da491eaae7 [sfc] Update email addresses
Email from solarflare.com will stop working, so update those.  Remove
email for Shradha Shah, as she is not involved with this any more.
Update copyright notices for files touched.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-28 18:41:55 +00:00
Josh McSavaney 68f1914aae [x509] Clarify debug message for an untrusted X.509 issuer
We surface this debugging information in cases where a cert actually
lacks an issuer, but also in cases where it *has* an issuer, but we
cannot trust it (e.g. due to issues in establishing a trust chain).

Signed-off-by: Josh McSavaney <me@mcsau.cc>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-28 18:18:58 +00:00
Mohammed Taha ce841946df [golan] Add new PCI IDs
Signed-off-by: Mohammed <mohammedt@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-28 13:55:30 +00:00
Michael Brown 47098d7cb1 [efi] Allow EFI_USB_IO_PROTOCOL interfaces to be nullified and leaked
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-17 21:46:52 +00:00
Michael Brown 6769a7c3c6 [efi] Skip interface uninstallation during shutdown
iPXE seems to be almost alone in the UEFI world in attempting to shut
down cleanly, free resources, and leave hardware in a well-defined
reset state before handing over to the booted operating system.

The UEFI driver model does allow for graceful shutdown via
uninstallation of protocol interfaces.  However, virtually no other
UEFI drivers do this, and the external code paths that react to
uninstallation are consequently poorly tested.  This leads to a
proliferation of bugs found in UEFI implementations in the wild, as
described in commits such as 1295b4a ("[efi] Allow initialisation via
SNP interface even while claimed") or b6e2ea0 ("[efi] Veto the HP
XhciDxe Driver").

Try to avoid triggering such bugs by unconditionally skipping the
protocol interface uninstallation during UEFI boot services shutdown,
leaving the interfaces present but nullified and deliberately leaking
the containing memory.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-17 21:32:49 +00:00
Michael Brown fb91542f2a [efi] Nullify interfaces unconditionally on error and shutdown paths
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-17 19:52:41 +00:00
Michael Brown f47a45ea2d [iphone] Add iPhone tethering driver
USB tethering via an iPhone is unreasonably complicated due to the
requirement to perform a pairing operation that involves establishing
a TLS session over a completely unrelated USB function that speaks a
protocol that is almost, but not quite, entirely unlike TCP.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-16 13:29:06 +00:00
Michael Brown f43a8f8b9f [crypto] Allow private key to be specified as a TLS connection parameter
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-15 16:54:06 +00:00
Michael Brown 6a8664d9ec [tls] Include root of trust within definition of TLS session
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-15 16:28:33 +00:00
Michael Brown 3475f9162b [x509] Make root of trust a reference-counted structure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-09 16:45:50 +00:00
Michael Brown e3eedb0be5 [efi] Avoid using potentially uninitialised driver name in veto checks
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-08 15:52:25 +00:00
Michael Brown 39f5293492 [x509] Record root of trust used when validating a certificate
Record the root of trust used at the point that a certificate is
validated, redefine validation as checking a certificate against a
specific root of trust, and pass an explicit root of trust when
creating a TLS connection.

This allows a custom TLS connection to be used with a custom root of
trust, without causing any validated certificates to be treated as
valid for normal purposes.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-12-08 15:04:28 +00:00