aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386')
-rw-r--r--arch/i386/kernel/acpi/cstate.c6
-rw-r--r--arch/i386/kernel/cpu/mcheck/non-fatal.c6
-rw-r--r--arch/i386/kernel/cpu/mcheck/therm_throt.c2
-rw-r--r--arch/i386/kernel/cpuid.c2
-rw-r--r--arch/i386/kernel/crash.c66
-rw-r--r--arch/i386/kernel/io_apic.c1
-rw-r--r--arch/i386/kernel/kprobes.c4
-rw-r--r--arch/i386/kernel/microcode.c2
-rw-r--r--arch/i386/kernel/msr.c2
-rw-r--r--arch/i386/kernel/reboot.c1
-rw-r--r--arch/i386/kernel/setup.c3
-rw-r--r--arch/i386/kernel/smp.c4
-rw-r--r--arch/i386/kernel/smpboot.c11
-rw-r--r--arch/i386/kernel/sysenter.c2
-rw-r--r--arch/i386/kernel/traps.c2
-rw-r--r--arch/i386/kernel/tsc.c4
-rw-r--r--arch/i386/mm/highmem.c26
-rw-r--r--arch/i386/mm/hugetlbpage.c112
-rw-r--r--arch/i386/mm/init.c4
-rw-r--r--arch/i386/mm/pgtable.c6
-rw-r--r--arch/i386/power/Makefile2
-rw-r--r--arch/i386/power/suspend.c158
-rw-r--r--arch/i386/power/swsusp.S9
23 files changed, 319 insertions, 116 deletions
diff --git a/arch/i386/kernel/acpi/cstate.c b/arch/i386/kernel/acpi/cstate.c
index 4664b55f623e..12e937c1ce4b 100644
--- a/arch/i386/kernel/acpi/cstate.c
+++ b/arch/i386/kernel/acpi/cstate.c
@@ -156,10 +156,8 @@ static int __init ffh_cstate_init(void)
156 156
157static void __exit ffh_cstate_exit(void) 157static void __exit ffh_cstate_exit(void)
158{ 158{
159 if (cpu_cstate_entry) { 159 free_percpu(cpu_cstate_entry);
160 free_percpu(cpu_cstate_entry); 160 cpu_cstate_entry = NULL;
161 cpu_cstate_entry = NULL;
162 }
163} 161}
164 162
165arch_initcall(ffh_cstate_init); 163arch_initcall(ffh_cstate_init);
diff --git a/arch/i386/kernel/cpu/mcheck/non-fatal.c b/arch/i386/kernel/cpu/mcheck/non-fatal.c
index 1f9153ae5b03..6b5d3518a1c0 100644
--- a/arch/i386/kernel/cpu/mcheck/non-fatal.c
+++ b/arch/i386/kernel/cpu/mcheck/non-fatal.c
@@ -51,10 +51,10 @@ static void mce_checkregs (void *info)
51 } 51 }
52} 52}
53 53
54static void mce_work_fn(void *data); 54static void mce_work_fn(struct work_struct *work);
55static DECLARE_WORK(mce_work, mce_work_fn, NULL); 55static DECLARE_DELAYED_WORK(mce_work, mce_work_fn);
56 56
57static void mce_work_fn(void *data) 57static void mce_work_fn(struct work_struct *work)
58{ 58{
59 on_each_cpu(mce_checkregs, NULL, 1, 1); 59 on_each_cpu(mce_checkregs, NULL, 1, 1);
60 schedule_delayed_work(&mce_work, MCE_RATE); 60 schedule_delayed_work(&mce_work, MCE_RATE);
diff --git a/arch/i386/kernel/cpu/mcheck/therm_throt.c b/arch/i386/kernel/cpu/mcheck/therm_throt.c
index bad8b4420709..065005c3f168 100644
--- a/arch/i386/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/i386/kernel/cpu/mcheck/therm_throt.c
@@ -116,7 +116,6 @@ static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev)
116 return sysfs_create_group(&sys_dev->kobj, &thermal_throttle_attr_group); 116 return sysfs_create_group(&sys_dev->kobj, &thermal_throttle_attr_group);
117} 117}
118 118
119#ifdef CONFIG_HOTPLUG_CPU
120static __cpuinit void thermal_throttle_remove_dev(struct sys_device *sys_dev) 119static __cpuinit void thermal_throttle_remove_dev(struct sys_device *sys_dev)
121{ 120{
122 return sysfs_remove_group(&sys_dev->kobj, &thermal_throttle_attr_group); 121 return sysfs_remove_group(&sys_dev->kobj, &thermal_throttle_attr_group);
@@ -153,7 +152,6 @@ static struct notifier_block thermal_throttle_cpu_notifier =
153{ 152{
154 .notifier_call = thermal_throttle_cpu_callback, 153 .notifier_call = thermal_throttle_cpu_callback,
155}; 154};
156#endif /* CONFIG_HOTPLUG_CPU */
157 155
158static __init int thermal_throttle_init_device(void) 156static __init int thermal_throttle_init_device(void)
159{ 157{
diff --git a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
index 5c5d4507ee7d..db6dd20c3589 100644
--- a/arch/i386/kernel/cpuid.c
+++ b/arch/i386/kernel/cpuid.c
@@ -166,7 +166,6 @@ static int cpuid_device_create(int i)
166 return err; 166 return err;
167} 167}
168 168
169#ifdef CONFIG_HOTPLUG_CPU
170static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) 169static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
171{ 170{
172 unsigned int cpu = (unsigned long)hcpu; 171 unsigned int cpu = (unsigned long)hcpu;
@@ -186,7 +185,6 @@ static struct notifier_block __cpuinitdata cpuid_class_cpu_notifier =
186{ 185{
187 .notifier_call = cpuid_class_cpu_callback, 186 .notifier_call = cpuid_class_cpu_callback,
188}; 187};
189#endif /* !CONFIG_HOTPLUG_CPU */
190 188
191static int __init cpuid_init(void) 189static int __init cpuid_init(void)
192{ 190{
diff --git a/arch/i386/kernel/crash.c b/arch/i386/kernel/crash.c
index 144b43288965..a5e0e990ea95 100644
--- a/arch/i386/kernel/crash.c
+++ b/arch/i386/kernel/crash.c
@@ -31,68 +31,6 @@
31/* This keeps a track of which one is crashing cpu. */ 31/* This keeps a track of which one is crashing cpu. */
32static int crashing_cpu; 32static int crashing_cpu;
33 33
34static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
35 size_t data_len)
36{
37 struct elf_note note;
38
39 note.n_namesz = strlen(name) + 1;
40 note.n_descsz = data_len;
41 note.n_type = type;
42 memcpy(buf, &note, sizeof(note));
43 buf += (sizeof(note) +3)/4;
44 memcpy(buf, name, note.n_namesz);
45 buf += (note.n_namesz + 3)/4;
46 memcpy(buf, data, note.n_descsz);
47 buf += (note.n_descsz + 3)/4;
48
49 return buf;
50}
51
52static void final_note(u32 *buf)
53{
54 struct elf_note note;
55
56 note.n_namesz = 0;
57 note.n_descsz = 0;
58 note.n_type = 0;
59 memcpy(buf, &note, sizeof(note));
60}
61
62static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
63{
64 struct elf_prstatus prstatus;
65 u32 *buf;
66
67 if ((cpu < 0) || (cpu >= NR_CPUS))
68 return;
69
70 /* Using ELF notes here is opportunistic.
71 * I need a well defined structure format
72 * for the data I pass, and I need tags
73 * on the data to indicate what information I have
74 * squirrelled away. ELF notes happen to provide
75 * all of that, so there is no need to invent something new.
76 */
77 buf = (u32*)per_cpu_ptr(crash_notes, cpu);
78 if (!buf)
79 return;
80 memset(&prstatus, 0, sizeof(prstatus));
81 prstatus.pr_pid = current->pid;
82 elf_core_copy_regs(&prstatus.pr_reg, regs);
83 buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
84 sizeof(prstatus));
85 final_note(buf);
86}
87
88static void crash_save_self(struct pt_regs *regs)
89{
90 int cpu;
91
92 cpu = safe_smp_processor_id();
93 crash_save_this_cpu(regs, cpu);
94}
95
96#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC) 34#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
97static atomic_t waiting_for_crash_ipi; 35static atomic_t waiting_for_crash_ipi;
98 36
@@ -121,7 +59,7 @@ static int crash_nmi_callback(struct notifier_block *self,
121 crash_fixup_ss_esp(&fixed_regs, regs); 59 crash_fixup_ss_esp(&fixed_regs, regs);
122 regs = &fixed_regs; 60 regs = &fixed_regs;
123 } 61 }
124 crash_save_this_cpu(regs, cpu); 62 crash_save_cpu(regs, cpu);
125 disable_local_APIC(); 63 disable_local_APIC();
126 atomic_dec(&waiting_for_crash_ipi); 64 atomic_dec(&waiting_for_crash_ipi);
127 /* Assume hlt works */ 65 /* Assume hlt works */
@@ -195,5 +133,5 @@ void machine_crash_shutdown(struct pt_regs *regs)
195#if defined(CONFIG_X86_IO_APIC) 133#if defined(CONFIG_X86_IO_APIC)
196 disable_IO_APIC(); 134 disable_IO_APIC();
197#endif 135#endif
198 crash_save_self(regs); 136 crash_save_cpu(regs, safe_smp_processor_id());
199} 137}
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 7f015a71ab55..e21dcde0790e 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -34,6 +34,7 @@
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/msi.h> 35#include <linux/msi.h>
36#include <linux/htirq.h> 36#include <linux/htirq.h>
37#include <linux/freezer.h>
37 38
38#include <asm/io.h> 39#include <asm/io.h>
39#include <asm/smp.h> 40#include <asm/smp.h>
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index fc79e1e859c4..af1d53344993 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -184,7 +184,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
184void __kprobes arch_remove_kprobe(struct kprobe *p) 184void __kprobes arch_remove_kprobe(struct kprobe *p)
185{ 185{
186 mutex_lock(&kprobe_mutex); 186 mutex_lock(&kprobe_mutex);
187 free_insn_slot(p->ainsn.insn); 187 free_insn_slot(p->ainsn.insn, (p->ainsn.boostable == 1));
188 mutex_unlock(&kprobe_mutex); 188 mutex_unlock(&kprobe_mutex);
189} 189}
190 190
@@ -333,7 +333,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
333 return 1; 333 return 1;
334 334
335ss_probe: 335ss_probe:
336#ifndef CONFIG_PREEMPT 336#if !defined(CONFIG_PREEMPT) || defined(CONFIG_PM)
337 if (p->ainsn.boostable == 1 && !p->post_handler){ 337 if (p->ainsn.boostable == 1 && !p->post_handler){
338 /* Boost up -- we can execute copied instructions directly */ 338 /* Boost up -- we can execute copied instructions directly */
339 reset_current_kprobe(); 339 reset_current_kprobe();
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index 23f5984d0654..972346604f9d 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -703,7 +703,6 @@ static struct sysdev_driver mc_sysdev_driver = {
703 .resume = mc_sysdev_resume, 703 .resume = mc_sysdev_resume,
704}; 704};
705 705
706#ifdef CONFIG_HOTPLUG_CPU
707static __cpuinit int 706static __cpuinit int
708mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) 707mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
709{ 708{
@@ -726,7 +725,6 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
726static struct notifier_block mc_cpu_notifier = { 725static struct notifier_block mc_cpu_notifier = {
727 .notifier_call = mc_cpu_callback, 726 .notifier_call = mc_cpu_callback,
728}; 727};
729#endif
730 728
731static int __init microcode_init (void) 729static int __init microcode_init (void)
732{ 730{
diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
index fd45059c9084..1d1a56cae340 100644
--- a/arch/i386/kernel/msr.c
+++ b/arch/i386/kernel/msr.c
@@ -249,7 +249,6 @@ static int msr_device_create(int i)
249 return err; 249 return err;
250} 250}
251 251
252#ifdef CONFIG_HOTPLUG_CPU
253static int msr_class_cpu_callback(struct notifier_block *nfb, 252static int msr_class_cpu_callback(struct notifier_block *nfb,
254 unsigned long action, void *hcpu) 253 unsigned long action, void *hcpu)
255{ 254{
@@ -270,7 +269,6 @@ static struct notifier_block __cpuinitdata msr_class_cpu_notifier =
270{ 269{
271 .notifier_call = msr_class_cpu_callback, 270 .notifier_call = msr_class_cpu_callback,
272}; 271};
273#endif
274 272
275static int __init msr_init(void) 273static int __init msr_init(void)
276{ 274{
diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c
index 84278e0093a2..3514b4153f7f 100644
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -12,6 +12,7 @@
12#include <linux/dmi.h> 12#include <linux/dmi.h>
13#include <linux/ctype.h> 13#include <linux/ctype.h>
14#include <linux/pm.h> 14#include <linux/pm.h>
15#include <linux/reboot.h>
15#include <asm/uaccess.h> 16#include <asm/uaccess.h>
16#include <asm/apic.h> 17#include <asm/apic.h>
17#include <asm/desc.h> 18#include <asm/desc.h>
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 695d53fd14de..79df6e612dbd 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -448,8 +448,7 @@ void __init setup_bootmem_allocator(void)
448 if (LOADER_TYPE && INITRD_START) { 448 if (LOADER_TYPE && INITRD_START) {
449 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) { 449 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
450 reserve_bootmem(INITRD_START, INITRD_SIZE); 450 reserve_bootmem(INITRD_START, INITRD_SIZE);
451 initrd_start = 451 initrd_start = INITRD_START + PAGE_OFFSET;
452 INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
453 initrd_end = initrd_start+INITRD_SIZE; 452 initrd_end = initrd_start+INITRD_SIZE;
454 } 453 }
455 else { 454 else {
diff --git a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
index 1b080ab8a49f..5285aff8367f 100644
--- a/arch/i386/kernel/smp.c
+++ b/arch/i386/kernel/smp.c
@@ -693,6 +693,10 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
693 put_cpu(); 693 put_cpu();
694 return -EBUSY; 694 return -EBUSY;
695 } 695 }
696
697 /* Can deadlock when called with interrupts disabled */
698 WARN_ON(irqs_disabled());
699
696 spin_lock_bh(&call_lock); 700 spin_lock_bh(&call_lock);
697 __smp_call_function_single(cpu, func, info, nonatomic, wait); 701 __smp_call_function_single(cpu, func, info, nonatomic, wait);
698 spin_unlock_bh(&call_lock); 702 spin_unlock_bh(&call_lock);
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index b4e6f32de453..4bf0e3c83b8b 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -1071,13 +1071,15 @@ void cpu_exit_clear(void)
1071 1071
1072struct warm_boot_cpu_info { 1072struct warm_boot_cpu_info {
1073 struct completion *complete; 1073 struct completion *complete;
1074 struct work_struct task;
1074 int apicid; 1075 int apicid;
1075 int cpu; 1076 int cpu;
1076}; 1077};
1077 1078
1078static void __cpuinit do_warm_boot_cpu(void *p) 1079static void __cpuinit do_warm_boot_cpu(struct work_struct *work)
1079{ 1080{
1080 struct warm_boot_cpu_info *info = p; 1081 struct warm_boot_cpu_info *info =
1082 container_of(work, struct warm_boot_cpu_info, task);
1081 do_boot_cpu(info->apicid, info->cpu); 1083 do_boot_cpu(info->apicid, info->cpu);
1082 complete(info->complete); 1084 complete(info->complete);
1083} 1085}
@@ -1086,7 +1088,6 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
1086{ 1088{
1087 DECLARE_COMPLETION_ONSTACK(done); 1089 DECLARE_COMPLETION_ONSTACK(done);
1088 struct warm_boot_cpu_info info; 1090 struct warm_boot_cpu_info info;
1089 struct work_struct task;
1090 int apicid, ret; 1091 int apicid, ret;
1091 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu); 1092 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
1092 1093
@@ -1111,7 +1112,7 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
1111 info.complete = &done; 1112 info.complete = &done;
1112 info.apicid = apicid; 1113 info.apicid = apicid;
1113 info.cpu = cpu; 1114 info.cpu = cpu;
1114 INIT_WORK(&task, do_warm_boot_cpu, &info); 1115 INIT_WORK(&info.task, do_warm_boot_cpu);
1115 1116
1116 tsc_sync_disabled = 1; 1117 tsc_sync_disabled = 1;
1117 1118
@@ -1119,7 +1120,7 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
1119 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS, 1120 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
1120 KERNEL_PGD_PTRS); 1121 KERNEL_PGD_PTRS);
1121 flush_tlb_all(); 1122 flush_tlb_all();
1122 schedule_work(&task); 1123 schedule_work(&info.task);
1123 wait_for_completion(&done); 1124 wait_for_completion(&done);
1124 1125
1125 tsc_sync_disabled = 0; 1126 tsc_sync_disabled = 0;
diff --git a/arch/i386/kernel/sysenter.c b/arch/i386/kernel/sysenter.c
index 92849c7def5a..7de9117b5a3a 100644
--- a/arch/i386/kernel/sysenter.c
+++ b/arch/i386/kernel/sysenter.c
@@ -136,7 +136,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
136 goto up_fail; 136 goto up_fail;
137 } 137 }
138 138
139 vma = kmem_cache_zalloc(vm_area_cachep, SLAB_KERNEL); 139 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
140 if (!vma) { 140 if (!vma) {
141 ret = -ENOMEM; 141 ret = -ENOMEM;
142 goto up_fail; 142 goto up_fail;
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index c447807e2a45..68de48e498ca 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -464,7 +464,7 @@ void die(const char * str, struct pt_regs * regs, long err)
464 u32 lock_owner; 464 u32 lock_owner;
465 int lock_owner_depth; 465 int lock_owner_depth;
466 } die = { 466 } die = {
467 .lock = SPIN_LOCK_UNLOCKED, 467 .lock = __SPIN_LOCK_UNLOCKED(die.lock),
468 .lock_owner = -1, 468 .lock_owner = -1,
469 .lock_owner_depth = 0 469 .lock_owner_depth = 0
470 }; 470 };
diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c
index 7f22e03253e2..1bbe45dca7a0 100644
--- a/arch/i386/kernel/tsc.c
+++ b/arch/i386/kernel/tsc.c
@@ -216,7 +216,7 @@ static unsigned int cpufreq_delayed_issched = 0;
216static unsigned int cpufreq_init = 0; 216static unsigned int cpufreq_init = 0;
217static struct work_struct cpufreq_delayed_get_work; 217static struct work_struct cpufreq_delayed_get_work;
218 218
219static void handle_cpufreq_delayed_get(void *v) 219static void handle_cpufreq_delayed_get(struct work_struct *work)
220{ 220{
221 unsigned int cpu; 221 unsigned int cpu;
222 222
@@ -305,7 +305,7 @@ static int __init cpufreq_tsc(void)
305{ 305{
306 int ret; 306 int ret;
307 307
308 INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get, NULL); 308 INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get);
309 ret = cpufreq_register_notifier(&time_cpufreq_notifier_block, 309 ret = cpufreq_register_notifier(&time_cpufreq_notifier_block,
310 CPUFREQ_TRANSITION_NOTIFIER); 310 CPUFREQ_TRANSITION_NOTIFIER);
311 if (!ret) 311 if (!ret)
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
20static 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
41static 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 */
58static 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);
96out:
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 */
112int 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
20pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) 127pte_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 f4dd048187ff..84697dfc7348 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -697,8 +697,8 @@ int remove_memory(u64 start, u64 size)
697#endif 697#endif
698#endif 698#endif
699 699
700kmem_cache_t *pgd_cache; 700struct kmem_cache *pgd_cache;
701kmem_cache_t *pmd_cache; 701struct kmem_cache *pmd_cache;
702 702
703void __init pgtable_cache_init(void) 703void __init pgtable_cache_init(void)
704{ 704{
diff --git a/arch/i386/mm/pgtable.c b/arch/i386/mm/pgtable.c
index 65b5c0959033..f349eaf450b0 100644
--- a/arch/i386/mm/pgtable.c
+++ b/arch/i386/mm/pgtable.c
@@ -196,7 +196,7 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
196 return pte; 196 return pte;
197} 197}
198 198
199void pmd_ctor(void *pmd, kmem_cache_t *cache, unsigned long flags) 199void pmd_ctor(void *pmd, struct kmem_cache *cache, unsigned long flags)
200{ 200{
201 memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t)); 201 memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
202} 202}
@@ -236,7 +236,7 @@ static inline void pgd_list_del(pgd_t *pgd)
236 set_page_private(next, (unsigned long)pprev); 236 set_page_private(next, (unsigned long)pprev);
237} 237}
238 238
239void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused) 239void pgd_ctor(void *pgd, struct kmem_cache *cache, unsigned long unused)
240{ 240{
241 unsigned long flags; 241 unsigned long flags;
242 242
@@ -256,7 +256,7 @@ void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
256} 256}
257 257
258/* never called when PTRS_PER_PMD > 1 */ 258/* never called when PTRS_PER_PMD > 1 */
259void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused) 259void pgd_dtor(void *pgd, struct kmem_cache *cache, unsigned long unused)
260{ 260{
261 unsigned long flags; /* can be called from interrupt context */ 261 unsigned long flags; /* can be called from interrupt context */
262 262
diff --git a/arch/i386/power/Makefile b/arch/i386/power/Makefile
index 8cfa4e8a719d..2de7bbf03cd7 100644
--- a/arch/i386/power/Makefile
+++ b/arch/i386/power/Makefile
@@ -1,2 +1,2 @@
1obj-$(CONFIG_PM) += cpu.o 1obj-$(CONFIG_PM) += cpu.o
2obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o 2obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o suspend.o
diff --git a/arch/i386/power/suspend.c b/arch/i386/power/suspend.c
new file mode 100644
index 000000000000..db5e98d2eb73
--- /dev/null
+++ b/arch/i386/power/suspend.c
@@ -0,0 +1,158 @@
1/*
2 * Suspend support specific for i386 - temporary page tables
3 *
4 * Distribute under GPLv2
5 *
6 * Copyright (c) 2006 Rafael J. Wysocki <rjw@sisk.pl>
7 */
8
9#include <linux/suspend.h>
10#include <linux/bootmem.h>
11
12#include <asm/system.h>
13#include <asm/page.h>
14#include <asm/pgtable.h>
15
16/* Defined in arch/i386/power/swsusp.S */
17extern int restore_image(void);
18
19/* Pointer to the temporary resume page tables */
20pgd_t *resume_pg_dir;
21
22/* The following three functions are based on the analogous code in
23 * arch/i386/mm/init.c
24 */
25
26/*
27 * Create a middle page table on a resume-safe page and put a pointer to it in
28 * the given global directory entry. This only returns the gd entry
29 * in non-PAE compilation mode, since the middle layer is folded.
30 */
31static pmd_t *resume_one_md_table_init(pgd_t *pgd)
32{
33 pud_t *pud;
34 pmd_t *pmd_table;
35
36#ifdef CONFIG_X86_PAE
37 pmd_table = (pmd_t *)get_safe_page(GFP_ATOMIC);
38 if (!pmd_table)
39 return NULL;
40
41 set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
42 pud = pud_offset(pgd, 0);
43
44 BUG_ON(pmd_table != pmd_offset(pud, 0));
45#else
46 pud = pud_offset(pgd, 0);
47 pmd_table = pmd_offset(pud, 0);
48#endif
49
50 return pmd_table;
51}
52
53/*
54 * Create a page table on a resume-safe page and place a pointer to it in
55 * a middle page directory entry.
56 */
57static pte_t *resume_one_page_table_init(pmd_t *pmd)
58{
59 if (pmd_none(*pmd)) {
60 pte_t *page_table = (pte_t *)get_safe_page(GFP_ATOMIC);
61 if (!page_table)
62 return NULL;
63
64 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
65
66 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
67
68 return page_table;
69 }
70
71 return pte_offset_kernel(pmd, 0);
72}
73
74/*
75 * This maps the physical memory to kernel virtual address space, a total
76 * of max_low_pfn pages, by creating page tables starting from address
77 * PAGE_OFFSET. The page tables are allocated out of resume-safe pages.
78 */
79static int resume_physical_mapping_init(pgd_t *pgd_base)
80{
81 unsigned long pfn;
82 pgd_t *pgd;
83 pmd_t *pmd;
84 pte_t *pte;
85 int pgd_idx, pmd_idx;
86
87 pgd_idx = pgd_index(PAGE_OFFSET);
88 pgd = pgd_base + pgd_idx;
89 pfn = 0;
90
91 for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
92 pmd = resume_one_md_table_init(pgd);
93 if (!pmd)
94 return -ENOMEM;
95
96 if (pfn >= max_low_pfn)
97 continue;
98
99 for (pmd_idx = 0; pmd_idx < PTRS_PER_PMD; pmd++, pmd_idx++) {
100 if (pfn >= max_low_pfn)
101 break;
102
103 /* Map with big pages if possible, otherwise create
104 * normal page tables.
105 * NOTE: We can mark everything as executable here
106 */
107 if (cpu_has_pse) {
108 set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE_EXEC));
109 pfn += PTRS_PER_PTE;
110 } else {
111 pte_t *max_pte;
112
113 pte = resume_one_page_table_init(pmd);
114 if (!pte)
115 return -ENOMEM;
116
117 max_pte = pte + PTRS_PER_PTE;
118 for (; pte < max_pte; pte++, pfn++) {
119 if (pfn >= max_low_pfn)
120 break;
121
122 set_pte(pte, pfn_pte(pfn, PAGE_KERNEL_EXEC));
123 }
124 }
125 }
126 }
127 return 0;
128}
129
130static inline void resume_init_first_level_page_table(pgd_t *pg_dir)
131{
132#ifdef CONFIG_X86_PAE
133 int i;
134
135 /* Init entries of the first-level page table to the zero page */
136 for (i = 0; i < PTRS_PER_PGD; i++)
137 set_pgd(pg_dir + i,
138 __pgd(__pa(empty_zero_page) | _PAGE_PRESENT));
139#endif
140}
141
142int swsusp_arch_resume(void)
143{
144 int error;
145
146 resume_pg_dir = (pgd_t *)get_safe_page(GFP_ATOMIC);
147 if (!resume_pg_dir)
148 return -ENOMEM;
149
150 resume_init_first_level_page_table(resume_pg_dir);
151 error = resume_physical_mapping_init(resume_pg_dir);
152 if (error)
153 return error;
154
155 /* We have got enough memory and from now on we cannot recover */
156 restore_image();
157 return 0;
158}
diff --git a/arch/i386/power/swsusp.S b/arch/i386/power/swsusp.S
index 8a2b50a0aaad..53662e05b393 100644
--- a/arch/i386/power/swsusp.S
+++ b/arch/i386/power/swsusp.S
@@ -28,8 +28,9 @@ ENTRY(swsusp_arch_suspend)
28 call swsusp_save 28 call swsusp_save
29 ret 29 ret
30 30
31ENTRY(swsusp_arch_resume) 31ENTRY(restore_image)
32 movl $swsusp_pg_dir-__PAGE_OFFSET, %ecx 32 movl resume_pg_dir, %ecx
33 subl $__PAGE_OFFSET, %ecx
33 movl %ecx, %cr3 34 movl %ecx, %cr3
34 35
35 movl restore_pblist, %edx 36 movl restore_pblist, %edx
@@ -51,6 +52,10 @@ copy_loop:
51 .p2align 4,,7 52 .p2align 4,,7
52 53
53done: 54done:
55 /* go back to the original page tables */
56 movl $swapper_pg_dir, %ecx
57 subl $__PAGE_OFFSET, %ecx
58 movl %ecx, %cr3
54 /* Flush TLB, including "global" things (vmalloc) */ 59 /* Flush TLB, including "global" things (vmalloc) */
55 movl mmu_cr4_features, %eax 60 movl mmu_cr4_features, %eax
56 movl %eax, %edx 61 movl %eax, %edx