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

5709 Commits

Author SHA1 Message Date
Michael Brown 1e4a3f5bab [tls] Support RFC5746 secure renegotiation
Support renegotiation with servers supporting RFC5746.  This allows
for the use of per-directory client certificates.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-07-04 19:54:34 +01:00
Michael Brown c20da4fc5c [mucurses] Avoid potential division by zero
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-07-04 12:51:53 +01:00
Michael Brown 8e48d0df6b [usb] Use non-zero language ID to retrieve strings
We currently use a zero language ID to retrieve strings such as the
ECM/NCM MAC address.  This works on most hardware devices, but is
known to fail on some software emulated CDC-NCM devices.

Fix by using the first supported language ID, falling back to English
(0x0409) if any error occurs when fetching the list of supported
languages.  This matches the behaviour of the Linux kernel.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-07-03 13:38:55 +01:00
Michael Brown 1e5c5a2163 [exanic] Add driver for Exablaze ExaNIC cards
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-24 19:17:55 +01:00
Michael Brown 14e3b4b29a [crypto] Expose pem_asn1() for use with non-image data
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-20 10:14:07 +01:00
Michael Brown b506528c1e [crypto] Provide asn1_built() to construct a cursor from a builder
Our ASN.1 parsing code uses a struct asn1_cursor, while the object
construction code uses a struct asn1_builder.  These structures are
identical apart from the const modifier applied to the data pointer in
struct asn1_cursor.

Provide asn1_built() to safely typecast a struct asn1_builder to a
struct asn1_cursor, allowing constructed objects to be passed to
functions expecting a struct asn1_cursor.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-20 09:49:00 +01:00
Michael Brown e5bfa107ba [crypto] Expose asn1_grow()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-20 09:49:00 +01:00
Michael Brown 5b608bbfe0 [crypto] Expose RSA_CTX_SIZE constant
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-20 09:49:00 +01:00
Michael Brown a6a5825f8d [cpuid] Allow input %ecx value to be specified
For some CPUID leaves (e.g. %eax=0x00000004), the result depends on
the input value of %ecx.  Allow this subfunction number to be
specified as a parameter to the cpuid() wrapper.

The subfunction number is exposed via the ${cpuid/...} settings
mechanism using the syntax

  ${cpuid/<subfunction>.0x40.<register>.<function>}

e.g.

  ${cpuid/0.0x40.0.0x0000000b}
  ${cpuid/1.0x40.0.0x0000000b}

to retrieve the CPU topology information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-16 01:17:48 +01:00
Michael Brown c8cb867d65 [ecm] Display invalid MAC address strings in debug messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-14 17:40:05 +01:00
Michael Brown 7c395b0e21 [build] Use -no-pie on newer versions of gcc
Some distributions patch gcc to generate position independent
executables by default.  We currently include a workaround to check
for this and to add -fno-PIE -nopie to CFLAGS if required.

Newer patched versions of gcc require -fno-PIE -no-pie instead.  Check
for both variants.

Reported-by: Nathan Rennie-Waldock <nathan.renniewaldock@gmail.com>
Originally-fixed-by: Markos Chandras <mchandras@suse.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-14 12:33:16 +01:00
Mika Tiainen 62573b99cc [intel] Add INTEL_NO_PHY_RST for I219-V
Fix booting on HP EliteBook 820 G3.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-14 12:22:08 +01:00
Michael Brown 63113f591f [usb] Allow for USB network devices with no interrupt endpoint
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-14 12:14:54 +01:00
Michael Brown 84e25513b1 [hdprefix] Avoid attempts to read beyond the end of the disk
When booting from a hard disk image (e.g. bin/ipxe.usb) within an
emulator such as QEMU, the disk may not exist beyond the end of the
image.  Limit all reads to the length of the image to avoid spurious
errors when loading the iPXE image.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-14 12:14:54 +01:00
Michael Brown 1fdf4dddbd [syslog] Handle backspace characters
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-13 11:54:41 +01:00
Michael Brown 356f6c1b64 [acpi] Expose ACPI tables via settings mechanism
Allow values to be read from ACPI tables using the syntax

  ${acpi/<signature>.<index>.0.<offset>.<length>}

where <signature> is the ACPI table signature as a 32-bit hexadecimal
number (e.g. 0x41504093 for the 'APIC' signature on the MADT), <index>
is the index into the array of tables matching this signature,
<offset> is the byte offset within the table, and <length> is the
field length in bytes.

