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

5054 Commits

Author SHA1 Message Date
Michael Brown a9da129122 [test] Simplify digest algorithm self-tests
Update the digest self-tests to use okx(), and centralise concepts and
data shared between tests for multiple algorithms to reduce duplicated
code.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-12 17:01:10 +01:00
Laszlo Ersek b12b1b620f [virtio] Downgrade per-iobuf debug messages to DBGC2
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-10 21:18:42 +01:00
Michael Brown dc795b9fef [test] Add setjmp()/longjmp() self-tests
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-07 06:40:46 +01:00
Michael Brown fb2bedcff3 [libc] Add x86_64 versions of setjmp() and longjmp()
None of the x86_64 builds currently have any way of invoking these
functions.  They are included only to avoid introducing unnecessary
architecture-specific dependencies into the self-test suite.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-07 06:40:42 +01:00
Michael Brown 00ff3d8bb3 [libc] Fix typo in longjmp()
Commit 8ab4b00 ("[libc] Rewrite setjmp() and longjmp()") introduced a
regression in which the saved values of %ebx, %esi, and %edi were all
accidentally restored into %esp.  The result is that the second and
subsequent returns from setjmp() would effectively corrupt %ebx, %esi,
%edi, and the stack pointer %esp.

Use of setjmp() and longjmp() is generally discouraged: our only use
occurs as part of the implementation of PXENV_RESTART_TFTP, since the
PXE API effectively mandates its use here.  The call to setjmp()
occurs at the start of pxe_start_nbp(), where there are almost
certainly no values held in %ebx, %esi, or %edi.  The corruption of
these registers therefore had no visible effect on program execution.
The corruption of %esp would have been visible on return from
pxe_start_nbp(), but there are no known PXE NBPs which first call
PXENV_RESTART_TFTP and subsequently attempt to return to the PXE base
code.  The effect on program execution was therefore similar to that
of moving the stack to a pseudo-random location in the 32-bit address
space; this will often allow execution to complete successfully since
there is a high chance that the pseudo-random location will be unused.
The regression therefore went undetected for around one month.

Fix by restoring the correct registers from the saved jmp_buf
structure.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-07 06:40:34 +01:00
Michael Brown f557794ab3 [xhci] Support USB1 devices attached via transaction translators
xHCI provides a somewhat convoluted mechanism for specifying details
of a transaction translator.  Hubs must be marked as such in the
device slot context.  The only opportunity to do so is as part of a
Configure Endpoint command, which can be executed only when opening
the hub's interrupt endpoint.

We add a mechanism for host controllers to intercept the opening of
hub devices, providing xHCI with an opportunity to update the internal
device slot structure for the corresponding USB device to indicate
that the device is a hub.  We then include the hub-specific details in
the input context whenever any Configure Endpoint command is issued.

When a device is opened, we record the device slot and port for its
transaction translator (if any), and supply these as part of the
Address Device command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23 20:24:20 +00:00
Michael Brown 026b3446b9 [usb] Improve debug messages for failed control transactions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23 20:18:02 +00:00
Michael Brown b418af26d9 [ehci] Support USB1 devices attached via transaction translators
Support low-speed and full-speed devices attached to a USB2 hub.  Such
devices use a transaction translator (TT) within the USB2 hub, which
asynchronously initiates transactions on the lower-speed bus and
returns the result via a split completion on the high-speed bus.

