Commit Graph

6352 Commits (bda2a4984cd3c64ebbe858ea15ad9429af256527)
 

Author SHA1 Message Date
Michael Brown e63b8c3302 [librm] Add missing __asmcall on init_idt()
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 14:52:25 +00:00
Michael Brown 22bb29eabc [prefix] Add a generic raw image prefix
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 13:53:26 +00:00
Michael Brown 8446a439b3 [initrd] Allow for zero-length initrd files
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-18 01:49:23 +00:00
Michael Brown 4039b54ba3 [cloud] Do not enable serial console on EFI platforms
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 22:38:38 +00:00
Michael Brown cd3de55ea5 [efi] Record cached DHCPACK from loaded image's device handle, if present
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 18:11:43 +00:00
Michael Brown d562339fca [efi] Defer autoboot link-layer address and autoexec script probing
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 17:14:19 +00:00
Michael Brown e39cd79a00 [efi] Split out autoexec script portions of efi_autoboot.c
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 17:14:19 +00:00
Michael Brown 057674bb1f [pxe] Split out platform-independent portions of cachedhcp.c
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-17 15:59:52 +00:00
Bruce Rogers 19d0fab40f [ath5k] Add missing AR5K_EEPROM_READ in ath5k_eeprom_read_turbo_modes
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 23:35:24 +00:00
Michael Brown fa012dd020 [cloud] Enable IPv6 and HTTPS in cloud boot images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-16 10:58:42 +00:00
Michael Brown d16535aa4f [cloud] Add utility for importing images to AWS EC2
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-16 00:27:40 +00:00
Michael Brown 1b99ba2a93 [build] Work around stray sections introduced by some binutils versions
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-15 10:02:32 +00:00
Michael Brown 83516ba7f0 [cloud] Use PCIAPI_DIRECT for cloud images
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 19:41:03 +00:00
Michael Brown 0049243367 [ena] Switch to two-phase reset mechanism
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-13 19:08:45 +00:00
Michael Brown c160fb2593 [build] Use .balign directive instead of .align
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 23:22:54 +00:00
Michael Brown b539e9a7e9 [build] Remove support for building with the Intel C compiler
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>
2021-02-12 22:08:41 +00:00
Michael Brown df16df2c85 [build] Report detailed errors when unable to find a usable mkisofs
As of commit 7c3d186 ("[build] Check that mkisofs equivalent supports
the required options"), we may refuse to use a mkisofs equivalent if
it does not support the options required to produce the requested
output file.

This can result in confusing error messages since the user is unaware
of the reason for which the installed mkisofs or genisoimage has been
rejected.

Fix by explicitly reporting the reason why each possible mkisofs
equivalent could not be used.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-12 12:16:48 +00:00
Michael Brown d79f504c0c [ci] Disable redundant scheduled execution of Coverity Scan
The scheduled Coverity Scan run is triggered by an external mechanism
that synchronises the coverity_scan branch with the master branch.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-05 11:59:27 +00:00
Michael Brown 831f17f66f [ci] Disable Travis CI
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-04 16:41:56 +00:00
Michael Brown 1259580dde [ci] Add GitHub action for Coverity Scan
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-04 16:41:55 +00:00
Michael Brown eeca29a1e0 [ci] Add GitHub action for build testing
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-04 16:41:55 +00:00
Michael Brown e8393c3728 [build] Work around distros that use -fcf-protection=full by default
Some patched versions of gcc (observed with gcc 9.3.0 on Ubuntu 20.04)
enable -fcf-protection=full by default.  This breaks code that is not
explicitly written to expect the use of this flag.  The breakage
occurs only at runtime if the affected code (such as setjmp()) happens
to execute, and is therefore a particularly pernicious class of bug to
be introduced into working code by a broken compiler.

Work around these broken patched versions of gcc by detecting support
for -fcf-protection and explicitly setting -fcf-protection=none if
found.

If any Ubuntu maintainers are listening: PLEASE STOP DOING THIS.  It's
extremely unhelpful to have to keep working around breakages that you
introduce by modifying the compiler's default behaviour.  Do what Red
Hat does instead: set your preferred CFLAGS within the package build
system rather than by patching the compiler to behave in violation of
its own documentation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-04 11:24:05 +00:00
Michael Brown e80299c56b [build] Work around -fPIE patched versions of gcc on all architectures
Several distributions include versions of gcc that are patched to
create position-independent executables by default.  These have caused
multiple problems over the years: see e.g. commits fe61f6d ("[build]
Fix compilation when gcc is patched to default to -fPIE -Wl,-pie"),
5de1346 ("[build] Apply the "-fno-PIE -nopie" workaround only to i386
builds"), 7c395b0 ("[build] Use -no-pie on newer versions of gcc"),
and decee20 ("[build] Disable position-independent code for ARM64 EFI
builds").

The build system currently attempts to work around these mildly broken
patched versions of gcc for the i386 and arm64 architectures.  This
misses the relatively obscure bin-x86_64-pcbios build platform, which
turns out to also require the same workaround.

Attempt to preempt the next such required workaround by moving the
existing i386 version to apply to all platforms and all architectures,
unless -fpie has been requested explicitly by another Makefile (as is
done by arch/x86_64/Makefile.efi).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-04 02:53:25 +00:00
Michael Brown bfb72ec234 [build] Avoid spurious "make clean" when building for the first time
The function trace recorder build logic defaults to making "clean" a
dependency of the first build in a clean checkout.  This is redundant
and causes problems if the build process spins up multiple make
invocations to handle multiple build architectures.

Fix by replacing with logic based on the known-working patterns used
for the ASSERT and PROFILE build parameters.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-04 02:53:25 +00:00
Michael Brown 885c6d6e98 [efi] Fix erroneous comparison of a pointer against userptr_t
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-03 16:00:06 +00:00
Michael Brown 5bdb75c9d0 [contrib] Update bochsrc.txt to work with current versions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-02 00:01:41 +00:00
Christian Iversen 1af0fe04f8 [hermon] Add support for ConnectX-3 based cards
After a ton of tedious work, I am pleased to finally introduce full
support for ConnectX-3 cards in iPXE!

The work has been done by finding all publicly available versions of
the Mellanox Flexboot sources, cleaning them up, synthesizing a git
history from them, cleaning out non-significant changes, and
correlating with the iPXE upstream git history.

After this, a proof-of-concept diff was produced, that allowed iPXE to
be compiled with rudimentary ConnectX-3 support. This diff was over
10k lines, and contained many changes that were not part of the core
driver.

Special thanks to Michael Brown <mcb30@ipxe.org> for answering my
barrage of questions, and helping brainstorm the development along the
way.

Signed-off-by: Christian Iversen <ci@iversenit.dk>
2021-02-02 00:37:43 +01:00
Michael Brown 0c94659a8a [autoboot] Avoid closing and immediately reopening network device
Some network devices can take a substantial time to close and reopen.
Avoid closing the device from which we are about to attempt booting,
in case it happens to be already open.

Suggested-by: Christian Iversen <ci@iversenit.dk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-01 23:33:50 +00:00
Michael Brown 6f1cb791ee [hermon] Avoid parsing length field on completion errors
The CQE length field will not be valid for a completion in error.
Avoid parsing the length field and just call the completion handler
directly.

In debug builds, also dump the queue pair context to allow for
inspection of the error.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-01 23:08:49 +00:00
Michael Brown 8747241b3e [hermon] Make hermon_dump_xxx() functions no-ops on non-debug builds
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-01 23:00:05 +00:00
Michael Brown 410566cef7 [hermon] Minimise reset time
Check for reset completion by waiting for the device to respond to PCI
configuration cycles, as documented in the Programmer's Reference
Manual.  On the original ConnectX HCA, this reduces the time spent on
reset from 1000ms down to 1ms.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-01 22:29:30 +00:00
Christian Iversen 7b2b35981f [hermon] Throttle debug output when sensing port type
When auto-detecting the initial port type, the Hermon driver will spam
the debug output without hesitation.  Add a short delay in each
iteration to fix this.

Signed-off-by: Christian Iversen <ci@iversenit.dk>
2021-02-01 12:35:22 +00:00
Christian Iversen 299c671f57 [hermon] Add a debug notice when initialization is complete
Signed-off-by: Christian Iversen <ci@iversenit.dk>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-01 12:30:25 +00:00
Christian Iversen 8b07c88df8 [hermon] Add support for port management event
Inspired by Flexboot, the function hermon_event_port_mgmnt_change() is
added to handle the HERMON_EV_PORT_MGMNT_CHANGE event type, which
updates the Infiniband subsystem.

Signed-off-by: Christian Iversen <ci@iversenit.dk>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-01 11:44:54 +00:00
Christian Iversen d948ac6c61 [hermon] Adjust Ethernet work queue size
Hermon Ethernet work queues have more RX than TX entries, unlike most
other drivers.  This is possibly the source of some stochastic
deadlocks previously experienced with this driver.

Update the sizes to be in line with other drivers, and make them
slightly larger for better performance.  These new queue sizes have
been found to work well with ConnectX-3 hardware.

Signed-off-by: Christian Iversen <ci@iversenit.dk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-01 11:12:26 +00:00
Michael Brown e62c3e3513 [hermon] Use reset value suitable for ConnectX-3
The programming documentation states that the reset magic value is
"0x00000001 (Big Endian)", and the current code matches this by using
the value 0x01000000 for the implicitly little-endian writel().

Inspection of the FlexBoot source code reveals an exciting variety of
reset values, some suggestive of confusion around endianness.

Experimentation suggests that the value 0x01000001 works reliably
across a wide range of hardware.

Debugged-by: Christian Iversen <ci@iversenit.dk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-01 01:53:15 +00:00
Christian Iversen 2e3d5909ee [hermon] Clean up whitespace in hermon.c
Signed-off-by: Christian Iversen <ci@iversenit.dk>
2021-02-01 01:48:29 +00:00
Christian Iversen 79031fee21 [iscsi] Update link to iBFT reference manual
Signed-off-by: Christian Iversen <ci@iversenit.dk>
2021-02-01 01:27:08 +01:00
Michael Brown def46cf344 [hermon] Limit link poll frequency in DOWN state
Some older versions of the hardware (and/or firmware) do not report an
event when an Infiniband link reaches the INIT state.  The driver
works around this missing event by calling ib_smc_update() on each
event queue poll while the link is in the DOWN state.

Commit 6cb12ee ("[hermon] Increase polling rate for command
completions") addressed this by speeding up the time taken to issue
each command invoked by ib_smc_update().  Experimentation shows that
the impact is still significant: for example, in a situation where an
unplugged port is opened, the throughput on the other port can be
reduced by over 99%.

Fix by throttling the rate at which link polling is attempted.

Debugged-by: Christian Iversen <ci@iversenit.dk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-31 23:29:45 +00:00
Michael Brown ba20ba4273 [build] Avoid using awk to format build ID as hexadecimal
The version of awk used in FreeBSD seems to be incapable of formatting
unsigned 32-bit integers above 0x80000000 and will silently render any
such value as 0x80000000.  For example:

  echo 3735928559 | awk '{printf "0x%08x", $1}'

will produce 0x80000000 instead of the correct 0xdeadbeef.

This results in an approximately 50% chance of a build ID collision
when building on FreeBSD.

Work around this problem by passing the decimal value directly in the
ld --defsym argument value.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-31 00:41:34 +00:00
Michael Brown 3a2411b43f [build] Avoid using sha1sum when calculating build ID
The sha1sum command may not be available on all systems.  Use the
POSIX-confirming cksum instead.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-31 00:30:10 +00:00
Michael Brown 82dbca4938 [build] Allow BIOS linker script to be used with FreeBSD linker
Add a few more ABSOLUTE() expressions to convince the FreeBSD linker
that already-absolute symbols are, in fact, absolute.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-30 18:37:01 +00:00
Michael Brown 1fea8ce06a [build] Check for broken elftoolchain version of objcopy
The elftoolchain version of objcopy (as used in FreeBSD) seems to be
unusable for generating a raw binary file, since it will apparently
ignore the load memory addresses specified for each section in the
input file.

The binutils version of objcopy may be used on FreeBSD by specifying

  OBJCOPY=/usr/local/bin/objcopy

Detect an attempt to use the unusable elftoolchain version of objcopy
and report it as an error.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-30 18:37:01 +00:00
Michael Brown fe52f8e8be [build] Avoid modifying load addresses when stripping .zinfo section
Some versions of objcopy will spuriously complain when asked to
extract the .zinfo section since doing so will nominally alter the
load addresses of the (non-loadable) .bss.* sections.

Avoid these warnings by placing the .zinfo section at the very end of
the load memory address space.

Allocate non-overlapping load memory addresses for the (non-loadable)
.bss.* sections, in the hope of avoiding spurious warnings about
overlapping load addresses.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-30 18:37:01 +00:00
Manuel Mendez d8dc06fbf9 [build] Replace random build ID with a deterministic one
Calculate the build ID as a checksum over the input files.  Since the
input files include $(BIN)/version.%.o which itself includes the build
target name (from which TGT_LD_FLAGS is calculated), this should be
sufficient to meet the requirement that the build ID be unique for
each $(BIN)/%.tmp even within the same build run.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-30 18:21:59 +00:00
Manuel Mendez bc4979e2cf [build] Use $(shell ...) to invoke BUILD_ID_CMD
When using $(shell), make will first invoke BUILD_ID_CMD and then have
the value defined when calling $(LD).  This means we get to see the
_build_id when building with make V=1.  Previously the build_id was
figured out as a subshell command run during the recipe execution
without being able to see the build_id itself.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-30 18:06:34 +00:00
Manuel Mendez 9d000c9fd7 [build] Use SOURCE_DATE_EPOCH if it exists
See https://reproducible-builds.org/docs/source-date-epoch/ for
rationale.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-30 17:55:34 +00:00
Michael Brown 6c91eebd0a [build] Use recursive deletion for "make clean"
Directories may be left behind by failed filesystem image builds, and
will not currently be successfully removed by a "make clean".

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-30 17:37:09 +00:00
Michael Brown 5e260c73f1 [build] Avoid shell brace expansion in "make clean"
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-30 17:34:49 +00:00
Michael Brown f034ae59f6 [build] Allow elf2efi.c to build on FreeBSD
The elf.h on FreeBSD defines ELF_R_TYPE and ELF_R_SYM (based on the
host platform) and omits some but not all of the AArch64 relocation
types.

Fix by undefining ELF_R_TYPE and ELF_R_SYM in favour of our own
definitions, and by placing each potentially missing relocation type
within an individual #ifdef guard.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-01-30 00:11:33 +00:00