Numeric values are returned in reverse byte order, since ACPI numeric
values are usually little-endian.

For example:

  ${acpi/0x41504943.0.0.0.0}           - entire MADT table in raw hex
  ${acpi/0x41504943.0.0.0x0a.6:string} - MADT table OEM ID
  ${acpi/0x41504943.0.0.0x24.4:uint32} - local APIC address

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-23 18:48:06 +01:00
Michael Brown 993fd2b451 [efi] Provide access to ACPI tables
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-23 18:48:02 +01:00
Michael Brown 933e6dadc0 [acpi] Make acpi_find_rsdt() a per-platform method
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-23 18:34:39 +01:00
Michael Brown ee9897fe64 [settings] Extend numerical setting tags to 64 bits
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-22 13:54:13 +01:00
Michael Brown 2f12690455 [tls] Keep cipherstream window open until TLS negotiation is complete
When performing a SAN boot, the plainstream window size will be zero
(since this is the mechanism used internally to indicate that no data
should be fetched via the initial request).  This zero value currently
propagates to the advertised TCP window size, which prevents the TLS
negotiation from completing.

Fix by ensuring that the cipherstream window is held open until TLS
negotiation is complete, and only then falling back to passing through
the plainstream window size.

Reported-by: John Wigley <johnwigley#ipxe@acorna.co.uk>
Tested-by: John Wigley <johnwigley#ipxe@acorna.co.uk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-22 13:17:23 +01:00
Michael Brown de37652044 [efi] Prevent EFI code from being linked in to non-EFI builds
Ensure that efi_systab is an undefined symbol in non-EFI builds.  In
particular, this prevents users from incorrectly enabling IMAGE_EFI in
a BIOS build of iPXE.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-19 12:21:18 +01:00
Michael Brown 7457bfc5b2 [xen] Provide 18 4kB receive buffers to work around xen-netback bug
The Xen network backend (xen-netback) suffered from a regression
between upstream Linux kernels 3.18 and 4.2 inclusive, which would
cause packet reception to fail unless at least 18 receive buffers were
available.  This bug was fixed in kernel commit 1d5d485 ("xen-netback:
require fewer guest Rx slots when not using GSO").

Work around this bug in affected versions of xen-netback by providing
the requisite 18 receive buffers.

Reported-by: Taylor Schneider <tschneider@live.com>
Tested-by: Taylor Schneider <tschneider@live.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-19 02:56:53 +01:00
Michael Brown a19ac24971 [iscsi] Fix iBFT when no explicit initiator name setting exists
Commit 7cfdd76 ("[block] Describe all SAN devices via ACPI tables")
changed the definition of the iSCSI initiator IQN in the iBFT to
represent a common initiator IQN used for all iSCSI sessions, and
attempted to calculate this common initiator IQN by fetching the
common ${initiator-iqn} setting.

This fails when no explicit ${initiator-iqn} has been specified
(i.e. when an initiator IQN has instead been constructed from either
the hostname or system UUID), and results in an empty initiator IQN in
the iBFT.

Fix by using the initiator IQN of an arbitrary iSCSI session
present in the iBFT.

Debugged-by: Tal Aloni <tal.aloni.il@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-10 16:01:47 +01:00
Michael Brown 785389c2ba [iscsi] Always send FirstBurstLength parameter
As of kernel 4.11, the LIO target will propose a value for
FirstBurstLength if the initiator did not do so.  This is entirely
redundant in our case, since FirstBurstLength is defined by RFC 3720
to be

  "Irrelevant when: ( InitialR2T=Yes and ImmediateData=No )"

and we already enforce both InitialR2T=Yes and ImmediateData=No in our
initial proposal.  However, LIO (arguably correctly) complains when we
do not respond to its redundant proposal of an already-irrelevant
value.

Fix by always proposing the default value for FirstBurstLength.

Debugged-by: Patrick Seeburger <info@8bit.de>
Tested-by: Patrick Seeburger <info@8bit.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-03 13:01:11 +01:00
Michael Brown 17887f87b7 [efi] Standardise PCI debug messages
Use the PCI bus:dev.fn address in debug messages, falling back to the
EFI handle name only if we do not yet have enough information to
determine the bus:dev.fn address.

Include the vendor and device IDs in debug messages when no suitable
driver is found, to match the diagnostics available in a BIOS
environment.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-05-01 14:01:54 +01:00
Michael Brown b91cc983da [hyperv] Cope with Windows Server 2016 enlightenments
An "enlightened" external bootloader (such as Windows Server 2016's
winload.exe) may take ownership of the Hyper-V connection before all
INT 13 operations have been completed.  When this happens, all VMBus
devices are implicitly closed and we are left with a non-functional
network connection.

Detect when our Hyper-V connection has been lost (by checking the
SynIC message page MSR).  Reclaim ownership of the Hyper-V connection
and reestablish any VMBus devices, without disrupting any existing
iPXE state (such as IPv4 settings attached to the network device).

Windows Server 2016 will not cleanly take ownership of an active
Hyper-V connection.  Experimentation shows that we can quiesce by
resetting only the SynIC message page MSR; this results in a
successful SAN boot (on a Windows 2012 R2 physical host).  Choose to
quiesce by resetting (almost) all MSRs, in the hope that this will be
more robust against corner cases such as a stray synthetic interrupt
occurring during the handover.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-28 16:20:47 +01:00
Michael Brown 276d618ca9 [hyperv] Remove redundant return status code from mapping functions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-28 16:20:35 +01:00
Michael Brown a0f6e75532 [hyperv] Do not fail if guest OS ID MSR is already set
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-26 20:15:39 +01:00
Michael Brown 648657b776 [block] Provide abstraction to allow system to be quiesced
When performing a SAN boot via INT 13, there is no way for the
operating system to indicate that it has finished using the INT 13 SAN
device.  We therefore have no opportunity to clean up state before the
loaded operating system's native drivers take over.  This can cause
problems when booting Windows, which tends not to be forgiving of
unexpected system state.

Windows will typically write a flag to the SAN device as the last
action before transferring control to the native drivers.  We can use
this as a heuristic to bring the system to a quiescent state (without
performing a full shutdown); this provides us an opportunity to
temporarily clean up state that could otherwise prevent a successful
Windows boot.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-26 20:15:39 +01:00
Michael Brown dd976cb50d [block] Provide sandev_read() and sandev_write() as global symbols
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-26 20:15:39 +01:00
Michael Brown 2d79b20f2a [intel] Do not enable ASDE on i350 backplane NIC
On most Intel NICs, Auto-Speed Detection Enable (ASDE) can be used to
automatically detect the correct link speed by sampling the link using
the internal PHY.  This feature is automatically inhibited when not
appropriate for the physical link (e.g. when using internal SerDes
mode on the 8254x).

On the i350 datasheet ASDE is a reserved bit, but the relevant
auto-speed detection hardware appears still to be present.  However,
enabling ASDE on the i350 1000BASE-KX backplane NIC seems to cause an
immediate link failure.  It is possible that the auto-speed detection
hardware is still present, is not connected to a physical link, and is
not inhibited from being applied in this mode.

Work around this problem by adding an INTEL_NO_ASDE flag bit
(analogous to INTEL_NO_PHY_RST), and applying this for the i350
backplane NIC.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-16 21:37:41 +01:00
Michael Brown e6616da8b8 [intel] Show original CTRL and STATUS values in debugging output
In situations where iPXE fails to reach link-up as expected, it is
useful to know the original values of the CTRL and STATUS registers
prior to our reset attempt.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-14 10:09:57 +01:00
Michael Brown 84d406ccf4 [block] Allow use of a non-default EFI SAN boot filename
Some older operating systems (e.g. RHEL6) use a non-default filename
on the root disk and rely on setting an EFI variable to point to the
bootloader.  This does not work when performing a SAN boot on a
machine where the EFI variable is not present.

Fix by allowing a non-default filename to be specified via the
"sanboot --filename" option or the "san-filename" setting.  For
example:

  sanboot --filename \efi\redhat\grub.efi \
          iscsi:192.168.0.1::::iqn.2010-04.org.ipxe.demo:rhel6

or

  option ipxe.san-filename code 188 = string;
  option ipxe.san-filename "\\efi\\redhat\\grub.efi";
  option root-path "iscsi:192.168.0.1::::iqn.2010-04.org.ipxe.demo:rhel6";

Originally-implemented-by: Vishvananda Ishaya Abrams <vish.ishaya@oracle.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-12 15:58:05 +01:00
Michael Brown a82f937485 [efi] Add efi_sprintf() and efi_vsprintf()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-12 15:01:56 +01:00
Michael Brown 6c7487d00d [efi] Fix typo in efi_acpi_table_protocol_guid
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-10 16:46:11 +01:00
Martin Habets f3788fa837 [sfc] Add driver for Solarflare SFC8XXX adapters
Signed-off-by: Martin Habets <mhabets@solarflare.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-10 16:17:08 +01:00
Michael Brown ffb5fe4ced [libc] Add stdbool.h standard header
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-04-10 16:12:53 +01:00
Adamczyk, Konrad fd6d1f4660 [thunderx] Use ThunderxConfigProtocol to obtain board configuration
Following changes were introduced:
 - added GetBgxProp and GetLmacProp methods to ThunderxConfigProtocol
 - replaced direct BOARD_CFG access with usage of introduced methods
 - removed redundant BOARD_CFG
 - changed GUID of ThunderxConfigProtocol, as this is not compatible
   with previous version
 - changed UINTN* to UINT64* buffer type to fix issue on 32-bit
   platforms with MAC address

This change allows us to avoid alignment of BOARD_CFG definitions
every time it changes in UEFI.

Signed-off-by: Konrad Adamczyk <konrad.adamczyk@cavium.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-31 09:08:13 +03:00
Michael Brown a66ac07165 [scsi] Retry TEST UNIT READY command
The TEST UNIT READY command is issued automatically when the device is
opened, and is not the result of a command being issued by the caller.
This is required in order that a permanent TEST UNIT READY failure can
be used to identify unusable paths in a multipath SAN device.

Since the TEST UNIT READY command is not part of the caller's command
issuing process, it is not covered by any external retry loops (such
as the main retry loop in sandev_command()).

We must therefore be prepared to retry the TEST UNIT READY command
within the SCSI layer itself.  We retry only the TEST UNIT READY
command so as not to multiply the number of potential retries for
normal commands (which are already retried by sandev_command()).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-29 12:42:36 +03:00
Michael Brown 2c056f02d0 [linux] Fix building with kernel 4.11 headers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-29 10:58:17 +03:00
Michael Brown 5f85cbb9ee [build] Avoid implicit-fallthrough warnings on GCC 7
Reported-by: Vinson Lee <vlee@freedesktop.org>
Reported-by: Liang Yan <lyan@suse.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-29 10:36:45 +03:00
Michael Brown 28e26dd250 [mucurses] Fix erroneous __nonnull attribute
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-29 10:35:05 +03:00
Michael Brown c8cae7cc17 [http] Notify data transfer interface when underlying connection is ready
HTTP implements xfer_window_changed() on the underlying server
connection using http_step(), which does not propagate the window
change notification to the data transfer interface.  This breaks the
multipath-capable SAN boot code, which relies on the window change
notification to discover that the HTTP block device is ready for
commands to be issued.

Fix by sending xfer_window_changed() in http_step() once the
underlying connection has been determined to be ready.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-28 23:40:52 +03:00
Michael Brown 2ace5196e5 [iscsi] Do not install iBFT when no iSCSI targets exist
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-28 20:45:23 +03:00
Michael Brown 7cfdd769aa [block] Describe all SAN devices via ACPI tables
Describe all SAN devices via ACPI tables such as the iBFT.  For tables
that can describe only a single device (i.e. the aBFT and sBFT), one
table is installed per device.  For multi-device tables (i.e. the
iBFT), all devices are described in a single table.

An underlying SAN device connection may be closed at the time that we
need to construct an ACPI table.  We therefore introduce the concept
of an "ACPI descriptor" which enables the SAN boot code to maintain an
opaque pointer to the underlying object, and an "ACPI model" which can
build tables from a list of such descriptors.  This separates the
lifecycles of ACPI descriptions from the lifecycles of the block
device interfaces, and allows for construction of the ACPI tables even
if the block device interface has been closed.

For a multipath SAN device, iPXE will wait until sufficient
information is available to describe all devices but will not wait for
all paths to connect successfully.  For example: with a multipath
iSCSI boot iPXE will wait until at least one path has become available
and name resolution has completed on all other paths.  We do this
since the iBFT has to include IP addresses rather than DNS names.  We
will commence booting without waiting for the inactive paths to either
become available or close; this avoids unnecessary boot delays.

Note that the Linux kernel will refuse to accept an iBFT with more
than two NIC or target structures.  We therefore describe only the
NICs that are actually required in order to reach the described
targets.  Any iBFT with at most two targets is therefore guaranteed to
describe at most two NICs.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-28 19:12:48 +03:00
Michael Brown 414b4fc9c5 [block] Ignore redundant xfer_window_changed() messages
For some block device protocols, the active path may continue to
receive xfer_window_changed() notifications during normal use.  These
currently result in the active path being erroneously closed.

Fix by ignoring any xfer_window_changed() messages if this path is
already the active path.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-28 19:02:38 +03:00
Michael Brown fa879f9f52 [linux] Use dummy SAN device
Allow for easier testing of SAN code by using the dummy SAN device by
default.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-28 17:34:41 +03:00
Michael Brown 539088a27b [block] Gracefully close SAN device if registration fails
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-27 16:57:40 +03:00
Michael Brown ee35b03583 [block] Retry reopening indefinitely for multipath devices
For multipath SAN devices, verify that the device is capable of being
opened (i.e. that all URIs are parseable and that at least one path is
alive) and thereafter retry indefinitely to reopen the device as
needed.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-27 15:41:22 +03:00
Michael Brown 164378fee6 [block] Add a small delay between attempts to reopen SAN targets
When all SAN targets are completely unreachable, there will be a
natural delay between reopening attempts due to the network connection
timeout on the unreachable targets.

However, some SAN targets may accept connections instantly and report
a temporary unavailability by e.g. failing the TEST UNIT READY
command.  If all targets are behaving this way then there will be no
natural delay, and we will attempt to saturate the network with
connection attempts.

Fix by introducing a small delay between attempts.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-27 15:41:22 +03:00
Michael Brown 6b385c9da3 [block] Allow SAN retry count to be reconfigured
Allow the SAN retry count to be configured via the ${san-retry}
setting, defaulting to the current value of 10 retries if not
specified.

Note that setting a retry count of zero is inadvisable, since iSCSI
targets in particular will often report spurious errors such as "power
on occurred" for the first few commands.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-27 15:41:22 +03:00
Michael Brown 6bd0060f26 [time] Add sleep_fixed() function to sleep without checking for Ctrl-C
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-27 15:41:22 +03:00
Michael Brown c73af29fe2 [int13con] Avoid overwriting random portions of SAN boot disks
The INT13 console type (CONSOLE_INT13) autodetects at initialisation
time a magic partition to be used for logging iPXE console output.  If
the INT13 drive number mapping is subsequently changed (e.g. because
iPXE was used to perform a SAN boot), then the console logging output
will be written to the incorrect disk.

Fix by recording the INT13 vector at initialisation time, and using
this original vector to emulate INT13 calls for all subsequent
accesses.  This should be robust against drive remapping performed
either by ourselves or by another bootloader (e.g. a chainloaded
undionly.kpxe which then performs a SAN boot).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-27 10:50:59 +03:00
Michael Brown ebceb8ad8a [int13] Improve geometry guessing for unaligned partitions
Some partition tables have partitions that are not aligned to a
cylinder boundary, which confuses the current geometry guessing logic.

Enhance the existing logic to ensure that we never reduce our guesses
for the number of heads or sectors per track, and add extra logic to
calculate the exact number of sectors per track if we find a partition
that starts within cylinder zero.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-26 21:03:50 +03:00
Michael Brown bb5a54b79a [block] Add basic multipath support
Add basic support for multipath block devices.  The "sanboot" and
"sanhook" commands now accept a list of SAN URIs.  We open all URIs
concurrently.  The first connection to become available for issuing
block device commands is marked as the active path and used for all
subsequent commands; all other connections are then closed.  Whenever
the active path fails, we reopen all URIs and repeat the process.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-26 16:06:02 +03:00
Michael Brown c212597336 [block] Add dummy SAN device
Add a dummy SAN device which allows the "sanhook" command to be tested
even when no SAN booting capability is present on the platform.  This
allows substantial portions of the SAN boot code to be run in Linux
under Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-26 16:03:29 +03:00
Michael Brown 6bc4a8ac91 [scsi] Avoid duplicate call to scsicmd_close() on TEST UNIT READY failure
When the TEST UNIT READY command receives an error response, the
shutdown of the command's block data interface will result in
scsidev_ready() closing the SCSI device.  This will subsequently
result in a duplicate call to scsicmd_close(), leading to an assertion
failure when list_del() is called for the second time.

Fix by removing the command from the list of outstanding commands
before shutting down the command's interfaces.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-26 11:29:18 +03:00
Michael Brown c13bf52509 [vxge] Fix use of stale I/O buffer on error path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-23 21:10:25 +02:00
Michael Brown b340971852 [iobuf] Increase minimum I/O buffer size to 128 bytes
The eIPoIB translation layer needs to translate outbound ARP packets
from Ethernet to IPoIB.  A 64-byte buffer (starting with the Ethernet
header) does not provide enough tailroom to expand to hold the two
20-byte IPoIB MAC addresses.  The result is that an UNDI API user will
be unable to send ARP packets.

We could potentially shuffle the packet contents to reuse the space
occupied by the stripped Ethernet link-layer header, but this would
add complexity.  Instead, fix by increasing the minimum allocation
size to 128 bytes.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-23 18:29:46 +02:00
Mike McCormack a317e9a310 [sky2] Use 32-bit read to read Y2_VAUX_AVAIL
B0_CTST is a 24bit register according to the vendor driver (sk98lin).
A 16bit read on B0_CTST will always return 0 for Y2_VAUX_AVAIL
(1<<16), so use a 32bit read when testing Y2_VAUX_AVAIL.

[This patch is copied directly from the Linux kernel tree.]

Signed-off-by: Mike McCormack <mikem@ring3k.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-23 17:54:03 +02:00
Michael Brown 19d3e966d9 [pcnet32] Eliminate redundant register read
The value of ( ( x & 0x0c00 ) | 0x0c00 ) is always 0x0c00 regardless
of the value of x, and so the read_csr() is redundant.  (There are no
read side effects for this register, according to the datasheet.)

This line of code originated in Linux kernel 2.3.19pre1 as

  a->write_csr(ioaddr, 80, a->read_csr(ioaddr, 80) | 0x0c00);

and was modified in kernel 2.3.41pre4 to read

  a->write_csr(ioaddr, 80, (a->read_csr(ioaddr, 80) & 0x0C00) | 0x0c00);

In the absence of commit messages, the intention of the code is
unclear.  However, the logic resulting in a fixed value of 0x0c00 has
remained unaltered for over 17 years, and can probably be assumed to
have the correct overall result.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-23 17:43:13 +02:00
Raed Salem 1ff1eebcf7 [golan] Bug fixes and improved paging allocation method
Updates:
- revert Support for clear interrupt via BAR

Signed-off-by: Raed Salem <raeds@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-23 16:03:40 +02:00
Michael Brown ce240c8c2d [rtl818x] Fix resource leak on error path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-23 11:40:36 +02:00
Michael Brown c90b4d82b7 [malloc] Track maximum heap usage
Track the current and maximum heap usage, and display the maximum
during shutdown when DEBUG=malloc is enabled.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 20:01:25 +02:00
Michael Brown f032556b15 [mucurses] Ensure SLK labels are always terminated
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 16:35:29 +02:00
Michael Brown 3870a7bde2 [sis190] Avoid NULL pointer dereference
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 16:12:56 +02:00
Michael Brown 99e1207a4d [w89c840] Avoid potential array overrun
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 15:59:27 +02:00
Michael Brown ad725fa7d9 [tlan] Guard against failure to identify chip
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 15:28:58 +02:00
Michael Brown dea5b74475 [hermon] Assert that mapping length is non-zero
An (impossible) mapping length of zero produces a negative bit shift,
which is technically undefined.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 15:20:14 +02:00
Michael Brown 0ced99e97c [arbel] Assert that mapping length is non-zero
An (impossible) mapping length of zero produces a negative bit shift,
which is technically undefined.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 15:18:54 +02:00
Michael Brown 7495813792 [video_subr] Use memmove() for overlapping memory copy
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 15:13:06 +02:00
Michael Brown 75bb948008 [tcp] Use correct length for memset()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 15:11:05 +02:00
Michael Brown 01496a5028 [xen] Use standard calling pattern for asprintf()
Our asprintf() implementation guarantees that strp will be NULL on
allocation failure, but this is not standard behaviour.  Detect errors
by checking for a negative return value instead of a NULL pointer.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 14:41:01 +02:00
Michael Brown 21d8624da8 [usb] Use correct length for memcpy()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 14:14:57 +02:00
Michael Brown 966a960a83 [pixbuf] Avoid potential division by zero
Avoid potential division by zero when performing the check against
multiplication overflow.  (Note that if the width is zero then there
can be no overflow anyway, so it is then safe to bypass the check.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 14:11:19 +02:00
Michael Brown 45f2265bfc [ath] Add missing break statements
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 11:52:09 +02:00
Michael Brown e846bd22c3 [block] Quell spurious Coverity size mismatch warning
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 11:45:28 +02:00
Michael Brown c26c1fd07c [infiniband] Return status code from ib_create_mi()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 11:18:23 +02:00
Michael Brown 39ef530088 [infiniband] Return status code from ib_create_cq() and ib_create_qp()
Any underlying errors arising during ib_create_cq() or ib_create_qp()
are lost since the functions simply return NULL on error.  This makes
debugging harder, since a debug-enabled build is required to discover
the root cause of the error.

Fix by returning a status code from these functions, thereby allowing
any underlying errors to be propagated.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 11:18:02 +02:00
Michael Brown e88e2a2965 [build] Avoid confusing sparse in single-argument DBG() macros
For visual consistency with surrounding lines, the definitions of
DBG_MORE(), DBG_PAUSE(), etc include an unnecessary ##__VA_ARGS__
argument which is always elided.  This confuses sparse, which
complains about DBG_MORE_IF() being called with more than one
argument.

Work around this problem by adding an unused variable argument list to
the single-argument macros DBG_MORE_IF() and DBG_PAUSE_IF().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 08:25:04 +02:00
Michael Brown 6124c0ebfa [xhci] Avoid accessing beyond end of endpoint context array
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 16:22:42 +02:00
Michael Brown 501fa53b25 [mucurses] Attempt to fix use of uninitialised buffer with strcat()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 15:30:05 +02:00
Michael Brown f17cf0ecd0 [http] Add missing check for memory allocation failure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 15:20:59 +02:00
Michael Brown 1ec2a60614 [eoib] Avoid passing a NULL I/O buffer to netdev_tx_complete_err()
Report errors in eoib_duplicate() via netdev_tx_err() rather than
netdev_tx_complete_err(), since netdev_tx_complete_err() accepts only
valid I/O buffers that are currently in the network device's transmit
queue.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 15:07:10 +02:00
Michael Brown 64de7dc7fd [slam] Avoid NULL pointer dereference in slam_pull_value()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 14:57:36 +02:00
Michael Brown 60561d0f3d [slam] Fix resource leak on error path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 14:53:13 +02:00
Michael Brown 8963193cda [hyperv] Fix resource leaks on error path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 14:51:03 +02:00
Michael Brown 2ae759219b [mucurses] Attempt to fix resource leaks
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 14:46:19 +02:00
Michael Brown 583d258b89 [mucurses] Attempt to fix keypress processing logic
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 14:42:02 +02:00
Michael Brown d29e2d551c [mucurses] Attempt to fix test for empty string
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 14:37:53 +02:00
Michael Brown 7b113bc744 [usb] Use correct length for memcpy()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 14:21:54 +02:00
Michael Brown d25e7daf47 [librm] Fail gracefully if asked to ioremap() a zero length
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 14:17:18 +02:00
Michael Brown 36cffe054d [crypto] Free correct pointer on the error path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 14:07:40 +02:00
Michael Brown 9b581158b5 [802.11] Remove redundant NULL pointer check after dereference
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 14:01:08 +02:00
Michael Brown eb6acabc8f [sis900] Remove extraneous memset() with incorrect length
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 13:55:04 +02:00
Michael Brown ae915aa5cc [qib7322] Use correct length for memset()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 13:51:56 +02:00
Michael Brown 6ee15cbac3 [linda] Use correct length for memset()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 13:50:51 +02:00
Michael Brown e500e5dd07 [nfs] Fix double free bug on error path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 13:46:26 +02:00
Michael Brown 91372d6dab [xfer] Ensure va_end() is called on failure path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 13:38:39 +02:00
Michael Brown a5affc832e [arbel] Avoid potential integer overflow when calculating memory mappings
When the area to be mapped straddles the 2GB boundary, the expression
(high+size) will overflow on the first loop iteration.  Fix by using
(end-size), which cannot underflow.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-21 12:01:55 +02:00