We make the simplifying assumption that there will never be more than
sixteen active interrupt endpoints behind a single transaction
translator; this assumption allows us to schedule all periodic start
splits in microframe 0 and all periodic split completions in
microframes 2 and 3.  (We do not handle isochronous endpoints.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23 16:23:08 +00:00
Michael Brown 5486c947e2 [usb] Clear transaction translator buffers when applicable
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23 16:22:55 +00:00
Michael Brown 9e88194655 [usb] Add clear_tt() hub method to clear transaction translator buffer
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23 16:21:13 +00:00
Michael Brown de6f4e3ede [usb] Reset endpoints without waiting for a new transfer to be enqueued
The current endpoint reset logic defers the reset until the caller
attempts to enqueue a new transfer to that endpoint.  This is
insufficient when dealing with endpoints behind a transaction
translator, since the transaction translator is a resource shared
between multiple endpoints.

We cannot reset the endpoint as part of the completion handling, since
that would introduce recursive calls to usb_poll().  Instead, we
add the endpoint to a list of halted endpoints, and perform the reset
on the next call to usb_step().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23 15:21:35 +00:00
Michael Brown 661189eede [xhci] Ring doorbell as part of endpoint reset
The endpoint may already have enqueued TRBs at the time that
xhci_endpoint_reset() is called.  Ring the doorbell to resume
processing these TRBs immediately, rather than waiting until the next
call to xhci_endpoint_message() or xhci_endpoint_stream().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23 15:21:35 +00:00
Michael Brown a3c00d8d3b [libprefix] Fix building on 64-bit FreeBSD 8.4
Reported-by: Pavel Antonov <holly@istu.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-23 13:28:59 +00:00
Michael Brown acc27b9005 [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>
2015-03-18 16:43:18 +00:00
Michael Brown c492a9fd92 [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>
2015-03-18 16:42:39 +00:00
Michael Brown 8370f87745 [ehci] Add support for EHCI host controllers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-18 12:35:17 +00:00
Michael Brown ec0e2a7bd7 [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>
2015-03-18 12:35:16 +00:00
Michael Brown e1feb7bcab [usb] Add config/usb.h for USB configuration options
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-18 12:35:16 +00:00
Michael Brown 75d6fec6c4 [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>
2015-03-17 02:30:06 +00:00
Michael Brown 3de0ffc887 [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>
2015-03-16 20:38:48 +00:00
Michael Brown 838ab97ce3 [usb] Add functions for manual device address assignment
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-16 15:42:29 +00:00
Michael Brown 74f57016dc [ncm] Respect maximum transfer size of the bus
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-16 15:40:54 +00:00
Michael Brown 7b6765ff1b [usb] Add the concept of a USB bus maximum transfer size
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-16 15:40:53 +00:00
Michael Brown 79697c75ee [libc] Add ffs(), ffsl(), and ffsll()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-16 15:40:53 +00:00
Michael Brown 57bab4e1d3 [tcpip] Fix dubious calculation of min_port
Detected using sparse.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-13 10:19:44 +00:00
Michael Brown 7f80eb511e [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>
2015-03-11 23:14:43 +00:00
Michael Brown e0fc8fe781 [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>
2015-03-11 23:14:39 +00:00
Michael Brown bc985ca089 [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>
2015-03-11 14:23:14 +00:00
Michael Brown 69062bbc21 [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>
2015-03-11 13:38:38 +00:00
Michael Brown 6ad02e78bb [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>
2015-03-10 21:31:07 +00:00
Michael Brown 03e71d5d1a [legal] Relicense Davicom DM96xx drivers
Reported-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-10 00:12:39 +00:00
Michael Brown 1ae94c903d [dm96xx] Add driver for Davicom DM96xx USB Ethernet NICs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-09 19:58:57 +00:00
Thomas Miletich 02bf4f16f3 [intel] Add PCI ID for I218-LM
Signed-off-by: Thomas Miletich <thomas.miletich@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-09 14:20:41 +00:00
Michael Brown 042a982c4d [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>
2015-03-09 13:45:09 +00:00
Michael Brown 42ea20afee [http] Abstract out HTTP Digest hash algorithm operations
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-09 13:21:27 +00:00
Michael Brown 3eb91209d9 [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>
2015-03-09 08:52:03 +00:00
Michael Brown e905cdcce3 [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>
2015-03-06 17:15:29 +00:00
Michael Brown ff320404d5 [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>
2015-03-06 11:58:14 +00:00
Michael Brown 1a4e94a828 [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>
2015-03-05 11:40:13 +00:00
Michael Brown 93b4586447 [retry] Colourise debug output
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-05 11:25:54 +00:00
Michael Brown 47ad8fc1ba [retry] Rewrite unrelicensable portions of retry.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-05 11:06:03 +00:00
Michael Brown bfbb2b8f1c [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>
2015-03-05 02:43:37 +00:00
Michael Brown 81166302a0 [i386] Move real_to_user() to realmode.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-05 02:30:58 +00:00
Michael Brown fbc4ba4b4e [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>
2015-03-05 00:59:38 +00:00
Michael Brown 86ae6e6c18 [build] Use REQUIRE_OBJECT() to drag in per-object configuration
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-05 00:57:44 +00:00
Michael Brown 04c1ea8170 [build] Remove obsolete and unused portions of config.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-04 14:49:43 +00:00
Michael Brown 81112dea5f [pxe] Remove obsolete references to pxeparent_dhcp
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 16:30:09 +00:00
Michael Brown 334eed0cb5 [build] Remove unused __keepme macro
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 16:08:39 +00:00
Michael Brown 30d356b455 [build] Remove unused IMPORT_SYMBOL() and EXPORT_SYMBOL() macros
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 15:51:33 +00:00
Michael Brown b2f38da888 [malloc] Rewrite unrelicensable portions of malloc.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 15:24:15 +00:00