<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/arch/arm64/kernel/mte.c, branch linux-5.10.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.10.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.10.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2025-10-29T13:01:15Z</updated>
<entry>
<title>arm64: mte: Do not flag the zero page as PG_mte_tagged</title>
<updated>2025-10-29T13:01:15Z</updated>
<author>
<name>Catalin Marinas</name>
</author>
<published>2025-10-17T13:14:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cd1f79df5d82c8a9d82741de59d6ff45344884b0'/>
<id>urn:sha1:cd1f79df5d82c8a9d82741de59d6ff45344884b0</id>
<content type='text'>
[ Upstream commit f620d66af3165838bfa845dcf9f5f9b4089bf508 ]

Commit 68d54ceeec0e ("arm64: mte: Allow PTRACE_PEEKMTETAGS access to the
zero page") attempted to fix ptrace() reading of tags from the zero page
by marking it as PG_mte_tagged during cpu_enable_mte(). The same commit
also changed the ptrace() tag access permission check to the VM_MTE vma
flag while turning the page flag test into a WARN_ON_ONCE().

Attempting to set the PG_mte_tagged flag early with
CONFIG_DEFERRED_STRUCT_PAGE_INIT enabled may either hang (after commit
d77e59a8fccd "arm64: mte: Lock a page for MTE tag initialisation") or
have the flags cleared later during page_alloc_init_late(). In addition,
pages_identical() -&gt; memcmp_pages() will reject any comparison with the
zero page as it is marked as tagged.

Partially revert the above commit to avoid setting PG_mte_tagged on the
zero page. Update the __access_remote_tags() warning on untagged pages
to ignore the zero page since it is known to have the tags initialised.

Note that all user mapping of the zero page are marked as pte_special().
The arm64 set_pte_at() will not call mte_sync_tags() on such pages, so
PG_mte_tagged will remain cleared.

Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Fixes: 68d54ceeec0e ("arm64: mte: Allow PTRACE_PEEKMTETAGS access to the zero page")
Reported-by: Gergely Kovacs &lt;Gergely.Kovacs2@arm.com&gt;
Cc: stable@vger.kernel.org # 5.10.x
Cc: Will Deacon &lt;will@kernel.org&gt;
Cc: David Hildenbrand &lt;david@redhat.com&gt;
Cc: Lance Yang &lt;lance.yang@linux.dev&gt;
Acked-by: Lance Yang &lt;lance.yang@linux.dev&gt;
Reviewed-by: David Hildenbrand &lt;david@redhat.com&gt;
Tested-by: Lance Yang &lt;lance.yang@linux.dev&gt;
Signed-off-by: Will Deacon &lt;will@kernel.org&gt;
[ replaced is_zero_page() with is_zero_pfn(page_to_pfn()) and folio APIs with page APIs ]
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>arm64: mte: Ensure the cleared tags are visible before setting the PTE</title>
<updated>2022-05-25T07:17:56Z</updated>
<author>
<name>Catalin Marinas</name>
</author>
<published>2022-05-17T09:35:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6013ef5f51e0861a904b74a694e621bb451fe7ae'/>
<id>urn:sha1:6013ef5f51e0861a904b74a694e621bb451fe7ae</id>
<content type='text'>
commit 1d0cb4c8864addc362bae98e8ffa5500c87e1227 upstream.

As an optimisation, only pages mapped with PROT_MTE in user space have
the MTE tags zeroed. This is done lazily at the set_pte_at() time via
mte_sync_tags(). However, this function is missing a barrier and another
CPU may see the PTE updated before the zeroed tags are visible. Add an
smp_wmb() barrier if the mapping is Normal Tagged.

Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Fixes: 34bfeea4a9e9 ("arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE")
Cc: &lt;stable@vger.kernel.org&gt; # 5.10.x
Reported-by: Vladimir Murzin &lt;vladimir.murzin@arm.com&gt;
Cc: Will Deacon &lt;will@kernel.org&gt;
Reviewed-by: Steven Price &lt;steven.price@arm.com&gt;
Tested-by: Vladimir Murzin &lt;vladimir.murzin@arm.com&gt;
Link: https://lore.kernel.org/r/20220517093532.127095-1-catalin.marinas@arm.com
Signed-off-by: Will Deacon &lt;will@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>arm64: mte: Allow PTRACE_PEEKMTETAGS access to the zero page</title>
<updated>2021-02-17T10:02:28Z</updated>
<author>
<name>Catalin Marinas</name>
</author>
<published>2021-02-10T18:03:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=975a2396e37cecc42ba006d69d943be149efbeb0'/>
<id>urn:sha1:975a2396e37cecc42ba006d69d943be149efbeb0</id>
<content type='text'>
commit 68d54ceeec0e5fee4fb8048e6a04c193f32525ca upstream.

The ptrace(PTRACE_PEEKMTETAGS) implementation checks whether the user
page has valid tags (mapped with PROT_MTE) by testing the PG_mte_tagged
page flag. If this bit is cleared, ptrace(PTRACE_PEEKMTETAGS) returns
-EIO.

A newly created (PROT_MTE) mapping points to the zero page which had its
tags zeroed during cpu_enable_mte(). If there were no prior writes to
this mapping, ptrace(PTRACE_PEEKMTETAGS) fails with -EIO since the zero
page does not have the PG_mte_tagged flag set.

Set PG_mte_tagged on the zero page when its tags are cleared during
boot. In addition, to avoid ptrace(PTRACE_PEEKMTETAGS) succeeding on
!PROT_MTE mappings pointing to the zero page, change the
__access_remote_tags() check to (vm_flags &amp; VM_MTE) instead of
PG_mte_tagged.

Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Fixes: 34bfeea4a9e9 ("arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE")
Cc: &lt;stable@vger.kernel.org&gt; # 5.10.x
Cc: Will Deacon &lt;will@kernel.org&gt;
Reported-by: Luis Machado &lt;luis.machado@linaro.org&gt;
Tested-by: Luis Machado &lt;luis.machado@linaro.org&gt;
Reviewed-by: Vincenzo Frascino &lt;vincenzo.frascino@arm.com&gt;
Link: https://lore.kernel.org/r/20210210180316.23654-1-catalin.marinas@arm.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>arm64: mte: fix prctl(PR_GET_TAGGED_ADDR_CTRL) if TCF0=NONE</title>
<updated>2020-12-30T10:53:33Z</updated>
<author>
<name>Peter Collingbourne</name>
</author>
<published>2020-12-03T07:51:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0e3847accafa3c6da69c7d66a44be407fed2556d'/>
<id>urn:sha1:0e3847accafa3c6da69c7d66a44be407fed2556d</id>
<content type='text'>
[ Upstream commit 929c1f3384d7e5cd319d03242cb925c3f91236f7 ]

Previously we were always returning a tag inclusion mask of zero via
PR_GET_TAGGED_ADDR_CTRL if TCF0 was set to NONE. Fix it by making
the code for the NONE case match the others.

Signed-off-by: Peter Collingbourne &lt;pcc@google.com&gt;
Link: https://linux-review.googlesource.com/id/Iefbea66cf7d2b4c80b82f9639b9ea7f33f7fac53
Fixes: af5ce95282dc ("arm64: mte: Allow user control of the generated random tags via prctl()")
Reviewed-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Link: https://lore.kernel.org/r/20201203075110.2781021-1-pcc@google.com
Signed-off-by: Will Deacon &lt;will@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>arm64: mte: Enable swap of tagged pages</title>
<updated>2020-09-04T11:46:07Z</updated>
<author>
<name>Steven Price</name>
</author>
<published>2020-05-13T15:37:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=36943aba91860269abfba2e736e9534d48e90cae'/>
<id>urn:sha1:36943aba91860269abfba2e736e9534d48e90cae</id>
<content type='text'>
When swapping pages out to disk it is necessary to save any tags that
have been set, and restore when swapping back in. Make use of the new
page flag (PG_ARCH_2, locally named PG_mte_tagged) to identify pages
with tags. When swapping out these pages the tags are stored in memory
and later restored when the pages are brought back in. Because shmem can
swap pages back in without restoring the userspace PTE it is also
necessary to add a hook for shmem.

Signed-off-by: Steven Price &lt;steven.price@arm.com&gt;
[catalin.marinas@arm.com: move function prototypes to mte.h]
[catalin.marinas@arm.com: drop '_tags' from arch_swap_restore_tags()]
Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Will Deacon &lt;will@kernel.org&gt;
</content>
</entry>
<entry>
<title>arm64: mte: ptrace: Add PTRACE_{PEEK,POKE}MTETAGS support</title>
<updated>2020-09-04T11:46:07Z</updated>
<author>
<name>Catalin Marinas</name>
</author>
<published>2020-03-30T09:29:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=18ddbaa02b7a64f4cf3e7e3d4b78b8b70481a17b'/>
<id>urn:sha1:18ddbaa02b7a64f4cf3e7e3d4b78b8b70481a17b</id>
<content type='text'>
Add support for bulk setting/getting of the MTE tags in a tracee's
address space at 'addr' in the ptrace() syscall prototype. 'data' points
to a struct iovec in the tracer's address space with iov_base
representing the address of a tracer's buffer of length iov_len. The
tags to be copied to/from the tracer's buffer are stored as one tag per
byte.

On successfully copying at least one tag, ptrace() returns 0 and updates
the tracer's iov_len with the number of tags copied. In case of error,
either -EIO or -EFAULT is returned, trying to follow the ptrace() man
page.

Note that the tag copying functions are not performance critical,
therefore they lack optimisations found in typical memory copy routines.

Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Cc: Will Deacon &lt;will@kernel.org&gt;
Cc: Alan Hayward &lt;Alan.Hayward@arm.com&gt;
Cc: Luis Machado &lt;luis.machado@linaro.org&gt;
Cc: Omair Javaid &lt;omair.javaid@linaro.org&gt;
</content>
</entry>
<entry>
<title>arm64: mte: Allow {set,get}_tagged_addr_ctrl() on non-current tasks</title>
<updated>2020-09-04T11:46:07Z</updated>
<author>
<name>Catalin Marinas</name>
</author>
<published>2020-07-03T13:25:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=93f067f6caf5941cc730e99ce72042304e0e6ff5'/>
<id>urn:sha1:93f067f6caf5941cc730e99ce72042304e0e6ff5</id>
<content type='text'>
In preparation for ptrace() access to the prctl() value, allow calling
these functions on non-current tasks.

Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Cc: Will Deacon &lt;will@kernel.org&gt;
</content>
</entry>
<entry>
<title>arm64: mte: Restore the GCR_EL1 register after a suspend</title>
<updated>2020-09-04T11:46:07Z</updated>
<author>
<name>Catalin Marinas</name>
</author>
<published>2020-04-17T17:29:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=39d08e8318c49c5fd2bda9cadfd2bc54d2d3dfd8'/>
<id>urn:sha1:39d08e8318c49c5fd2bda9cadfd2bc54d2d3dfd8</id>
<content type='text'>
The CPU resume/suspend routines only take care of the common system
registers. Restore GCR_EL1 in addition via the __cpu_suspend_exit()
function.

Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Cc: Will Deacon &lt;will@kernel.org&gt;
Reviewed-by: Lorenzo Pieralisi &lt;lorenzo.pieralisi@arm.com&gt;
</content>
</entry>
<entry>
<title>arm64: mte: Allow user control of the generated random tags via prctl()</title>
<updated>2020-09-04T11:46:07Z</updated>
<author>
<name>Catalin Marinas</name>
</author>
<published>2019-12-10T11:19:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=af5ce95282dc99d08a27a407a02c763dde1c5558'/>
<id>urn:sha1:af5ce95282dc99d08a27a407a02c763dde1c5558</id>
<content type='text'>
The IRG, ADDG and SUBG instructions insert a random tag in the resulting
address. Certain tags can be excluded via the GCR_EL1.Exclude bitmap
when, for example, the user wants a certain colour for freed buffers.
Since the GCR_EL1 register is not accessible at EL0, extend the
prctl(PR_SET_TAGGED_ADDR_CTRL) interface to include a 16-bit field in
the first argument for controlling which tags can be generated by the
above instruction (an include rather than exclude mask). Note that by
default all non-zero tags are excluded. This setting is per-thread.

Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Cc: Will Deacon &lt;will@kernel.org&gt;
</content>
</entry>
<entry>
<title>arm64: mte: Allow user control of the tag check mode via prctl()</title>
<updated>2020-09-04T11:46:07Z</updated>
<author>
<name>Catalin Marinas</name>
</author>
<published>2019-11-27T10:30:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1c101da8b971a36695319dce7a24711dc567a0dd'/>
<id>urn:sha1:1c101da8b971a36695319dce7a24711dc567a0dd</id>
<content type='text'>
By default, even if PROT_MTE is set on a memory range, there is no tag
check fault reporting (SIGSEGV). Introduce a set of option to the
exiting prctl(PR_SET_TAGGED_ADDR_CTRL) to allow user control of the tag
check fault mode:

  PR_MTE_TCF_NONE  - no reporting (default)
  PR_MTE_TCF_SYNC  - synchronous tag check fault reporting
  PR_MTE_TCF_ASYNC - asynchronous tag check fault reporting

These options translate into the corresponding SCTLR_EL1.TCF0 bitfield,
context-switched by the kernel. Note that the kernel accesses to the
user address space (e.g. read() system call) are not checked if the user
thread tag checking mode is PR_MTE_TCF_NONE or PR_MTE_TCF_ASYNC. If the
tag checking mode is PR_MTE_TCF_SYNC, the kernel makes a best effort to
check its user address accesses, however it cannot always guarantee it.

Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Cc: Will Deacon &lt;will@kernel.org&gt;
</content>
</entry>
</feed>
