david/ipxe
david
/
ipxe
Archived
1
0
Fork 0
Commit Graph

62 Commits

Author SHA1 Message Date
Michael Brown e8f30571a3 [efi] Match behaviour of SnpDxe for truncated received packets
The UEFI specification does not state whether or not a return value of
EFI_BUFFER_TOO_SMALL from the SNP Receive() method should follow the
usual EFI API behaviour of allowing the caller to retry the request
with an increased buffer size.

Examination of the SnpDxe driver in EDK2 suggests that Receive() will
just return the truncated packet (complete with any requested
link-layer header fields), so match this behaviour.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-06 23:56:22 +01:00
Michael Brown 3f429bdcfe [efi] Check buffer length for packets retrieved via our SNP protocol
We do not currently check the length of the caller's buffer for
received packets.  This creates a potential buffer overrun when iPXE
is being used via the SNP or UNDI protocols.

Fix by checking the buffer length and correctly returning the required
length and an EFI_BUFFER_TOO_SMALL error.

Reported-by: Paul McMillan <paul.mcmillan@oracle.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-06 23:28:21 +01:00
Michael Brown 632e57f0f3 [efi] Do not copy garbage bytes into SNP device path MAC address
The SNP device path includes the network device's MAC address within
the MAC_ADDR_DEVICE_PATH.MacAddress field.  We check that the
link-layer address will fit within this field, and then perform the
copy using the length of the destination buffer.

At 32 bytes, the MacAddress field is actually larger than the current
maximum iPXE link-layer address.  The copy therefore overflows the
source buffer, resulting in trailing garbage bytes being appended to
the device path's MacAddress.  This is invisible in debug messages,
since the DevicePathToText protocol will render only the length
implied by the interface type.

Fix by copying only the actual length of the link-layer address (which
we have already verified will not overflow the destination buffer).

Debugged-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-06-22 09:07:20 +01:00
Michael Brown 8f0bec4346 [efi] Include VLAN in SNP device path if applicable
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-06-18 18:45:18 +01:00
Michael Brown 6847232e70 [efi] Add support for EFI_GRAPHICS_OUTPUT_PROTOCOL frame buffer consoles
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-10-16 16:38:41 +01:00
Michael Brown 300a371bfb [efi] Expose an UNDI interface alongside the existing SNP interface
UEFI UNDI is a hideously ugly lump of poorly specified garbage bolted
on as an appendix of the UEFI specification.  My personal favourite
line from the UNDI 'specification' is section E.2.2, which states
"Basically, the rule is: Do it right, or don't do it at all".  The
author appears to believe that such exhortations are a viable
substitute for documenting what it is that the wretched reader is
supposed to, in fact, do.

(Second favourite is the section listing the pros and cons of various
driver types.  This fails to identify a single con for the mythical
"Hardware UNDI", a design so insanely intrinsically slow that it
appears to have been the inspiration for the EFI_USB_IO_PROTOCOL.)

UNDI is functionally isomorphic to the substantially less preposterous
EFI_SIMPLE_NETWORK_PROTOCOL.  Provide an UNDI interface (as a thin
wrapper around the existing SNP interface) to allow for use by
third-party software that has made poor life choices.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-28 03:42:09 +01:00
Michael Brown e727f576c2 [efi] Include a copy of the device path within struct efi_device
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-13 13:08:08 +01:00
Michael Brown 7107334391 [efi] Provide efi_devpath_len()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-13 12:54:31 +01:00
Michael Brown 355da7b133 [efi] Do not return EFI_NOT_READY from our ReceiveFilters() method
Our SNP ReceiveFilters() method is a no-op, since we always (if
possible) use promiscuous mode for all network cards.  The method
currently returns EFI_NOT_READY if the SNP interfaces are claimed for
use by iPXE, as with all other SNP methods.

The WDS bootstrap wdsmgfw.efi attempts to use both the PXE Base Code
protocol and the Simple Network Protocol simultaneously.  This is
fundamentally broken, since use of the PXE Base Code protocol requires
us to disable the use of SNP (by claiming the interfaces for use by
iPXE), otherwise MnpDxe swallows all of the received packets before
our PXE Base Code's UdpRead() method is able to return them.

The root cause of this problem is that, as with BIOS PXE, the network
booting portions of the UEFI specification are less of a specification
and more of an application note sketchily describing how the original
hacked-together Intel implementation works.  No sane design would ever
have included the UdpWrite() and UdpRead() methods.

Work around these fundamental conceptual flaws by unconditionally
returning success from efi_snp_receive_filters().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-01 21:24:02 +01:00
Michael Brown 226d5f2caf [efi] Fix order of events on SNP removal path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-01 21:24:02 +01:00
Michael Brown 9869ee5125 [efi] Allow calls to efi_snp_claim() and efi_snp_release() to be nested
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-01 21:04:45 +01:00
Michael Brown 9501eaf68d [efi] Remove raw EFI_HANDLE values from debug messages
The raw EFI_HANDLE value is almost never useful to know, and simply
adds noise to the already verbose debug messages.  Improve the
legibility of debug messages by using only the name generated by
efi_handle_name().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-27 15:40:44 +01:00
Michael Brown f58ebbdfb5 [test] Allow self-tests to report exit status when running under Linux
Allow the return status from an embedded image to propagate out to the
eventual return status from main().  When running under Linux, this
allows the pass/fail result of unit tests to be observable without
having to visually inspect the console output.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-21 15:46:28 +01:00
Michael Brown c6b299df20 [efi] Hold off watchdog timer while running
UEFI platforms may provide a watchdog timer, which will reboot the
machine if an operating system takes more than five minutes to load.
This can cause long-lived iPXE downloads (or interactive shell
sessions) to unexpectedly reboot.

Fix by resetting the watchdog timer every ten seconds while the iPXE
main processing loop continues to run.

Reported-by: Bradley B Williams <bradleybwilliams@swbell.net>
Reported-by: John Clark <john.r.clark.3@gmail.com>
Reported-by: wdriever@gmail.com
Reported-by: Charlie Beima <cbeima@indiana.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-03 12:48:02 +01:00
Michael Brown a15c0d7e86 [efi] Allow user experience to be downgraded
iPXE does not currently provide EFI_PXE_BASE_CODE_PROTOCOL: this
causes failures when chainloading bootloaders such as shim.efi which
assume that this protocol will be present.

Provide the ability to work around these problems via the build
configuration option EFI_DOWNGRADE_UX.  If this option is enabled,
then we will not install our usual EFI_LOAD_FILE_PROTOCOL
implementation, thereby allowing the platform firmware to install its
own EFI_PXE_BASE_CODE_PROTOCOL implementation on top of our
EFI_SIMPLE_NETWORK_PROTOCOL handle.

A somewhat major side-effect of this workaround is that almost all
iPXE features will be disabled.

This configuration option will be removed in future when support for
EFI_PXE_BASE_CODE_PROTOCOL is added.

Requested-by: Laszlo Ersek <lersek@redhat.com>
Requested-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 20:40:01 +01:00
Michael Brown 88a5f56dc7 [efi] Fix receive and transmit completion reporting
Fix the TxBuf value filled in by GetStatus() to report the transmit
buffer address as required by the (now clarified) specification.

Simplify "interrupt" handling in GetStatus() to report only that one
or more packets have been transmitted or received; there is no need to
report one GetStatus() "interrupt" per packet.

Simplify receive handling to dequeue received packets immediately from
the network device into an internal list (thereby avoiding the hacks
previously used to determine when to report new packet arrivals).

Originally-fixed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 18:31:45 +01:00
Michael Brown 9ee89d0bf1 [efi] Centralise definitions of more protocol GUIDs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-09-25 12:29:12 +01:00
Michael Brown 2bf428c2a9 [efi] Move abstract device path and handle functions to efi_utils.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-06 14:27:45 +01:00
Michael Brown 7b3cc18462 [efi] Open device path protocol only at point of use
Some EFI 1.10 systems (observed on an Apple iMac) do not allow us to
open the device path protocol with an attribute of
EFI_OPEN_PROTOCOL_BY_DRIVER and so we cannot maintain a safe,
long-lived pointer to the device path.  Work around this by instead
opening the device path protocol with an attribute of
EFI_OPEN_PROTOCOL_GET_PROTOCOL whenever we need to use it.

Debugged-by: Curtis Larsen <larsen@dixie.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-05 23:10:33 +01:00
Michael Brown 3b42ed477f [efi] Provide centralised definitions of commonly-used GUIDs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-05 23:08:32 +01:00
Michael Brown 60891f699a [efi] Use efi_handle_name() instead of efi_devpath_text() where applicable
Using efi_devpath_text() is marginally more efficient if we already
have the device path protocol available, but the mild increase in
efficiency is not worth compromising the clarity of the pattern:

  DBGC ( device, "THING %p %s ...", device, efi_handle_name ( device ) );

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31 11:57:31 +01:00
Michael Brown 7cfb502fff [efi] Ignore failures when attempting to install SNP HII protocol
HII seems to fail on several systems.  Since it is non-essential,
treat HII problems as non-fatal.

