blob: 75beffe2ee8a86b936b469357466bc4179d1a569 [file] [log] [blame]
Thomas Gleixnercaab2772019-06-03 07:44:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Catalin Marinas4f04d8f2012-03-05 11:49:27 +00002/*
3 * Copyright (C) 2012 ARM Ltd.
Catalin Marinas4f04d8f2012-03-05 11:49:27 +00004 */
5#ifndef __ASM_MMU_H
6#define __ASM_MMU_H
7
Will Deaconb89d82e2019-01-08 16:19:01 +00008#include <asm/cputype.h>
9
Yury Norov5ce93ab62017-08-20 13:20:47 +030010#define MMCF_AARCH32 0x1 /* mm context flag for AArch32 executables */
James Morse79e9aa52018-01-08 15:38:18 +000011#define USER_ASID_BIT 48
12#define USER_ASID_FLAG (UL(1) << USER_ASID_BIT)
Will Deaconb5195382017-12-01 17:33:48 +000013#define TTBR_ASID_MASK (UL(0xffff) << 48)
Yury Norov5ce93ab62017-08-20 13:20:47 +030014
Will Deaconfc0e1292017-11-14 13:58:08 +000015#ifndef __ASSEMBLY__
16
Jean-Philippe Brucker48118152020-09-18 12:18:44 +020017#include <linux/refcount.h>
18
Catalin Marinas4f04d8f2012-03-05 11:49:27 +000019typedef struct {
Will Deacon5aec7152015-10-06 18:46:24 +010020 atomic64_t id;
Will Deacona39060b2020-06-22 12:35:41 +010021#ifdef CONFIG_COMPAT
22 void *sigpage;
23#endif
Jean-Philippe Brucker48118152020-09-18 12:18:44 +020024 refcount_t pinned;
Will Deacon5aec7152015-10-06 18:46:24 +010025 void *vdso;
Pratyush Anand06beb722016-11-02 14:40:45 +053026 unsigned long flags;
Catalin Marinas4f04d8f2012-03-05 11:49:27 +000027} mm_context_t;
28
Will Deacon5aec7152015-10-06 18:46:24 +010029/*
Will Deacon90765f72020-02-28 12:43:55 +000030 * This macro is only used by the TLBI and low-level switch_mm() code,
31 * neither of which can race with an ASID change. We therefore don't
32 * need to reload the counter using atomic64_read().
Will Deacon5aec7152015-10-06 18:46:24 +010033 */
34#define ASID(mm) ((mm)->context.id.counter & 0xffff)
Catalin Marinas4f04d8f2012-03-05 11:49:27 +000035
Will Deaconfc0e1292017-11-14 13:58:08 +000036static inline bool arm64_kernel_unmapped_at_el0(void)
37{
Will Deaconc8355782020-03-18 20:38:29 +000038 return cpus_have_const_cap(ARM64_UNMAP_KERNEL_AT_EL0);
Will Deaconb89d82e2019-01-08 16:19:01 +000039}
40
Will Deacon83504032019-01-14 14:22:24 +000041extern void arm64_memblock_init(void);
Catalin Marinas4f04d8f2012-03-05 11:49:27 +000042extern void paging_init(void);
David Daney3194ac62016-04-08 15:50:26 -070043extern void bootmem_init(void);
Catalin Marinas2475ff92012-10-23 14:55:08 +010044extern void __iomem *early_io_map(phys_addr_t phys, unsigned long virt);
Mark Salter0bf757c2014-04-07 15:39:51 -070045extern void init_mem_pgprot(void);
Ard Biesheuvel8ce837c2014-10-20 15:42:07 +020046extern void create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
47 unsigned long virt, phys_addr_t size,
Ard Biesheuvelf14c66c2016-10-21 12:22:57 +010048 pgprot_t prot, bool page_mappings_only);
Hsin-Yi Wange112b032019-08-23 14:24:50 +080049extern void *fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot);
Ard Biesheuvel5ea53062017-03-09 21:52:01 +010050extern void mark_linear_text_alias_ro(void);
Mark Brown09e3c222019-12-09 18:12:17 +000051extern bool kaslr_requires_kpti(void);
Catalin Marinas4f04d8f2012-03-05 11:49:27 +000052
Jun Yao2b5548b2018-09-24 15:47:49 +010053#define INIT_MM_CONTEXT(name) \
54 .pgd = init_pg_dir,
55
Will Deaconfc0e1292017-11-14 13:58:08 +000056#endif /* !__ASSEMBLY__ */
Catalin Marinas4f04d8f2012-03-05 11:49:27 +000057#endif