Commit Graph

5843 Commits (8f1514a00450119b04b08642c55aa674bdf5a4ef)

Author SHA1 Message Date
Michael Brown 447e5cd447 [crypto] Use x509_name() in validator debug messages
Display a human-readable certificate name in validator debug messages
wherever possible.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-03-07 13:47:30 +00:00
Michael Brown eaba1a22b8 [tls] Support stateless session resumption
Add support for RFC5077 session ticket extensions to allow for
stateless TLS session resumption.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-03-06 15:11:18 +00:00
Michael Brown 799781f168 [tls] Fix incorrectly duplicated error number
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-03-06 15:11:18 +00:00
Michael Brown 272fe32529 [tls] Support stateful session resumption
Record the session ID (if any) provided by the server and attempt to
reuse it for any concurrent connections to the same server.

If multiple connections are initiated concurrently (e.g. when using
PeerDist) then defer sending the ClientHello for all but the first
connection, to allow time for the first connection to potentially
obtain a session ID (and thereby speed up the negotiation for all
remaining connections).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-02-21 11:32:25 +00:00
Michael Brown 64b4452bca [efi] Blacklist the Dell Ip4ConfigDxe driver
On a Dell OptiPlex 7010, calling DisconnectController() on the LOM
device handle will lock up the system.  Debugging shows that execution
is trapped in an infinite loop that is somehow trying to reconnect
drivers (without going via ConnectController()).

The problem can be reproduced in the UEFI shell with no iPXE code
present, by using the "disconnect" command.  Experimentation shows
that the only fix is to unload (rather than just disconnect) the
"Ip4ConfigDxe" driver.

Add the concept of a blacklist of UEFI drivers that will be
automatically unloaded when iPXE runs as an application, and add the
Dell Ip4ConfigDxe driver to this blacklist.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-02-19 19:02:11 +00:00
Michael Brown 36a4c85f91 [init] Show startup and shutdown function names in debug messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-01-25 14:53:43 +00:00
Petr Borsodi de4565cbe7 [util] Add support for EFI ROM images
The Option::ROM module recognizes and checks EFI header of image.  The
disrom.pl utility dumps this header if is present.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-01-21 11:58:02 +00:00
Petr Borsodi 3f4c179a14 [util] Improve processing of ROM images in Option::ROM
The Option::ROM module now compares the Code Type in the PCIR header
to 0x00 (PC-AT) in order to check the presence of other header types
(PnP, UNDI, iPXE, etc).  The validity of these headers are checked not
only by offset, but by range and signature checks also.  The image
checksum and initial size also depends on Code Type.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-01-21 11:56:35 +00:00
Michael Brown 956f6a7227 [zbin] Fix compiler warning with GCC 9
GCC 9 warns that abs() may truncate its signed long argument.  Fix by
using labs() instead.

Reported-by: Martin Liška <mliska@suse.cz>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-01-21 11:17:04 +00:00
Aaron Young 3946aa9bac [libc] Fix strcmp()/strncmp() to return proper values
Fix strcmp() and strncmp() to return proper standard positive/negative
values for unequal strings.  Current implementation is backwards
(i.e. the functions are returning negative when should be positive and
vice-versa).

Currently all consumers of these functions only check the return value
for ==0 or !=0 and so we can safely change the implementation without
breaking things.

Signed-off-by: Aaron Young <Aaron.Young@oracle.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-01-15 14:12:27 +00:00
Ignat Korchagin e226fecd1b [efi] Fix error handling path in efi_snp_probe
Current (simplified):

1. InstallMultipleProtocolInterfaces
       if err goto err_install_protocol_interface;
2. OpenProtocol(efi_nii_protocol_guid)
       if err goto err_open_nii;
3. OpenProtocol(efi_nii31_protocol_guid)
       if err goto err_open_nii31;
4. efi_child_add
       if err goto err_efi_child_add;
...
err_efi_child_add:
   CloseProtocol(efi_nii_protocol_guid) <= should be efi_nii31_protocol_guid
err_open_nii: <= should be err_open_nii31
   CloseProtocol(efi_nii31_protocol_guid) <= should be efi_nii_protocol_guid
err_open_nii31: <= should be err_open_nii
   UninstallMultipleProtocolInterfaces

