aboutsummaryrefslogtreecommitdiff
path: root/src/arch/i386
AgeCommit message (Collapse)AuthorFilesLines
2024-01-14[build] Fix building with newer binutilsMichael Brown2-1/+2
Newer versions of the GNU assembler (observed with binutils 2.41) will complain about the ".arch i386" in files assembled with "as --64", with the message "Error: 64bit mode not supported on 'i386'". In files such as stack.S that contain no instructions to be assembled, the ".arch i386" is redundant and may be removed entirely. In the remaining files, fix by moving ".arch i386" below the relevant ".code16" or ".code32" directive, so that the assembler is no longer expecting 64-bit instructions to be used by the time that the ".arch i386" directive is encountered. Reported-by: Ali Mustakim <alim@forwardcomputers.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-06-30[build] Inhibit linker warnings about an implied executable stackGeert Stappers3-0/+3
Signed-off-by: Geert Stappers <stappers@stappers.it> Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-02-05[build] Allow for per-architecture unprefixed constant operand modifierMichael Brown1-0/+3
Over the years, the undocumented operand modifier used to produce the unprefixed constant values in __einfo_error() has varied from "%c0" to "%a0" in commit 1a77466 ("[build] Fix use of inline assembly on GCC 4.8 ARM64 builds") and back to "%c0" in commit 3fb3ffc ("[build] Fix use of inline assembly on GCC 8 ARM64 builds"), according to the evolving demands of the toolchain. LoongArch64 suffers from a similar issue: GCC 13 will allow either, but the currently released GCC 12 allows only the "%a0" form. Introduce a macro ASM_NO_PREFIX, defined in bits/compiler.h, to abstract away this difference and allow different architectures to use different operand modifiers. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-22[dhcp] Simplify platform-specific client architecture definitionsMichael Brown3-80/+20
Move the platform-specific DHCP client architecture definitions to header files of the form <ipxe/$(PLATFORM)/dhcparch.h>. This simplifies the directory structure and allows the otherwise unused arch/$(ARCH)/include/$(PLATFORM) to be removed from the include directory search path, which avoids the confusing situation in which a header file may potentially be accessed through more than one path. For Linux userspace binaries on any architecture, use the EFI values for that architecture by delegating to the EFI header file. This avoids the need to explicitly select values for Linux userspace binaries for each architecture. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-22[linux] Centralise the linker script for Linux binariesMichael Brown2-108/+2
Reduce duplication between i386 and x86_64 by providing a single shared linker script that both architectures can include. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-01-13[efi] Include Secure Boot Advanced Targeting (SBAT) metadatasbatMichael Brown2-0/+4
SBAT defines an encoding for security generation numbers stored as a CSV file within a special ".sbat" section in the signed binary. If a Secure Boot exploit is discovered then the generation number will be incremented alongside the corresponding fix. Platforms may then record the minimum generation number required for any given product. This allows for an efficient revocation mechanism that consumes minimal flash storage space (in contrast to the DBX mechanism, which allows for only a single-digit number of revocation events to ever take place across all possible signed binaries). Add SBAT metadata to iPXE EFI binaries to support this mechanism. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-03-02[build] Allow __asmcall to be used as a type attributeMichael Brown1-1/+1
The "used" attribute can be applied only to functions or variables, which prevents the use of __asmcall as a type attribute. Fix by removing "used" from the definition of __asmcall for i386 and x86_64 architectures, and adding explicit __used annotations where necessary. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-28[linux] Use host glibc system call wrappersMichael Brown4-80/+9
When building as a Linux userspace application, iPXE currently implements its own system calls to the host kernel rather than relying on the host's C library. The output binary is statically linked and has no external dependencies. This matches the general philosophy of other platforms on which iPXE runs, since there are no external libraries available on either BIOS or UEFI bare metal. However, it would be useful for the Linux userspace application to be able to link against host libraries such as libslirp. Modify the build process to perform a two-stage link: first picking out the requested objects in the usual way from blib.a but with relocations left present, then linking again with a helper object to create a standard hosted application. The helper object provides the standard main() entry point and wrappers for the Linux system calls required by the iPXE Linux drivers and interface code. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2021-02-04[build] Work around -fPIE patched versions of gcc on all architecturesMichael Brown1-16/+0
Several distributions include versions of gcc that are patched to create position-independent executables by default. These have caused multiple problems over the years: see e.g. commits fe61f6d ("[build] Fix compilation when gcc is patched to default to -fPIE -Wl,-pie"), 5de1346 ("[build] Apply the "-fno-PIE -nopie" workaround only to i386 builds"), 7c395b0 ("[build] Use -no-pie on newer versions of gcc"), and decee20 ("[build] Disable position-independent code for ARM64 EFI builds"). The build system currently attempts to work around these mildly broken patched versions of gcc for the i386 and arm64 architectures. This misses the relatively obscure bin-x86_64-pcbios build platform, which turns out to also require the same workaround. Attempt to preempt the next such required workaround by moving the existing i386 version to apply to all platforms and all architectures, unless -fpie has been requested explicitly by another Makefile (as is done by arch/x86_64/Makefile.efi). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-06-14[build] Use -no-pie on newer versions of gccMichael Brown1-3/+8
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>
2016-07-04[dhcp] Automatically generate vendor class identifier stringMichael Brown2-10/+0
The vendor class identifier strings in DHCP_ARCH_VENDOR_CLASS_ID are out of sync with the (correct) client architecture values in DHCP_ARCH_CLIENT_ARCHITECTURE. Fix by removing all definitions of DHCP_ARCH_VENDOR_CLASS_ID, and instead generating the vendor class identifier string automatically based on DHCP_ARCH_CLIENT_ARCHITECTURE and DHCP_ARCH_CLIENT_NDI. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-07-04[dhcp] Allow for variable encapsulation of architecture-specific optionsMichael Brown2-14/+12
DHCPv4 and DHCPv6 share some values in common for the architecture- specific options (such as the client system architecture type), but use different encapsulations: DHCPv4 has a single byte for the option length while DHCPv6 has a 16-bit field for the option length. Move the containing DHCP_OPTION() and related wrappers from the individual dhcp_arch.h files to dhcp.c, thus allowing for the architecture-specific values to be reused in dhcpv6.c. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-15[comboot] Support COMBOOT in 64-bit buildsMichael Brown10-1991/+0
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-22[gdb] Add support for x86_64Michael Brown3-210/+12
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-17[test] Move i386-specific tests to arch/i386/testsMichael Brown5-0/+347
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-16[hyperv] Use generic set_bit() functionMichael Brown1-23/+0
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-18[librm] Provide an abstraction wrapper for prot_callMichael Brown2-13/+7
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-18[librm] Convert prot_call() to a real-mode near callMichael Brown1-3/+0
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[librm] Discard argument as part of return from prot_call()Michael Brown1-3/+3
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[bios] Add bin-x86_64-pcbios build platformMichael Brown142-28193/+5
Move most arch/i386 files to arch/x86, and adjust the contents of the Makefiles and the include/bits/*.h headers to reflect the new locations. This patch makes no substantive code changes, as can be seen using a rename-aware diff (e.g. "git show -M5"). This patch does not make the pcbios platform functional for x86_64; it merely allows it to compile without errors. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[bios] Move isolinux definitions to Makefile.pcbiosMichael Brown2-22/+22
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[bios] Allow librm to be compiled for x86_64Michael Brown3-15/+30
This commit does not make librm functional for x86_64; it merely allows it to compile without errors. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[bios] Allow memmap.c to be compiled for x86_64Michael Brown1-1/+1
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[bios] Allow bios_console.c to be compiled for x86_64Michael Brown1-1/+1
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[bios] Allow bzimage.c to be compiled for x86_64Michael Brown1-3/+3
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[bios] Allow rtc_entropy.c to be compiled for x86_64Michael Brown1-16/+13
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[bios] Allow relocate.c to be compiled for x86_64Michael Brown1-12/+12
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[bios] Use size_t when casting _text16_memsz and _data16_memszMichael Brown2-6/+7
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[bios] Use intptr_t when casting .text16 function pointersMichael Brown9-32/+24
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-16[libc] Split rmsetjmp() and rmlongjmp() into a separate rmsetjmp.hMichael Brown7-25/+33
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-12[prefix] Pad .text16 and .data16 segment sizes at build timeMichael Brown2-10/+7
Commit c64747d ("[librm] Speed up real-to-protected mode transition under KVM") rounded down the .text16 segment address calculated in alloc_basemem() to a multiple of 64 bytes in order to speed up mode transitions under KVM. This creates a potential discrepancy between alloc_basemem() and free_basemem(), meaning that free_basemem() may free less memory than was allocated by alloc_basemem(). Fix by padding the calculated sizes of both .text16 and .data16 to a multiple of 64 bytes at build time. Debugged-by: Yossef Efraim <yossefe@mellanox.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-11[pxe] Clarify comments regarding shrinking of cached DHCP packetMichael Brown1-6/+9
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-12[i386] Add check_bios_interrupts() debug functionMichael Brown2-0/+28
Provide a debug function check_bios_interrupts() to look for changes to the interrupt vector table. This can be useful when investigating the behaviour (including crashes) of external PXE NBPs. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-11[pxe] Add debug message to display real-mode segment addressesMichael Brown1-0/+11
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-11[pxe] Colourise debug outputMichael Brown1-3/+3
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-06[romprefix] Report an optimistic runtime size estimateMichael Brown1-4/+16
Commit 5de45cd ("[romprefix] Report a pessimistic runtime size estimate") set the PCI3.0 "runtime size" field equal to the worst-case runtime size, on the basis that there is no guarantee that PMM allocation will succeed and hence no guarantee that we will be able to shrink the ROM image. On a PCI3.0 system where PMM allocation would succeed, this can cause the BIOS to unnecessarily refuse to initialise the iPXE ROM due to a perceived shortage of option ROM space. Fix by reporting the best-case runtime size via the PCI header, and checking that we have sufficient runtime space (if applicable). This allows iPXE ROMs to initialise on PCI3.0 systems that might otherwise fail due to a shortage of option ROM space. This may cause iPXE ROMs to fail to initialise on PCI3.0 systems where PMM is broken. (Pre-PCI3.0 systems are unaffected since there must already have been sufficient option ROM space available for the initialisation entry point to be called.) On balance, it seems preferable to avoid breaking "good" systems (PCI3.0 with working PMM) at the cost of potentially breaking "bad" systems (PCI3.0 with broken PMM). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-05[vmware] Expose GuestRPC mechanism in 64-bit buildsMichael Brown7-953/+0
The GuestRPC mechanism (used for VMWARE_SETTINGS and CONSOLE_VMWARE) does not use any real-mode code and so can be exposed in both 64-bit and 32-bit builds. Reported-by: Matthew Helton <mwhelton@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-12-23[bios] Add support for injecting keypressesMichael Brown1-38/+209
When USB network card drivers are used, the BIOS' legacy USB capability is necessarily disabled since there is no way to share the host controller between the BIOS and iPXE. Commit 3726722 ("[usb] Add basic support for USB keyboards") added support allowing a USB keyboard to be used within iPXE. However, external code such as a PXE NBP has no way to utilise this support, and so a USB keyboard cannot be used to control a PXE NBP loaded from a USB network card. Add support for injecting keypresses from any iPXE console into the BIOS keyboard buffer. This allows external code such as a PXE NBP to function with a USB keyboard even after the BIOS' legacy USB capability has been disabled. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-12-07[efi] Add %.usb target for building EFI-bootable USB (or other) disk imagesMichael Brown1-0/+4
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-11-17[comboot] Reset console before starting COMBOOT executableMichael Brown2-0/+8
iPXE does not call shutdown() before invoking a COMBOOT executable, since the executable is allowed to make API calls back into iPXE. If a background picture is used, then the console will not be restored to text mode before invoking the COMBOOT executable. This can cause undefined behaviour. Fix by adding an explicit call to console_reset() immediately before invoking a COMBOOT or COM32 executable, analogous to the call made to console_reset() immediately before invokving a PXE NBP. Debugged-by: Andrew Widdersheim <awiddersheim@inetu.net> Tested-by: Andrew Widdersheim <awiddersheim@inetu.net> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-10-16[build] Generalise CONSOLE_VESAFB to CONSOLE_FRAMEBUFFERMichael Brown1-1/+7
The name "vesafb" is intrinsically specific to a BIOS environment. Generalise the build configuration option CONSOLE_VESAFB to CONSOLE_FRAMEBUFFER, in preparation for adding EFI framebuffer support. Existing configurations using CONSOLE_VESAFB will continue to work. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-10-14[fbcon] Move margin calculations to fbcon.cMichael Brown1-28/+2
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-10-14[fbcon] Allow character height to be selected at runtimeMichael Brown1-5/+23
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-15[pxe] Notify BIOS via INT 1a,564e for each new network deviceMichael Brown1-0/+26
Use INT 1a,564e to notify the BIOS of each network device that we detect. This provides an opportunity for the BIOS to implement platform policy such as changing the MAC address by issuing a call to PXENV_UNDI_SET_STATION_ADDRESS. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-15[pxe] Invoke INT 1a,564e when PXE stack is activatedMichael Brown1-0/+12
Invoke INT 1a,564e whenever a PXE stack is activated, passing the address of the PXENV+ structure in %es:%bx. This is designed to allow a BIOS to be notified when a PXE stack has been installed, providing an opportunity for start-of-day commands such as setting the MAC address according to a policy chosen by the BIOS. PXE defines INT 1a,5650 as a means of locating the PXENV+ structure: this call returns %ax=0x564e and the address of the PXENV+ structure in %es:%bx. We choose INT 1a,564e as a fairly natural notification call, using the parameters as would be returned by INT 1a,5650. The full calling convention (documented as per section 3.1 of the PXE specification) is: INT 1a,564e - PXE installation notification Enter: %ax = 0x564e %es = 16-bit segment address of the PXENV+ structure %bx = 16-bit offset of the PXENV+ structure Exit: %edx may be trashed (as is the case for INT 1a,5650) All other register contents must be preserved CF is cleared IF is preserved All other flags are undefined Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-02[uri] Generalise tftp_uri() to pxe_uri()Michael Brown1-13/+11
Merge the functionality of parse_next_server_and_filename() and tftp_uri() into a single pxe_uri(), which takes a server address (IPv4/IPv6/none) and a filename, and produces a URI using the rule: - if the filename is a hierarchical absolute URI (i.e. includes a scheme such as "http://" or "tftp://") then use that URI and ignore the server address, - otherwise, if the server address is recognised (according to sa_family) then construct a TFTP URI based on the server address, port, and filename - otherwise fail. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-01[build] Search for ldlinux.c32 separately from isolinux.binMichael Brown2-10/+20
Some distributions (observed with Ubuntu 15.04) place ldlinux.c32 in a separate directory from isolinux.bin. Search for these files separately, and allow an alternative location of ldlinux.c32 to be provided via LDLINUX_C32=... on the make command line. Reported-by: Adrian Koshka <adriankoshcha@teknik.io> Tested-by: Adrian Koshka <adriankoshcha@teknik.io> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-29[pxe] Construct all fake DHCP packets before starting PXE NBPMichael Brown3-24/+38
Commit edf74df ("[pxe] Always reconstruct packet for PXENV_GET_CACHED_INFO") fixed the problems caused by returning stale DHCP packets (e.g. from an earlier boot attempt using a different network device), but broke interoperability with NBPs such as WDS which may overwrite our cached (fake) DHCP packets and expect the modified packets to be returned by a subsequent call to PXENV_GET_CACHED_INFO. Fix by constructing the fake DHCP packets immediately before transferring control to a PXE NBP. Calls to PXENV_GET_CACHED_INFO will now never modify the cached packets. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-21[pxe] Warn about PXE NBPs that may be EFI executablesMichael Brown1-4/+42
A relatively common user mistake is to attempt to boot an EFI executable (such as grub.efi) using a BIOS version of iPXE. Unfortunately there are no signature checks that we can use to unambiguously identify a PXE NBP, since a PXE NBP is just raw machine code. We therefore have to accept anything sufficiently small to fit into base memory as a valid PXE NBP. We can detect that a file might be an EFI executable by checking for the initial "MZ" signature bytes. This does not necessarily preclude the file from also being a PXE NBP (since it would be possible to create a hybrid binary which acts as both an EFI executable and a PXE NBP, similar to the way in which wimboot and the Linux kernel are hybrid binaries which act as both an EFI executable and a bzImage). If the initial "MZ" signature bytes are present, then attempt to warn the user by setting the image type to "PXE-NBP (may be EFI?)". We can't (sensibly) prevent the user from accidentally running an EFI executable as a PXE NBP, but we can at least make it easier for the user to identify their mistake. Inspired-by: Robin Smidsrød <robin@smidsrod.no> Inspired-by: Wissam Shoukair <wissams@mellanox.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-14[prefix] Use correct register for KEEP_IT_REAL physical address conversionDaniel Pieczko1-2/+2
Signed-off-by: Daniel Pieczko <dpieczko@solarflare.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>