X32 ABI

Last updated

The x32 ABI is an application binary interface (ABI) and one of the interfaces of the Linux kernel. The x32 ABI provides 32-bit integers, long and pointers (ILP32) on Intel and AMD 64-bit hardware. The ABI allows programs to take advantage of the benefits of x86-64 instruction set (larger number of CPU registers, better floating-point performance, faster position-independent code, shared libraries, function parameters passed via registers, faster syscall instruction) while using 32-bit pointers and thus avoiding the overhead of 64-bit pointers. [1] [2] [3]

Contents

Details

Though the x32 ABI limits the program to a virtual address space of 4 GiB, it also decreases the memory footprint of the program by making pointers smaller. This can allow it to run faster by fitting more code and more data into cache. [1] [2] [3] The best results during testing were with the 181.mcf SPEC CPU 2000 benchmark, in which the x32 ABI version was 40% faster than the x86-64 version. [3] [4] On average, x32 is 5–8% faster on the SPEC CPU integer benchmarks compared to x86-64. There is no speed advantage over x86-64 in the SPEC CPU floating-point benchmarks. [5] There are also some application benchmarks that demonstrate the advantages of the x32 ABI. [6] [7]

ABI comparison
Feature i386 ABIx32 ABI x86-64 ABI
Pointers 4 bytes8 bytes
Max. memory per process 4 GiB128 TiB
Integer registers 6 (PIC)15
FP registers 816
64-bit arithmeticNoYes
Floating-point arithmetic x87 SSE
Calling convention Memory Registers
PIC prologue2–3 instructionsNone

History

Running a userspace that consists mostly of programs compiled in ILP32 mode and which also have principal access to 64-bit CPU instructions has not been uncommon, especially in the field of "classic RISC" chips. For example, the Solaris operating system does so for both SPARC and x86-64. On the Linux side, Debian also ships an ILP32 userspace. The underlying reason is the somewhat "more expensive" nature of LP64 code, [8] just like it has been shown for x86-64. In that regard, the x32 ABI extends the ILP32-on-64bit concept to the x86-64 platform.

Several people had discussed the benefits of an x86-64 ABI with 32-bit pointers in the years since the Athlon 64's release in 2003, notably Donald Knuth in 2008. [9] There was little publicly visible progress towards implementing such a mode until August 27, 2011, when Hans Peter Anvin announced to the Linux kernel mailing list that he and H. J. Lu had been working on the x32 ABI. [10]

That same day, Linus Torvalds replied with a concern that the use of 32-bit time values in the x32 ABI could cause problems in the future. [11] [12] This is because the use of 32-bit time values would cause the time values to overflow in the year 2038. [11] [12] Following this request, the developers of the x32 ABI changed the time values to 64-bit. [13]

A presentation at the Linux Plumbers Conference on September 7, 2011, covered the x32 ABI. [2]

The x32 ABI was merged into the Linux kernel for the 3.4 release with support being added to the GNU C Library in version 2.16. [14]

In December 2018 there was discussion as to whether to deprecate the x32 ABI, which has not happened as of April 2023. [15]

Adoption

Linux distributionMore information
Debian X32 Port
Gentoo Multilib via abi_x86_x32 use-flags
Yocto Project X32 ABI
T2 SDE x86-64

Related Research Articles

<span class="mw-page-title-main">Executable and Linkable Format</span> Standard file format for executables, object code, shared libraries, and core dumps.

In computing, the Executable and Linkable Format, is a common standard file format for executable files, object code, shared libraries, and core dumps. First published in the specification for the application binary interface (ABI) of the Unix operating system version named System V Release 4 (SVR4), and later in the Tool Interface Standard, it was quickly accepted among different vendors of Unix systems. In 1999, it was chosen as the standard binary file format for Unix and Unix-like systems on x86 processors by the 86open project.

