summaryrefslogtreecommitdiffstats
path: root/src/interface/efi/efi_snp.c
Commit message (Collapse)AuthorAgeFilesLines
* [efi] Fix error handling path in efi_snp_probeIgnat Korchagin2019-01-151-3/+3
| | | | | | | | | | | | | | | | | | | | | | | 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>
* [efi] Exclude link-layer header length from MaxPacketSizeRob Taglang2018-07-071-1/+1
| | | | | Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Raise TPL within EFI_SIMPLE_NETWORK_PROTOCOL entry pointsMichael Brown2018-02-201-12/+81
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Run at TPL_CALLBACK to protect against UEFI timersMichael Brown2018-02-201-0/+12
| | | | | | | | | | | | | | | | | | | 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>
* [efi] Match behaviour of SnpDxe for truncated received packetsMichael Brown2017-09-071-13/+9Star
| | | | | | | | | | | | | 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>
* [efi] Check buffer length for packets retrieved via our SNP protocolMichael Brown2017-09-071-3/+14
| | | | | | | | | | | | 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>
* [efi] Do not copy garbage bytes into SNP device path MAC addressMichael Brown2016-06-221-1/+1
| | | | | | | | | | | | | | | | | | | | 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>
* [efi] Include VLAN in SNP device path if applicableMichael Brown2016-06-181-2/+15
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Add support for EFI_GRAPHICS_OUTPUT_PROTOCOL frame buffer consolesMichael Brown2015-10-161-0/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Expose an UNDI interface alongside the existing SNP interfaceMichael Brown2015-09-281-23/+676
| | | | | | | | | | | | | | | | | | | | | | 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>
* [efi] Include a copy of the device path within struct efi_deviceMichael Brown2015-09-131-22/+2Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Provide efi_devpath_len()Michael Brown2015-09-131-2/+1Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Do not return EFI_NOT_READY from our ReceiveFilters() methodMichael Brown2015-09-011-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [efi] Fix order of events on SNP removal pathMichael Brown2015-09-011-1/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Allow calls to efi_snp_claim() and efi_snp_release() to be nestedMichael Brown2015-09-011-4/+5
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Remove raw EFI_HANDLE values from debug messagesMichael Brown2015-08-271-11/+10Star
| | | | | | | | | 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>
* [test] Allow self-tests to report exit status when running under LinuxMichael Brown2015-08-211-7/+5Star
| | | | | | | | | 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>
* [efi] Hold off watchdog timer while runningMichael Brown2015-08-031-0/+7
| | | | | | | | | | | | | | | | 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>
* [efi] Allow user experience to be downgradedMichael Brown2015-07-221-0/+34
| | | | | | | | | | | | | | | | | | | | | | | 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>
* [efi] Fix receive and transmit completion reportingMichael Brown2015-07-221-66/+66
| | | | | | | | | | | | | | | | 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>
* [efi] Centralise definitions of more protocol GUIDsMichael Brown2014-09-251-14/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Move abstract device path and handle functions to efi_utils.cMichael Brown2014-08-061-5/+6
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Open device path protocol only at point of useMichael Brown2014-08-061-12/+43
| | | | | | | | | | | | 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>
* [efi] Provide centralised definitions of commonly-used GUIDsMichael Brown2014-08-061-16/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Use efi_handle_name() instead of efi_devpath_text() where applicableMichael Brown2014-07-311-2/+2
| | | | | | | | | | 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>
* [efi] Ignore failures when attempting to install SNP HII protocolMichael Brown2014-07-301-4/+8
| | | | | | | | 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>
* [efi] Default to releasing network devices for use via SNPMichael Brown2014-07-301-30/+27Star
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* [efi] Allow network devices to be created on top of arbitrary SNP devicesMichael Brown2014-07-031-25/+40
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Provide a meaningful EFI SNP device nameMichael Brown2014-06-251-1/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Expose build timestamp, build name, and product namesMichael Brown2014-06-241-4/+4
| | | | | | | | 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>
* [efi] Disable SNP devices when running iPXE as the applicationMichael Brown2014-03-141-7/+126
| | | | | | | | | | | | | 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>
* [efi] Perform meaningful error code conversionsMichael Brown2013-04-191-24/+18Star
| | | | | | | | 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>
* [efi] Add our own EFI_LOAD_FILE_PROTOCOL implementationMichael Brown2013-03-141-1/+56
| | | | | | | | | | | | | 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>
* [efi] Add last_opened_snpdev()Michael Brown2013-03-131-0/+15
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Include product short name in EFI SNP device namesMichael Brown2012-11-211-3/+5
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Add EFI_COMPONENT_NAME2_PROTOCOL instance for each SNP deviceMichael Brown2012-10-231-0/+68
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Split SNP HII functionality into a separate fileMichael Brown2012-10-161-418/+9Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Mark SNP formset compliant with IBM's Unified Configuration ManagerMichael Brown2012-10-051-2/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Provide guaranteed space in transmitted packetsMichael Brown2012-09-141-6/+7
| | | | | | | | | | | | | 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>
* [ipoib] Expose Ethernet-compatible eIPoIB link-layer addresses and headersMichael Brown2012-08-311-1/+2
| | | | | | | | | | | | | 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>
* [legal] Update FSF mailing address in GPL licence textsMichael Brown2012-07-201-1/+2
| | | | | Suggested-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Update link state in SNP device mode dataMichael Brown2012-04-191-2/+15
| | | | | | | | | | | 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>
* [netdevice] Allow link layer to report broadcast/multicast packets via pull()Michael Brown2011-07-151-1/+3
| | | | | | | | 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>
* [efi] Ensure that each HII package list and formset has a unique GUIDMichael Brown2011-05-031-3/+6
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Add support for HIIMichael Brown2011-04-081-0/+374
| | | | | | | Some EFI platforms expect us to provide an HII interface to display information about the driver. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Add EFI string formatting functionsMichael Brown2011-04-081-7/+4Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Mark SNP devices as children of EFI PCI deviceMichael Brown2011-03-151-0/+15
| | | | | | | | | | | | | 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>
* [efi] Allow EFI to control PCI bus enumerationMichael Brown2011-02-171-285/+72Star
| | | | | | | | | | | | | | 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>
* [pci] Use single "busdevfn" field in struct pci_deviceMichael Brown2011-02-171-1/+1
| | | | | | | 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>
* [efi] Always allow MAX_LL_HEADER_LEN for the link-layer headerMichael Brown2010-11-191-1/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>