arch/arm64/include/asm/mte.h
Source file repositories/reference/linux-study-clean/arch/arm64/include/asm/mte.h
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/include/asm/mte.h- Extension
.h- Size
- 7283 bytes
- Lines
- 293
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/compiler.hasm/mte-def.hlinux/bitfield.hlinux/kasan-enabled.hlinux/page-flags.hlinux/sched.hlinux/types.hasm/pgtable-types.h
Detected Declarations
function set_page_mte_taggedfunction page_mte_taggedfunction taggedfunction set_page_mte_taggedfunction try_page_mte_taggingfunction mte_zero_clear_page_tagsfunction get_mte_ctrlfunction mte_ptrace_copy_tagsfunction folio_set_hugetlb_mte_taggedfunction folio_test_hugetlb_mte_taggedfunction folio_try_hugetlb_mte_taggingfunction folio_set_hugetlb_mte_taggedfunction folio_try_hugetlb_mte_taggingfunction mte_disable_tco_entryfunction mte_check_tfsr_entryfunction mte_check_tfsr_exitfunction mte_check_tfsr_el1
Annotated Snippet
#ifndef __ASM_MTE_H
#define __ASM_MTE_H
#include <asm/compiler.h>
#include <asm/mte-def.h>
#ifndef __ASSEMBLER__
#include <linux/bitfield.h>
#include <linux/kasan-enabled.h>
#include <linux/page-flags.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <asm/pgtable-types.h>
void mte_clear_page_tags(void *addr);
unsigned long mte_copy_tags_from_user(void *to, const void __user *from,
unsigned long n);
unsigned long mte_copy_tags_to_user(void __user *to, void *from,
unsigned long n);
int mte_save_tags(struct page *page);
void mte_save_page_tags(const void *page_addr, void *tag_storage);
void mte_restore_tags(swp_entry_t entry, struct page *page);
void mte_restore_page_tags(void *page_addr, const void *tag_storage);
void mte_invalidate_tags(int type, pgoff_t offset);
void mte_invalidate_tags_area(int type);
void *mte_allocate_tag_storage(void);
void mte_free_tag_storage(char *storage);
#ifdef CONFIG_ARM64_MTE
/* track which pages have valid allocation tags */
#define PG_mte_tagged PG_arch_2
/* simple lock to avoid multiple threads tagging the same page */
#define PG_mte_lock PG_arch_3
static inline void set_page_mte_tagged(struct page *page)
{
VM_WARN_ON_ONCE(folio_test_hugetlb(page_folio(page)));
/*
* Ensure that the tags written prior to this function are visible
* before the page flags update.
*/
smp_wmb();
set_bit(PG_mte_tagged, &page->flags.f);
}
static inline bool page_mte_tagged(struct page *page)
{
bool ret = test_bit(PG_mte_tagged, &page->flags.f);
VM_WARN_ON_ONCE(folio_test_hugetlb(page_folio(page)));
/*
* If the page is tagged, ensure ordering with a likely subsequent
* read of the tags.
*/
if (ret)
smp_rmb();
return ret;
}
/*
* Lock the page for tagging and return 'true' if the page can be tagged,
* 'false' if already tagged. PG_mte_tagged is never cleared and therefore the
* locking only happens once for page initialisation.
*
* The page MTE lock state:
*
* Locked: PG_mte_lock && !PG_mte_tagged
* Unlocked: !PG_mte_lock || PG_mte_tagged
*
* Acquire semantics only if the page is tagged (returning 'false').
*/
static inline bool try_page_mte_tagging(struct page *page)
{
VM_WARN_ON_ONCE(folio_test_hugetlb(page_folio(page)));
if (!test_and_set_bit(PG_mte_lock, &page->flags.f))
return true;
/*
* The tags are either being initialised or may have been initialised
* already. Check if the PG_mte_tagged flag has been set or wait
* otherwise.
*/
smp_cond_load_acquire(&page->flags.f, VAL & (1UL << PG_mte_tagged));
Annotation
- Immediate include surface: `asm/compiler.h`, `asm/mte-def.h`, `linux/bitfield.h`, `linux/kasan-enabled.h`, `linux/page-flags.h`, `linux/sched.h`, `linux/types.h`, `asm/pgtable-types.h`.
- Detected declarations: `function set_page_mte_tagged`, `function page_mte_tagged`, `function tagged`, `function set_page_mte_tagged`, `function try_page_mte_tagging`, `function mte_zero_clear_page_tags`, `function get_mte_ctrl`, `function mte_ptrace_copy_tags`, `function folio_set_hugetlb_mte_tagged`, `function folio_test_hugetlb_mte_tagged`.
- Atlas domain: Architecture Layer / arch/arm64.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.