summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* [efi] Make EFI_HII_DATABASE_PROTOCOL optionalMichael Brown2014-05-201-1/+10
| | | | | | | | | | | | Some UEFI systems (observed with a Mac Pro) do not provide EFI_HII_DATABASE_PROTOCOL. We can continue to function without providing access to network device settings via HII, so make this protocol optional and fall back to simply not providing any HII protocols. Reported-by: Matt Woodward <pxematt@woodwardcc.com> Tested-by: Matt Woodward <pxematt@woodwardcc.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Make EFI_DEVICE_PATH_TO_TEXT_PROTOCOL optionalMichael Brown2014-05-201-9/+15
| | | | | | | | | | | Some UEFI systems (observed with a Mac Pro) do not provide EFI_DEVICE_PATH_TO_TEXT_PROTOCOL. Since we use this protocol only for debug messages, make it optional and fall back to printing the raw device path bytes. Reported-by: Matt Woodward <pxematt@woodwardcc.com> Tested-by: Matt Woodward <pxematt@woodwardcc.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Allow for optional protocolsMichael Brown2014-05-192-2/+20
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [nfs] Rewrite NFS URI handlingMarin Hannache2014-05-184-90/+228
| | | | | | | | Get the NFS URI manipulation code out of nfs_open.c. The resulting code is now much more readable. Signed-off-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Prevent strndup() from reading beyond the end of the stringMichael Brown2014-05-182-3/+21
| | | | | | | | | | | | strndup() may be called on a string which is not NUL-terminated. Use strnlen() instead of strlen() to ensure that we do not read beyond the end of such a string. Add self-tests for strndup(), including a test case with an unterminated string. Originally-fixed-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add self-tests for strdup()Michael Brown2014-05-181-0/+10
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [syslog] Strip invalid characters from hostnameMichael Brown2014-05-161-6/+31
| | | | | | | | | | Avoid generating syntactically invalid log messages by ensuring that invalid characters are not present in the hostname. In particular, ensure that any whitespace is stripped, since whitespace functions as a field separator for syslog messages. Reported-by: Alex Davies <adavies@jumptrading.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [intel] Increase receive ring fill levelMichael Brown2014-05-161-2/+2
| | | | | | | | | | | | | | | | | | As of commit d28bb51 ("[tcp] Defer sending ACKs until all received packets have been processed"), increasing the RX ring size will increase the number of received packets per transmitted ACK (since each poll will process up to one complete receive ring). Under KVM, this can make a substantial (up to ~200%) difference to the overall download speed, since transmissions are very expensive. Increase the ring fill level from four to eight packets: this increases the download speed by around 50% at a cost of around 8kB of heap space. Further speedups are possible by increasing the ring size further, but it would be preferable to find alternative methods which do not use noticeable amounts of heap space. Tested-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [nfs] Fix an invalid free() when loading a regular (non-symlink) fileMarin Hannache2014-05-161-3/+4
| | | | | | | | | An invalid free() was ironically introduced by fixing another invalid free in commit 7aa69c4 ("[nfs] Fix an invalid free() when loading a symlink"). Signed-off-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [lkrnprefix] Make real-mode setup code relocatableMichael Brown2014-05-151-3/+4
| | | | | | | | | | | | The bzImage boot protocol allows the real-mode code to be loaded at any segment within base memory. (The fact that both iPXE and recent versions of Syslinux will load the real-mode code at 1000:0000 is a coincidence; it is not guaranteed by the specification.) Fix by making the code relocatable. Reported-by: Andrew Stuart <andrew@shopcusa.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Merge util/geniso and util/genlisoChristian Hesse2014-05-143-137/+125Star
| | | | | | | | Rework geniso and genliso to provide a single merged utility for generating ISO images. Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [undi] Apply quota only to number of complete received packetsMichael Brown2014-05-141-4/+5
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Avoid errors when build directory is mounted via NFSMichael Brown2014-05-132-4/+4
| | | | | Reported-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [lkrnprefix] Function as a bzImage kernelMichael Brown2014-05-131-132/+83Star
| | | | | | | | | | | | | | | | | | | | The .lkrn prefix currently provides a zImage kernel with unused setup sectors and the whole iPXE binary placed within the "protected mode kernel" portion of the zImage. The work carried out years ago to create the .mrom format provides a mechanism allowing the iPXE binary to be split into a small real-mode header and a larger payload. This neatly matches the way that a bzImage is loaded: the "setup sectors" can contain the header and the "protected mode kernel" can contain the payload. This removes the size restrictions on an iPXE .lkrn image (and hence on derived image formats such as .iso). Also remove obsolete copyright information, since none of the original code or functionality now remains. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [tcp] Defer sending ACKs until all received packets have been processedMichael Brown2014-05-121-8/+25
| | | | | | | | | | | | | | | | | | | | | When running inside a virtual machine (or when using the UNDI driver), transmitting packets can be expensive. When we receive several packets in one poll (e.g. because a slow BIOS timer interrupt routine has caused us to fall behind in processing), we can safely send just a single ACK to cover all of the received packets. This reduces the time spent transmitting and allows us to clear the backlog much faster. Various RFCs (starting with RFC1122) state that there should be an ACK for at least every second segment. We choose not to enforce this rule. Under normal operation each poll should find at most one received packet, and we will then not delay any ACKs. We delay (i.e. omit) ACKs only when under sufficiently heavy load that we are finding multiple packets per poll; under these conditions it is important to clear the backlog quickly since any delay may lead to dropped packets. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [nfs] Fix an invalid free() when loading a symlinkMarin Hannache2014-05-121-0/+11
| | | | | Signed-off-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Fix version.o dependency upon git indexMichael Brown2014-05-121-1/+1
| | | | | | | | | | | | | | | | | | | Commit 8540300 ("[build] Disable ccache for all relevant build targets") attempted to generalise the rule for $(BIN)/version.o to $(BIN)/version.% in order to apply the dependency to all relevant build targets (debug objects, assembly listings, etc). This generalisation appears to work for the ccache override directives, but seems to cause make (at least, GNU make 4.0) to simply ignore the dependency upon the git index. Since version.c contains only some string constants, there is unlikely to be a substantive need for its debug objects, assembly listings, etc. Restore the previous form of the dependency and accept that hypothetical builds with e.g. DEBUG=version will not be handled correctly. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [intel] Exclude time spent in hypervisor from profilingMichael Brown2014-05-061-0/+3
| | | | | | | | When profiling, exclude any time spent inside the hypervisor responding to our MMIO accesses. This substantially reduces the variance accumulated on many other profilers. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [profile] Allow interrupts to be excluded from profiling resultsMichael Brown2014-05-044-17/+114
| | | | | | | | | Interrupt processing adds noise to profiling results. Allow interrupts (from within protected mode) to be profiled separately, with time spent within the interrupt handler being excluded from any other profiling currently in progress. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [undi] Place an upper limit on the number of PXENV_UNDI_ISR calls per pollMichael Brown2014-05-031-1/+5
| | | | | | | | | PXENV_UNDI_ISR calls may implicitly refill the underlying receive ring, and so could continue to retrieve packets indefinitely. Place an upper limit on the number of calls to PXENV_UNDI_ISR per call to undinet_poll(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [undi] Do not switch to real mode to check for NIC interruptMichael Brown2014-05-031-4/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [undi] Report any PXENV_UNDI_ISR errors via netdev_rx_err()Michael Brown2014-05-031-1/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [undi] Profile transmit and receive datapathsMichael Brown2014-05-031-1/+33
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [undi] Profile all PXE API callsMichael Brown2014-05-031-6/+97
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pxe] Work around missing PXENV_UNDI_OPEN only when necessaryMichael Brown2014-05-031-2/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pxe] Profile UNDI transmit datapathMichael Brown2014-05-031-0/+8
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pxe] Profile all PXE API callsMichael Brown2014-05-031-0/+49
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Add profiling self-tests for complete real_call and prot_call cyclesMichael Brown2014-05-031-0/+38
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [profile] Provide methods for profiling individual stages of operationsMichael Brown2014-05-032-11/+41
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Speed up protected-mode calls under KVMMichael Brown2014-05-021-19/+35
| | | | | | | | | | | | | When making a call from real mode to protected mode, we save and restore the global and interrupt descriptor table registers. The restore currently takes place after returning to real mode, which generates two EXCEPTION_NMIs and corresponding VM exits when running under KVM on an Intel CPU. Avoid the VM exits by restoring the descriptor table registers inside prot_to_real, while still running in protected mode. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Speed up real-to-protected mode transition under KVMMichael Brown2014-05-023-5/+22
| | | | | | | | | | | | | | | Ensure that all segment registers have zero in the low two bits before transitioning to protected mode. This allows the CPU state to immediately be deemed to be "valid", and eliminates the need for any further emulated instructions. Load the protected-mode interrupt descriptor table after switching to protected mode, since this avoids triggering an EXCEPTION_NMI and corresponding VM exit. This reduces the time taken by real_to_prot under KVM by around 50%. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Speed up protected-to-real mode transition under KVMMichael Brown2014-05-022-22/+20Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | On an Intel CPU supporting VMX, KVM will emulate instructions while the CPU state remains "invalid". In real mode, the CPU state is defined to be "invalid" if any segment register has a base which is not equal to (sreg<<4) or a limit which is not equal to 64kB. We don't actually use the base stored in the REAL_DS descriptor for any significant purpose. Change the base stored in this descriptor to be equal to (REAL_DS<<4). A segment register loaded with REAL_DS is then automatically valid in both real and protected modes. This allows KVM to stop emulating instructions much sooner. The only use of REAL_DS for memory accesses currently occurs in the indirect ljmp within prot_to_real. Change this to a direct ljmp, storing rm_cs in .text16 as part of the ljmp instruction. This removes the only memory access via REAL_DS (thereby allowing for the above descriptor base address hack), and also simplifies the ljmp instruction (which will still have to be emulated). Load the real-mode interrupt descriptor table register before switching to real mode, since this avoids triggering an EXCEPTION_NMI and corresponding VM exit. This reduces the time taken by prot_to_real under KVM by around 65%. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Add meaningful labels at section changesMichael Brown2014-05-021-12/+12
| | | | | | | | | | | | | The mode-transition code involves paths which switch back and forth between the .text and .text16 sections. At present, only the start of each function is labelled, which makes it difficult to decode addresses within the parts of the function existing in a different section. Add explicit labels at the start of each section change, so that addresses can be meaningfully decoded to the nearest label. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Add a profiling self-test for measuring mode transition timesMichael Brown2014-05-021-0/+77
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Print out profiling statistics after a successful test runMichael Brown2014-05-021-0/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pcbios] Do not switch to real mode to sleep the CPUMichael Brown2014-04-291-3/+3
| | | | | | | Now that we can handle interrupts while in protected mode, there is no need to switch to real mode just to halt the CPU. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pcbios] Do not switch to real mode to check for timer interruptMichael Brown2014-04-291-4/+4
| | | | | | | | | | | | | The currticks() function is called at least once per TCP packet, and so is performance-critical. Switching to real mode just to allow the timer interrupt to fire is expensive when running inside a virtual machine, and imposes a significant performance cost. Fix by enabling interrupts without switching to real mode. This results in an approximately 100% increase in download speed when running under KVM. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [comboot] Use built-in interrupt reflectorMichael Brown2014-04-294-134/+6Star
| | | | | | | | We now have the ability to handle interrupts while in protected mode, and so no longer need to set up a dedicated interrupt descriptor table while running COM32 executables. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Allow interrupts in protected modeMichael Brown2014-04-299-135/+322
| | | | | | | | When running in a virtual machine, switching to real mode may be expensive. Allow interrupts to be enabled while in protected mode and reflected down to the real-mode interrupt handlers. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Allow for a debug level of zeroMichael Brown2014-04-282-17/+4Star
| | | | | | | | Allow for an explicit debug level of zero, which will enable assertions and profiling (i.e. anything controlled by NDEBUG) without generating any debug messages. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [downloader] Profile receive datapathMichael Brown2014-04-281-0/+15
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [http] Profile receive datapathMichael Brown2014-04-281-0/+13
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [tcp] Profile transmit and receive datapathsMichael Brown2014-04-281-0/+20
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ipv4] Profile transmit and receive datapathsMichael Brown2014-04-281-0/+15
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Use genuine real mode to accelerate operation in virtual machinesMichael Brown2014-04-282-5/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently use flat real mode wherever real mode is required. This guarantees that we will not surprise some unsuspecting external caller which has carefully set up flat real mode by suddenly reducing the segment limits to 64kB. However, operating in flat real mode imposes a severe performance penalty in some virtualisation environments, since some CPUs cannot fully virtualise flat real mode and so the hypervisor must fall back to emulation. In particular, operating under KVM on a pre-Westmere Intel CPU will be at least an order of magnitude slower, to the point that there is a visible teletype effect when printing anything to the BIOS console. (Older versions of KVM used to cheat and ignore the "flat" part of flat real mode, which masked the problem.) Switch (back) to using genuine real mode with 64kB segment limits instead of flat real mode. Hopefully this won't break anything. Add an explicit switch to flat real mode before returning to the BIOS from the ROM prefix, since we know that a PMM BIOS will call the ROM initialisation point (and potentially the BEV) in flat real mode. As noted in previous commit messages, it is not possible to restore the real-mode segment limits after a transition to protected mode, since there is no way to know which protected-mode segment descriptor was originally used to initialise the limit portion of the segment register. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [intel] Push new RX descriptors in batchesMichael Brown2014-04-281-8/+13
| | | | | | | | | | | | Inside a virtual machine, writing the RX ring tail pointer may incur a substantial overhead of processing inside the hypervisor. Minimise this overhead by writing the tail pointer once per batch of descriptors, rather than once per descriptor. Profiling under qemu-kvm (version 1.6.2) shows that this reduces the amount of time taken to refill the RX descriptor ring by around 90%. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [intel] Profile common virtual machine operationsMichael Brown2014-04-281-0/+19
| | | | | | | | | Operations which are negligible on physical hardware (such as issuing a posted write to the transmit ring tail register) may involve substantial amounts of processing within the hypervisor if running in a virtual machine. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [netdevice] Profile common operationsMichael Brown2014-04-281-0/+16
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Add "profstat" command to display profiling statisticsMichael Brown2014-04-285-0/+132
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [profile] Add generic profiling infrastructureMichael Brown2014-04-2810-76/+591
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>