ipxe.git
6 years ago[libprefix] Fix building on 64-bit FreeBSD 8.4
Michael Brown [Mon, 23 Mar 2015 13:28:59 +0000 (13:28 +0000)] 
[libprefix] Fix building on 64-bit FreeBSD 8.4

Reported-by: Pavel Antonov <holly@istu.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[usb] Fix USB timeouts to match specification
Michael Brown [Wed, 18 Mar 2015 16:43:18 +0000 (16:43 +0000)] 
[usb] Fix USB timeouts to match specification

Several of the USB timeouts were chosen on the principle of "pick an
arbitrary but ridiculously large value, just to be safe".  It turns
out that some of the timeouts permitted by the USB specification are
even larger: for example, control transactions are allowed to take up
to five seconds to complete.

Fix up these USB timeout values to match those found in the USB2
specification.

Debugged-by: Robin Smidsrød <robin@smidsrod.no>
Tested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[netdevice] Add missing bus types to netdev_fetch_bustype()
Michael Brown [Wed, 18 Mar 2015 16:42:39 +0000 (16:42 +0000)] 
[netdevice] Add missing bus types to netdev_fetch_bustype()

Reported-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[ehci] Add support for EHCI host controllers
Michael Brown [Sun, 15 Mar 2015 01:01:08 +0000 (01:01 +0000)] 
[ehci] Add support for EHCI host controllers

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[xhci] Do not release ownership back to BIOS when booting an OS
Michael Brown [Wed, 18 Mar 2015 11:57:41 +0000 (11:57 +0000)] 
[xhci] Do not release ownership back to BIOS when booting an OS

xHCI (and EHCI) nominally provide a mechanism for releasing ownership
of the host controller back to the BIOS, which can then potentially
restore legacy USB keyboard functionality.

This is a rarely used code path, since most operating systems claim
ownership and never attempt to later return to the BIOS.  On some
systems (observed with a Lenovo X1 Carbon), this code path leads to
obscure and interesting bugs: if the xHCI and EHCI controllers are
both claimed and later released back to the BIOS, then a subsequent
call to INT 16,0305 to set the keyboard repeat rate to a non-default
value will lock the system.

Obscure though this sequence of operations may sound, it is exactly
what happens when using iPXE to boot a Linux kernel via a USB network
card.  There is old and probably unwanted code in Linux's
arch/x86/boot/main.c which sets the keyboard repeat rate (with the
accompanying comment "Set keyboard repeat rate (why?)").  When booting
Linux via a USB network card on a Lenovo X1 Carbon, the system
therefore locks up immediately after jumping to the kernel's entry
point.

Work around this problem by preventing the release of ownership back
to the BIOS if it is known that we are shutting down to boot an OS.
This should allow legacy USB keyboard functionality to be restored if
the user chooses to exit iPXE, while avoiding the rarely used code
paths (and corresponding BIOS bugs) if the user chooses instead to
boot an OS.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[usb] Add config/usb.h for USB configuration options
Michael Brown [Wed, 18 Mar 2015 11:37:51 +0000 (11:37 +0000)] 
[usb] Add config/usb.h for USB configuration options

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[autoboot] Match against parent devices when matching by bus type and location
Michael Brown [Tue, 17 Mar 2015 02:30:06 +0000 (02:30 +0000)] 
[autoboot] Match against parent devices when matching by bus type and location