Signed-off-by: Ignat Korchagin <ignat@cloudflare.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-01-15 14:01:17 +00:00
Petr Borsodi ba0d5aa993 [pci] Correct invalid base-class/sub-class/prog-if order in PCIR
PCI Configuration Space contains fields prog-if at the offset 0x09,
sub-class at the offset 0x0a and base-class at the offset 0x0b (it
respects little endian).  PCIR structure uses these fields in the same
order.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-01-15 13:08:44 +00:00
Christian Hesse 133f4c47ba [build] Handle R_X86_64_PLT32 from binutils 2.31
Starting from binutils 2.31.0 (commit bd7ab16b) x86-64 assembler
generates R_X86_64_PLT32 instead of R_X86_64_PC32.

Acked-by: John Jolly <jjolly@suse.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-09-17 12:24:18 +01:00
Martin Habets af1860711a [sfc] Add support for X25xx adapters
The first adapters in this family are X2522-10, X2522-25, X2541 and
X2542.

These no longer use PCI BAR 0 for I/O, but use that for memory.  In
other words, BAR 2 on SFN8xxx adapters now becomes BAR 0.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-08-26 22:02:23 +01:00
Michael Brown d2063b7693 [intelxl] Add driver for Intel 40 Gigabit Ethernet NICs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-07-17 12:14:43 +01:00
Michael Brown b9d68b9de0 [ethernet] Use standard 1500 byte MTU unless explicitly overridden
Devices that support jumbo frames will currently default to the
largest possible MTU.  This assumption is valid for virtual adapters
such as virtio-net, where the MTU must have been configured by a
system administrator, but is unsafe in the general case of a physical
adapter.

Default to the standard Ethernet MTU, unless explicitly overridden
either by the driver or via the ${netX/mtu} setting.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-07-17 12:14:43 +01:00
Michael Brown 05b979146d [rndis] Clean up error handling path in register_rndis()
Avoid calling rndis_halt() and rndis->op->close() twice if the call to
register_netdev() fails.

Reported-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-07-09 10:35:57 +01:00
Michael Brown 1c47eb186e [build] Use positive-form tests when checking for supported warnings
Some versions of gcc seem to silently accept an attempt to disable an
unrecognised warning (e.g. via -Wno-stringop-truncation) but will then
report the unrecognised warning if any other error occurs during the
build, resulting in a potentially misleading error message.

Avoid this potential confusion by using the positive-form tests in
order to determine the workaround CFLAGS.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-07-08 18:17:18 +01:00
Roman Kagan 40956545e2 [vmbus] Do not expect version in version_response
The definition of version_response channel message in Linux doesn't
include version field, so the upcoming VMBus implementation in QEMU
doesn't set it either.  Neither Windows nor Linux had any problem with
this.

The check against this field is redundant because the message is the
response to initiate_contact message containing the specific version
requested, so the response with version_supported=true is unambiguous.

Drop this check and don't rely on the field to be present in the
message.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-07-08 00:45:47 +01:00
Roman Kagan 16d7495308 [rndis] Register netdev with MAC filled
register_netdev expects ->hw_addr and ->ll_addr to be already filled,
so move it towards the end of register_rndis, after the respective
fields have been successfully queried from the underlying device.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-07-07 20:19:14 +01:00
Rob Taglang 88ac1d3fe4 [efi] Exclude link-layer header length from MaxPacketSize
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-07-07 20:12:10 +01:00
Steven Haber 97a3d37285 [intelx] Add support for Intel X552 NIC
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-07-07 20:05:25 +01:00
Bruce Rogers 8ed4e3049f [build] Disable gcc stringop-truncation warnings
The gcc 8 compiler introduces a warning for certain string
manipulation functions, flagging usages which _may_ not be intended.
An audit of the iPXE sources indicates all usages of strncat and
strncpy are as intended, so the warnings currently issued are not
helpful, especially if warnings are considered errors.

Fix by detecting gcc's support for -Wno-stringop-truncation and, if
detected, using that option to avoid the warning.

Signed-off-by: Bruce Rogers <brogers@suse.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Also-fixed-by: Christian Hesse <list@eworm.de>
Also-fixed-by: Roman Kagan <rkagan@virtuozzo.com>
Also-fixed-by: Bernhard M. Wiedemann <bwiedemann@suse.de>
Also-fixed-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-07-07 19:46:16 +01:00
Michael Brown e7f67d5a4c [http] Work around stateful authentication schemes
As pointedly documented in RFC7230 section 2.3, HTTP is a stateless
protocol: each request message can be understood in isolation from any
other requests or responses.  Various authentication schemes such as
NTLM break this fundamental property of HTTP and rely on the same TCP
connection being reused.

