Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
page.h
Go to the documentation of this file.
1 /*
2  * S390 version
3  * Copyright IBM Corp. 1999, 2000
4  * Author(s): Hartmut Penner ([email protected])
5  */
6 
7 #ifndef _S390_PAGE_H
8 #define _S390_PAGE_H
9 
10 #include <linux/const.h>
11 #include <asm/types.h>
12 
13 /* PAGE_SHIFT determines the page size */
14 #define PAGE_SHIFT 12
15 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
16 #define PAGE_MASK (~(PAGE_SIZE-1))
17 #define PAGE_DEFAULT_ACC 0
18 #define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)
19 
20 #define HPAGE_SHIFT 20
21 #define HPAGE_SIZE (1UL << HPAGE_SHIFT)
22 #define HPAGE_MASK (~(HPAGE_SIZE - 1))
23 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
24 
25 #define ARCH_HAS_SETCLEAR_HUGE_PTE
26 #define ARCH_HAS_HUGE_PTE_TYPE
27 #define ARCH_HAS_PREPARE_HUGEPAGE
28 #define ARCH_HAS_HUGEPAGE_CLEAR_FLUSH
29 
30 #include <asm/setup.h>
31 #ifndef __ASSEMBLY__
32 
33 static unsigned long pfmf(unsigned long function, unsigned long address)
34 {
35  asm volatile(
36  " .insn rre,0xb9af0000,%[function],%[address]"
37  : [address] "+a" (address)
38  : [function] "d" (function)
39  : "memory");
40  return address;
41 }
42 
43 static inline void clear_page(void *page)
44 {
45  if (MACHINE_HAS_PFMF) {
46  pfmf(0x10000, (unsigned long)page);
47  } else {
48  register unsigned long reg1 asm ("1") = 0;
49  register void *reg2 asm ("2") = page;
50  register unsigned long reg3 asm ("3") = 4096;
51  asm volatile(
52  " mvcl 2,0"
53  : "+d" (reg2), "+d" (reg3) : "d" (reg1)
54  : "memory", "cc");
55  }
56 }
57 
58 static inline void copy_page(void *to, void *from)
59 {
60  if (MACHINE_HAS_MVPG) {
61  register unsigned long reg0 asm ("0") = 0;
62  asm volatile(
63  " mvpg %0,%1"
64  : : "a" (to), "a" (from), "d" (reg0)
65  : "memory", "cc");
66  } else
67  asm volatile(
68  " mvc 0(256,%0),0(%1)\n"
69  " mvc 256(256,%0),256(%1)\n"
70  " mvc 512(256,%0),512(%1)\n"
71  " mvc 768(256,%0),768(%1)\n"
72  " mvc 1024(256,%0),1024(%1)\n"
73  " mvc 1280(256,%0),1280(%1)\n"
74  " mvc 1536(256,%0),1536(%1)\n"
75  " mvc 1792(256,%0),1792(%1)\n"
76  " mvc 2048(256,%0),2048(%1)\n"
77  " mvc 2304(256,%0),2304(%1)\n"
78  " mvc 2560(256,%0),2560(%1)\n"
79  " mvc 2816(256,%0),2816(%1)\n"
80  " mvc 3072(256,%0),3072(%1)\n"
81  " mvc 3328(256,%0),3328(%1)\n"
82  " mvc 3584(256,%0),3584(%1)\n"
83  " mvc 3840(256,%0),3840(%1)\n"
84  : : "a" (to), "a" (from) : "memory");
85 }
86 
87 #define clear_user_page(page, vaddr, pg) clear_page(page)
88 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
89 
90 #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
91  alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
92 #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
93 
94 /*
95  * These are used to make use of C type-checking..
96  */
97 
98 typedef struct { unsigned long pgprot; } pgprot_t;
99 typedef struct { unsigned long pgste; } pgste_t;
100 typedef struct { unsigned long pte; } pte_t;
101 typedef struct { unsigned long pmd; } pmd_t;
102 typedef struct { unsigned long pud; } pud_t;
103 typedef struct { unsigned long pgd; } pgd_t;
104 typedef pte_t *pgtable_t;
105 
106 #define pgprot_val(x) ((x).pgprot)
107 #define pgste_val(x) ((x).pgste)
108 #define pte_val(x) ((x).pte)
109 #define pmd_val(x) ((x).pmd)
110 #define pud_val(x) ((x).pud)
111 #define pgd_val(x) ((x).pgd)
112 
113 #define __pgste(x) ((pgste_t) { (x) } )
114 #define __pte(x) ((pte_t) { (x) } )
115 #define __pmd(x) ((pmd_t) { (x) } )
116 #define __pud(x) ((pud_t) { (x) } )
117 #define __pgd(x) ((pgd_t) { (x) } )
118 #define __pgprot(x) ((pgprot_t) { (x) } )
119 
120 static inline void page_set_storage_key(unsigned long addr,
121  unsigned char skey, int mapped)
122 {
123  if (!mapped)
124  asm volatile(".insn rrf,0xb22b0000,%0,%1,8,0"
125  : : "d" (skey), "a" (addr));
126  else
127  asm volatile("sske %0,%1" : : "d" (skey), "a" (addr));
128 }
129 
130 static inline unsigned char page_get_storage_key(unsigned long addr)
131 {
132  unsigned char skey;
133 
134  asm volatile("iske %0,%1" : "=d" (skey) : "a" (addr));
135  return skey;
136 }
137 
138 static inline int page_reset_referenced(unsigned long addr)
139 {
140  unsigned int ipm;
141 
142  asm volatile(
143  " rrbe 0,%1\n"
144  " ipm %0\n"
145  : "=d" (ipm) : "a" (addr) : "cc");
146  return !!(ipm & 0x20000000);
147 }
148 
149 /* Bits int the storage key */
150 #define _PAGE_CHANGED 0x02 /* HW changed bit */
151 #define _PAGE_REFERENCED 0x04 /* HW referenced bit */
152 #define _PAGE_FP_BIT 0x08 /* HW fetch protection bit */
153 #define _PAGE_ACC_BITS 0xf0 /* HW access control bits */
154 
155 /*
156  * Test and clear dirty bit in storage key.
157  * We can't clear the changed bit atomically. This is a potential
158  * race against modification of the referenced bit. This function
159  * should therefore only be called if it is not mapped in any
160  * address space.
161  */
162 #define __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY
163 static inline int page_test_and_clear_dirty(unsigned long pfn, int mapped)
164 {
165  unsigned char skey;
166 
167  skey = page_get_storage_key(pfn << PAGE_SHIFT);
168  if (!(skey & _PAGE_CHANGED))
169  return 0;
170  page_set_storage_key(pfn << PAGE_SHIFT, skey & ~_PAGE_CHANGED, mapped);
171  return 1;
172 }
173 
174 /*
175  * Test and clear referenced bit in storage key.
176  */
177 #define __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG
178 static inline int page_test_and_clear_young(unsigned long pfn)
179 {
180  return page_reset_referenced(pfn << PAGE_SHIFT);
181 }
182 
183 struct page;
184 void arch_free_page(struct page *page, int order);
185 void arch_alloc_page(struct page *page, int order);
186 void arch_set_page_states(int make_stable);
187 
188 static inline int devmem_is_allowed(unsigned long pfn)
189 {
190  return 0;
191 }
192 
193 #define HAVE_ARCH_FREE_PAGE
194 #define HAVE_ARCH_ALLOC_PAGE
195 
196 #endif /* !__ASSEMBLY__ */
197 
198 #define __PAGE_OFFSET 0x0UL
199 #define PAGE_OFFSET 0x0UL
200 #define __pa(x) (unsigned long)(x)
201 #define __va(x) (void *)(unsigned long)(x)
202 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
203 #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
204 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
205 
206 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
207  VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
208 
210 #include <asm-generic/getorder.h>
211 
212 #define __HAVE_ARCH_GATE_AREA 1
213 
214 #endif /* _S390_PAGE_H */