aboutsummaryrefslogtreecommitdiffstats
path: root/src/arch/x86_64
Commit message (Collapse)AuthorAgeFilesLines
* [profile] Standardise return type of profile_timestamp()Michael Brown2024-09-241-1/+1
| | | | | | | | | | | | | | | | All consumers of profile_timestamp() currently treat the value as an unsigned long. Only the elapsed number of ticks is ever relevant: the absolute value of the timestamp is not used. Profiling is used to measure short durations that are generally fewer than a million CPU cycles, for which an unsigned long is easily large enough. Standardise the return type of profile_timestamp() as unsigned long across all CPU architectures. This allows 32-bit architectures such as i386 and riscv32 to omit all logic associated with retrieving the upper 32 bits of the 64-bit hardware counter, which simplifies the code and allows riscv32 and riscv64 to share the same implementation. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Remove redundant EFI_BOOT_FILE definitionsMichael Brown2024-09-161-4/+0
| | | | | | | | | | | | As of commit 79c0173 ("[build] Create util/genfsimg for building filesystem-based images"), the EFI boot file name for each CPU architecture is defined within the genfsimg script itself, rather than being passed in as a Makefile parameter. Remove the now-redundant Makefile definitions for EFI_BOOT_FILE. Reported-by: Christian I. Nilsson <nikize@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Centralise architecture-independent portions of setjmp.hMichael Brown2024-09-121-9/+3
| | | | | | | | | | | The definitions of the setjmp() and longjmp() functions are common to all architectures, with only the definition of the jump buffer structure being architecture-specific. Move the architecture-specific portions to bits/setjmp.h and provide a common setjmp.h for the function definitions. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [gdb] Allow CPU architectures to omit support for GDBMichael Brown2024-09-051-0/+0
| | | | | | | | Move the <gdbmach.h> file to <bits/gdbmach.h>, and provide a common dummy implementation for all architectures that have not yet implemented support for GDB. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Inhibit linker warnings about an implied executable stackGeert Stappers2023-06-302-0/+2
| | | | | | Signed-off-by: Geert Stappers <stappers@stappers.it> Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Allow for per-architecture unprefixed constant operand modifierMichael Brown2023-02-051-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>
* [dhcp] Simplify platform-specific client architecture definitionsMichael Brown2023-01-223-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>
* [linux] Centralise the linker script for Linux binariesMichael Brown2023-01-222-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>
* [efi] Include Secure Boot Advanced Targeting (SBAT) metadatasbatMichael Brown2022-01-131-0/+2
| | | | | | | | | | | | | | | | | 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>
* [build] Allow __asmcall to be used as a type attributeMichael Brown2021-03-021-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>
* [linux] Use host glibc system call wrappersMichael Brown2021-02-284-66/+6
| | | | | | | | | | | | | | | | | | | | | | 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>
* [build] Prevent use of MMX and SSE registersMichael Brown2018-03-202-2/+5
| | | | | | | | | | | | | | | | | | | | | | | The existence of MMX and SSE is required by the System V x86_64 ABI and so is assumed by gcc, but these registers are not preserved by our own interrupt handlers and are unlikely to be preserved by other context switch handlers in a boot firmware environment. Explicitly prevent gcc from using MMX or SSE registers to avoid potential problems due to silent register corruption. We must remove the %xmm0-%xmm5 clobbers from the x86_64 version of hv_call() since otherwise gcc will complain about unknown register names. Theoretically, we should probably add code to explicitly preserve the %xmm0-%xmm5 registers across a hypercall, in order to guarantee to external code that these registers remain unchanged. In practice this is difficult since SSE registers are disabled by default: for background information see commits 71560d1 ("[librm] Preserve FPU, MMX and SSE state across calls to virt_call()") and dd9a14d ("[librm] Conditionalize the workaround for the Tivoli VMM's SSE garbling"). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Add missing FILE_LICENCE declarationsMichael Brown2017-12-293-0/+6
| | | | | | | | Add missing FILE_LICENCE declarations to x86_64 headers based on the corresponding i386 headers (from which the x86_64 headers were originally derived). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [dhcp] Automatically generate vendor class identifier stringMichael Brown2016-07-042-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>
* [dhcp] Allow for variable encapsulation of architecture-specific optionsMichael Brown2016-07-042-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>
* [gdb] Add support for x86_64Michael Brown2016-03-222-11/+206
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hyperv] Use generic set_bit() functionMichael Brown2016-03-161-23/+0
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Fix building on older versions of binutilsMichael Brown2016-02-191-4/+0
| | | | | | | | | | | | | 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>
* [librm] Generate page tables for 64-bit buildsMichael Brown2016-02-191-0/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Prepare for long-mode memory mapMichael Brown2016-02-193-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [librm] Provide an abstraction wrapper for prot_callMichael Brown2016-02-181-1/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [bios] Add bin-x86_64-pcbios build platformMichael Brown2016-02-1611-100/+52
| | | | | | | | | | | | | | 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>
* [efi] Add %.usb target for building EFI-bootable USB (or other) disk imagesMichael Brown2015-12-071-0/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Add x86_64 versions of setjmp() and longjmp()Michael Brown2015-04-073-0/+100
| | | | | | | | None of the x86_64 builds currently have any way of invoking these functions. They are included only to avoid introducing unnecessary architecture-specific dependencies into the self-test suite. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Add ffs(), ffsl(), and ffsll()Michael Brown2015-03-161-1/+37
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Fix the REQUIRE_SYMBOL mechanismMichael Brown2015-03-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | At some point in the past few years, binutils became more aggressive at removing unused symbols. To function as a symbol requirement, a relocation record must now be in a section marked with @progbits and must not be in a section which gets discarded during the link (either via --gc-sections or via /DISCARD/). Update REQUIRE_SYMBOL() to generate relocation records meeting these criteria. To minimise the impact upon the final binary size, we use existing symbols (specified via the REQUIRING_SYMBOL() macro) as the relocation targets where possible. We use R_386_NONE or R_X86_64_NONE relocation types to prevent any actual unwanted relocation taking place. Where no suitable symbol exists for REQUIRING_SYMBOL() (such as in config.c), the macro PROVIDE_REQUIRING_SYMBOL() can be used to generate a one-byte-long symbol to act as the relocation target. If there are versions of binutils for which this approach fails, then the fallback will probably involve killing off REQUEST_SYMBOL(), redefining REQUIRE_SYMBOL() to use the current definition of REQUEST_SYMBOL(), and postprocessing the linked ELF file with something along the lines of "nm -u | wc -l" to check that there are no undefined symbols remaining. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Rewrite byte-swapping codeMichael Brown2015-03-021-6/+0
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-021-3/+8
| | | | | | | | | | These files cannot be automatically relicensed by util/relicense.pl since they either contain unusual but trivial contributions (such as the addition of __nonnull function attributes), or contain lines dating back to the initial git revision (and so require manual knowledge of the code's origin). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-029-9/+9
| | | | | | | Relicense files for which I am the sole author (as identified by util/relicense.pl). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [hyperv] Add support for Hyper-V hypervisorMichael Brown2014-12-181-0/+75
| | | | | | | Add support for detecting and communicating with the Hyper-V hypervisor. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [x86_64] Add functions to read and write model-specific registersMichael Brown2014-07-231-0/+43
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [librm] Allow interrupts in protected modeMichael Brown2014-04-291-0/+2
| | | | | | | | 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>
* [profile] Add generic profiling infrastructureMichael Brown2014-04-271-0/+29
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Add flsll()Michael Brown2014-04-271-0/+42
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Fix %.licence build targetMichael Brown2013-07-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Our use of --gc-sections causes the linker to discard the symbols defined by FILE_LICENCE(), meaning that the resulting licence determination is incomplete. We must use the KEEP() directive in the linker script to force the linker to not discard the licence symbols. Using KEEP(*(COMMON)) would be undesirable, since there are some symbols in COMMON which we may wish to discard. Fix by placing symbols defined by PROVIDE_SYMBOL() (which is used by FILE_LICENCE()) into a special ".provided" section, which we then mark with KEEP(). All such symbols are zero-length, so there is no cost in terms of the final binary size. Since the symbols are no longer in COMMON, the linker will reject symbols with the same name coming from multiple objects. We therefore append the object name to the licence symbol, to ensure that it is unique. Reported-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Add "reboot" command for EFIMichael Brown2013-03-221-0/+12
| | | | | | | | | Abstract out the ability to reboot the system to a separate reboot() function (with platform-specific implementations), add an EFI implementation, and make the existing "reboot" command available under EFI. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Use -maccumulate-outgoing-args if required by gccMichael Brown2012-11-021-0/+12
| | | | | | | | | | | | | Current versions of gcc require -maccumulate-outgoing-args if any sysv_abi functions call ms_abi functions. This requirement is likely to be lifted in future gcc versions, so test explicitly to see if the current version of gcc requires -maccumulate-outgoing-args. This problem is currently masked since the implied -fasynchronous-unwind-tables (which is the default in current gcc versions) implies -maccumulate-outgoing-args. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ioapi] Generalise i386 raw I/O API to x86Michael Brown2012-07-171-10/+0
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Merge i386 and x86_64 versions of errfile.hMichael Brown2012-06-061-11/+0
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [linux] Fix a build error on some platformsMarin Mareo Hannache2012-04-101-1/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [time] Define an API for getting the current timeMichael Brown2012-03-191-0/+12
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [x86_64] Use memory address constraint in __bswap_16s()Michael Brown2012-03-041-1/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [x86_64] Provide __bswap_{16,32,64}s()Michael Brown2012-03-041-0/+25
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [rng] Add ANS X9.82 Approved Source of Entropy InputMichael Brown2012-02-211-0/+12
| | | | | | | | | | | | | | | | ANS X9.82 specifies several Approved Sources of Entropy Input (SEI). One such SEI uses an entropy source as the Source of Entropy Input, condensing each entropy source output after each GetEntropy call. This can be implemented relatively cheaply in iPXE and avoids the need to allocate potentially very large buffers. (Note that the terms "entropy source" and "Source of Entropy Input" are not synonyms within the context of ANS X9.82.) Use the iPXE API mechanism to allow entropy sources to be selected at compilation time. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [dhcp] Add symbolic definitions for DHCP client architecture valuesMichael Brown2011-07-061-2/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [linux] Avoid building Linux-specific prefix on non-Linux buildsMichael Brown2011-04-271-0/+0
| | | | | Reported-by: David Yeske <dyeske@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [linux] Make malloc and linux_umalloc valgrindablePiotr Jaroszyński2011-03-271-3/+4
| | | | | | | | | | Make the allocators used by malloc and linux_umalloc valgrindable. Include valgrind headers in the codebase to avoid a build dependency on valgrind. Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com> Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Use unique entry symbols for each prefixMichael Brown2011-02-232-5/+3
| | | | | | | | | | | | Some binutils versions will drag in an object to satisfy the entry symbol; some won't. Try to cope with this exciting variety of behaviour by ensuring that all entry symbols are unique. Remove the explicit inclusion of the prefix object on the linker command line, since the entry symbol now provides all the information needed to identify the prefix. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Eliminate unused sections at link-timeMichael Brown2011-02-221-1/+3
| | | | | | | | | Use -ffunction-sections, -fdata-sections, and --gc-sections to automatically prune out any unreferenced sections. This saves around 744 bytes (uncompressed) from the rtl8139.rom build. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Replace gPXE block-device API with an iPXE asynchronous interfaceMichael Brown2010-09-141-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The block device interface used in gPXE predates the invention of even the old gPXE data-transfer interface, let alone the current iPXE generic asynchronous interface mechanism. Bring this old code up to date, with the following benefits: o Block device commands can be cancelled by the requestor. The INT 13 layer uses this to provide a global timeout on all INT 13 calls, with the result that an unexpected passive failure mode (such as an iSCSI target ACKing the request but never sending a response) will lead to a timeout that gets reported back to the INT 13 user, rather than simply freezing the system. o INT 13,00 (reset drive) is now able to reset the underlying block device. INT 13 users, such as DOS, that use INT 13,00 as a method for error recovery now have a chance of recovering. o All block device commands are tagged, with a numerical tag that will show up in debugging output and in packet captures; this will allow easier interpretation of bug reports that include both sources of information. o The extremely ugly hacks used to generate the boot firmware tables have been eradicated and replaced with a generic acpi_describe() method (exploiting the ability of iPXE interfaces to pass through methods to an underlying interface). The ACPI tables are now built in a shared data block within .bss16, rather than each requiring dedicated space in .data16. o The architecture-independent concept of a SAN device has been exposed to the iPXE core through the sanboot API, which provides calls to hook, unhook, boot, and describe SAN devices. This allows for much more flexible usage patterns (such as hooking an empty SAN device and then running an OS installer via TFTP). Signed-off-by: Michael Brown <mcb30@ipxe.org>