mmu.h 1.4 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
L
Linus Torvalds 已提交
2 3 4
#ifndef __MMU_H
#define __MMU_H

5
#include <linux/cpumask.h>
6 7
#include <linux/errno.h>

8
typedef struct {
9
	spinlock_t lock;
10
	cpumask_t cpu_attach_mask;
11
	atomic_t flush_count;
12
	unsigned int flush_mm;
13
	struct list_head pgtable_list;
14
	struct list_head gmap_list;
15
	unsigned long gmap_asce;
16
	unsigned long asce;
M
Martin Schwidefsky 已提交
17
	unsigned long asce_limit;
M
Martin Schwidefsky 已提交
18
	unsigned long vdso_base;
19 20 21 22 23 24 25
	/*
	 * The following bitfields need a down_write on the mm
	 * semaphore when they are written to. As they are only
	 * written once, they can be read without a lock.
	 *
	 * The mmu context allocates 4K page tables.
	 */
26 27
	unsigned int alloc_pgste:1;
	/* The mmu context uses extended page tables. */
28
	unsigned int has_pgste:1;
29
	/* The mmu context uses storage keys. */
30
	unsigned int uses_skeys:1;
31 32
	/* The mmu context uses CMM. */
	unsigned int uses_cmm:1;
33 34
	/* The gmaps associated with this context are allowed to use huge pages. */
	unsigned int allow_gmap_hpage_1m:1;
35
} mm_context_t;
L
Linus Torvalds 已提交
36

37
#define INIT_MM_CONTEXT(name)						   \
38
	.context.lock =	__SPIN_LOCK_UNLOCKED(name.context.lock),	   \
39
	.context.pgtable_list = LIST_HEAD_INIT(name.context.pgtable_list), \
40
	.context.gmap_list = LIST_HEAD_INIT(name.context.gmap_list),
41

42 43 44 45 46 47 48 49 50 51 52 53 54 55
static inline int tprot(unsigned long addr)
{
	int rc = -EFAULT;

	asm volatile(
		"	tprot	0(%1),0\n"
		"0:	ipm	%0\n"
		"	srl	%0,28\n"
		"1:\n"
		EX_TABLE(0b,1b)
		: "+d" (rc) : "a" (addr) : "cc");
	return rc;
}

L
Linus Torvalds 已提交
56
#endif