Work around these broken authentication schemes by ensuring that the
most recently pooled connection is reused for the subsequent
authentication retry.

Reported-by: Andreas Hammarskjöld <junior@2PintSoftware.com>
Tested-by: Andreas Hammarskjöld <junior@2PintSoftware.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-06-08 13:53:02 +01:00
Sylvie Barlow 960d1e36b0 [icplus] Add driver for IC+ network card
Signed-off-by: Sylvie Barlow <sylvie.c.barlow@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-04-20 15:26:09 +01:00
Sylvie Barlow c239f0bff2 [mii] Add bit-bashing interface
Signed-off-by: Sylvie Barlow <sylvie.c.barlow@gmail.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-04-20 15:24:33 +01:00
Sylvie Barlow 7ed1dc98c3 [mii] Add mii_find()
Add the function mii_find() in order to locate the PHY address.

Signed-off-by: Sylvie Barlow <sylvie.c.barlow@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-04-20 15:21:32 +01:00
Michael Brown 6047b7ca7a [mii] Fix typo in parameter name
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-04-20 13:25:46 +01:00
Michael Brown e901e6b73b [tcp] Add missing packed attribute on struct tcp_header
Debugged-by: Mark Rutland <mark.rutland@arm.com>
Debugged-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-04-19 19:05:37 +01:00
Michael Brown 6804a8c89b [mii] Separate concepts of MII interface and MII device
We currently have no generic concept of a PHY address, since all
existing implementations simply hardcode the PHY address within the
MII access methods.

A bit-bashing MII interface will need to be provided with an explicit
PHY address in order to generate the correct waveform.  Allow for this
by separating out the concept of a MII device (i.e. a specific PHY
address attached to a particular MII interface).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-04-19 12:43:06 +01:00
Michael Brown 285e3e5287 [velocity] Fix usage of mii_read() and mii_write()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-04-19 12:36:16 +01:00
Michael Brown f71ba143c7 [rhine] Fix usage of mii_read()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-04-19 12:34:08 +01:00
Michael Brown d6f02c72c9 [undi] Include subsystem IDs in broken interrupt device check
Allow the subsystem IDs to be used when checking for PXE stacks with
broken interrupt support.

Suggested-by: Levi Hsieh <Levi.Hsieh@dell.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-04-18 16:57:05 +01:00
Rob Taglang 2eef77ecc0 [intelx] Add PCI_ROM entry for Intel X553 NIC
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-04-10 17:38:17 +01:00
Heinrich Schuchardt 8c17ee115d [efi] Add support for R_ARM_REL32 relocations
The relocation type R_ARM_REL32 is generated when building
bin-arm32-efi/snp.efi using gcc 6.3 and ld 2.28.

R_ARM_REL32 is a program counter (PC) relative 32 bit relocation so we
can ignore it like all other PC relative relocations.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-28 17:55:58 +01:00
Michael Brown 4f362a032b [efi] Do not raise TPL within EFI_DRIVER_BINDING_PROTOCOL.Supported()
When booting some versions of the UEFI shell, our driver binding
protocol's Supported() entry point is called at TPL_NOTIFY for no
discernible reason.  Attempting to raise to TPL_CALLBACK triggers an
immediate assertion failure in the firmware.

Since our Supported() method can run at any TPL, fix by simply not
attempting to raise the TPL within this method.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-26 12:10:09 +01:00
Michael Brown 331ac451e7 [efi] Release SNP devices before starting SAN boot image
Release SNP devices to allow the SAN booted image to use our
EFI_SIMPLE_NETWORK_PROTOCOL instance, and to ensure that the image is
started at TPL_APPLICATION.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-26 11:31:41 +01:00
Michael Brown baaf50017d [tls] Ensure that window change is propagated to plainstream interface
The cipherstream xfer_window_changed() message is used to retrigger
the TLS transmit state machine.  If the transmit state machine is
idle, then the window change message will not be propagated to the
plainstream interface.  This can potentially cause the plainstream
interface peer (e.g. httpcore) to block waiting for a window change
message that will never arrive.

