aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/processor.h33
-rw-r--r--arch/x86/include/asm/tlbflush.h37
-rw-r--r--arch/x86/include/asm/virtext.h3
-rw-r--r--arch/x86/kernel/cpu/common.c10
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c3
-rw-r--r--arch/x86/kernel/cpu/mcheck/p5.c3
-rw-r--r--arch/x86/kernel/cpu/mcheck/winchip.c3
-rw-r--r--arch/x86/kernel/cpu/perf_event.c7
-rw-r--r--arch/x86/kernel/i387.c3
-rw-r--r--arch/x86/kernel/process.c5
-rw-r--r--arch/x86/kernel/xsave.c3
-rw-r--r--arch/x86/kvm/vmx.c4
-rw-r--r--arch/x86/mm/init.c4
-rw-r--r--arch/x86/xen/enlighten.c4
14 files changed, 67 insertions, 55 deletions
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index a092a0cce0b7..ec1c93588cef 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -579,39 +579,6 @@ static inline void load_sp0(struct tss_struct *tss,
579#define set_iopl_mask native_set_iopl_mask 579#define set_iopl_mask native_set_iopl_mask
580#endif /* CONFIG_PARAVIRT */ 580#endif /* CONFIG_PARAVIRT */
581 581
582/*
583 * Save the cr4 feature set we're using (ie
584 * Pentium 4MB enable and PPro Global page
585 * enable), so that any CPU's that boot up
586 * after us can get the correct flags.
587 */
588extern unsigned long mmu_cr4_features;
589extern u32 *trampoline_cr4_features;
590
591static inline void set_in_cr4(unsigned long mask)
592{
593 unsigned long cr4;
594
595 mmu_cr4_features |= mask;
596 if (trampoline_cr4_features)
597 *trampoline_cr4_features = mmu_cr4_features;
598 cr4 = read_cr4();
599 cr4 |= mask;
600 write_cr4(cr4);
601}
602
603static inline void clear_in_cr4(unsigned long mask)
604{
605 unsigned long cr4;
606
607 mmu_cr4_features &= ~mask;
608 if (trampoline_cr4_features)
609 *trampoline_cr4_features = mmu_cr4_features;
610 cr4 = read_cr4();
611 cr4 &= ~mask;
612 write_cr4(cr4);
613}
614
615typedef struct { 582typedef struct {
616 unsigned long seg; 583 unsigned long seg;
617} mm_segment_t; 584} mm_segment_t;
diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
index 04905bfc508b..fc0c4bc356ce 100644
--- a/arch/x86/include/asm/tlbflush.h
+++ b/arch/x86/include/asm/tlbflush.h
@@ -15,6 +15,43 @@
15#define __flush_tlb_single(addr) __native_flush_tlb_single(addr) 15#define __flush_tlb_single(addr) __native_flush_tlb_single(addr)
16#endif 16#endif
17 17
18/* Set in this cpu's CR4. */
19static inline void cr4_set_bits(unsigned long mask)
20{
21 unsigned long cr4;
22
23 cr4 = read_cr4();
24 cr4 |= mask;
25 write_cr4(cr4);
26}
27
28/* Clear in this cpu's CR4. */
29static inline void cr4_clear_bits(unsigned long mask)
30{
31 unsigned long cr4;
32
33 cr4 = read_cr4();
34 cr4 &= ~mask;
35 write_cr4(cr4);
36}
37
38/*
39 * Save some of cr4 feature set we're using (e.g. Pentium 4MB
40 * enable and PPro Global page enable), so that any CPU's that boot
41 * up after us can get the correct flags. This should only be used
42 * during boot on the boot cpu.
43 */
44extern unsigned long mmu_cr4_features;
45extern u32 *trampoline_cr4_features;
46
47static inline void cr4_set_bits_and_update_boot(unsigned long mask)
48{
49 mmu_cr4_features |= mask;
50 if (trampoline_cr4_features)
51 *trampoline_cr4_features = mmu_cr4_features;
52 cr4_set_bits(mask);
53}
54
18static inline void __native_flush_tlb(void) 55static inline void __native_flush_tlb(void)
19{ 56{
20 native_write_cr3(native_read_cr3()); 57 native_write_cr3(native_read_cr3());
diff --git a/arch/x86/include/asm/virtext.h b/arch/x86/include/asm/virtext.h
index 5da71c27cc59..f41e19ca717b 100644
--- a/arch/x86/include/asm/virtext.h
+++ b/arch/x86/include/asm/virtext.h
@@ -19,6 +19,7 @@
19 19
20#include <asm/vmx.h> 20#include <asm/vmx.h>
21#include <asm/svm.h> 21#include <asm/svm.h>
22#include <asm/tlbflush.h>
22 23
23/* 24/*
24 * VMX functions: 25 * VMX functions:
@@ -40,7 +41,7 @@ static inline int cpu_has_vmx(void)
40static inline void cpu_vmxoff(void) 41static inline void cpu_vmxoff(void)
41{ 42{
42 asm volatile (ASM_VMX_VMXOFF : : : "cc"); 43 asm volatile (ASM_VMX_VMXOFF : : : "cc");
43 write_cr4(read_cr4() & ~X86_CR4_VMXE); 44 cr4_clear_bits(X86_CR4_VMXE);
44} 45}
45 46
46static inline int cpu_vmx_enabled(void) 47static inline int cpu_vmx_enabled(void)
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index c6049650c093..9d8fc49f0922 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -278,7 +278,7 @@ __setup("nosmep", setup_disable_smep);
278static __always_inline void setup_smep(struct cpuinfo_x86 *c) 278static __always_inline void setup_smep(struct cpuinfo_x86 *c)
279{ 279{
280 if (cpu_has(c, X86_FEATURE_SMEP)) 280 if (cpu_has(c, X86_FEATURE_SMEP))
281 set_in_cr4(X86_CR4_SMEP); 281 cr4_set_bits(X86_CR4_SMEP);
282} 282}
283 283
284static __init int setup_disable_smap(char *arg) 284static __init int setup_disable_smap(char *arg)
@@ -298,9 +298,9 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
298 298
299 if (cpu_has(c, X86_FEATURE_SMAP)) { 299 if (cpu_has(c, X86_FEATURE_SMAP)) {
300#ifdef CONFIG_X86_SMAP 300#ifdef CONFIG_X86_SMAP
301 set_in_cr4(X86_CR4_SMAP); 301 cr4_set_bits(X86_CR4_SMAP);
302#else 302#else
303 clear_in_cr4(X86_CR4_SMAP); 303 cr4_clear_bits(X86_CR4_SMAP);
304#endif 304#endif
305 } 305 }
306} 306}
@@ -1312,7 +1312,7 @@ void cpu_init(void)
1312 1312
1313 pr_debug("Initializing CPU#%d\n", cpu); 1313 pr_debug("Initializing CPU#%d\n", cpu);
1314 1314
1315 clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE); 1315 cr4_clear_bits(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
1316 1316
1317 /* 1317 /*
1318 * Initialize the per-CPU GDT with the boot GDT, 1318 * Initialize the per-CPU GDT with the boot GDT,
@@ -1393,7 +1393,7 @@ void cpu_init(void)
1393 printk(KERN_INFO "Initializing CPU#%d\n", cpu); 1393 printk(KERN_INFO "Initializing CPU#%d\n", cpu);
1394 1394
1395 if (cpu_feature_enabled(X86_FEATURE_VME) || cpu_has_tsc || cpu_has_de) 1395 if (cpu_feature_enabled(X86_FEATURE_VME) || cpu_has_tsc || cpu_has_de)
1396 clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE); 1396 cr4_clear_bits(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
1397 1397
1398 load_current_idt(); 1398 load_current_idt();
1399 switch_to_new_gdt(cpu); 1399 switch_to_new_gdt(cpu);
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index d23179900755..15ad3ed1a3cd 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -44,6 +44,7 @@
44 44
45#include <asm/processor.h> 45#include <asm/processor.h>
46#include <asm/traps.h> 46#include <asm/traps.h>
47#include <asm/tlbflush.h>
47#include <asm/mce.h> 48#include <asm/mce.h>
48#include <asm/msr.h> 49#include <asm/msr.h>
49 50
@@ -1449,7 +1450,7 @@ static void __mcheck_cpu_init_generic(void)
1449 bitmap_fill(all_banks, MAX_NR_BANKS); 1450 bitmap_fill(all_banks, MAX_NR_BANKS);
1450 machine_check_poll(MCP_UC | m_fl, &all_banks); 1451 machine_check_poll(MCP_UC | m_fl, &all_banks);
1451 1452
1452 set_in_cr4(X86_CR4_MCE); 1453 cr4_set_bits(X86_CR4_MCE);
1453 1454
1454 rdmsrl(MSR_IA32_MCG_CAP, cap); 1455 rdmsrl(MSR_IA32_MCG_CAP, cap);
1455 if (cap & MCG_CTL_P) 1456 if (cap & MCG_CTL_P)
diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
index ec2663a708e4..737b0ad4e61a 100644
--- a/arch/x86/kernel/cpu/mcheck/p5.c
+++ b/arch/x86/kernel/cpu/mcheck/p5.c
@@ -9,6 +9,7 @@
9 9
10#include <asm/processor.h> 10#include <asm/processor.h>
11#include <asm/traps.h> 11#include <asm/traps.h>
12#include <asm/tlbflush.h>
12#include <asm/mce.h> 13#include <asm/mce.h>
13#include <asm/msr.h> 14#include <asm/msr.h>
14 15
@@ -65,7 +66,7 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
65 "Intel old style machine check architecture supported.\n"); 66 "Intel old style machine check architecture supported.\n");
66 67
67 /* Enable MCE: */ 68 /* Enable MCE: */
68 set_in_cr4(X86_CR4_MCE); 69 cr4_set_bits(X86_CR4_MCE);
69 printk(KERN_INFO 70 printk(KERN_INFO
70 "Intel old style machine check reporting enabled on CPU#%d.\n", 71 "Intel old style machine check reporting enabled on CPU#%d.\n",
71 smp_processor_id()); 72 smp_processor_id());
diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
index bd5d46a32210..44f138296fbe 100644
--- a/arch/x86/kernel/cpu/mcheck/winchip.c
+++ b/arch/x86/kernel/cpu/mcheck/winchip.c
@@ -8,6 +8,7 @@
8 8
9#include <asm/processor.h> 9#include <asm/processor.h>
10#include <asm/traps.h> 10#include <asm/traps.h>
11#include <asm/tlbflush.h>
11#include <asm/mce.h> 12#include <asm/mce.h>
12#include <asm/msr.h> 13#include <asm/msr.h>
13 14
@@ -36,7 +37,7 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
36 lo &= ~(1<<4); /* Enable MCE */ 37 lo &= ~(1<<4); /* Enable MCE */
37 wrmsr(MSR_IDT_FCR1, lo, hi); 38 wrmsr(MSR_IDT_FCR1, lo, hi);
38 39
39 set_in_cr4(X86_CR4_MCE); 40 cr4_set_bits(X86_CR4_MCE);
40 41
41 printk(KERN_INFO 42 printk(KERN_INFO
42 "Winchip machine check reporting enabled on CPU#0.\n"); 43 "Winchip machine check reporting enabled on CPU#0.\n");
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 143e5f5dc855..6b5acd5f4a34 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -31,6 +31,7 @@
31#include <asm/nmi.h> 31#include <asm/nmi.h>
32#include <asm/smp.h> 32#include <asm/smp.h>
33#include <asm/alternative.h> 33#include <asm/alternative.h>
34#include <asm/tlbflush.h>
34#include <asm/timer.h> 35#include <asm/timer.h>
35#include <asm/desc.h> 36#include <asm/desc.h>
36#include <asm/ldt.h> 37#include <asm/ldt.h>
@@ -1328,7 +1329,7 @@ x86_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
1328 1329
1329 case CPU_STARTING: 1330 case CPU_STARTING:
1330 if (x86_pmu.attr_rdpmc) 1331 if (x86_pmu.attr_rdpmc)
1331 set_in_cr4(X86_CR4_PCE); 1332 cr4_set_bits(X86_CR4_PCE);
1332 if (x86_pmu.cpu_starting) 1333 if (x86_pmu.cpu_starting)
1333 x86_pmu.cpu_starting(cpu); 1334 x86_pmu.cpu_starting(cpu);
1334 break; 1335 break;
@@ -1834,9 +1835,9 @@ static void change_rdpmc(void *info)
1834 bool enable = !!(unsigned long)info; 1835 bool enable = !!(unsigned long)info;
1835 1836
1836 if (enable) 1837 if (enable)
1837 set_in_cr4(X86_CR4_PCE); 1838 cr4_set_bits(X86_CR4_PCE);
1838 else 1839 else
1839 clear_in_cr4(X86_CR4_PCE); 1840 cr4_clear_bits(X86_CR4_PCE);
1840} 1841}
1841 1842
1842static ssize_t set_attr_rdpmc(struct device *cdev, 1843static ssize_t set_attr_rdpmc(struct device *cdev,
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index a9a4229f6161..87727b03196d 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -13,6 +13,7 @@
13#include <asm/sigcontext.h> 13#include <asm/sigcontext.h>
14#include <asm/processor.h> 14#include <asm/processor.h>
15#include <asm/math_emu.h> 15#include <asm/math_emu.h>
16#include <asm/tlbflush.h>
16#include <asm/uaccess.h> 17#include <asm/uaccess.h>
17#include <asm/ptrace.h> 18#include <asm/ptrace.h>
18#include <asm/i387.h> 19#include <asm/i387.h>
@@ -180,7 +181,7 @@ void fpu_init(void)
180 if (cpu_has_xmm) 181 if (cpu_has_xmm)
181 cr4_mask |= X86_CR4_OSXMMEXCPT; 182 cr4_mask |= X86_CR4_OSXMMEXCPT;
182 if (cr4_mask) 183 if (cr4_mask)
183 set_in_cr4(cr4_mask); 184 cr4_set_bits(cr4_mask);
184 185
185 cr0 = read_cr0(); 186 cr0 = read_cr0();
186 cr0 &= ~(X86_CR0_TS|X86_CR0_EM); /* clear TS and EM */ 187 cr0 &= ~(X86_CR0_TS|X86_CR0_EM); /* clear TS and EM */
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index e127ddaa2d5a..046e2d620bbe 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -28,6 +28,7 @@
28#include <asm/fpu-internal.h> 28#include <asm/fpu-internal.h>
29#include <asm/debugreg.h> 29#include <asm/debugreg.h>
30#include <asm/nmi.h> 30#include <asm/nmi.h>
31#include <asm/tlbflush.h>
31 32
32/* 33/*
33 * per-CPU TSS segments. Threads are completely 'soft' on Linux, 34 * per-CPU TSS segments. Threads are completely 'soft' on Linux,
@@ -141,7 +142,7 @@ void flush_thread(void)
141 142
142static void hard_disable_TSC(void) 143static void hard_disable_TSC(void)
143{ 144{
144 write_cr4(read_cr4() | X86_CR4_TSD); 145 cr4_set_bits(X86_CR4_TSD);
145} 146}
146 147
147void disable_TSC(void) 148void disable_TSC(void)
@@ -158,7 +159,7 @@ void disable_TSC(void)
158 159
159static void hard_enable_TSC(void) 160static void hard_enable_TSC(void)
160{ 161{
161 write_cr4(read_cr4() & ~X86_CR4_TSD); 162 cr4_clear_bits(X86_CR4_TSD);
162} 163}
163 164
164static void enable_TSC(void) 165static void enable_TSC(void)
diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index 0de1fae2bdf0..34f66e58a896 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -12,6 +12,7 @@
12#include <asm/i387.h> 12#include <asm/i387.h>
13#include <asm/fpu-internal.h> 13#include <asm/fpu-internal.h>
14#include <asm/sigframe.h> 14#include <asm/sigframe.h>
15#include <asm/tlbflush.h>
15#include <asm/xcr.h> 16#include <asm/xcr.h>
16 17
17/* 18/*
@@ -453,7 +454,7 @@ static void prepare_fx_sw_frame(void)
453 */ 454 */
454static inline void xstate_enable(void) 455static inline void xstate_enable(void)
455{ 456{
456 set_in_cr4(X86_CR4_OSXSAVE); 457 cr4_set_bits(X86_CR4_OSXSAVE);
457 xsetbv(XCR_XFEATURE_ENABLED_MASK, pcntxt_mask); 458 xsetbv(XCR_XFEATURE_ENABLED_MASK, pcntxt_mask);
458} 459}
459 460
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index d4c58d884838..db77537013d1 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2812,7 +2812,7 @@ static int hardware_enable(void)
2812 /* enable and lock */ 2812 /* enable and lock */
2813 wrmsrl(MSR_IA32_FEATURE_CONTROL, old | test_bits); 2813 wrmsrl(MSR_IA32_FEATURE_CONTROL, old | test_bits);
2814 } 2814 }
2815 write_cr4(read_cr4() | X86_CR4_VMXE); /* FIXME: not cpu hotplug safe */ 2815 cr4_set_bits(X86_CR4_VMXE);
2816 2816
2817 if (vmm_exclusive) { 2817 if (vmm_exclusive) {
2818 kvm_cpu_vmxon(phys_addr); 2818 kvm_cpu_vmxon(phys_addr);
@@ -2849,7 +2849,7 @@ static void hardware_disable(void)
2849 vmclear_local_loaded_vmcss(); 2849 vmclear_local_loaded_vmcss();
2850 kvm_cpu_vmxoff(); 2850 kvm_cpu_vmxoff();
2851 } 2851 }
2852 write_cr4(read_cr4() & ~X86_CR4_VMXE); 2852 cr4_clear_bits(X86_CR4_VMXE);
2853} 2853}
2854 2854
2855static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt, 2855static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt,
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 079c3b6a3ff1..d4eddbd92c28 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -173,11 +173,11 @@ static void __init probe_page_size_mask(void)
173 173
174 /* Enable PSE if available */ 174 /* Enable PSE if available */
175 if (cpu_has_pse) 175 if (cpu_has_pse)
176 set_in_cr4(X86_CR4_PSE); 176 cr4_set_bits_and_update_boot(X86_CR4_PSE);
177 177
178 /* Enable PGE if available */ 178 /* Enable PGE if available */
179 if (cpu_has_pge) { 179 if (cpu_has_pge) {
180 set_in_cr4(X86_CR4_PGE); 180 cr4_set_bits_and_update_boot(X86_CR4_PGE);
181 __supported_pte_mask |= _PAGE_GLOBAL; 181 __supported_pte_mask |= _PAGE_GLOBAL;
182 } 182 }
183} 183}
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 78a881b7fc41..bd8b8459c3d0 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1494,10 +1494,10 @@ static void xen_pvh_set_cr_flags(int cpu)
1494 * set them here. For all, OSFXSR OSXMMEXCPT are set in fpu_init. 1494 * set them here. For all, OSFXSR OSXMMEXCPT are set in fpu_init.
1495 */ 1495 */
1496 if (cpu_has_pse) 1496 if (cpu_has_pse)
1497 set_in_cr4(X86_CR4_PSE); 1497 cr4_set_bits_and_update_boot(X86_CR4_PSE);
1498 1498
1499 if (cpu_has_pge) 1499 if (cpu_has_pge)
1500 set_in_cr4(X86_CR4_PGE); 1500 cr4_set_bits_and_update_boot(X86_CR4_PGE);
1501} 1501}
1502 1502
1503/* 1503/*