2sphinx.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]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 <}(hhhhhNhNubh)}(hcatalin.marinas@arm.comh]hcatalin.marinas@arm.com}(hhhhhNhNubah}(h]h ]h"]h$]h&]refurimailto:catalin.marinas@arm.comuh1hhhubh>}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhubah}(h]h ]h"]h$]h&]uh1hhhubeh}(h]h ]h"]h$]h&]uh1hhhhKhhubah}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hDate: 21 August 2019h]hDate: 21 August 2019}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(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.}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hhh](h)}(h1. Introductionh]h1. Introduction}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj?hhhhhKubh)}(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 }(hjPhhhNhNubhliteral)}(h``TCR_EL1.TBI0``h]h TCR_EL1.TBI0}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjPubhX 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.}(hjPhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj?hhubeh}(h] introductionah ]h"]1. introductionah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h2. AArch64 Tagged Address ABIh]h2. AArch64 Tagged Address ABI}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjzhhhhhKubh)}(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&]uh1hhhhKhjzhhubh 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](h)}(h ``mmap()`` syscall where either:h](jY)}(h ``mmap()``h]hmmap()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh syscall where either:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hhh](j)}(h+flags have the ``MAP_ANONYMOUS`` bit set orh]h)}(hjh](hflags have the }(hjhhhNhNubjY)}(h``MAP_ANONYMOUS``h]h MAP_ANONYMOUS}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh bit set or}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK 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]h)}(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 }(hjhhhNhNubjY)}(h``memfd_create()``h]hmemfd_create()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh) or }(hjhhhNhNubjY)}(h ``/dev/zero``h]h /dev/zero}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubeh}(h]h ]h"]h$]h&]uh1hhhhK!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]h)}(h``brk()`` syscall (i.e. the heap area between the initial location of the program break at process creation and its current location).h](jY)}(h ``brk()``h]hbrk()}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1jXhj6ubh} syscall (i.e. the heap area between the initial location of the program break at process creation and its current location).}(hj6hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK$hj2ubah}(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]h)}(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 }(hj\hhhNhNubjY)}(h ``mmap()``h]hmmap()}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhj\ubh above (e.g. data, bss, stack).}(hj\hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK'hjXubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]j*j+uh1jhhhKhjzhhubh)}(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&]uh1hhhhK+hjzhhubhenumerated_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](h)}(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. }(hjhhhNhNubjY)}(h``mprotect()``h]h mprotect()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh, }(hjhhhNhNubjY)}(h ``madvise()``h]h madvise()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubhU). The use of valid tagged pointers in this context is allowed with these exceptions:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK.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](h)}(h``brk()``, ``mmap()`` and the ``new_address`` argument to ``mremap()`` as these have the potential to alias with existing user addresses.h](jY)}(h ``brk()``h]hbrk()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh, }(hjhhhNhNubjY)}(h ``mmap()``h]hmmap()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh and the }(hjhhhNhNubjY)}(h``new_address``h]h new_address}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh argument to }(hjhhhNhNubjY)}(h ``mremap()``h]hmremap()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubhC as these have the potential to alias with existing user addresses.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK2hjubh)}(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*hhhNhNubjY)}(h ``brk()``h]hbrk()}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jXhj*ubh, }(hj*hhhNhNubjY)}(h ``mmap()``h]hmmap()}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhj*ubh and }(hj*hhhNhNubjY)}(h ``mremap()``h]hmremap()}(hjVhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhj*ubh system calls.}(hj*hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK6hjubeh}(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](h)}(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 }(hjxhhhNhNubjY)}(h``range.start``h]h range.start}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjxubh, }(hjxhhhNhNubjY)}(h ``start``h]hstart}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjxubh and }(hjxhhhNhNubjY)}(h``dst``h]hdst}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjxubh arguments to the }(hjxhhhNhNubjY)}(h ``UFFDIO_*``h]hUFFDIO_*}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjxubh }(hjxhhhNhNubjY)}(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&]uh1jXhjxubh, as fault addresses subsequently obtained by reading the file descriptor will be untagged, which may otherwise confuse tag-unaware programs.}(hjxhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK:hjtubh)}(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&]uh1hhhhK@hjtubeh}(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](h)}(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. }(hjhhhNhNubjY)}(h ``write()``h]hwrite()}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubhk). This ABI relaxation is disabled by default and the application thread needs to explicitly enable it via }(hjhhhNhNubjY)}(h ``prctl()``h]hprctl()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh as follows:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKChjubj)}(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](h)}(he``PR_SET_TAGGED_ADDR_CTRL``: enable or disable the AArch64 Tagged Address ABI for the calling thread.h](jY)}(h``PR_SET_TAGGED_ADDR_CTRL``h]hPR_SET_TAGGED_ADDR_CTRL}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhj=ubhJ: enable or disable the AArch64 Tagged Address ABI for the calling thread.}(hj=hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKGhj9ubh)}(hTThe ``(unsigned int) arg2`` argument is a bit mask describing the control mode used:h](hThe }(hjYhhhNhNubjY)}(h``(unsigned int) arg2``h]h(unsigned int) arg2}(hjahhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjYubh9 argument is a bit mask describing the control mode used:}(hjYhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKJhj9ubj)}(hhh]j)}(hZ``PR_TAGGED_ADDR_ENABLE``: enable AArch64 Tagged Address ABI. Default status is disabled. h]h)}(hY``PR_TAGGED_ADDR_ENABLE``: enable AArch64 Tagged Address ABI. Default status is disabled.h](jY)}(h``PR_TAGGED_ADDR_ENABLE``h]hPR_TAGGED_ADDR_ENABLE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh@: enable AArch64 Tagged Address ABI. Default status is disabled.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKMhj|ubah}(h]h ]h"]h$]h&]uh1jhjyubah}(h]h ]h"]h$]h&]j*j+uh1jhhhKMhj9ubh)}(h5Arguments ``arg3``, ``arg4``, and ``arg5`` must be 0.h](h Arguments }(hjhhhNhNubjY)}(h``arg3``h]harg3}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh, }(hjhhhNhNubjY)}(h``arg4``h]harg4}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh, and }(hjhhhNhNubjY)}(h``arg5``h]harg5}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh must be 0.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKPhj9ubeh}(h]h ]h"]h$]h&]uh1jhj6ubj)}(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](h)}(he``PR_GET_TAGGED_ADDR_CTRL``: get the status of the AArch64 Tagged Address ABI for the calling thread.h](jY)}(h``PR_GET_TAGGED_ADDR_CTRL``h]hPR_GET_TAGGED_ADDR_CTRL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubhJ: get the status of the AArch64 Tagged Address ABI for the calling thread.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKRhjubh)}(h?Arguments ``arg2``, ``arg3``, ``arg4``, and ``arg5`` must be 0.h](h Arguments }(hjhhhNhNubjY)}(h``arg2``h]harg2}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh, }(hjhhhNhNubjY)}(h``arg3``h]harg3}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh, }hjsbjY)}(h``arg4``h]harg4}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh, and }(hjhhhNhNubjY)}(h``arg5``h]harg5}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh must be 0.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKUhjubeh}(h]h ]h"]h$]h&]uh1jhj6ubeh}(h]h ]h"]h$]h&]j*j+uh1jhhhKGhjubh)}(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().}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKWhjubh)}(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 }(hjhhhNhNubjY)}(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&]uh1jXhjubh returns }(hjhhhNhNubjY)}(h ``-EINVAL``h]h-EINVAL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh; if the AArch64 Tagged Address ABI is globally disabled by }(hjhhhNhNubjY)}(h%``sysctl abi.tagged_addr_disabled=1``h]h!sysctl abi.tagged_addr_disabled=1}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh. The default }(hjhhhNhNubjY)}(h#``sysctl abi.tagged_addr_disabled``h]hsysctl abi.tagged_addr_disabled}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh configuration is 0.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKZhjubeh}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix.uh1jhjzhhhhhK.ubh)}(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&]uh1hhhhK_hjzhhubj)}(hhh](j)}(hZAll syscalls except the cases mentioned in section 3 can accept any valid tagged pointer. h]h)}(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&]uh1hhhhKbhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(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]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.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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKehjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hiThe syscall behaviour for a valid tagged pointer is the same as for the corresponding untagged pointer. h]h)}(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.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKihj*ubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]j*j+uh1jhhhKbhjzhhubh)}(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.}(hjHhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKmhjzhhubeh}(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}(hjahhhNhNubah}(h]h ]h"]h$]h&]uh1hhj^hhhhhKqubh)}(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:}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKshj^hhubj)}(hhh](j)}(h}``prctl()`` other than pointers to user data either passed directly or indirectly as arguments to be accessed by the kernel. h]h)}(h|``prctl()`` other than pointers to user data either passed directly or indirectly as arguments to be accessed by the kernel.h](jY)}(h ``prctl()``h]hprctl()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubhq 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&]uh1hhhhKvhjubah}(h]h ]h"]h$]h&]uh1jhj}hhhhhNubj)}(h}``ioctl()`` other than pointers to user data either passed directly or indirectly as arguments to be accessed by the kernel. h]h)}(h|``ioctl()`` other than pointers to user data either passed directly or indirectly as arguments to be accessed by the kernel.h](jY)}(h ``ioctl()``h]hioctl()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubhq 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&]uh1hhhhKyhjubah}(h]h ]h"]h$]h&]uh1jhj}hhhhhNubj)}(h``shmat()`` and ``shmdt()``. h]h)}(h``shmat()`` and ``shmdt()``.h](jY)}(h ``shmat()``h]hshmat()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh and }(hjhhhNhNubjY)}(h ``shmdt()``h]hshmdt()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK|hjubah}(h]h ]h"]h$]h&]uh1jhj}hhhhhNubj)}(h``brk()`` (since kernel v5.6). h]h)}(h``brk()`` (since kernel v5.6).h](jY)}(h ``brk()``h]hbrk()}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjubh (since kernel v5.6).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK~hjubah}(h]h ]h"]h$]h&]uh1jhj}hhhhhNubj)}(h ``mmap()`` (since kernel v5.6). h]h)}(h``mmap()`` (since kernel v5.6).h](jY)}(h ``mmap()``h]hmmap()}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jXhj.ubh (since kernel v5.6).}(hj.hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj*ubah}(h]h ]h"]h$]h&]uh1jhj}hhhhhNubj)}(h@``mremap()``, the ``new_address`` argument (since kernel v5.6). h]h)}(h?``mremap()``, the ``new_address`` argument (since kernel v5.6).h](jY)}(h ``mremap()``h]hmremap()}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjTubh, the }(hjThhhNhNubjY)}(h``new_address``h]h new_address}(hjjhhhNhNubah}(h]h ]h"]h$]h&]uh1jXhjTubh argument (since kernel v5.6).}(hjThhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjPubah}(h]h ]h"]h$]h&]uh1jhj}hhhhhNubeh}(h]h ]h"]h$]h&]j*j+uh1jhhhKvhj^hhubh)}(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&]uh1hhhhKhj^hhubeh}(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}(jjjwjtj[jXjjjju nametypes}(jjwj[jjuh}(jhjtj?jXjzjj^jju 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.