diff options
Diffstat (limited to 'arch/i386/mm')
-rw-r--r-- | arch/i386/mm/boot_ioremap.c | 1 | ||||
-rw-r--r-- | arch/i386/mm/discontig.c | 2 | ||||
-rw-r--r-- | arch/i386/mm/fault.c | 12 | ||||
-rw-r--r-- | arch/i386/mm/highmem.c | 26 | ||||
-rw-r--r-- | arch/i386/mm/hugetlbpage.c | 112 | ||||
-rw-r--r-- | arch/i386/mm/init.c | 6 | ||||
-rw-r--r-- | arch/i386/mm/pageattr.c | 24 | ||||
-rw-r--r-- | arch/i386/mm/pgtable.c | 13 |
8 files changed, 157 insertions, 39 deletions
diff --git a/arch/i386/mm/boot_ioremap.c b/arch/i386/mm/boot_ioremap.c index 4de11f508c3a..4de95a17a7d4 100644 --- a/arch/i386/mm/boot_ioremap.c +++ b/arch/i386/mm/boot_ioremap.c | |||
@@ -16,6 +16,7 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #undef CONFIG_X86_PAE | 18 | #undef CONFIG_X86_PAE |
19 | #undef CONFIG_PARAVIRT | ||
19 | #include <asm/page.h> | 20 | #include <asm/page.h> |
20 | #include <asm/pgtable.h> | 21 | #include <asm/pgtable.h> |
21 | #include <asm/tlbflush.h> | 22 | #include <asm/tlbflush.h> |
diff --git a/arch/i386/mm/discontig.c b/arch/i386/mm/discontig.c index ddbdb0336f28..103b76e56a94 100644 --- a/arch/i386/mm/discontig.c +++ b/arch/i386/mm/discontig.c | |||
@@ -168,7 +168,7 @@ static void __init allocate_pgdat(int nid) | |||
168 | if (nid && node_has_online_mem(nid)) | 168 | if (nid && node_has_online_mem(nid)) |
169 | NODE_DATA(nid) = (pg_data_t *)node_remap_start_vaddr[nid]; | 169 | NODE_DATA(nid) = (pg_data_t *)node_remap_start_vaddr[nid]; |
170 | else { | 170 | else { |
171 | NODE_DATA(nid) = (pg_data_t *)(__va(min_low_pfn << PAGE_SHIFT)); | 171 | NODE_DATA(nid) = (pg_data_t *)(pfn_to_kaddr(min_low_pfn)); |
172 | min_low_pfn += PFN_UP(sizeof(pg_data_t)); | 172 | min_low_pfn += PFN_UP(sizeof(pg_data_t)); |
173 | } | 173 | } |
174 | } | 174 | } |
diff --git a/arch/i386/mm/fault.c b/arch/i386/mm/fault.c index 2581575786c1..aaaa4d225f7e 100644 --- a/arch/i386/mm/fault.c +++ b/arch/i386/mm/fault.c | |||
@@ -22,9 +22,9 @@ | |||
22 | #include <linux/highmem.h> | 22 | #include <linux/highmem.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/kprobes.h> | 24 | #include <linux/kprobes.h> |
25 | #include <linux/uaccess.h> | ||
25 | 26 | ||
26 | #include <asm/system.h> | 27 | #include <asm/system.h> |
27 | #include <asm/uaccess.h> | ||
28 | #include <asm/desc.h> | 28 | #include <asm/desc.h> |
29 | #include <asm/kdebug.h> | 29 | #include <asm/kdebug.h> |
30 | #include <asm/segment.h> | 30 | #include <asm/segment.h> |
@@ -167,7 +167,7 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs, | |||
167 | static int __is_prefetch(struct pt_regs *regs, unsigned long addr) | 167 | static int __is_prefetch(struct pt_regs *regs, unsigned long addr) |
168 | { | 168 | { |
169 | unsigned long limit; | 169 | unsigned long limit; |
170 | unsigned long instr = get_segment_eip (regs, &limit); | 170 | unsigned char *instr = (unsigned char *)get_segment_eip (regs, &limit); |
171 | int scan_more = 1; | 171 | int scan_more = 1; |
172 | int prefetch = 0; | 172 | int prefetch = 0; |
173 | int i; | 173 | int i; |
@@ -177,9 +177,9 @@ static int __is_prefetch(struct pt_regs *regs, unsigned long addr) | |||
177 | unsigned char instr_hi; | 177 | unsigned char instr_hi; |
178 | unsigned char instr_lo; | 178 | unsigned char instr_lo; |
179 | 179 | ||
180 | if (instr > limit) | 180 | if (instr > (unsigned char *)limit) |
181 | break; | 181 | break; |
182 | if (__get_user(opcode, (unsigned char __user *) instr)) | 182 | if (probe_kernel_address(instr, opcode)) |
183 | break; | 183 | break; |
184 | 184 | ||
185 | instr_hi = opcode & 0xf0; | 185 | instr_hi = opcode & 0xf0; |
@@ -204,9 +204,9 @@ static int __is_prefetch(struct pt_regs *regs, unsigned long addr) | |||
204 | case 0x00: | 204 | case 0x00: |
205 | /* Prefetch instruction is 0x0F0D or 0x0F18 */ | 205 | /* Prefetch instruction is 0x0F0D or 0x0F18 */ |
206 | scan_more = 0; | 206 | scan_more = 0; |
207 | if (instr > limit) | 207 | if (instr > (unsigned char *)limit) |
208 | break; | 208 | break; |
209 | if (__get_user(opcode, (unsigned char __user *) instr)) | 209 | if (probe_kernel_address(instr, opcode)) |
210 | break; | 210 | break; |
211 | prefetch = (instr_lo == 0xF) && | 211 | prefetch = (instr_lo == 0xF) && |
212 | (opcode == 0x0D || opcode == 0x18); | 212 | (opcode == 0x0D || opcode == 0x18); |
diff --git a/arch/i386/mm/highmem.c b/arch/i386/mm/highmem.c index f9f647cdbc7b..e0fa6cb655a8 100644 --- a/arch/i386/mm/highmem.c +++ b/arch/i386/mm/highmem.c | |||
@@ -32,7 +32,7 @@ void *kmap_atomic(struct page *page, enum km_type type) | |||
32 | unsigned long vaddr; | 32 | unsigned long vaddr; |
33 | 33 | ||
34 | /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ | 34 | /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ |
35 | inc_preempt_count(); | 35 | pagefault_disable(); |
36 | if (!PageHighMem(page)) | 36 | if (!PageHighMem(page)) |
37 | return page_address(page); | 37 | return page_address(page); |
38 | 38 | ||
@@ -50,26 +50,22 @@ void kunmap_atomic(void *kvaddr, enum km_type type) | |||
50 | unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; | 50 | unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; |
51 | enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); | 51 | enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); |
52 | 52 | ||
53 | #ifdef CONFIG_DEBUG_HIGHMEM | ||
54 | if (vaddr >= PAGE_OFFSET && vaddr < (unsigned long)high_memory) { | ||
55 | dec_preempt_count(); | ||
56 | preempt_check_resched(); | ||
57 | return; | ||
58 | } | ||
59 | |||
60 | if (vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx)) | ||
61 | BUG(); | ||
62 | #endif | ||
63 | /* | 53 | /* |
64 | * Force other mappings to Oops if they'll try to access this pte | 54 | * Force other mappings to Oops if they'll try to access this pte |
65 | * without first remap it. Keeping stale mappings around is a bad idea | 55 | * without first remap it. Keeping stale mappings around is a bad idea |
66 | * also, in case the page changes cacheability attributes or becomes | 56 | * also, in case the page changes cacheability attributes or becomes |
67 | * a protected page in a hypervisor. | 57 | * a protected page in a hypervisor. |
68 | */ | 58 | */ |
69 | kpte_clear_flush(kmap_pte-idx, vaddr); | 59 | if (vaddr == __fix_to_virt(FIX_KMAP_BEGIN+idx)) |
60 | kpte_clear_flush(kmap_pte-idx, vaddr); | ||
61 | else { | ||
62 | #ifdef CONFIG_DEBUG_HIGHMEM | ||
63 | BUG_ON(vaddr < PAGE_OFFSET); | ||
64 | BUG_ON(vaddr >= (unsigned long)high_memory); | ||
65 | #endif | ||
66 | } | ||
70 | 67 | ||
71 | dec_preempt_count(); | 68 | pagefault_enable(); |
72 | preempt_check_resched(); | ||
73 | } | 69 | } |
74 | 70 | ||
75 | /* This is the same as kmap_atomic() but can map memory that doesn't | 71 | /* This is the same as kmap_atomic() but can map memory that doesn't |
@@ -80,7 +76,7 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type) | |||
80 | enum fixed_addresses idx; | 76 | enum fixed_addresses idx; |
81 | unsigned long vaddr; | 77 | unsigned long vaddr; |
82 | 78 | ||
83 | inc_preempt_count(); | 79 | pagefault_disable(); |
84 | 80 | ||
85 | idx = type + KM_TYPE_NR*smp_processor_id(); | 81 | idx = type + KM_TYPE_NR*smp_processor_id(); |
86 | vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); | 82 | vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); |
diff --git a/arch/i386/mm/hugetlbpage.c b/arch/i386/mm/hugetlbpage.c index 1719a8141f81..34728e4afe48 100644 --- a/arch/i386/mm/hugetlbpage.c +++ b/arch/i386/mm/hugetlbpage.c | |||
@@ -17,6 +17,113 @@ | |||
17 | #include <asm/tlb.h> | 17 | #include <asm/tlb.h> |
18 | #include <asm/tlbflush.h> | 18 | #include <asm/tlbflush.h> |
19 | 19 | ||
20 | static unsigned long page_table_shareable(struct vm_area_struct *svma, | ||
21 | struct vm_area_struct *vma, | ||
22 | unsigned long addr, pgoff_t idx) | ||
23 | { | ||
24 | unsigned long saddr = ((idx - svma->vm_pgoff) << PAGE_SHIFT) + | ||
25 | svma->vm_start; | ||
26 | unsigned long sbase = saddr & PUD_MASK; | ||
27 | unsigned long s_end = sbase + PUD_SIZE; | ||
28 | |||
29 | /* | ||
30 | * match the virtual addresses, permission and the alignment of the | ||
31 | * page table page. | ||
32 | */ | ||
33 | if (pmd_index(addr) != pmd_index(saddr) || | ||
34 | vma->vm_flags != svma->vm_flags || | ||
35 | sbase < svma->vm_start || svma->vm_end < s_end) | ||
36 | return 0; | ||
37 | |||
38 | return saddr; | ||
39 | } | ||
40 | |||
41 | static int vma_shareable(struct vm_area_struct *vma, unsigned long addr) | ||
42 | { | ||
43 | unsigned long base = addr & PUD_MASK; | ||
44 | unsigned long end = base + PUD_SIZE; | ||
45 | |||
46 | /* | ||
47 | * check on proper vm_flags and page table alignment | ||
48 | */ | ||
49 | if (vma->vm_flags & VM_MAYSHARE && | ||
50 | vma->vm_start <= base && end <= vma->vm_end) | ||
51 | return 1; | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | * search for a shareable pmd page for hugetlb. | ||
57 | */ | ||
58 | static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud) | ||
59 | { | ||
60 | struct vm_area_struct *vma = find_vma(mm, addr); | ||
61 | struct address_space *mapping = vma->vm_file->f_mapping; | ||
62 | pgoff_t idx = ((addr - vma->vm_start) >> PAGE_SHIFT) + | ||
63 | vma->vm_pgoff; | ||
64 | struct prio_tree_iter iter; | ||
65 | struct vm_area_struct *svma; | ||
66 | unsigned long saddr; | ||
67 | pte_t *spte = NULL; | ||
68 | |||
69 | if (!vma_shareable(vma, addr)) | ||
70 | return; | ||
71 | |||
72 | spin_lock(&mapping->i_mmap_lock); | ||
73 | vma_prio_tree_foreach(svma, &iter, &mapping->i_mmap, idx, idx) { | ||
74 | if (svma == vma) | ||
75 | continue; | ||
76 | |||
77 | saddr = page_table_shareable(svma, vma, addr, idx); | ||
78 | if (saddr) { | ||
79 | spte = huge_pte_offset(svma->vm_mm, saddr); | ||
80 | if (spte) { | ||
81 | get_page(virt_to_page(spte)); | ||
82 | break; | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | |||
87 | if (!spte) | ||
88 | goto out; | ||
89 | |||
90 | spin_lock(&mm->page_table_lock); | ||
91 | if (pud_none(*pud)) | ||
92 | pud_populate(mm, pud, (unsigned long) spte & PAGE_MASK); | ||
93 | else | ||
94 | put_page(virt_to_page(spte)); | ||
95 | spin_unlock(&mm->page_table_lock); | ||
96 | out: | ||
97 | spin_unlock(&mapping->i_mmap_lock); | ||
98 | } | ||
99 | |||
100 | /* | ||
101 | * unmap huge page backed by shared pte. | ||
102 | * | ||
103 | * Hugetlb pte page is ref counted at the time of mapping. If pte is shared | ||
104 | * indicated by page_count > 1, unmap is achieved by clearing pud and | ||
105 | * decrementing the ref count. If count == 1, the pte page is not shared. | ||
106 | * | ||
107 | * called with vma->vm_mm->page_table_lock held. | ||
108 | * | ||
109 | * returns: 1 successfully unmapped a shared pte page | ||
110 | * 0 the underlying pte page is not shared, or it is the last user | ||
111 | */ | ||
112 | int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep) | ||
113 | { | ||
114 | pgd_t *pgd = pgd_offset(mm, *addr); | ||
115 | pud_t *pud = pud_offset(pgd, *addr); | ||
116 | |||
117 | BUG_ON(page_count(virt_to_page(ptep)) == 0); | ||
118 | if (page_count(virt_to_page(ptep)) == 1) | ||
119 | return 0; | ||
120 | |||
121 | pud_clear(pud); | ||
122 | put_page(virt_to_page(ptep)); | ||
123 | *addr = ALIGN(*addr, HPAGE_SIZE * PTRS_PER_PTE) - HPAGE_SIZE; | ||
124 | return 1; | ||
125 | } | ||
126 | |||
20 | pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) | 127 | pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) |
21 | { | 128 | { |
22 | pgd_t *pgd; | 129 | pgd_t *pgd; |
@@ -25,8 +132,11 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) | |||
25 | 132 | ||
26 | pgd = pgd_offset(mm, addr); | 133 | pgd = pgd_offset(mm, addr); |
27 | pud = pud_alloc(mm, pgd, addr); | 134 | pud = pud_alloc(mm, pgd, addr); |
28 | if (pud) | 135 | if (pud) { |
136 | if (pud_none(*pud)) | ||
137 | huge_pmd_share(mm, addr, pud); | ||
29 | pte = (pte_t *) pmd_alloc(mm, pud, addr); | 138 | pte = (pte_t *) pmd_alloc(mm, pud, addr); |
139 | } | ||
30 | BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte)); | 140 | BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte)); |
31 | 141 | ||
32 | return pte; | 142 | return pte; |
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c index 167416155ee4..84697dfc7348 100644 --- a/arch/i386/mm/init.c +++ b/arch/i386/mm/init.c | |||
@@ -192,8 +192,6 @@ static inline int page_kills_ppro(unsigned long pagenr) | |||
192 | return 0; | 192 | return 0; |
193 | } | 193 | } |
194 | 194 | ||
195 | extern int is_available_memory(efi_memory_desc_t *); | ||
196 | |||
197 | int page_is_ram(unsigned long pagenr) | 195 | int page_is_ram(unsigned long pagenr) |
198 | { | 196 | { |
199 | int i; | 197 | int i; |
@@ -699,8 +697,8 @@ int remove_memory(u64 start, u64 size) | |||
699 | #endif | 697 | #endif |
700 | #endif | 698 | #endif |
701 | 699 | ||
702 | kmem_cache_t *pgd_cache; | 700 | struct kmem_cache *pgd_cache; |
703 | kmem_cache_t *pmd_cache; | 701 | struct kmem_cache *pmd_cache; |
704 | 702 | ||
705 | void __init pgtable_cache_init(void) | 703 | void __init pgtable_cache_init(void) |
706 | { | 704 | { |
diff --git a/arch/i386/mm/pageattr.c b/arch/i386/mm/pageattr.c index 8564b6ae17e3..ad91528bdc14 100644 --- a/arch/i386/mm/pageattr.c +++ b/arch/i386/mm/pageattr.c | |||
@@ -67,11 +67,17 @@ static struct page *split_large_page(unsigned long address, pgprot_t prot, | |||
67 | return base; | 67 | return base; |
68 | } | 68 | } |
69 | 69 | ||
70 | static void flush_kernel_map(void *dummy) | 70 | static void flush_kernel_map(void *arg) |
71 | { | 71 | { |
72 | /* Could use CLFLUSH here if the CPU supports it (Hammer,P4) */ | 72 | unsigned long adr = (unsigned long)arg; |
73 | if (boot_cpu_data.x86_model >= 4) | 73 | |
74 | if (adr && cpu_has_clflush) { | ||
75 | int i; | ||
76 | for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size) | ||
77 | asm volatile("clflush (%0)" :: "r" (adr + i)); | ||
78 | } else if (boot_cpu_data.x86_model >= 4) | ||
74 | wbinvd(); | 79 | wbinvd(); |
80 | |||
75 | /* Flush all to work around Errata in early athlons regarding | 81 | /* Flush all to work around Errata in early athlons regarding |
76 | * large page flushing. | 82 | * large page flushing. |
77 | */ | 83 | */ |
@@ -173,9 +179,9 @@ __change_page_attr(struct page *page, pgprot_t prot) | |||
173 | return 0; | 179 | return 0; |
174 | } | 180 | } |
175 | 181 | ||
176 | static inline void flush_map(void) | 182 | static inline void flush_map(void *adr) |
177 | { | 183 | { |
178 | on_each_cpu(flush_kernel_map, NULL, 1, 1); | 184 | on_each_cpu(flush_kernel_map, adr, 1, 1); |
179 | } | 185 | } |
180 | 186 | ||
181 | /* | 187 | /* |
@@ -217,9 +223,13 @@ void global_flush_tlb(void) | |||
217 | spin_lock_irq(&cpa_lock); | 223 | spin_lock_irq(&cpa_lock); |
218 | list_replace_init(&df_list, &l); | 224 | list_replace_init(&df_list, &l); |
219 | spin_unlock_irq(&cpa_lock); | 225 | spin_unlock_irq(&cpa_lock); |
220 | flush_map(); | 226 | if (!cpu_has_clflush) |
221 | list_for_each_entry_safe(pg, next, &l, lru) | 227 | flush_map(0); |
228 | list_for_each_entry_safe(pg, next, &l, lru) { | ||
229 | if (cpu_has_clflush) | ||
230 | flush_map(page_address(pg)); | ||
222 | __free_page(pg); | 231 | __free_page(pg); |
232 | } | ||
223 | } | 233 | } |
224 | 234 | ||
225 | #ifdef CONFIG_DEBUG_PAGEALLOC | 235 | #ifdef CONFIG_DEBUG_PAGEALLOC |
diff --git a/arch/i386/mm/pgtable.c b/arch/i386/mm/pgtable.c index 10126e3f8174..f349eaf450b0 100644 --- a/arch/i386/mm/pgtable.c +++ b/arch/i386/mm/pgtable.c | |||
@@ -95,8 +95,11 @@ static void set_pte_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags) | |||
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | pte = pte_offset_kernel(pmd, vaddr); | 97 | pte = pte_offset_kernel(pmd, vaddr); |
98 | /* <pfn,flags> stored as-is, to permit clearing entries */ | 98 | if (pgprot_val(flags)) |
99 | set_pte(pte, pfn_pte(pfn, flags)); | 99 | /* <pfn,flags> stored as-is, to permit clearing entries */ |
100 | set_pte(pte, pfn_pte(pfn, flags)); | ||
101 | else | ||
102 | pte_clear(&init_mm, vaddr, pte); | ||
100 | 103 | ||
101 | /* | 104 | /* |
102 | * It's enough to flush this one mapping. | 105 | * It's enough to flush this one mapping. |
@@ -193,7 +196,7 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) | |||
193 | return pte; | 196 | return pte; |
194 | } | 197 | } |
195 | 198 | ||
196 | void pmd_ctor(void *pmd, kmem_cache_t *cache, unsigned long flags) | 199 | void pmd_ctor(void *pmd, struct kmem_cache *cache, unsigned long flags) |
197 | { | 200 | { |
198 | memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t)); | 201 | memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t)); |
199 | } | 202 | } |
@@ -233,7 +236,7 @@ static inline void pgd_list_del(pgd_t *pgd) | |||
233 | set_page_private(next, (unsigned long)pprev); | 236 | set_page_private(next, (unsigned long)pprev); |
234 | } | 237 | } |
235 | 238 | ||
236 | void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused) | 239 | void pgd_ctor(void *pgd, struct kmem_cache *cache, unsigned long unused) |
237 | { | 240 | { |
238 | unsigned long flags; | 241 | unsigned long flags; |
239 | 242 | ||
@@ -253,7 +256,7 @@ void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused) | |||
253 | } | 256 | } |
254 | 257 | ||
255 | /* never called when PTRS_PER_PMD > 1 */ | 258 | /* never called when PTRS_PER_PMD > 1 */ |
256 | void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused) | 259 | void pgd_dtor(void *pgd, struct kmem_cache *cache, unsigned long unused) |
257 | { | 260 | { |
258 | unsigned long flags; /* can be called from interrupt context */ | 261 | unsigned long flags; /* can be called from interrupt context */ |
259 | 262 | ||