162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  arch/arm/include/asm/pgtable.h
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci *  Copyright (C) 1995-2002 Russell King
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci#ifndef _ASMARM_PGTABLE_H
862306a36Sopenharmony_ci#define _ASMARM_PGTABLE_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <linux/const.h>
1162306a36Sopenharmony_ci#include <asm/proc-fns.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#ifndef __ASSEMBLY__
1462306a36Sopenharmony_ci/*
1562306a36Sopenharmony_ci * ZERO_PAGE is a global shared page that is always zero: used
1662306a36Sopenharmony_ci * for zero-mapped memory areas etc..
1762306a36Sopenharmony_ci */
1862306a36Sopenharmony_ciextern struct page *empty_zero_page;
1962306a36Sopenharmony_ci#define ZERO_PAGE(vaddr)	(empty_zero_page)
2062306a36Sopenharmony_ci#endif
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#ifndef CONFIG_MMU
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#include <asm-generic/pgtable-nopud.h>
2562306a36Sopenharmony_ci#include <asm/pgtable-nommu.h>
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#else
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci#include <asm-generic/pgtable-nopud.h>
3062306a36Sopenharmony_ci#include <asm/page.h>
3162306a36Sopenharmony_ci#include <asm/pgtable-hwdef.h>
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci#include <asm/tlbflush.h>
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#ifdef CONFIG_ARM_LPAE
3762306a36Sopenharmony_ci#include <asm/pgtable-3level.h>
3862306a36Sopenharmony_ci#else
3962306a36Sopenharmony_ci#include <asm/pgtable-2level.h>
4062306a36Sopenharmony_ci#endif
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci/*
4362306a36Sopenharmony_ci * Just any arbitrary offset to the start of the vmalloc VM area: the
4462306a36Sopenharmony_ci * current 8MB value just means that there will be a 8MB "hole" after the
4562306a36Sopenharmony_ci * physical memory until the kernel virtual memory starts.  That means that
4662306a36Sopenharmony_ci * any out-of-bounds memory accesses will hopefully be caught.
4762306a36Sopenharmony_ci * The vmalloc() routines leaves a hole of 4kB between each vmalloced
4862306a36Sopenharmony_ci * area for the same reason. ;)
4962306a36Sopenharmony_ci */
5062306a36Sopenharmony_ci#define VMALLOC_OFFSET		(8*1024*1024)
5162306a36Sopenharmony_ci#define VMALLOC_START		(((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
5262306a36Sopenharmony_ci#define VMALLOC_END		0xff800000UL
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#define LIBRARY_TEXT_START	0x0c000000
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci#ifndef __ASSEMBLY__
5762306a36Sopenharmony_ciextern void __pte_error(const char *file, int line, pte_t);
5862306a36Sopenharmony_ciextern void __pmd_error(const char *file, int line, pmd_t);
5962306a36Sopenharmony_ciextern void __pgd_error(const char *file, int line, pgd_t);
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci#define pte_ERROR(pte)		__pte_error(__FILE__, __LINE__, pte)
6262306a36Sopenharmony_ci#define pmd_ERROR(pmd)		__pmd_error(__FILE__, __LINE__, pmd)
6362306a36Sopenharmony_ci#define pgd_ERROR(pgd)		__pgd_error(__FILE__, __LINE__, pgd)
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci/*
6662306a36Sopenharmony_ci * This is the lowest virtual address we can permit any user space
6762306a36Sopenharmony_ci * mapping to be mapped at.  This is particularly important for
6862306a36Sopenharmony_ci * non-high vector CPUs.
6962306a36Sopenharmony_ci */
7062306a36Sopenharmony_ci#define FIRST_USER_ADDRESS	(PAGE_SIZE * 2)
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci/*
7362306a36Sopenharmony_ci * Use TASK_SIZE as the ceiling argument for free_pgtables() and
7462306a36Sopenharmony_ci * free_pgd_range() to avoid freeing the modules pmd when LPAE is enabled (pmd
7562306a36Sopenharmony_ci * page shared between user and kernel).
7662306a36Sopenharmony_ci */
7762306a36Sopenharmony_ci#ifdef CONFIG_ARM_LPAE
7862306a36Sopenharmony_ci#define USER_PGTABLES_CEILING	TASK_SIZE
7962306a36Sopenharmony_ci#endif
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci/*
8262306a36Sopenharmony_ci * The pgprot_* and protection_map entries will be fixed up in runtime
8362306a36Sopenharmony_ci * to include the cachable and bufferable bits based on memory policy,
8462306a36Sopenharmony_ci * as well as any architecture dependent bits like global/ASID and SMP
8562306a36Sopenharmony_ci * shared mapping bits.
8662306a36Sopenharmony_ci */
8762306a36Sopenharmony_ci#define _L_PTE_DEFAULT	L_PTE_PRESENT | L_PTE_YOUNG
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ciextern pgprot_t		pgprot_user;
9062306a36Sopenharmony_ciextern pgprot_t		pgprot_kernel;
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci#define _MOD_PROT(p, b)	__pgprot(pgprot_val(p) | (b))
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci#define PAGE_NONE		_MOD_PROT(pgprot_user, L_PTE_XN | L_PTE_RDONLY | L_PTE_NONE)
9562306a36Sopenharmony_ci#define PAGE_SHARED		_MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_XN)
9662306a36Sopenharmony_ci#define PAGE_SHARED_EXEC	_MOD_PROT(pgprot_user, L_PTE_USER)
9762306a36Sopenharmony_ci#define PAGE_COPY		_MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_RDONLY | L_PTE_XN)
9862306a36Sopenharmony_ci#define PAGE_COPY_EXEC		_MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_RDONLY)
9962306a36Sopenharmony_ci#define PAGE_READONLY		_MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_RDONLY | L_PTE_XN)
10062306a36Sopenharmony_ci#define PAGE_READONLY_EXEC	_MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_RDONLY)
10162306a36Sopenharmony_ci#define PAGE_KERNEL		_MOD_PROT(pgprot_kernel, L_PTE_XN)
10262306a36Sopenharmony_ci#define PAGE_KERNEL_EXEC	pgprot_kernel
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci#define __PAGE_NONE		__pgprot(_L_PTE_DEFAULT | L_PTE_RDONLY | L_PTE_XN | L_PTE_NONE)
10562306a36Sopenharmony_ci#define __PAGE_SHARED		__pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_XN)
10662306a36Sopenharmony_ci#define __PAGE_SHARED_EXEC	__pgprot(_L_PTE_DEFAULT | L_PTE_USER)
10762306a36Sopenharmony_ci#define __PAGE_COPY		__pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_RDONLY | L_PTE_XN)
10862306a36Sopenharmony_ci#define __PAGE_COPY_EXEC	__pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_RDONLY)
10962306a36Sopenharmony_ci#define __PAGE_READONLY		__pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_RDONLY | L_PTE_XN)
11062306a36Sopenharmony_ci#define __PAGE_READONLY_EXEC	__pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_RDONLY)
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci#define __pgprot_modify(prot,mask,bits)		\
11362306a36Sopenharmony_ci	__pgprot((pgprot_val(prot) & ~(mask)) | (bits))
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci#define pgprot_noncached(prot) \
11662306a36Sopenharmony_ci	__pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_UNCACHED)
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci#define pgprot_writecombine(prot) \
11962306a36Sopenharmony_ci	__pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_BUFFERABLE)
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci#define pgprot_stronglyordered(prot) \
12262306a36Sopenharmony_ci	__pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_UNCACHED)
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci#define pgprot_device(prot) \
12562306a36Sopenharmony_ci	__pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_DEV_SHARED | L_PTE_SHARED | L_PTE_DIRTY | L_PTE_XN)
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci#ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
12862306a36Sopenharmony_ci#define pgprot_dmacoherent(prot) \
12962306a36Sopenharmony_ci	__pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_BUFFERABLE | L_PTE_XN)
13062306a36Sopenharmony_ci#define __HAVE_PHYS_MEM_ACCESS_PROT
13162306a36Sopenharmony_cistruct file;
13262306a36Sopenharmony_ciextern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
13362306a36Sopenharmony_ci				     unsigned long size, pgprot_t vma_prot);
13462306a36Sopenharmony_ci#else
13562306a36Sopenharmony_ci#define pgprot_dmacoherent(prot) \
13662306a36Sopenharmony_ci	__pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_UNCACHED | L_PTE_XN)
13762306a36Sopenharmony_ci#endif
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci/*
14262306a36Sopenharmony_ci * The table below defines the page protection levels that we insert into our
14362306a36Sopenharmony_ci * Linux page table version.  These get translated into the best that the
14462306a36Sopenharmony_ci * architecture can perform.  Note that on most ARM hardware:
14562306a36Sopenharmony_ci *  1) We cannot do execute protection
14662306a36Sopenharmony_ci *  2) If we could do execute protection, then read is implied
14762306a36Sopenharmony_ci *  3) write implies read permissions
14862306a36Sopenharmony_ci */
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci#ifndef __ASSEMBLY__
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ciextern pgd_t swapper_pg_dir[PTRS_PER_PGD];
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci#define pud_page(pud)		pmd_page(__pmd(pud_val(pud)))
15562306a36Sopenharmony_ci#define pud_write(pud)		pmd_write(__pmd(pud_val(pud)))
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci#define pmd_none(pmd)		(!pmd_val(pmd))
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_cistatic inline pte_t *pmd_page_vaddr(pmd_t pmd)
16062306a36Sopenharmony_ci{
16162306a36Sopenharmony_ci	return __va(pmd_val(pmd) & PHYS_MASK & (s32)PAGE_MASK);
16262306a36Sopenharmony_ci}
16362306a36Sopenharmony_ci
16462306a36Sopenharmony_ci#define pmd_page(pmd)		pfn_to_page(__phys_to_pfn(pmd_val(pmd) & PHYS_MASK))
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ci#define pte_pfn(pte)		((pte_val(pte) & PHYS_MASK) >> PAGE_SHIFT)
16762306a36Sopenharmony_ci#define pfn_pte(pfn,prot)	__pte(__pfn_to_phys(pfn) | pgprot_val(prot))
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ci#define pte_page(pte)		pfn_to_page(pte_pfn(pte))
17062306a36Sopenharmony_ci#define mk_pte(page,prot)	pfn_pte(page_to_pfn(page), prot)
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci#define pte_clear(mm,addr,ptep)	set_pte_ext(ptep, __pte(0), 0)
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci#define pte_isset(pte, val)	((u32)(val) == (val) ? pte_val(pte) & (val) \
17562306a36Sopenharmony_ci						: !!(pte_val(pte) & (val)))
17662306a36Sopenharmony_ci#define pte_isclear(pte, val)	(!(pte_val(pte) & (val)))
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_ci#define pte_none(pte)		(!pte_val(pte))
17962306a36Sopenharmony_ci#define pte_present(pte)	(pte_isset((pte), L_PTE_PRESENT))
18062306a36Sopenharmony_ci#define pte_valid(pte)		(pte_isset((pte), L_PTE_VALID))
18162306a36Sopenharmony_ci#define pte_accessible(mm, pte)	(mm_tlb_flush_pending(mm) ? pte_present(pte) : pte_valid(pte))
18262306a36Sopenharmony_ci#define pte_write(pte)		(pte_isclear((pte), L_PTE_RDONLY))
18362306a36Sopenharmony_ci#define pte_dirty(pte)		(pte_isset((pte), L_PTE_DIRTY))
18462306a36Sopenharmony_ci#define pte_young(pte)		(pte_isset((pte), L_PTE_YOUNG))
18562306a36Sopenharmony_ci#define pte_exec(pte)		(pte_isclear((pte), L_PTE_XN))
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ci#define pte_valid_user(pte)	\
18862306a36Sopenharmony_ci	(pte_valid(pte) && pte_isset((pte), L_PTE_USER) && pte_young(pte))
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_cistatic inline bool pte_access_permitted(pte_t pte, bool write)
19162306a36Sopenharmony_ci{
19262306a36Sopenharmony_ci	pteval_t mask = L_PTE_PRESENT | L_PTE_USER;
19362306a36Sopenharmony_ci	pteval_t needed = mask;
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci	if (write)
19662306a36Sopenharmony_ci		mask |= L_PTE_RDONLY;
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ci	return (pte_val(pte) & mask) == needed;
19962306a36Sopenharmony_ci}
20062306a36Sopenharmony_ci#define pte_access_permitted pte_access_permitted
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ci#if __LINUX_ARM_ARCH__ < 6
20362306a36Sopenharmony_cistatic inline void __sync_icache_dcache(pte_t pteval)
20462306a36Sopenharmony_ci{
20562306a36Sopenharmony_ci}
20662306a36Sopenharmony_ci#else
20762306a36Sopenharmony_ciextern void __sync_icache_dcache(pte_t pteval);
20862306a36Sopenharmony_ci#endif
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_civoid set_ptes(struct mm_struct *mm, unsigned long addr,
21162306a36Sopenharmony_ci		      pte_t *ptep, pte_t pteval, unsigned int nr);
21262306a36Sopenharmony_ci#define set_ptes set_ptes
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_cistatic inline pte_t clear_pte_bit(pte_t pte, pgprot_t prot)
21562306a36Sopenharmony_ci{
21662306a36Sopenharmony_ci	pte_val(pte) &= ~pgprot_val(prot);
21762306a36Sopenharmony_ci	return pte;
21862306a36Sopenharmony_ci}
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_cistatic inline pte_t set_pte_bit(pte_t pte, pgprot_t prot)
22162306a36Sopenharmony_ci{
22262306a36Sopenharmony_ci	pte_val(pte) |= pgprot_val(prot);
22362306a36Sopenharmony_ci	return pte;
22462306a36Sopenharmony_ci}
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_cistatic inline pte_t pte_wrprotect(pte_t pte)
22762306a36Sopenharmony_ci{
22862306a36Sopenharmony_ci	return set_pte_bit(pte, __pgprot(L_PTE_RDONLY));
22962306a36Sopenharmony_ci}
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_cistatic inline pte_t pte_mkwrite_novma(pte_t pte)
23262306a36Sopenharmony_ci{
23362306a36Sopenharmony_ci	return clear_pte_bit(pte, __pgprot(L_PTE_RDONLY));
23462306a36Sopenharmony_ci}
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_cistatic inline pte_t pte_mkclean(pte_t pte)
23762306a36Sopenharmony_ci{
23862306a36Sopenharmony_ci	return clear_pte_bit(pte, __pgprot(L_PTE_DIRTY));
23962306a36Sopenharmony_ci}
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_cistatic inline pte_t pte_mkdirty(pte_t pte)
24262306a36Sopenharmony_ci{
24362306a36Sopenharmony_ci	return set_pte_bit(pte, __pgprot(L_PTE_DIRTY));
24462306a36Sopenharmony_ci}
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_cistatic inline pte_t pte_mkold(pte_t pte)
24762306a36Sopenharmony_ci{
24862306a36Sopenharmony_ci	return clear_pte_bit(pte, __pgprot(L_PTE_YOUNG));
24962306a36Sopenharmony_ci}
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_cistatic inline pte_t pte_mkyoung(pte_t pte)
25262306a36Sopenharmony_ci{
25362306a36Sopenharmony_ci	return set_pte_bit(pte, __pgprot(L_PTE_YOUNG));
25462306a36Sopenharmony_ci}
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_cistatic inline pte_t pte_mkexec(pte_t pte)
25762306a36Sopenharmony_ci{
25862306a36Sopenharmony_ci	return clear_pte_bit(pte, __pgprot(L_PTE_XN));
25962306a36Sopenharmony_ci}
26062306a36Sopenharmony_ci
26162306a36Sopenharmony_cistatic inline pte_t pte_mknexec(pte_t pte)
26262306a36Sopenharmony_ci{
26362306a36Sopenharmony_ci	return set_pte_bit(pte, __pgprot(L_PTE_XN));
26462306a36Sopenharmony_ci}
26562306a36Sopenharmony_ci
26662306a36Sopenharmony_cistatic inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
26762306a36Sopenharmony_ci{
26862306a36Sopenharmony_ci	const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
26962306a36Sopenharmony_ci		L_PTE_NONE | L_PTE_VALID;
27062306a36Sopenharmony_ci	pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
27162306a36Sopenharmony_ci	return pte;
27262306a36Sopenharmony_ci}
27362306a36Sopenharmony_ci
27462306a36Sopenharmony_ci/*
27562306a36Sopenharmony_ci * Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that
27662306a36Sopenharmony_ci * are !pte_none() && !pte_present().
27762306a36Sopenharmony_ci *
27862306a36Sopenharmony_ci * Format of swap PTEs:
27962306a36Sopenharmony_ci *
28062306a36Sopenharmony_ci *   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
28162306a36Sopenharmony_ci *   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
28262306a36Sopenharmony_ci *   <------------------- offset ------------------> E < type -> 0 0
28362306a36Sopenharmony_ci *
28462306a36Sopenharmony_ci *   E is the exclusive marker that is not stored in swap entries.
28562306a36Sopenharmony_ci *
28662306a36Sopenharmony_ci * This gives us up to 31 swap files and 64GB per swap file.  Note that
28762306a36Sopenharmony_ci * the offset field is always non-zero.
28862306a36Sopenharmony_ci */
28962306a36Sopenharmony_ci#define __SWP_TYPE_SHIFT	2
29062306a36Sopenharmony_ci#define __SWP_TYPE_BITS		5
29162306a36Sopenharmony_ci#define __SWP_TYPE_MASK		((1 << __SWP_TYPE_BITS) - 1)
29262306a36Sopenharmony_ci#define __SWP_OFFSET_SHIFT	(__SWP_TYPE_BITS + __SWP_TYPE_SHIFT + 1)
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_ci#define __swp_type(x)		(((x).val >> __SWP_TYPE_SHIFT) & __SWP_TYPE_MASK)
29562306a36Sopenharmony_ci#define __swp_offset(x)		((x).val >> __SWP_OFFSET_SHIFT)
29662306a36Sopenharmony_ci#define __swp_entry(type, offset) ((swp_entry_t) { (((type) & __SWP_TYPE_MASK) << __SWP_TYPE_SHIFT) | \
29762306a36Sopenharmony_ci						   ((offset) << __SWP_OFFSET_SHIFT) })
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_ci#define __pte_to_swp_entry(pte)	((swp_entry_t) { pte_val(pte) })
30062306a36Sopenharmony_ci#define __swp_entry_to_pte(swp)	__pte((swp).val)
30162306a36Sopenharmony_ci
30262306a36Sopenharmony_cistatic inline int pte_swp_exclusive(pte_t pte)
30362306a36Sopenharmony_ci{
30462306a36Sopenharmony_ci	return pte_isset(pte, L_PTE_SWP_EXCLUSIVE);
30562306a36Sopenharmony_ci}
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_cistatic inline pte_t pte_swp_mkexclusive(pte_t pte)
30862306a36Sopenharmony_ci{
30962306a36Sopenharmony_ci	return set_pte_bit(pte, __pgprot(L_PTE_SWP_EXCLUSIVE));
31062306a36Sopenharmony_ci}
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_cistatic inline pte_t pte_swp_clear_exclusive(pte_t pte)
31362306a36Sopenharmony_ci{
31462306a36Sopenharmony_ci	return clear_pte_bit(pte, __pgprot(L_PTE_SWP_EXCLUSIVE));
31562306a36Sopenharmony_ci}
31662306a36Sopenharmony_ci
31762306a36Sopenharmony_ci/*
31862306a36Sopenharmony_ci * It is an error for the kernel to have more swap files than we can
31962306a36Sopenharmony_ci * encode in the PTEs.  This ensures that we know when MAX_SWAPFILES
32062306a36Sopenharmony_ci * is increased beyond what we presently support.
32162306a36Sopenharmony_ci */
32262306a36Sopenharmony_ci#define MAX_SWAPFILES_CHECK() BUILD_BUG_ON(MAX_SWAPFILES_SHIFT > __SWP_TYPE_BITS)
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_ci/*
32562306a36Sopenharmony_ci * We provide our own arch_get_unmapped_area to cope with VIPT caches.
32662306a36Sopenharmony_ci */
32762306a36Sopenharmony_ci#define HAVE_ARCH_UNMAPPED_AREA
32862306a36Sopenharmony_ci#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
32962306a36Sopenharmony_ci
33062306a36Sopenharmony_ci#endif /* !__ASSEMBLY__ */
33162306a36Sopenharmony_ci
33262306a36Sopenharmony_ci#endif /* CONFIG_MMU */
33362306a36Sopenharmony_ci
33462306a36Sopenharmony_ci#endif /* _ASMARM_PGTABLE_H */
335