1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2012 ARM Ltd.
8 #include <asm/cputype.h>
10 #define MMCF_AARCH32 0x1 /* mm context flag for AArch32 executables */
11 #define USER_ASID_BIT 48
12 #define USER_ASID_FLAG (UL(1) << USER_ASID_BIT)
13 #define TTBR_ASID_MASK (UL(0xffff) << 48)
17 #include <linux/refcount.h>
18 #include <asm/cpufeature.h>
31 * We use atomic64_read() here because the ASID for an 'mm_struct' can
32 * be reallocated when scheduling one of its threads following a
33 * rollover event (see new_context() and flush_context()). In this case,
34 * a concurrent TLBI (e.g. via try_to_unmap_one() and ptep_clear_flush())
35 * may use a stale ASID. This is fine in principle as the new ASID is
36 * guaranteed to be clean in the TLB, but the TLBI routines have to take
37 * care to handle the following race:
41 * // ptep_clear_flush(mm)
42 * xchg_relaxed(pte, 0)
46 * | new = new_context(mm)
47 * \-----------------> atomic_set(mm->context.id, new)
49 * // Hardware walk of pte using new ASID
52 * In this scenario, the barrier on CPU 0 and the dependency on CPU 1
53 * ensure that the page-table walker on CPU 1 *must* see the invalid PTE
56 #define ASID(mm) (atomic64_read(&(mm)->context.id) & 0xffff)
58 static inline bool arm64_kernel_unmapped_at_el0(void)
60 return alternative_has_cap_unlikely(ARM64_UNMAP_KERNEL_AT_EL0);
63 extern void arm64_memblock_init(void);
64 extern void paging_init(void);
65 extern void bootmem_init(void);
66 extern void __iomem *early_io_map(phys_addr_t phys, unsigned long virt);
67 extern void create_mapping_noalloc(phys_addr_t phys, unsigned long virt,
68 phys_addr_t size, pgprot_t prot);
69 extern void create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
70 unsigned long virt, phys_addr_t size,
71 pgprot_t prot, bool page_mappings_only);
72 extern void *fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot);
73 extern void mark_linear_text_alias_ro(void);
74 extern bool kaslr_requires_kpti(void);
76 #define INIT_MM_CONTEXT(name) \
79 #endif /* !__ASSEMBLY__ */