Debugged-by: Curtis Larsen <larsen@dixie.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-30 18:44:09 +01:00
Michael Brown dc18fd7648 [efi] Default to releasing network devices for use via SNP
We currently treat network devices as available for use via the SNP
API only if RX queue processing has been frozen.  (This is similar in
spirit to the way that RX queue processing is frozen for the network
device currently exposed via the PXE API.)

The default state of a freshly created network device is for the RX
queue to not be frozen, and thus to be unavailable for use via SNP.
This causes problems when devices are added through code paths other
than _efidrv_start() (which explicitly releases devices for use via
SNP).

We don't actually need to freeze RX queue processing, since calls via
the SNP API will always use netdev_poll() rather than net_poll(), and
so will never trigger the RX queue processing code path anyway.

We can therefore simplify the code to use a single global flag to
indicate whether network devices are claimed for use by iPXE or
available for use via SNP.  Using a global flag allows the default
state for dynamically created network devices to behave sensibly.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-30 14:27:07 +01:00
Michael Brown c7051d826b [efi] Allow network devices to be created on top of arbitrary SNP devices
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-03 15:28:17 +01:00
Michael Brown f2c116ff7d [efi] Provide a meaningful EFI SNP device name
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-25 14:46:41 +01:00
Michael Brown 8290a95513 [build] Expose build timestamp, build name, and product names
Expose the build timestamp (measured in seconds since the Epoch) and
the build name (e.g. "rtl8139.rom" or "ipxe.efi"), and provide the
product name and product short name in a single centralised location.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-24 15:32:35 +01:00
Michael Brown f473b9c3f6 [efi] Disable SNP devices when running iPXE as the application
Some UEFI builds will set up a timer to continuously poll any SNP
devices.  This can drain packets from the network device's receive
queue before iPXE gets a chance to process them.

Use netdev_rx_[un]freeze() to explicitly indicate when we expect our
network devices to be driven via the external SNP API (as we do with
the UNDI API on the standard BIOS build), and disable the SNP API
except when receive queue processing is frozen.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-14 17:09:51 +00:00
Michael Brown 54409583e2 [efi] Perform meaningful error code conversions
Exploit the redefinition of iPXE error codes to include a "platform
error code" to allow for meaningful conversion of EFI_STATUS values to
iPXE errors and vice versa.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-19 13:34:19 +01:00
Michael Brown c7c3d839fc [efi] Add our own EFI_LOAD_FILE_PROTOCOL implementation
When iPXE is used as a UEFI driver, the UEFI PXE base code currently
provides the TCP/IP stack, network protocols, and user interface.
This represents a substantial downgrade from the standard BIOS iPXE
user experience.

Fix by installing our own EFI_LOAD_FILE_PROTOCOL implementation which
initiates the standard iPXE boot procedure.  This upgrades the UEFI
iPXE user experience to match the standard BIOS iPXE user experience.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-13 23:01:53 +00:00
Michael Brown db014f3c23 [efi] Add last_opened_snpdev()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-13 22:42:15 +00:00
Michael Brown 717279a294 [efi] Include product short name in EFI SNP device names
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-21 03:43:43 +00:00
Michael Brown 7cf6c6bfed [efi] Add EFI_COMPONENT_NAME2_PROTOCOL instance for each SNP device
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-23 14:07:50 -07:00
Michael Brown 41ea18a455 [efi] Split SNP HII functionality into a separate file
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-16 15:10:52 +01:00
Michael Brown bab0a4c1ce [efi] Mark SNP formset compliant with IBM's Unified Configuration Manager
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-05 13:24:07 +01:00
Michael Brown 09cc63fc8b [efi] Provide guaranteed space in transmitted packets
eIPoIB requires space to expand a transmitted ARP packet.  This
guarantee is met by ensuring that a transmitted packet consists of at
least MAX_LL_HEADER_LEN bytes from the start of the I/O buffer up to
the end of the link-layer header, and at least IOB_ZLEN bytes
thereafter.