When using iPXE as an option ROM for a PCI USB controller (e.g. via
qemu's "-device nec-usb-xhci,romfile=..." syntax), the ROM prefix will
set the PCI bus:dev.fn address of the USB controller as the PCI
autoboot device.  This will cause iPXE to fail to boot from any
detected USB network devices, since they will not match the autoboot
bus type (or location).

Fix by allowing the autoboot bus type and location to match against
the network device or any of its parent devices.  This allows the
match to succeed for USB network devices attached to the selected PCI
USB controller.

Reported-by: Dan Ellis <Dan.Ellis@displaylink.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[xhci] Forcibly disable SMIs if BIOS fails to release ownership
Michael Brown [Mon, 16 Mar 2015 20:32:33 +0000 (20:32 +0000)] 
[xhci] Forcibly disable SMIs if BIOS fails to release ownership

If the BIOS fails to gracefully release ownership of the xHCI
controller, we can forcibly claim it by disabling all SMIs via the
USB legacy support control/status register.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[usb] Add functions for manual device address assignment
Michael Brown [Mon, 16 Mar 2015 15:37:39 +0000 (15:37 +0000)] 
[usb] Add functions for manual device address assignment

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[ncm] Respect maximum transfer size of the bus
Michael Brown [Mon, 16 Mar 2015 05:39:41 +0000 (05:39 +0000)] 
[ncm] Respect maximum transfer size of the bus

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[usb] Add the concept of a USB bus maximum transfer size
Michael Brown [Mon, 16 Mar 2015 05:39:14 +0000 (05:39 +0000)] 
[usb] Add the concept of a USB bus maximum transfer size

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[libc] Add ffs(), ffsl(), and ffsll()
Michael Brown [Sun, 15 Mar 2015 19:28:05 +0000 (19:28 +0000)] 
[libc] Add ffs(), ffsl(), and ffsll()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[tcpip] Fix dubious calculation of min_port
Michael Brown [Fri, 13 Mar 2015 10:19:44 +0000 (10:19 +0000)] 
[tcpip] Fix dubious calculation of min_port

Detected using sparse.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[smsc75xx] Move RX FIFO overflow message to DBGLVL_EXTRA
Michael Brown [Wed, 11 Mar 2015 22:33:51 +0000 (22:33 +0000)] 
[smsc75xx] Move RX FIFO overflow message to DBGLVL_EXTRA

RX FIFO overflow is almost inevitable since the (usable) USB2 bus
bandwidth is approximately one quarter of the Ethernet bandwidth.
Avoid flooding the console with RX FIFO overflow messages in a
standard debug build.

With TCP SACK implemented, the RX FIFO overflow no longer causes a
catastrophic drop in throughput.  Experimentation shows that HTTP
downloads now progress at a fairly smooth 250Mbps, which is around the
maximum speed attainable for a USB2 NIC.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[tcp] Implement support for TCP Selective Acknowledgements (SACK)
Michael Brown [Wed, 11 Mar 2015 17:53:29 +0000 (17:53 +0000)] 
[tcp] Implement support for TCP Selective Acknowledgements (SACK)

The TCP Selective Acknowledgement option (specified in RFC2018)
provides a mechanism for the receiver to indicate packets that have
been received out of order (e.g. due to earlier dropped packets).

iPXE often operates in environments in which there is a high
probability of packet loss.  For example, the legacy USB keyboard
emulation in some BIOSes involves polling the USB bus from within a
system management interrupt: this introduces an invisible delay of
around 500us which is long enough for around 40 full-length packets to
be dropped.  Similarly, almost all 1Gbps USB2 devices will eventually
end up dropping packets because the USB2 bus does not provide enough
bandwidth to sustain a 1Gbps stream, and most devices will not provide
enough internal buffering to hold a full TCP window's worth of
received packets.

Add support for sending TCP Selective Acknowledgements.  This provides
the sender with more detailed information about which packets have
been lost, and so allows for a more efficient retransmission strategy.

We include a SACK-permitted option in our SYN packet, since
experimentation shows that at least Linux peers will not include a
SACK-permitted option in the SYN-ACK packet if one was not present in
the initial SYN.  (RFC2018 does not seem to mandate this behaviour,
but it is consistent with the approach taken in RFC1323.)  We ignore
any received SACK options; this is safe to do since SACK is only ever
advisory and we never have to send non-trivial amounts of data.

Since our TCP receive queue is a candidate for cache discarding under
low memory conditions, we may end up discarding data that has been
reported as received via a SACK option.  This is permitted by RFC2018.
We follow the stricture that SACK blocks must not report data which is
no longer held by the receiver: previously-reported blocks are
validated against the current receive queue before being included
within the current SACK block list.

Experiments in a qemu VM using forced packet drops (by setting
NETDEV_DISCARD_RATE to 32) show that implementing SACK improves
throughput by around 400%.

Experiments with a USB2 NIC (an SMSC7500) show that implementing SACK
improves throughput by around 700%, increasing the download rate from
35Mbps up to 250Mbps (which is approximately the usable bandwidth
limit for USB2).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Michael Brown [Wed, 11 Mar 2015 14:23:14 +0000 (14:23 +0000)] 
[legal] Relicense files under GPL2_OR_LATER_OR_UBDL

Several of the assembly files in arch/i386/prefix were missed by the
automated relicensing tool due to missing licence declarations, code
dating back to the initial git revision, etc.  Manual review shows
that these files may be relicensed.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[smsc75xx] Add driver for SMSC/Microchip LAN75xx USB Ethernet NICs
Michael Brown [Tue, 10 Mar 2015 14:37:18 +0000 (14:37 +0000)] 
[smsc75xx] Add driver for SMSC/Microchip LAN75xx USB Ethernet NICs

This driver is functional but any downloads via a TCP-based protocol
tend to perform poorly.  The 1Gbps Ethernet line rate is substantially
higher than the 480Mbps (in practice around 280Mbps) provided by USB2,
and the device has only 32kB of internal buffer memory.  Our 256kB TCP
receive window therefore rapidly overflows the RX FIFO, leading to
multiple dropped packets (usually within the same TCP window) and
hence a low overall throughput.

Reducing the TCP window size so that the RX FIFO does not overflow
greatly increases throughput, but is not a general-purpose solution.

Further investigation is required to determine how other OSes
(e.g. Linux) cope with this scenario.  It is possible that
implementing TCP SACK would provide some benefit.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[mii] Add generic mii_check_link() function
Michael Brown [Tue, 10 Mar 2015 21:23:51 +0000 (21:23 +0000)] 
[mii] Add generic mii_check_link() function

Most devices expose at least the link up/down status via a bit in a
MAC register, since the MAC generally already needs to know whether or
not the link is up.  Some devices (e.g. the SMSC75xx USB NIC) expose
this information to software only via the MII registers.

Provide a generic mii_check_link() implementation to check the BMSR
and report the link status via netdev_link_{up,down}().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[legal] Relicense Davicom DM96xx drivers
Michael Brown [Tue, 10 Mar 2015 00:12:39 +0000 (00:12 +0000)] 
[legal] Relicense Davicom DM96xx drivers

Reported-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[dm96xx] Add driver for Davicom DM96xx USB Ethernet NICs
Michael Brown [Mon, 16 Feb 2015 15:22:44 +0000 (15:22 +0000)] 
[dm96xx] Add driver for Davicom DM96xx USB Ethernet NICs

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[intel] Add PCI ID for I218-LM
Thomas Miletich [Fri, 6 Mar 2015 20:39:42 +0000 (21:39 +0100)] 
[intel] Add PCI ID for I218-LM

Signed-off-by: Thomas Miletich <thomas.miletich@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[http] Support MD5-sess Digest authentication
Michael Brown [Mon, 9 Mar 2015 13:22:49 +0000 (13:22 +0000)] 
[http] Support MD5-sess Digest authentication

Microsoft IIS supports only MD5-sess for Digest authentication.

Requested-by: Andreas Hammarskjöld <junior@2PintSoftware.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[http] Abstract out HTTP Digest hash algorithm operations
Michael Brown [Mon, 9 Mar 2015 12:35:17 +0000 (12:35 +0000)] 
[http] Abstract out HTTP Digest hash algorithm operations

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[xen] Set the "feature-rx-notify" flag for netfront devices
Michael Brown [Fri, 6 Mar 2015 17:19:09 +0000 (17:19 +0000)] 
[xen] Set the "feature-rx-notify" flag for netfront devices

iPXE already sends RX notifications to the backend when needed, but
does not set the "feature-rx-notify" flag.  As of XenServer 6.5, this
flag is mandatory and omitting it will cause the backend to fail.

Fix by setting the "feature-rx-notify" flag, to inform the backend
that we will send notifications.

Reported-by: Shalom Bhooshi <shalom.bhooshi@citrix.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[xhci] Undo PCH-specific quirk fixes when removing device
Michael Brown [Fri, 6 Mar 2015 17:15:29 +0000 (17:15 +0000)] 
[xhci] Undo PCH-specific quirk fixes when removing device

Restore the original values of XUSB2PR and USB3PSSEN, in case we are
booting an OS with no support for xHCI.

Suggested-by: Dan Ellis <Dan.Ellis@displaylink.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[xhci] Enable USB3 ports on Intel PCH8/PCH9 controllers
Michael Brown [Fri, 6 Mar 2015 11:41:37 +0000 (11:41 +0000)] 
[xhci] Enable USB3 ports on Intel PCH8/PCH9 controllers

Intel PCH controllers default to routing USB2 ports to EHCI rather
than xHCI, and default to disabling SuperSpeed connections.
Manipulate the PCI configuration space registers as necessary to
reroute ports and enable SuperSpeed.

Originally-fixed-by: Dan Ellis <Dan.Ellis@displaylink.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Michael Brown [Thu, 5 Mar 2015 11:36:30 +0000 (11:36 +0000)] 
[legal] Relicense files under GPL2_OR_LATER_OR_UBDL

Relicense files with kind permission from

    Stefan Hajnoczi <stefanha@redhat.com>

alongside the contributors who have already granted such relicensing
permission.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[retry] Colourise debug output
Michael Brown [Thu, 5 Mar 2015 11:25:54 +0000 (11:25 +0000)] 
[retry] Colourise debug output

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[retry] Rewrite unrelicensable portions of retry.c
Michael Brown [Thu, 5 Mar 2015 11:04:47 +0000 (11:04 +0000)] 
[retry] Rewrite unrelicensable portions of retry.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[linux] Rewrite headers included in all builds
Michael Brown [Thu, 5 Mar 2015 02:43:37 +0000 (02:43 +0000)] 
[linux] Rewrite headers included in all builds

Rewrite (and relicense) the header files which are included in all
builds of iPXE (including non-Linux builds).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[i386] Move real_to_user() to realmode.h
Michael Brown [Thu, 5 Mar 2015 02:30:58 +0000 (02:30 +0000)] 
[i386] Move real_to_user() to realmode.h

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[build] Fix the REQUIRE_SYMBOL mechanism
Michael Brown [Wed, 4 Mar 2015 18:48:19 +0000 (18:48 +0000)] 
[build] Fix the REQUIRE_SYMBOL mechanism

At some point in the past few years, binutils became more aggressive
at removing unused symbols.  To function as a symbol requirement, a
relocation record must now be in a section marked with @progbits and
must not be in a section which gets discarded during the link (either
via --gc-sections or via /DISCARD/).

Update REQUIRE_SYMBOL() to generate relocation records meeting these
criteria.  To minimise the impact upon the final binary size, we use
existing symbols (specified via the REQUIRING_SYMBOL() macro) as the
relocation targets where possible.  We use R_386_NONE or R_X86_64_NONE
relocation types to prevent any actual unwanted relocation taking
place.  Where no suitable symbol exists for REQUIRING_SYMBOL() (such
as in config.c), the macro PROVIDE_REQUIRING_SYMBOL() can be used to
generate a one-byte-long symbol to act as the relocation target.

If there are versions of binutils for which this approach fails, then
the fallback will probably involve killing off REQUEST_SYMBOL(),
redefining REQUIRE_SYMBOL() to use the current definition of
REQUEST_SYMBOL(), and postprocessing the linked ELF file with
something along the lines of "nm -u | wc -l" to check that there are
no undefined symbols remaining.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[build] Use REQUIRE_OBJECT() to drag in per-object configuration
Michael Brown [Wed, 4 Mar 2015 17:22:07 +0000 (17:22 +0000)] 
[build] Use REQUIRE_OBJECT() to drag in per-object configuration

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[build] Remove obsolete and unused portions of config.c
Michael Brown [Wed, 4 Mar 2015 14:49:43 +0000 (14:49 +0000)] 
[build] Remove obsolete and unused portions of config.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[pxe] Remove obsolete references to pxeparent_dhcp
Michael Brown [Tue, 3 Mar 2015 16:30:09 +0000 (16:30 +0000)] 
[pxe] Remove obsolete references to pxeparent_dhcp

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[build] Remove unused __keepme macro
Michael Brown [Tue, 3 Mar 2015 16:08:39 +0000 (16:08 +0000)] 
[build] Remove unused __keepme macro

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[build] Remove unused IMPORT_SYMBOL() and EXPORT_SYMBOL() macros
Michael Brown [Tue, 3 Mar 2015 15:51:33 +0000 (15:51 +0000)] 
[build] Remove unused IMPORT_SYMBOL() and EXPORT_SYMBOL() macros

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[malloc] Rewrite unrelicensable portions of malloc.c
Michael Brown [Tue, 3 Mar 2015 15:16:32 +0000 (15:16 +0000)] 
[malloc] Rewrite unrelicensable portions of malloc.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[malloc] Move valgrind headers out of arch/x86
Michael Brown [Tue, 3 Mar 2015 14:25:51 +0000 (14:25 +0000)] 
[malloc] Move valgrind headers out of arch/x86

The valgrind headers are not x86-specific; they detect the CPU
architecture and contain inline assembly for multiple architectures.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[settings] Use generic jump scrolling abstraction
Michael Brown [Tue, 3 Mar 2015 03:51:08 +0000 (03:51 +0000)] 
[settings] Use generic jump scrolling abstraction

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[menu] Abstract out the generic concept of a jump scroller
Michael Brown [Tue, 3 Mar 2015 02:47:37 +0000 (02:47 +0000)] 
[menu] Abstract out the generic concept of a jump scroller

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[settings] Rewrite unrelicensable portions of settings.c
Michael Brown [Tue, 3 Mar 2015 00:41:39 +0000 (00:41 +0000)] 
[settings] Rewrite unrelicensable portions of settings.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[settings] Use list_first_entry() when unregistering child settings
Michael Brown [Tue, 3 Mar 2015 00:29:42 +0000 (00:29 +0000)] 
[settings] Use list_first_entry() when unregistering child settings

Unregistering a child settings block can have almost arbitrary
effects, due to the call to apply_settings().  Avoid potentially
dereferencing a stale pointer by using list_first_entry() rather than
list_for_each_entry_safe() to iterate over the list of child settings.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[pci] Rewrite unrelicensable portions of pci.h
Michael Brown [Tue, 3 Mar 2015 00:08:41 +0000 (00:08 +0000)] 
[pci] Rewrite unrelicensable portions of pci.h

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[pci] Remove outdated and mostly-unused pci_ids.h file
Michael Brown [Mon, 2 Mar 2015 21:37:45 +0000 (21:37 +0000)] 
[pci] Remove outdated and mostly-unused pci_ids.h file

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[iscsi] Rewrite unrelicensable portions of iscsi.c
Michael Brown [Mon, 2 Mar 2015 20:37:24 +0000 (20:37 +0000)] 
[iscsi] Rewrite unrelicensable portions of iscsi.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[list] Relicense list.h
Michael Brown [Mon, 2 Mar 2015 19:47:32 +0000 (19:47 +0000)] 
[list] Relicense list.h

The code in list.h was originally taken from the Linux kernel many
years ago, but has been rewritten to the point that no original code
remains, and may therefore be relicensed.

The functions and data structures remain largely API-compatible, to
facilitate the conversion of Linux network drivers to iPXE.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[elf] Rewrite ELF header
Michael Brown [Mon, 2 Mar 2015 19:42:48 +0000 (19:42 +0000)] 
[elf] Rewrite ELF header

Rewrite the ELF header to include only the relevant portions from the
ELF specification.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[libc] Rewrite byte-swapping code
Michael Brown [Mon, 2 Mar 2015 16:25:53 +0000 (16:25 +0000)] 
[libc] Rewrite byte-swapping code

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[libc] Rewrite setjmp() and longjmp()
Michael Brown [Mon, 2 Mar 2015 15:21:38 +0000 (15:21 +0000)] 
[libc] Rewrite setjmp() and longjmp()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[libc] Rewrite unrelicensable portions of ctype.h
Michael Brown [Mon, 2 Mar 2015 14:41:49 +0000 (14:41 +0000)] 
[libc] Rewrite unrelicensable portions of ctype.h

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[libc] Rewrite unrelicensable portions of stddef.h
Michael Brown [Mon, 2 Mar 2015 14:10:21 +0000 (14:10 +0000)] 
[libc] Rewrite unrelicensable portions of stddef.h

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Michael Brown [Mon, 2 Mar 2015 13:29:46 +0000 (13:29 +0000)] 
[legal] Relicense files under GPL2_OR_LATER_OR_UBDL

These files cannot be automatically relicensed by util/relicense.pl
since they either contain unusual but trivial contributions (such as
the addition of __nonnull function attributes), or contain lines
dating back to the initial git revision (and so require manual
knowledge of the code's origin).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Michael Brown [Mon, 2 Mar 2015 12:28:42 +0000 (12:28 +0000)] 
[legal] Relicense files under GPL2_OR_LATER_OR_UBDL

Relicence files with kind permission from the following contributors:

  Alex Williamson <alex.williamson@redhat.com>
  Eduardo Habkost <ehabkost@redhat.com>
  Greg Jednaszewski <jednaszewski@gmail.com>
  H. Peter Anvin <hpa@zytor.com>
  Marin Hannache <git@mareo.fr>
  Robin Smidsrød <robin@smidsrod.no>
  Shao Miller <sha0.miller@gmail.com>
  Thomas Horsten <thomas@horsten.com>

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Michael Brown [Mon, 2 Mar 2015 12:04:57 +0000 (12:04 +0000)] 
[legal] Relicense files under GPL2_OR_LATER_OR_UBDL

Relicense files authored by Dan Lynch while working as an employee of
Fen Systems Ltd., with permission from Fen Systems Ltd.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Michael Brown [Mon, 2 Mar 2015 11:54:40 +0000 (11:54 +0000)] 
[legal] Relicense files under GPL2_OR_LATER_OR_UBDL

Relicense files for which I am the sole author (as identified by
util/relicense.pl).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[legal] Add UBDL relicensing tool
Michael Brown [Mon, 2 Mar 2015 11:42:29 +0000 (11:42 +0000)] 
[legal] Add UBDL relicensing tool

The UBDL relicensing tool (util/relicense.pl) is designed to identify
files which may be relicensed under a dual GPL+UBDL licence.  It uses
git-blame to identify the author of each line (using the -M and -C
options to track lines moved or copied between files), and relicenses
files for which all authors have given permission.

The relicensing tool will ignore certain types of lines identified by
git-blame:

 - empty lines
 - comments
 - standalone opening or closing braces
 - "#include ..."
 - "return 0;"
 - "return rc;"
 - "PCI_ROM(...)"
 - "FILE_LICENCE(...)"

These lines either contain no meaningful content (e.g. empty lines),
contain only non-copyrightable facts (e.g. PCI ROM IDs) or are
sufficiently common within the codebase that git-blame is likely to
misattribute their origin (e.g. "return 0").

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[legal] Add support for the Unmodified Binary Distribution Licence
Michael Brown [Thu, 26 Feb 2015 15:58:42 +0000 (15:58 +0000)] 
[legal] Add support for the Unmodified Binary Distribution Licence

Add the text for the Unmodified Binary Distribution Licence.  This
Licence allows for the distribution of unmodified binaries built from
publicly available source code, without imposing the obligations of
the GNU General Public License upon anyone who chooses to distribute
only the unmodified binaries built from that source code.  See the
licence text for the precise terms and conditions.

Add the licence GPL2_OR_LATER_OR_UBDL to the set of licences which can
be declared using FILE_LICENCE(), and add the corresponding support to
licence.pl.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[mucurses] Add missing FILE_LICENCE declarations
Michael Brown [Mon, 2 Mar 2015 12:02:11 +0000 (12:02 +0000)] 
[mucurses] Add missing FILE_LICENCE declarations

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[legal] Include full licence text for all GPL2_OR_LATER files
Michael Brown [Thu, 26 Feb 2015 17:49:38 +0000 (17:49 +0000)] 
[legal] Include full licence text for all GPL2_OR_LATER files

Add the standard warranty disclaimer and Free Software Foundation
address paragraphs to the licence text where these are not currently
present.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[legal] Update GPLv2 licence text
Michael Brown [Thu, 26 Feb 2015 15:43:40 +0000 (15:43 +0000)] 
[legal] Update GPLv2 licence text

Update the GPLv2 licence text to the current version (with the current
address of the Free Software Foundation, and without the Y2k
compatibility issue).

Rename the GPLv2 licence text to COPYING.GPLv2 (to hopefully make it
clearer that the licence does not apply to all files within the source
tree) and rename COPYRIGHTS to COPYING.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[zbin] Remove now-unused unnrv2b.S decompressor
Michael Brown [Thu, 26 Feb 2015 17:41:38 +0000 (17:41 +0000)] 
[zbin] Remove now-unused unnrv2b.S decompressor

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[vbox] Enable some more features now that we have LZMA compression
Robin Smidsrød [Thu, 26 Feb 2015 13:58:21 +0000 (14:58 +0100)] 
[vbox] Enable some more features now that we have LZMA compression

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[zbin] Fix check for existence of most recent output byte
Michael Brown [Thu, 26 Feb 2015 13:01:55 +0000 (13:01 +0000)] 
[zbin] Fix check for existence of most recent output byte

The code in lzma_literal() checks to see if we are at the start of the
compressed input data in order to determine whether or not a most
recent output byte exists.  This check is incorrect, since
initialisation of the decompressor will always consume the first five
bytes of the compressed input data.

Fix by instead checking whether or not we are at the start of the
output data stream.  This is, in any case, a more logical check.

This issue was masked during development and testing since virtual
machines tend to zero the initial contents of RAM; the spuriously-read
"most recent output byte" is therefore likely to already be a zero
when running in a virtual machine.

Reported-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[zbin] Allow decompressor to generate debug output via BIOS console
Michael Brown [Thu, 26 Feb 2015 12:59:08 +0000 (12:59 +0000)] 
[zbin] Allow decompressor to generate debug output via BIOS console

The 0xe9 debug port exists only on virtual machines.  Provide an
option to print debug output on the BIOS console, to allow for
debugging on real hardware.

Note that this option can be used only if the decompressor is called
in flat real mode; the easiest way to achieve this is to build with
DEBUG=libprefix.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[prefix] Call decompressor in flat real mode when DEBUG=libprefix is enabled
Michael Brown [Thu, 26 Feb 2015 12:56:07 +0000 (12:56 +0000)] 
[prefix] Call decompressor in flat real mode when DEBUG=libprefix is enabled

Allow the decompressor the option of generating debugging output via
the BIOS console by calling it in flat real mode (rather than 16-bit
protected mode) when libprefix.S is built with debugging enabled.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[zbin] Perform extra normalisation after completing decompression
Michael Brown [Thu, 26 Feb 2015 09:46:59 +0000 (09:46 +0000)] 
[zbin] Perform extra normalisation after completing decompression

LZMA performs an extra normalisation after decompression is complete,
which does not affect the output but may consume an extra byte from
the input (and so may affect which byte is identified as being the
start of the next block).

Reported-by: Robin Smidsrød <robin@smidsrod.no>
Tested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[dhcp] Extract timing parameters out to config/dhcp.h
Alex Williamson [Mon, 26 Jan 2015 17:54:29 +0000 (10:54 -0700)] 
[dhcp] Extract timing parameters out to config/dhcp.h

iPXE uses DHCP timeouts loosely based on values recommended by the
specification, but often abbreviated to reduce timeouts for reliable
and/or simple network topologies.  Extract the DHCP timing parameters
to config/dhcp.h and document them.  The resulting default iPXE
behavior is exactly the same, but downstreams are now afforded the
opportunity to implement spec-compliant behavior via config file
overrides.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[zbin] Use LZMA compression
Michael Brown [Sat, 21 Feb 2015 14:29:53 +0000 (14:29 +0000)] 
[zbin] Use LZMA compression

LZMA provides significantly better compression (by ~15%) than the
current NRV2B algorithm.

We use a raw LZMA stream (aka LZMA1) to avoid the need for code to
parse the LZMA2 block headers.  We use parameters {lc=2,lp=0,pb=0} to
reduce the stack space required by the decompressor to acceptable
levels (around 8kB).  Using lc=3 or pb=2 would give marginally better
compression, but at the cost of substantially increasing the required
stack space.

The build process now requires the liblzma headers to be present on
the build system, since we do not include a copy of an LZMA compressor
within the iPXE source tree.  The decompressor is written from scratch
(based on XZ Embedded) and is entirely self-contained within the
iPXE source.

The branch-call-jump (BCJ) filter used to improve the compressibility
is specific to iPXE.  We choose not to use liblzma's built-in BCJ
filter since the algorithm is complex and undocumented.  Our BCJ
filter achieves approximately the same results (on typical iPXE
binaries) with a substantially simpler algorithm.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[prefix] Use .bss16 as temporary stack space for calls to install_block
Michael Brown [Tue, 24 Feb 2015 16:13:55 +0000 (16:13 +0000)] 
[prefix] Use .bss16 as temporary stack space for calls to install_block

Some decompression algorithms (e.g. LZMA) require large amounts of
temporary stack space, which may not be made available by all
prefixes.  Use .bss16 as a temporary stack for the duration of the
calls to install_block (switching back to the external stack before we
start making calls into code which might access variables in .bss16),
and allow the decompressor to define a global symbol to force a
minimum value on the size of .bss16.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[hyperv] Check for required features
Michael Brown [Thu, 19 Feb 2015 14:47:07 +0000 (14:47 +0000)] 
[hyperv] Check for required features

Other hypervisors (e.g. KVM) may provide an unusable subset of the
Hyper-V features, and our attempts to use these non-existent features
cause the guest to reboot.

Fix by explicitly checking for the Hyper-V features that we use.

Reported-by: Ján ONDREJ (SAL) <ondrejj@salstar.sk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[libc] Rewrite strtoul()
Michael Brown [Thu, 19 Feb 2015 16:00:01 +0000 (16:00 +0000)] 
[libc] Rewrite strtoul()

The implementation of strtoul() has a partially unknown provenance.
Rewrite this code to avoid potential licensing uncertainty.

Since we now use -ffunction-sections, there is no need to place
strtoull() in a separate file from strtoul().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[ipv4] Rewrite inet_aton()
Michael Brown [Thu, 19 Feb 2015 14:02:07 +0000 (14:02 +0000)] 
[ipv4] Rewrite inet_aton()

The implementation of inet_aton() has an unknown provenance.  Rewrite
this code to avoid potential licensing uncertainty.

Also move the code from core/misc.c to its logical home in net/ipv4.c,
and add a few extra test cases.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[legal] Add missing copyright header to net/ipv4.c
Michael Brown [Wed, 18 Feb 2015 14:16:59 +0000 (14:16 +0000)] 
[legal] Add missing copyright header to net/ipv4.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[test] Add IPv4 self-tests
Michael Brown [Wed, 18 Feb 2015 14:11:32 +0000 (14:11 +0000)] 
[test] Add IPv4 self-tests

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[xhci] Abort commands on timeout
Michael Brown [Wed, 18 Feb 2015 11:10:55 +0000 (11:10 +0000)] 
[xhci] Abort commands on timeout

When a command times out, abort it (via the Command Abort bit in the
Command Ring Control Register) so that subsequent commands may execute
as expected.

This improves robustness when a device fails to respond to the Set
Address command, since the subsequent Disable Slot command will now
succeed.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[xhci] Leak memory if controller fails to disable slot
Michael Brown [Wed, 18 Feb 2015 09:25:36 +0000 (09:25 +0000)] 
[xhci] Leak memory if controller fails to disable slot

If the Disable Slot command fails then the hardware may continue to
write to the slot context.  Leak the memory used by the slot context
to avoid future memory corruption.

This situation has been observed in practice when a Set Address
command fails, causing the command ring to become temporarily
unresponsive.

Note that there is no need to similarly leak memory on the failure
path in xhci_device_open(), since in the event of a failure the
hardware is never informed of the slot context address.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[timer] Rewrite the 8254 Programmable Interval Timer support
Michael Brown [Tue, 17 Feb 2015 16:24:02 +0000 (16:24 +0000)] 
[timer] Rewrite the 8254 Programmable Interval Timer support

The 8254 timer code (used to implement udelay()) has an unknown
provenance.  Rewrite this code to avoid potential licensing
uncertainty.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[ncm] Use generic USB network device framework
Michael Brown [Sun, 15 Feb 2015 23:32:39 +0000 (23:32 +0000)] 
[ncm] Use generic USB network device framework

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[ecm] Use generic USB network device framework
Michael Brown [Mon, 16 Feb 2015 14:06:27 +0000 (14:06 +0000)] 
[ecm] Use generic USB network device framework

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[usb] Add generic USB network device framework
Michael Brown [Mon, 16 Feb 2015 14:05:45 +0000 (14:05 +0000)] 
[usb] Add generic USB network device framework

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[libc] Reduce size of memset()
Michael Brown [Tue, 17 Feb 2015 00:42:28 +0000 (00:42 +0000)] 
[libc] Reduce size of memset()

As with memcpy(), we can reduce the code size (by an average of 0.2%)
by giving the compiler more visibility into what memset() is doing,
and by avoiding the "rep" prefix on short fixed-length sequences of
string operations.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[test] Add constant-length memset() self-tests
Michael Brown [Tue, 17 Feb 2015 00:41:40 +0000 (00:41 +0000)] 
[test] Add constant-length memset() self-tests

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[test] Add self-tests for more string functions
Michael Brown [Mon, 16 Feb 2015 16:26:01 +0000 (16:26 +0000)] 
[test] Add self-tests for more string functions

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[libc] Rewrite string functions
Michael Brown [Mon, 16 Feb 2015 17:59:11 +0000 (17:59 +0000)] 
[libc] Rewrite string functions

Some of the C library string functions have an unknown provenance.
Reimplement all such functions to avoid potential licensing
uncertainty.

Remove the inline-assembler versions of strlen(), memswap(), and
strncmp(); these save a minimal amount of space (around 40 bytes in
total) and are not performance-critical.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[libc] Remove unused string functions
Michael Brown [Mon, 16 Feb 2015 15:33:32 +0000 (15:33 +0000)] 
[libc] Remove unused string functions

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[ncm] Use generic refill framework for bulk IN and interrupt endpoints
Michael Brown [Thu, 12 Feb 2015 15:17:21 +0000 (15:17 +0000)] 
[ncm] Use generic refill framework for bulk IN and interrupt endpoints

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[ecm] Use generic refill framework for bulk IN and interrupt endpoints
Michael Brown [Thu, 12 Feb 2015 15:16:40 +0000 (15:16 +0000)] 
[ecm] Use generic refill framework for bulk IN and interrupt endpoints

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[usb] Use generic refill framework for USB hub interrupt endpoints
Michael Brown [Thu, 12 Feb 2015 15:15:57 +0000 (15:15 +0000)] 
[usb] Use generic refill framework for USB hub interrupt endpoints

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[usb] Provide generic framework for refilling receive endpoints
Michael Brown [Thu, 12 Feb 2015 15:14:04 +0000 (15:14 +0000)] 
[usb] Provide generic framework for refilling receive endpoints

Provide a generic framework for allocating, refilling, and optionally
recycling I/O buffers used by bulk IN and interrupt endpoints.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[build] Apply the "-fno-PIE -nopie" workaround only to i386 builds
Michael Brown [Thu, 12 Feb 2015 15:58:26 +0000 (15:58 +0000)] 
[build] Apply the "-fno-PIE -nopie" workaround only to i386 builds

Hardened versions of gcc default to building position-independent
code, which breaks our i386 build.  Our build process therefore
detects such platforms and automatically adds "-fno-PIE -nopie" to the
gcc command line.

On x86_64, we choose to build position-independent code (in order to
reduce the final binary size and, in particular, the number of
relocations required for UEFI binaries).  The workaround therefore
breaks the build process for x86_64 binaries on such platforms.

Fix by moving the workaround to the i386-specific portion of the
Makefile.

Reported-by: Jan Kundrát <jkt@kde.org>
Debugged-by: Jan Kundrát <jkt@kde.org>
Debugged-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[efi] Disallow R_X86_64_32 relocations
Michael Brown [Thu, 12 Feb 2015 13:35:11 +0000 (13:35 +0000)] 
[efi] Disallow R_X86_64_32 relocations

UEFI binaries may be relocated to any location within the 64-bit
address space.  We compile as position-independent code with hidden
visibility, which should force all relocation records to be either
PC-relative (in which case no PE relocations are required) or full
64-bit relocations.  There should be no R_X86_64_32 relocation
records, since that would imply an invalid assumption that code could
not be relocated above 4GB.

Remove support for R_X86_64_32 relocation records from util/elf2efi.c,
so that any such records result in a build failure rather than a
potential runtime failure.

Reported-by: Jan Kundrát <jkt@kde.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[build] Sort objects in blib.a
Olaf Hering [Mon, 2 Feb 2015 13:54:12 +0000 (14:54 +0100)] 
[build] Sort objects in blib.a

When building hvmloader for Xen tools the iPXE objects are also linked
into the binary.  Unfortunately the linker will place them in the
order found in the archive.  Since this order is random the resulting
hvmloader binary differs when it was built from identical sources but
on different build hosts.  To help with creating a reproducible binary
the elements in blib.a must simply be sorted before passing them to
$(AR).

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[usb] Handle port status changes received after failing to find a driver
Michael Brown [Thu, 12 Feb 2015 00:46:22 +0000 (00:46 +0000)] 
[usb] Handle port status changes received after failing to find a driver

Commit a60f2dd ("[usb] Try multiple USB device configurations")
changed the behaviour of register_usb() such that if no drivers are
found then the device will be closed and the memory used will be
freed.

If a port status change subsequently occurs while the device is still
physically attached, then usb_hotplug() will see this as a new device
having been attached, since there is no device recorded as being
currently attached to the port.  This can lead to spurious hotplug
events (or even endless loops of hotplug events, if the process of
opening and closing the device happens to generate a port status
change).

Fix by using a separate flag to indicate that a device is physically
attached (even if we have no corresponding struct usb_device).

Reported-by: Dan Ellis <Dan.Ellis@displaylink.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[rndis] Add rndis_rx_err()
Michael Brown [Wed, 11 Feb 2015 17:26:51 +0000 (17:26 +0000)] 
[rndis] Add rndis_rx_err()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[build] Allow product tag line to be customised via config/branding.h
Michael Brown [Wed, 11 Feb 2015 14:22:43 +0000 (14:22 +0000)] 
[build] Allow product tag line to be customised via config/branding.h

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[build] Allow setting help text URI to be customised via config/branding.h
Michael Brown [Wed, 11 Feb 2015 13:57:34 +0000 (13:57 +0000)] 
[build] Allow setting help text URI to be customised via config/branding.h

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[build] Allow command help text URI to be customised via config/branding.h
Michael Brown [Wed, 11 Feb 2015 13:49:02 +0000 (13:49 +0000)] 
[build] Allow command help text URI to be customised via config/branding.h

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[build] Allow error message URI to be customised via config/branding.h
Michael Brown [Wed, 11 Feb 2015 13:32:57 +0000 (13:32 +0000)] 
[build] Allow error message URI to be customised via config/branding.h

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 years ago[build] Allow product URI to be customised via config/branding.h
Michael Brown [Wed, 11 Feb 2015 13:08:36 +0000 (13:08 +0000)] 
[build] Allow product URI to be customised via config/branding.h

Signed-off-by: Michael Brown <mcb30@ipxe.org>