sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget1/translations/zh_CN/arch/arm64/tagged-address-abimodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget1/translations/zh_TW/arch/arm64/tagged-address-abimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget1/translations/it_IT/arch/arm64/tagged-address-abimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget1/translations/ja_JP/arch/arm64/tagged-address-abimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget1/translations/ko_KR/arch/arm64/tagged-address-abimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hPortuguese (Brazilian)}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget1/translations/pt_BR/arch/arm64/tagged-address-abimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget1/translations/sp_SP/arch/arm64/tagged-address-abimodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hAArch64 TAGGED ADDRESS ABIh]hAArch64 TAGGED ADDRESS ABI}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhK/var/lib/git/docbuild/linux/Documentation/arch/arm64/tagged-address-abi.rsthKubhdefinition_list)}(hhh]hdefinition_list_item)}(haAuthors: Vincenzo Frascino Catalin Marinas h](hterm)}(h6Authors: Vincenzo Frascino h](hAuthors: Vincenzo Frascino <}(hhhhhNhNubh reference)}(hvincenzo.frascino@arm.comh]hvincenzo.frascino@arm.com}(hhhhhNhNubah}(h]h ]h"]h$]h&]refuri mailto:vincenzo.frascino@arm.comuh1hhhubh>}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhubh definition)}(hhh]h paragraph)}(h)Catalin Marinas h](hCatalin Marinas <}(hjhhhNhNubh)}(hcatalin.marinas@arm.comh]hcatalin.marinas@arm.com}(hj hhhNhNubah}(h]h ]h"]h$]h&]refurimailto:catalin.marinas@arm.comuh1hhjubh>}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKhhubah}(h]h ]h"]h$]h&]uh1hhhubeh}(h]h ]h"]h$]h&]uh1hhhhKhhubah}(h]h ]h"]h$]h&]uh1hhhhhhhhNubj)}(hDate: 21 August 2019h]hDate: 21 August 2019}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhhhhubj)}(h[This document describes the usage and semantics of the Tagged Address ABI on AArch64 Linux.h]h[This document describes the usage and semantics of the Tagged Address ABI on AArch64 Linux.}(hjEhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK hhhhubh)}(hhh](h)}(h1. Introductionh]h1. Introduction}(hjVhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjShhhhhKubj)}(hX On AArch64 the ``TCR_EL1.TBI0`` bit is set by default, allowing userspace (EL0) to perform memory accesses through 64-bit pointers with a non-zero top byte. This document describes the relaxation of the syscall ABI that allows userspace to pass certain tagged pointers to kernel syscalls.h](hOn AArch64 the }(hjdhhhNhNubhliteral)}(h``TCR_EL1.TBI0``h]h TCR_EL1.TBI0}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjdubhX bit is set by default, allowing userspace (EL0) to perform memory accesses through 64-bit pointers with a non-zero top byte. This document describes the relaxation of the syscall ABI that allows userspace to pass certain tagged pointers to kernel syscalls.}(hjdhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKhjShhubeh}(h] introductionah ]h"]1. introductionah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h2. AArch64 Tagged Address ABIh]h2. AArch64 Tagged Address ABI}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubj)}(hXFrom the kernel syscall interface perspective and for the purposes of this document, a "valid tagged pointer" is a pointer with a potentially non-zero top-byte that references an address in the user process address space obtained in one of the following ways:h]hXFrom the kernel syscall interface perspective and for the purposes of this document, a “valid tagged pointer” is a pointer with a potentially non-zero top-byte that references an address in the user process address space obtained in one of the following ways:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubh bullet_list)}(hhh](h list_item)}(h``mmap()`` syscall where either: - flags have the ``MAP_ANONYMOUS`` bit set or - the file descriptor refers to a regular file (including those returned by ``memfd_create()``) or ``/dev/zero`` h](j)}(h ``mmap()`` syscall where either:h](jm)}(h ``mmap()``h]hmmap()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh syscall where either:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hhh](j)}(h+flags have the ``MAP_ANONYMOUS`` bit set orh]j)}(hjh](hflags have the }(hjhhhNhNubjm)}(h``MAP_ANONYMOUS``h]h MAP_ANONYMOUS}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh bit set or}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhK hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hothe file descriptor refers to a regular file (including those returned by ``memfd_create()``) or ``/dev/zero`` h]j)}(hnthe file descriptor refers to a regular file (including those returned by ``memfd_create()``) or ``/dev/zero``h](hJthe file descriptor refers to a regular file (including those returned by }(hjhhhNhNubjm)}(h``memfd_create()``h]hmemfd_create()}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh) or }(hjhhhNhNubjm)}(h ``/dev/zero``h]h /dev/zero}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubeh}(h]h ]h"]h$]h&]uh1jhhhK!hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]bullet-uh1jhhhK hjubeh}(h]h ]h"]h$]h&]uh1jhjhhhNhNubj)}(h``brk()`` syscall (i.e. the heap area between the initial location of the program break at process creation and its current location). h]j)}(h``brk()`` syscall (i.e. the heap area between the initial location of the program break at process creation and its current location).h](jm)}(h ``brk()``h]hbrk()}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjJubh} syscall (i.e. the heap area between the initial location of the program break at process creation and its current location).}(hjJhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhK$hjFubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hany memory mapped by the kernel in the address space of the process during creation and with the same restrictions as for ``mmap()`` above (e.g. data, bss, stack). h]j)}(hany memory mapped by the kernel in the address space of the process during creation and with the same restrictions as for ``mmap()`` above (e.g. data, bss, stack).h](hzany memory mapped by the kernel in the address space of the process during creation and with the same restrictions as for }(hjphhhNhNubjm)}(h ``mmap()``h]hmmap()}(hjxhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjpubh above (e.g. data, bss, stack).}(hjphhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhK'hjlubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]j>j?uh1jhhhKhjhhubj)}(hwThe AArch64 Tagged Address ABI has two stages of relaxation depending on how the user addresses are used by the kernel:h]hwThe AArch64 Tagged Address ABI has two stages of relaxation depending on how the user addresses are used by the kernel:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK+hjhhubhenumerated_list)}(hhh](j)}(hXUser addresses not accessed by the kernel but used for address space management (e.g. ``mprotect()``, ``madvise()``). The use of valid tagged pointers in this context is allowed with these exceptions: - ``brk()``, ``mmap()`` and the ``new_address`` argument to ``mremap()`` as these have the potential to alias with existing user addresses. NOTE: This behaviour changed in v5.6 and so some earlier kernels may incorrectly accept valid tagged pointers for the ``brk()``, ``mmap()`` and ``mremap()`` system calls. - The ``range.start``, ``start`` and ``dst`` arguments to the ``UFFDIO_*`` ``ioctl()``s used on a file descriptor obtained from ``userfaultfd()``, as fault addresses subsequently obtained by reading the file descriptor will be untagged, which may otherwise confuse tag-unaware programs. NOTE: This behaviour changed in v5.14 and so some earlier kernels may incorrectly accept valid tagged pointers for this system call. h](j)}(hUser addresses not accessed by the kernel but used for address space management (e.g. ``mprotect()``, ``madvise()``). The use of valid tagged pointers in this context is allowed with these exceptions:h](hVUser addresses not accessed by the kernel but used for address space management (e.g. }(hjhhhNhNubjm)}(h``mprotect()``h]h mprotect()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh, }(hjhhhNhNubjm)}(h ``madvise()``h]h madvise()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubhU). The use of valid tagged pointers in this context is allowed with these exceptions:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhK.hjubj)}(hhh](j)}(hX6``brk()``, ``mmap()`` and the ``new_address`` argument to ``mremap()`` as these have the potential to alias with existing user addresses. NOTE: This behaviour changed in v5.6 and so some earlier kernels may incorrectly accept valid tagged pointers for the ``brk()``, ``mmap()`` and ``mremap()`` system calls. h](j)}(h``brk()``, ``mmap()`` and the ``new_address`` argument to ``mremap()`` as these have the potential to alias with existing user addresses.h](jm)}(h ``brk()``h]hbrk()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh, }(hjhhhNhNubjm)}(h ``mmap()``h]hmmap()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh and the }(hjhhhNhNubjm)}(h``new_address``h]h new_address}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh argument to }(hjhhhNhNubjm)}(h ``mremap()``h]hmremap()}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubhC as these have the potential to alias with existing user addresses.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhK2hjubj)}(hNOTE: This behaviour changed in v5.6 and so some earlier kernels may incorrectly accept valid tagged pointers for the ``brk()``, ``mmap()`` and ``mremap()`` system calls.h](hvNOTE: This behaviour changed in v5.6 and so some earlier kernels may incorrectly accept valid tagged pointers for the }(hj>hhhNhNubjm)}(h ``brk()``h]hbrk()}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhj>ubh, }(hj>hhhNhNubjm)}(h ``mmap()``h]hmmap()}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhj>ubh and }(hj>hhhNhNubjm)}(h ``mremap()``h]hmremap()}(hjjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhj>ubh system calls.}(hj>hhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhK6hjubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(hXThe ``range.start``, ``start`` and ``dst`` arguments to the ``UFFDIO_*`` ``ioctl()``s used on a file descriptor obtained from ``userfaultfd()``, as fault addresses subsequently obtained by reading the file descriptor will be untagged, which may otherwise confuse tag-unaware programs. NOTE: This behaviour changed in v5.14 and so some earlier kernels may incorrectly accept valid tagged pointers for this system call. h](j)}(hXThe ``range.start``, ``start`` and ``dst`` arguments to the ``UFFDIO_*`` ``ioctl()``s used on a file descriptor obtained from ``userfaultfd()``, as fault addresses subsequently obtained by reading the file descriptor will be untagged, which may otherwise confuse tag-unaware programs.h](hThe }(hjhhhNhNubjm)}(h``range.start``h]h range.start}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh, }(hjhhhNhNubjm)}(h ``start``h]hstart}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh and }(hjhhhNhNubjm)}(h``dst``h]hdst}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh arguments to the }(hjhhhNhNubjm)}(h ``UFFDIO_*``h]hUFFDIO_*}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh }(hjhhhNhNubjm)}(hF``ioctl()``s used on a file descriptor obtained from ``userfaultfd()``h]hBioctl()``s used on a file descriptor obtained from ``userfaultfd()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh, as fault addresses subsequently obtained by reading the file descriptor will be untagged, which may otherwise confuse tag-unaware programs.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhK:hjubj)}(hNOTE: This behaviour changed in v5.14 and so some earlier kernels may incorrectly accept valid tagged pointers for this system call.h]hNOTE: This behaviour changed in v5.14 and so some earlier kernels may incorrectly accept valid tagged pointers for this system call.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK@hjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]j>j?uh1jhhhK2hjubeh}(h]h ]h"]h$]h&]uh1jhjhhhNhNubj)}(hX<User addresses accessed by the kernel (e.g. ``write()``). This ABI relaxation is disabled by default and the application thread needs to explicitly enable it via ``prctl()`` as follows: - ``PR_SET_TAGGED_ADDR_CTRL``: enable or disable the AArch64 Tagged Address ABI for the calling thread. The ``(unsigned int) arg2`` argument is a bit mask describing the control mode used: - ``PR_TAGGED_ADDR_ENABLE``: enable AArch64 Tagged Address ABI. Default status is disabled. Arguments ``arg3``, ``arg4``, and ``arg5`` must be 0. - ``PR_GET_TAGGED_ADDR_CTRL``: get the status of the AArch64 Tagged Address ABI for the calling thread. Arguments ``arg2``, ``arg3``, ``arg4``, and ``arg5`` must be 0. The ABI properties described above are thread-scoped, inherited on clone() and fork() and cleared on exec(). Calling ``prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0)`` returns ``-EINVAL`` if the AArch64 Tagged Address ABI is globally disabled by ``sysctl abi.tagged_addr_disabled=1``. The default ``sysctl abi.tagged_addr_disabled`` configuration is 0. h](j)}(hUser addresses accessed by the kernel (e.g. ``write()``). This ABI relaxation is disabled by default and the application thread needs to explicitly enable it via ``prctl()`` as follows:h](h,User addresses accessed by the kernel (e.g. }(hjhhhNhNubjm)}(h ``write()``h]hwrite()}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubhk). This ABI relaxation is disabled by default and the application thread needs to explicitly enable it via }(hjhhhNhNubjm)}(h ``prctl()``h]hprctl()}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh as follows:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKChjubj)}(hhh](j)}(hXR``PR_SET_TAGGED_ADDR_CTRL``: enable or disable the AArch64 Tagged Address ABI for the calling thread. The ``(unsigned int) arg2`` argument is a bit mask describing the control mode used: - ``PR_TAGGED_ADDR_ENABLE``: enable AArch64 Tagged Address ABI. Default status is disabled. Arguments ``arg3``, ``arg4``, and ``arg5`` must be 0. h](j)}(he``PR_SET_TAGGED_ADDR_CTRL``: enable or disable the AArch64 Tagged Address ABI for the calling thread.h](jm)}(h``PR_SET_TAGGED_ADDR_CTRL``h]hPR_SET_TAGGED_ADDR_CTRL}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjQubhJ: enable or disable the AArch64 Tagged Address ABI for the calling thread.}(hjQhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKGhjMubj)}(hTThe ``(unsigned int) arg2`` argument is a bit mask describing the control mode used:h](hThe }(hjmhhhNhNubjm)}(h``(unsigned int) arg2``h]h(unsigned int) arg2}(hjuhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjmubh9 argument is a bit mask describing the control mode used:}(hjmhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKJhjMubj)}(hhh]j)}(hZ``PR_TAGGED_ADDR_ENABLE``: enable AArch64 Tagged Address ABI. Default status is disabled. h]j)}(hY``PR_TAGGED_ADDR_ENABLE``: enable AArch64 Tagged Address ABI. Default status is disabled.h](jm)}(h``PR_TAGGED_ADDR_ENABLE``h]hPR_TAGGED_ADDR_ENABLE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh@: enable AArch64 Tagged Address ABI. Default status is disabled.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKMhjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]j>j?uh1jhhhKMhjMubj)}(h5Arguments ``arg3``, ``arg4``, and ``arg5`` must be 0.h](h Arguments }(hjhhhNhNubjm)}(h``arg3``h]harg3}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh, }(hjhhhNhNubjm)}(h``arg4``h]harg4}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh, and }(hjhhhNhNubjm)}(h``arg5``h]harg5}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh must be 0.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKPhjMubeh}(h]h ]h"]h$]h&]uh1jhjJubj)}(h``PR_GET_TAGGED_ADDR_CTRL``: get the status of the AArch64 Tagged Address ABI for the calling thread. Arguments ``arg2``, ``arg3``, ``arg4``, and ``arg5`` must be 0. h](j)}(he``PR_GET_TAGGED_ADDR_CTRL``: get the status of the AArch64 Tagged Address ABI for the calling thread.h](jm)}(h``PR_GET_TAGGED_ADDR_CTRL``h]hPR_GET_TAGGED_ADDR_CTRL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhj ubhJ: get the status of the AArch64 Tagged Address ABI for the calling thread.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKRhjubj)}(h?Arguments ``arg2``, ``arg3``, ``arg4``, and ``arg5`` must be 0.h](h Arguments }(hj&hhhNhNubjm)}(h``arg2``h]harg2}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1jlhj&ubh, }(hj&hhhNhNubjm)}(h``arg3``h]harg3}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1jlhj&ubh, }hj&sbjm)}(h``arg4``h]harg4}(hjRhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhj&ubh, and }(hj&hhhNhNubjm)}(h``arg5``h]harg5}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhj&ubh must be 0.}(hj&hhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKUhjubeh}(h]h ]h"]h$]h&]uh1jhjJubeh}(h]h ]h"]h$]h&]j>j?uh1jhhhKGhjubj)}(hlThe ABI properties described above are thread-scoped, inherited on clone() and fork() and cleared on exec().h]hlThe ABI properties described above are thread-scoped, inherited on clone() and fork() and cleared on exec().}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKWhjubj)}(hXCalling ``prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0)`` returns ``-EINVAL`` if the AArch64 Tagged Address ABI is globally disabled by ``sysctl abi.tagged_addr_disabled=1``. The default ``sysctl abi.tagged_addr_disabled`` configuration is 0.h](hCalling }(hjhhhNhNubjm)}(hB``prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0)``h]h>prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh returns }(hjhhhNhNubjm)}(h ``-EINVAL``h]h-EINVAL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh; if the AArch64 Tagged Address ABI is globally disabled by }(hjhhhNhNubjm)}(h%``sysctl abi.tagged_addr_disabled=1``h]h!sysctl abi.tagged_addr_disabled=1}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh. The default }(hjhhhNhNubjm)}(h#``sysctl abi.tagged_addr_disabled``h]hsysctl abi.tagged_addr_disabled}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh configuration is 0.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKZhjubeh}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix.uh1jhjhhhhhK.ubj)}(heWhen the AArch64 Tagged Address ABI is enabled for a thread, the following behaviours are guaranteed:h]heWhen the AArch64 Tagged Address ABI is enabled for a thread, the following behaviours are guaranteed:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK_hjhhubj)}(hhh](j)}(hZAll syscalls except the cases mentioned in section 3 can accept any valid tagged pointer. h]j)}(hYAll syscalls except the cases mentioned in section 3 can accept any valid tagged pointer.h]hYAll syscalls except the cases mentioned in section 3 can accept any valid tagged pointer.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKbhjubah}(h]h ]h"]h$]h&]uh1jhj hhhhhNubj)}(hThe syscall behaviour is undefined for invalid tagged pointers: it may result in an error code being returned, a (fatal) signal being raised, or other modes of failure. h]j)}(hThe syscall behaviour is undefined for invalid tagged pointers: it may result in an error code being returned, a (fatal) signal being raised, or other modes of failure.h]hThe syscall behaviour is undefined for invalid tagged pointers: it may result in an error code being returned, a (fatal) signal being raised, or other modes of failure.}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKehj&ubah}(h]h ]h"]h$]h&]uh1jhj hhhhhNubj)}(hiThe syscall behaviour for a valid tagged pointer is the same as for the corresponding untagged pointer. h]j)}(hgThe syscall behaviour for a valid tagged pointer is the same as for the corresponding untagged pointer.h]hgThe syscall behaviour for a valid tagged pointer is the same as for the corresponding untagged pointer.}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKihj>ubah}(h]h ]h"]h$]h&]uh1jhj hhhhhNubeh}(h]h ]h"]h$]h&]j>j?uh1jhhhKbhjhhubj)}(hwA definition of the meaning of tagged pointers on AArch64 can be found in Documentation/arch/arm64/tagged-pointers.rst.h]hwA definition of the meaning of tagged pointers on AArch64 can be found in Documentation/arch/arm64/tagged-pointers.rst.}(hj\hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKmhjhhubeh}(h]id1ah ]h"]2. aarch64 tagged address abiah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h(3. AArch64 Tagged Address ABI Exceptionsh]h(3. AArch64 Tagged Address ABI Exceptions}(hjuhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjrhhhhhKqubj)}(hWThe following system call parameters must be untagged regardless of the ABI relaxation:h]hWThe following system call parameters must be untagged regardless of the ABI relaxation:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKshjrhhubj)}(hhh](j)}(h}``prctl()`` other than pointers to user data either passed directly or indirectly as arguments to be accessed by the kernel. h]j)}(h|``prctl()`` other than pointers to user data either passed directly or indirectly as arguments to be accessed by the kernel.h](jm)}(h ``prctl()``h]hprctl()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubhq other than pointers to user data either passed directly or indirectly as arguments to be accessed by the kernel.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKvhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h}``ioctl()`` other than pointers to user data either passed directly or indirectly as arguments to be accessed by the kernel. h]j)}(h|``ioctl()`` other than pointers to user data either passed directly or indirectly as arguments to be accessed by the kernel.h](jm)}(h ``ioctl()``h]hioctl()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubhq other than pointers to user data either passed directly or indirectly as arguments to be accessed by the kernel.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKyhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h``shmat()`` and ``shmdt()``. h]j)}(h``shmat()`` and ``shmdt()``.h](jm)}(h ``shmat()``h]hshmat()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh and }(hjhhhNhNubjm)}(h ``shmdt()``h]hshmdt()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhK|hjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h``brk()`` (since kernel v5.6). h]j)}(h``brk()`` (since kernel v5.6).h](jm)}(h ``brk()``h]hbrk()}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjubh (since kernel v5.6).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhK~hjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h ``mmap()`` (since kernel v5.6). h]j)}(h``mmap()`` (since kernel v5.6).h](jm)}(h ``mmap()``h]hmmap()}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjBubh (since kernel v5.6).}(hjBhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKhj>ubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h@``mremap()``, the ``new_address`` argument (since kernel v5.6). h]j)}(h?``mremap()``, the ``new_address`` argument (since kernel v5.6).h](jm)}(h ``mremap()``h]hmremap()}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjhubh, the }(hjhhhhNhNubjm)}(h``new_address``h]h new_address}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1jlhjhubh argument (since kernel v5.6).}(hjhhhhNhNubeh}(h]h ]h"]h$]h&]uh1jhhhKhjdubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]j>j?uh1jhhhKvhjrhhubj)}(hAny attempt to use non-zero tagged pointers may result in an error code being returned, a (fatal) signal being raised, or other modes of failure.h]hAny attempt to use non-zero tagged pointers may result in an error code being returned, a (fatal) signal being raised, or other modes of failure.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjrhhubeh}(h]%aarch64-tagged-address-abi-exceptionsah ]h"](3. aarch64 tagged address abi exceptionsah$]h&]uh1hhhhhhhhKqubh)}(hhh](h)}(h4. Example of correct usageh]h4. Example of correct usage}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh literal_block)}(hX#include #include #include #include #include #define PR_SET_TAGGED_ADDR_CTRL 55 #define PR_TAGGED_ADDR_ENABLE (1UL << 0) #define TAG_SHIFT 56 int main(void) { int tbi_enabled = 0; unsigned long tag = 0; char *ptr; /* check/enable the tagged address ABI */ if (!prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0)) tbi_enabled = 1; /* memory allocation */ ptr = mmap(NULL, sysconf(_SC_PAGE_SIZE), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (ptr == MAP_FAILED) return 1; /* set a non-zero tag if the ABI is available */ if (tbi_enabled) tag = rand() & 0xff; ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT)); /* memory access to a tagged address */ strcpy(ptr, "tagged pointer\n"); /* syscall with a tagged pointer */ write(1, ptr, strlen(ptr)); return 0; }h]hX#include #include #include #include #include #define PR_SET_TAGGED_ADDR_CTRL 55 #define PR_TAGGED_ADDR_ENABLE (1UL << 0) #define TAG_SHIFT 56 int main(void) { int tbi_enabled = 0; unsigned long tag = 0; char *ptr; /* check/enable the tagged address ABI */ if (!prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0)) tbi_enabled = 1; /* memory allocation */ ptr = mmap(NULL, sysconf(_SC_PAGE_SIZE), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (ptr == MAP_FAILED) return 1; /* set a non-zero tag if the ABI is available */ if (tbi_enabled) tag = rand() & 0xff; ptr = (char *)((unsigned long)ptr | (tag << TAG_SHIFT)); /* memory access to a tagged address */ strcpy(ptr, "tagged pointer\n"); /* syscall with a tagged pointer */ write(1, ptr, strlen(ptr)); return 0; }}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveforcelanguagechighlight_args}uh1jhhhKhjhhubeh}(h]example-of-correct-usageah ]h"]4. example of correct usageah$]h&]uh1hhhhhhhhKubeh}(h]aarch64-tagged-address-abiah ]h"]aarch64 tagged address abiah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourcehʌ _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jjjjjojljjjju nametypes}(jjjojjuh}(jhjjSjljjjrjju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}j!KsRparse_messages]transform_messages] transformerN include_log] decorationNhhub.