pgtable.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596
  1. /*
  2. * S390 version
  3. * Copyright IBM Corp. 1999, 2000
  4. * 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. #ifndef _ASM_S390_PGTABLE_H
  11. #define _ASM_S390_PGTABLE_H
  12. /*
  13. * The Linux memory management assumes a three-level page table setup. For
  14. * s390 31 bit we "fold" the mid level into the top-level page table, so
  15. * that we physically have the same two-level page table as the s390 mmu
  16. * expects in 31 bit mode. For s390 64 bit we use three of the five levels
  17. * the hardware provides (region first and region second tables are not
  18. * used).
  19. *
  20. * The "pgd_xxx()" functions are trivial for a folded two-level
  21. * setup: the pgd is never bad, and a pmd always exists (as it's folded
  22. * into the pgd entry)
  23. *
  24. * This file contains the functions and defines necessary to modify and use
  25. * the S390 page table tree.
  26. */
  27. #ifndef __ASSEMBLY__
  28. #include <linux/sched.h>
  29. #include <linux/mm_types.h>
  30. #include <linux/page-flags.h>
  31. #include <asm/bug.h>
  32. #include <asm/page.h>
  33. extern pgd_t swapper_pg_dir[] __attribute__ ((aligned (4096)));
  34. extern void paging_init(void);
  35. extern void vmem_map_init(void);
  36. /*
  37. * The S390 doesn't have any external MMU info: the kernel page
  38. * tables contain all the necessary information.
  39. */
  40. #define update_mmu_cache(vma, address, ptep) do { } while (0)
  41. #define update_mmu_cache_pmd(vma, address, ptep) do { } while (0)
  42. /*
  43. * ZERO_PAGE is a global shared page that is always zero; used
  44. * for zero-mapped memory areas etc..
  45. */
  46. extern unsigned long empty_zero_page;
  47. extern unsigned long zero_page_mask;
  48. #define ZERO_PAGE(vaddr) \
  49. (virt_to_page((void *)(empty_zero_page + \
  50. (((unsigned long)(vaddr)) &zero_page_mask))))
  51. #define __HAVE_COLOR_ZERO_PAGE
  52. /* TODO: s390 cannot support io_remap_pfn_range... */
  53. #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
  54. remap_pfn_range(vma, vaddr, pfn, size, prot)
  55. #endif /* !__ASSEMBLY__ */
  56. /*
  57. * PMD_SHIFT determines the size of the area a second-level page
  58. * table can map
  59. * PGDIR_SHIFT determines what a third-level page table entry can map
  60. */
  61. #ifndef CONFIG_64BIT
  62. # define PMD_SHIFT 20
  63. # define PUD_SHIFT 20
  64. # define PGDIR_SHIFT 20
  65. #else /* CONFIG_64BIT */
  66. # define PMD_SHIFT 20
  67. # define PUD_SHIFT 31
  68. # define PGDIR_SHIFT 42
  69. #endif /* CONFIG_64BIT */
  70. #define PMD_SIZE (1UL << PMD_SHIFT)
  71. #define PMD_MASK (~(PMD_SIZE-1))
  72. #define PUD_SIZE (1UL << PUD_SHIFT)
  73. #define PUD_MASK (~(PUD_SIZE-1))
  74. #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
  75. #define PGDIR_MASK (~(PGDIR_SIZE-1))
  76. /*
  77. * entries per page directory level: the S390 is two-level, so
  78. * we don't really have any PMD directory physically.
  79. * for S390 segment-table entries are combined to one PGD
  80. * that leads to 1024 pte per pgd
  81. */
  82. #define PTRS_PER_PTE 256
  83. #ifndef CONFIG_64BIT
  84. #define PTRS_PER_PMD 1
  85. #define PTRS_PER_PUD 1
  86. #else /* CONFIG_64BIT */
  87. #define PTRS_PER_PMD 2048
  88. #define PTRS_PER_PUD 2048
  89. #endif /* CONFIG_64BIT */
  90. #define PTRS_PER_PGD 2048
  91. #define FIRST_USER_ADDRESS 0
  92. #define pte_ERROR(e) \
  93. printk("%s:%d: bad pte %p.\n", __FILE__, __LINE__, (void *) pte_val(e))
  94. #define pmd_ERROR(e) \
  95. printk("%s:%d: bad pmd %p.\n", __FILE__, __LINE__, (void *) pmd_val(e))
  96. #define pud_ERROR(e) \
  97. printk("%s:%d: bad pud %p.\n", __FILE__, __LINE__, (void *) pud_val(e))
  98. #define pgd_ERROR(e) \
  99. printk("%s:%d: bad pgd %p.\n", __FILE__, __LINE__, (void *) pgd_val(e))
  100. #ifndef __ASSEMBLY__
  101. /*
  102. * The vmalloc and module area will always be on the topmost area of the kernel
  103. * mapping. We reserve 96MB (31bit) / 128GB (64bit) for vmalloc and modules.
  104. * On 64 bit kernels we have a 2GB area at the top of the vmalloc area where
  105. * modules will reside. That makes sure that inter module branches always
  106. * happen without trampolines and in addition the placement within a 2GB frame
  107. * is branch prediction unit friendly.
  108. */
  109. extern unsigned long VMALLOC_START;
  110. extern unsigned long VMALLOC_END;
  111. extern struct page *vmemmap;
  112. #define VMEM_MAX_PHYS ((unsigned long) vmemmap)
  113. #ifdef CONFIG_64BIT
  114. extern unsigned long MODULES_VADDR;
  115. extern unsigned long MODULES_END;
  116. #define MODULES_VADDR MODULES_VADDR
  117. #define MODULES_END MODULES_END
  118. #define MODULES_LEN (1UL << 31)
  119. #endif
  120. /*
  121. * A 31 bit pagetable entry of S390 has following format:
  122. * | PFRA | | OS |
  123. * 0 0IP0
  124. * 00000000001111111111222222222233
  125. * 01234567890123456789012345678901
  126. *
  127. * I Page-Invalid Bit: Page is not available for address-translation
  128. * P Page-Protection Bit: Store access not possible for page
  129. *
  130. * A 31 bit segmenttable entry of S390 has following format:
  131. * | P-table origin | |PTL
  132. * 0 IC
  133. * 00000000001111111111222222222233
  134. * 01234567890123456789012345678901
  135. *
  136. * I Segment-Invalid Bit: Segment is not available for address-translation
  137. * C Common-Segment Bit: Segment is not private (PoP 3-30)
  138. * PTL Page-Table-Length: Page-table length (PTL+1*16 entries -> up to 256)
  139. *
  140. * The 31 bit segmenttable origin of S390 has following format:
  141. *
  142. * |S-table origin | | STL |
  143. * X **GPS
  144. * 00000000001111111111222222222233
  145. * 01234567890123456789012345678901
  146. *
  147. * X Space-Switch event:
  148. * G Segment-Invalid Bit: *
  149. * P Private-Space Bit: Segment is not private (PoP 3-30)
  150. * S Storage-Alteration:
  151. * STL Segment-Table-Length: Segment-table length (STL+1*16 entries -> up to 2048)
  152. *
  153. * A 64 bit pagetable entry of S390 has following format:
  154. * | PFRA |0IPC| OS |
  155. * 0000000000111111111122222222223333333333444444444455555555556666
  156. * 0123456789012345678901234567890123456789012345678901234567890123
  157. *
  158. * I Page-Invalid Bit: Page is not available for address-translation
  159. * P Page-Protection Bit: Store access not possible for page
  160. * C Change-bit override: HW is not required to set change bit
  161. *
  162. * A 64 bit segmenttable entry of S390 has following format:
  163. * | P-table origin | TT
  164. * 0000000000111111111122222222223333333333444444444455555555556666
  165. * 0123456789012345678901234567890123456789012345678901234567890123
  166. *
  167. * I Segment-Invalid Bit: Segment is not available for address-translation
  168. * C Common-Segment Bit: Segment is not private (PoP 3-30)
  169. * P Page-Protection Bit: Store access not possible for page
  170. * TT Type 00
  171. *
  172. * A 64 bit region table entry of S390 has following format:
  173. * | S-table origin | TF TTTL
  174. * 0000000000111111111122222222223333333333444444444455555555556666
  175. * 0123456789012345678901234567890123456789012345678901234567890123
  176. *
  177. * I Segment-Invalid Bit: Segment is not available for address-translation
  178. * TT Type 01
  179. * TF
  180. * TL Table length
  181. *
  182. * The 64 bit regiontable origin of S390 has following format:
  183. * | region table origon | DTTL
  184. * 0000000000111111111122222222223333333333444444444455555555556666
  185. * 0123456789012345678901234567890123456789012345678901234567890123
  186. *
  187. * X Space-Switch event:
  188. * G Segment-Invalid Bit:
  189. * P Private-Space Bit:
  190. * S Storage-Alteration:
  191. * R Real space
  192. * TL Table-Length:
  193. *
  194. * A storage key has the following format:
  195. * | ACC |F|R|C|0|
  196. * 0 3 4 5 6 7
  197. * ACC: access key
  198. * F : fetch protection bit
  199. * R : referenced bit
  200. * C : changed bit
  201. */
  202. /* Hardware bits in the page table entry */
  203. #define _PAGE_CO 0x100 /* HW Change-bit override */
  204. #define _PAGE_RO 0x200 /* HW read-only bit */
  205. #define _PAGE_INVALID 0x400 /* HW invalid bit */
  206. /* Software bits in the page table entry */
  207. #define _PAGE_SWT 0x001 /* SW pte type bit t */
  208. #define _PAGE_SWX 0x002 /* SW pte type bit x */
  209. #define _PAGE_SWC 0x004 /* SW pte changed bit */
  210. #define _PAGE_SWR 0x008 /* SW pte referenced bit */
  211. #define _PAGE_SWW 0x010 /* SW pte write bit */
  212. #define _PAGE_SPECIAL 0x020 /* SW associated with special page */
  213. #define __HAVE_ARCH_PTE_SPECIAL
  214. /* Set of bits not changed in pte_modify */
  215. #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_SPECIAL | _PAGE_CO | \
  216. _PAGE_SWC | _PAGE_SWR)
  217. /* Six different types of pages. */
  218. #define _PAGE_TYPE_EMPTY 0x400
  219. #define _PAGE_TYPE_NONE 0x401
  220. #define _PAGE_TYPE_SWAP 0x403
  221. #define _PAGE_TYPE_FILE 0x601 /* bit 0x002 is used for offset !! */
  222. #define _PAGE_TYPE_RO 0x200
  223. #define _PAGE_TYPE_RW 0x000
  224. /*
  225. * Only four types for huge pages, using the invalid bit and protection bit
  226. * of a segment table entry.
  227. */
  228. #define _HPAGE_TYPE_EMPTY 0x020 /* _SEGMENT_ENTRY_INV */
  229. #define _HPAGE_TYPE_NONE 0x220
  230. #define _HPAGE_TYPE_RO 0x200 /* _SEGMENT_ENTRY_RO */
  231. #define _HPAGE_TYPE_RW 0x000
  232. /*
  233. * PTE type bits are rather complicated. handle_pte_fault uses pte_present,
  234. * pte_none and pte_file to find out the pte type WITHOUT holding the page
  235. * table lock. ptep_clear_flush on the other hand uses ptep_clear_flush to
  236. * invalidate a given pte. ipte sets the hw invalid bit and clears all tlbs
  237. * for the page. The page table entry is set to _PAGE_TYPE_EMPTY afterwards.
  238. * This change is done while holding the lock, but the intermediate step
  239. * of a previously valid pte with the hw invalid bit set can be observed by
  240. * handle_pte_fault. That makes it necessary that all valid pte types with
  241. * the hw invalid bit set must be distinguishable from the four pte types
  242. * empty, none, swap and file.
  243. *
  244. * irxt ipte irxt
  245. * _PAGE_TYPE_EMPTY 1000 -> 1000
  246. * _PAGE_TYPE_NONE 1001 -> 1001
  247. * _PAGE_TYPE_SWAP 1011 -> 1011
  248. * _PAGE_TYPE_FILE 11?1 -> 11?1
  249. * _PAGE_TYPE_RO 0100 -> 1100
  250. * _PAGE_TYPE_RW 0000 -> 1000
  251. *
  252. * pte_none is true for bits combinations 1000, 1010, 1100, 1110
  253. * pte_present is true for bits combinations 0000, 0010, 0100, 0110, 1001
  254. * pte_file is true for bits combinations 1101, 1111
  255. * swap pte is 1011 and 0001, 0011, 0101, 0111 are invalid.
  256. */
  257. #ifndef CONFIG_64BIT
  258. /* Bits in the segment table address-space-control-element */
  259. #define _ASCE_SPACE_SWITCH 0x80000000UL /* space switch event */
  260. #define _ASCE_ORIGIN_MASK 0x7ffff000UL /* segment table origin */
  261. #define _ASCE_PRIVATE_SPACE 0x100 /* private space control */
  262. #define _ASCE_ALT_EVENT 0x80 /* storage alteration event control */
  263. #define _ASCE_TABLE_LENGTH 0x7f /* 128 x 64 entries = 8k */
  264. /* Bits in the segment table entry */
  265. #define _SEGMENT_ENTRY_ORIGIN 0x7fffffc0UL /* page table origin */
  266. #define _SEGMENT_ENTRY_RO 0x200 /* page protection bit */
  267. #define _SEGMENT_ENTRY_INV 0x20 /* invalid segment table entry */
  268. #define _SEGMENT_ENTRY_COMMON 0x10 /* common segment bit */
  269. #define _SEGMENT_ENTRY_PTL 0x0f /* page table length */
  270. #define _SEGMENT_ENTRY (_SEGMENT_ENTRY_PTL)
  271. #define _SEGMENT_ENTRY_EMPTY (_SEGMENT_ENTRY_INV)
  272. /* Page status table bits for virtualization */
  273. #define RCP_ACC_BITS 0xf0000000UL
  274. #define RCP_FP_BIT 0x08000000UL
  275. #define RCP_PCL_BIT 0x00800000UL
  276. #define RCP_HR_BIT 0x00400000UL
  277. #define RCP_HC_BIT 0x00200000UL
  278. #define RCP_GR_BIT 0x00040000UL
  279. #define RCP_GC_BIT 0x00020000UL
  280. #define RCP_IN_BIT 0x00002000UL /* IPTE notify bit */
  281. /* User dirty / referenced bit for KVM's migration feature */
  282. #define KVM_UR_BIT 0x00008000UL
  283. #define KVM_UC_BIT 0x00004000UL
  284. #else /* CONFIG_64BIT */
  285. /* Bits in the segment/region table address-space-control-element */
  286. #define _ASCE_ORIGIN ~0xfffUL/* segment table origin */
  287. #define _ASCE_PRIVATE_SPACE 0x100 /* private space control */
  288. #define _ASCE_ALT_EVENT 0x80 /* storage alteration event control */
  289. #define _ASCE_SPACE_SWITCH 0x40 /* space switch event */
  290. #define _ASCE_REAL_SPACE 0x20 /* real space control */
  291. #define _ASCE_TYPE_MASK 0x0c /* asce table type mask */
  292. #define _ASCE_TYPE_REGION1 0x0c /* region first table type */
  293. #define _ASCE_TYPE_REGION2 0x08 /* region second table type */
  294. #define _ASCE_TYPE_REGION3 0x04 /* region third table type */
  295. #define _ASCE_TYPE_SEGMENT 0x00 /* segment table type */
  296. #define _ASCE_TABLE_LENGTH 0x03 /* region table length */
  297. /* Bits in the region table entry */
  298. #define _REGION_ENTRY_ORIGIN ~0xfffUL/* region/segment table origin */
  299. #define _REGION_ENTRY_RO 0x200 /* region protection bit */
  300. #define _REGION_ENTRY_INV 0x20 /* invalid region table entry */
  301. #define _REGION_ENTRY_TYPE_MASK 0x0c /* region/segment table type mask */
  302. #define _REGION_ENTRY_TYPE_R1 0x0c /* region first table type */
  303. #define _REGION_ENTRY_TYPE_R2 0x08 /* region second table type */
  304. #define _REGION_ENTRY_TYPE_R3 0x04 /* region third table type */
  305. #define _REGION_ENTRY_LENGTH 0x03 /* region third length */
  306. #define _REGION1_ENTRY (_REGION_ENTRY_TYPE_R1 | _REGION_ENTRY_LENGTH)
  307. #define _REGION1_ENTRY_EMPTY (_REGION_ENTRY_TYPE_R1 | _REGION_ENTRY_INV)
  308. #define _REGION2_ENTRY (_REGION_ENTRY_TYPE_R2 | _REGION_ENTRY_LENGTH)
  309. #define _REGION2_ENTRY_EMPTY (_REGION_ENTRY_TYPE_R2 | _REGION_ENTRY_INV)
  310. #define _REGION3_ENTRY (_REGION_ENTRY_TYPE_R3 | _REGION_ENTRY_LENGTH)
  311. #define _REGION3_ENTRY_EMPTY (_REGION_ENTRY_TYPE_R3 | _REGION_ENTRY_INV)
  312. #define _REGION3_ENTRY_LARGE 0x400 /* RTTE-format control, large page */
  313. #define _REGION3_ENTRY_RO 0x200 /* page protection bit */
  314. #define _REGION3_ENTRY_CO 0x100 /* change-recording override */
  315. /* Bits in the segment table entry */
  316. #define _SEGMENT_ENTRY_ORIGIN_LARGE ~0xfffffUL /* large page address */
  317. #define _SEGMENT_ENTRY_ORIGIN ~0x7ffUL/* segment table origin */
  318. #define _SEGMENT_ENTRY_RO 0x200 /* page protection bit */
  319. #define _SEGMENT_ENTRY_INV 0x20 /* invalid segment table entry */
  320. #define _SEGMENT_ENTRY (0)
  321. #define _SEGMENT_ENTRY_EMPTY (_SEGMENT_ENTRY_INV)
  322. #define _SEGMENT_ENTRY_LARGE 0x400 /* STE-format control, large page */
  323. #define _SEGMENT_ENTRY_CO 0x100 /* change-recording override */
  324. #define _SEGMENT_ENTRY_SPLIT_BIT 0 /* THP splitting bit number */
  325. #define _SEGMENT_ENTRY_SPLIT (1UL << _SEGMENT_ENTRY_SPLIT_BIT)
  326. /* Set of bits not changed in pmd_modify */
  327. #define _SEGMENT_CHG_MASK (_SEGMENT_ENTRY_ORIGIN | _SEGMENT_ENTRY_LARGE \
  328. | _SEGMENT_ENTRY_SPLIT | _SEGMENT_ENTRY_CO)
  329. /* Page status table bits for virtualization */
  330. #define RCP_ACC_BITS 0xf000000000000000UL
  331. #define RCP_FP_BIT 0x0800000000000000UL
  332. #define RCP_PCL_BIT 0x0080000000000000UL
  333. #define RCP_HR_BIT 0x0040000000000000UL
  334. #define RCP_HC_BIT 0x0020000000000000UL
  335. #define RCP_GR_BIT 0x0004000000000000UL
  336. #define RCP_GC_BIT 0x0002000000000000UL
  337. #define RCP_IN_BIT 0x0000200000000000UL /* IPTE notify bit */
  338. /* User dirty / referenced bit for KVM's migration feature */
  339. #define KVM_UR_BIT 0x0000800000000000UL
  340. #define KVM_UC_BIT 0x0000400000000000UL
  341. #endif /* CONFIG_64BIT */
  342. /*
  343. * A user page table pointer has the space-switch-event bit, the
  344. * private-space-control bit and the storage-alteration-event-control
  345. * bit set. A kernel page table pointer doesn't need them.
  346. */
  347. #define _ASCE_USER_BITS (_ASCE_SPACE_SWITCH | _ASCE_PRIVATE_SPACE | \
  348. _ASCE_ALT_EVENT)
  349. /*
  350. * Page protection definitions.
  351. */
  352. #define PAGE_NONE __pgprot(_PAGE_TYPE_NONE)
  353. #define PAGE_RO __pgprot(_PAGE_TYPE_RO)
  354. #define PAGE_RW __pgprot(_PAGE_TYPE_RO | _PAGE_SWW)
  355. #define PAGE_RWC __pgprot(_PAGE_TYPE_RW | _PAGE_SWW | _PAGE_SWC)
  356. #define PAGE_KERNEL PAGE_RWC
  357. #define PAGE_SHARED PAGE_KERNEL
  358. #define PAGE_COPY PAGE_RO
  359. /*
  360. * On s390 the page table entry has an invalid bit and a read-only bit.
  361. * Read permission implies execute permission and write permission
  362. * implies read permission.
  363. */
  364. /*xwr*/
  365. #define __P000 PAGE_NONE
  366. #define __P001 PAGE_RO
  367. #define __P010 PAGE_RO
  368. #define __P011 PAGE_RO
  369. #define __P100 PAGE_RO
  370. #define __P101 PAGE_RO
  371. #define __P110 PAGE_RO
  372. #define __P111 PAGE_RO
  373. #define __S000 PAGE_NONE
  374. #define __S001 PAGE_RO
  375. #define __S010 PAGE_RW
  376. #define __S011 PAGE_RW
  377. #define __S100 PAGE_RO
  378. #define __S101 PAGE_RO
  379. #define __S110 PAGE_RW
  380. #define __S111 PAGE_RW
  381. /*
  382. * Segment entry (large page) protection definitions.
  383. */
  384. #define SEGMENT_NONE __pgprot(_HPAGE_TYPE_NONE)
  385. #define SEGMENT_RO __pgprot(_HPAGE_TYPE_RO)
  386. #define SEGMENT_RW __pgprot(_HPAGE_TYPE_RW)
  387. static inline int mm_exclusive(struct mm_struct *mm)
  388. {
  389. return likely(mm == current->active_mm &&
  390. atomic_read(&mm->context.attach_count) <= 1);
  391. }
  392. static inline int mm_has_pgste(struct mm_struct *mm)
  393. {
  394. #ifdef CONFIG_PGSTE
  395. if (unlikely(mm->context.has_pgste))
  396. return 1;
  397. #endif
  398. return 0;
  399. }
  400. /*
  401. * pgd/pmd/pte query functions
  402. */
  403. #ifndef CONFIG_64BIT
  404. static inline int pgd_present(pgd_t pgd) { return 1; }
  405. static inline int pgd_none(pgd_t pgd) { return 0; }
  406. static inline int pgd_bad(pgd_t pgd) { return 0; }
  407. static inline int pud_present(pud_t pud) { return 1; }
  408. static inline int pud_none(pud_t pud) { return 0; }
  409. static inline int pud_large(pud_t pud) { return 0; }
  410. static inline int pud_bad(pud_t pud) { return 0; }
  411. #else /* CONFIG_64BIT */
  412. static inline int pgd_present(pgd_t pgd)
  413. {
  414. if ((pgd_val(pgd) & _REGION_ENTRY_TYPE_MASK) < _REGION_ENTRY_TYPE_R2)
  415. return 1;
  416. return (pgd_val(pgd) & _REGION_ENTRY_ORIGIN) != 0UL;
  417. }
  418. static inline int pgd_none(pgd_t pgd)
  419. {
  420. if ((pgd_val(pgd) & _REGION_ENTRY_TYPE_MASK) < _REGION_ENTRY_TYPE_R2)
  421. return 0;
  422. return (pgd_val(pgd) & _REGION_ENTRY_INV) != 0UL;
  423. }
  424. static inline int pgd_bad(pgd_t pgd)
  425. {
  426. /*
  427. * With dynamic page table levels the pgd can be a region table
  428. * entry or a segment table entry. Check for the bit that are
  429. * invalid for either table entry.
  430. */
  431. unsigned long mask =
  432. ~_SEGMENT_ENTRY_ORIGIN & ~_REGION_ENTRY_INV &
  433. ~_REGION_ENTRY_TYPE_MASK & ~_REGION_ENTRY_LENGTH;
  434. return (pgd_val(pgd) & mask) != 0;
  435. }
  436. static inline int pud_present(pud_t pud)
  437. {
  438. if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) < _REGION_ENTRY_TYPE_R3)
  439. return 1;
  440. return (pud_val(pud) & _REGION_ENTRY_ORIGIN) != 0UL;
  441. }
  442. static inline int pud_none(pud_t pud)
  443. {
  444. if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) < _REGION_ENTRY_TYPE_R3)
  445. return 0;
  446. return (pud_val(pud) & _REGION_ENTRY_INV) != 0UL;
  447. }
  448. static inline int pud_large(pud_t pud)
  449. {
  450. if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) != _REGION_ENTRY_TYPE_R3)
  451. return 0;
  452. return !!(pud_val(pud) & _REGION3_ENTRY_LARGE);
  453. }
  454. static inline int pud_bad(pud_t pud)
  455. {
  456. /*
  457. * With dynamic page table levels the pud can be a region table
  458. * entry or a segment table entry. Check for the bit that are
  459. * invalid for either table entry.
  460. */
  461. unsigned long mask =
  462. ~_SEGMENT_ENTRY_ORIGIN & ~_REGION_ENTRY_INV &
  463. ~_REGION_ENTRY_TYPE_MASK & ~_REGION_ENTRY_LENGTH;
  464. return (pud_val(pud) & mask) != 0;
  465. }
  466. #endif /* CONFIG_64BIT */
  467. static inline int pmd_present(pmd_t pmd)
  468. {
  469. unsigned long mask = _SEGMENT_ENTRY_INV | _SEGMENT_ENTRY_RO;
  470. return (pmd_val(pmd) & mask) == _HPAGE_TYPE_NONE ||
  471. !(pmd_val(pmd) & _SEGMENT_ENTRY_INV);
  472. }
  473. static inline int pmd_none(pmd_t pmd)
  474. {
  475. return (pmd_val(pmd) & _SEGMENT_ENTRY_INV) &&
  476. !(pmd_val(pmd) & _SEGMENT_ENTRY_RO);
  477. }
  478. static inline int pmd_large(pmd_t pmd)
  479. {
  480. #ifdef CONFIG_64BIT
  481. return !!(pmd_val(pmd) & _SEGMENT_ENTRY_LARGE);
  482. #else
  483. return 0;
  484. #endif
  485. }
  486. static inline int pmd_bad(pmd_t pmd)
  487. {
  488. unsigned long mask = ~_SEGMENT_ENTRY_ORIGIN & ~_SEGMENT_ENTRY_INV;
  489. return (pmd_val(pmd) & mask) != _SEGMENT_ENTRY;
  490. }
  491. #define __HAVE_ARCH_PMDP_SPLITTING_FLUSH
  492. extern void pmdp_splitting_flush(struct vm_area_struct *vma,
  493. unsigned long addr, pmd_t *pmdp);
  494. #define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
  495. extern int pmdp_set_access_flags(struct vm_area_struct *vma,
  496. unsigned long address, pmd_t *pmdp,
  497. pmd_t entry, int dirty);
  498. #define __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH
  499. extern int pmdp_clear_flush_young(struct vm_area_struct *vma,
  500. unsigned long address, pmd_t *pmdp);
  501. #define __HAVE_ARCH_PMD_WRITE
  502. static inline int pmd_write(pmd_t pmd)
  503. {
  504. return (pmd_val(pmd) & _SEGMENT_ENTRY_RO) == 0;
  505. }
  506. static inline int pmd_young(pmd_t pmd)
  507. {
  508. return 0;
  509. }
  510. static inline int pte_none(pte_t pte)
  511. {
  512. return (pte_val(pte) & _PAGE_INVALID) && !(pte_val(pte) & _PAGE_SWT);
  513. }
  514. static inline int pte_present(pte_t pte)
  515. {
  516. unsigned long mask = _PAGE_RO | _PAGE_INVALID | _PAGE_SWT | _PAGE_SWX;
  517. return (pte_val(pte) & mask) == _PAGE_TYPE_NONE ||
  518. (!(pte_val(pte) & _PAGE_INVALID) &&
  519. !(pte_val(pte) & _PAGE_SWT));
  520. }
  521. static inline int pte_file(pte_t pte)
  522. {
  523. unsigned long mask = _PAGE_RO | _PAGE_INVALID | _PAGE_SWT;
  524. return (pte_val(pte) & mask) == _PAGE_TYPE_FILE;
  525. }
  526. static inline int pte_special(pte_t pte)
  527. {
  528. return (pte_val(pte) & _PAGE_SPECIAL);
  529. }
  530. #define __HAVE_ARCH_PTE_SAME
  531. static inline int pte_same(pte_t a, pte_t b)
  532. {
  533. return pte_val(a) == pte_val(b);
  534. }
  535. static inline pgste_t pgste_get_lock(pte_t *ptep)
  536. {
  537. unsigned long new = 0;
  538. #ifdef CONFIG_PGSTE
  539. unsigned long old;
  540. preempt_disable();
  541. asm(
  542. " lg %0,%2\n"
  543. "0: lgr %1,%0\n"
  544. " nihh %0,0xff7f\n" /* clear RCP_PCL_BIT in old */
  545. " oihh %1,0x0080\n" /* set RCP_PCL_BIT in new */
  546. " csg %0,%1,%2\n"
  547. " jl 0b\n"
  548. : "=&d" (old), "=&d" (new), "=Q" (ptep[PTRS_PER_PTE])
  549. : "Q" (ptep[PTRS_PER_PTE]) : "cc", "memory");
  550. #endif
  551. return __pgste(new);
  552. }
  553. static inline void pgste_set_unlock(pte_t *ptep, pgste_t pgste)
  554. {
  555. #ifdef CONFIG_PGSTE
  556. asm(
  557. " nihh %1,0xff7f\n" /* clear RCP_PCL_BIT */
  558. " stg %1,%0\n"
  559. : "=Q" (ptep[PTRS_PER_PTE])
  560. : "d" (pgste_val(pgste)), "Q" (ptep[PTRS_PER_PTE])
  561. : "cc", "memory");
  562. preempt_enable();
  563. #endif
  564. }
  565. static inline void pgste_set(pte_t *ptep, pgste_t pgste)
  566. {
  567. #ifdef CONFIG_PGSTE
  568. *(pgste_t *)(ptep + PTRS_PER_PTE) = pgste;
  569. #endif
  570. }
  571. static inline pgste_t pgste_update_all(pte_t *ptep, pgste_t pgste)
  572. {
  573. #ifdef CONFIG_PGSTE
  574. unsigned long address, bits;
  575. unsigned char skey;
  576. if (pte_val(*ptep) & _PAGE_INVALID)
  577. return pgste;
  578. address = pte_val(*ptep) & PAGE_MASK;
  579. skey = page_get_storage_key(address);
  580. bits = skey & (_PAGE_CHANGED | _PAGE_REFERENCED);
  581. /* Clear page changed & referenced bit in the storage key */
  582. if (bits & _PAGE_CHANGED)
  583. page_set_storage_key(address, skey ^ bits, 0);
  584. else if (bits)
  585. page_reset_referenced(address);
  586. /* Transfer page changed & referenced bit to guest bits in pgste */
  587. pgste_val(pgste) |= bits << 48; /* RCP_GR_BIT & RCP_GC_BIT */
  588. /* Get host changed & referenced bits from pgste */
  589. bits |= (pgste_val(pgste) & (RCP_HR_BIT | RCP_HC_BIT)) >> 52;
  590. /* Transfer page changed & referenced bit to kvm user bits */
  591. pgste_val(pgste) |= bits << 45; /* KVM_UR_BIT & KVM_UC_BIT */
  592. /* Clear relevant host bits in pgste. */
  593. pgste_val(pgste) &= ~(RCP_HR_BIT | RCP_HC_BIT);
  594. pgste_val(pgste) &= ~(RCP_ACC_BITS | RCP_FP_BIT);
  595. /* Copy page access key and fetch protection bit to pgste */
  596. pgste_val(pgste) |=
  597. (unsigned long) (skey & (_PAGE_ACC_BITS | _PAGE_FP_BIT)) << 56;
  598. /* Transfer referenced bit to pte */
  599. pte_val(*ptep) |= (bits & _PAGE_REFERENCED) << 1;
  600. #endif
  601. return pgste;
  602. }
  603. static inline pgste_t pgste_update_young(pte_t *ptep, pgste_t pgste)
  604. {
  605. #ifdef CONFIG_PGSTE
  606. int young;
  607. if (pte_val(*ptep) & _PAGE_INVALID)
  608. return pgste;
  609. /* Get referenced bit from storage key */
  610. young = page_reset_referenced(pte_val(*ptep) & PAGE_MASK);
  611. if (young)
  612. pgste_val(pgste) |= RCP_GR_BIT;
  613. /* Get host referenced bit from pgste */
  614. if (pgste_val(pgste) & RCP_HR_BIT) {
  615. pgste_val(pgste) &= ~RCP_HR_BIT;
  616. young = 1;
  617. }
  618. /* Transfer referenced bit to kvm user bits and pte */
  619. if (young) {
  620. pgste_val(pgste) |= KVM_UR_BIT;
  621. pte_val(*ptep) |= _PAGE_SWR;
  622. }
  623. #endif
  624. return pgste;
  625. }
  626. static inline void pgste_set_key(pte_t *ptep, pgste_t pgste, pte_t entry)
  627. {
  628. #ifdef CONFIG_PGSTE
  629. unsigned long address;
  630. unsigned long nkey;
  631. if (pte_val(entry) & _PAGE_INVALID)
  632. return;
  633. VM_BUG_ON(!(pte_val(*ptep) & _PAGE_INVALID));
  634. address = pte_val(entry) & PAGE_MASK;
  635. /*
  636. * Set page access key and fetch protection bit from pgste.
  637. * The guest C/R information is still in the PGSTE, set real
  638. * key C/R to 0.
  639. */
  640. nkey = (pgste_val(pgste) & (RCP_ACC_BITS | RCP_FP_BIT)) >> 56;
  641. page_set_storage_key(address, nkey, 0);
  642. #endif
  643. }
  644. static inline void pgste_set_pte(pte_t *ptep, pte_t entry)
  645. {
  646. if (!MACHINE_HAS_ESOP && (pte_val(entry) & _PAGE_SWW)) {
  647. /*
  648. * Without enhanced suppression-on-protection force
  649. * the dirty bit on for all writable ptes.
  650. */
  651. pte_val(entry) |= _PAGE_SWC;
  652. pte_val(entry) &= ~_PAGE_RO;
  653. }
  654. *ptep = entry;
  655. }
  656. /**
  657. * struct gmap_struct - guest address space
  658. * @mm: pointer to the parent mm_struct
  659. * @table: pointer to the page directory
  660. * @asce: address space control element for gmap page table
  661. * @crst_list: list of all crst tables used in the guest address space
  662. */
  663. struct gmap {
  664. struct list_head list;
  665. struct mm_struct *mm;
  666. unsigned long *table;
  667. unsigned long asce;
  668. struct list_head crst_list;
  669. };
  670. /**
  671. * struct gmap_rmap - reverse mapping for segment table entries
  672. * @gmap: pointer to the gmap_struct
  673. * @entry: pointer to a segment table entry
  674. * @vmaddr: virtual address in the guest address space
  675. */
  676. struct gmap_rmap {
  677. struct list_head list;
  678. struct gmap *gmap;
  679. unsigned long *entry;
  680. unsigned long vmaddr;
  681. };
  682. /**
  683. * struct gmap_pgtable - gmap information attached to a page table
  684. * @vmaddr: address of the 1MB segment in the process virtual memory
  685. * @mapper: list of segment table entries mapping a page table
  686. */
  687. struct gmap_pgtable {
  688. unsigned long vmaddr;
  689. struct list_head mapper;
  690. };
  691. /**
  692. * struct gmap_notifier - notify function block for page invalidation
  693. * @notifier_call: address of callback function
  694. */
  695. struct gmap_notifier {
  696. struct list_head list;
  697. void (*notifier_call)(struct gmap *gmap, unsigned long address);
  698. };
  699. struct gmap *gmap_alloc(struct mm_struct *mm);
  700. void gmap_free(struct gmap *gmap);
  701. void gmap_enable(struct gmap *gmap);
  702. void gmap_disable(struct gmap *gmap);
  703. int gmap_map_segment(struct gmap *gmap, unsigned long from,
  704. unsigned long to, unsigned long len);
  705. int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long len);
  706. unsigned long __gmap_translate(unsigned long address, struct gmap *);
  707. unsigned long gmap_translate(unsigned long address, struct gmap *);
  708. unsigned long __gmap_fault(unsigned long address, struct gmap *);
  709. unsigned long gmap_fault(unsigned long address, struct gmap *);
  710. void gmap_discard(unsigned long from, unsigned long to, struct gmap *);
  711. void gmap_register_ipte_notifier(struct gmap_notifier *);
  712. void gmap_unregister_ipte_notifier(struct gmap_notifier *);
  713. int gmap_ipte_notify(struct gmap *, unsigned long start, unsigned long len);
  714. void gmap_do_ipte_notify(struct mm_struct *, unsigned long addr, pte_t *);
  715. static inline pgste_t pgste_ipte_notify(struct mm_struct *mm,
  716. unsigned long addr,
  717. pte_t *ptep, pgste_t pgste)
  718. {
  719. #ifdef CONFIG_PGSTE
  720. if (pgste_val(pgste) & RCP_IN_BIT) {
  721. pgste_val(pgste) &= ~RCP_IN_BIT;
  722. gmap_do_ipte_notify(mm, addr, ptep);
  723. }
  724. #endif
  725. return pgste;
  726. }
  727. /*
  728. * Certain architectures need to do special things when PTEs
  729. * within a page table are directly modified. Thus, the following
  730. * hook is made available.
  731. */
  732. static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
  733. pte_t *ptep, pte_t entry)
  734. {
  735. pgste_t pgste;
  736. if (mm_has_pgste(mm)) {
  737. pgste = pgste_get_lock(ptep);
  738. pgste_set_key(ptep, pgste, entry);
  739. pgste_set_pte(ptep, entry);
  740. pgste_set_unlock(ptep, pgste);
  741. } else {
  742. if (!(pte_val(entry) & _PAGE_INVALID) && MACHINE_HAS_EDAT1)
  743. pte_val(entry) |= _PAGE_CO;
  744. *ptep = entry;
  745. }
  746. }
  747. /*
  748. * query functions pte_write/pte_dirty/pte_young only work if
  749. * pte_present() is true. Undefined behaviour if not..
  750. */
  751. static inline int pte_write(pte_t pte)
  752. {
  753. return (pte_val(pte) & _PAGE_SWW) != 0;
  754. }
  755. static inline int pte_dirty(pte_t pte)
  756. {
  757. return (pte_val(pte) & _PAGE_SWC) != 0;
  758. }
  759. static inline int pte_young(pte_t pte)
  760. {
  761. #ifdef CONFIG_PGSTE
  762. if (pte_val(pte) & _PAGE_SWR)
  763. return 1;
  764. #endif
  765. return 0;
  766. }
  767. /*
  768. * pgd/pmd/pte modification functions
  769. */
  770. static inline void pgd_clear(pgd_t *pgd)
  771. {
  772. #ifdef CONFIG_64BIT
  773. if ((pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R2)
  774. pgd_val(*pgd) = _REGION2_ENTRY_EMPTY;
  775. #endif
  776. }
  777. static inline void pud_clear(pud_t *pud)
  778. {
  779. #ifdef CONFIG_64BIT
  780. if ((pud_val(*pud) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3)
  781. pud_val(*pud) = _REGION3_ENTRY_EMPTY;
  782. #endif
  783. }
  784. static inline void pmd_clear(pmd_t *pmdp)
  785. {
  786. pmd_val(*pmdp) = _SEGMENT_ENTRY_EMPTY;
  787. }
  788. static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
  789. {
  790. pte_val(*ptep) = _PAGE_TYPE_EMPTY;
  791. }
  792. /*
  793. * The following pte modification functions only work if
  794. * pte_present() is true. Undefined behaviour if not..
  795. */
  796. static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
  797. {
  798. pte_val(pte) &= _PAGE_CHG_MASK;
  799. pte_val(pte) |= pgprot_val(newprot);
  800. if ((pte_val(pte) & _PAGE_SWC) && (pte_val(pte) & _PAGE_SWW))
  801. pte_val(pte) &= ~_PAGE_RO;
  802. return pte;
  803. }
  804. static inline pte_t pte_wrprotect(pte_t pte)
  805. {
  806. pte_val(pte) &= ~_PAGE_SWW;
  807. /* Do not clobber _PAGE_TYPE_NONE pages! */
  808. if (!(pte_val(pte) & _PAGE_INVALID))
  809. pte_val(pte) |= _PAGE_RO;
  810. return pte;
  811. }
  812. static inline pte_t pte_mkwrite(pte_t pte)
  813. {
  814. pte_val(pte) |= _PAGE_SWW;
  815. if (pte_val(pte) & _PAGE_SWC)
  816. pte_val(pte) &= ~_PAGE_RO;
  817. return pte;
  818. }
  819. static inline pte_t pte_mkclean(pte_t pte)
  820. {
  821. pte_val(pte) &= ~_PAGE_SWC;
  822. /* Do not clobber _PAGE_TYPE_NONE pages! */
  823. if (!(pte_val(pte) & _PAGE_INVALID))
  824. pte_val(pte) |= _PAGE_RO;
  825. return pte;
  826. }
  827. static inline pte_t pte_mkdirty(pte_t pte)
  828. {
  829. pte_val(pte) |= _PAGE_SWC;
  830. if (pte_val(pte) & _PAGE_SWW)
  831. pte_val(pte) &= ~_PAGE_RO;
  832. return pte;
  833. }
  834. static inline pte_t pte_mkold(pte_t pte)
  835. {
  836. #ifdef CONFIG_PGSTE
  837. pte_val(pte) &= ~_PAGE_SWR;
  838. #endif
  839. return pte;
  840. }
  841. static inline pte_t pte_mkyoung(pte_t pte)
  842. {
  843. return pte;
  844. }
  845. static inline pte_t pte_mkspecial(pte_t pte)
  846. {
  847. pte_val(pte) |= _PAGE_SPECIAL;
  848. return pte;
  849. }
  850. #ifdef CONFIG_HUGETLB_PAGE
  851. static inline pte_t pte_mkhuge(pte_t pte)
  852. {
  853. pte_val(pte) |= (_SEGMENT_ENTRY_LARGE | _SEGMENT_ENTRY_CO);
  854. return pte;
  855. }
  856. #endif
  857. /*
  858. * Get (and clear) the user dirty bit for a pte.
  859. */
  860. static inline int ptep_test_and_clear_user_dirty(struct mm_struct *mm,
  861. pte_t *ptep)
  862. {
  863. pgste_t pgste;
  864. int dirty = 0;
  865. if (mm_has_pgste(mm)) {
  866. pgste = pgste_get_lock(ptep);
  867. pgste = pgste_update_all(ptep, pgste);
  868. dirty = !!(pgste_val(pgste) & KVM_UC_BIT);
  869. pgste_val(pgste) &= ~KVM_UC_BIT;
  870. pgste_set_unlock(ptep, pgste);
  871. return dirty;
  872. }
  873. return dirty;
  874. }
  875. /*
  876. * Get (and clear) the user referenced bit for a pte.
  877. */
  878. static inline int ptep_test_and_clear_user_young(struct mm_struct *mm,
  879. pte_t *ptep)
  880. {
  881. pgste_t pgste;
  882. int young = 0;
  883. if (mm_has_pgste(mm)) {
  884. pgste = pgste_get_lock(ptep);
  885. pgste = pgste_update_young(ptep, pgste);
  886. young = !!(pgste_val(pgste) & KVM_UR_BIT);
  887. pgste_val(pgste) &= ~KVM_UR_BIT;
  888. pgste_set_unlock(ptep, pgste);
  889. }
  890. return young;
  891. }
  892. #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
  893. static inline int ptep_test_and_clear_young(struct vm_area_struct *vma,
  894. unsigned long addr, pte_t *ptep)
  895. {
  896. pgste_t pgste;
  897. pte_t pte;
  898. if (mm_has_pgste(vma->vm_mm)) {
  899. pgste = pgste_get_lock(ptep);
  900. pgste = pgste_update_young(ptep, pgste);
  901. pte = *ptep;
  902. *ptep = pte_mkold(pte);
  903. pgste_set_unlock(ptep, pgste);
  904. return pte_young(pte);
  905. }
  906. return 0;
  907. }
  908. #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
  909. static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
  910. unsigned long address, pte_t *ptep)
  911. {
  912. /* No need to flush TLB
  913. * On s390 reference bits are in storage key and never in TLB
  914. * With virtualization we handle the reference bit, without we
  915. * we can simply return */
  916. return ptep_test_and_clear_young(vma, address, ptep);
  917. }
  918. static inline void __ptep_ipte(unsigned long address, pte_t *ptep)
  919. {
  920. if (!(pte_val(*ptep) & _PAGE_INVALID)) {
  921. #ifndef CONFIG_64BIT
  922. /* pto must point to the start of the segment table */
  923. pte_t *pto = (pte_t *) (((unsigned long) ptep) & 0x7ffffc00);
  924. #else
  925. /* ipte in zarch mode can do the math */
  926. pte_t *pto = ptep;
  927. #endif
  928. asm volatile(
  929. " ipte %2,%3"
  930. : "=m" (*ptep) : "m" (*ptep),
  931. "a" (pto), "a" (address));
  932. }
  933. }
  934. /*
  935. * This is hard to understand. ptep_get_and_clear and ptep_clear_flush
  936. * both clear the TLB for the unmapped pte. The reason is that
  937. * ptep_get_and_clear is used in common code (e.g. change_pte_range)
  938. * to modify an active pte. The sequence is
  939. * 1) ptep_get_and_clear
  940. * 2) set_pte_at
  941. * 3) flush_tlb_range
  942. * On s390 the tlb needs to get flushed with the modification of the pte
  943. * if the pte is active. The only way how this can be implemented is to
  944. * have ptep_get_and_clear do the tlb flush. In exchange flush_tlb_range
  945. * is a nop.
  946. */
  947. #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
  948. static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
  949. unsigned long address, pte_t *ptep)
  950. {
  951. pgste_t pgste;
  952. pte_t pte;
  953. mm->context.flush_mm = 1;
  954. if (mm_has_pgste(mm)) {
  955. pgste = pgste_get_lock(ptep);
  956. pgste = pgste_ipte_notify(mm, address, ptep, pgste);
  957. }
  958. pte = *ptep;
  959. if (!mm_exclusive(mm))
  960. __ptep_ipte(address, ptep);
  961. pte_val(*ptep) = _PAGE_TYPE_EMPTY;
  962. if (mm_has_pgste(mm)) {
  963. pgste = pgste_update_all(&pte, pgste);
  964. pgste_set_unlock(ptep, pgste);
  965. }
  966. return pte;
  967. }
  968. #define __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION
  969. static inline pte_t ptep_modify_prot_start(struct mm_struct *mm,
  970. unsigned long address,
  971. pte_t *ptep)
  972. {
  973. pgste_t pgste;
  974. pte_t pte;
  975. mm->context.flush_mm = 1;
  976. if (mm_has_pgste(mm)) {
  977. pgste = pgste_get_lock(ptep);
  978. pgste_ipte_notify(mm, address, ptep, pgste);
  979. }
  980. pte = *ptep;
  981. if (!mm_exclusive(mm))
  982. __ptep_ipte(address, ptep);
  983. if (mm_has_pgste(mm)) {
  984. pgste = pgste_update_all(&pte, pgste);
  985. pgste_set(ptep, pgste);
  986. }
  987. return pte;
  988. }
  989. static inline void ptep_modify_prot_commit(struct mm_struct *mm,
  990. unsigned long address,
  991. pte_t *ptep, pte_t pte)
  992. {
  993. pgste_t pgste;
  994. if (mm_has_pgste(mm)) {
  995. pgste = *(pgste_t *)(ptep + PTRS_PER_PTE);
  996. pgste_set_key(ptep, pgste, pte);
  997. pgste_set_pte(ptep, pte);
  998. pgste_set_unlock(ptep, pgste);
  999. } else
  1000. *ptep = pte;
  1001. }
  1002. #define __HAVE_ARCH_PTEP_CLEAR_FLUSH
  1003. static inline pte_t ptep_clear_flush(struct vm_area_struct *vma,
  1004. unsigned long address, pte_t *ptep)
  1005. {
  1006. pgste_t pgste;
  1007. pte_t pte;
  1008. if (mm_has_pgste(vma->vm_mm)) {
  1009. pgste = pgste_get_lock(ptep);
  1010. pgste = pgste_ipte_notify(vma->vm_mm, address, ptep, pgste);
  1011. }
  1012. pte = *ptep;
  1013. __ptep_ipte(address, ptep);
  1014. pte_val(*ptep) = _PAGE_TYPE_EMPTY;
  1015. if (mm_has_pgste(vma->vm_mm)) {
  1016. pgste = pgste_update_all(&pte, pgste);
  1017. pgste_set_unlock(ptep, pgste);
  1018. }
  1019. return pte;
  1020. }
  1021. /*
  1022. * The batched pte unmap code uses ptep_get_and_clear_full to clear the
  1023. * ptes. Here an optimization is possible. tlb_gather_mmu flushes all
  1024. * tlbs of an mm if it can guarantee that the ptes of the mm_struct
  1025. * cannot be accessed while the batched unmap is running. In this case
  1026. * full==1 and a simple pte_clear is enough. See tlb.h.
  1027. */
  1028. #define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
  1029. static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm,
  1030. unsigned long address,
  1031. pte_t *ptep, int full)
  1032. {
  1033. pgste_t pgste;
  1034. pte_t pte;
  1035. if (mm_has_pgste(mm)) {
  1036. pgste = pgste_get_lock(ptep);
  1037. if (!full)
  1038. pgste = pgste_ipte_notify(mm, address, ptep, pgste);
  1039. }
  1040. pte = *ptep;
  1041. if (!full)
  1042. __ptep_ipte(address, ptep);
  1043. pte_val(*ptep) = _PAGE_TYPE_EMPTY;
  1044. if (mm_has_pgste(mm)) {
  1045. pgste = pgste_update_all(&pte, pgste);
  1046. pgste_set_unlock(ptep, pgste);
  1047. }
  1048. return pte;
  1049. }
  1050. #define __HAVE_ARCH_PTEP_SET_WRPROTECT
  1051. static inline pte_t ptep_set_wrprotect(struct mm_struct *mm,
  1052. unsigned long address, pte_t *ptep)
  1053. {
  1054. pgste_t pgste;
  1055. pte_t pte = *ptep;
  1056. if (pte_write(pte)) {
  1057. mm->context.flush_mm = 1;
  1058. if (mm_has_pgste(mm)) {
  1059. pgste = pgste_get_lock(ptep);
  1060. pgste = pgste_ipte_notify(mm, address, ptep, pgste);
  1061. }
  1062. if (!mm_exclusive(mm))
  1063. __ptep_ipte(address, ptep);
  1064. pte = pte_wrprotect(pte);
  1065. if (mm_has_pgste(mm)) {
  1066. pgste_set_pte(ptep, pte);
  1067. pgste_set_unlock(ptep, pgste);
  1068. } else
  1069. *ptep = pte;
  1070. }
  1071. return pte;
  1072. }
  1073. #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
  1074. static inline int ptep_set_access_flags(struct vm_area_struct *vma,
  1075. unsigned long address, pte_t *ptep,
  1076. pte_t entry, int dirty)
  1077. {
  1078. pgste_t pgste;
  1079. if (pte_same(*ptep, entry))
  1080. return 0;
  1081. if (mm_has_pgste(vma->vm_mm)) {
  1082. pgste = pgste_get_lock(ptep);
  1083. pgste = pgste_ipte_notify(vma->vm_mm, address, ptep, pgste);
  1084. }
  1085. __ptep_ipte(address, ptep);
  1086. if (mm_has_pgste(vma->vm_mm)) {
  1087. pgste_set_pte(ptep, entry);
  1088. pgste_set_unlock(ptep, pgste);
  1089. } else
  1090. *ptep = entry;
  1091. return 1;
  1092. }
  1093. /*
  1094. * Conversion functions: convert a page and protection to a page entry,
  1095. * and a page entry and page directory to the page they refer to.
  1096. */
  1097. static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)
  1098. {
  1099. pte_t __pte;
  1100. pte_val(__pte) = physpage + pgprot_val(pgprot);
  1101. return __pte;
  1102. }
  1103. static inline pte_t mk_pte(struct page *page, pgprot_t pgprot)
  1104. {
  1105. unsigned long physpage = page_to_phys(page);
  1106. pte_t __pte = mk_pte_phys(physpage, pgprot);
  1107. if ((pte_val(__pte) & _PAGE_SWW) && PageDirty(page)) {
  1108. pte_val(__pte) |= _PAGE_SWC;
  1109. pte_val(__pte) &= ~_PAGE_RO;
  1110. }
  1111. return __pte;
  1112. }
  1113. #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
  1114. #define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
  1115. #define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
  1116. #define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1))
  1117. #define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
  1118. #define pgd_offset_k(address) pgd_offset(&init_mm, address)
  1119. #ifndef CONFIG_64BIT
  1120. #define pmd_deref(pmd) (pmd_val(pmd) & _SEGMENT_ENTRY_ORIGIN)
  1121. #define pud_deref(pmd) ({ BUG(); 0UL; })
  1122. #define pgd_deref(pmd) ({ BUG(); 0UL; })
  1123. #define pud_offset(pgd, address) ((pud_t *) pgd)
  1124. #define pmd_offset(pud, address) ((pmd_t *) pud + pmd_index(address))
  1125. #else /* CONFIG_64BIT */
  1126. #define pmd_deref(pmd) (pmd_val(pmd) & _SEGMENT_ENTRY_ORIGIN)
  1127. #define pud_deref(pud) (pud_val(pud) & _REGION_ENTRY_ORIGIN)
  1128. #define pgd_deref(pgd) (pgd_val(pgd) & _REGION_ENTRY_ORIGIN)
  1129. static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
  1130. {
  1131. pud_t *pud = (pud_t *) pgd;
  1132. if ((pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R2)
  1133. pud = (pud_t *) pgd_deref(*pgd);
  1134. return pud + pud_index(address);
  1135. }
  1136. static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
  1137. {
  1138. pmd_t *pmd = (pmd_t *) pud;
  1139. if ((pud_val(*pud) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3)
  1140. pmd = (pmd_t *) pud_deref(*pud);
  1141. return pmd + pmd_index(address);
  1142. }
  1143. #endif /* CONFIG_64BIT */
  1144. #define pfn_pte(pfn,pgprot) mk_pte_phys(__pa((pfn) << PAGE_SHIFT),(pgprot))
  1145. #define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT)
  1146. #define pte_page(x) pfn_to_page(pte_pfn(x))
  1147. #define pmd_page(pmd) pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)
  1148. /* Find an entry in the lowest level page table.. */
  1149. #define pte_offset(pmd, addr) ((pte_t *) pmd_deref(*(pmd)) + pte_index(addr))
  1150. #define pte_offset_kernel(pmd, address) pte_offset(pmd,address)
  1151. #define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address)
  1152. #define pte_unmap(pte) do { } while (0)
  1153. static inline void __pmd_idte(unsigned long address, pmd_t *pmdp)
  1154. {
  1155. unsigned long sto = (unsigned long) pmdp -
  1156. pmd_index(address) * sizeof(pmd_t);
  1157. if (!(pmd_val(*pmdp) & _SEGMENT_ENTRY_INV)) {
  1158. asm volatile(
  1159. " .insn rrf,0xb98e0000,%2,%3,0,0"
  1160. : "=m" (*pmdp)
  1161. : "m" (*pmdp), "a" (sto),
  1162. "a" ((address & HPAGE_MASK))
  1163. : "cc"
  1164. );
  1165. }
  1166. }
  1167. #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLB_PAGE)
  1168. static inline unsigned long massage_pgprot_pmd(pgprot_t pgprot)
  1169. {
  1170. /*
  1171. * pgprot is PAGE_NONE, PAGE_RO, or PAGE_RW (see __Pxxx / __Sxxx)
  1172. * Convert to segment table entry format.
  1173. */
  1174. if (pgprot_val(pgprot) == pgprot_val(PAGE_NONE))
  1175. return pgprot_val(SEGMENT_NONE);
  1176. if (pgprot_val(pgprot) == pgprot_val(PAGE_RO))
  1177. return pgprot_val(SEGMENT_RO);
  1178. return pgprot_val(SEGMENT_RW);
  1179. }
  1180. static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
  1181. {
  1182. pmd_val(pmd) &= _SEGMENT_CHG_MASK;
  1183. pmd_val(pmd) |= massage_pgprot_pmd(newprot);
  1184. return pmd;
  1185. }
  1186. static inline pmd_t mk_pmd_phys(unsigned long physpage, pgprot_t pgprot)
  1187. {
  1188. pmd_t __pmd;
  1189. pmd_val(__pmd) = physpage + massage_pgprot_pmd(pgprot);
  1190. return __pmd;
  1191. }
  1192. static inline pmd_t pmd_mkwrite(pmd_t pmd)
  1193. {
  1194. /* Do not clobber _HPAGE_TYPE_NONE pages! */
  1195. if (!(pmd_val(pmd) & _SEGMENT_ENTRY_INV))
  1196. pmd_val(pmd) &= ~_SEGMENT_ENTRY_RO;
  1197. return pmd;
  1198. }
  1199. #endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLB_PAGE */
  1200. #ifdef CONFIG_TRANSPARENT_HUGEPAGE
  1201. #define __HAVE_ARCH_PGTABLE_DEPOSIT
  1202. extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pgtable_t pgtable);
  1203. #define __HAVE_ARCH_PGTABLE_WITHDRAW
  1204. extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm);
  1205. static inline int pmd_trans_splitting(pmd_t pmd)
  1206. {
  1207. return pmd_val(pmd) & _SEGMENT_ENTRY_SPLIT;
  1208. }
  1209. static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
  1210. pmd_t *pmdp, pmd_t entry)
  1211. {
  1212. if (!(pmd_val(entry) & _SEGMENT_ENTRY_INV) && MACHINE_HAS_EDAT1)
  1213. pmd_val(entry) |= _SEGMENT_ENTRY_CO;
  1214. *pmdp = entry;
  1215. }
  1216. static inline pmd_t pmd_mkhuge(pmd_t pmd)
  1217. {
  1218. pmd_val(pmd) |= _SEGMENT_ENTRY_LARGE;
  1219. return pmd;
  1220. }
  1221. static inline pmd_t pmd_wrprotect(pmd_t pmd)
  1222. {
  1223. pmd_val(pmd) |= _SEGMENT_ENTRY_RO;
  1224. return pmd;
  1225. }
  1226. static inline pmd_t pmd_mkdirty(pmd_t pmd)
  1227. {
  1228. /* No dirty bit in the segment table entry. */
  1229. return pmd;
  1230. }
  1231. static inline pmd_t pmd_mkold(pmd_t pmd)
  1232. {
  1233. /* No referenced bit in the segment table entry. */
  1234. return pmd;
  1235. }
  1236. static inline pmd_t pmd_mkyoung(pmd_t pmd)
  1237. {
  1238. /* No referenced bit in the segment table entry. */
  1239. return pmd;
  1240. }
  1241. #define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
  1242. static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
  1243. unsigned long address, pmd_t *pmdp)
  1244. {
  1245. unsigned long pmd_addr = pmd_val(*pmdp) & HPAGE_MASK;
  1246. long tmp, rc;
  1247. int counter;
  1248. rc = 0;
  1249. if (MACHINE_HAS_RRBM) {
  1250. counter = PTRS_PER_PTE >> 6;
  1251. asm volatile(
  1252. "0: .insn rre,0xb9ae0000,%0,%3\n" /* rrbm */
  1253. " ogr %1,%0\n"
  1254. " la %3,0(%4,%3)\n"
  1255. " brct %2,0b\n"
  1256. : "=&d" (tmp), "+&d" (rc), "+d" (counter),
  1257. "+a" (pmd_addr)
  1258. : "a" (64 * 4096UL) : "cc");
  1259. rc = !!rc;
  1260. } else {
  1261. counter = PTRS_PER_PTE;
  1262. asm volatile(
  1263. "0: rrbe 0,%2\n"
  1264. " la %2,0(%3,%2)\n"
  1265. " brc 12,1f\n"
  1266. " lhi %0,1\n"
  1267. "1: brct %1,0b\n"
  1268. : "+d" (rc), "+d" (counter), "+a" (pmd_addr)
  1269. : "a" (4096UL) : "cc");
  1270. }
  1271. return rc;
  1272. }
  1273. #define __HAVE_ARCH_PMDP_GET_AND_CLEAR
  1274. static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
  1275. unsigned long address, pmd_t *pmdp)
  1276. {
  1277. pmd_t pmd = *pmdp;
  1278. __pmd_idte(address, pmdp);
  1279. pmd_clear(pmdp);
  1280. return pmd;
  1281. }
  1282. #define __HAVE_ARCH_PMDP_CLEAR_FLUSH
  1283. static inline pmd_t pmdp_clear_flush(struct vm_area_struct *vma,
  1284. unsigned long address, pmd_t *pmdp)
  1285. {
  1286. return pmdp_get_and_clear(vma->vm_mm, address, pmdp);
  1287. }
  1288. #define __HAVE_ARCH_PMDP_INVALIDATE
  1289. static inline void pmdp_invalidate(struct vm_area_struct *vma,
  1290. unsigned long address, pmd_t *pmdp)
  1291. {
  1292. __pmd_idte(address, pmdp);
  1293. }
  1294. #define __HAVE_ARCH_PMDP_SET_WRPROTECT
  1295. static inline void pmdp_set_wrprotect(struct mm_struct *mm,
  1296. unsigned long address, pmd_t *pmdp)
  1297. {
  1298. pmd_t pmd = *pmdp;
  1299. if (pmd_write(pmd)) {
  1300. __pmd_idte(address, pmdp);
  1301. set_pmd_at(mm, address, pmdp, pmd_wrprotect(pmd));
  1302. }
  1303. }
  1304. #define pfn_pmd(pfn, pgprot) mk_pmd_phys(__pa((pfn) << PAGE_SHIFT), (pgprot))
  1305. #define mk_pmd(page, pgprot) pfn_pmd(page_to_pfn(page), (pgprot))
  1306. static inline int pmd_trans_huge(pmd_t pmd)
  1307. {
  1308. return pmd_val(pmd) & _SEGMENT_ENTRY_LARGE;
  1309. }
  1310. static inline int has_transparent_hugepage(void)
  1311. {
  1312. return MACHINE_HAS_HPAGE ? 1 : 0;
  1313. }
  1314. static inline unsigned long pmd_pfn(pmd_t pmd)
  1315. {
  1316. return pmd_val(pmd) >> PAGE_SHIFT;
  1317. }
  1318. #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
  1319. /*
  1320. * 31 bit swap entry format:
  1321. * A page-table entry has some bits we have to treat in a special way.
  1322. * Bits 0, 20 and bit 23 have to be zero, otherwise an specification
  1323. * exception will occur instead of a page translation exception. The
  1324. * specifiation exception has the bad habit not to store necessary
  1325. * information in the lowcore.
  1326. * Bit 21 and bit 22 are the page invalid bit and the page protection
  1327. * bit. We set both to indicate a swapped page.
  1328. * Bit 30 and 31 are used to distinguish the different page types. For
  1329. * a swapped page these bits need to be zero.
  1330. * This leaves the bits 1-19 and bits 24-29 to store type and offset.
  1331. * We use the 5 bits from 25-29 for the type and the 20 bits from 1-19
  1332. * plus 24 for the offset.
  1333. * 0| offset |0110|o|type |00|
  1334. * 0 0000000001111111111 2222 2 22222 33
  1335. * 0 1234567890123456789 0123 4 56789 01
  1336. *
  1337. * 64 bit swap entry format:
  1338. * A page-table entry has some bits we have to treat in a special way.
  1339. * Bits 52 and bit 55 have to be zero, otherwise an specification
  1340. * exception will occur instead of a page translation exception. The
  1341. * specifiation exception has the bad habit not to store necessary
  1342. * information in the lowcore.
  1343. * Bit 53 and bit 54 are the page invalid bit and the page protection
  1344. * bit. We set both to indicate a swapped page.
  1345. * Bit 62 and 63 are used to distinguish the different page types. For
  1346. * a swapped page these bits need to be zero.
  1347. * This leaves the bits 0-51 and bits 56-61 to store type and offset.
  1348. * We use the 5 bits from 57-61 for the type and the 53 bits from 0-51
  1349. * plus 56 for the offset.
  1350. * | offset |0110|o|type |00|
  1351. * 0000000000111111111122222222223333333333444444444455 5555 5 55566 66
  1352. * 0123456789012345678901234567890123456789012345678901 2345 6 78901 23
  1353. */
  1354. #ifndef CONFIG_64BIT
  1355. #define __SWP_OFFSET_MASK (~0UL >> 12)
  1356. #else
  1357. #define __SWP_OFFSET_MASK (~0UL >> 11)
  1358. #endif
  1359. static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
  1360. {
  1361. pte_t pte;
  1362. offset &= __SWP_OFFSET_MASK;
  1363. pte_val(pte) = _PAGE_TYPE_SWAP | ((type & 0x1f) << 2) |
  1364. ((offset & 1UL) << 7) | ((offset & ~1UL) << 11);
  1365. return pte;
  1366. }
  1367. #define __swp_type(entry) (((entry).val >> 2) & 0x1f)
  1368. #define __swp_offset(entry) (((entry).val >> 11) | (((entry).val >> 7) & 1))
  1369. #define __swp_entry(type,offset) ((swp_entry_t) { pte_val(mk_swap_pte((type),(offset))) })
  1370. #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
  1371. #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
  1372. #ifndef CONFIG_64BIT
  1373. # define PTE_FILE_MAX_BITS 26
  1374. #else /* CONFIG_64BIT */
  1375. # define PTE_FILE_MAX_BITS 59
  1376. #endif /* CONFIG_64BIT */
  1377. #define pte_to_pgoff(__pte) \
  1378. ((((__pte).pte >> 12) << 7) + (((__pte).pte >> 1) & 0x7f))
  1379. #define pgoff_to_pte(__off) \
  1380. ((pte_t) { ((((__off) & 0x7f) << 1) + (((__off) >> 7) << 12)) \
  1381. | _PAGE_TYPE_FILE })
  1382. #endif /* !__ASSEMBLY__ */
  1383. #define kern_addr_valid(addr) (1)
  1384. extern int vmem_add_mapping(unsigned long start, unsigned long size);
  1385. extern int vmem_remove_mapping(unsigned long start, unsigned long size);
  1386. extern int s390_enable_sie(void);
  1387. /*
  1388. * No page table caches to initialise
  1389. */
  1390. static inline void pgtable_cache_init(void) { }
  1391. static inline void check_pgt_cache(void) { }
  1392. #include <asm-generic/pgtable.h>
  1393. #endif /* _S390_PAGE_H */