Commit 9766cdbc authored by Jaswinder Singh Rajput's avatar Jaswinder Singh Rajput Committed by Ingo Molnar

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: default avatarJaswinder Singh Rajput <jaswinder@kernel.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent bf5172d0
...@@ -391,6 +391,9 @@ DECLARE_PER_CPU(union irq_stack_union, irq_stack_union); ...@@ -391,6 +391,9 @@ DECLARE_PER_CPU(union irq_stack_union, irq_stack_union);
DECLARE_INIT_PER_CPU(irq_stack_union); DECLARE_INIT_PER_CPU(irq_stack_union);
DECLARE_PER_CPU(char *, irq_stack_ptr); DECLARE_PER_CPU(char *, irq_stack_ptr);
DECLARE_PER_CPU(unsigned int, irq_count);
extern unsigned long kernel_eflags;
extern asmlinkage void ignore_sysret(void);
#else /* X86_64 */ #else /* X86_64 */
#ifdef CONFIG_CC_STACKPROTECTOR #ifdef CONFIG_CC_STACKPROTECTOR
DECLARE_PER_CPU(unsigned long, stack_canary); DECLARE_PER_CPU(unsigned long, stack_canary);
......
#include <linux/init.h> #include <linux/topology.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/linkage.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kgdb.h> #include <linux/percpu.h>
#include <linux/topology.h> #include <linux/string.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/sched.h>
#include <linux/init.h>
#include <linux/kgdb.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/percpu.h> #include <linux/io.h>
#include <asm/i387.h>
#include <asm/msr.h> #include <asm/stackprotector.h>
#include <asm/io.h>
#include <asm/linkage.h>
#include <asm/mmu_context.h> #include <asm/mmu_context.h>
#include <asm/hypervisor.h>
#include <asm/processor.h>
#include <asm/sections.h>
#include <asm/cpumask.h>
#include <asm/pgtable.h>
#include <asm/atomic.h>
#include <asm/proto.h>
#include <asm/setup.h>
#include <asm/apic.h>
#include <asm/desc.h>
#include <asm/i387.h>
#include <asm/mtrr.h> #include <asm/mtrr.h>
#include <asm/numa.h>
#include <asm/asm.h>
#include <asm/cpu.h>
#include <asm/mce.h> #include <asm/mce.h>
#include <asm/msr.h>
#include <asm/pat.h> #include <asm/pat.h>
#include <asm/asm.h>
#include <asm/numa.h>
#include <asm/smp.h> #include <asm/smp.h>
#include <asm/cpu.h>
#include <asm/cpumask.h>
#include <asm/apic.h>
#ifdef CONFIG_X86_LOCAL_APIC #ifdef CONFIG_X86_LOCAL_APIC
#include <asm/uv/uv.h> #include <asm/uv/uv.h>
#endif #endif
#include <asm/pgtable.h>
#include <asm/processor.h>
#include <asm/desc.h>
#include <asm/atomic.h>
#include <asm/proto.h>
#include <asm/sections.h>
#include <asm/setup.h>
#include <asm/hypervisor.h>
#include <asm/stackprotector.h>
#include "cpu.h" #include "cpu.h"
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
/* all of these masks are initialized in setup_cpu_local_masks() */ /* all of these masks are initialized in setup_cpu_local_masks() */
cpumask_var_t cpu_callin_mask;
cpumask_var_t cpu_callout_mask;
cpumask_var_t cpu_initialized_mask; cpumask_var_t cpu_initialized_mask;
cpumask_var_t cpu_callout_mask;
cpumask_var_t cpu_callin_mask;
/* representing cpus for which sibling maps can be computed */ /* representing cpus for which sibling maps can be computed */
cpumask_var_t cpu_sibling_setup_mask; cpumask_var_t cpu_sibling_setup_mask;
...@@ -62,10 +62,10 @@ void __init setup_cpu_local_masks(void) ...@@ -62,10 +62,10 @@ void __init setup_cpu_local_masks(void)
#else /* CONFIG_X86_32 */ #else /* CONFIG_X86_32 */
cpumask_t cpu_callin_map; cpumask_t cpu_sibling_setup_map;
cpumask_t cpu_callout_map; cpumask_t cpu_callout_map;
cpumask_t cpu_initialized; cpumask_t cpu_initialized;
cpumask_t cpu_sibling_setup_map; cpumask_t cpu_callin_map;
#endif /* CONFIG_X86_32 */ #endif /* CONFIG_X86_32 */
...@@ -79,7 +79,7 @@ DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { ...@@ -79,7 +79,7 @@ DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
* IRET will check the segment types kkeil 2000/10/28 * IRET will check the segment types kkeil 2000/10/28
* Also sysret mandates a special GDT layout * Also sysret mandates a special GDT layout
* *
* The TLS descriptors are currently at a different place compared to i386. * TLS descriptors are currently at a different place compared to i386.
* Hopefully nobody expects them at a fixed place (Wine?) * Hopefully nobody expects them at a fixed place (Wine?)
*/ */
[GDT_ENTRY_KERNEL32_CS] = { { { 0x0000ffff, 0x00cf9b00 } } }, [GDT_ENTRY_KERNEL32_CS] = { { { 0x0000ffff, 0x00cf9b00 } } },
...@@ -243,6 +243,7 @@ cpuid_dependent_features[] = { ...@@ -243,6 +243,7 @@ cpuid_dependent_features[] = {
static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn) static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn)
{ {
const struct cpuid_dependent_feature *df; const struct cpuid_dependent_feature *df;
for (df = cpuid_dependent_features; df->feature; df++) { for (df = cpuid_dependent_features; df->feature; df++) {
/* /*
* Note: cpuid_level is set to -1 if unavailable, but * Note: cpuid_level is set to -1 if unavailable, but
...@@ -441,14 +442,15 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c) ...@@ -441,14 +442,15 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
} else if (smp_num_siblings > 1) { } else if (smp_num_siblings > 1) {
if (smp_num_siblings > nr_cpu_ids) { if (smp_num_siblings > nr_cpu_ids) {
printk(KERN_WARNING "CPU: Unsupported number of siblings %d", pr_warning("CPU: Unsupported number of siblings %d",
smp_num_siblings); smp_num_siblings);
smp_num_siblings = 1; smp_num_siblings = 1;
return; return;
} }
index_msb = get_count_order(smp_num_siblings); index_msb = get_count_order(smp_num_siblings);
c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid, index_msb); c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid,
index_msb);
smp_num_siblings = smp_num_siblings / c->x86_max_cores; smp_num_siblings = smp_num_siblings / c->x86_max_cores;
...@@ -491,7 +493,8 @@ static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) ...@@ -491,7 +493,8 @@ static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
if (!printed) { if (!printed) {
printed++; printed++;
printk(KERN_ERR "CPU: vendor_id '%s' unknown, using generic init.\n", v); printk(KERN_ERR "CPU: vendor_id '%s'"
"unknown, using generic init.\n", v);
printk(KERN_ERR "CPU: Your system may be unstable.\n"); printk(KERN_ERR "CPU: Your system may be unstable.\n");
} }
...@@ -637,7 +640,7 @@ void __init early_cpu_init(void) ...@@ -637,7 +640,7 @@ void __init early_cpu_init(void)
struct cpu_dev **cdev; struct cpu_dev **cdev;
int count = 0; int count = 0;
printk("KERNEL supported cpus:\n"); printk(KERN_INFO "KERNEL supported cpus:\n");
for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) { for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) {
struct cpu_dev *cpudev = *cdev; struct cpu_dev *cpudev = *cdev;
unsigned int j; unsigned int j;
...@@ -650,7 +653,7 @@ void __init early_cpu_init(void) ...@@ -650,7 +653,7 @@ void __init early_cpu_init(void)
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
if (!cpudev->c_ident[j]) if (!cpudev->c_ident[j])
continue; continue;
printk(" %s %s\n", cpudev->c_vendor, printk(KERN_INFO " %s %s\n", cpudev->c_vendor,
cpudev->c_ident[j]); cpudev->c_ident[j]);
} }
} }
...@@ -952,8 +955,6 @@ static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks ...@@ -952,8 +955,6 @@ static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks
[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]) [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ])
__aligned(PAGE_SIZE); __aligned(PAGE_SIZE);
extern asmlinkage void ignore_sysret(void);
/* May not be marked __init: used by software suspend */ /* May not be marked __init: used by software suspend */
void syscall_init(void) void syscall_init(void)
{ {
...@@ -999,6 +1000,22 @@ struct pt_regs * __cpuinit idle_regs(struct pt_regs *regs) ...@@ -999,6 +1000,22 @@ struct pt_regs * __cpuinit idle_regs(struct pt_regs *regs)
} }
#endif /* x86_64 */ #endif /* x86_64 */
/*
* Clear all 6 debug registers:
*/
static void clear_all_debug_regs(void)
{
int i;
for (i = 0; i < 8; i++) {
/* Ignore db4, db5 */
if ((i == 4) || (i == 5))
continue;
set_debugreg(0, i);
}
}
/* /*
* cpu_init() initializes state that is per-CPU. Some data is already * cpu_init() initializes state that is per-CPU. Some data is already
* initialized (naturally) in the bootstrap process, such as the GDT * initialized (naturally) in the bootstrap process, such as the GDT
...@@ -1098,17 +1115,7 @@ void __cpuinit cpu_init(void) ...@@ -1098,17 +1115,7 @@ void __cpuinit cpu_init(void)
arch_kgdb_ops.correct_hw_break(); arch_kgdb_ops.correct_hw_break();
else else
#endif #endif
{ clear_all_debug_regs();
/*
* Clear all 6 debug registers:
*/
set_debugreg(0UL, 0);
set_debugreg(0UL, 1);
set_debugreg(0UL, 2);
set_debugreg(0UL, 3);
set_debugreg(0UL, 6);
set_debugreg(0UL, 7);
}
fpu_init(); fpu_init();
...@@ -1129,7 +1136,8 @@ void __cpuinit cpu_init(void) ...@@ -1129,7 +1136,8 @@ void __cpuinit cpu_init(void)
if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) { if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); printk(KERN_WARNING "CPU#%d already initialized!\n", cpu);
for (;;) local_irq_enable(); for (;;)
local_irq_enable();
} }
printk(KERN_INFO "Initializing CPU#%d\n", cpu); printk(KERN_INFO "Initializing CPU#%d\n", cpu);
...@@ -1159,13 +1167,7 @@ void __cpuinit cpu_init(void) ...@@ -1159,13 +1167,7 @@ void __cpuinit cpu_init(void)
__set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss); __set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss);
#endif #endif
/* Clear all 6 debug registers: */ clear_all_debug_regs();
set_debugreg(0, 0);
set_debugreg(0, 1);
set_debugreg(0, 2);
set_debugreg(0, 3);
set_debugreg(0, 6);
set_debugreg(0, 7);
/* /*
* Force FPU initialization: * Force FPU initialization:
...@@ -1186,5 +1188,4 @@ void __cpuinit cpu_init(void) ...@@ -1186,5 +1188,4 @@ void __cpuinit cpu_init(void)
xsave_init(); xsave_init();
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment