diff options
| author | Jaswinder Singh Rajput <jaswinder@kernel.org> | 2009-03-14 01:49:49 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2009-03-14 03:59:50 -0400 |
| commit | 9766cdbcb260389669e9679b2aa87c11832f479f (patch) | |
| tree | df0d6591378c0ef79c99c31e452ff78727dce5ce | |
| parent | bf5172d07ac38e538e01143289e9b46076494ad5 (diff) | |
x86: cpu/common.c cleanups
- fix various style problems
- declare varibles before they get used
- introduced clear_all_debug_regs
- fix header files issues
LKML-Reference: <1237009789.4387.2.camel@localhost.localdomain>
Signed-off-by: Jaswinder Singh Rajput <jaswinder@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
| -rw-r--r-- | arch/x86/include/asm/processor.h | 3 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/common.c | 129 |
2 files changed, 68 insertions, 64 deletions
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 76139506c3e4..dccef5be0fc1 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
| @@ -391,6 +391,9 @@ DECLARE_PER_CPU(union irq_stack_union, irq_stack_union); | |||
| 391 | DECLARE_INIT_PER_CPU(irq_stack_union); | 391 | DECLARE_INIT_PER_CPU(irq_stack_union); |
| 392 | 392 | ||
| 393 | DECLARE_PER_CPU(char *, irq_stack_ptr); | 393 | DECLARE_PER_CPU(char *, irq_stack_ptr); |
| 394 | DECLARE_PER_CPU(unsigned int, irq_count); | ||
| 395 | extern unsigned long kernel_eflags; | ||
| 396 | extern asmlinkage void ignore_sysret(void); | ||
| 394 | #else /* X86_64 */ | 397 | #else /* X86_64 */ |
| 395 | #ifdef CONFIG_CC_STACKPROTECTOR | 398 | #ifdef CONFIG_CC_STACKPROTECTOR |
| 396 | DECLARE_PER_CPU(unsigned long, stack_canary); | 399 | DECLARE_PER_CPU(unsigned long, stack_canary); |
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 826d5c876278..cad6878c88db 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
| @@ -1,52 +1,52 @@ | |||
| 1 | #include <linux/init.h> | 1 | #include <linux/topology.h> |
| 2 | #include <linux/kernel.h> | ||
| 3 | #include <linux/sched.h> | ||
| 4 | #include <linux/string.h> | ||
| 5 | #include <linux/bootmem.h> | 2 | #include <linux/bootmem.h> |
| 3 | #include <linux/linkage.h> | ||
| 6 | #include <linux/bitops.h> | 4 | #include <linux/bitops.h> |
| 5 | #include <linux/kernel.h> | ||
| 7 | #include <linux/module.h> | 6 | #include <linux/module.h> |
| 8 | #include <linux/kgdb.h> | 7 | #include <linux/percpu.h> |
| 9 | #include <linux/topology.h> | 8 | #include <linux/string.h> |
| 10 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
| 10 | #include <linux/sched.h> | ||
| 11 | #include <linux/init.h> | ||
| 12 | #include <linux/kgdb.h> | ||
| 11 | #include <linux/smp.h> | 13 | #include <linux/smp.h> |
| 12 | #include <linux/percpu.h> | 14 | #include <linux/io.h> |
| 13 | #include <asm/i387.h> | 15 | |
| 14 | #include <asm/msr.h> | 16 | #include <asm/stackprotector.h> |
| 15 | #include <asm/io.h> | ||
| 16 | #include <asm/linkage.h> | ||
| 17 | #include <asm/mmu_context.h> | 17 | #include <asm/mmu_context.h> |
| 18 | #include <asm/hypervisor.h> | ||
| 19 | #include <asm/processor.h> | ||
| 20 | #include <asm/sections.h> | ||
| 21 | #include <asm/cpumask.h> | ||
| 22 | #include <asm/pgtable.h> | ||
| 23 | #include <asm/atomic.h> | ||
| 24 | #include <asm/proto.h> | ||
| 25 | #include <asm/setup.h> | ||
| 26 | #include <asm/apic.h> | ||
| 27 | #include <asm/desc.h> | ||
| 28 | #include <asm/i387.h> | ||
| 18 | #include <asm/mtrr.h> | 29 | #include <asm/mtrr.h> |
| 30 | #include <asm/numa.h> | ||
| 31 | #include <asm/asm.h> | ||
| 32 | #include <asm/cpu.h> | ||
| 19 | #include <asm/mce.h> | 33 | #include <asm/mce.h> |
| 34 | #include <asm/msr.h> | ||
| 20 | #include <asm/pat.h> | 35 | #include <asm/pat.h> |
| 21 | #include <asm/asm.h> | ||
| 22 | #include <asm/numa.h> | ||
| 23 | #include <asm/smp.h> | 36 | #include <asm/smp.h> |
| 24 | #include <asm/cpu.h> | ||
| 25 | #include <asm/cpumask.h> | ||
| 26 | #include <asm/apic.h> | ||
| 27 | 37 | ||
| 28 | #ifdef CONFIG_X86_LOCAL_APIC | 38 | #ifdef CONFIG_X86_LOCAL_APIC |
| 29 | #include <asm/uv/uv.h> | 39 | #include <asm/uv/uv.h> |
| 30 | #endif | 40 | #endif |
| 31 | 41 | ||
| 32 | #include <asm/pgtable.h> | ||
| 33 | #include <asm/processor.h> | ||
| 34 | #include <asm/desc.h> | ||
| 35 | #include <asm/atomic.h> | ||
| 36 | #include <asm/proto.h> | ||
| 37 | #include <asm/sections.h> | ||
| 38 | #include <asm/setup.h> | ||
| 39 | #include <asm/hypervisor.h> | ||
| 40 | #include <asm/stackprotector.h> | ||
| 41 | |||
| 42 | #include "cpu.h" | 42 | #include "cpu.h" |
| 43 | 43 | ||
| 44 | #ifdef CONFIG_X86_64 | 44 | #ifdef CONFIG_X86_64 |
| 45 | 45 | ||
| 46 | /* all of these masks are initialized in setup_cpu_local_masks() */ | 46 | /* all of these masks are initialized in setup_cpu_local_masks() */ |
| 47 | cpumask_var_t cpu_callin_mask; | ||
| 48 | cpumask_var_t cpu_callout_mask; | ||
| 49 | cpumask_var_t cpu_initialized_mask; | 47 | cpumask_var_t cpu_initialized_mask; |
| 48 | cpumask_var_t cpu_callout_mask; | ||
| 49 | cpumask_var_t cpu_callin_mask; | ||
| 50 | 50 | ||
| 51 | /* representing cpus for which sibling maps can be computed */ | 51 | /* representing cpus for which sibling maps can be computed */ |
| 52 | cpumask_var_t cpu_sibling_setup_mask; | 52 | cpumask_var_t cpu_sibling_setup_mask; |
| @@ -62,10 +62,10 @@ void __init setup_cpu_local_masks(void) | |||
| 62 | 62 | ||
| 63 | #else /* CONFIG_X86_32 */ | 63 | #else /* CONFIG_X86_32 */ |
| 64 | 64 | ||
| 65 | cpumask_t cpu_callin_map; | 65 | cpumask_t cpu_sibling_setup_map; |
| 66 | cpumask_t cpu_callout_map; | 66 | cpumask_t cpu_callout_map; |
| 67 | cpumask_t cpu_initialized; | 67 | cpumask_t cpu_initialized; |
| 68 | cpumask_t cpu_sibling_setup_map; | 68 | cpumask_t cpu_callin_map; |
| 69 | 69 | ||
| 70 | #endif /* CONFIG_X86_32 */ | 70 | #endif /* CONFIG_X86_32 */ |
| 71 | 71 | ||
| @@ -79,7 +79,7 @@ DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { | |||
| 79 | * IRET will check the segment types kkeil 2000/10/28 | 79 | * IRET will check the segment types kkeil 2000/10/28 |
| 80 | * Also sysret mandates a special GDT layout | 80 | * Also sysret mandates a special GDT layout |
| 81 | * | 81 | * |
| 82 | * The TLS descriptors are currently at a different place compared to i386. | 82 | * TLS descriptors are currently at a different place compared to i386. |
| 83 | * Hopefully nobody expects them at a fixed place (Wine?) | 83 | * Hopefully nobody expects them at a fixed place (Wine?) |
| 84 | */ | 84 | */ |
| 85 | [GDT_ENTRY_KERNEL32_CS] = { { { 0x0000ffff, 0x00cf9b00 } } }, | 85 | [GDT_ENTRY_KERNEL32_CS] = { { { 0x0000ffff, 0x00cf9b00 } } }, |
| @@ -243,6 +243,7 @@ cpuid_dependent_features[] = { | |||
| 243 | static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn) | 243 | static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn) |
| 244 | { | 244 | { |
| 245 | const struct cpuid_dependent_feature *df; | 245 | const struct cpuid_dependent_feature *df; |
| 246 | |||
| 246 | for (df = cpuid_dependent_features; df->feature; df++) { | 247 | for (df = cpuid_dependent_features; df->feature; df++) { |
| 247 | /* | 248 | /* |
| 248 | * Note: cpuid_level is set to -1 if unavailable, but | 249 | * Note: cpuid_level is set to -1 if unavailable, but |
| @@ -364,12 +365,12 @@ static void __cpuinit get_model_name(struct cpuinfo_x86 *c) | |||
| 364 | undo that brain damage */ | 365 | undo that brain damage */ |
| 365 | p = q = &c->x86_model_id[0]; | 366 | p = q = &c->x86_model_id[0]; |
| 366 | while (*p == ' ') | 367 | while (*p == ' ') |
| 367 | p++; | 368 | p++; |
| 368 | if (p != q) { | 369 | if (p != q) { |
| 369 | while (*p) | 370 | while (*p) |
| 370 | *q++ = *p++; | 371 | *q++ = *p++; |
| 371 | while (q <= &c->x86_model_id[48]) | 372 | while (q <= &c->x86_model_id[48]) |
| 372 | *q++ = '\0'; /* Zero-pad the rest */ | 373 | *q++ = '\0'; /* Zero-pad the rest */ |
| 373 | } | 374 | } |
| 374 | } | 375 | } |
| 375 | 376 | ||
| @@ -441,14 +442,15 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c) | |||
| 441 | } else if (smp_num_siblings > 1) { | 442 | } else if (smp_num_siblings > 1) { |
| 442 | 443 | ||
| 443 | if (smp_num_siblings > nr_cpu_ids) { | 444 | if (smp_num_siblings > nr_cpu_ids) { |
| 444 | printk(KERN_WARNING "CPU: Unsupported number of siblings %d", | 445 | pr_warning("CPU: Unsupported number of siblings %d", |
| 445 | smp_num_siblings); | 446 | smp_num_siblings); |
| 446 | smp_num_siblings = 1; | 447 | smp_num_siblings = 1; |
| 447 | return; | 448 | return; |
| 448 | } | 449 | } |
| 449 | 450 | ||
| 450 | index_msb = get_count_order(smp_num_siblings); | 451 | index_msb = get_count_order(smp_num_siblings); |
| 451 | c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid, index_msb); | 452 | c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid, |
| 453 | index_msb); | ||
| 452 | 454 | ||
| 453 | smp_num_siblings = smp_num_siblings / c->x86_max_cores; | 455 | smp_num_siblings = smp_num_siblings / c->x86_max_cores; |
| 454 | 456 | ||
| @@ -491,7 +493,8 @@ static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) | |||
| 491 | 493 | ||
| 492 | if (!printed) { | 494 | if (!printed) { |
| 493 | printed++; | 495 | printed++; |
| 494 | printk(KERN_ERR "CPU: vendor_id '%s' unknown, using generic init.\n", v); | 496 | printk(KERN_ERR "CPU: vendor_id '%s'" |
| 497 | "unknown, using generic init.\n", v); | ||
| 495 | printk(KERN_ERR "CPU: Your system may be unstable.\n"); | 498 | printk(KERN_ERR "CPU: Your system may be unstable.\n"); |
| 496 | } | 499 | } |
| 497 | 500 | ||
| @@ -637,7 +640,7 @@ void __init early_cpu_init(void) | |||
| 637 | struct cpu_dev **cdev; | 640 | struct cpu_dev **cdev; |
| 638 | int count = 0; | 641 | int count = 0; |
| 639 | 642 | ||
| 640 | printk("KERNEL supported cpus:\n"); | 643 | printk(KERN_INFO "KERNEL supported cpus:\n"); |
| 641 | for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) { | 644 | for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) { |
| 642 | struct cpu_dev *cpudev = *cdev; | 645 | struct cpu_dev *cpudev = *cdev; |
| 643 | unsigned int j; | 646 | unsigned int j; |
| @@ -650,7 +653,7 @@ void __init early_cpu_init(void) | |||
| 650 | for (j = 0; j < 2; j++) { | 653 | for (j = 0; j < 2; j++) { |
| 651 | if (!cpudev->c_ident[j]) | 654 | if (!cpudev->c_ident[j]) |
| 652 | continue; | 655 | continue; |
| 653 | printk(" %s %s\n", cpudev->c_vendor, | 656 | printk(KERN_INFO " %s %s\n", cpudev->c_vendor, |
| 654 | cpudev->c_ident[j]); | 657 | cpudev->c_ident[j]); |
| 655 | } | 658 | } |
| 656 | } | 659 | } |
| @@ -952,8 +955,6 @@ static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks | |||
| 952 | [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]) | 955 | [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]) |
| 953 | __aligned(PAGE_SIZE); | 956 | __aligned(PAGE_SIZE); |
| 954 | 957 | ||
| 955 | extern asmlinkage void ignore_sysret(void); | ||
| 956 | |||
| 957 | /* May not be marked __init: used by software suspend */ | 958 | /* May not be marked __init: used by software suspend */ |
| 958 | void syscall_init(void) | 959 | void syscall_init(void) |
| 959 | { | 960 | { |
| @@ -1000,6 +1001,22 @@ struct pt_regs * __cpuinit idle_regs(struct pt_regs *regs) | |||
| 1000 | #endif /* x86_64 */ | 1001 | #endif /* x86_64 */ |
| 1001 | 1002 | ||
| 1002 | /* | 1003 | /* |
| 1004 | * Clear all 6 debug registers: | ||
| 1005 | */ | ||
| 1006 | static void clear_all_debug_regs(void) | ||
| 1007 | { | ||
| 1008 | int i; | ||
| 1009 | |||
| 1010 | for (i = 0; i < 8; i++) { | ||
| 1011 | /* Ignore db4, db5 */ | ||
| 1012 | if ((i == 4) || (i == 5)) | ||
| 1013 | continue; | ||
| 1014 | |||
| 1015 | set_debugreg(0, i); | ||
| 1016 | } | ||
| 1017 | } | ||
| 1018 | |||
| 1019 | /* | ||
| 1003 | * cpu_init() initializes state that is per-CPU. Some data is already | 1020 | * cpu_init() initializes state that is per-CPU. Some data is already |
| 1004 | * initialized (naturally) in the bootstrap process, such as the GDT | 1021 | * initialized (naturally) in the bootstrap process, such as the GDT |
| 1005 | * and IDT. We reload them nevertheless, this function acts as a | 1022 | * and IDT. We reload them nevertheless, this function acts as a |
| @@ -1098,17 +1115,7 @@ void __cpuinit cpu_init(void) | |||
| 1098 | arch_kgdb_ops.correct_hw_break(); | 1115 | arch_kgdb_ops.correct_hw_break(); |
| 1099 | else | 1116 | else |
| 1100 | #endif | 1117 | #endif |
| 1101 | { | 1118 | clear_all_debug_regs(); |
| 1102 | /* | ||
| 1103 | * Clear all 6 debug registers: | ||
| 1104 | */ | ||
| 1105 | set_debugreg(0UL, 0); | ||
| 1106 | set_debugreg(0UL, 1); | ||
| 1107 | set_debugreg(0UL, 2); | ||
| 1108 | set_debugreg(0UL, 3); | ||
| 1109 | set_debugreg(0UL, 6); | ||
| 1110 | set_debugreg(0UL, 7); | ||
| 1111 | } | ||
| 1112 | 1119 | ||
| 1113 | fpu_init(); | 1120 | fpu_init(); |
| 1114 | 1121 | ||
| @@ -1129,7 +1136,8 @@ void __cpuinit cpu_init(void) | |||
| 1129 | 1136 | ||
| 1130 | if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) { | 1137 | if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) { |
| 1131 | printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); | 1138 | printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); |
| 1132 | for (;;) local_irq_enable(); | 1139 | for (;;) |
| 1140 | local_irq_enable(); | ||
| 1133 | } | 1141 | } |
| 1134 | 1142 | ||
| 1135 | printk(KERN_INFO "Initializing CPU#%d\n", cpu); | 1143 | printk(KERN_INFO "Initializing CPU#%d\n", cpu); |
| @@ -1159,13 +1167,7 @@ void __cpuinit cpu_init(void) | |||
| 1159 | __set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss); | 1167 | __set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss); |
| 1160 | #endif | 1168 | #endif |
| 1161 | 1169 | ||
| 1162 | /* Clear all 6 debug registers: */ | 1170 | clear_all_debug_regs(); |
| 1163 | set_debugreg(0, 0); | ||
| 1164 | set_debugreg(0, 1); | ||
| 1165 | set_debugreg(0, 2); | ||
| 1166 | set_debugreg(0, 3); | ||
| 1167 | set_debugreg(0, 6); | ||
| 1168 | set_debugreg(0, 7); | ||
| 1169 | 1171 | ||
| 1170 | /* | 1172 | /* |
| 1171 | * Force FPU initialization: | 1173 | * Force FPU initialization: |
| @@ -1186,5 +1188,4 @@ void __cpuinit cpu_init(void) | |||
| 1186 | xsave_init(); | 1188 | xsave_init(); |
| 1187 | } | 1189 | } |
| 1188 | 1190 | ||
| 1189 | |||
| 1190 | #endif | 1191 | #endif |
