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

5795 Commits

Author SHA1 Message Date
Michael Brown af9afd0a86 [dhcp] Fix definitions for x86_64 and EFI BC client architectures
There has been a longstanding disagreement between RFC4578 and the
IANA "Processor Architecture Types" registry.  RFC4578 section 2.1
defines type 7 as "EFI BC" and type 9 as "EFI x86-64"; the IANA
registry quotes RFC4578 as its source but has these values erroneously
swapped.  The EDK2 codebase uses the IANA values.

As of March 2016, RFC4578 has been modified by an errata to match the
values as recorded in the IANA registry.

Fix our definitions to match the consensus values.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-26 13:58:37 +01:00
Michael Brown 31d4a7b8db [arm] Use correct DHCP client architecture values
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-26 13:43:33 +01:00
Michael Brown ee5dfb75aa [axge] Add driver for ASIX 10/100/1000 USB Ethernet NICs
Add driver for the AX88178A (USB2) and AX88179 (USB3) 10/100/1000
Ethernet NICs.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-26 12:52:06 +01:00
Michael Brown 8dd39b9572 [efi] Work around broken UEFI keyboard drivers
Some UEFI keyboard drivers are blissfully unaware of the existence of
either Ctrl key, and will report "Ctrl-<key>" as just "<key>".  This
breaks substantial portions of the iPXE user interface.

Work around these broken UEFI drivers by allowing "ESC <key>" to be
used as a substitute for "Ctrl-<key>".

Tested-by: Dreamcat4 <dreamcat4@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-25 23:28:41 +01:00
Michael Brown f42b2585fe [http] Ignore unrecognised "Connection" header tokens
Some HTTP/2 servers send the header "Connection: upgrade, close".  This
currently causes iPXE to fail due to the unrecognised "upgrade" token.

Fix by ignoring any unrecognised tokens in the "Connection" header.