In computer architecture, 64-bit integers, memory addresses, or other data units are those that are 64 bits wide. Also, 64-bit central processing units (CPU) and arithmetic logic units (ALU) are those that are based on processor registers, address buses, or data buses of that size. A computer that uses such a processor is a 64-bit computer.

x86 assembly language is the name for the family of assembly languages which provide some level of backward compatibility with CPUs back to the Intel 8008 microprocessor, which was launched in April 1972. It is used to produce object code for the x86 class of processors.

x86-64 Type of instruction set which is a 64-bit version of the x86 instruction set

x86-64 is a 64-bit version of the x86 instruction set, first released in 1999. It introduced two new modes of operation, 64-bit mode and compatibility mode, along with a new 4-level paging mode.

<span class="mw-page-title-main">DragonFly BSD</span> Free and open-source Unix-like operating system

DragonFly BSD is a free and open-source Unix-like operating system forked from FreeBSD 4.8. Matthew Dillon, an Amiga developer in the late 1980s and early 1990s and FreeBSD developer between 1994 and 2003, began working on DragonFly BSD in June 2003 and announced it on the FreeBSD mailing lists on 16 July 2003.

The GNU C Library, commonly known as glibc, is the GNU Project's implementation of the C standard library. It is a wrapper around the system calls of the Linux kernel for application use. Despite its name, it now also directly supports C++. It was started in the 1980s by the Free Software Foundation (FSF) for the GNU operating system.

In software engineering, a compatibility layer is an interface that allows binaries for a legacy or foreign system to run on a host system. This translates system calls for the foreign system into native system calls for the host system. With some libraries for the foreign system, this will often be sufficient to run foreign binaries on the host system. A hardware compatibility layer consists of tools that allow hardware emulation.

<span class="mw-page-title-main">Arch Linux</span> Rolling release distribution of Linux

Arch Linux is an independently developed, x86-64 general-purpose Linux distribution that strives to provide the latest stable versions of most software by following a rolling-release model. The default installation is a minimal base system, configured by the user to only add what is purposely required.

Mach-O, short for Mach object file format, is a file format for executables, object code, shared libraries, dynamically loaded code, and core dumps. It was developed to replace the a.out format.

<span class="mw-page-title-main">Linux kernel interfaces</span> An overview and comparison of the Linux kernal APIs and ABIs.

The Linux kernel provides several interfaces to user-space applications that are used for different purposes and that have different properties by design. There are two types of application programming interface (API) in the Linux kernel that are not to be confused: the "kernel–user space" API and the "kernel internal" API.

In computer security, executable-space protection marks memory regions as non-executable, such that an attempt to execute machine code in these regions will cause an exception. It makes use of hardware features such as the NX bit, or in some cases software emulation of those features. However, technologies that emulate or supply an NX bit will usually impose a measurable overhead while using a hardware-supplied NX bit imposes no measurable overhead.

<span class="mw-page-title-main">Linux kernel</span> Operating system kernel

The Linux kernel is a free and open-source, monolithic, modular, multitasking, Unix-like operating system kernel. It was originally written in 1991 by Linus Torvalds for his i386-based PC, and it was soon adopted as the kernel for the GNU operating system, which was written to be a free (libre) replacement for Unix.

<span class="mw-page-title-main">H. Peter Anvin</span> Swedish-American computer programmer

Hans Peter Anvin, also known as hpa, is a Swedish-American computer programmer who has contributed to free and open-source software projects. Anvin is the originator of SYSLINUX, Linux Assigned Names and Numbers Authority (LANANA), and various Linux kernel features.

In computing, klibc is a minimalistic subset of the standard C library developed by H. Peter Anvin. It was developed mainly to be used during the Linux startup process, and it is part of the early user space, i.e. components used during kernel startup, but which do not run in kernel mode. These components do not have access to the standard library used by normal userspace programs.

perf is a performance analyzing tool in Linux, available from Linux kernel version 2.6.31 in 2009. Userspace controlling utility, named perf, is accessed from the command line and provides a number of subcommands; it is capable of statistical profiling of the entire system.

