Commit 08964c565b2fe49e338ffbe4907adcc19647ef16

Authored by Jeff Dike
Committed by Linus Torvalds
1 parent c56004901f

[PATCH] uml: merge duplicated page table code

There is a lot of code which is duplicated between the 2 and 3 level
implementation, with the only difference that the 3-level implementation is a
bit more generalized (instead of accessing directly pte_t.pte, it uses the
appropriate access macros).

So this code is joined together.

As obvious, a "core code nice cleanup" is not a "stability-friendly patch" so
usual care applies.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 3 changed files with 46 additions and 63 deletions Inline Diff

include/asm-um/pgtable-2level.h
1 /* 1 /*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Copyright 2003 PathScale, Inc. 3 * Copyright 2003 PathScale, Inc.
4 * Derived from include/asm-i386/pgtable.h 4 * Derived from include/asm-i386/pgtable.h
5 * Licensed under the GPL 5 * Licensed under the GPL
6 */ 6 */
7 7
8 #ifndef __UM_PGTABLE_2LEVEL_H 8 #ifndef __UM_PGTABLE_2LEVEL_H
9 #define __UM_PGTABLE_2LEVEL_H 9 #define __UM_PGTABLE_2LEVEL_H
10 10
11 #include <asm-generic/pgtable-nopmd.h> 11 #include <asm-generic/pgtable-nopmd.h>
12 12
13 /* PGDIR_SHIFT determines what a third-level page table entry can map */ 13 /* PGDIR_SHIFT determines what a third-level page table entry can map */
14 14
15 #define PGDIR_SHIFT 22 15 #define PGDIR_SHIFT 22
16 #define PGDIR_SIZE (1UL << PGDIR_SHIFT) 16 #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
17 #define PGDIR_MASK (~(PGDIR_SIZE-1)) 17 #define PGDIR_MASK (~(PGDIR_SIZE-1))
18 18
19 /* 19 /*
20 * entries per page directory level: the i386 is two-level, so 20 * entries per page directory level: the i386 is two-level, so
21 * we don't really have any PMD directory physically. 21 * we don't really have any PMD directory physically.
22 */ 22 */
23 #define PTRS_PER_PTE 1024 23 #define PTRS_PER_PTE 1024
24 #define USER_PTRS_PER_PGD ((TASK_SIZE + (PGDIR_SIZE - 1)) / PGDIR_SIZE) 24 #define USER_PTRS_PER_PGD ((TASK_SIZE + (PGDIR_SIZE - 1)) / PGDIR_SIZE)
25 #define PTRS_PER_PGD 1024 25 #define PTRS_PER_PGD 1024
26 #define FIRST_USER_ADDRESS 0 26 #define FIRST_USER_ADDRESS 0
27 27
28 #define pte_ERROR(e) \ 28 #define pte_ERROR(e) \
29 printk("%s:%d: bad pte %p(%08lx).\n", __FILE__, __LINE__, &(e), \ 29 printk("%s:%d: bad pte %p(%08lx).\n", __FILE__, __LINE__, &(e), \
30 pte_val(e)) 30 pte_val(e))
31 #define pgd_ERROR(e) \ 31 #define pgd_ERROR(e) \
32 printk("%s:%d: bad pgd %p(%08lx).\n", __FILE__, __LINE__, &(e), \ 32 printk("%s:%d: bad pgd %p(%08lx).\n", __FILE__, __LINE__, &(e), \
33 pgd_val(e)) 33 pgd_val(e))
34 34
35 static inline int pgd_newpage(pgd_t pgd) { return 0; } 35 static inline int pgd_newpage(pgd_t pgd) { return 0; }
36 static inline void pgd_mkuptodate(pgd_t pgd) { } 36 static inline void pgd_mkuptodate(pgd_t pgd) { }
37 37
38 #define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
39
40 static inline pte_t pte_mknewprot(pte_t pte)
41 {
42 pte_val(pte) |= _PAGE_NEWPROT;
43 return(pte);
44 }
45
46 static inline pte_t pte_mknewpage(pte_t pte)
47 {
48 pte_val(pte) |= _PAGE_NEWPAGE;
49 return(pte);
50 }
51
52 static inline void set_pte(pte_t *pteptr, pte_t pteval)
53 {
54 /* If it's a swap entry, it needs to be marked _PAGE_NEWPAGE so
55 * fix_range knows to unmap it. _PAGE_NEWPROT is specific to
56 * mapped pages.
57 */
58 *pteptr = pte_mknewpage(pteval);
59 if(pte_present(*pteptr)) *pteptr = pte_mknewprot(*pteptr);
60 }
61 #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
62
63 #define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval)) 38 #define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
64 39
65 #define pte_page(x) pfn_to_page(pte_pfn(x))
66 #define pte_none(x) !(pte_val(x) & ~_PAGE_NEWPAGE)
67 #define pte_pfn(x) phys_to_pfn(pte_val(x)) 40 #define pte_pfn(x) phys_to_pfn(pte_val(x))
68 #define pfn_pte(pfn, prot) __pte(pfn_to_phys(pfn) | pgprot_val(prot)) 41 #define pfn_pte(pfn, prot) __pte(pfn_to_phys(pfn) | pgprot_val(prot))
69 #define pfn_pmd(pfn, prot) __pmd(pfn_to_phys(pfn) | pgprot_val(prot)) 42 #define pfn_pmd(pfn, prot) __pmd(pfn_to_phys(pfn) | pgprot_val(prot))
70 43
71 #define pmd_page_kernel(pmd) \ 44 #define pmd_page_kernel(pmd) \
72 ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) 45 ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
73 46
74 /* 47 /*
75 * Bits 0 through 3 are taken 48 * Bits 0 through 3 are taken
76 */ 49 */
77 #define PTE_FILE_MAX_BITS 28 50 #define PTE_FILE_MAX_BITS 28
78 51
79 #define pte_to_pgoff(pte) (pte_val(pte) >> 4) 52 #define pte_to_pgoff(pte) (pte_val(pte) >> 4)
80 53
81 #define pgoff_to_pte(off) ((pte_t) { ((off) << 4) + _PAGE_FILE }) 54 #define pgoff_to_pte(off) ((pte_t) { ((off) << 4) + _PAGE_FILE })
82 55
83 #endif 56 #endif
84 57
include/asm-um/pgtable-3level.h
1 /* 1 /*
2 * Copyright 2003 PathScale Inc 2 * Copyright 2003 PathScale Inc
3 * Derived from include/asm-i386/pgtable.h 3 * Derived from include/asm-i386/pgtable.h
4 * Licensed under the GPL 4 * Licensed under the GPL
5 */ 5 */
6 6
7 #ifndef __UM_PGTABLE_3LEVEL_H 7 #ifndef __UM_PGTABLE_3LEVEL_H
8 #define __UM_PGTABLE_3LEVEL_H 8 #define __UM_PGTABLE_3LEVEL_H
9 9
10 #include <asm-generic/pgtable-nopud.h> 10 #include <asm-generic/pgtable-nopud.h>
11 11
12 /* PGDIR_SHIFT determines what a third-level page table entry can map */ 12 /* PGDIR_SHIFT determines what a third-level page table entry can map */
13 13
14 #define PGDIR_SHIFT 30 14 #define PGDIR_SHIFT 30
15 #define PGDIR_SIZE (1UL << PGDIR_SHIFT) 15 #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
16 #define PGDIR_MASK (~(PGDIR_SIZE-1)) 16 #define PGDIR_MASK (~(PGDIR_SIZE-1))
17 17
18 /* PMD_SHIFT determines the size of the area a second-level page table can 18 /* PMD_SHIFT determines the size of the area a second-level page table can
19 * map 19 * map
20 */ 20 */
21 21
22 #define PMD_SHIFT 21 22 #define PMD_SHIFT 21
23 #define PMD_SIZE (1UL << PMD_SHIFT) 23 #define PMD_SIZE (1UL << PMD_SHIFT)
24 #define PMD_MASK (~(PMD_SIZE-1)) 24 #define PMD_MASK (~(PMD_SIZE-1))
25 25
26 /* 26 /*
27 * entries per page directory level 27 * entries per page directory level
28 */ 28 */
29 29
30 #define PTRS_PER_PTE 512 30 #define PTRS_PER_PTE 512
31 #define PTRS_PER_PMD 512 31 #define PTRS_PER_PMD 512
32 #define USER_PTRS_PER_PGD ((TASK_SIZE + (PGDIR_SIZE - 1)) / PGDIR_SIZE) 32 #define USER_PTRS_PER_PGD ((TASK_SIZE + (PGDIR_SIZE - 1)) / PGDIR_SIZE)
33 #define PTRS_PER_PGD 512 33 #define PTRS_PER_PGD 512
34 #define FIRST_USER_ADDRESS 0 34 #define FIRST_USER_ADDRESS 0
35 35
36 #define pte_ERROR(e) \ 36 #define pte_ERROR(e) \
37 printk("%s:%d: bad pte %p(%016lx).\n", __FILE__, __LINE__, &(e), \ 37 printk("%s:%d: bad pte %p(%016lx).\n", __FILE__, __LINE__, &(e), \
38 pte_val(e)) 38 pte_val(e))
39 #define pmd_ERROR(e) \ 39 #define pmd_ERROR(e) \
40 printk("%s:%d: bad pmd %p(%016lx).\n", __FILE__, __LINE__, &(e), \ 40 printk("%s:%d: bad pmd %p(%016lx).\n", __FILE__, __LINE__, &(e), \
41 pmd_val(e)) 41 pmd_val(e))
42 #define pgd_ERROR(e) \ 42 #define pgd_ERROR(e) \
43 printk("%s:%d: bad pgd %p(%016lx).\n", __FILE__, __LINE__, &(e), \ 43 printk("%s:%d: bad pgd %p(%016lx).\n", __FILE__, __LINE__, &(e), \
44 pgd_val(e)) 44 pgd_val(e))
45 45
46 #define pud_none(x) (!(pud_val(x) & ~_PAGE_NEWPAGE)) 46 #define pud_none(x) (!(pud_val(x) & ~_PAGE_NEWPAGE))
47 #define pud_bad(x) ((pud_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) 47 #define pud_bad(x) ((pud_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
48 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT) 48 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
49 #define pud_populate(mm, pud, pmd) \ 49 #define pud_populate(mm, pud, pmd) \
50 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd))) 50 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
51 51
52 #define set_pud(pudptr, pudval) set_64bit((phys_t *) (pudptr), pud_val(pudval)) 52 #define set_pud(pudptr, pudval) set_64bit((phys_t *) (pudptr), pud_val(pudval))
53 static inline int pgd_newpage(pgd_t pgd) 53 static inline int pgd_newpage(pgd_t pgd)
54 { 54 {
55 return(pgd_val(pgd) & _PAGE_NEWPAGE); 55 return(pgd_val(pgd) & _PAGE_NEWPAGE);
56 } 56 }
57 57
58 static inline void pgd_mkuptodate(pgd_t pgd) { pgd_val(pgd) &= ~_PAGE_NEWPAGE; } 58 static inline void pgd_mkuptodate(pgd_t pgd) { pgd_val(pgd) &= ~_PAGE_NEWPAGE; }
59 59
60
61 #define pte_present(x) pte_get_bits(x, (_PAGE_PRESENT | _PAGE_PROTNONE))
62
63 static inline pte_t pte_mknewprot(pte_t pte)
64 {
65 pte_set_bits(pte, _PAGE_NEWPROT);
66 return(pte);
67 }
68
69 static inline pte_t pte_mknewpage(pte_t pte)
70 {
71 pte_set_bits(pte, _PAGE_NEWPAGE);
72 return(pte);
73 }
74
75 static inline void set_pte(pte_t *pteptr, pte_t pteval)
76 {
77 pte_copy(*pteptr, pteval);
78
79 /* If it's a swap entry, it needs to be marked _PAGE_NEWPAGE so
80 * fix_range knows to unmap it. _PAGE_NEWPROT is specific to
81 * mapped pages.
82 */
83
84 *pteptr = pte_mknewpage(*pteptr);
85 if(pte_present(*pteptr)) *pteptr = pte_mknewprot(*pteptr);
86 }
87 #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
88
89 #define set_pmd(pmdptr, pmdval) set_64bit((phys_t *) (pmdptr), pmd_val(pmdval)) 60 #define set_pmd(pmdptr, pmdval) set_64bit((phys_t *) (pmdptr), pmd_val(pmdval))
90 61
91 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) 62 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
92 { 63 {
93 pmd_t *pmd = (pmd_t *) __get_free_page(GFP_KERNEL); 64 pmd_t *pmd = (pmd_t *) __get_free_page(GFP_KERNEL);
94 65
95 if(pmd) 66 if(pmd)
96 memset(pmd, 0, PAGE_SIZE); 67 memset(pmd, 0, PAGE_SIZE);
97 68
98 return pmd; 69 return pmd;
99 } 70 }
100 71
101 static inline void pmd_free(pmd_t *pmd){ 72 static inline void pmd_free(pmd_t *pmd){
102 free_page((unsigned long) pmd); 73 free_page((unsigned long) pmd);
103 } 74 }
104 75
105 #define __pmd_free_tlb(tlb,x) do { } while (0) 76 #define __pmd_free_tlb(tlb,x) do { } while (0)
106 77
107 static inline void pud_clear (pud_t * pud) { } 78 static inline void pud_clear (pud_t * pud) { }
108 79
109 #define pud_page(pud) \ 80 #define pud_page(pud) \
110 ((struct page *) __va(pud_val(pud) & PAGE_MASK)) 81 ((struct page *) __va(pud_val(pud) & PAGE_MASK))
111 82
112 /* Find an entry in the second-level page table.. */ 83 /* Find an entry in the second-level page table.. */
113 #define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \ 84 #define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \
114 pmd_index(address)) 85 pmd_index(address))
115
116 #define pte_page(x) pfn_to_page(pte_pfn(x))
117
118 static inline int pte_none(pte_t pte)
119 {
120 return pte_is_zero(pte);
121 }
122 86
123 static inline unsigned long pte_pfn(pte_t pte) 87 static inline unsigned long pte_pfn(pte_t pte)
124 { 88 {
125 return phys_to_pfn(pte_val(pte)); 89 return phys_to_pfn(pte_val(pte));
126 } 90 }
127 91
128 static inline pte_t pfn_pte(pfn_t page_nr, pgprot_t pgprot) 92 static inline pte_t pfn_pte(pfn_t page_nr, pgprot_t pgprot)
129 { 93 {
130 pte_t pte; 94 pte_t pte;
131 phys_t phys = pfn_to_phys(page_nr); 95 phys_t phys = pfn_to_phys(page_nr);
132 96
133 pte_set_val(pte, phys, pgprot); 97 pte_set_val(pte, phys, pgprot);
134 return pte; 98 return pte;
135 } 99 }
136 100
137 static inline pmd_t pfn_pmd(pfn_t page_nr, pgprot_t pgprot) 101 static inline pmd_t pfn_pmd(pfn_t page_nr, pgprot_t pgprot)
138 { 102 {
139 return __pmd((page_nr << PAGE_SHIFT) | pgprot_val(pgprot)); 103 return __pmd((page_nr << PAGE_SHIFT) | pgprot_val(pgprot));
140 } 104 }
141 105
142 /* 106 /*
143 * Bits 0 through 3 are taken in the low part of the pte, 107 * Bits 0 through 3 are taken in the low part of the pte,
144 * put the 32 bits of offset into the high part. 108 * put the 32 bits of offset into the high part.
145 */ 109 */
146 #define PTE_FILE_MAX_BITS 32 110 #define PTE_FILE_MAX_BITS 32
147 111
148 #ifdef CONFIG_64BIT 112 #ifdef CONFIG_64BIT
149 113
150 #define pte_to_pgoff(p) ((p).pte >> 32) 114 #define pte_to_pgoff(p) ((p).pte >> 32)
151 115
152 #define pgoff_to_pte(off) ((pte_t) { ((off) << 32) | _PAGE_FILE }) 116 #define pgoff_to_pte(off) ((pte_t) { ((off) << 32) | _PAGE_FILE })
153 117
154 #else 118 #else
155 119
156 #define pte_to_pgoff(pte) ((pte).pte_high) 120 #define pte_to_pgoff(pte) ((pte).pte_high)
157 121
158 #define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) }) 122 #define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) })
159 123
160 #endif 124 #endif
161 125
162 #endif 126 #endif
163 127
164 /* 128 /*
165 * Overrides for Emacs so that we follow Linus's tabbing style. 129 * Overrides for Emacs so that we follow Linus's tabbing style.
166 * Emacs will notice this stuff at the end of the file and automatically 130 * Emacs will notice this stuff at the end of the file and automatically
167 * adjust the settings for this buffer only. This must remain at the end 131 * adjust the settings for this buffer only. This must remain at the end
168 * of the file. 132 * of the file.
169 * --------------------------------------------------------------------------- 133 * ---------------------------------------------------------------------------
170 * Local variables: 134 * Local variables:
171 * c-file-style: "linux" 135 * c-file-style: "linux"
172 * End: 136 * End:
173 */ 137 */
174 138
include/asm-um/pgtable.h
1 /* 1 /*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Copyright 2003 PathScale, Inc. 3 * Copyright 2003 PathScale, Inc.
4 * Derived from include/asm-i386/pgtable.h 4 * Derived from include/asm-i386/pgtable.h
5 * Licensed under the GPL 5 * Licensed under the GPL
6 */ 6 */
7 7
8 #ifndef __UM_PGTABLE_H 8 #ifndef __UM_PGTABLE_H
9 #define __UM_PGTABLE_H 9 #define __UM_PGTABLE_H
10 10
11 #include "linux/sched.h" 11 #include "linux/sched.h"
12 #include "linux/linkage.h" 12 #include "linux/linkage.h"
13 #include "asm/processor.h" 13 #include "asm/processor.h"
14 #include "asm/page.h" 14 #include "asm/page.h"
15 #include "asm/fixmap.h" 15 #include "asm/fixmap.h"
16 16
17 #define _PAGE_PRESENT 0x001 17 #define _PAGE_PRESENT 0x001
18 #define _PAGE_NEWPAGE 0x002 18 #define _PAGE_NEWPAGE 0x002
19 #define _PAGE_NEWPROT 0x004 19 #define _PAGE_NEWPROT 0x004
20 #define _PAGE_RW 0x020 20 #define _PAGE_RW 0x020
21 #define _PAGE_USER 0x040 21 #define _PAGE_USER 0x040
22 #define _PAGE_ACCESSED 0x080 22 #define _PAGE_ACCESSED 0x080
23 #define _PAGE_DIRTY 0x100 23 #define _PAGE_DIRTY 0x100
24 /* If _PAGE_PRESENT is clear, we use these: */ 24 /* If _PAGE_PRESENT is clear, we use these: */
25 #define _PAGE_FILE 0x008 /* nonlinear file mapping, saved PTE; unset:swap */ 25 #define _PAGE_FILE 0x008 /* nonlinear file mapping, saved PTE; unset:swap */
26 #define _PAGE_PROTNONE 0x010 /* if the user mapped it with PROT_NONE; 26 #define _PAGE_PROTNONE 0x010 /* if the user mapped it with PROT_NONE;
27 pte_present gives true */ 27 pte_present gives true */
28 28
29 #ifdef CONFIG_3_LEVEL_PGTABLES 29 #ifdef CONFIG_3_LEVEL_PGTABLES
30 #include "asm/pgtable-3level.h" 30 #include "asm/pgtable-3level.h"
31 #else 31 #else
32 #include "asm/pgtable-2level.h" 32 #include "asm/pgtable-2level.h"
33 #endif 33 #endif
34 34
35 extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; 35 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
36 36
37 extern void *um_virt_to_phys(struct task_struct *task, unsigned long virt, 37 extern void *um_virt_to_phys(struct task_struct *task, unsigned long virt,
38 pte_t *pte_out); 38 pte_t *pte_out);
39 39
40 /* zero page used for uninitialized stuff */ 40 /* zero page used for uninitialized stuff */
41 extern unsigned long *empty_zero_page; 41 extern unsigned long *empty_zero_page;
42 42
43 #define pgtable_cache_init() do ; while (0) 43 #define pgtable_cache_init() do ; while (0)
44 44
45 /* 45 /*
46 * pgd entries used up by user/kernel: 46 * pgd entries used up by user/kernel:
47 */ 47 */
48 48
49 #define USER_PGD_PTRS (TASK_SIZE >> PGDIR_SHIFT) 49 #define USER_PGD_PTRS (TASK_SIZE >> PGDIR_SHIFT)
50 #define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS) 50 #define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
51 51
52 #ifndef __ASSEMBLY__ 52 #ifndef __ASSEMBLY__
53 /* Just any arbitrary offset to the start of the vmalloc VM area: the 53 /* Just any arbitrary offset to the start of the vmalloc VM area: the
54 * current 8MB value just means that there will be a 8MB "hole" after the 54 * current 8MB value just means that there will be a 8MB "hole" after the
55 * physical memory until the kernel virtual memory starts. That means that 55 * physical memory until the kernel virtual memory starts. That means that
56 * any out-of-bounds memory accesses will hopefully be caught. 56 * any out-of-bounds memory accesses will hopefully be caught.
57 * The vmalloc() routines leaves a hole of 4kB between each vmalloced 57 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
58 * area for the same reason. ;) 58 * area for the same reason. ;)
59 */ 59 */
60 60
61 extern unsigned long end_iomem; 61 extern unsigned long end_iomem;
62 62
63 #define VMALLOC_OFFSET (__va_space) 63 #define VMALLOC_OFFSET (__va_space)
64 #define VMALLOC_START ((end_iomem + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)) 64 #define VMALLOC_START ((end_iomem + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
65 65
66 #ifdef CONFIG_HIGHMEM 66 #ifdef CONFIG_HIGHMEM
67 # define VMALLOC_END (PKMAP_BASE-2*PAGE_SIZE) 67 # define VMALLOC_END (PKMAP_BASE-2*PAGE_SIZE)
68 #else 68 #else
69 # define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) 69 # define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
70 #endif 70 #endif
71 71
72 #define REGION_SHIFT (sizeof(pte_t) * 8 - 4) 72 #define REGION_SHIFT (sizeof(pte_t) * 8 - 4)
73 #define REGION_MASK (((unsigned long) 0xf) << REGION_SHIFT) 73 #define REGION_MASK (((unsigned long) 0xf) << REGION_SHIFT)
74 74
75 #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY) 75 #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
76 #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) 76 #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
77 #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) 77 #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
78 78
79 #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED) 79 #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
80 #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED) 80 #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED)
81 #define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) 81 #define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
82 #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) 82 #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
83 #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED) 83 #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
84 #define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_DIRTY | _PAGE_ACCESSED) 84 #define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_DIRTY | _PAGE_ACCESSED)
85 85
86 /* 86 /*
87 * The i386 can't do page protection for execute, and considers that the same are read. 87 * The i386 can't do page protection for execute, and considers that the same are read.
88 * Also, write permissions imply read permissions. This is the closest we can get.. 88 * Also, write permissions imply read permissions. This is the closest we can get..
89 */ 89 */
90 #define __P000 PAGE_NONE 90 #define __P000 PAGE_NONE
91 #define __P001 PAGE_READONLY 91 #define __P001 PAGE_READONLY
92 #define __P010 PAGE_COPY 92 #define __P010 PAGE_COPY
93 #define __P011 PAGE_COPY 93 #define __P011 PAGE_COPY
94 #define __P100 PAGE_READONLY 94 #define __P100 PAGE_READONLY
95 #define __P101 PAGE_READONLY 95 #define __P101 PAGE_READONLY
96 #define __P110 PAGE_COPY 96 #define __P110 PAGE_COPY
97 #define __P111 PAGE_COPY 97 #define __P111 PAGE_COPY
98 98
99 #define __S000 PAGE_NONE 99 #define __S000 PAGE_NONE
100 #define __S001 PAGE_READONLY 100 #define __S001 PAGE_READONLY
101 #define __S010 PAGE_SHARED 101 #define __S010 PAGE_SHARED
102 #define __S011 PAGE_SHARED 102 #define __S011 PAGE_SHARED
103 #define __S100 PAGE_READONLY 103 #define __S100 PAGE_READONLY
104 #define __S101 PAGE_READONLY 104 #define __S101 PAGE_READONLY
105 #define __S110 PAGE_SHARED 105 #define __S110 PAGE_SHARED
106 #define __S111 PAGE_SHARED 106 #define __S111 PAGE_SHARED
107 107
108 /* 108 /*
109 * Define this if things work differently on an i386 and an i486: 109 * Define this if things work differently on an i386 and an i486:
110 * it will (on an i486) warn about kernel memory accesses that are 110 * it will (on an i486) warn about kernel memory accesses that are
111 * done without a 'access_ok(VERIFY_WRITE,..)' 111 * done without a 'access_ok(VERIFY_WRITE,..)'
112 */ 112 */
113 #undef TEST_VERIFY_AREA 113 #undef TEST_VERIFY_AREA
114 114
115 /* page table for 0-4MB for everybody */ 115 /* page table for 0-4MB for everybody */
116 extern unsigned long pg0[1024]; 116 extern unsigned long pg0[1024];
117 117
118 /* 118 /*
119 * ZERO_PAGE is a global shared page that is always zero: used 119 * ZERO_PAGE is a global shared page that is always zero: used
120 * for zero-mapped memory areas etc.. 120 * for zero-mapped memory areas etc..
121 */ 121 */
122 122
123 #define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page) 123 #define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page)
124 124
125 /* number of bits that fit into a memory pointer */ 125 /* number of bits that fit into a memory pointer */
126 #define BITS_PER_PTR (8*sizeof(unsigned long)) 126 #define BITS_PER_PTR (8*sizeof(unsigned long))
127 127
128 /* to align the pointer to a pointer address */ 128 /* to align the pointer to a pointer address */
129 #define PTR_MASK (~(sizeof(void*)-1)) 129 #define PTR_MASK (~(sizeof(void*)-1))
130 130
131 /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */ 131 /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */
132 /* 64-bit machines, beware! SRB. */ 132 /* 64-bit machines, beware! SRB. */
133 #define SIZEOF_PTR_LOG2 3 133 #define SIZEOF_PTR_LOG2 3
134 134
135 /* to find an entry in a page-table */ 135 /* to find an entry in a page-table */
136 #define PAGE_PTR(address) \ 136 #define PAGE_PTR(address) \
137 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK) 137 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
138 138
139 #define pte_clear(mm,addr,xp) pte_set_val(*(xp), (phys_t) 0, __pgprot(_PAGE_NEWPAGE)) 139 #define pte_clear(mm,addr,xp) pte_set_val(*(xp), (phys_t) 0, __pgprot(_PAGE_NEWPAGE))
140 140
141 #define pmd_none(x) (!(pmd_val(x) & ~_PAGE_NEWPAGE)) 141 #define pmd_none(x) (!(pmd_val(x) & ~_PAGE_NEWPAGE))
142 #define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) 142 #define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
143 #define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 143 #define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
144 #define pmd_clear(xp) do { pmd_val(*(xp)) = _PAGE_NEWPAGE; } while (0) 144 #define pmd_clear(xp) do { pmd_val(*(xp)) = _PAGE_NEWPAGE; } while (0)
145 145
146 #define pmd_newpage(x) (pmd_val(x) & _PAGE_NEWPAGE) 146 #define pmd_newpage(x) (pmd_val(x) & _PAGE_NEWPAGE)
147 #define pmd_mkuptodate(x) (pmd_val(x) &= ~_PAGE_NEWPAGE) 147 #define pmd_mkuptodate(x) (pmd_val(x) &= ~_PAGE_NEWPAGE)
148 148
149 #define pud_newpage(x) (pud_val(x) & _PAGE_NEWPAGE) 149 #define pud_newpage(x) (pud_val(x) & _PAGE_NEWPAGE)
150 #define pud_mkuptodate(x) (pud_val(x) &= ~_PAGE_NEWPAGE) 150 #define pud_mkuptodate(x) (pud_val(x) &= ~_PAGE_NEWPAGE)
151 151
152 #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) 152 #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
153 153
154 #define pmd_page(pmd) phys_to_page(pmd_val(pmd) & PAGE_MASK) 154 #define pmd_page(pmd) phys_to_page(pmd_val(pmd) & PAGE_MASK)
155 155
156 #define pte_page(x) pfn_to_page(pte_pfn(x))
156 #define pte_address(x) (__va(pte_val(x) & PAGE_MASK)) 157 #define pte_address(x) (__va(pte_val(x) & PAGE_MASK))
157 #define mk_phys(a, r) ((a) + (((unsigned long) r) << REGION_SHIFT)) 158 #define mk_phys(a, r) ((a) + (((unsigned long) r) << REGION_SHIFT))
158 #define phys_addr(p) ((p) & ~REGION_MASK) 159 #define phys_addr(p) ((p) & ~REGION_MASK)
159 160
161 #define pte_present(x) pte_get_bits(x, (_PAGE_PRESENT | _PAGE_PROTNONE))
162
160 /* 163 /*
164 * =================================
165 * Flags checking section.
166 * =================================
167 */
168
169 static inline int pte_none(pte_t pte)
170 {
171 return pte_is_zero(pte);
172 }
173
174 /*
161 * The following only work if pte_present() is true. 175 * The following only work if pte_present() is true.
162 * Undefined behaviour if not.. 176 * Undefined behaviour if not..
163 */ 177 */
164 static inline int pte_user(pte_t pte) 178 static inline int pte_user(pte_t pte)
165 { 179 {
166 return((pte_get_bits(pte, _PAGE_USER)) && 180 return((pte_get_bits(pte, _PAGE_USER)) &&
167 !(pte_get_bits(pte, _PAGE_PROTNONE))); 181 !(pte_get_bits(pte, _PAGE_PROTNONE)));
168 } 182 }
169 183
170 static inline int pte_read(pte_t pte) 184 static inline int pte_read(pte_t pte)
171 { 185 {
172 return((pte_get_bits(pte, _PAGE_USER)) && 186 return((pte_get_bits(pte, _PAGE_USER)) &&
173 !(pte_get_bits(pte, _PAGE_PROTNONE))); 187 !(pte_get_bits(pte, _PAGE_PROTNONE)));
174 } 188 }
175 189
176 static inline int pte_exec(pte_t pte){ 190 static inline int pte_exec(pte_t pte){
177 return((pte_get_bits(pte, _PAGE_USER)) && 191 return((pte_get_bits(pte, _PAGE_USER)) &&
178 !(pte_get_bits(pte, _PAGE_PROTNONE))); 192 !(pte_get_bits(pte, _PAGE_PROTNONE)));
179 } 193 }
180 194
181 static inline int pte_write(pte_t pte) 195 static inline int pte_write(pte_t pte)
182 { 196 {
183 return((pte_get_bits(pte, _PAGE_RW)) && 197 return((pte_get_bits(pte, _PAGE_RW)) &&
184 !(pte_get_bits(pte, _PAGE_PROTNONE))); 198 !(pte_get_bits(pte, _PAGE_PROTNONE)));
185 } 199 }
186 200
187 /* 201 /*
188 * The following only works if pte_present() is not true. 202 * The following only works if pte_present() is not true.
189 */ 203 */
190 static inline int pte_file(pte_t pte) 204 static inline int pte_file(pte_t pte)
191 { 205 {
192 return pte_get_bits(pte, _PAGE_FILE); 206 return pte_get_bits(pte, _PAGE_FILE);
193 } 207 }
194 208
195 static inline int pte_dirty(pte_t pte) 209 static inline int pte_dirty(pte_t pte)
196 { 210 {
197 return pte_get_bits(pte, _PAGE_DIRTY); 211 return pte_get_bits(pte, _PAGE_DIRTY);
198 } 212 }
199 213
200 static inline int pte_young(pte_t pte) 214 static inline int pte_young(pte_t pte)
201 { 215 {
202 return pte_get_bits(pte, _PAGE_ACCESSED); 216 return pte_get_bits(pte, _PAGE_ACCESSED);
203 } 217 }
204 218
205 static inline int pte_newpage(pte_t pte) 219 static inline int pte_newpage(pte_t pte)
206 { 220 {
207 return pte_get_bits(pte, _PAGE_NEWPAGE); 221 return pte_get_bits(pte, _PAGE_NEWPAGE);
208 } 222 }
209 223
210 static inline int pte_newprot(pte_t pte) 224 static inline int pte_newprot(pte_t pte)
211 { 225 {
212 return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT))); 226 return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT)));
213 } 227 }
214 228
229 /*
230 * =================================
231 * Flags setting section.
232 * =================================
233 */
234
235 static inline pte_t pte_mknewprot(pte_t pte)
236 {
237 pte_set_bits(pte, _PAGE_NEWPROT);
238 return(pte);
239 }
240
215 static inline pte_t pte_rdprotect(pte_t pte) 241 static inline pte_t pte_rdprotect(pte_t pte)
216 { 242 {
217 pte_clear_bits(pte, _PAGE_USER); 243 pte_clear_bits(pte, _PAGE_USER);
218 return(pte_mknewprot(pte)); 244 return(pte_mknewprot(pte));
219 } 245 }
220 246
221 static inline pte_t pte_exprotect(pte_t pte) 247 static inline pte_t pte_exprotect(pte_t pte)
222 { 248 {
223 pte_clear_bits(pte, _PAGE_USER); 249 pte_clear_bits(pte, _PAGE_USER);
224 return(pte_mknewprot(pte)); 250 return(pte_mknewprot(pte));
225 } 251 }
226 252
227 static inline pte_t pte_mkclean(pte_t pte) 253 static inline pte_t pte_mkclean(pte_t pte)
228 { 254 {
229 pte_clear_bits(pte, _PAGE_DIRTY); 255 pte_clear_bits(pte, _PAGE_DIRTY);
230 return(pte); 256 return(pte);
231 } 257 }
232 258
233 static inline pte_t pte_mkold(pte_t pte) 259 static inline pte_t pte_mkold(pte_t pte)
234 { 260 {
235 pte_clear_bits(pte, _PAGE_ACCESSED); 261 pte_clear_bits(pte, _PAGE_ACCESSED);
236 return(pte); 262 return(pte);
237 } 263 }
238 264
239 static inline pte_t pte_wrprotect(pte_t pte) 265 static inline pte_t pte_wrprotect(pte_t pte)
240 { 266 {
241 pte_clear_bits(pte, _PAGE_RW); 267 pte_clear_bits(pte, _PAGE_RW);
242 return(pte_mknewprot(pte)); 268 return(pte_mknewprot(pte));
243 } 269 }
244 270
245 static inline pte_t pte_mkread(pte_t pte) 271 static inline pte_t pte_mkread(pte_t pte)
246 { 272 {
247 pte_set_bits(pte, _PAGE_RW); 273 pte_set_bits(pte, _PAGE_RW);
248 return(pte_mknewprot(pte)); 274 return(pte_mknewprot(pte));
249 } 275 }
250 276
251 static inline pte_t pte_mkexec(pte_t pte) 277 static inline pte_t pte_mkexec(pte_t pte)
252 { 278 {
253 pte_set_bits(pte, _PAGE_USER); 279 pte_set_bits(pte, _PAGE_USER);
254 return(pte_mknewprot(pte)); 280 return(pte_mknewprot(pte));
255 } 281 }
256 282
257 static inline pte_t pte_mkdirty(pte_t pte) 283 static inline pte_t pte_mkdirty(pte_t pte)
258 { 284 {
259 pte_set_bits(pte, _PAGE_DIRTY); 285 pte_set_bits(pte, _PAGE_DIRTY);
260 return(pte); 286 return(pte);
261 } 287 }
262 288
263 static inline pte_t pte_mkyoung(pte_t pte) 289 static inline pte_t pte_mkyoung(pte_t pte)
264 { 290 {
265 pte_set_bits(pte, _PAGE_ACCESSED); 291 pte_set_bits(pte, _PAGE_ACCESSED);
266 return(pte); 292 return(pte);
267 } 293 }
268 294
269 static inline pte_t pte_mkwrite(pte_t pte) 295 static inline pte_t pte_mkwrite(pte_t pte)
270 { 296 {
271 pte_set_bits(pte, _PAGE_RW); 297 pte_set_bits(pte, _PAGE_RW);
272 return(pte_mknewprot(pte)); 298 return(pte_mknewprot(pte));
273 } 299 }
274 300
275 static inline pte_t pte_mkuptodate(pte_t pte) 301 static inline pte_t pte_mkuptodate(pte_t pte)
276 { 302 {
277 pte_clear_bits(pte, _PAGE_NEWPAGE); 303 pte_clear_bits(pte, _PAGE_NEWPAGE);
278 if(pte_present(pte)) 304 if(pte_present(pte))
279 pte_clear_bits(pte, _PAGE_NEWPROT); 305 pte_clear_bits(pte, _PAGE_NEWPROT);
280 return(pte); 306 return(pte);
281 } 307 }
308
309 static inline pte_t pte_mknewpage(pte_t pte)
310 {
311 pte_set_bits(pte, _PAGE_NEWPAGE);
312 return(pte);
313 }
314
315 static inline void set_pte(pte_t *pteptr, pte_t pteval)
316 {
317 pte_copy(*pteptr, pteval);
318
319 /* If it's a swap entry, it needs to be marked _PAGE_NEWPAGE so
320 * fix_range knows to unmap it. _PAGE_NEWPROT is specific to
321 * mapped pages.
322 */
323
324 *pteptr = pte_mknewpage(*pteptr);
325 if(pte_present(*pteptr)) *pteptr = pte_mknewprot(*pteptr);
326 }
327 #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
282 328
283 extern phys_t page_to_phys(struct page *page); 329 extern phys_t page_to_phys(struct page *page);
284 330
285 /* 331 /*
286 * Conversion functions: convert a page and protection to a page entry, 332 * Conversion functions: convert a page and protection to a page entry,
287 * and a page entry and page directory to the page they refer to. 333 * and a page entry and page directory to the page they refer to.
288 */ 334 */
289 335
290 extern pte_t mk_pte(struct page *page, pgprot_t pgprot); 336 extern pte_t mk_pte(struct page *page, pgprot_t pgprot);
291 337
292 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 338 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
293 { 339 {
294 pte_set_val(pte, (pte_val(pte) & _PAGE_CHG_MASK), newprot); 340 pte_set_val(pte, (pte_val(pte) & _PAGE_CHG_MASK), newprot);
295 if(pte_present(pte)) pte = pte_mknewpage(pte_mknewprot(pte)); 341 if(pte_present(pte)) pte = pte_mknewpage(pte_mknewprot(pte));
296 return pte; 342 return pte;
297 } 343 }
298 344
299 #define pmd_page_kernel(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) 345 #define pmd_page_kernel(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
300 346
301 /* 347 /*
302 * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD] 348 * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD]
303 * 349 *
304 * this macro returns the index of the entry in the pgd page which would 350 * this macro returns the index of the entry in the pgd page which would
305 * control the given virtual address 351 * control the given virtual address
306 */ 352 */
307 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) 353 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
308 354
309 #define pgd_index_k(addr) pgd_index(addr) 355 #define pgd_index_k(addr) pgd_index(addr)
310 356
311 /* 357 /*
312 * pgd_offset() returns a (pgd_t *) 358 * pgd_offset() returns a (pgd_t *)
313 * pgd_index() is used get the offset into the pgd page's array of pgd_t's; 359 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
314 */ 360 */
315 #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) 361 #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
316 362
317 /* 363 /*
318 * a shortcut which implies the use of the kernel's pgd, instead 364 * a shortcut which implies the use of the kernel's pgd, instead
319 * of a process's 365 * of a process's
320 */ 366 */
321 #define pgd_offset_k(address) pgd_offset(&init_mm, address) 367 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
322 368
323 /* 369 /*
324 * the pmd page can be thought of an array like this: pmd_t[PTRS_PER_PMD] 370 * the pmd page can be thought of an array like this: pmd_t[PTRS_PER_PMD]
325 * 371 *
326 * this macro returns the index of the entry in the pmd page which would 372 * this macro returns the index of the entry in the pmd page which would
327 * control the given virtual address 373 * control the given virtual address
328 */ 374 */
329 #define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) 375 #define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
330 376
331 /* 377 /*
332 * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE] 378 * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
333 * 379 *
334 * this macro returns the index of the entry in the pte page which would 380 * this macro returns the index of the entry in the pte page which would
335 * control the given virtual address 381 * control the given virtual address
336 */ 382 */
337 #define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) 383 #define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
338 #define pte_offset_kernel(dir, address) \ 384 #define pte_offset_kernel(dir, address) \
339 ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(address)) 385 ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(address))
340 #define pte_offset_map(dir, address) \ 386 #define pte_offset_map(dir, address) \
341 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) 387 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
342 #define pte_offset_map_nested(dir, address) pte_offset_map(dir, address) 388 #define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
343 #define pte_unmap(pte) do { } while (0) 389 #define pte_unmap(pte) do { } while (0)
344 #define pte_unmap_nested(pte) do { } while (0) 390 #define pte_unmap_nested(pte) do { } while (0)
345 391
346 #define update_mmu_cache(vma,address,pte) do ; while (0) 392 #define update_mmu_cache(vma,address,pte) do ; while (0)
347 393
348 /* Encode and de-code a swap entry */ 394 /* Encode and de-code a swap entry */
349 #define __swp_type(x) (((x).val >> 4) & 0x3f) 395 #define __swp_type(x) (((x).val >> 4) & 0x3f)
350 #define __swp_offset(x) ((x).val >> 11) 396 #define __swp_offset(x) ((x).val >> 11)
351 397
352 #define __swp_entry(type, offset) \ 398 #define __swp_entry(type, offset) \
353 ((swp_entry_t) { ((type) << 4) | ((offset) << 11) }) 399 ((swp_entry_t) { ((type) << 4) | ((offset) << 11) })
354 #define __pte_to_swp_entry(pte) \ 400 #define __pte_to_swp_entry(pte) \
355 ((swp_entry_t) { pte_val(pte_mkuptodate(pte)) }) 401 ((swp_entry_t) { pte_val(pte_mkuptodate(pte)) })
356 #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 402 #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
357 403
358 #define kern_addr_valid(addr) (1) 404 #define kern_addr_valid(addr) (1)
359 405
360 #include <asm-generic/pgtable.h> 406 #include <asm-generic/pgtable.h>
361 407
362 #include <asm-generic/pgtable-nopud.h> 408 #include <asm-generic/pgtable-nopud.h>
363 409
364 #endif 410 #endif
365 #endif 411 #endif
366 412
367 extern struct page *phys_to_page(const unsigned long phys); 413 extern struct page *phys_to_page(const unsigned long phys);
368 extern struct page *__virt_to_page(const unsigned long virt); 414 extern struct page *__virt_to_page(const unsigned long virt);
369 #define virt_to_page(addr) __virt_to_page((const unsigned long) addr) 415 #define virt_to_page(addr) __virt_to_page((const unsigned long) addr)
370 416
371 /* 417 /*
372 * Overrides for Emacs so that we follow Linus's tabbing style. 418 * Overrides for Emacs so that we follow Linus's tabbing style.
373 * Emacs will notice this stuff at the end of the file and automatically 419 * Emacs will notice this stuff at the end of the file and automatically
374 * adjust the settings for this buffer only. This must remain at the end 420 * adjust the settings for this buffer only. This must remain at the end
375 * of the file. 421 * of the file.
376 * --------------------------------------------------------------------------- 422 * ---------------------------------------------------------------------------
377 * Local variables: 423 * Local variables:
378 * c-file-style: "linux" 424 * c-file-style: "linux"
379 * End: 425 * End:
380 */ 426 */
381 427