Fix by ensuring that the window change message is propagated to the
plainstream interface if the transmit state machine is idle.  (If the
transmit state machine is not idle then the plainstream window will be
zero anyway.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-24 21:51:07 +00:00
Michael Brown 4152aff103 [tls] Rename tls_session to tls_connection
In TLS terminology a session conceptually spans multiple individual
connections, and essentially represents the stored cryptographic state
(master secret and cipher suite) required to establish communication
without going through the certificate and key exchange handshakes.

Rename tls_session to tls_connection in order to make the name
tls_session available to represent the session state.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-24 21:37:17 +00:00
Michael Brown 6be010d919 [list] Add list_is_first_entry() and list_is_last_entry()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-24 21:32:06 +00:00
Michael Brown ac4fbd47ae [tls] Ensure received data list is initialised before calling tls_free()
A failure in tls_generate_random() will result in a call to ref_put()
before the received data list has been initialised, which will cause
free_tls() to attempt to traverse an uninitialised list.

Fix by ensuring that all fields referenced by free_tls() are
initialised before any of the potential failure paths.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-23 11:07:29 +00:00
Robin Smidsrød eda9f4db61 [util] Support reversed sort ordering when generating NIC list
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-21 17:09:25 +02:00
Michael Brown bc85368cdd [librm] Ensure that inline code symbols are unique
Commit 6149e0a ("[librm] Provide symbols for inline code placed into
other sections") may cause build failures due to duplicate label names
if the compiler chooses to duplicate inline assembly code.

Fix by using the "%=" special format string to include a
guaranteed-unique number within the label name.

The "%=" will be expanded only if constraints exist for the inline
assembly.  This fix therefore requires that all REAL_CODE() fragments
use a (possibly empty) constraint list.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-21 17:00:53 +02:00
Michael Brown 6149e0af3c [librm] Provide symbols for inline code placed into other sections
Provide symbols constructed from the object name and line number for
code fragments placed into alternative sections, such as inline
REAL_CODE() assembly placed into .text16.  This simplifies the
debugging task of finding the source code corresponding to a given
instruction pointer.

Note that we cannot use __FUNCTION__ since it is not a preprocessor
macro and so cannot be concatenated with string literals.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-21 14:44:04 +02:00
Michael Brown 0600ffeb30 [undi] Treat invalid IRQ numbers as non-fatal errors
If the underlying PXE stack reports an invalid IRQ number (above
IRQ_MAX), treat this as equivalent to an empty IRQ number and fall
back to using polling mode.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-21 10:28:05 +02:00
Michael Brown 1df3b53051 [build] Prevent use of MMX and SSE registers
The existence of MMX and SSE is required by the System V x86_64 ABI
and so is assumed by gcc, but these registers are not preserved by our
own interrupt handlers and are unlikely to be preserved by other
context switch handlers in a boot firmware environment.

Explicitly prevent gcc from using MMX or SSE registers to avoid
potential problems due to silent register corruption.

We must remove the %xmm0-%xmm5 clobbers from the x86_64 version of
hv_call() since otherwise gcc will complain about unknown register
names.  Theoretically, we should probably add code to explicitly
preserve the %xmm0-%xmm5 registers across a hypercall, in order to
guarantee to external code that these registers remain unchanged.  In
practice this is difficult since SSE registers are disabled by
default: for background information see commits 71560d1 ("[librm]
Preserve FPU, MMX and SSE state across calls to virt_call()") and
dd9a14d ("[librm] Conditionalize the workaround for the Tivoli VMM's
SSE garbling").

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-20 22:01:08 +02:00
Michael Brown 0d35411f88 [rng] Use fixed-point calculations for min-entropy quantities
We currently perform various min-entropy calculations using build-time
floating-point arithmetic.  No floating-point code ends up in the
final binary, since the results are eventually converted to integers
and asserted to be compile-time constants.

Though this mechanism is undoubtedly cute, it inhibits us from using
"-mno-sse" to prevent the use of SSE registers by the compiler.

Fix by using fixed-point arithmetic instead.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-20 20:56:01 +02:00
Ameer Mahagneh d5d4bf8870 [golan] Set log_max_qp to 1
This is required to work around a bug in some firmware versions.

Signed-off-by: Ameer Mahagneh <ameerm@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-20 17:55:04 +02:00
Michael Brown 3ec2079ce2 [time] Add support for the ACPI power management timer
Allow the ACPI power management timer to be used if enabled via
TIMER_ACPI in config/timer.h.  This provides an alternative timer on
systems where the standard 8254 PIT is unavailable or unreliable.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-20 17:26:49 +02:00
Michael Brown e8e9ca3613 [efi] Provide Map_Mem() and associated UNDI callbacks
Some drivers are known to call the optional Map_Mem() callback without
first checking that the callback exists.  Provide a usable basic
implementation of Map_Mem() along with the other callbacks that become
mandatory if Map_Mem() is provided.

Note that in theory the PCI I/O protocol is allowed to require
multiple calls to Map(), with each call handling only a subset of the
overall mapped range.  However, the reference implementation in EDK2
assumes that a single Map() will always suffice, so we can probably
make the same simplifying assumption here.

Tested with the Intel E3522X2.EFI driver (which, incidentally, fails
to cleanly remove one of its mappings).

Originally-implemented-by: Maor Dickman <maord@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-20 13:31:45 +02:00
Michael Brown 342ff967cc [lacp] Check the partner's own state when checking for blocked links
The blocked link test in eth_slow_lacp_rx() is performed before the
actor TLV is copied to the partner TLV, and so must test the actor
state field rather than the partner state field.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-19 15:47:39 +02:00
Michael Brown 9759860ec0 [ocsp] Allow OCSP checks to be disabled
Some CAs provide non-functional OCSP servers, and some clients are
forced to operate on networks without access to the OCSP servers.
Allow the user to explicitly disable the use of OCSP checks by
undefining OCSP_CHECK in config/crypto.h.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-18 22:30:21 +02:00
Michael Brown a0021a30dd [ocsp] Centralise test for whether or not an OCSP check is required
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-18 22:25:01 +02:00
Michael Brown ae93064496 [profile] Prevent potential division by zero
Limit the profile sample count to INT_MAX to avoid both signed
overflow and a potential division by zero when updating the stored
mean value.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-18 18:39:39 +02:00
Michael Brown b11ae1d91b [tftp] Prevent potential division by zero
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-18 17:43:11 +02:00
Michael Brown c160c9dfc0 [lacp] Fix debug message to match documentation
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-18 17:20:04 +02:00
Michael Brown 33d79d5d2b [lacp] Mark link as blocked if partner is not yet up and running
Mark the link as blocked if the LACP partner is not reporting itself
as being in sync, collecting, and distributing.

This matches the behaviour for STP: we mark the link as blocked if we
detect that the switch is actively blocking traffic, in order to
extend the DHCP discovery period and so prevent boot failures on
switches that take an excessively long time to enable ports.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-18 17:16:35 +02:00
Michael Brown 0778418e29 [golan] Do not assume all devices are identical
Remove the global variable shomron_nodnic_supported, since it may have
different values for different PCI devices.

Originally-fixed-by: Mohammed Taha <mohammedt@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-18 15:41:21 +02:00
Michael Brown 89e31f8491 [librm] Add facility to provide register and stack dump for CPU exceptions
When DEBUG=librm_mgmt is enabled, intercept CPU exceptions and provide
a register and stack dump, then drop to an emergency shell.  Exiting
from the shell will almost certainly not work, but this provides an
opportunity to view the register and stack dump and carry out some
basic debugging.

Note that we can intercept only the first 8 CPU exceptions, since a
PXE ROM is not permitted to rebase the PIC.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-18 14:59:34 +02:00
Rob Taglang 0c43bb934a [intel] Add PCI_ROM entry for Intel i354 NIC
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-15 00:04:33 +00:00
Michael Brown 10d083ffa9 [efi] Raise TPL within EFI_DRIVER_BINDING_PROTOCOL entry points
Debugged-by: Rob Taglang <rob@privatemachines.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-14 23:55:28 +00:00
Michael Brown d8c500b794 [efi] Drop to TPL_APPLICATION when gathering entropy
Commit c89a446 ("[efi] Run at TPL_CALLBACK to protect against UEFI
timers") introduced a regression in the EFI entropy gathering code.
When the EFI_RNG_PROTOCOL is not present, we fall back to using timer
interrupts (as for the BIOS build).  Since timer interrupts are
disabled at TPL_CALLBACK, WaitForEvent() fails and no entropy can be
gathered.

Fix by dropping to TPL_APPLICATION while entropy gathering is enabled.

Reported-by: Andreas Hammarskjöld <junior@2PintSoftware.com>
Tested-by: Andreas Hammarskjöld <junior@2PintSoftware.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-12 11:02:19 +00:00
Hannes Reinecke c84f9d6727 [iscsi] Parse IPv6 address in root path
The iSCSI root path may contain a literal IPv6 address.  Update the
parser to handle this address format correctly.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-03-01 13:30:41 +00:00
Michael Brown 47849be3a9 [process] Include process name in debug messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-02-20 18:02:25 +00:00
Michael Brown f672a27b34 [efi] Raise TPL within EFI_USB_IO_PROTOCOL entry points
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-02-20 11:19:39 +00:00
Michael Brown a272b7ce57 [efi] Raise TPL within EFI_SIMPLE_NETWORK_PROTOCOL entry points
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-02-20 11:19:21 +00:00
Michael Brown c89a446cf0 [efi] Run at TPL_CALLBACK to protect against UEFI timers
As noted in the comments, UEFI manages to combines the all of the
worst aspects of both a polling design (inefficiency and inability to
sleep until something interesting happens) and of an interrupt-driven
design (the complexity of code that could be preempted at any time,
thanks to UEFI timers).

This causes problems in particular for UEFI USB keyboards: the
keyboard driver calls UsbAsyncInterruptTransfer() to set up a periodic
timer which is used to poll the USB bus.  This poll may interrupt a
critical section within iPXE, typically resulting in list corruption
and either a hang or reboot.

Work around this problem by mirroring the BIOS design, in which we run
with interrupts disabled almost all of the time.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-02-20 10:56:31 +00:00
Michael Brown 8dbb73a779 [xhci] Consume event TRB before reporting completion to USB core
Reporting a completion via usb_complete() will pass control outside
the scope of xhci.c, and could potentially result in a further call to
xhci_event_poll() before returning from usb_complete().  Since we
currently update the event consumer counter only after calling
usb_complete(), this can result in duplicate completions and
consequent corruption of the submission TRB ring structures.

Fix by updating the event ring consumer counter before passing control
to usb_complete().

Reported-by: Andreas Hammarskjöld <junior@2PintSoftware.com>
Tested-by: Andreas Hammarskjöld <junior@2PintSoftware.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-02-19 18:59:45 +00:00
Michael Brown 6737a8795f [http] Allow for domain names within NTLM user names
Allow a NetBIOS domain name to be specified within a URL using a
syntax such as:

  http://domain%5Cusername:password@server/path

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-02-19 11:58:28 +00:00
Michael Brown 546dd51de8 [intel] Work around broken reset mechanism in i219 devices
The i219 appears to have a seriously broken reset mechanism.  After
any transmit or receive activity, resetting the card will break both
the transmit and receive datapaths until the next PCI bus reset.

The Linux and BSD drivers include a convoluted workaround authored by
Intel which involves setting a bit in the undocumented FEXTNVM11
register, then transmitting a dummy 512-byte packet containing garbage
data, then reconfiguring the receive descriptor prefetch thresholds
and temporarily reenabling the receive datapath.  The comments in the
Intel fix do not even remotely match what the code actually does, and
the code accidentally leaves the transmitter enabled after use.

Experimentation suggests that an equivalent fix is to simply set the
undocumented bit in FEXTNVM11 before enabling the transmit or receive
descriptor rings.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-02-03 19:21:54 +00:00
Michael Brown c900751fa6 [xhci] Assume an invalid PSI table if any invalid PSI value is observed
Invalid protocol speed ID tables appear to be increasingly common in
the wild, to the point that it is infeasible to apply an explicit
XHCI_BAD_PSIV flag for each offending PCI device ID.

Fix by assuming an invalid PSI table as soon as any invalid value is
reported by the hardware.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-01-29 21:28:12 +00:00
Michael Brown fbe8c52d0d [ena] Fix spurious uninitialised variable warning on older versions of gcc
Some older versions of gcc (observed with gcc 4.7.2) report a spurious
uninitialised variable warning in ena_get_device_attributes().  Work
around this warning by manually inlining the relevant code (which has
only a single call site).

Reported-by: xbgmsharp <xbgmsharp@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-01-17 14:09:56 +00:00
Martin Habets 70189a8e47 [netdevice] Make netdev_irq_enabled() independent of netdev_irq_supported()
The UNDI layer uses the NETDEV_IRQ_ENABLED flag to choose whether to
return PXENV_UNDI_ISR_OUT_OURS or PXENV_UNDI_ISR_OUT_NOT_OURS for a
given interrupt.  For a network device that does not support
interrupts, the flag will never be set and so pxenv_undi_isr() will
always return PXENV_UNDI_ISR_OUT_NOT_OURS.  This causes some NBPs
(such as lpxelinux.0) to hang.

Redefine NETDEV_IRQ_ENABLED as a simple administrative flag which can
be set even on network devices that do not support interrupts.  This
allows pxenv_undi_isr() (which is the sole user of NETDEV_IRQ_ENABLED)
to function as expected by lpxelinux.0.

Signed-off-by: Martin Habets <mhabets@solarflare.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-01-14 21:53:29 +00:00
Joseph Wong 08db2fd55c [tg3] Add support for SerDes PHY initialization
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-01-14 21:26:36 +00:00
Michael Brown 329202691f [skel] Remove MII interface
Most drivers do not utilise an MII interface, since the link state is
typically available directly from a memory-mapped register.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-01-14 21:16:36 +00:00
Michael Brown 2fb70e8b32 [ena] Add driver for Amazon ENA virtual function NIC
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-01-12 23:46:02 +00:00
Michael Brown 2bb4ec1f54 [build] Avoid use of "ld --oformat binary"
Using "ld --oformat binary" for mbr.bin and usbdisk.bin seems to cause
segmentation faults on some versions of binutils (observed on Fedora
27).  Work around this problem by using ld to create an intermediate
ELF object, followed by objcopy (via the existing %.tmp -> %.bin rule)
to create the final binary.

Note that we cannot simply use a single-stage "objcopy -O binary"
since this will not process the relocation records for x86_64: see
commit 1afcccd ("[build] Do not use "objcopy -O binary" for objects
with relocation records").

Reported-by: Brent S <bts@square-r00t.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2018-01-02 21:26:40 +01:00
Michael Brown 00c5b958c5 [legal] Add missing FILE_LICENCE declarations
Add missing FILE_LICENCE declarations to x86_64 headers based on the
corresponding i386 headers (from which the x86_64 headers were
originally derived).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-12-29 11:57:00 +00:00
Michael Brown ff648c339d [legal] Add missing FILE_LICENCE declarations
Add missing FILE_LICENCE declarations to EFI headers based on the
corresponding source file.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-12-29 11:54:59 +00:00
Michael Brown be9ed2848d [image] Omit URI query string and fragment from download progress messages
The URIs printed as part of download progress messages are intended to
provide a quick visual progress indication to the user.  Very long
query strings can render this visual indication useless in practice,
since the most important information (generally the URI host and path)
is drowned out by multiple lines of human-illegible URI-encoded data.

Omit the query string entirely from the download progress message.
For consistency and brevity, also omit the URI fragment along with the
username and password (which was previously redacted anyway).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-12-28 13:42:44 +00:00
Michael Brown 659c484efc [http] Report unsuccessful response status lines at DBGVL_LOG
The precise HTTP response status code is currently visible only at
DBGLVL_EXTRA.  Allow for easier debugging by reporting the whole
status line at DBGLVL_LOG for any unsuccessful responses.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-12-28 13:04:59 +00:00
Michael Brown ea29122a70 [http] Include error messages for 4xx and 5xx response codes
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-12-28 12:34:07 +00:00
Michael Brown e4461f65d8 [xen] Skip probing of any unsupported device types
Xen 4.4 includes the device "device/suspend/event-channel" which does
not have a "backend" key.  This currently causes the entire XenBus
device tree probe to fail.

Fix by skipping probe attempts for device types for which there is no
iPXE driver.

Debugged-by: Eytan Heidingsfeld <eytanh@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-12-28 12:09:27 +00:00
Janos Mattyasovszky aeffcce44f [intel] Add PCI device ID for X550-T2
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-12-20 12:20:43 +00:00
Michael Brown b5e0b50723 [http] Add support for NTLM authentication
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-11-12 18:52:04 +00:00
Michael Brown 96bd872c03 [http] Handle parsing of WWW-Authenticate header within authentication scheme
Allow individual authentication schemes to parse WWW-Authenticate
headers that do not comply with RFC2617.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-11-12 18:52:04 +00:00
Michael Brown c49acbb4d2 [http] Gracefully handle offers of multiple authentication schemes
Servers may provide multiple WWW-Authenticate headers, each offering a
different authentication scheme.  We currently fail the request as
soon as we encounter an unrecognised scheme, which prevents subsequent
offers from succeeding.

Fix by silently ignoring headers for schemes that we do not recognise.
If no schemes are recognised then the request will eventually fail
anyway due to the 401 response code.

If multiple schemes are supported, arbitrarily choose the scheme
appearing first within the response headers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-11-12 18:52:03 +00:00
Michael Brown fc2f0dd930 [ntlm] Add support for NTLM authentication mechanism
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-11-12 18:52:03 +00:00
Michael Brown 0077b0933d [crypto] Add MD4 message digest algorithm
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-11-12 18:52:03 +00:00
Michael Brown 32d54691e9 [crypto] Eliminate repetitions in MD5 round constant table
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-11-12 18:52:03 +00:00
Michael Brown fb6b66ce13 [crypto] Fix endianness typo in comment
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-11-11 23:45:31 +00:00
Michael Brown 1b67a05646 [efi] Allow for building with older versions of elf.h system header
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-24 19:26:58 +01:00
Heinrich Schuchardt c4ce92599d [efi] Accept (and ignore) R_ARM_V4BX relocations
Relocation type R_ARM_V4BX requires no computation.  It marks the
location of an ARMv4 branch exchange instruction.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-24 18:03:10 +01:00
Ladi Prosek 0631a46a94 [crypto] Fail fast if cross-certificate source is empty
In fully self-contained deployments it may be desirable to build iPXE
with an empty CROSSCERT source to avoid talking to external services.

Add an explicit check for this case and make validator_start_download
fail immediately if the base URI is empty.

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-24 17:56:04 +01:00
Michael Brown 74d90b33f8 [efi] Inhibit our driver Start() method during disconnection attempts
Some HP BIOSes (observed with a Z840) seem to attempt to connect our
drivers in the middle of our call to DisconnectController().  The
precise chain of events is unclear, but the symptom is that we see
several calls to our Supported() and Start() methods, followed by a
system lock-up.

Work around this dubious BIOS behaviour by explicitly failing calls to
our Start() method while we are in the middle of attempting to
disconnect drivers.

Reported-by: Jordan Wright <jordan.m.wright@disney.com>
Debugged-by: Adrian Lucrèce Céleste <adrianlucrececeleste@airmail.cc>
Debugged-by: Christian Nilsson <nikize@gmail.com>
Tested-by: Jordan Wright <jordan.m.wright@disney.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-22 18:39:04 +01:00
Michael Brown 7428ab7258 [build] Exclude selected directories from Secure Boot builds
When submitting binaries for UEFI Secure Boot signing, certain
known-dubious subsystems (such as 802.11 and NFS) must be excluded
from the build.  Mark the directories containing these subsystems as
insecure, and allow the build target to include an explicit "security
flag" (a literal "-sb" appended to the build platform) to exclude
these source directories from the build process.

For example:

  make bin-x86_64-efi-sb/ipxe.efi

will build iPXE with all code from the 802.11 and NFS subsystems
excluded from the build.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-18 14:38:12 +01:00
Michael Brown d46c53cfc6 [efi] Continue to connect remaining handles after connection errors
Some UEFI BIOSes will deliberately break the implementation of
ConnectController() to return errors for devices that have been
"disabled" via the BIOS setup screen.  (As an added bonus, such BIOSes
may return garbage EFI_STATUS values such as 0xff.)

Work around these broken UEFI BIOSes by ignoring failures and
continuing to attempt to connect any remaining handles.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-13 10:07:55 +03:00
Peter von Konigsmark 9720f8396f [exanic] Add PCI device ID for another X40 variant
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-07 12:37:09 +01:00
Peter von Konigsmark f756fd78f7 [exanic] Power up optical PHYs (if present)
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-07 12:36:33 +01:00
Michael Brown af02a8d071 [dns] Ensure DNS names are NUL-terminated when used as diagnostic strings
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-07 12:19:35 +01:00