Reported-by: Ján ONDREJ (SAL) <ondrejj@salstar.sk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-25 15:35:43 +01:00
Michael Brown 80dd6cbcc4 [lotest] Add option to use broadcast packets for loopback testing
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-23 14:17:47 +01:00
Michael Brown 231adda40f [netdevice] Fix failure path in register_netdev()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-23 14:17:47 +01:00
Michael Brown 56c0147deb [settings] Extend numerical setting tags to "unsigned long"
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-20 16:51:56 +01:00
Michael Brown 6d2bdc4ea3 [pci] Add support for PCI Enhanced Allocation
Some embedded devices have immovable BARs, which are described via a
PCI Enhanced Allocation capability.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-20 16:51:56 +01:00
Michael Brown 276d7c31c5 [undi] Work around broken HP EliteBook 745 G3 PXE ROM
Reported-by: Arturino Mazzei <mazzeia@hotmail.com>
Tested-by: Arturino Mazzei <mazzeia@hotmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-13 13:22:06 +01:00
Christian Hesse 858f56e68b [ath9k] Fix buffer overrun for ar9287
This backport is from linux kernel upstream commit 83d6f1f ("ath9k:
fix buffer overrun for ar9287").

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-12 14:55:13 +01:00
Michael Brown 601706688b [arm] Use CNTVCT_EL0 as profiling timestamp
The raw cycle counter at PMCCNTR_EL0 works in qemu but seems to always
read as zero on physical hardware (tested on Juno r1 and Cavium
ThunderX), even after ensuring that PMCR_EL0.E and PMCNTENSET_EL0.C
are both enabled.

Use CNTVCT_EL0 instead; this seems to count at a lower resolution
(tens of CPU cycles), but is usable for profiling.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-12 11:16:41 +01:00
Michael Brown 6164741f81 [efi] Guard against GetStatus() failing to return a NULL TX buffer
The UEFI specification requires the EFI_SIMPLE_NETWORK_PROTOCOL
GetStatus() method to set TxBuf to NULL if there are no transmit
buffers to recycle.

Some implementations (observed with Lan9118Dxe in EDK2) fill in TxBuf
only when there is a transmit buffer to recycle, which leads to large
numbers of "spurious TX completion" errors.

Work around this problem by initialising TxBuf to NULL before calling
the GetStatus() method.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-11 23:02:10 +01:00
Michael Brown 47931a4de5 [arm] Add optimised TCP/IP checksumming for 64-bit ARM
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-11 08:16:36 +01:00
Michael Brown 95716ece91 [arm] Add optimised string functions for 64-bit ARM
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-11 08:15:52 +01:00
Michael Brown a966570dce [libc] Avoid implicit assumptions about potentially-optimised memcpy()
Do not assume that an architecture-specific optimised memcpy() will
have the same properties as generic_memcpy() in terms of handling
overlapping regions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-09 16:23:38 +01:00
Michael Brown 45cd68c0fb [efi] Allow for building with older versions of elf.h system header
Reported-by: Ahmad Mahagna <ahmhad@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-09 16:18:10 +01:00
Michael Brown 17c6f322ee [arm] Add support for 64-bit ARM (Aarch64)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-08 00:20:20 +01:00
Michael Brown edea3a434c [arm] Split out 32-bit-specific code to arch/arm32
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-08 00:18:35 +01:00
Michael Brown 2a187f480e [arm] Avoid instruction references to symbols defined via ".equ"
When building for 64-bit ARM, some symbol references may be resolved
via an "adrp" instruction (to obtain the start of the 4kB page
containing the symbol) and a separate 12-bit offset.  For example
(taken from the GNU assembler documentation):

  adrp x0, foo
  ldr  x0, [x0, #:lo12:foo]

We occasionally refer to symbols defined via mechanisms that are not
directly visible to gcc.  For example:

  extern char some_magic_symbol[];
  __asm__ ( ".equ some_magic_symbol, some_magic_expression" );

The subsequent use of the ":lo12:" prefix on such magically-defined
symbols triggers an assertion failure in the assembler.

This problem seems to affect only "private_key_len" in the current
codebase.  Fix by storing this value as static data; this avoids the
need to provide the value as a literal within the instruction stream,
and so avoids the problematic use of the ":lo12:" prefix.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-08 00:08:48 +01:00
Michael Brown 1a16f67a28 [arm] Add support for 32-bit ARM
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-06 12:08:44 +01:00
Michael Brown 49a5bcfba6 [bitops] Fix typo in test case
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-05 23:42:57 +01:00
Michael Brown 67f539fa80 [libgcc] Provide __divmoddi4()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-05 23:42:57 +01:00
Michael Brown a5885fbc19 [legacy] Fix building with GCC 6
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-04 16:01:33 +01:00
Michael Brown 63037bdce4 [ath] Fix building with GCC 6
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-04 16:01:33 +01:00
Michael Brown 08230599ef [golan] Fix building with GCC 6
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-04 16:01:32 +01:00
Michael Brown 76ec2a0540 [skge] Fix building with GCC 6
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-04 16:01:32 +01:00
Michael Brown 65b32a0b70 [sis190] Fix building with GCC 6
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-04 16:01:32 +01:00
Vinson Lee e2f14c2f8c [mucurses] Fix GCC 6 nonnull-compare errors
Remove null checks for arguments declared as nonnull.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-04 16:01:32 +01:00
Michael Brown 57d0ea7c46 [efi] Generalise EFI entropy generation to non-x86 CPUs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-04 14:34:24 +01:00
Michael Brown 757ab98381 [efi] Use a timer event to generate the currticks() timer
We currently use the EFI_CPU_ARCH_PROTOCOL's GetTimerValue() method to
generate the currticks() timer, calibrated against a 1ms delay from
the boot services Stall() method.

This does not work on ARM platforms, where GetTimerValue() is an empty
stub which just returns EFI_UNSUPPORTED.

Fix by instead creating a periodic timer event, and using this event
to increment a current tick counter.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-04 13:38:33 +01:00
Michael Brown 1e066431a4 [tcpip] Do not fall back to using unoptimised TCP/IP checksumming
Require architecture-specific code to make a deliberate choice to use
the unoptimised generic_tcpip_continue_chksum() function, if there is
no optimised version available.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-04 13:38:25 +01:00
Michael Brown 9f91df422b [build] Remove unnecessary dependency on zlib
The dependency on zlib seems to have been introduced in commit 3dd7ce1
("[efi] Allow building with non-system libbfd") as an indirect
requirement of either libbfd or libiberty when building on Mac OS X.
Since we no longer use either of these libraries, remove the
unnecessary link against zlib.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-02 23:09:49 +01:00
Michael Brown efd5cf9aad [efi] Eliminate use of libbfd
Parse the intermediate ELF file directly instead of using libbfd, in
order to allow for cross-compiled ELF objects.

As a side bonus, this eliminates libbfd as a build requirement.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-02 22:35:14 +01:00
Michael Brown 71560d1854 [librm] Preserve FPU, MMX and SSE state across calls to virt_call()
The IBM Tivoli Provisioning Manager for OS Deployment (also known as
TPMfOSD, Rembo-ia32, or Rembo Auto-Deploy) has a serious bug in some
older versions (observed with v5.1.1.0, apparently fixed by v7.1.1.0)
which can lead to arbitrary data corruption.

As mentioned in commit 87723a0 ("[libflat] Test A20 gate without
switching to flat real mode"), Tivoli's NBP sets up a VMM and makes
calls to the PXE stack in VM86 mode.  This appears to be some kind of
attempt to run PXE API calls inside a sandbox.  The VMM is fairly
sophisticated: for example, it handles our attempts to switch into
protected mode and patches our GDT so that our protected-mode code
runs in ring 1 instead of ring 0.  However, it neglects to apply any
memory protections.  In particular, it does not enable paging and
leaves us with 4GB segment limits.  We can therefore trivially break
out of the sandbox by simply overwriting the GDT (or by modifying any
of Tivoli's VMM code or data structures).

When we attempt to execute privileged instructions (such as "lidt"),
the CPU raises an exception and control is passed to the Tivoli VMM.
This may result in a call to Tivoli's memcpy() function.

Tivoli's memcpy() function includes optimisations which use the SSE
registers %xmm0-%xmm3 to speed up aligned memory copies.

Unfortunately, the Tivoli VMM's exception handler does not save or
restore %xmm0-%xmm3.  The net effect of this bug in the Tivoli VMM is
that any privileged instruction (such as "lidt") issued by iPXE may
result in unexpected corruption of the %xmm0-%xmm3 registers.

Even more unfortunately, this problem affects the code path taken in
response to a hardware interrupt from the NIC, since that code path
will call PXENV_UNDI_ISR.  The net effect therefore becomes that any
NIC hardware interrupt (e.g. due to a received packet) may result in
unexpected corruption of the %xmm0-%xmm3 registers.

If a packet arrives while Tivoli is in the middle of using its
memcpy() function, then the unexpected corruption of the %xmm0-%xmm3
registers will result in unexpected corruption in the destination
buffer.  The net effect therefore becomes that any received packet may
result in a 16-byte block of corruption somewhere in any data that
Tivoli copied using its memcpy() function.

We can work around this bug in the Tivoli VMM by saving and restoring
the %xmm0-%xmm3 registers across calls to virt_call().  To work around
the problem, we need to save registers before attempting to execute
any privileged instructions, and ensure that we attempt no further
privileged instructions after restoring the registers.

This is less simple than it may sound.  We can use the "movups"
instruction to save and restore individual registers, but this will
itself generate an undefined opcode exception if SSE is not currently
enabled according to the flags in %cr0 and %cr4.  We can't access %cr0
or %cr4 before attempting the "movups" instruction, because access a
control register is itself a privileged instruction (which may
therefore trigger corruption of the registers that we're trying to
save).

The best solution seems to be to use the "fxsave" and "fxrstor"
instructions.  If SSE is not enabled, then these instructions may fail
to save and restore the SSE register contents, but will not generate
an undefined opcode exception.  (If SSE is not enabled, then we don't
really care about preserving the SSE register contents anyway.)

The use of "fxsave" and "fxrstor" introduces an implicit assumption
that the CPU supports SSE instructions (even though we make no
assumption about whether or not SSE is currently enabled).  SSE was
introduced in 1999 with the Pentium III (and added by AMD in 2001),
and is an architectural requirement for x86_64.  Experimentation with
current versions of gcc suggest that it may generate SSE instructions
even when using "-m32", unless an explicit "-march=i386" or "-mno-sse"
is used to inhibit this.  It therefore seems reasonable to assume that
SSE will be supported on any hardware that might realistically be used
with new iPXE builds.

As a side benefit of this change, the MMX register %mm0 will now be
preserved across virt_call() even in an i386 build of iPXE using a
driver that requires readq()/writeq(), and the SSE registers
%xmm0-%xmm5 will now be preserved across virt_call() even in an x86_64
build of iPXE using the Hyper-V netvsc driver.

Experimentation suggests that this change adds around 10% to the
number of cycles required for a do-nothing virt_call(), most of which
are due to the extra bytes copied using "rep movsb".  Since the number
of bytes copied is a compile-time constant local to librm.S, we could
potentially reduce this impact by ensuring that we always copy a whole
number of dwords and so can use "rep movsl" instead of "rep movsb".

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-02 14:02:31 +01:00
Michael Brown fe62f3c831 [tg3] Fix _tg3_flag() for 64-bit builds
Commit 86f96a4 ("[tg3] Remove x86-specific inline assembly")
introduced a regression in _tg3_flag() in 64-bit builds, since any
flags in the upper 32 bits of a 64-bit unsigned long would be
discarded when truncating to a 32-bit int.

Debugged-by: Shane Thompson <shane.thompson@aeontech.com.au>
Tested-by: Shane Thompson <shane.thompson@aeontech.com.au>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-02 13:25:56 +01:00
Michael Brown 2d42d3cff6 [librm] Reduce real-mode stack consumption in virt_call()
Some PXE NBPs are known to make PXE API calls with very little space
available on the real-mode stack.  For example, the Rembo-ia32 NBP
from some versions of IBM's Tivoli Provisioning Manager for Operating
System Deployment (TPMfOSD) will issue calls with the real-mode stack
placed at 0000:03d2; this is at the end of the interrupt vector table
and leaves only 498 bytes of stack space available before overwriting
the hardware IRQ vectors.  This limits the amount of state that we can
preserve before transitioning to protected mode.

Work around these challenging conditions by preserving everything
other than the initial register dump in a temporary static buffer
within our real-mode data segment, and copying the contents of this
buffer to the protected-mode stack.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-29 11:48:39 +01:00
Michael Brown b696a5063e [image] Skip misleading "format not recognised" error message
Return success (rather than failure) after an image format has been
correctly identified.

This has no practical effect, since the return value from
image_probe() is deliberately never used, but avoids a somewhat
surprising and misleading "format not recognised" error message when
debugging is enabled.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-28 12:12:50 +01:00
Michael Brown 55e409b14f [libgcc] Provide symbol to handle gcc's implicit calls to memset()
On some architectures (such as ARM), gcc will insert implicit calls to
memset().  Handle these using the same mechanism as for the implicit
calls to memcpy() used by x86.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-20 16:46:24 +01:00
Michael Brown 91aa188fbb [libc] Allow CPU architectures to use unoptimised string functions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-19 16:30:49 +01:00
Michael Brown 40a8a5294c [ethernet] Make LACP support configurable at build time
Add a build configuration option NET_PROTO_LACP to control whether or
not LACP support is included for Ethernet devices.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-18 10:08:46 +01:00
Ladi Prosek 988243c93f [virtio] Add virtio-net 1.0 support
This commit makes virtio-net support devices with VEN 0x1af4 and DEV
0x1041, which is how non-transitional (modern-only) virtio-net devices
are exposed on the PCI bus.

Transitional devices supporting both the old 0.9.5 and new 1.0 version
of the virtio spec are driven using the new protocol.  Legacy devices
are driven using the old protocol, same as before this commit.

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-15 17:43:07 +01:00
Ladi Prosek 8a055a2a70 [virtio] Add virtio 1.0 PCI support
This commit adds support for driving virtio 1.0 PCI devices.  In
addition to various helpers, a number of vpm_ functions are introduced
to be used instead of their legacy vp_ counterparts when accessing
virtio 1.0 (aka modern) devices.

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-15 17:41:26 +01:00
Ladi Prosek 7b499f849e [virtio] Add virtio 1.0 constants and data structures
Virtio 1.0 introduces new constants and data structures, common to all
devices as well as specific to virtio-net.  This commit adds a subset
of these to be able to drive the virtio-net 1.0 network device.

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-15 17:28:06 +01:00
Ladi Prosek 2379494918 [pci] Add pci_find_next_capability()
PCI devices may support more capabilities of the same type (for
example PCI_CAP_ID_VNDR) and there was no way to discover all of them.
This commit adds a new API pci_find_next_capability which provides
this functionality.  It would typically be used like so:

  for (pos = pci_find_capability(pci, PCI_CAP_ID_VNDR);
       pos > 0;
       pos = pci_find_next_capability(pci, pos, PCI_CAP_ID_VNDR)) {
    ...
  }

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-15 17:27:35 +01:00
Michael Brown 5e5450c2d0 [comboot] Support COMBOOT in 64-bit builds
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-15 15:31:36 +01:00
Suresh Sundriyal 4afb758423 [pool] Fix check for reopenable pooled connections
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-12 14:18:17 +01:00
Wissam Shoukair 0eea8b5c3b [golan] Add missing iounmap()
Signed-off-by: Wissam Shoukair <wissams@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-12 13:40:50 +01:00
Wissam Shoukair ffd959a1d6 [mlx_icmd] Fix compilation error in GCC versions newer than 4.6.4
Signed-off-by: Wissam Shoukair <wissams@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-12 13:38:10 +01:00
Michael Brown 5238c85b62 [efi] Work around broken EFI HII specification
The EFI_HII_CONFIG_ACCESS_PROTOCOL's ExtractConfig() method is passed
a request string which includes the parameters being queried plus an
apparently meaningless blob of information (the ConfigHdr), and is
expected to include this same meaningless blob of information in the
results string.

Neither the specification nor the existing EDK2 code (including the
nominal reference implementation in the DriverSampleDxe driver)
provide any reason for the existence of this meaningless blob of
information.  It appears to be consumed in its entirety by the
EFI_HII_CONFIG_ROUTING_PROTOCOL, and to contain zero bits of
information by the time it reaches an EFI_HII_CONFIG_ACCESS_PROTOCOL
instance.  It would potentially allow for multiple configuration data
sets to be handled by a single EFI_HII_CONFIG_ACCESS_PROTOCOL
instance, in a style alien to the rest of the UEFI specification
(which implicitly assumes that the instance pointer is always
sufficient to uniquely identify the instance).

iPXE currently handles this by simply copying the ConfigHdr from the
request string to the results string, and otherwise ignoring it.  This
approach is also used by some code in EDK2, such as OVMF's PlatformDxe
driver.

As of EDK2 commit 8a45f80 ("MdeModulePkg: Make HII configuration
settings available to OS runtime"), this causes an assertion failure
inside EDK2.  The failure arises when iPXE is handled a NULL request
string, and responds (as per the specification) with a results string
including all settings.  Since there is no meaningless blob to copy
from the request string, there is no corresponding meaningless blob in
the results string.  This now causes an assertion failure in
HiiDatabaseDxe's HiiConfigRoutingExportConfig().

The same failure does not affect the OVMF PlatformDxe driver, which
simply passes the request string to the HII BlockToConfig() utility
function.  The BlockToConfig() function returns EFI_INVALID_PARAMETER
when passed a null request string, and PlatformDxe propagates this
error directly to the caller.

Fix by matching the behaviour of OVMF's PlatformDxe driver: explicitly
return EFI_INVALID_PARAMETER if the request string is NULL or empty.
This violates the specification (insofar as it is feasible to
determine what the specification actually requires), but causes
correct behaviour with the EDK2 codebase.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-12 12:24:14 +01:00