aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile/include/asm/page.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/tile/include/asm/page.h')
-rw-r--r--arch/tile/include/asm/page.h71
1 files changed, 32 insertions, 39 deletions
diff --git a/arch/tile/include/asm/page.h b/arch/tile/include/asm/page.h
index 7d90641cf18d..db93518fac03 100644
--- a/arch/tile/include/asm/page.h
+++ b/arch/tile/include/asm/page.h
@@ -16,10 +16,12 @@
16#define _ASM_TILE_PAGE_H 16#define _ASM_TILE_PAGE_H
17 17
18#include <linux/const.h> 18#include <linux/const.h>
19#include <hv/hypervisor.h>
20#include <arch/chip.h>
19 21
20/* PAGE_SHIFT and HPAGE_SHIFT determine the page sizes. */ 22/* PAGE_SHIFT and HPAGE_SHIFT determine the page sizes. */
21#define PAGE_SHIFT 16 23#define PAGE_SHIFT HV_LOG2_PAGE_SIZE_SMALL
22#define HPAGE_SHIFT 24 24#define HPAGE_SHIFT HV_LOG2_PAGE_SIZE_LARGE
23 25
24#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT) 26#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
25#define HPAGE_SIZE (_AC(1, UL) << HPAGE_SHIFT) 27#define HPAGE_SIZE (_AC(1, UL) << HPAGE_SHIFT)
@@ -27,25 +29,13 @@
27#define PAGE_MASK (~(PAGE_SIZE - 1)) 29#define PAGE_MASK (~(PAGE_SIZE - 1))
28#define HPAGE_MASK (~(HPAGE_SIZE - 1)) 30#define HPAGE_MASK (~(HPAGE_SIZE - 1))
29 31
30#ifdef __KERNEL__
31
32#include <hv/hypervisor.h>
33#include <arch/chip.h>
34
35/* 32/*
36 * The {,H}PAGE_SHIFT values must match the HV_LOG2_PAGE_SIZE_xxx 33 * If the Kconfig doesn't specify, set a maximum zone order that
37 * definitions in <hv/hypervisor.h>. We validate this at build time 34 * is enough so that we can create huge pages from small pages given
38 * here, and again at runtime during early boot. We provide a 35 * the respective sizes of the two page types. See <linux/mmzone.h>.
39 * separate definition since userspace doesn't have <hv/hypervisor.h>.
40 *
41 * Be careful to distinguish PAGE_SHIFT from HV_PTE_INDEX_PFN, since
42 * they are the same on i386 but not TILE.
43 */ 36 */
44#if HV_LOG2_PAGE_SIZE_SMALL != PAGE_SHIFT 37#ifndef CONFIG_FORCE_MAX_ZONEORDER
45# error Small page size mismatch in Linux 38#define CONFIG_FORCE_MAX_ZONEORDER (HPAGE_SHIFT - PAGE_SHIFT + 1)
46#endif
47#if HV_LOG2_PAGE_SIZE_LARGE != HPAGE_SHIFT
48# error Huge page size mismatch in Linux
49#endif 39#endif
50 40
51#ifndef __ASSEMBLY__ 41#ifndef __ASSEMBLY__
@@ -81,12 +71,6 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
81 * Hypervisor page tables are made of the same basic structure. 71 * Hypervisor page tables are made of the same basic structure.
82 */ 72 */
83 73
84typedef __u64 pteval_t;
85typedef __u64 pmdval_t;
86typedef __u64 pudval_t;
87typedef __u64 pgdval_t;
88typedef __u64 pgprotval_t;
89
90typedef HV_PTE pte_t; 74typedef HV_PTE pte_t;
91typedef HV_PTE pgd_t; 75typedef HV_PTE pgd_t;
92typedef HV_PTE pgprot_t; 76typedef HV_PTE pgprot_t;
@@ -103,6 +87,10 @@ typedef struct page *pgtable_t;
103/* Must be a macro since it is used to create constants. */ 87/* Must be a macro since it is used to create constants. */
104#define __pgprot(val) hv_pte(val) 88#define __pgprot(val) hv_pte(val)
105 89
90/* Rarely-used initializers, typically with a "zero" value. */
91#define __pte(x) hv_pte(x)
92#define __pgd(x) hv_pte(x)
93
106static inline u64 pgprot_val(pgprot_t pgprot) 94static inline u64 pgprot_val(pgprot_t pgprot)
107{ 95{
108 return hv_pte_val(pgprot); 96 return hv_pte_val(pgprot);
@@ -122,6 +110,8 @@ static inline u64 pgd_val(pgd_t pgd)
122 110
123typedef HV_PTE pmd_t; 111typedef HV_PTE pmd_t;
124 112
113#define __pmd(x) hv_pte(x)
114
125static inline u64 pmd_val(pmd_t pmd) 115static inline u64 pmd_val(pmd_t pmd)
126{ 116{
127 return hv_pte_val(pmd); 117 return hv_pte_val(pmd);
@@ -199,17 +189,17 @@ static inline __attribute_const__ int get_order(unsigned long size)
199 * If you want more physical memory than this then see the CONFIG_HIGHMEM 189 * If you want more physical memory than this then see the CONFIG_HIGHMEM
200 * option in the kernel configuration. 190 * option in the kernel configuration.
201 * 191 *
202 * The top two 16MB chunks in the table below (VIRT and HV) are 192 * The top 16MB chunk in the table below is unavailable to Linux. Since
203 * unavailable to Linux. Since the kernel interrupt vectors must live 193 * the kernel interrupt vectors must live at ether 0xfe000000 or 0xfd000000
204 * at 0xfd000000, we map all of the bottom of RAM at this address with 194 * (depending on whether the kernel is at PL2 or Pl1), we map all of the
205 * a huge page table entry to minimize its ITLB footprint (as well as 195 * bottom of RAM at this address with a huge page table entry to minimize
206 * at PAGE_OFFSET). The last architected requirement is that user 196 * its ITLB footprint (as well as at PAGE_OFFSET). The last architected
207 * interrupt vectors live at 0xfc000000, so we make that range of 197 * requirement is that user interrupt vectors live at 0xfc000000, so we
208 * memory available to user processes. The remaining regions are sized 198 * make that range of memory available to user processes. The remaining
209 * as shown; after the first four addresses, we show "typical" values, 199 * regions are sized as shown; the first four addresses use the PL 1
210 * since the actual addresses depend on kernel #defines. 200 * values, and after that, we show "typical" values, since the actual
201 * addresses depend on kernel #defines.
211 * 202 *
212 * MEM_VIRT_INTRPT 0xff000000
213 * MEM_HV_INTRPT 0xfe000000 203 * MEM_HV_INTRPT 0xfe000000
214 * MEM_SV_INTRPT (kernel code) 0xfd000000 204 * MEM_SV_INTRPT (kernel code) 0xfd000000
215 * MEM_USER_INTRPT (user vector) 0xfc000000 205 * MEM_USER_INTRPT (user vector) 0xfc000000
@@ -221,9 +211,14 @@ static inline __attribute_const__ int get_order(unsigned long size)
221 */ 211 */
222 212
223#define MEM_USER_INTRPT _AC(0xfc000000, UL) 213#define MEM_USER_INTRPT _AC(0xfc000000, UL)
214#if CONFIG_KERNEL_PL == 1
224#define MEM_SV_INTRPT _AC(0xfd000000, UL) 215#define MEM_SV_INTRPT _AC(0xfd000000, UL)
225#define MEM_HV_INTRPT _AC(0xfe000000, UL) 216#define MEM_HV_INTRPT _AC(0xfe000000, UL)
226#define MEM_VIRT_INTRPT _AC(0xff000000, UL) 217#else
218#define MEM_GUEST_INTRPT _AC(0xfd000000, UL)
219#define MEM_SV_INTRPT _AC(0xfe000000, UL)
220#define MEM_HV_INTRPT _AC(0xff000000, UL)
221#endif
227 222
228#define INTRPT_SIZE 0x4000 223#define INTRPT_SIZE 0x4000
229 224
@@ -325,7 +320,7 @@ static inline int pfn_valid(unsigned long pfn)
325 320
326/* Provide as macros since these require some other headers included. */ 321/* Provide as macros since these require some other headers included. */
327#define page_to_pa(page) ((phys_addr_t)(page_to_pfn(page)) << PAGE_SHIFT) 322#define page_to_pa(page) ((phys_addr_t)(page_to_pfn(page)) << PAGE_SHIFT)
328#define virt_to_page(kaddr) pfn_to_page(kaddr_to_pfn(kaddr)) 323#define virt_to_page(kaddr) pfn_to_page(kaddr_to_pfn((void *)(kaddr)))
329#define page_to_virt(page) pfn_to_kaddr(page_to_pfn(page)) 324#define page_to_virt(page) pfn_to_kaddr(page_to_pfn(page))
330 325
331struct mm_struct; 326struct mm_struct;
@@ -338,6 +333,4 @@ extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
338 333
339#include <asm-generic/memory_model.h> 334#include <asm-generic/memory_model.h>
340 335
341#endif /* __KERNEL__ */
342
343#endif /* _ASM_TILE_PAGE_H */ 336#endif /* _ASM_TILE_PAGE_H */