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

5795 Commits

Author SHA1 Message Date
Michael Brown 4350d26a04 [qib7322] Use standard readq() and writeq() implementations
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-12 17:51:59 +00:00
Michael Brown 5229662b7f [linda] Use standard readq() and writeq() implementations
This driver is the original source of the current readq() and writeq()
implementations for 32-bit iPXE.  Switch to using the now-centralised
definitions, to avoid including architecture-specific code in an
otherwise architecture-independent driver.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-12 17:42:30 +00:00
Michael Brown cc9f31ee0c [librm] Do not unconditionally preserve flags across virt_call()
Commit 196f0f2 ("[librm] Convert prot_call() to a real-mode near
call") introduced a regression in which any deliberate modification to
the low 16 bits of the CPU flags (in struct i386_all_regs) would be
overwritten with the original flags value at the time of entry to
prot_call().

The regression arose because the alignment requirements of the
protected-mode stack necessitated the insertion of two bytes of
padding immediately below the prot_call() return address.  The
solution chosen was to extend the existing "pushfl / popfl" pair to
"pushfw;pushfl / popfl;popfw".  The extra "pushfw / popfw" appears at
first glance to be a no-op, but fails to take into account the fact
that the flags restored by popfl may have been deliberately modified
by the protected-mode function.

Fix by replacing "pushfw / popfw" with "pushw %ss / popw %ss".  While
%ss does appear within struct i386_all_regs, any modification to the
stored value has always been ignored by prot_call() anyway.

The most visible symptom of this regression was that SAN booting would
fail since every INT 13 call would be chained to the original INT 13
vector.

Reported-by: Vishvananda Ishaya <vishvananda@gmail.com>
Reported-by: Jamie Thompson <forum.ipxe@jamie-thompson.co.uk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-12 12:39:17 +00:00
Michael Brown 64acfd9ddd [arp] Validate length of ARP packet
There is no practical way to generate an underlength ARP packet since
an ARP packet is always padded up to the minimum Ethernet frame length
(or dropped by the receiving Ethernet hardware if incorrectly padded),
but the absence of an explicit check causes warnings from some
analysis tools.

Fix by adding an explicit check on the I/O buffer length.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-12 01:24:03 +00:00
Michael Brown 11396473f5 [pixbuf] Check for unsigned integer overflow on multiplication
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-12 00:09:23 +00:00
Michael Brown 5a6ed90a00 [crypto] Allow for zero-length ASN.1 cursors
The assumption in asn1_type() that an ASN.1 cursor will always contain
a type byte is incorrect.  A cursor that has been cleanly invalidated
via asn1_invalidate_cursor() will contain a type byte, but there are
other ways in which to arrive at a zero-length cursor.

Fix by explicitly checking the cursor length in asn1_type().  This
allows asn1_invalidate_cursor() to be reduced to simply zeroing the
length field.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-11 16:58:51 +00:00
Michael Brown 05dcb07cb2 [tls] Avoid potential out-of-bound reads in length fields
Many TLS records contain variable-length fields.  We currently
validate the overall record length, but do so only after reading the
length of the variable-length field.  If the record is too short to
even contain the length field, then we may read uninitialised data
from beyond the end of the record.

This is harmless in practice (since the subsequent overall record
length check would fail regardless of the value read from the
uninitialised length field), but causes warnings from some analysis
tools.

Fix by validating that the overall record length is sufficient to
contain the length field before reading from the length field.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-11 16:09:40 +00:00
Michael Brown e303a6b387 [efi] Work around broken GetFontInfo() implementations
Several UEFI platforms are known to return EFI_NOT_FOUND when asked to
retrieve the system default font information via GetFontInfo().  Work
around these broken platforms by iterating over the glyphs to find the
maximum height used by a printable character.

Originally-fixed-by: Jonathan Dieter <jdieter@lesbg.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-10 18:09:59 +00:00
Michael Brown e44f6dcb89 [xsigo] Add support for Xsigo virtual Ethernet (XVE) EoIB devices
Add support for EoIB devices as implemented by Xsigo.  Based on the
public (but out-of-tree) Linux kernel drivers at

  https://oss.oracle.com/git/?p=linux-uek.git;a=log;h=v4.1.12-32.2.1

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-09 08:46:24 +00:00
Michael Brown 3144e4fb64 [eoib] Support non-FullMember gateway devices
Some EoIB implementations utilise an EoIB-to-Ethernet gateway device
that does not perform a FullMember join to the multicast group for the
EoIB broadcast domain.  This has various exciting side-effects, such
as requiring every EoIB node to send every broadcast packet twice.

As an added bonus, the gateway may also break the EoIB MAC address to
GID mapping protocol by sending Ethernet-sourced packets from the
wrong QPN.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-09 08:43:40 +00:00
Michael Brown 1a9ed68cbb [eoib] Allow the multicast group to be forcefully created
Some EoIB implementations require each individual EoIB node to create
the multicast group for the EoIB broadcast domain.

It is left as an exercise for the interested reader to determine how
such an implementation might ever allow the parameters of such a
multicast group to be changed without requiring a simultaneous upgrade
of every driver on every operating system on every machine currently
attached to the fabric.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-09 08:43:40 +00:00
Michael Brown ecd93cfc11 [eoib] Silently ignore EoIB heartbeat packets
Some EoIB implementations transmit a vendor-proprietary heartbeat
packet on the same multicast group used to provide the EoIB broadcast
domain.

Silently ignore these heartbeat packets, to avoid cluttering up the
network interface error statistics.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-09 08:43:40 +00:00
Michael Brown 9154d7a65c [eoib] Add Ethernet over Infiniband (EoIB) driver
EoIB is a fairly simple protocol in which raw Ethernet frames
(excluding the CRC) are encapsulated within Infiniband Unreliable
Datagrams, with a four-byte fixed EoIB header (which conveys no actual
information).  The Ethernet broadcast domain is provided by a
multicast group, similar to the IPoIB IPv4 multicast group.

The mapping from Ethernet MAC addresses to Infiniband address vectors
is achieved by snooping incoming traffic and building a peer cache
which can then be used to map a MAC address into a port GID.  The
address vector is completed using a path record lookup, as for IPoIB.
Note that this requires every packet to include a GRH.

Add basic support for EoIB devices.  This driver is substantially
derived from the IPoIB driver.  There is currently no mechanism for
automatically creating EoIB devices.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-09 08:43:40 +00:00
Michael Brown 5bcaa1e4d4 [infiniband] Make IPoIB support configurable at build time
Add a build configuration option VNIC_IPOIB to control whether or not
IPoIB support is included for Infiniband devices.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-09 08:43:40 +00:00
Michael Brown 8290a10aba [ifmgmt] Include human-readable error message for configuration failure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 17:45:30 +00:00
Michael Brown 9939b704f1 [ipoib] Increase number of transmit work queue entries
Avoid running out of transmit work queue entries under heavy load.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 17:44:28 +00:00
Michael Brown b5aa51ac62 [ipoib] Resimplify test for received broadcast packets
Commit e62e52b ("[ipoib] Simplify test for received broadcast
packets") relies upon the multicast LID being present in the
destination address vector as passed to ipoib_complete_recv().
Unfortunately, this information is not present in many Infiniband
devices' completion queue entries.

Fix by testing instead for the presence of a multicast GID.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 17:43:26 +00:00
Michael Brown 076d772648 [infiniband] Retrieve GID flag from cached path entries
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 17:40:52 +00:00
Michael Brown 299fdabe48 [infiniband] Add "ibstat" command
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 17:38:06 +00:00
Michael Brown 6a3ffa0114 [infiniband] Assign names to queue pairs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 15:51:53 +00:00
Michael Brown 174bf6b569 [infiniband] Assign names to CMRC connections
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 15:51:19 +00:00
Michael Brown d3db00ecf9 [pcbios] Restrict external memory allocations to the low 4GB
When running the 64-bit BIOS version of iPXE, restrict external memory
allocations to the low 4GB to ensure that allocations (such as for
initrds) fall within our identity-mapped memory region, and will be
accessible to the potentially 32-bit operating system.

Move largest_memblock() back to memtop_umalloc.c, since this change
imposes a restriction that applies only to BIOS builds.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 13:25:09 +00:00
Michael Brown 5a7fd2cc90 [infiniband] Allow for the creation of multicast groups
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:23:30 +00:00
Michael Brown e62e52b2b9 [ipoib] Simplify test for received broadcast packets
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:23:30 +00:00
Michael Brown ffdf8ea757 [ipoib] Avoid unnecessary path record lookup for broadcast address
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:23:30 +00:00
Michael Brown 14ad9cbd67 [infiniband] Parse MLID, rate, and SL from multicast membership record
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:23:30 +00:00
Michael Brown c335f8eae4 [infiniband] Record multicast GID attachment as part of group membership
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:23:30 +00:00
Michael Brown 114a2f19a6 [infiniband] Do not use GRH for local paths
Avoid including an unnecessary GRH in packets sent to unicast
destinations within the local subnet.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:23:24 +00:00
Michael Brown bd1687465c [infiniband] Use correct transaction identifier in CM responses
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:08:58 +00:00
Michael Brown 8336186564 [infiniband] Use connection's local ID as debug message identifier
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:08:58 +00:00
Michael Brown 36c4779356 [infiniband] Use "%d" as format specifier for LIDs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:08:58 +00:00
Michael Brown 7aef4d4c94 [infiniband] Use "%#lx" as format specifier for queue pair numbers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:08:58 +00:00
Michael Brown d7794dcac7 [infiniband] Assign names to Infiniband devices for debug messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:08:58 +00:00
Michael Brown ff13eeb747 [infiniband] Add support for performing service record lookups
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:08:58 +00:00
Michael Brown 7544763626 [infiniband] Avoid multiple calls to ib_cmrc_shutdown()
When a CMRC connection is closed, the deferred shutdown process calls
ib_destroy_qp().  This will cause the receive work queue entries to
complete in error (since they are being cancelled), which will in turn
reschedule the deferred shutdown process.  This eventually leads to
ib_destroy_conn() being called on a connection that has already been
freed.

Fix by explicitly cancelling any pending shutdown process after the
shutdown process has completed.

Ironically, this almost exactly reverts commit 019d4c1 ("[infiniband]
Use a one-shot process for CMRC shutdown"); prior to the introduction
of one-shot processes the only way to achieve a one-shot process was
for the process to cancel itself.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 12:07:03 +00:00
Michael Brown 60e205a551 [infiniband] Remove concept of whole-device owner data
Remove the implicit assumption that the IPoIB protocol owns the whole
Infiniband device.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-07 21:04:40 +00:00
Michael Brown fcf3b03544 [netdevice] Refuse to create duplicate network device names
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-07 21:04:40 +00:00
Michael Brown 99b5216b1c [librm] Support ioremap() for addresses above 4GB in a 64-bit build
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-26 15:34:28 +00:00
Michael Brown 5bd8427d3d [ioapi] Split ioremap() out to a separate IOMAP API
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-26 15:33:40 +00:00
Michael Brown 6143057430 [librm] Add support for running in 64-bit long mode
Add support for running the BIOS version of iPXE in 64-bit long mode.
A 64-bit BIOS version of iPXE can be built using e.g.

  make bin-x86_64-pcbios/ipxe.usb
  make bin-x86_64-pcbios/8086100e.mrom

The 64-bit BIOS version should appear to function identically to the
normal 32-bit BIOS version.  The physical memory layout is unaltered:
iPXE is still relocated to the top of the available 32-bit address
space.  The code is linked to a virtual address of 0xffffffffeb000000
(in the negative 2GB as required by -mcmodel=kernel), with 4kB pages
created to cover the whole of .textdata.  2MB pages are created to
cover the whole of the 32-bit address space.

The 32-bit portions of the code run with VIRTUAL_CS and VIRTUAL_DS
configured such that truncating a 64-bit virtual address gives a
32-bit virtual address pointing to the same physical location.

The stack pointer remains as a physical address when running in long
mode (although the .stack section is accessible via the negative 2GB
virtual address); this is done in order to simplify the handling of
interrupts occurring while executing a portion of 32-bit code with
flat physical addressing via PHYS_CODE().

Interrupts may be enabled in either 64-bit long mode, 32-bit protected
mode with virtual addresses, 32-bit protected mode with physical
addresses, or 16-bit real mode.  Interrupts occurring in any mode
other than real mode will be reflected down to real mode and handled
by whichever ISR is hooked into the BIOS interrupt vector table.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-24 03:10:12 +00:00
Michael Brown e2cf3138f0 [librm] Rename prot_call() to virt_call()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-22 00:50:32 +00:00
Michael Brown 4c1f2486e6 [librm] Support userptr_t in 64-bit builds
In a 64-bit build, the entirety of the 32-bit address space is
identity-mapped and so any valid physical address may immediately be
used as a virtual address.  Conversely, a virtual address that is
already within the 32-bit address space may immediately be used as a
physical address.

A valid virtual address that lies outside the 32-bit address space
must be an address within .textdata, and so can be converted to a
physical address by adding virt_offset.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-21 11:37:37 +00:00
Michael Brown b6ebafe1bb [librm] Mark virt_offset, text16, data16, rm_cs, and rm_ds as constant
The physical locations of .textdata, .text16 and .data16 are constant
from the point of view of C code.  Mark the relevant variables as
constant to allow gcc to optimise out redundant reads.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-21 11:13:04 +00:00
Michael Brown 5fbfe50ccb [librm] Do not preserve flags unnecessarily
No callers of prot_to_phys, phys_to_prot, or intr_to_prot require the
flags to be preserved.  Remove the unnecessary pushfl/popfl pairs.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-21 01:01:28 +00:00
Michael Brown ea203e4fe1 [librm] Add phys_call() wrapper for calling code with physical addressing
Add a phys_call() wrapper function (analogous to the existing
real_call() wrapper function) for calling code with flat physical
addressing, and use this wrapper within the PHYS_CODE() macro.

Move the relevant functionality inside librm.S, where it more
naturally belongs.

The COMBOOT code currently uses explicit calls to _virt_to_phys and
_phys_to_virt.  These will need to be rewritten if our COMBOOT support
is ever generalised to be able to run in a 64-bit build.
Specifically:

  - com32_exec_loop() should be restructured to use PHYS_CODE()

  - com32_wrapper.S should be restructured to use an equivalent of
    prot_call(), passing parameters via a struct i386_all_regs

  - there appears to be no need for com32_wrapper.S to switch between
    external and internal stacks; this could be omitted to simplify
    the design.

For now, librm.S continues to expose _virt_to_phys and _phys_to_virt
for use by com32.c and com32_wrapper.S.  Similarly, librm.S continues
to expose _intr_to_virt for use by gdbidt.S.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-20 23:09:36 +00:00
Michael Brown a4923354e3 [build] Fix building on older versions of binutils
Some older versions of binutils have issues with both the use of
PROVIDE() and the interpretation of numeric literals within a section
description.

Work around these older versions by defining the required numeric
literals outside of any section description, and by automatically
determining whether or not to generate extra space for page tables
rather than relying on LDFLAGS.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-19 20:03:30 +00:00
Michael Brown 163f8acba0 [librm] Generate page tables for 64-bit builds
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-19 03:21:38 +00:00
Michael Brown d1562c38a6 [librm] Prepare for long-mode memory map
The bulk of the iPXE binary (the .textdata section) is physically
relocated at runtime to the top of the 32-bit address space in order
to allow space for an OS to be loaded.  The relocation is achieved
with the assistance of segmentation: we adjust the code and data
segment bases so that the link-time addresses remain valid.

Segmentation is not available (for normal code and data segments) in
long mode.  We choose to compile the C code with -mcmodel=kernel and
use a link-time address of 0xffffffffeb000000.  This choice allows us
to identity-map the entirety of the 32-bit address space, and to alias
our chosen link-time address to the physical location of our .textdata
section.  (This requires the .textdata section to always be aligned to
a page boundary.)

We simultaneously choose to set the 32-bit virtual address segment
bases such that the link-time addresses may simply be truncated to 32
bits in order to generate a valid 32-bit virtual address.  This allows
symbols in .textdata to be trivially accessed by both 32-bit and
64-bit code.

There is no (sensible) way in 32-bit assembly code to generate the
required R_X86_64_32S relocation records for these truncated symbols.
However, subtracting the fixed constant 0xffffffff00000000 has the
same effect as truncation, and can be represented in a standard
R_X86_64_32 relocation record.  We define the VIRTUAL() macro to
abstract away this truncation operation, and apply it to all
references by 32-bit (or 16-bit) assembly code to any symbols within
the .textdata section.

We define "virt_offset" for a 64-bit build as "the value to be added
to an address within .textdata in order to obtain its physical
address".  With this definition, the low 32 bits of "virt_offset" can
be treated by 32-bit code as functionally equivalent to "virt_offset"
in a 32-bit build.

We define "text16" and "data16" for a 64-bit build as the physical
addresses of the .text16 and .data16 sections.  Since a physical
address within the 32-bit address space may be used directly as a
64-bit virtual address (thanks to the identity map), this definition
provides the most natural access to variables in .text16 and .data16.
Note that this requires a minor adjustment in prot_to_real(), which
accesses .text16 using 32-bit virtual addresses.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-19 02:58:09 +00:00
Michael Brown bfe6e3e90e [relocate] Preserve page alignment during relocation
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-19 02:39:56 +00:00
Michael Brown 6eb1c927a3 [librm] Transition to protected mode within init_librm()
Long-mode operation will require page tables, which are too large to
sensibly fit in our .data16 segment in base memory.

Add a portion of init_librm() running in 32-bit protected mode to
provide access to high memory.  Use this portion of init_librm() to
initialise the .textdata variables "virt_offset", "text16", and
"data16", eliminating the redundant (re)initialisation currently
performed on every mode transition as part of real_to_prot().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-19 01:01:27 +00:00