X32 ABI

{{Short description|Application binary interface (ABI) of the Linux kernel}}

{{lowercase title}}

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.{{cite news |url=http://www.h-online.com/open/features/Kernel-Log-x32-ABI-gets-around-64-bit-drawbacks-1342061.html |archive-url=https://web.archive.org/web/20111028081253/http://www.h-online.com/open/features/Kernel-Log-x32-ABI-gets-around-64-bit-drawbacks-1342061.html|archive-date=28 October 2011|title=Kernel Log: x32 ABI gets around 64-bit drawbacks |publisher=www.h-online.com |author=Thorsten Leemhuis |date=2011-09-13 |access-date=2011-11-01}}{{cite news |url=http://linuxplumbersconf.org/2011/ocw/sessions/531 |title=x32 - a native 32-bit ABI for x86-64 |publisher=linuxplumbersconf.org |access-date=2012-06-12}}{{cite news |url=http://sites.google.com/site/x32abi/ |title=x32-abi |publisher=Google Sites |access-date=2011-11-01}}

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. 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.{{cite news |url=http://www.spec.org/cpu2000/CINT2000/181.mcf/docs/181.mcf.html |title=181.mcf SPEC CPU2000 Benchmark Description File |publisher=Standard Performance Evaluation Corporation |date=1999-10-14 |access-date=2011-11-01}} 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.{{cite news |url=http://www.linuxplumbersconf.net/2011/ocw//system/presentations/531/original/x32-LPC-2011-0906.pptx |title=X32 - A Native 32bit ABI For X86-64 |author1=H. J. Lu |author2=H. Peter Anvin |author3=Milind Girkar |date= September 2011}} There are also some application benchmarks that demonstrate the advantages of the x32 ABI.{{cite journal | last1 = Rauschmayr | first1 = Nathalie | last2 = Streit | first2 = Achim | year = 2013 | title = Evaluation of x32-ABI in the Context of LHC Applications | journal = Procedia Computer Science | volume = 18 | pages = 2233–2240 | doi = 10.1016/j.procs.2013.05.394 | doi-access = free }}

{{Cite web|url=https://www.sempria.de/hop/x32-ABI|title=Applications that Profit from the Underrated x32-ABI|website=www.sempria.de|accessdate=22 May 2023}}

class="wikitable" style="text-align:center"

|+ ABI comparison

! Feature

! i386 ABI

! x32 ABI

! x86-64 ABI

style="text-align:left" | Pointers

| colspan="2" style="background:#DFD;" | 4 bytes

| style="background:#FDD;" | 8 bytes

style="text-align:left" | Max. memory per process

| colspan="2" style="background:#FDD;" | 4 GiB

| style="background:#DFD;" | 128 TiB

style="text-align:left" | Integer registers

| style="background:#FDD;" | 6 (PIC)

| colspan="2" style="background:#DFD;" | 15

style="text-align:left" | FP registers

| style="background:#FDD;" | 8

| colspan="2" style="background:#DFD;" | 16

style="text-align:left" | 64-bit arithmetic

| style="background:#FDD;" | No

| colspan="2" style="background:#DFD;" | Yes

style="text-align:left" | Floating-point arithmetic

| style="background:#FDD;" | x87

| colspan="2" style="background:#DFD;" | SSE

style="text-align:left" | Calling convention

| style="background:#FDD;" | Memory

| colspan="2" style="background:#DFD;" | Registers

style="text-align:left" | PIC prologue

| style="background:#FDD;" | 2–3 instructions

| colspan="2" style="background:#DFD;" | None

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,{{cite web|url=http://www.osnews.com/story/5768/Are_64-bit_Binaries_Really_Slower_than_32-bit_Binaries_|title=Are 64-bit Binaries Really Slower than 32-bit Binaries?|date=2004-01-22|access-date=2014-03-25|author=Tony Bourke}} 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.{{cite web |url=http://www-cs-faculty.stanford.edu/~knuth/news08.html |title=Recent News: A Flame About 64-bit Pointers |author=Donald Knuth |date=February 2008 |access-date=15 May 2012 |archive-date=4 November 2008 |archive-url=https://web.archive.org/web/20081104104512/http://www-cs-faculty.stanford.edu/~knuth/news08.html |url-status=dead }} 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.{{cite web |url=https://lkml.org/lkml/2011/8/26/415 |title= RFD: x32 ABI system call numbers |author=H. Peter Anvin |date=27 August 2011 |access-date=15 May 2012}}

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.{{cite news |url=https://lwn.net/Articles/456731/ |title=The x32 system call ABI |publisher=LWN.net |author=Jonathan Corbet |date=2011-08-29 |access-date=2011-11-01}}{{cite news |url=https://lwn.net/Articles/456750/ |title=Re: RFD: x32 ABI system call numbers |publisher=LWN.net |author=Linus Torvalds |date=2011-08-26 |access-date=2016-02-26}} This is because the use of 32-bit time values would cause the time values to overflow in the year 2038. Following this request, the developers of the x32 ABI changed the time values to 64-bit.{{cite mailing list |url=http://www.sourceware.org/ml/libc-alpha/2011-11/msg00086.html |mailing-list=libc-alpha |title=X32 project status update |first=H. J. |last=Lu |date=2011-11-24 |access-date=2019-10-17 }}

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

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.{{cite mailing list |url=https://sourceware.org/ml/libc-alpha/2012-06/msg00807.html |title=The GNU C Library version 2.16 is now available. |date=30 June 2012 |access-date=27 December 2016 |mailing-list=libc-alpha |last=O'Donell |first=Carlos}}

In December 2018 there was discussion as to whether to deprecate the x32 ABI, which has not happened as of April 2023,{{cite web |title=Can we drop upstream Linux x32 support? |url=https://lkml.org/lkml/2018/12/10/1145 |website=LKML |access-date=13 March 2019}} and has seen some new development in May 2024.{{cite web |title=The first half of the 6.10 merge window |url=https://lwn.net/Articles/973687/ |website=LWN |access-date=17 May 2024}}

Adoption

class="wikitable sortable" style="margin-left: auto; margin-right: auto;"
scope="col" | Linux distributionscope="col" | More information
Debian

| [https://wiki.debian.org/X32Port X32 Port]

Gentoo

| [https://wiki.gentoo.org/wiki/Multilib/Concepts Multilib] via {{code|abi_x86_x32}} use-flags

Yocto Project

| [https://wiki.yoctoproject.org/wiki/X32_abi X32 ABI]

T2 SDE

| [https://t2sde.org/architectures/x86-64/ x86-64]

References

{{reflist|30em}}