blob: 9bfdbca14f953ce75fea14489c7c7870de217cb7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * S390 version
Heiko Carstensa53c8fa2012-07-20 11:15:04 +02003 * Copyright IBM Corp. 1999, 2000
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * Author(s): Hartmut Penner (hp@de.ibm.com)
5 * Ulrich Weigand (weigand@de.ibm.com)
6 * Martin Schwidefsky (schwidefsky@de.ibm.com)
7 *
8 * Derived from "include/asm-i386/pgtable.h"
9 */
10
11#ifndef _ASM_S390_PGTABLE_H
12#define _ASM_S390_PGTABLE_H
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014/*
15 * The Linux memory management assumes a three-level page table setup. For
16 * s390 31 bit we "fold" the mid level into the top-level page table, so
17 * that we physically have the same two-level page table as the s390 mmu
18 * expects in 31 bit mode. For s390 64 bit we use three of the five levels
19 * the hardware provides (region first and region second tables are not
20 * used).
21 *
22 * The "pgd_xxx()" functions are trivial for a folded two-level
23 * setup: the pgd is never bad, and a pmd always exists (as it's folded
24 * into the pgd entry)
25 *
26 * This file contains the functions and defines necessary to modify and use
27 * the S390 page table tree.
28 */
29#ifndef __ASSEMBLY__
Heiko Carstens9789db02008-07-14 09:59:11 +020030#include <linux/sched.h>
Heiko Carstens2dcea572006-09-29 01:58:41 -070031#include <linux/mm_types.h>
Martin Schwidefskyabf09be2012-11-07 13:17:37 +010032#include <linux/page-flags.h>
Martin Schwidefsky527e30b2014-04-30 16:04:25 +020033#include <linux/radix-tree.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <asm/bug.h>
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +020035#include <asm/page.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Linus Torvalds1da177e2005-04-16 15:20:36 -070037extern pgd_t swapper_pg_dir[] __attribute__ ((aligned (4096)));
38extern void paging_init(void);
Heiko Carstens2b67fc42007-02-05 21:16:47 +010039extern void vmem_map_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/*
42 * The S390 doesn't have any external MMU info: the kernel page
43 * tables contain all the necessary information.
44 */
Russell King4b3073e2009-12-18 16:40:18 +000045#define update_mmu_cache(vma, address, ptep) do { } while (0)
David Millerb113da62012-10-08 16:34:25 -070046#define update_mmu_cache_pmd(vma, address, ptep) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48/*
Martin Schwidefsky238ec4e2010-10-25 16:10:07 +020049 * ZERO_PAGE is a global shared page that is always zero; used
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 * for zero-mapped memory areas etc..
51 */
Martin Schwidefsky238ec4e2010-10-25 16:10:07 +020052
53extern unsigned long empty_zero_page;
54extern unsigned long zero_page_mask;
55
56#define ZERO_PAGE(vaddr) \
57 (virt_to_page((void *)(empty_zero_page + \
58 (((unsigned long)(vaddr)) &zero_page_mask))))
Kirill A. Shutemov816422a2012-12-12 13:52:36 -080059#define __HAVE_COLOR_ZERO_PAGE
Martin Schwidefsky238ec4e2010-10-25 16:10:07 +020060
Linus Torvalds4f2e2902013-04-17 08:46:19 -070061/* TODO: s390 cannot support io_remap_pfn_range... */
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#endif /* !__ASSEMBLY__ */
63
64/*
65 * PMD_SHIFT determines the size of the area a second-level page
66 * table can map
67 * PGDIR_SHIFT determines what a third-level page table entry can map
68 */
Heiko Carstensf4815ac2012-05-23 16:24:51 +020069#ifndef CONFIG_64BIT
Martin Schwidefsky146e4b32008-02-09 18:24:35 +010070# define PMD_SHIFT 20
71# define PUD_SHIFT 20
72# define PGDIR_SHIFT 20
Heiko Carstensf4815ac2012-05-23 16:24:51 +020073#else /* CONFIG_64BIT */
Martin Schwidefsky146e4b32008-02-09 18:24:35 +010074# define PMD_SHIFT 20
Martin Schwidefsky190a1d72007-10-22 12:52:48 +020075# define PUD_SHIFT 31
Martin Schwidefsky5a216a22008-02-09 18:24:36 +010076# define PGDIR_SHIFT 42
Heiko Carstensf4815ac2012-05-23 16:24:51 +020077#endif /* CONFIG_64BIT */
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79#define PMD_SIZE (1UL << PMD_SHIFT)
80#define PMD_MASK (~(PMD_SIZE-1))
Martin Schwidefsky190a1d72007-10-22 12:52:48 +020081#define PUD_SIZE (1UL << PUD_SHIFT)
82#define PUD_MASK (~(PUD_SIZE-1))
Martin Schwidefsky5a216a22008-02-09 18:24:36 +010083#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
84#define PGDIR_MASK (~(PGDIR_SIZE-1))
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
86/*
87 * entries per page directory level: the S390 is two-level, so
88 * we don't really have any PMD directory physically.
89 * for S390 segment-table entries are combined to one PGD
90 * that leads to 1024 pte per pgd
91 */
Martin Schwidefsky146e4b32008-02-09 18:24:35 +010092#define PTRS_PER_PTE 256
Heiko Carstensf4815ac2012-05-23 16:24:51 +020093#ifndef CONFIG_64BIT
Martin Schwidefsky146e4b32008-02-09 18:24:35 +010094#define PTRS_PER_PMD 1
Martin Schwidefsky5a216a22008-02-09 18:24:36 +010095#define PTRS_PER_PUD 1
Heiko Carstensf4815ac2012-05-23 16:24:51 +020096#else /* CONFIG_64BIT */
Martin Schwidefsky146e4b32008-02-09 18:24:35 +010097#define PTRS_PER_PMD 2048
Martin Schwidefsky5a216a22008-02-09 18:24:36 +010098#define PTRS_PER_PUD 2048
Heiko Carstensf4815ac2012-05-23 16:24:51 +020099#endif /* CONFIG_64BIT */
Martin Schwidefsky146e4b32008-02-09 18:24:35 +0100100#define PTRS_PER_PGD 2048
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
Hugh Dickinsd455a362005-04-19 13:29:23 -0700102#define FIRST_USER_ADDRESS 0
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#define pte_ERROR(e) \
105 printk("%s:%d: bad pte %p.\n", __FILE__, __LINE__, (void *) pte_val(e))
106#define pmd_ERROR(e) \
107 printk("%s:%d: bad pmd %p.\n", __FILE__, __LINE__, (void *) pmd_val(e))
Martin Schwidefsky190a1d72007-10-22 12:52:48 +0200108#define pud_ERROR(e) \
109 printk("%s:%d: bad pud %p.\n", __FILE__, __LINE__, (void *) pud_val(e))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110#define pgd_ERROR(e) \
111 printk("%s:%d: bad pgd %p.\n", __FILE__, __LINE__, (void *) pgd_val(e))
112
113#ifndef __ASSEMBLY__
114/*
Heiko Carstensc972cc62012-10-05 16:52:18 +0200115 * The vmalloc and module area will always be on the topmost area of the kernel
116 * mapping. We reserve 96MB (31bit) / 128GB (64bit) for vmalloc and modules.
117 * On 64 bit kernels we have a 2GB area at the top of the vmalloc area where
118 * modules will reside. That makes sure that inter module branches always
119 * happen without trampolines and in addition the placement within a 2GB frame
120 * is branch prediction unit friendly.
Heiko Carstens8b62bc92006-12-04 15:40:56 +0100121 */
Heiko Carstens239a64252009-06-12 10:26:33 +0200122extern unsigned long VMALLOC_START;
Martin Schwidefsky14045eb2011-12-27 11:27:07 +0100123extern unsigned long VMALLOC_END;
124extern struct page *vmemmap;
Heiko Carstens239a64252009-06-12 10:26:33 +0200125
Martin Schwidefsky14045eb2011-12-27 11:27:07 +0100126#define VMEM_MAX_PHYS ((unsigned long) vmemmap)
Christian Borntraeger5fd9c6e2008-01-26 14:11:00 +0100127
Heiko Carstensc972cc62012-10-05 16:52:18 +0200128#ifdef CONFIG_64BIT
129extern unsigned long MODULES_VADDR;
130extern unsigned long MODULES_END;
131#define MODULES_VADDR MODULES_VADDR
132#define MODULES_END MODULES_END
133#define MODULES_LEN (1UL << 31)
134#endif
135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136/*
137 * A 31 bit pagetable entry of S390 has following format:
138 * | PFRA | | OS |
139 * 0 0IP0
140 * 00000000001111111111222222222233
141 * 01234567890123456789012345678901
142 *
143 * I Page-Invalid Bit: Page is not available for address-translation
144 * P Page-Protection Bit: Store access not possible for page
145 *
146 * A 31 bit segmenttable entry of S390 has following format:
147 * | P-table origin | |PTL
148 * 0 IC
149 * 00000000001111111111222222222233
150 * 01234567890123456789012345678901
151 *
152 * I Segment-Invalid Bit: Segment is not available for address-translation
153 * C Common-Segment Bit: Segment is not private (PoP 3-30)
154 * PTL Page-Table-Length: Page-table length (PTL+1*16 entries -> up to 256)
155 *
156 * The 31 bit segmenttable origin of S390 has following format:
157 *
158 * |S-table origin | | STL |
159 * X **GPS
160 * 00000000001111111111222222222233
161 * 01234567890123456789012345678901
162 *
163 * X Space-Switch event:
164 * G Segment-Invalid Bit: *
165 * P Private-Space Bit: Segment is not private (PoP 3-30)
166 * S Storage-Alteration:
167 * STL Segment-Table-Length: Segment-table length (STL+1*16 entries -> up to 2048)
168 *
169 * A 64 bit pagetable entry of S390 has following format:
Christian Borntraeger6a985c62009-12-07 12:52:11 +0100170 * | PFRA |0IPC| OS |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 * 0000000000111111111122222222223333333333444444444455555555556666
172 * 0123456789012345678901234567890123456789012345678901234567890123
173 *
174 * I Page-Invalid Bit: Page is not available for address-translation
175 * P Page-Protection Bit: Store access not possible for page
Christian Borntraeger6a985c62009-12-07 12:52:11 +0100176 * C Change-bit override: HW is not required to set change bit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 *
178 * A 64 bit segmenttable entry of S390 has following format:
179 * | P-table origin | TT
180 * 0000000000111111111122222222223333333333444444444455555555556666
181 * 0123456789012345678901234567890123456789012345678901234567890123
182 *
183 * I Segment-Invalid Bit: Segment is not available for address-translation
184 * C Common-Segment Bit: Segment is not private (PoP 3-30)
185 * P Page-Protection Bit: Store access not possible for page
186 * TT Type 00
187 *
188 * A 64 bit region table entry of S390 has following format:
189 * | S-table origin | TF TTTL
190 * 0000000000111111111122222222223333333333444444444455555555556666
191 * 0123456789012345678901234567890123456789012345678901234567890123
192 *
193 * I Segment-Invalid Bit: Segment is not available for address-translation
194 * TT Type 01
195 * TF
Martin Schwidefsky190a1d72007-10-22 12:52:48 +0200196 * TL Table length
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 *
198 * The 64 bit regiontable origin of S390 has following format:
199 * | region table origon | DTTL
200 * 0000000000111111111122222222223333333333444444444455555555556666
201 * 0123456789012345678901234567890123456789012345678901234567890123
202 *
203 * X Space-Switch event:
204 * G Segment-Invalid Bit:
205 * P Private-Space Bit:
206 * S Storage-Alteration:
207 * R Real space
208 * TL Table-Length:
209 *
210 * A storage key has the following format:
211 * | ACC |F|R|C|0|
212 * 0 3 4 5 6 7
213 * ACC: access key
214 * F : fetch protection bit
215 * R : referenced bit
216 * C : changed bit
217 */
218
219/* Hardware bits in the page table entry */
Christian Borntraeger6a985c62009-12-07 12:52:11 +0100220#define _PAGE_CO 0x100 /* HW Change-bit override */
Martin Schwidefskye5098612013-07-23 20:57:57 +0200221#define _PAGE_PROTECT 0x200 /* HW read-only bit */
Martin Schwidefsky83377482006-10-18 18:30:51 +0200222#define _PAGE_INVALID 0x400 /* HW invalid bit */
Martin Schwidefskye5098612013-07-23 20:57:57 +0200223#define _PAGE_LARGE 0x800 /* Bit to mark a large pte */
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200224
225/* Software bits in the page table entry */
Martin Schwidefskye5098612013-07-23 20:57:57 +0200226#define _PAGE_PRESENT 0x001 /* SW pte present bit */
227#define _PAGE_TYPE 0x002 /* SW pte type bit */
228#define _PAGE_YOUNG 0x004 /* SW pte young bit */
229#define _PAGE_DIRTY 0x008 /* SW pte dirty bit */
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200230#define _PAGE_READ 0x010 /* SW pte read bit */
231#define _PAGE_WRITE 0x020 /* SW pte write bit */
232#define _PAGE_SPECIAL 0x040 /* SW associated with special page */
Konstantin Weitzb31288f2013-04-17 17:36:29 +0200233#define _PAGE_UNUSED 0x080 /* SW bit for pgste usage state */
Nick Piggina08cb622008-04-28 02:13:03 -0700234#define __HAVE_ARCH_PTE_SPECIAL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
Nick Piggin138c9022008-07-08 11:31:06 +0200236/* Set of bits not changed in pte_modify */
Martin Schwidefskyabf09be2012-11-07 13:17:37 +0100237#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_SPECIAL | _PAGE_CO | \
Martin Schwidefskye5098612013-07-23 20:57:57 +0200238 _PAGE_DIRTY | _PAGE_YOUNG)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239
Martin Schwidefsky83377482006-10-18 18:30:51 +0200240/*
Martin Schwidefskye5098612013-07-23 20:57:57 +0200241 * handle_pte_fault uses pte_present, pte_none and pte_file to find out the
242 * pte type WITHOUT holding the page table lock. The _PAGE_PRESENT bit
243 * is used to distinguish present from not-present ptes. It is changed only
244 * with the page table lock held.
Martin Schwidefsky83377482006-10-18 18:30:51 +0200245 *
Martin Schwidefskye5098612013-07-23 20:57:57 +0200246 * The following table gives the different possible bit combinations for
247 * the pte hardware and software bits in the last 12 bits of a pte:
Martin Schwidefsky83377482006-10-18 18:30:51 +0200248 *
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200249 * 842100000000
250 * 000084210000
251 * 000000008421
252 * .IR...wrdytp
253 * empty .10...000000
254 * swap .10...xxxx10
255 * file .11...xxxxx0
256 * prot-none, clean, old .11...000001
257 * prot-none, clean, young .11...000101
258 * prot-none, dirty, old .10...001001
259 * prot-none, dirty, young .10...001101
260 * read-only, clean, old .11...010001
261 * read-only, clean, young .01...010101
262 * read-only, dirty, old .11...011001
263 * read-only, dirty, young .01...011101
264 * read-write, clean, old .11...110001
265 * read-write, clean, young .01...110101
266 * read-write, dirty, old .10...111001
267 * read-write, dirty, young .00...111101
Martin Schwidefskye5098612013-07-23 20:57:57 +0200268 *
269 * pte_present is true for the bit pattern .xx...xxxxx1, (pte & 0x001) == 0x001
270 * pte_none is true for the bit pattern .10...xxxx00, (pte & 0x603) == 0x400
271 * pte_file is true for the bit pattern .11...xxxxx0, (pte & 0x601) == 0x600
272 * pte_swap is true for the bit pattern .10...xxxx10, (pte & 0x603) == 0x402
Martin Schwidefsky83377482006-10-18 18:30:51 +0200273 */
274
Heiko Carstensf4815ac2012-05-23 16:24:51 +0200275#ifndef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200277/* Bits in the segment table address-space-control-element */
278#define _ASCE_SPACE_SWITCH 0x80000000UL /* space switch event */
279#define _ASCE_ORIGIN_MASK 0x7ffff000UL /* segment table origin */
280#define _ASCE_PRIVATE_SPACE 0x100 /* private space control */
281#define _ASCE_ALT_EVENT 0x80 /* storage alteration event control */
282#define _ASCE_TABLE_LENGTH 0x7f /* 128 x 64 entries = 8k */
283
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284/* Bits in the segment table entry */
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200285#define _SEGMENT_ENTRY_BITS 0x7fffffffUL /* Valid segment table bits */
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200286#define _SEGMENT_ENTRY_ORIGIN 0x7fffffc0UL /* page table origin */
Martin Schwidefskye5098612013-07-23 20:57:57 +0200287#define _SEGMENT_ENTRY_PROTECT 0x200 /* page protection bit */
288#define _SEGMENT_ENTRY_INVALID 0x20 /* invalid segment table entry */
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200289#define _SEGMENT_ENTRY_COMMON 0x10 /* common segment bit */
290#define _SEGMENT_ENTRY_PTL 0x0f /* page table length */
Martin Schwidefsky152125b2014-07-24 11:03:41 +0200291
292#define _SEGMENT_ENTRY_DIRTY 0 /* No sw dirty bit for 31-bit */
293#define _SEGMENT_ENTRY_YOUNG 0 /* No sw young bit for 31-bit */
294#define _SEGMENT_ENTRY_READ 0 /* No sw read bit for 31-bit */
295#define _SEGMENT_ENTRY_WRITE 0 /* No sw write bit for 31-bit */
296#define _SEGMENT_ENTRY_LARGE 0 /* No large pages for 31-bit */
297#define _SEGMENT_ENTRY_BITS_LARGE 0
298#define _SEGMENT_ENTRY_ORIGIN_LARGE 0
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200299
300#define _SEGMENT_ENTRY (_SEGMENT_ENTRY_PTL)
Martin Schwidefskye5098612013-07-23 20:57:57 +0200301#define _SEGMENT_ENTRY_EMPTY (_SEGMENT_ENTRY_INVALID)
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200302
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200303/*
304 * Segment table entry encoding (I = invalid, R = read-only bit):
305 * ..R...I.....
306 * prot-none ..1...1.....
307 * read-only ..1...0.....
308 * read-write ..0...0.....
309 * empty ..0...1.....
310 */
311
Martin Schwidefsky6c61cfe2011-06-06 14:14:42 +0200312/* Page status table bits for virtualization */
Martin Schwidefsky0d0dafc2013-05-17 14:41:33 +0200313#define PGSTE_ACC_BITS 0xf0000000UL
314#define PGSTE_FP_BIT 0x08000000UL
315#define PGSTE_PCL_BIT 0x00800000UL
316#define PGSTE_HR_BIT 0x00400000UL
317#define PGSTE_HC_BIT 0x00200000UL
318#define PGSTE_GR_BIT 0x00040000UL
319#define PGSTE_GC_BIT 0x00020000UL
Martin Schwidefsky0a61b222013-10-18 12:03:41 +0200320#define PGSTE_UC_BIT 0x00008000UL /* user dirty (migration) */
321#define PGSTE_IN_BIT 0x00004000UL /* IPTE notify bit */
Martin Schwidefsky6c61cfe2011-06-06 14:14:42 +0200322
Heiko Carstensf4815ac2012-05-23 16:24:51 +0200323#else /* CONFIG_64BIT */
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200324
325/* Bits in the segment/region table address-space-control-element */
326#define _ASCE_ORIGIN ~0xfffUL/* segment table origin */
327#define _ASCE_PRIVATE_SPACE 0x100 /* private space control */
328#define _ASCE_ALT_EVENT 0x80 /* storage alteration event control */
329#define _ASCE_SPACE_SWITCH 0x40 /* space switch event */
330#define _ASCE_REAL_SPACE 0x20 /* real space control */
331#define _ASCE_TYPE_MASK 0x0c /* asce table type mask */
332#define _ASCE_TYPE_REGION1 0x0c /* region first table type */
333#define _ASCE_TYPE_REGION2 0x08 /* region second table type */
334#define _ASCE_TYPE_REGION3 0x04 /* region third table type */
335#define _ASCE_TYPE_SEGMENT 0x00 /* segment table type */
336#define _ASCE_TABLE_LENGTH 0x03 /* region table length */
337
338/* Bits in the region table entry */
339#define _REGION_ENTRY_ORIGIN ~0xfffUL/* region/segment table origin */
Martin Schwidefskye5098612013-07-23 20:57:57 +0200340#define _REGION_ENTRY_PROTECT 0x200 /* region protection bit */
341#define _REGION_ENTRY_INVALID 0x20 /* invalid region table entry */
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200342#define _REGION_ENTRY_TYPE_MASK 0x0c /* region/segment table type mask */
343#define _REGION_ENTRY_TYPE_R1 0x0c /* region first table type */
344#define _REGION_ENTRY_TYPE_R2 0x08 /* region second table type */
345#define _REGION_ENTRY_TYPE_R3 0x04 /* region third table type */
346#define _REGION_ENTRY_LENGTH 0x03 /* region third length */
347
348#define _REGION1_ENTRY (_REGION_ENTRY_TYPE_R1 | _REGION_ENTRY_LENGTH)
Martin Schwidefskye5098612013-07-23 20:57:57 +0200349#define _REGION1_ENTRY_EMPTY (_REGION_ENTRY_TYPE_R1 | _REGION_ENTRY_INVALID)
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200350#define _REGION2_ENTRY (_REGION_ENTRY_TYPE_R2 | _REGION_ENTRY_LENGTH)
Martin Schwidefskye5098612013-07-23 20:57:57 +0200351#define _REGION2_ENTRY_EMPTY (_REGION_ENTRY_TYPE_R2 | _REGION_ENTRY_INVALID)
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200352#define _REGION3_ENTRY (_REGION_ENTRY_TYPE_R3 | _REGION_ENTRY_LENGTH)
Martin Schwidefskye5098612013-07-23 20:57:57 +0200353#define _REGION3_ENTRY_EMPTY (_REGION_ENTRY_TYPE_R3 | _REGION_ENTRY_INVALID)
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200354
Heiko Carstens18da2362012-10-08 09:18:26 +0200355#define _REGION3_ENTRY_LARGE 0x400 /* RTTE-format control, large page */
Heiko Carstens1819ed12013-02-16 11:47:27 +0100356#define _REGION3_ENTRY_RO 0x200 /* page protection bit */
357#define _REGION3_ENTRY_CO 0x100 /* change-recording override */
Heiko Carstens18da2362012-10-08 09:18:26 +0200358
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200359/* Bits in the segment table entry */
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200360#define _SEGMENT_ENTRY_BITS 0xfffffffffffffe33UL
Martin Schwidefsky152125b2014-07-24 11:03:41 +0200361#define _SEGMENT_ENTRY_BITS_LARGE 0xfffffffffff0ff33UL
Heiko Carstensea815312013-03-21 12:50:39 +0100362#define _SEGMENT_ENTRY_ORIGIN_LARGE ~0xfffffUL /* large page address */
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200363#define _SEGMENT_ENTRY_ORIGIN ~0x7ffUL/* segment table origin */
Martin Schwidefskye5098612013-07-23 20:57:57 +0200364#define _SEGMENT_ENTRY_PROTECT 0x200 /* page protection bit */
365#define _SEGMENT_ENTRY_INVALID 0x20 /* invalid segment table entry */
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200366
367#define _SEGMENT_ENTRY (0)
Martin Schwidefskye5098612013-07-23 20:57:57 +0200368#define _SEGMENT_ENTRY_EMPTY (_SEGMENT_ENTRY_INVALID)
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200369
Martin Schwidefsky152125b2014-07-24 11:03:41 +0200370#define _SEGMENT_ENTRY_DIRTY 0x2000 /* SW segment dirty bit */
371#define _SEGMENT_ENTRY_YOUNG 0x1000 /* SW segment young bit */
372#define _SEGMENT_ENTRY_SPLIT 0x0800 /* THP splitting bit */
373#define _SEGMENT_ENTRY_LARGE 0x0400 /* STE-format control, large page */
374#define _SEGMENT_ENTRY_CO 0x0100 /* change-recording override */
375#define _SEGMENT_ENTRY_READ 0x0002 /* SW segment read bit */
376#define _SEGMENT_ENTRY_WRITE 0x0001 /* SW segment write bit */
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200377
378/*
379 * Segment table entry encoding (R = read-only, I = invalid, y = young bit):
Martin Schwidefsky152125b2014-07-24 11:03:41 +0200380 * dy..R...I...wr
381 * prot-none, clean, old 00..1...1...00
382 * prot-none, clean, young 01..1...1...00
383 * prot-none, dirty, old 10..1...1...00
384 * prot-none, dirty, young 11..1...1...00
385 * read-only, clean, old 00..1...1...01
386 * read-only, clean, young 01..1...0...01
387 * read-only, dirty, old 10..1...1...01
388 * read-only, dirty, young 11..1...0...01
389 * read-write, clean, old 00..1...1...11
390 * read-write, clean, young 01..1...0...11
391 * read-write, dirty, old 10..0...1...11
392 * read-write, dirty, young 11..0...0...11
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200393 * The segment table origin is used to distinguish empty (origin==0) from
394 * read-write, old segment table entries (origin!=0)
395 */
Martin Schwidefskye5098612013-07-23 20:57:57 +0200396
Martin Schwidefsky152125b2014-07-24 11:03:41 +0200397#define _SEGMENT_ENTRY_SPLIT_BIT 11 /* THP splitting bit number */
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -0700398
Martin Schwidefsky6c61cfe2011-06-06 14:14:42 +0200399/* Page status table bits for virtualization */
Martin Schwidefsky0d0dafc2013-05-17 14:41:33 +0200400#define PGSTE_ACC_BITS 0xf000000000000000UL
401#define PGSTE_FP_BIT 0x0800000000000000UL
402#define PGSTE_PCL_BIT 0x0080000000000000UL
403#define PGSTE_HR_BIT 0x0040000000000000UL
404#define PGSTE_HC_BIT 0x0020000000000000UL
405#define PGSTE_GR_BIT 0x0004000000000000UL
406#define PGSTE_GC_BIT 0x0002000000000000UL
Martin Schwidefsky0a61b222013-10-18 12:03:41 +0200407#define PGSTE_UC_BIT 0x0000800000000000UL /* user dirty (migration) */
408#define PGSTE_IN_BIT 0x0000400000000000UL /* IPTE notify bit */
Martin Schwidefsky6c61cfe2011-06-06 14:14:42 +0200409
Heiko Carstensf4815ac2012-05-23 16:24:51 +0200410#endif /* CONFIG_64BIT */
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200411
Konstantin Weitzb31288f2013-04-17 17:36:29 +0200412/* Guest Page State used for virtualization */
413#define _PGSTE_GPS_ZERO 0x0000000080000000UL
414#define _PGSTE_GPS_USAGE_MASK 0x0000000003000000UL
415#define _PGSTE_GPS_USAGE_STABLE 0x0000000000000000UL
416#define _PGSTE_GPS_USAGE_UNUSED 0x0000000001000000UL
417
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200418/*
419 * A user page table pointer has the space-switch-event bit, the
420 * private-space-control bit and the storage-alteration-event-control
421 * bit set. A kernel page table pointer doesn't need them.
422 */
423#define _ASCE_USER_BITS (_ASCE_SPACE_SWITCH | _ASCE_PRIVATE_SPACE | \
424 _ASCE_ALT_EVENT)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426/*
Gerald Schaefer9282ed92006-09-20 15:59:37 +0200427 * Page protection definitions.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 */
Martin Schwidefskye5098612013-07-23 20:57:57 +0200429#define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_INVALID)
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200430#define PAGE_READ __pgprot(_PAGE_PRESENT | _PAGE_READ | \
431 _PAGE_INVALID | _PAGE_PROTECT)
432#define PAGE_WRITE __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
433 _PAGE_INVALID | _PAGE_PROTECT)
Gerald Schaefer9282ed92006-09-20 15:59:37 +0200434
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200435#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
436 _PAGE_YOUNG | _PAGE_DIRTY)
437#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
438 _PAGE_YOUNG | _PAGE_DIRTY)
439#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_YOUNG | \
440 _PAGE_PROTECT)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
442/*
Martin Schwidefsky043d0702011-05-23 10:24:23 +0200443 * On s390 the page table entry has an invalid bit and a read-only bit.
444 * Read permission implies execute permission and write permission
445 * implies read permission.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 */
447 /*xwr*/
Gerald Schaefer9282ed92006-09-20 15:59:37 +0200448#define __P000 PAGE_NONE
Martin Schwidefskye5098612013-07-23 20:57:57 +0200449#define __P001 PAGE_READ
450#define __P010 PAGE_READ
451#define __P011 PAGE_READ
452#define __P100 PAGE_READ
453#define __P101 PAGE_READ
454#define __P110 PAGE_READ
455#define __P111 PAGE_READ
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456
Gerald Schaefer9282ed92006-09-20 15:59:37 +0200457#define __S000 PAGE_NONE
Martin Schwidefskye5098612013-07-23 20:57:57 +0200458#define __S001 PAGE_READ
459#define __S010 PAGE_WRITE
460#define __S011 PAGE_WRITE
461#define __S100 PAGE_READ
462#define __S101 PAGE_READ
463#define __S110 PAGE_WRITE
464#define __S111 PAGE_WRITE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465
Gerald Schaefer106c9922013-04-29 15:07:23 -0700466/*
467 * Segment entry (large page) protection definitions.
468 */
Martin Schwidefskye5098612013-07-23 20:57:57 +0200469#define SEGMENT_NONE __pgprot(_SEGMENT_ENTRY_INVALID | \
470 _SEGMENT_ENTRY_PROTECT)
Martin Schwidefsky152125b2014-07-24 11:03:41 +0200471#define SEGMENT_READ __pgprot(_SEGMENT_ENTRY_PROTECT | \
472 _SEGMENT_ENTRY_READ)
473#define SEGMENT_WRITE __pgprot(_SEGMENT_ENTRY_READ | \
474 _SEGMENT_ENTRY_WRITE)
Gerald Schaefer106c9922013-04-29 15:07:23 -0700475
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200476static inline int mm_has_pgste(struct mm_struct *mm)
477{
478#ifdef CONFIG_PGSTE
479 if (unlikely(mm->context.has_pgste))
480 return 1;
481#endif
482 return 0;
483}
Dominik Dingel65eef3352014-01-14 15:02:11 +0100484
485static inline int mm_use_skey(struct mm_struct *mm)
486{
487#ifdef CONFIG_PGSTE
488 if (mm->context.use_skey)
489 return 1;
490#endif
491 return 0;
492}
493
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494/*
495 * pgd/pmd/pte query functions
496 */
Heiko Carstensf4815ac2012-05-23 16:24:51 +0200497#ifndef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800499static inline int pgd_present(pgd_t pgd) { return 1; }
500static inline int pgd_none(pgd_t pgd) { return 0; }
501static inline int pgd_bad(pgd_t pgd) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502
Martin Schwidefsky190a1d72007-10-22 12:52:48 +0200503static inline int pud_present(pud_t pud) { return 1; }
504static inline int pud_none(pud_t pud) { return 0; }
Heiko Carstens18da2362012-10-08 09:18:26 +0200505static inline int pud_large(pud_t pud) { return 0; }
Martin Schwidefsky190a1d72007-10-22 12:52:48 +0200506static inline int pud_bad(pud_t pud) { return 0; }
507
Heiko Carstensf4815ac2012-05-23 16:24:51 +0200508#else /* CONFIG_64BIT */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509
Martin Schwidefsky5a216a22008-02-09 18:24:36 +0100510static inline int pgd_present(pgd_t pgd)
511{
Martin Schwidefsky6252d702008-02-09 18:24:37 +0100512 if ((pgd_val(pgd) & _REGION_ENTRY_TYPE_MASK) < _REGION_ENTRY_TYPE_R2)
513 return 1;
Martin Schwidefsky5a216a22008-02-09 18:24:36 +0100514 return (pgd_val(pgd) & _REGION_ENTRY_ORIGIN) != 0UL;
515}
516
517static inline int pgd_none(pgd_t pgd)
518{
Martin Schwidefsky6252d702008-02-09 18:24:37 +0100519 if ((pgd_val(pgd) & _REGION_ENTRY_TYPE_MASK) < _REGION_ENTRY_TYPE_R2)
520 return 0;
Martin Schwidefskye5098612013-07-23 20:57:57 +0200521 return (pgd_val(pgd) & _REGION_ENTRY_INVALID) != 0UL;
Martin Schwidefsky5a216a22008-02-09 18:24:36 +0100522}
523
524static inline int pgd_bad(pgd_t pgd)
525{
Martin Schwidefsky6252d702008-02-09 18:24:37 +0100526 /*
527 * With dynamic page table levels the pgd can be a region table
528 * entry or a segment table entry. Check for the bit that are
529 * invalid for either table entry.
530 */
Martin Schwidefsky5a216a22008-02-09 18:24:36 +0100531 unsigned long mask =
Martin Schwidefskye5098612013-07-23 20:57:57 +0200532 ~_SEGMENT_ENTRY_ORIGIN & ~_REGION_ENTRY_INVALID &
Martin Schwidefsky5a216a22008-02-09 18:24:36 +0100533 ~_REGION_ENTRY_TYPE_MASK & ~_REGION_ENTRY_LENGTH;
534 return (pgd_val(pgd) & mask) != 0;
535}
Martin Schwidefsky190a1d72007-10-22 12:52:48 +0200536
537static inline int pud_present(pud_t pud)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538{
Martin Schwidefsky6252d702008-02-09 18:24:37 +0100539 if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) < _REGION_ENTRY_TYPE_R3)
540 return 1;
Martin Schwidefsky0d017922007-12-17 16:25:48 +0100541 return (pud_val(pud) & _REGION_ENTRY_ORIGIN) != 0UL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542}
543
Martin Schwidefsky190a1d72007-10-22 12:52:48 +0200544static inline int pud_none(pud_t pud)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545{
Martin Schwidefsky6252d702008-02-09 18:24:37 +0100546 if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) < _REGION_ENTRY_TYPE_R3)
547 return 0;
Martin Schwidefskye5098612013-07-23 20:57:57 +0200548 return (pud_val(pud) & _REGION_ENTRY_INVALID) != 0UL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549}
550
Heiko Carstens18da2362012-10-08 09:18:26 +0200551static inline int pud_large(pud_t pud)
552{
553 if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) != _REGION_ENTRY_TYPE_R3)
554 return 0;
555 return !!(pud_val(pud) & _REGION3_ENTRY_LARGE);
556}
557
Martin Schwidefsky190a1d72007-10-22 12:52:48 +0200558static inline int pud_bad(pud_t pud)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559{
Martin Schwidefsky6252d702008-02-09 18:24:37 +0100560 /*
561 * With dynamic page table levels the pud can be a region table
562 * entry or a segment table entry. Check for the bit that are
563 * invalid for either table entry.
564 */
Martin Schwidefsky5a216a22008-02-09 18:24:36 +0100565 unsigned long mask =
Martin Schwidefskye5098612013-07-23 20:57:57 +0200566 ~_SEGMENT_ENTRY_ORIGIN & ~_REGION_ENTRY_INVALID &
Martin Schwidefsky5a216a22008-02-09 18:24:36 +0100567 ~_REGION_ENTRY_TYPE_MASK & ~_REGION_ENTRY_LENGTH;
568 return (pud_val(pud) & mask) != 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569}
570
Heiko Carstensf4815ac2012-05-23 16:24:51 +0200571#endif /* CONFIG_64BIT */
Martin Schwidefsky3610cce2007-10-22 12:52:47 +0200572
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800573static inline int pmd_present(pmd_t pmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200575 return pmd_val(pmd) != _SEGMENT_ENTRY_INVALID;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576}
577
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800578static inline int pmd_none(pmd_t pmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200580 return pmd_val(pmd) == _SEGMENT_ENTRY_INVALID;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581}
582
Heiko Carstens378b1e72012-10-01 12:58:34 +0200583static inline int pmd_large(pmd_t pmd)
584{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200585 return (pmd_val(pmd) & _SEGMENT_ENTRY_LARGE) != 0;
Heiko Carstens378b1e72012-10-01 12:58:34 +0200586}
587
Martin Schwidefsky152125b2014-07-24 11:03:41 +0200588static inline int pmd_pfn(pmd_t pmd)
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200589{
Martin Schwidefsky152125b2014-07-24 11:03:41 +0200590 unsigned long origin_mask;
591
592 origin_mask = _SEGMENT_ENTRY_ORIGIN;
593 if (pmd_large(pmd))
594 origin_mask = _SEGMENT_ENTRY_ORIGIN_LARGE;
595 return (pmd_val(pmd) & origin_mask) >> PAGE_SHIFT;
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200596}
597
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800598static inline int pmd_bad(pmd_t pmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599{
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200600 if (pmd_large(pmd))
601 return (pmd_val(pmd) & ~_SEGMENT_ENTRY_BITS_LARGE) != 0;
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200602 return (pmd_val(pmd) & ~_SEGMENT_ENTRY_BITS) != 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603}
604
Gerald Schaefer75077af2012-10-08 16:30:15 -0700605#define __HAVE_ARCH_PMDP_SPLITTING_FLUSH
606extern void pmdp_splitting_flush(struct vm_area_struct *vma,
607 unsigned long addr, pmd_t *pmdp);
608
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -0700609#define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
610extern int pmdp_set_access_flags(struct vm_area_struct *vma,
611 unsigned long address, pmd_t *pmdp,
612 pmd_t entry, int dirty);
613
614#define __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH
615extern int pmdp_clear_flush_young(struct vm_area_struct *vma,
616 unsigned long address, pmd_t *pmdp);
617
618#define __HAVE_ARCH_PMD_WRITE
619static inline int pmd_write(pmd_t pmd)
620{
Martin Schwidefsky152125b2014-07-24 11:03:41 +0200621 return (pmd_val(pmd) & _SEGMENT_ENTRY_WRITE) != 0;
622}
623
624static inline int pmd_dirty(pmd_t pmd)
625{
626 int dirty = 1;
627 if (pmd_large(pmd))
628 dirty = (pmd_val(pmd) & _SEGMENT_ENTRY_DIRTY) != 0;
629 return dirty;
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -0700630}
631
632static inline int pmd_young(pmd_t pmd)
633{
Martin Schwidefsky152125b2014-07-24 11:03:41 +0200634 int young = 1;
635 if (pmd_large(pmd))
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200636 young = (pmd_val(pmd) & _SEGMENT_ENTRY_YOUNG) != 0;
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200637 return young;
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -0700638}
639
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800640static inline int pte_present(pte_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200642 /* Bit pattern: (pte & 0x001) == 0x001 */
643 return (pte_val(pte) & _PAGE_PRESENT) != 0;
644}
645
646static inline int pte_none(pte_t pte)
647{
648 /* Bit pattern: pte == 0x400 */
649 return pte_val(pte) == _PAGE_INVALID;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650}
651
Konstantin Weitzb31288f2013-04-17 17:36:29 +0200652static inline int pte_swap(pte_t pte)
653{
654 /* Bit pattern: (pte & 0x603) == 0x402 */
655 return (pte_val(pte) & (_PAGE_INVALID | _PAGE_PROTECT |
656 _PAGE_TYPE | _PAGE_PRESENT))
657 == (_PAGE_INVALID | _PAGE_TYPE);
658}
659
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800660static inline int pte_file(pte_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200662 /* Bit pattern: (pte & 0x601) == 0x600 */
663 return (pte_val(pte) & (_PAGE_INVALID | _PAGE_PROTECT | _PAGE_PRESENT))
664 == (_PAGE_INVALID | _PAGE_PROTECT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665}
666
Nick Piggin7e675132008-04-28 02:13:00 -0700667static inline int pte_special(pte_t pte)
668{
Nick Piggina08cb622008-04-28 02:13:03 -0700669 return (pte_val(pte) & _PAGE_SPECIAL);
Nick Piggin7e675132008-04-28 02:13:00 -0700670}
671
Martin Schwidefskyba8a9222007-10-22 12:52:44 +0200672#define __HAVE_ARCH_PTE_SAME
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200673static inline int pte_same(pte_t a, pte_t b)
Christian Borntraeger5b7baf02008-03-25 18:47:12 +0100674{
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200675 return pte_val(a) == pte_val(b);
Christian Borntraeger5b7baf02008-03-25 18:47:12 +0100676}
677
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200678static inline pgste_t pgste_get_lock(pte_t *ptep)
679{
680 unsigned long new = 0;
681#ifdef CONFIG_PGSTE
682 unsigned long old;
683
684 preempt_disable();
685 asm(
686 " lg %0,%2\n"
687 "0: lgr %1,%0\n"
Martin Schwidefsky0d0dafc2013-05-17 14:41:33 +0200688 " nihh %0,0xff7f\n" /* clear PCL bit in old */
689 " oihh %1,0x0080\n" /* set PCL bit in new */
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200690 " csg %0,%1,%2\n"
691 " jl 0b\n"
692 : "=&d" (old), "=&d" (new), "=Q" (ptep[PTRS_PER_PTE])
Christian Borntraegera8f6e7f2013-06-05 09:25:34 +0200693 : "Q" (ptep[PTRS_PER_PTE]) : "cc", "memory");
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200694#endif
695 return __pgste(new);
696}
697
698static inline void pgste_set_unlock(pte_t *ptep, pgste_t pgste)
Christian Borntraeger5b7baf02008-03-25 18:47:12 +0100699{
700#ifdef CONFIG_PGSTE
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200701 asm(
Martin Schwidefsky0d0dafc2013-05-17 14:41:33 +0200702 " nihh %1,0xff7f\n" /* clear PCL bit */
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200703 " stg %1,%0\n"
704 : "=Q" (ptep[PTRS_PER_PTE])
Christian Borntraegera8f6e7f2013-06-05 09:25:34 +0200705 : "d" (pgste_val(pgste)), "Q" (ptep[PTRS_PER_PTE])
706 : "cc", "memory");
Christian Borntraeger5b7baf02008-03-25 18:47:12 +0100707 preempt_enable();
708#endif
709}
710
Martin Schwidefskyd56c8932013-07-19 11:15:54 +0200711static inline pgste_t pgste_get(pte_t *ptep)
712{
713 unsigned long pgste = 0;
714#ifdef CONFIG_PGSTE
715 pgste = *(unsigned long *)(ptep + PTRS_PER_PTE);
716#endif
717 return __pgste(pgste);
718}
719
Christian Borntraeger3a826032013-06-05 09:22:33 +0200720static inline void pgste_set(pte_t *ptep, pgste_t pgste)
721{
722#ifdef CONFIG_PGSTE
723 *(pgste_t *)(ptep + PTRS_PER_PTE) = pgste;
724#endif
725}
726
Dominik Dingel65eef3352014-01-14 15:02:11 +0100727static inline pgste_t pgste_update_all(pte_t *ptep, pgste_t pgste,
728 struct mm_struct *mm)
Christian Borntraeger5b7baf02008-03-25 18:47:12 +0100729{
730#ifdef CONFIG_PGSTE
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200731 unsigned long address, bits, skey;
Christian Borntraeger5b7baf02008-03-25 18:47:12 +0100732
Dominik Dingel65eef3352014-01-14 15:02:11 +0100733 if (!mm_use_skey(mm) || pte_val(*ptep) & _PAGE_INVALID)
Martin Schwidefsky09b53882011-11-14 11:19:00 +0100734 return pgste;
Heiko Carstensa43a9d92011-05-29 12:40:50 +0200735 address = pte_val(*ptep) & PAGE_MASK;
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200736 skey = (unsigned long) page_get_storage_key(address);
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200737 bits = skey & (_PAGE_CHANGED | _PAGE_REFERENCED);
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200738 /* Transfer page changed & referenced bit to guest bits in pgste */
Martin Schwidefsky0d0dafc2013-05-17 14:41:33 +0200739 pgste_val(pgste) |= bits << 48; /* GR bit & GC bit */
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200740 /* Copy page access key and fetch protection bit to pgste */
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200741 pgste_val(pgste) &= ~(PGSTE_ACC_BITS | PGSTE_FP_BIT);
742 pgste_val(pgste) |= (skey & (_PAGE_ACC_BITS | _PAGE_FP_BIT)) << 56;
Christian Borntraeger5b7baf02008-03-25 18:47:12 +0100743#endif
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200744 return pgste;
745
746}
747
Dominik Dingel65eef3352014-01-14 15:02:11 +0100748static inline void pgste_set_key(pte_t *ptep, pgste_t pgste, pte_t entry,
749 struct mm_struct *mm)
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200750{
751#ifdef CONFIG_PGSTE
Heiko Carstensa43a9d92011-05-29 12:40:50 +0200752 unsigned long address;
Christian Borntraeger338679f2013-06-04 09:53:59 +0200753 unsigned long nkey;
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200754
Dominik Dingel65eef3352014-01-14 15:02:11 +0100755 if (!mm_use_skey(mm) || pte_val(entry) & _PAGE_INVALID)
Martin Schwidefsky09b53882011-11-14 11:19:00 +0100756 return;
Christian Borntraeger338679f2013-06-04 09:53:59 +0200757 VM_BUG_ON(!(pte_val(*ptep) & _PAGE_INVALID));
Martin Schwidefsky09b53882011-11-14 11:19:00 +0100758 address = pte_val(entry) & PAGE_MASK;
Christian Borntraeger338679f2013-06-04 09:53:59 +0200759 /*
760 * Set page access key and fetch protection bit from pgste.
761 * The guest C/R information is still in the PGSTE, set real
762 * key C/R to 0.
763 */
Linus Torvaldsfe489bf2013-07-03 13:21:40 -0700764 nkey = (pgste_val(pgste) & (PGSTE_ACC_BITS | PGSTE_FP_BIT)) >> 56;
Martin Schwidefsky0a61b222013-10-18 12:03:41 +0200765 nkey |= (pgste_val(pgste) & (PGSTE_GR_BIT | PGSTE_GC_BIT)) >> 48;
Christian Borntraeger338679f2013-06-04 09:53:59 +0200766 page_set_storage_key(address, nkey, 0);
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200767#endif
768}
769
Martin Schwidefsky0a61b222013-10-18 12:03:41 +0200770static inline pgste_t pgste_set_pte(pte_t *ptep, pgste_t pgste, pte_t entry)
Martin Schwidefskyabf09be2012-11-07 13:17:37 +0100771{
Martin Schwidefsky0a61b222013-10-18 12:03:41 +0200772 if ((pte_val(entry) & _PAGE_PRESENT) &&
773 (pte_val(entry) & _PAGE_WRITE) &&
774 !(pte_val(entry) & _PAGE_INVALID)) {
775 if (!MACHINE_HAS_ESOP) {
776 /*
777 * Without enhanced suppression-on-protection force
778 * the dirty bit on for all writable ptes.
779 */
780 pte_val(entry) |= _PAGE_DIRTY;
781 pte_val(entry) &= ~_PAGE_PROTECT;
782 }
783 if (!(pte_val(entry) & _PAGE_PROTECT))
784 /* This pte allows write access, set user-dirty */
785 pgste_val(pgste) |= PGSTE_UC_BIT;
Martin Schwidefskyabf09be2012-11-07 13:17:37 +0100786 }
787 *ptep = entry;
Martin Schwidefsky0a61b222013-10-18 12:03:41 +0200788 return pgste;
Martin Schwidefskyabf09be2012-11-07 13:17:37 +0100789}
790
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200791/**
792 * struct gmap_struct - guest address space
Martin Schwidefsky527e30b2014-04-30 16:04:25 +0200793 * @crst_list: list of all crst tables used in the guest address space
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200794 * @mm: pointer to the parent mm_struct
Martin Schwidefsky527e30b2014-04-30 16:04:25 +0200795 * @guest_to_host: radix tree with guest to host address translation
796 * @host_to_guest: radix tree with pointer to segment table entries
797 * @guest_table_lock: spinlock to protect all entries in the guest page table
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200798 * @table: pointer to the page directory
Christian Borntraeger480e5922011-09-20 17:07:28 +0200799 * @asce: address space control element for gmap page table
Dominik Dingel24eb3a82013-06-17 16:25:18 +0200800 * @pfault_enabled: defines if pfaults are applicable for the guest
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200801 */
802struct gmap {
803 struct list_head list;
Martin Schwidefsky527e30b2014-04-30 16:04:25 +0200804 struct list_head crst_list;
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200805 struct mm_struct *mm;
Martin Schwidefsky527e30b2014-04-30 16:04:25 +0200806 struct radix_tree_root guest_to_host;
807 struct radix_tree_root host_to_guest;
808 spinlock_t guest_table_lock;
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200809 unsigned long *table;
Christian Borntraeger480e5922011-09-20 17:07:28 +0200810 unsigned long asce;
Christian Borntraeger2c70fe42013-05-17 14:41:36 +0200811 void *private;
Dominik Dingel24eb3a82013-06-17 16:25:18 +0200812 bool pfault_enabled;
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200813};
814
815/**
816 * struct gmap_rmap - reverse mapping for segment table entries
Martin Schwidefskyd3383632013-04-17 10:53:39 +0200817 * @gmap: pointer to the gmap_struct
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200818 * @entry: pointer to a segment table entry
Martin Schwidefskyd3383632013-04-17 10:53:39 +0200819 * @vmaddr: virtual address in the guest address space
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200820 */
821struct gmap_rmap {
822 struct list_head list;
Martin Schwidefskyd3383632013-04-17 10:53:39 +0200823 struct gmap *gmap;
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200824 unsigned long *entry;
Martin Schwidefskyd3383632013-04-17 10:53:39 +0200825 unsigned long vmaddr;
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200826};
827
828/**
829 * struct gmap_pgtable - gmap information attached to a page table
830 * @vmaddr: address of the 1MB segment in the process virtual memory
Martin Schwidefskyd3383632013-04-17 10:53:39 +0200831 * @mapper: list of segment table entries mapping a page table
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200832 */
833struct gmap_pgtable {
834 unsigned long vmaddr;
835 struct list_head mapper;
836};
837
Martin Schwidefskyd3383632013-04-17 10:53:39 +0200838/**
839 * struct gmap_notifier - notify function block for page invalidation
840 * @notifier_call: address of callback function
841 */
842struct gmap_notifier {
843 struct list_head list;
Martin Schwidefsky6e0a0432014-04-29 09:34:41 +0200844 void (*notifier_call)(struct gmap *gmap, unsigned long gaddr);
Martin Schwidefskyd3383632013-04-17 10:53:39 +0200845};
846
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200847struct gmap *gmap_alloc(struct mm_struct *mm);
848void gmap_free(struct gmap *gmap);
849void gmap_enable(struct gmap *gmap);
850void gmap_disable(struct gmap *gmap);
851int gmap_map_segment(struct gmap *gmap, unsigned long from,
Martin Schwidefskyd3383632013-04-17 10:53:39 +0200852 unsigned long to, unsigned long len);
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200853int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long len);
Martin Schwidefsky6e0a0432014-04-29 09:34:41 +0200854unsigned long __gmap_translate(struct gmap *, unsigned long gaddr);
855unsigned long gmap_translate(struct gmap *, unsigned long gaddr);
Martin Schwidefsky527e30b2014-04-30 16:04:25 +0200856int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr);
857int gmap_fault(struct gmap *, unsigned long gaddr, unsigned int fault_flags);
Martin Schwidefsky6e0a0432014-04-29 09:34:41 +0200858void gmap_discard(struct gmap *, unsigned long from, unsigned long to);
859void __gmap_zap(struct gmap *, unsigned long gaddr);
Dominik Dingela0bf4f12014-03-24 14:27:58 +0100860bool gmap_test_and_clear_dirty(unsigned long address, struct gmap *);
861
Martin Schwidefskye5992f22011-07-24 10:48:20 +0200862
Martin Schwidefskyd3383632013-04-17 10:53:39 +0200863void gmap_register_ipte_notifier(struct gmap_notifier *);
864void gmap_unregister_ipte_notifier(struct gmap_notifier *);
865int gmap_ipte_notify(struct gmap *, unsigned long start, unsigned long len);
Martin Schwidefsky9da4e382014-04-30 14:46:26 +0200866void gmap_do_ipte_notify(struct mm_struct *, unsigned long addr, pte_t *);
Martin Schwidefskyd3383632013-04-17 10:53:39 +0200867
868static inline pgste_t pgste_ipte_notify(struct mm_struct *mm,
Martin Schwidefsky55dbbdd2014-04-30 14:44:44 +0200869 unsigned long addr,
Martin Schwidefskyd3383632013-04-17 10:53:39 +0200870 pte_t *ptep, pgste_t pgste)
871{
872#ifdef CONFIG_PGSTE
Martin Schwidefsky0d0dafc2013-05-17 14:41:33 +0200873 if (pgste_val(pgste) & PGSTE_IN_BIT) {
874 pgste_val(pgste) &= ~PGSTE_IN_BIT;
Martin Schwidefsky9da4e382014-04-30 14:46:26 +0200875 gmap_do_ipte_notify(mm, addr, ptep);
Martin Schwidefskyd3383632013-04-17 10:53:39 +0200876 }
877#endif
878 return pgste;
879}
880
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200881/*
882 * Certain architectures need to do special things when PTEs
883 * within a page table are directly modified. Thus, the following
884 * hook is made available.
885 */
886static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
887 pte_t *ptep, pte_t entry)
888{
889 pgste_t pgste;
890
891 if (mm_has_pgste(mm)) {
892 pgste = pgste_get_lock(ptep);
Konstantin Weitzb31288f2013-04-17 17:36:29 +0200893 pgste_val(pgste) &= ~_PGSTE_GPS_ZERO;
Dominik Dingel65eef3352014-01-14 15:02:11 +0100894 pgste_set_key(ptep, pgste, entry, mm);
Martin Schwidefsky0a61b222013-10-18 12:03:41 +0200895 pgste = pgste_set_pte(ptep, pgste, entry);
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200896 pgste_set_unlock(ptep, pgste);
Martin Schwidefskyabf09be2012-11-07 13:17:37 +0100897 } else {
898 if (!(pte_val(entry) & _PAGE_INVALID) && MACHINE_HAS_EDAT1)
899 pte_val(entry) |= _PAGE_CO;
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200900 *ptep = entry;
Martin Schwidefskyabf09be2012-11-07 13:17:37 +0100901 }
Christian Borntraeger5b7baf02008-03-25 18:47:12 +0100902}
903
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904/*
905 * query functions pte_write/pte_dirty/pte_young only work if
906 * pte_present() is true. Undefined behaviour if not..
907 */
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800908static inline int pte_write(pte_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200910 return (pte_val(pte) & _PAGE_WRITE) != 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911}
912
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800913static inline int pte_dirty(pte_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200915 return (pte_val(pte) & _PAGE_DIRTY) != 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916}
917
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800918static inline int pte_young(pte_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919{
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200920 return (pte_val(pte) & _PAGE_YOUNG) != 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921}
922
Konstantin Weitzb31288f2013-04-17 17:36:29 +0200923#define __HAVE_ARCH_PTE_UNUSED
924static inline int pte_unused(pte_t pte)
925{
926 return pte_val(pte) & _PAGE_UNUSED;
927}
928
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929/*
930 * pgd/pmd/pte modification functions
931 */
932
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200933static inline void pgd_clear(pgd_t *pgd)
Martin Schwidefsky5a216a22008-02-09 18:24:36 +0100934{
Heiko Carstensf4815ac2012-05-23 16:24:51 +0200935#ifdef CONFIG_64BIT
Martin Schwidefsky6252d702008-02-09 18:24:37 +0100936 if ((pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R2)
937 pgd_val(*pgd) = _REGION2_ENTRY_EMPTY;
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200938#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939}
940
Martin Schwidefsky6252d702008-02-09 18:24:37 +0100941static inline void pud_clear(pud_t *pud)
Gerald Schaeferc1821c22007-02-05 21:18:17 +0100942{
Heiko Carstensf4815ac2012-05-23 16:24:51 +0200943#ifdef CONFIG_64BIT
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200944 if ((pud_val(*pud) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3)
945 pud_val(*pud) = _REGION3_ENTRY_EMPTY;
946#endif
Gerald Schaeferc1821c22007-02-05 21:18:17 +0100947}
Martin Schwidefsky146e4b32008-02-09 18:24:35 +0100948
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +0200949static inline void pmd_clear(pmd_t *pmdp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200951 pmd_val(*pmdp) = _SEGMENT_ENTRY_INVALID;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952}
953
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800954static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200956 pte_val(*ptep) = _PAGE_INVALID;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957}
958
959/*
960 * The following pte modification functions only work if
961 * pte_present() is true. Undefined behaviour if not..
962 */
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800963static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964{
Nick Piggin138c9022008-07-08 11:31:06 +0200965 pte_val(pte) &= _PAGE_CHG_MASK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966 pte_val(pte) |= pgprot_val(newprot);
Martin Schwidefsky0944fe32013-07-23 22:11:42 +0200967 /*
968 * newprot for PAGE_NONE, PAGE_READ and PAGE_WRITE has the
969 * invalid bit set, clear it again for readable, young pages
970 */
971 if ((pte_val(pte) & _PAGE_YOUNG) && (pte_val(pte) & _PAGE_READ))
972 pte_val(pte) &= ~_PAGE_INVALID;
973 /*
974 * newprot for PAGE_READ and PAGE_WRITE has the page protection
975 * bit set, clear it again for writable, dirty pages
976 */
Martin Schwidefskye5098612013-07-23 20:57:57 +0200977 if ((pte_val(pte) & _PAGE_DIRTY) && (pte_val(pte) & _PAGE_WRITE))
978 pte_val(pte) &= ~_PAGE_PROTECT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 return pte;
980}
981
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800982static inline pte_t pte_wrprotect(pte_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200984 pte_val(pte) &= ~_PAGE_WRITE;
985 pte_val(pte) |= _PAGE_PROTECT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986 return pte;
987}
988
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800989static inline pte_t pte_mkwrite(pte_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200991 pte_val(pte) |= _PAGE_WRITE;
992 if (pte_val(pte) & _PAGE_DIRTY)
993 pte_val(pte) &= ~_PAGE_PROTECT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 return pte;
995}
996
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800997static inline pte_t pte_mkclean(pte_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200999 pte_val(pte) &= ~_PAGE_DIRTY;
1000 pte_val(pte) |= _PAGE_PROTECT;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001 return pte;
1002}
1003
Adrian Bunk4448aaf2005-11-08 21:34:42 -08001004static inline pte_t pte_mkdirty(pte_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005{
Martin Schwidefskye5098612013-07-23 20:57:57 +02001006 pte_val(pte) |= _PAGE_DIRTY;
1007 if (pte_val(pte) & _PAGE_WRITE)
1008 pte_val(pte) &= ~_PAGE_PROTECT;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009 return pte;
1010}
1011
Adrian Bunk4448aaf2005-11-08 21:34:42 -08001012static inline pte_t pte_mkold(pte_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013{
Martin Schwidefskye5098612013-07-23 20:57:57 +02001014 pte_val(pte) &= ~_PAGE_YOUNG;
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001015 pte_val(pte) |= _PAGE_INVALID;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016 return pte;
1017}
1018
Adrian Bunk4448aaf2005-11-08 21:34:42 -08001019static inline pte_t pte_mkyoung(pte_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020{
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001021 pte_val(pte) |= _PAGE_YOUNG;
1022 if (pte_val(pte) & _PAGE_READ)
1023 pte_val(pte) &= ~_PAGE_INVALID;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024 return pte;
1025}
1026
Nick Piggin7e675132008-04-28 02:13:00 -07001027static inline pte_t pte_mkspecial(pte_t pte)
1028{
Nick Piggina08cb622008-04-28 02:13:03 -07001029 pte_val(pte) |= _PAGE_SPECIAL;
Nick Piggin7e675132008-04-28 02:13:00 -07001030 return pte;
1031}
1032
Heiko Carstens84afdce2010-10-25 16:10:36 +02001033#ifdef CONFIG_HUGETLB_PAGE
1034static inline pte_t pte_mkhuge(pte_t pte)
1035{
Martin Schwidefskye5098612013-07-23 20:57:57 +02001036 pte_val(pte) |= _PAGE_LARGE;
Heiko Carstens84afdce2010-10-25 16:10:36 +02001037 return pte;
1038}
1039#endif
1040
Gerald Schaefer9282ed92006-09-20 15:59:37 +02001041static inline void __ptep_ipte(unsigned long address, pte_t *ptep)
1042{
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001043 unsigned long pto = (unsigned long) ptep;
1044
Heiko Carstensf4815ac2012-05-23 16:24:51 +02001045#ifndef CONFIG_64BIT
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001046 /* pto in ESA mode must point to the start of the segment table */
1047 pto &= 0x7ffffc00;
Gerald Schaefer9282ed92006-09-20 15:59:37 +02001048#endif
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001049 /* Invalidation + global TLB flush for the pte */
1050 asm volatile(
1051 " ipte %2,%3"
1052 : "=m" (*ptep) : "m" (*ptep), "a" (pto), "a" (address));
1053}
1054
Martin Schwidefsky1b948d62014-04-03 13:55:01 +02001055static inline void __ptep_ipte_local(unsigned long address, pte_t *ptep)
1056{
1057 unsigned long pto = (unsigned long) ptep;
1058
1059#ifndef CONFIG_64BIT
1060 /* pto in ESA mode must point to the start of the segment table */
1061 pto &= 0x7ffffc00;
1062#endif
1063 /* Invalidation + local TLB flush for the pte */
1064 asm volatile(
1065 " .insn rrf,0xb2210000,%2,%3,0,1"
1066 : "=m" (*ptep) : "m" (*ptep), "a" (pto), "a" (address));
1067}
1068
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001069static inline void ptep_flush_direct(struct mm_struct *mm,
1070 unsigned long address, pte_t *ptep)
1071{
Martin Schwidefsky1b948d62014-04-03 13:55:01 +02001072 int active, count;
1073
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001074 if (pte_val(*ptep) & _PAGE_INVALID)
1075 return;
Martin Schwidefsky1b948d62014-04-03 13:55:01 +02001076 active = (mm == current->active_mm) ? 1 : 0;
1077 count = atomic_add_return(0x10000, &mm->context.attach_count);
1078 if (MACHINE_HAS_TLB_LC && (count & 0xffff) <= active &&
1079 cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id())))
1080 __ptep_ipte_local(address, ptep);
1081 else
1082 __ptep_ipte(address, ptep);
1083 atomic_sub(0x10000, &mm->context.attach_count);
Gerald Schaefer9282ed92006-09-20 15:59:37 +02001084}
1085
Martin Schwidefsky5c474a12013-08-16 13:31:40 +02001086static inline void ptep_flush_lazy(struct mm_struct *mm,
1087 unsigned long address, pte_t *ptep)
1088{
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001089 int active, count;
Martin Schwidefsky5c474a12013-08-16 13:31:40 +02001090
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001091 if (pte_val(*ptep) & _PAGE_INVALID)
1092 return;
1093 active = (mm == current->active_mm) ? 1 : 0;
1094 count = atomic_add_return(0x10000, &mm->context.attach_count);
1095 if ((count & 0xffff) <= active) {
1096 pte_val(*ptep) |= _PAGE_INVALID;
Martin Schwidefsky5c474a12013-08-16 13:31:40 +02001097 mm->context.flush_mm = 1;
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001098 } else
1099 __ptep_ipte(address, ptep);
1100 atomic_sub(0x10000, &mm->context.attach_count);
Martin Schwidefsky5c474a12013-08-16 13:31:40 +02001101}
1102
Martin Schwidefsky0a61b222013-10-18 12:03:41 +02001103/*
1104 * Get (and clear) the user dirty bit for a pte.
1105 */
1106static inline int ptep_test_and_clear_user_dirty(struct mm_struct *mm,
1107 unsigned long addr,
1108 pte_t *ptep)
1109{
1110 pgste_t pgste;
1111 pte_t pte;
1112 int dirty;
1113
1114 if (!mm_has_pgste(mm))
1115 return 0;
1116 pgste = pgste_get_lock(ptep);
1117 dirty = !!(pgste_val(pgste) & PGSTE_UC_BIT);
1118 pgste_val(pgste) &= ~PGSTE_UC_BIT;
1119 pte = *ptep;
1120 if (dirty && (pte_val(pte) & _PAGE_PRESENT)) {
Martin Schwidefsky55dbbdd2014-04-30 14:44:44 +02001121 pgste = pgste_ipte_notify(mm, addr, ptep, pgste);
Martin Schwidefsky0a61b222013-10-18 12:03:41 +02001122 __ptep_ipte(addr, ptep);
1123 if (MACHINE_HAS_ESOP || !(pte_val(pte) & _PAGE_WRITE))
1124 pte_val(pte) |= _PAGE_PROTECT;
1125 else
1126 pte_val(pte) |= _PAGE_INVALID;
1127 *ptep = pte;
1128 }
1129 pgste_set_unlock(ptep, pgste);
1130 return dirty;
1131}
1132
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001133#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
1134static inline int ptep_test_and_clear_young(struct vm_area_struct *vma,
1135 unsigned long addr, pte_t *ptep)
1136{
1137 pgste_t pgste;
1138 pte_t pte;
1139 int young;
1140
1141 if (mm_has_pgste(vma->vm_mm)) {
1142 pgste = pgste_get_lock(ptep);
Martin Schwidefsky55dbbdd2014-04-30 14:44:44 +02001143 pgste = pgste_ipte_notify(vma->vm_mm, addr, ptep, pgste);
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001144 }
1145
1146 pte = *ptep;
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001147 ptep_flush_direct(vma->vm_mm, addr, ptep);
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001148 young = pte_young(pte);
1149 pte = pte_mkold(pte);
1150
1151 if (mm_has_pgste(vma->vm_mm)) {
Martin Schwidefsky0a61b222013-10-18 12:03:41 +02001152 pgste = pgste_set_pte(ptep, pgste, pte);
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001153 pgste_set_unlock(ptep, pgste);
1154 } else
1155 *ptep = pte;
1156
1157 return young;
1158}
1159
1160#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
1161static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
1162 unsigned long address, pte_t *ptep)
1163{
1164 return ptep_test_and_clear_young(vma, address, ptep);
1165}
1166
Martin Schwidefskyba8a9222007-10-22 12:52:44 +02001167/*
1168 * This is hard to understand. ptep_get_and_clear and ptep_clear_flush
1169 * both clear the TLB for the unmapped pte. The reason is that
1170 * ptep_get_and_clear is used in common code (e.g. change_pte_range)
1171 * to modify an active pte. The sequence is
1172 * 1) ptep_get_and_clear
1173 * 2) set_pte_at
1174 * 3) flush_tlb_range
1175 * On s390 the tlb needs to get flushed with the modification of the pte
1176 * if the pte is active. The only way how this can be implemented is to
1177 * have ptep_get_and_clear do the tlb flush. In exchange flush_tlb_range
1178 * is a nop.
1179 */
1180#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001181static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
1182 unsigned long address, pte_t *ptep)
1183{
1184 pgste_t pgste;
1185 pte_t pte;
1186
Martin Schwidefskyd3383632013-04-17 10:53:39 +02001187 if (mm_has_pgste(mm)) {
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001188 pgste = pgste_get_lock(ptep);
Martin Schwidefsky55dbbdd2014-04-30 14:44:44 +02001189 pgste = pgste_ipte_notify(mm, address, ptep, pgste);
Martin Schwidefskyd3383632013-04-17 10:53:39 +02001190 }
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001191
1192 pte = *ptep;
Martin Schwidefsky5c474a12013-08-16 13:31:40 +02001193 ptep_flush_lazy(mm, address, ptep);
Martin Schwidefskye5098612013-07-23 20:57:57 +02001194 pte_val(*ptep) = _PAGE_INVALID;
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001195
1196 if (mm_has_pgste(mm)) {
Dominik Dingel65eef3352014-01-14 15:02:11 +01001197 pgste = pgste_update_all(&pte, pgste, mm);
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001198 pgste_set_unlock(ptep, pgste);
1199 }
1200 return pte;
1201}
1202
1203#define __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION
1204static inline pte_t ptep_modify_prot_start(struct mm_struct *mm,
1205 unsigned long address,
1206 pte_t *ptep)
1207{
Martin Schwidefskyd3383632013-04-17 10:53:39 +02001208 pgste_t pgste;
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001209 pte_t pte;
1210
Martin Schwidefskyd3383632013-04-17 10:53:39 +02001211 if (mm_has_pgste(mm)) {
1212 pgste = pgste_get_lock(ptep);
Martin Schwidefsky55dbbdd2014-04-30 14:44:44 +02001213 pgste_ipte_notify(mm, address, ptep, pgste);
Martin Schwidefskyd3383632013-04-17 10:53:39 +02001214 }
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001215
1216 pte = *ptep;
Martin Schwidefsky5c474a12013-08-16 13:31:40 +02001217 ptep_flush_lazy(mm, address, ptep);
Christian Borntraegerb56433c2013-05-27 16:19:55 +02001218
Christian Borntraeger3a826032013-06-05 09:22:33 +02001219 if (mm_has_pgste(mm)) {
Dominik Dingel65eef3352014-01-14 15:02:11 +01001220 pgste = pgste_update_all(&pte, pgste, mm);
Christian Borntraeger3a826032013-06-05 09:22:33 +02001221 pgste_set(ptep, pgste);
1222 }
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001223 return pte;
1224}
1225
1226static inline void ptep_modify_prot_commit(struct mm_struct *mm,
1227 unsigned long address,
1228 pte_t *ptep, pte_t pte)
1229{
Christian Borntraegerb56433c2013-05-27 16:19:55 +02001230 pgste_t pgste;
1231
Martin Schwidefskyabf09be2012-11-07 13:17:37 +01001232 if (mm_has_pgste(mm)) {
Martin Schwidefskyd56c8932013-07-19 11:15:54 +02001233 pgste = pgste_get(ptep);
Dominik Dingel65eef3352014-01-14 15:02:11 +01001234 pgste_set_key(ptep, pgste, pte, mm);
Martin Schwidefsky0a61b222013-10-18 12:03:41 +02001235 pgste = pgste_set_pte(ptep, pgste, pte);
Christian Borntraegerb56433c2013-05-27 16:19:55 +02001236 pgste_set_unlock(ptep, pgste);
Martin Schwidefskyabf09be2012-11-07 13:17:37 +01001237 } else
1238 *ptep = pte;
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001239}
Martin Schwidefskyba8a9222007-10-22 12:52:44 +02001240
1241#define __HAVE_ARCH_PTEP_CLEAR_FLUSH
Martin Schwidefskyf0e47c22007-07-17 04:03:03 -07001242static inline pte_t ptep_clear_flush(struct vm_area_struct *vma,
1243 unsigned long address, pte_t *ptep)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001244{
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001245 pgste_t pgste;
1246 pte_t pte;
1247
Martin Schwidefskyd3383632013-04-17 10:53:39 +02001248 if (mm_has_pgste(vma->vm_mm)) {
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001249 pgste = pgste_get_lock(ptep);
Martin Schwidefsky55dbbdd2014-04-30 14:44:44 +02001250 pgste = pgste_ipte_notify(vma->vm_mm, address, ptep, pgste);
Martin Schwidefskyd3383632013-04-17 10:53:39 +02001251 }
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001252
1253 pte = *ptep;
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001254 ptep_flush_direct(vma->vm_mm, address, ptep);
Martin Schwidefskye5098612013-07-23 20:57:57 +02001255 pte_val(*ptep) = _PAGE_INVALID;
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001256
1257 if (mm_has_pgste(vma->vm_mm)) {
Konstantin Weitzb31288f2013-04-17 17:36:29 +02001258 if ((pgste_val(pgste) & _PGSTE_GPS_USAGE_MASK) ==
1259 _PGSTE_GPS_USAGE_UNUSED)
1260 pte_val(pte) |= _PAGE_UNUSED;
Dominik Dingel65eef3352014-01-14 15:02:11 +01001261 pgste = pgste_update_all(&pte, pgste, vma->vm_mm);
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001262 pgste_set_unlock(ptep, pgste);
1263 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264 return pte;
1265}
1266
Martin Schwidefskyba8a9222007-10-22 12:52:44 +02001267/*
1268 * The batched pte unmap code uses ptep_get_and_clear_full to clear the
1269 * ptes. Here an optimization is possible. tlb_gather_mmu flushes all
1270 * tlbs of an mm if it can guarantee that the ptes of the mm_struct
1271 * cannot be accessed while the batched unmap is running. In this case
1272 * full==1 and a simple pte_clear is enough. See tlb.h.
1273 */
1274#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
1275static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm,
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001276 unsigned long address,
Martin Schwidefskyba8a9222007-10-22 12:52:44 +02001277 pte_t *ptep, int full)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278{
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001279 pgste_t pgste;
1280 pte_t pte;
Martin Schwidefskyba8a9222007-10-22 12:52:44 +02001281
Martin Schwidefskya055f662013-07-19 10:31:55 +02001282 if (!full && mm_has_pgste(mm)) {
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001283 pgste = pgste_get_lock(ptep);
Martin Schwidefsky55dbbdd2014-04-30 14:44:44 +02001284 pgste = pgste_ipte_notify(mm, address, ptep, pgste);
Martin Schwidefskyd3383632013-04-17 10:53:39 +02001285 }
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001286
1287 pte = *ptep;
1288 if (!full)
Martin Schwidefsky5c474a12013-08-16 13:31:40 +02001289 ptep_flush_lazy(mm, address, ptep);
Martin Schwidefskye5098612013-07-23 20:57:57 +02001290 pte_val(*ptep) = _PAGE_INVALID;
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001291
Martin Schwidefskya055f662013-07-19 10:31:55 +02001292 if (!full && mm_has_pgste(mm)) {
Dominik Dingel65eef3352014-01-14 15:02:11 +01001293 pgste = pgste_update_all(&pte, pgste, mm);
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001294 pgste_set_unlock(ptep, pgste);
1295 }
Martin Schwidefskyba8a9222007-10-22 12:52:44 +02001296 return pte;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297}
1298
Martin Schwidefskyba8a9222007-10-22 12:52:44 +02001299#define __HAVE_ARCH_PTEP_SET_WRPROTECT
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001300static inline pte_t ptep_set_wrprotect(struct mm_struct *mm,
1301 unsigned long address, pte_t *ptep)
1302{
1303 pgste_t pgste;
1304 pte_t pte = *ptep;
1305
1306 if (pte_write(pte)) {
Martin Schwidefskyd3383632013-04-17 10:53:39 +02001307 if (mm_has_pgste(mm)) {
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001308 pgste = pgste_get_lock(ptep);
Martin Schwidefsky55dbbdd2014-04-30 14:44:44 +02001309 pgste = pgste_ipte_notify(mm, address, ptep, pgste);
Martin Schwidefskyd3383632013-04-17 10:53:39 +02001310 }
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001311
Martin Schwidefsky5c474a12013-08-16 13:31:40 +02001312 ptep_flush_lazy(mm, address, ptep);
Martin Schwidefskyabf09be2012-11-07 13:17:37 +01001313 pte = pte_wrprotect(pte);
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001314
Martin Schwidefskyabf09be2012-11-07 13:17:37 +01001315 if (mm_has_pgste(mm)) {
Martin Schwidefsky0a61b222013-10-18 12:03:41 +02001316 pgste = pgste_set_pte(ptep, pgste, pte);
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001317 pgste_set_unlock(ptep, pgste);
Martin Schwidefskyabf09be2012-11-07 13:17:37 +01001318 } else
1319 *ptep = pte;
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001320 }
1321 return pte;
1322}
Martin Schwidefskyba8a9222007-10-22 12:52:44 +02001323
1324#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001325static inline int ptep_set_access_flags(struct vm_area_struct *vma,
1326 unsigned long address, pte_t *ptep,
1327 pte_t entry, int dirty)
1328{
1329 pgste_t pgste;
1330
1331 if (pte_same(*ptep, entry))
1332 return 0;
Martin Schwidefskyd3383632013-04-17 10:53:39 +02001333 if (mm_has_pgste(vma->vm_mm)) {
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001334 pgste = pgste_get_lock(ptep);
Martin Schwidefsky55dbbdd2014-04-30 14:44:44 +02001335 pgste = pgste_ipte_notify(vma->vm_mm, address, ptep, pgste);
Martin Schwidefskyd3383632013-04-17 10:53:39 +02001336 }
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001337
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001338 ptep_flush_direct(vma->vm_mm, address, ptep);
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001339
Martin Schwidefskyabf09be2012-11-07 13:17:37 +01001340 if (mm_has_pgste(vma->vm_mm)) {
Martin Schwidefsky0a61b222013-10-18 12:03:41 +02001341 pgste = pgste_set_pte(ptep, pgste, entry);
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001342 pgste_set_unlock(ptep, pgste);
Martin Schwidefskyabf09be2012-11-07 13:17:37 +01001343 } else
1344 *ptep = entry;
Martin Schwidefskyb2fa47e2011-05-23 10:24:40 +02001345 return 1;
1346}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001347
1348/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07001349 * Conversion functions: convert a page and protection to a page entry,
1350 * and a page entry and page directory to the page they refer to.
1351 */
1352static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)
1353{
1354 pte_t __pte;
1355 pte_val(__pte) = physpage + pgprot_val(pgprot);
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001356 return pte_mkyoung(__pte);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001357}
1358
Heiko Carstens2dcea572006-09-29 01:58:41 -07001359static inline pte_t mk_pte(struct page *page, pgprot_t pgprot)
1360{
Heiko Carstens0b2b6e1d2006-10-04 20:02:23 +02001361 unsigned long physpage = page_to_phys(page);
Martin Schwidefskyabf09be2012-11-07 13:17:37 +01001362 pte_t __pte = mk_pte_phys(physpage, pgprot);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001363
Martin Schwidefskye5098612013-07-23 20:57:57 +02001364 if (pte_write(__pte) && PageDirty(page))
1365 __pte = pte_mkdirty(__pte);
Martin Schwidefskyabf09be2012-11-07 13:17:37 +01001366 return __pte;
Heiko Carstens2dcea572006-09-29 01:58:41 -07001367}
1368
Linus Torvalds1da177e2005-04-16 15:20:36 -07001369#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
Martin Schwidefsky190a1d72007-10-22 12:52:48 +02001370#define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
1371#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
1372#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373
Martin Schwidefsky190a1d72007-10-22 12:52:48 +02001374#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375#define pgd_offset_k(address) pgd_offset(&init_mm, address)
1376
Heiko Carstensf4815ac2012-05-23 16:24:51 +02001377#ifndef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378
Martin Schwidefsky190a1d72007-10-22 12:52:48 +02001379#define pmd_deref(pmd) (pmd_val(pmd) & _SEGMENT_ENTRY_ORIGIN)
1380#define pud_deref(pmd) ({ BUG(); 0UL; })
1381#define pgd_deref(pmd) ({ BUG(); 0UL; })
1382
1383#define pud_offset(pgd, address) ((pud_t *) pgd)
1384#define pmd_offset(pud, address) ((pmd_t *) pud + pmd_index(address))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385
Heiko Carstensf4815ac2012-05-23 16:24:51 +02001386#else /* CONFIG_64BIT */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387
Martin Schwidefsky190a1d72007-10-22 12:52:48 +02001388#define pmd_deref(pmd) (pmd_val(pmd) & _SEGMENT_ENTRY_ORIGIN)
1389#define pud_deref(pud) (pud_val(pud) & _REGION_ENTRY_ORIGIN)
Martin Schwidefsky5a216a22008-02-09 18:24:36 +01001390#define pgd_deref(pgd) (pgd_val(pgd) & _REGION_ENTRY_ORIGIN)
Martin Schwidefsky190a1d72007-10-22 12:52:48 +02001391
Martin Schwidefsky5a216a22008-02-09 18:24:36 +01001392static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
1393{
Martin Schwidefsky6252d702008-02-09 18:24:37 +01001394 pud_t *pud = (pud_t *) pgd;
1395 if ((pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R2)
1396 pud = (pud_t *) pgd_deref(*pgd);
Martin Schwidefsky5a216a22008-02-09 18:24:36 +01001397 return pud + pud_index(address);
1398}
Martin Schwidefsky190a1d72007-10-22 12:52:48 +02001399
1400static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
1401{
Martin Schwidefsky6252d702008-02-09 18:24:37 +01001402 pmd_t *pmd = (pmd_t *) pud;
1403 if ((pud_val(*pud) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3)
1404 pmd = (pmd_t *) pud_deref(*pud);
Martin Schwidefsky190a1d72007-10-22 12:52:48 +02001405 return pmd + pmd_index(address);
1406}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407
Heiko Carstensf4815ac2012-05-23 16:24:51 +02001408#endif /* CONFIG_64BIT */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409
Martin Schwidefsky190a1d72007-10-22 12:52:48 +02001410#define pfn_pte(pfn,pgprot) mk_pte_phys(__pa((pfn) << PAGE_SHIFT),(pgprot))
1411#define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT)
1412#define pte_page(x) pfn_to_page(pte_pfn(x))
1413
Martin Schwidefsky152125b2014-07-24 11:03:41 +02001414#define pmd_page(pmd) pfn_to_page(pmd_pfn(pmd))
Martin Schwidefsky190a1d72007-10-22 12:52:48 +02001415
1416/* Find an entry in the lowest level page table.. */
1417#define pte_offset(pmd, addr) ((pte_t *) pmd_deref(*(pmd)) + pte_index(addr))
1418#define pte_offset_kernel(pmd, address) pte_offset(pmd,address)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001419#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420#define pte_unmap(pte) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001421
Gerald Schaefer106c9922013-04-29 15:07:23 -07001422#if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLB_PAGE)
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001423static inline unsigned long massage_pgprot_pmd(pgprot_t pgprot)
1424{
Gerald Schaeferd8e7a332012-10-25 17:42:50 +02001425 /*
Martin Schwidefskye5098612013-07-23 20:57:57 +02001426 * pgprot is PAGE_NONE, PAGE_READ, or PAGE_WRITE (see __Pxxx / __Sxxx)
Gerald Schaeferd8e7a332012-10-25 17:42:50 +02001427 * Convert to segment table entry format.
1428 */
1429 if (pgprot_val(pgprot) == pgprot_val(PAGE_NONE))
1430 return pgprot_val(SEGMENT_NONE);
Martin Schwidefskye5098612013-07-23 20:57:57 +02001431 if (pgprot_val(pgprot) == pgprot_val(PAGE_READ))
1432 return pgprot_val(SEGMENT_READ);
1433 return pgprot_val(SEGMENT_WRITE);
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001434}
1435
Martin Schwidefsky152125b2014-07-24 11:03:41 +02001436static inline pmd_t pmd_wrprotect(pmd_t pmd)
1437{
1438 pmd_val(pmd) &= ~_SEGMENT_ENTRY_WRITE;
1439 pmd_val(pmd) |= _SEGMENT_ENTRY_PROTECT;
1440 return pmd;
1441}
1442
1443static inline pmd_t pmd_mkwrite(pmd_t pmd)
1444{
1445 pmd_val(pmd) |= _SEGMENT_ENTRY_WRITE;
1446 if (pmd_large(pmd) && !(pmd_val(pmd) & _SEGMENT_ENTRY_DIRTY))
1447 return pmd;
1448 pmd_val(pmd) &= ~_SEGMENT_ENTRY_PROTECT;
1449 return pmd;
1450}
1451
1452static inline pmd_t pmd_mkclean(pmd_t pmd)
1453{
1454 if (pmd_large(pmd)) {
1455 pmd_val(pmd) &= ~_SEGMENT_ENTRY_DIRTY;
1456 pmd_val(pmd) |= _SEGMENT_ENTRY_PROTECT;
1457 }
1458 return pmd;
1459}
1460
1461static inline pmd_t pmd_mkdirty(pmd_t pmd)
1462{
1463 if (pmd_large(pmd)) {
1464 pmd_val(pmd) |= _SEGMENT_ENTRY_DIRTY;
1465 if (pmd_val(pmd) & _SEGMENT_ENTRY_WRITE)
1466 pmd_val(pmd) &= ~_SEGMENT_ENTRY_PROTECT;
1467 }
1468 return pmd;
1469}
1470
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001471static inline pmd_t pmd_mkyoung(pmd_t pmd)
1472{
Martin Schwidefsky152125b2014-07-24 11:03:41 +02001473 if (pmd_large(pmd)) {
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001474 pmd_val(pmd) |= _SEGMENT_ENTRY_YOUNG;
Martin Schwidefsky152125b2014-07-24 11:03:41 +02001475 if (pmd_val(pmd) & _SEGMENT_ENTRY_READ)
1476 pmd_val(pmd) &= ~_SEGMENT_ENTRY_INVALID;
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001477 }
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001478 return pmd;
1479}
1480
1481static inline pmd_t pmd_mkold(pmd_t pmd)
1482{
Martin Schwidefsky152125b2014-07-24 11:03:41 +02001483 if (pmd_large(pmd)) {
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001484 pmd_val(pmd) &= ~_SEGMENT_ENTRY_YOUNG;
1485 pmd_val(pmd) |= _SEGMENT_ENTRY_INVALID;
1486 }
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001487 return pmd;
1488}
1489
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001490static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
1491{
Martin Schwidefsky152125b2014-07-24 11:03:41 +02001492 if (pmd_large(pmd)) {
1493 pmd_val(pmd) &= _SEGMENT_ENTRY_ORIGIN_LARGE |
1494 _SEGMENT_ENTRY_DIRTY | _SEGMENT_ENTRY_YOUNG |
1495 _SEGMENT_ENTRY_LARGE | _SEGMENT_ENTRY_SPLIT;
1496 pmd_val(pmd) |= massage_pgprot_pmd(newprot);
1497 if (!(pmd_val(pmd) & _SEGMENT_ENTRY_DIRTY))
1498 pmd_val(pmd) |= _SEGMENT_ENTRY_PROTECT;
1499 if (!(pmd_val(pmd) & _SEGMENT_ENTRY_YOUNG))
1500 pmd_val(pmd) |= _SEGMENT_ENTRY_INVALID;
1501 return pmd;
1502 }
1503 pmd_val(pmd) &= _SEGMENT_ENTRY_ORIGIN;
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001504 pmd_val(pmd) |= massage_pgprot_pmd(newprot);
1505 return pmd;
1506}
1507
Gerald Schaefer106c9922013-04-29 15:07:23 -07001508static inline pmd_t mk_pmd_phys(unsigned long physpage, pgprot_t pgprot)
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001509{
Gerald Schaefer106c9922013-04-29 15:07:23 -07001510 pmd_t __pmd;
1511 pmd_val(__pmd) = physpage + massage_pgprot_pmd(pgprot);
Martin Schwidefsky152125b2014-07-24 11:03:41 +02001512 return __pmd;
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001513}
1514
Gerald Schaefer106c9922013-04-29 15:07:23 -07001515#endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLB_PAGE */
1516
Martin Schwidefsky1b948d62014-04-03 13:55:01 +02001517static inline void __pmdp_csp(pmd_t *pmdp)
1518{
1519 register unsigned long reg2 asm("2") = pmd_val(*pmdp);
1520 register unsigned long reg3 asm("3") = pmd_val(*pmdp) |
1521 _SEGMENT_ENTRY_INVALID;
1522 register unsigned long reg4 asm("4") = ((unsigned long) pmdp) + 5;
1523
1524 asm volatile(
1525 " csp %1,%3"
1526 : "=m" (*pmdp)
1527 : "d" (reg2), "d" (reg3), "d" (reg4), "m" (*pmdp) : "cc");
1528}
1529
1530static inline void __pmdp_idte(unsigned long address, pmd_t *pmdp)
1531{
1532 unsigned long sto;
1533
1534 sto = (unsigned long) pmdp - pmd_index(address) * sizeof(pmd_t);
1535 asm volatile(
1536 " .insn rrf,0xb98e0000,%2,%3,0,0"
1537 : "=m" (*pmdp)
1538 : "m" (*pmdp), "a" (sto), "a" ((address & HPAGE_MASK))
1539 : "cc" );
1540}
1541
1542static inline void __pmdp_idte_local(unsigned long address, pmd_t *pmdp)
1543{
1544 unsigned long sto;
1545
1546 sto = (unsigned long) pmdp - pmd_index(address) * sizeof(pmd_t);
1547 asm volatile(
1548 " .insn rrf,0xb98e0000,%2,%3,0,1"
1549 : "=m" (*pmdp)
1550 : "m" (*pmdp), "a" (sto), "a" ((address & HPAGE_MASK))
1551 : "cc" );
1552}
1553
1554static inline void pmdp_flush_direct(struct mm_struct *mm,
1555 unsigned long address, pmd_t *pmdp)
1556{
1557 int active, count;
1558
1559 if (pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID)
1560 return;
1561 if (!MACHINE_HAS_IDTE) {
1562 __pmdp_csp(pmdp);
1563 return;
1564 }
1565 active = (mm == current->active_mm) ? 1 : 0;
1566 count = atomic_add_return(0x10000, &mm->context.attach_count);
1567 if (MACHINE_HAS_TLB_LC && (count & 0xffff) <= active &&
1568 cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id())))
1569 __pmdp_idte_local(address, pmdp);
1570 else
1571 __pmdp_idte(address, pmdp);
1572 atomic_sub(0x10000, &mm->context.attach_count);
1573}
1574
Martin Schwidefsky3eabaee2013-07-26 15:04:02 +02001575static inline void pmdp_flush_lazy(struct mm_struct *mm,
1576 unsigned long address, pmd_t *pmdp)
1577{
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001578 int active, count;
Martin Schwidefsky3eabaee2013-07-26 15:04:02 +02001579
Martin Schwidefsky1b948d62014-04-03 13:55:01 +02001580 if (pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID)
1581 return;
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001582 active = (mm == current->active_mm) ? 1 : 0;
1583 count = atomic_add_return(0x10000, &mm->context.attach_count);
1584 if ((count & 0xffff) <= active) {
1585 pmd_val(*pmdp) |= _SEGMENT_ENTRY_INVALID;
Martin Schwidefsky3eabaee2013-07-26 15:04:02 +02001586 mm->context.flush_mm = 1;
Martin Schwidefsky1b948d62014-04-03 13:55:01 +02001587 } else if (MACHINE_HAS_IDTE)
1588 __pmdp_idte(address, pmdp);
1589 else
1590 __pmdp_csp(pmdp);
Martin Schwidefsky53e857f2012-09-10 13:00:09 +02001591 atomic_sub(0x10000, &mm->context.attach_count);
Martin Schwidefsky3eabaee2013-07-26 15:04:02 +02001592}
1593
Gerald Schaefer106c9922013-04-29 15:07:23 -07001594#ifdef CONFIG_TRANSPARENT_HUGEPAGE
1595
1596#define __HAVE_ARCH_PGTABLE_DEPOSIT
Aneesh Kumar K.V6b0b50b2013-06-05 17:14:02 -07001597extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
1598 pgtable_t pgtable);
Gerald Schaefer106c9922013-04-29 15:07:23 -07001599
1600#define __HAVE_ARCH_PGTABLE_WITHDRAW
Aneesh Kumar K.V6b0b50b2013-06-05 17:14:02 -07001601extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);
Gerald Schaefer106c9922013-04-29 15:07:23 -07001602
1603static inline int pmd_trans_splitting(pmd_t pmd)
1604{
Martin Schwidefsky152125b2014-07-24 11:03:41 +02001605 return (pmd_val(pmd) & _SEGMENT_ENTRY_LARGE) &&
1606 (pmd_val(pmd) & _SEGMENT_ENTRY_SPLIT);
Gerald Schaefer106c9922013-04-29 15:07:23 -07001607}
1608
1609static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
1610 pmd_t *pmdp, pmd_t entry)
1611{
Gerald Schaefer106c9922013-04-29 15:07:23 -07001612 *pmdp = entry;
1613}
1614
1615static inline pmd_t pmd_mkhuge(pmd_t pmd)
1616{
1617 pmd_val(pmd) |= _SEGMENT_ENTRY_LARGE;
Martin Schwidefsky152125b2014-07-24 11:03:41 +02001618 pmd_val(pmd) |= _SEGMENT_ENTRY_YOUNG;
1619 pmd_val(pmd) |= _SEGMENT_ENTRY_PROTECT;
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001620 return pmd;
1621}
1622
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001623#define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
1624static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
1625 unsigned long address, pmd_t *pmdp)
1626{
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001627 pmd_t pmd;
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001628
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001629 pmd = *pmdp;
Martin Schwidefsky1b948d62014-04-03 13:55:01 +02001630 pmdp_flush_direct(vma->vm_mm, address, pmdp);
Martin Schwidefsky0944fe32013-07-23 22:11:42 +02001631 *pmdp = pmd_mkold(pmd);
1632 return pmd_young(pmd);
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001633}
1634
1635#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
1636static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
1637 unsigned long address, pmd_t *pmdp)
1638{
1639 pmd_t pmd = *pmdp;
1640
Martin Schwidefsky1b948d62014-04-03 13:55:01 +02001641 pmdp_flush_direct(mm, address, pmdp);
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001642 pmd_clear(pmdp);
1643 return pmd;
1644}
1645
1646#define __HAVE_ARCH_PMDP_CLEAR_FLUSH
1647static inline pmd_t pmdp_clear_flush(struct vm_area_struct *vma,
1648 unsigned long address, pmd_t *pmdp)
1649{
1650 return pmdp_get_and_clear(vma->vm_mm, address, pmdp);
1651}
1652
1653#define __HAVE_ARCH_PMDP_INVALIDATE
1654static inline void pmdp_invalidate(struct vm_area_struct *vma,
1655 unsigned long address, pmd_t *pmdp)
1656{
Martin Schwidefsky1b948d62014-04-03 13:55:01 +02001657 pmdp_flush_direct(vma->vm_mm, address, pmdp);
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001658}
1659
Gerald Schaeferbe328652013-01-21 16:48:07 +01001660#define __HAVE_ARCH_PMDP_SET_WRPROTECT
1661static inline void pmdp_set_wrprotect(struct mm_struct *mm,
1662 unsigned long address, pmd_t *pmdp)
1663{
1664 pmd_t pmd = *pmdp;
1665
1666 if (pmd_write(pmd)) {
Martin Schwidefsky1b948d62014-04-03 13:55:01 +02001667 pmdp_flush_direct(mm, address, pmdp);
Gerald Schaeferbe328652013-01-21 16:48:07 +01001668 set_pmd_at(mm, address, pmdp, pmd_wrprotect(pmd));
1669 }
1670}
1671
Gerald Schaefer1ae1c1d2012-10-08 16:30:24 -07001672#define pfn_pmd(pfn, pgprot) mk_pmd_phys(__pa((pfn) << PAGE_SHIFT), (pgprot))
1673#define mk_pmd(page, pgprot) pfn_pmd(page_to_pfn(page), (pgprot))
1674
1675static inline int pmd_trans_huge(pmd_t pmd)
1676{
1677 return pmd_val(pmd) & _SEGMENT_ENTRY_LARGE;
1678}
1679
1680static inline int has_transparent_hugepage(void)
1681{
1682 return MACHINE_HAS_HPAGE ? 1 : 0;
1683}
Gerald Schaefer75077af2012-10-08 16:30:15 -07001684#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
1685
Linus Torvalds1da177e2005-04-16 15:20:36 -07001686/*
1687 * 31 bit swap entry format:
1688 * A page-table entry has some bits we have to treat in a special way.
1689 * Bits 0, 20 and bit 23 have to be zero, otherwise an specification
1690 * exception will occur instead of a page translation exception. The
1691 * specifiation exception has the bad habit not to store necessary
1692 * information in the lowcore.
Martin Schwidefskye5098612013-07-23 20:57:57 +02001693 * Bits 21, 22, 30 and 31 are used to indicate the page type.
1694 * A swap pte is indicated by bit pattern (pte & 0x603) == 0x402
Linus Torvalds1da177e2005-04-16 15:20:36 -07001695 * This leaves the bits 1-19 and bits 24-29 to store type and offset.
1696 * We use the 5 bits from 25-29 for the type and the 20 bits from 1-19
1697 * plus 24 for the offset.
1698 * 0| offset |0110|o|type |00|
1699 * 0 0000000001111111111 2222 2 22222 33
1700 * 0 1234567890123456789 0123 4 56789 01
1701 *
1702 * 64 bit swap entry format:
1703 * A page-table entry has some bits we have to treat in a special way.
1704 * Bits 52 and bit 55 have to be zero, otherwise an specification
1705 * exception will occur instead of a page translation exception. The
1706 * specifiation exception has the bad habit not to store necessary
1707 * information in the lowcore.
Martin Schwidefskye5098612013-07-23 20:57:57 +02001708 * Bits 53, 54, 62 and 63 are used to indicate the page type.
1709 * A swap pte is indicated by bit pattern (pte & 0x603) == 0x402
Linus Torvalds1da177e2005-04-16 15:20:36 -07001710 * This leaves the bits 0-51 and bits 56-61 to store type and offset.
1711 * We use the 5 bits from 57-61 for the type and the 53 bits from 0-51
1712 * plus 56 for the offset.
1713 * | offset |0110|o|type |00|
1714 * 0000000000111111111122222222223333333333444444444455 5555 5 55566 66
1715 * 0123456789012345678901234567890123456789012345678901 2345 6 78901 23
1716 */
Heiko Carstensf4815ac2012-05-23 16:24:51 +02001717#ifndef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718#define __SWP_OFFSET_MASK (~0UL >> 12)
1719#else
1720#define __SWP_OFFSET_MASK (~0UL >> 11)
1721#endif
Adrian Bunk4448aaf2005-11-08 21:34:42 -08001722static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001723{
1724 pte_t pte;
1725 offset &= __SWP_OFFSET_MASK;
Martin Schwidefskye5098612013-07-23 20:57:57 +02001726 pte_val(pte) = _PAGE_INVALID | _PAGE_TYPE | ((type & 0x1f) << 2) |
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727 ((offset & 1UL) << 7) | ((offset & ~1UL) << 11);
1728 return pte;
1729}
1730
1731#define __swp_type(entry) (((entry).val >> 2) & 0x1f)
1732#define __swp_offset(entry) (((entry).val >> 11) | (((entry).val >> 7) & 1))
1733#define __swp_entry(type,offset) ((swp_entry_t) { pte_val(mk_swap_pte((type),(offset))) })
1734
1735#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
1736#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
1737
Heiko Carstensf4815ac2012-05-23 16:24:51 +02001738#ifndef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001739# define PTE_FILE_MAX_BITS 26
Heiko Carstensf4815ac2012-05-23 16:24:51 +02001740#else /* CONFIG_64BIT */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741# define PTE_FILE_MAX_BITS 59
Heiko Carstensf4815ac2012-05-23 16:24:51 +02001742#endif /* CONFIG_64BIT */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743
1744#define pte_to_pgoff(__pte) \
1745 ((((__pte).pte >> 12) << 7) + (((__pte).pte >> 1) & 0x7f))
1746
1747#define pgoff_to_pte(__off) \
1748 ((pte_t) { ((((__off) & 0x7f) << 1) + (((__off) >> 7) << 12)) \
Martin Schwidefskye5098612013-07-23 20:57:57 +02001749 | _PAGE_INVALID | _PAGE_PROTECT })
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750
1751#endif /* !__ASSEMBLY__ */
1752
1753#define kern_addr_valid(addr) (1)
1754
Heiko Carstens17f34582008-04-30 13:38:47 +02001755extern int vmem_add_mapping(unsigned long start, unsigned long size);
1756extern int vmem_remove_mapping(unsigned long start, unsigned long size);
Carsten Otte402b0862008-03-25 18:47:10 +01001757extern int s390_enable_sie(void);
Dominik Dingel934bc132014-01-14 18:10:17 +01001758extern void s390_enable_skey(void);
Heiko Carstensf4eb07c2006-12-08 15:56:07 +01001759
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760/*
1761 * No page table caches to initialise
1762 */
Heiko Carstens765a0ca2013-03-23 10:29:01 +01001763static inline void pgtable_cache_init(void) { }
1764static inline void check_pgt_cache(void) { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001765
Linus Torvalds1da177e2005-04-16 15:20:36 -07001766#include <asm-generic/pgtable.h>
1767
1768#endif /* _S390_PAGE_H */