Adjust the I/O buffer allocation for SNP transmitted packets to ensure
that this guarantee is met.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-09-14 17:49:53 +01:00
Michael Brown 03f0c23f8b [ipoib] Expose Ethernet-compatible eIPoIB link-layer addresses and headers
Almost all clients of the raw-packet interfaces (UNDI and SNP) can
handle only Ethernet link layers.  Expose an Ethernet-compatible link
layer to local clients, while remaining compatible with IPoIB on the
wire.  This requires manipulation of ARP (but not DHCP) packets within
the IPoIB driver.

This is ugly, but it's the only viable way to allow IPoIB devices to
be driven via the raw-packet interfaces.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-08-31 21:22:59 +01:00
Michael Brown c3b4860ce3 [legal] Update FSF mailing address in GPL licence texts
Suggested-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-20 19:55:45 +01:00
Michael Brown d3d87a2d92 [efi] Update link state in SNP device mode data
There is no explicit SNP API call to determine link state; the SNP
interface user may check the MediaPresent field within the mode data
at any time.

Update the MediaPresent field whenever the link state changes.

Reported-by: Michael R Turner <mikeyt@us.ibm.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-19 22:54:24 +01:00
Michael Brown a667bf044a [netdevice] Allow link layer to report broadcast/multicast packets via pull()
Allow the link layer to directly report whether or not a packet is
multicast or broadcast at the time of calling pull(), rather than
relying on heuristics to determine this at a later stage.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-07-15 18:48:46 +01:00
Michael Brown 0a71888792 [efi] Ensure that each HII package list and formset has a unique GUID
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-05-03 18:55:05 +01:00
Michael Brown 1c67e20261 [efi] Add support for HII
Some EFI platforms expect us to provide an HII interface to display
information about the driver.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-07 23:15:07 +01:00
Michael Brown 870524a3b2 [efi] Add EFI string formatting functions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-07 23:15:06 +01:00
Michael Brown b9326c3655 [efi] Mark SNP devices as children of EFI PCI device
Re-open the EFI_PCI_IO_PROTOCOL specifying an Attributes value of
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.  This causes the SNP devices to
be marked as children of the EFI PCI device (as shown in the "devtree"
command).

On at least one IBM blade system, this is required in order to have
the relevant drivers automatically attach to the SNP controller at
device creation time.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-15 16:59:19 +00:00
Michael Brown d7736fbb7b [efi] Allow EFI to control PCI bus enumeration
EFI performs its own PCI bus enumeration.  Respect this, and start
controlling devices only when instructed to do so by EFI.

As a side benefit, we should now correctly create multiple SNP
instances for multi-port devices.

This should also fix the problem of failing to enumerate devices
because the PCI bridges have not yet been enabled at the time the iPXE
driver is loaded.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-02-17 02:56:55 +00:00
Michael Brown f9b3fae8d4 [pci] Use single "busdevfn" field in struct pci_device
Merge the "bus" and "devfn" fields into a single "busdevfn" field, to
match the format used by the majority of external code.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-02-17 01:25:11 +00:00
Michael Brown 308615cd97 [efi] Always allow MAX_LL_HEADER_LEN for the link-layer header
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-19 16:08:04 +00:00
Michael Brown 8406115834 [build] Rename gPXE to iPXE
Access to the gpxe.org and etherboot.org domains and associated
resources has been revoked by the registrant of the domain.  Work
around this problem by renaming project from gPXE to iPXE, and
updating URLs to match.

Also update README, LOG and COPYRIGHTS to remove obsolete information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-19 23:43:39 +01:00
Michael Brown 88e436376c [netdevice] Add netdev_is_open() wrapper function
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2010-03-23 00:46:35 +00:00
Michael Brown 4eab5bc8ca [netdevice] Allow the hardware and link-layer addresses to differ in size
IPoIB has a 20-byte link-layer address, of which only eight bytes
represent anything relating to a "hardware address".

The PXE and EFI SNP APIs expect the permanent address to be the same
size as the link-layer address, so fill in the "permanent address"
field with the initial link layer address (as generated by
register_netdev() based upon the real hardware address).
2009-08-12 00:23:38 +01:00
Michael Brown 37a0aab4ff [netdevice] Separate out the concept of hardware and link-layer addresses
The hardware address is an intrinsic property of the hardware, while
the link-layer address can be changed at runtime.  This separation is
exposed via APIs such as PXE and EFI, but is currently elided by gPXE.

Expose the hardware and link-layer addresses as separate properties
within a net device.  Drivers should now fill in hw_addr, which will
be used to initialise ll_addr at the time of calling
register_netdev().
2009-08-12 00:19:14 +01:00