1 /* 2 * S390 version 3 * Copyright IBM Corp. 1999, 2000 4 * Author(s): Hartmut Penner (hp@de.ibm.com) 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 void storage_key_init_range(unsigned long start, unsigned long end); 34 35 static inline void clear_page(void *page) 36 { 37 register unsigned long reg1 asm ("1") = 0; 38 register void *reg2 asm ("2") = page; 39 register unsigned long reg3 asm ("3") = 4096; 40 asm volatile( 41 " mvcl 2,0" 42 : "+d" (reg2), "+d" (reg3) : "d" (reg1) 43 : "memory", "cc"); 44 } 45 46 static inline void copy_page(void *to, void *from) 47 { 48 if (MACHINE_HAS_MVPG) { 49 register unsigned long reg0 asm ("0") = 0; 50 asm volatile( 51 " mvpg %0,%1" 52 : : "a" (to), "a" (from), "d" (reg0) 53 : "memory", "cc"); 54 } else 55 asm volatile( 56 " mvc 0(256,%0),0(%1)\n" 57 " mvc 256(256,%0),256(%1)\n" 58 " mvc 512(256,%0),512(%1)\n" 59 " mvc 768(256,%0),768(%1)\n" 60 " mvc 1024(256,%0),1024(%1)\n" 61 " mvc 1280(256,%0),1280(%1)\n" 62 " mvc 1536(256,%0),1536(%1)\n" 63 " mvc 1792(256,%0),1792(%1)\n" 64 " mvc 2048(256,%0),2048(%1)\n" 65 " mvc 2304(256,%0),2304(%1)\n" 66 " mvc 2560(256,%0),2560(%1)\n" 67 " mvc 2816(256,%0),2816(%1)\n" 68 " mvc 3072(256,%0),3072(%1)\n" 69 " mvc 3328(256,%0),3328(%1)\n" 70 " mvc 3584(256,%0),3584(%1)\n" 71 " mvc 3840(256,%0),3840(%1)\n" 72 : : "a" (to), "a" (from) : "memory"); 73 } 74 75 #define clear_user_page(page, vaddr, pg) clear_page(page) 76 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) 77 78 #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \ 79 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) 80 #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE 81 82 /* 83 * These are used to make use of C type-checking.. 84 */ 85 86 typedef struct { unsigned long pgprot; } pgprot_t; 87 typedef struct { unsigned long pgste; } pgste_t; 88 typedef struct { unsigned long pte; } pte_t; 89 typedef struct { unsigned long pmd; } pmd_t; 90 typedef struct { unsigned long pud; } pud_t; 91 typedef struct { unsigned long pgd; } pgd_t; 92 typedef pte_t *pgtable_t; 93 94 #define pgprot_val(x) ((x).pgprot) 95 #define pgste_val(x) ((x).pgste) 96 #define pte_val(x) ((x).pte) 97 #define pmd_val(x) ((x).pmd) 98 #define pud_val(x) ((x).pud) 99 #define pgd_val(x) ((x).pgd) 100 101 #define __pgste(x) ((pgste_t) { (x) } ) 102 #define __pte(x) ((pte_t) { (x) } ) 103 #define __pmd(x) ((pmd_t) { (x) } ) 104 #define __pud(x) ((pud_t) { (x) } ) 105 #define __pgd(x) ((pgd_t) { (x) } ) 106 #define __pgprot(x) ((pgprot_t) { (x) } ) 107 108 static inline void page_set_storage_key(unsigned long addr, 109 unsigned char skey, int mapped) 110 { 111 if (!mapped) 112 asm volatile(".insn rrf,0xb22b0000,%0,%1,8,0" 113 : : "d" (skey), "a" (addr)); 114 else 115 asm volatile("sske %0,%1" : : "d" (skey), "a" (addr)); 116 } 117 118 static inline unsigned char page_get_storage_key(unsigned long addr) 119 { 120 unsigned char skey; 121 122 asm volatile("iske %0,%1" : "=d" (skey) : "a" (addr)); 123 return skey; 124 } 125 126 static inline int page_reset_referenced(unsigned long addr) 127 { 128 unsigned int ipm; 129 130 asm volatile( 131 " rrbe 0,%1\n" 132 " ipm %0\n" 133 : "=d" (ipm) : "a" (addr) : "cc"); 134 return !!(ipm & 0x20000000); 135 } 136 137 /* Bits int the storage key */ 138 #define _PAGE_CHANGED 0x02 /* HW changed bit */ 139 #define _PAGE_REFERENCED 0x04 /* HW referenced bit */ 140 #define _PAGE_FP_BIT 0x08 /* HW fetch protection bit */ 141 #define _PAGE_ACC_BITS 0xf0 /* HW access control bits */ 142 143 struct page; 144 void arch_free_page(struct page *page, int order); 145 void arch_alloc_page(struct page *page, int order); 146 void arch_set_page_states(int make_stable); 147 148 static inline int devmem_is_allowed(unsigned long pfn) 149 { 150 return 0; 151 } 152 153 #define HAVE_ARCH_FREE_PAGE 154 #define HAVE_ARCH_ALLOC_PAGE 155 156 #endif /* !__ASSEMBLY__ */ 157 158 #define __PAGE_OFFSET 0x0UL 159 #define PAGE_OFFSET 0x0UL 160 #define __pa(x) (unsigned long)(x) 161 #define __va(x) (void *)(unsigned long)(x) 162 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 163 #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) 164 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) 165 166 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \ 167 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) 168 169 #include <asm-generic/memory_model.h> 170 #include <asm-generic/getorder.h> 171 172 #define __HAVE_ARCH_GATE_AREA 1 173 174 #endif /* _S390_PAGE_H */ 175