Supervisor Mode Access Prevention (SMAP) is a feature of some CPU implementations such as the Intel Broadwell microarchitecture that allows supervisor mode programs to optionally set user-space memory mappings so that access to those mappings from supervisor mode will cause a trap. This makes it harder for malicious programs to "trick" the kernel into using instructions or data from a user-space program.

kGraft is a feature of the Linux kernel that implements live patching of a running kernel, which allows kernel patches to be applied while the kernel is still running. By avoiding the need for rebooting the system with a new kernel that contains the desired patches, kGraft aims to maximize the system uptime and availability. At the same time, kGraft allows kernel-related security updates to be applied without deferring them to scheduled downtimes. Internally, kGraft allows entire functions in a running kernel to be replaced with their patched versions, doing that safely by selectively using original versions of functions to ensure per-process consistency while the live patching is performed.

kpatch is a feature of the Linux kernel that implements live patching of a running kernel, which allows kernel patches to be applied while the kernel is still running. By avoiding the need for rebooting the system with a new kernel that contains the desired patches, kpatch aims to maximize the system uptime and availability. At the same time, kpatch allows kernel-related security updates to be applied without deferring them to scheduled downtimes. Internally, kpatch allows entire functions in a running kernel to be replaced with their patched versions, doing that safely by stopping all running processes while the live patching is performed.

Retbleed is a speculative execution attack on x86-64 and ARM processors, including some recent Intel and AMD chips. First made public in 2022, it is a variant of the Spectre vulnerability which exploits retpoline, which was a mitigation for speculative execution attacks.

References

  1. 1 2 Thorsten Leemhuis (2011-09-13). "Kernel Log: x32 ABI gets around 64-bit drawbacks". www.h-online.com. Archived from the original on 28 October 2011. Retrieved 2011-11-01.
  2. 1 2 3 "x32 - a native 32-bit ABI for x86-64". linuxplumbersconf.org. Retrieved 2012-06-12.
  3. 1 2 3 "x32-abi". Google Sites. Retrieved 2011-11-01.
  4. "181.mcf SPEC CPU2000 Benchmark Description File". Standard Performance Evaluation Corporation. 1999-10-14. Retrieved 2011-11-01.
  5. H. J. Lu; H. Peter Anvin; Milind Girkar (September 2011). "X32 - A Native 32bit ABI For X86-64".
  6. Rauschmayr, Nathalie; Streit, Achim (2013). "Evaluation of x32-ABI in the Context of LHC Applications". Procedia Computer Science. 18: 2233–2240. doi: 10.1016/j.procs.2013.05.394 .
  7. "Applications that Profit from the Underrated x32-ABI". www.sempria.de. Retrieved 22 May 2023.
  8. Tony Bourke (2004-01-22). "Are 64-bit Binaries Really Slower than 32-bit Binaries?" . Retrieved 2014-03-25.
  9. Donald Knuth (February 2008). "Recent News: A Flame About 64-bit Pointers" . Retrieved 15 May 2012.
  10. H. Peter Anvin (27 August 2011). "RFD: x32 ABI system call numbers" . Retrieved 15 May 2012.
  11. 1 2 Jonathan Corbet (2011-08-29). "The x32 system call ABI". LWN.net. Retrieved 2011-11-01.
  12. 1 2 Linus Torvalds (2011-08-26). "Re: RFD: x32 ABI system call numbers". LWN.net. Retrieved 2016-02-26.
  13. Lu, H. J. (2011-11-24). "X32 project status update". libc-alpha (Mailing list). Retrieved 2019-10-17.
  14. O'Donell, Carlos (30 June 2012). "The GNU C Library version 2.16 is now available". libc-alpha (Mailing list). Retrieved 27 December 2016.
  15. "Can we drop upstream Linux x32 support?". LKML. Retrieved 13 March 2019.