diff options
Diffstat (limited to 'arch/i386/kernel')
| -rw-r--r-- | arch/i386/kernel/Makefile | 2 | ||||
| -rw-r--r-- | arch/i386/kernel/cpu/common.c | 32 | ||||
| -rw-r--r-- | arch/i386/kernel/efi.c | 12 | ||||
| -rw-r--r-- | arch/i386/kernel/head.S | 2 | ||||
| -rw-r--r-- | arch/i386/kernel/i386_ksyms.c | 2 | ||||
| -rw-r--r-- | arch/i386/kernel/io_apic.c | 6 | ||||
| -rw-r--r-- | arch/i386/kernel/kprobes.c | 16 | ||||
| -rw-r--r-- | arch/i386/kernel/microcode.c | 15 | ||||
| -rw-r--r-- | arch/i386/kernel/mpparse.c | 10 | ||||
| -rw-r--r-- | arch/i386/kernel/smpboot.c | 6 | ||||
| -rw-r--r-- | arch/i386/kernel/topology.c | 97 |
11 files changed, 168 insertions, 32 deletions
diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile index 60c3f76dfca4..53bb9a79e274 100644 --- a/arch/i386/kernel/Makefile +++ b/arch/i386/kernel/Makefile | |||
| @@ -7,7 +7,7 @@ extra-y := head.o init_task.o vmlinux.lds | |||
| 7 | obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \ | 7 | obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \ |
| 8 | ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \ | 8 | ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \ |
| 9 | pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \ | 9 | pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \ |
| 10 | quirks.o i8237.o | 10 | quirks.o i8237.o topology.o |
| 11 | 11 | ||
| 12 | obj-y += cpu/ | 12 | obj-y += cpu/ |
| 13 | obj-y += timers/ | 13 | obj-y += timers/ |
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c index 7eb9213734a3..4ecd4b326ded 100644 --- a/arch/i386/kernel/cpu/common.c +++ b/arch/i386/kernel/cpu/common.c | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include <linux/smp.h> | 4 | #include <linux/smp.h> |
| 5 | #include <linux/module.h> | 5 | #include <linux/module.h> |
| 6 | #include <linux/percpu.h> | 6 | #include <linux/percpu.h> |
| 7 | #include <linux/bootmem.h> | ||
| 7 | #include <asm/semaphore.h> | 8 | #include <asm/semaphore.h> |
| 8 | #include <asm/processor.h> | 9 | #include <asm/processor.h> |
| 9 | #include <asm/i387.h> | 10 | #include <asm/i387.h> |
| @@ -18,6 +19,9 @@ | |||
| 18 | 19 | ||
| 19 | #include "cpu.h" | 20 | #include "cpu.h" |
| 20 | 21 | ||
| 22 | DEFINE_PER_CPU(struct Xgt_desc_struct, cpu_gdt_descr); | ||
| 23 | EXPORT_PER_CPU_SYMBOL(cpu_gdt_descr); | ||
| 24 | |||
| 21 | DEFINE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]); | 25 | DEFINE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]); |
| 22 | EXPORT_PER_CPU_SYMBOL(cpu_16bit_stack); | 26 | EXPORT_PER_CPU_SYMBOL(cpu_16bit_stack); |
| 23 | 27 | ||
| @@ -571,8 +575,9 @@ void __devinit cpu_init(void) | |||
| 571 | int cpu = smp_processor_id(); | 575 | int cpu = smp_processor_id(); |
| 572 | struct tss_struct * t = &per_cpu(init_tss, cpu); | 576 | struct tss_struct * t = &per_cpu(init_tss, cpu); |
| 573 | struct thread_struct *thread = ¤t->thread; | 577 | struct thread_struct *thread = ¤t->thread; |
| 574 | struct desc_struct *gdt = get_cpu_gdt_table(cpu); | 578 | struct desc_struct *gdt; |
| 575 | __u32 stk16_off = (__u32)&per_cpu(cpu_16bit_stack, cpu); | 579 | __u32 stk16_off = (__u32)&per_cpu(cpu_16bit_stack, cpu); |
| 580 | struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu); | ||
| 576 | 581 | ||
| 577 | if (cpu_test_and_set(cpu, cpu_initialized)) { | 582 | if (cpu_test_and_set(cpu, cpu_initialized)) { |
| 578 | printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); | 583 | printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); |
| @@ -590,6 +595,25 @@ void __devinit cpu_init(void) | |||
| 590 | } | 595 | } |
| 591 | 596 | ||
| 592 | /* | 597 | /* |
| 598 | * This is a horrible hack to allocate the GDT. The problem | ||
| 599 | * is that cpu_init() is called really early for the boot CPU | ||
| 600 | * (and hence needs bootmem) but much later for the secondary | ||
| 601 | * CPUs, when bootmem will have gone away | ||
| 602 | */ | ||
| 603 | if (NODE_DATA(0)->bdata->node_bootmem_map) { | ||
| 604 | gdt = (struct desc_struct *)alloc_bootmem_pages(PAGE_SIZE); | ||
| 605 | /* alloc_bootmem_pages panics on failure, so no check */ | ||
| 606 | memset(gdt, 0, PAGE_SIZE); | ||
| 607 | } else { | ||
| 608 | gdt = (struct desc_struct *)get_zeroed_page(GFP_KERNEL); | ||
| 609 | if (unlikely(!gdt)) { | ||
| 610 | printk(KERN_CRIT "CPU%d failed to allocate GDT\n", cpu); | ||
| 611 | for (;;) | ||
| 612 | local_irq_enable(); | ||
| 613 | } | ||
| 614 | } | ||
| 615 | |||
| 616 | /* | ||
| 593 | * Initialize the per-CPU GDT with the boot GDT, | 617 | * Initialize the per-CPU GDT with the boot GDT, |
| 594 | * and set up the GDT descriptor: | 618 | * and set up the GDT descriptor: |
| 595 | */ | 619 | */ |
| @@ -601,10 +625,10 @@ void __devinit cpu_init(void) | |||
| 601 | ((((__u64)stk16_off) << 32) & 0xff00000000000000ULL) | | 625 | ((((__u64)stk16_off) << 32) & 0xff00000000000000ULL) | |
| 602 | (CPU_16BIT_STACK_SIZE - 1); | 626 | (CPU_16BIT_STACK_SIZE - 1); |
| 603 | 627 | ||
| 604 | cpu_gdt_descr[cpu].size = GDT_SIZE - 1; | 628 | cpu_gdt_descr->size = GDT_SIZE - 1; |
| 605 | cpu_gdt_descr[cpu].address = (unsigned long)gdt; | 629 | cpu_gdt_descr->address = (unsigned long)gdt; |
| 606 | 630 | ||
| 607 | load_gdt(&cpu_gdt_descr[cpu]); | 631 | load_gdt(cpu_gdt_descr); |
| 608 | load_idt(&idt_descr); | 632 | load_idt(&idt_descr); |
| 609 | 633 | ||
| 610 | /* | 634 | /* |
diff --git a/arch/i386/kernel/efi.c b/arch/i386/kernel/efi.c index ecad519fd395..e3e42fd62401 100644 --- a/arch/i386/kernel/efi.c +++ b/arch/i386/kernel/efi.c | |||
| @@ -103,17 +103,19 @@ static void efi_call_phys_prelog(void) | |||
| 103 | */ | 103 | */ |
| 104 | local_flush_tlb(); | 104 | local_flush_tlb(); |
| 105 | 105 | ||
| 106 | cpu_gdt_descr[0].address = __pa(cpu_gdt_descr[0].address); | 106 | per_cpu(cpu_gdt_descr, 0).address = |
| 107 | load_gdt((struct Xgt_desc_struct *) __pa(&cpu_gdt_descr[0])); | 107 | __pa(per_cpu(cpu_gdt_descr, 0).address); |
| 108 | load_gdt((struct Xgt_desc_struct *)__pa(&per_cpu(cpu_gdt_descr, 0))); | ||
| 108 | } | 109 | } |
| 109 | 110 | ||
| 110 | static void efi_call_phys_epilog(void) | 111 | static void efi_call_phys_epilog(void) |
| 111 | { | 112 | { |
| 112 | unsigned long cr4; | 113 | unsigned long cr4; |
| 113 | 114 | ||
| 114 | cpu_gdt_descr[0].address = | 115 | per_cpu(cpu_gdt_descr, 0).address = |
| 115 | (unsigned long) __va(cpu_gdt_descr[0].address); | 116 | (unsigned long)__va(per_cpu(cpu_gdt_descr, 0).address); |
| 116 | load_gdt(&cpu_gdt_descr[0]); | 117 | load_gdt((struct Xgt_desc_struct *)__va(&per_cpu(cpu_gdt_descr, 0))); |
| 118 | |||
| 117 | cr4 = read_cr4(); | 119 | cr4 = read_cr4(); |
| 118 | 120 | ||
| 119 | if (cr4 & X86_CR4_PSE) { | 121 | if (cr4 & X86_CR4_PSE) { |
diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S index 2bee6499edd9..e0b7c632efbc 100644 --- a/arch/i386/kernel/head.S +++ b/arch/i386/kernel/head.S | |||
| @@ -534,5 +534,3 @@ ENTRY(cpu_gdt_table) | |||
| 534 | .quad 0x0000000000000000 /* 0xf0 - unused */ | 534 | .quad 0x0000000000000000 /* 0xf0 - unused */ |
| 535 | .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */ | 535 | .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */ |
| 536 | 536 | ||
| 537 | /* Be sure this is zeroed to avoid false validations in Xen */ | ||
| 538 | .fill PAGE_SIZE_asm / 8 - GDT_ENTRIES,8,0 | ||
diff --git a/arch/i386/kernel/i386_ksyms.c b/arch/i386/kernel/i386_ksyms.c index 3999bec50c33..055325056a74 100644 --- a/arch/i386/kernel/i386_ksyms.c +++ b/arch/i386/kernel/i386_ksyms.c | |||
| @@ -3,8 +3,6 @@ | |||
| 3 | #include <asm/checksum.h> | 3 | #include <asm/checksum.h> |
| 4 | #include <asm/desc.h> | 4 | #include <asm/desc.h> |
| 5 | 5 | ||
| 6 | EXPORT_SYMBOL_GPL(cpu_gdt_descr); | ||
| 7 | |||
| 8 | EXPORT_SYMBOL(__down_failed); | 6 | EXPORT_SYMBOL(__down_failed); |
| 9 | EXPORT_SYMBOL(__down_failed_interruptible); | 7 | EXPORT_SYMBOL(__down_failed_interruptible); |
| 10 | EXPORT_SYMBOL(__down_failed_trylock); | 8 | EXPORT_SYMBOL(__down_failed_trylock); |
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c index f2dd218d88cb..235822b3f41b 100644 --- a/arch/i386/kernel/io_apic.c +++ b/arch/i386/kernel/io_apic.c | |||
| @@ -2566,8 +2566,10 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id) | |||
| 2566 | spin_unlock_irqrestore(&ioapic_lock, flags); | 2566 | spin_unlock_irqrestore(&ioapic_lock, flags); |
| 2567 | 2567 | ||
| 2568 | /* Sanity check */ | 2568 | /* Sanity check */ |
| 2569 | if (reg_00.bits.ID != apic_id) | 2569 | if (reg_00.bits.ID != apic_id) { |
| 2570 | panic("IOAPIC[%d]: Unable change apic_id!\n", ioapic); | 2570 | printk("IOAPIC[%d]: Unable to change apic_id!\n", ioapic); |
| 2571 | return -1; | ||
| 2572 | } | ||
| 2571 | } | 2573 | } |
| 2572 | 2574 | ||
| 2573 | apic_printk(APIC_VERBOSE, KERN_INFO | 2575 | apic_printk(APIC_VERBOSE, KERN_INFO |
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c index 6483eeb1a4e8..694a13997637 100644 --- a/arch/i386/kernel/kprobes.c +++ b/arch/i386/kernel/kprobes.c | |||
| @@ -58,6 +58,11 @@ static inline int is_IF_modifier(kprobe_opcode_t opcode) | |||
| 58 | 58 | ||
| 59 | int __kprobes arch_prepare_kprobe(struct kprobe *p) | 59 | int __kprobes arch_prepare_kprobe(struct kprobe *p) |
| 60 | { | 60 | { |
| 61 | /* insn: must be on special executable page on i386. */ | ||
| 62 | p->ainsn.insn = get_insn_slot(); | ||
| 63 | if (!p->ainsn.insn) | ||
| 64 | return -ENOMEM; | ||
| 65 | |||
| 61 | memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); | 66 | memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); |
| 62 | p->opcode = *p->addr; | 67 | p->opcode = *p->addr; |
| 63 | return 0; | 68 | return 0; |
| @@ -77,6 +82,13 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p) | |||
| 77 | (unsigned long) p->addr + sizeof(kprobe_opcode_t)); | 82 | (unsigned long) p->addr + sizeof(kprobe_opcode_t)); |
| 78 | } | 83 | } |
| 79 | 84 | ||
| 85 | void __kprobes arch_remove_kprobe(struct kprobe *p) | ||
| 86 | { | ||
| 87 | down(&kprobe_mutex); | ||
| 88 | free_insn_slot(p->ainsn.insn); | ||
| 89 | up(&kprobe_mutex); | ||
| 90 | } | ||
| 91 | |||
| 80 | static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) | 92 | static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) |
| 81 | { | 93 | { |
| 82 | kcb->prev_kprobe.kp = kprobe_running(); | 94 | kcb->prev_kprobe.kp = kprobe_running(); |
| @@ -111,7 +123,7 @@ static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) | |||
| 111 | if (p->opcode == BREAKPOINT_INSTRUCTION) | 123 | if (p->opcode == BREAKPOINT_INSTRUCTION) |
| 112 | regs->eip = (unsigned long)p->addr; | 124 | regs->eip = (unsigned long)p->addr; |
| 113 | else | 125 | else |
| 114 | regs->eip = (unsigned long)&p->ainsn.insn; | 126 | regs->eip = (unsigned long)p->ainsn.insn; |
| 115 | } | 127 | } |
| 116 | 128 | ||
| 117 | /* Called with kretprobe_lock held */ | 129 | /* Called with kretprobe_lock held */ |
| @@ -351,7 +363,7 @@ static void __kprobes resume_execution(struct kprobe *p, | |||
| 351 | { | 363 | { |
| 352 | unsigned long *tos = (unsigned long *)®s->esp; | 364 | unsigned long *tos = (unsigned long *)®s->esp; |
| 353 | unsigned long next_eip = 0; | 365 | unsigned long next_eip = 0; |
| 354 | unsigned long copy_eip = (unsigned long)&p->ainsn.insn; | 366 | unsigned long copy_eip = (unsigned long)p->ainsn.insn; |
| 355 | unsigned long orig_eip = (unsigned long)p->addr; | 367 | unsigned long orig_eip = (unsigned long)p->addr; |
| 356 | 368 | ||
| 357 | switch (p->ainsn.insn[0]) { | 369 | switch (p->ainsn.insn[0]) { |
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c index d3fdf0057d82..5390b521aca0 100644 --- a/arch/i386/kernel/microcode.c +++ b/arch/i386/kernel/microcode.c | |||
| @@ -74,6 +74,7 @@ | |||
| 74 | #include <linux/kernel.h> | 74 | #include <linux/kernel.h> |
| 75 | #include <linux/init.h> | 75 | #include <linux/init.h> |
| 76 | #include <linux/sched.h> | 76 | #include <linux/sched.h> |
| 77 | #include <linux/cpumask.h> | ||
| 77 | #include <linux/module.h> | 78 | #include <linux/module.h> |
| 78 | #include <linux/slab.h> | 79 | #include <linux/slab.h> |
| 79 | #include <linux/vmalloc.h> | 80 | #include <linux/vmalloc.h> |
| @@ -250,8 +251,8 @@ static int find_matching_ucodes (void) | |||
| 250 | error = -EINVAL; | 251 | error = -EINVAL; |
| 251 | goto out; | 252 | goto out; |
| 252 | } | 253 | } |
| 253 | 254 | ||
| 254 | for (cpu_num = 0; cpu_num < num_online_cpus(); cpu_num++) { | 255 | for_each_online_cpu(cpu_num) { |
| 255 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; | 256 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; |
| 256 | if (uci->err != MC_NOTFOUND) /* already found a match or not an online cpu*/ | 257 | if (uci->err != MC_NOTFOUND) /* already found a match or not an online cpu*/ |
| 257 | continue; | 258 | continue; |
| @@ -293,7 +294,7 @@ static int find_matching_ucodes (void) | |||
| 293 | error = -EFAULT; | 294 | error = -EFAULT; |
| 294 | goto out; | 295 | goto out; |
| 295 | } | 296 | } |
| 296 | for (cpu_num = 0; cpu_num < num_online_cpus(); cpu_num++) { | 297 | for_each_online_cpu(cpu_num) { |
| 297 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; | 298 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; |
| 298 | if (uci->err != MC_NOTFOUND) /* already found a match or not an online cpu*/ | 299 | if (uci->err != MC_NOTFOUND) /* already found a match or not an online cpu*/ |
| 299 | continue; | 300 | continue; |
| @@ -304,7 +305,9 @@ static int find_matching_ucodes (void) | |||
| 304 | } | 305 | } |
| 305 | } | 306 | } |
| 306 | /* now check if any cpu has matched */ | 307 | /* now check if any cpu has matched */ |
| 307 | for (cpu_num = 0, allocated_flag = 0, sum = 0; cpu_num < num_online_cpus(); cpu_num++) { | 308 | allocated_flag = 0; |
| 309 | sum = 0; | ||
| 310 | for_each_online_cpu(cpu_num) { | ||
| 308 | if (ucode_cpu_info[cpu_num].err == MC_MARKED) { | 311 | if (ucode_cpu_info[cpu_num].err == MC_MARKED) { |
| 309 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; | 312 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; |
| 310 | if (!allocated_flag) { | 313 | if (!allocated_flag) { |
| @@ -415,12 +418,12 @@ static int do_microcode_update (void) | |||
| 415 | } | 418 | } |
| 416 | 419 | ||
| 417 | out_free: | 420 | out_free: |
| 418 | for (i = 0; i < num_online_cpus(); i++) { | 421 | for_each_online_cpu(i) { |
| 419 | if (ucode_cpu_info[i].mc) { | 422 | if (ucode_cpu_info[i].mc) { |
| 420 | int j; | 423 | int j; |
| 421 | void *tmp = ucode_cpu_info[i].mc; | 424 | void *tmp = ucode_cpu_info[i].mc; |
| 422 | vfree(tmp); | 425 | vfree(tmp); |
| 423 | for (j = i; j < num_online_cpus(); j++) { | 426 | for_each_online_cpu(j) { |
| 424 | if (ucode_cpu_info[j].mc == tmp) | 427 | if (ucode_cpu_info[j].mc == tmp) |
| 425 | ucode_cpu_info[j].mc = NULL; | 428 | ucode_cpu_info[j].mc = NULL; |
| 426 | } | 429 | } |
diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c index e7609abf3796..e6e2f43db85e 100644 --- a/arch/i386/kernel/mpparse.c +++ b/arch/i386/kernel/mpparse.c | |||
| @@ -915,6 +915,7 @@ void __init mp_register_ioapic ( | |||
| 915 | u32 gsi_base) | 915 | u32 gsi_base) |
| 916 | { | 916 | { |
| 917 | int idx = 0; | 917 | int idx = 0; |
| 918 | int tmpid; | ||
| 918 | 919 | ||
| 919 | if (nr_ioapics >= MAX_IO_APICS) { | 920 | if (nr_ioapics >= MAX_IO_APICS) { |
| 920 | printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded " | 921 | printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded " |
| @@ -935,9 +936,14 @@ void __init mp_register_ioapic ( | |||
| 935 | 936 | ||
| 936 | set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); | 937 | set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); |
| 937 | if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && (boot_cpu_data.x86 < 15)) | 938 | if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && (boot_cpu_data.x86 < 15)) |
| 938 | mp_ioapics[idx].mpc_apicid = io_apic_get_unique_id(idx, id); | 939 | tmpid = io_apic_get_unique_id(idx, id); |
| 939 | else | 940 | else |
| 940 | mp_ioapics[idx].mpc_apicid = id; | 941 | tmpid = id; |
| 942 | if (tmpid == -1) { | ||
| 943 | nr_ioapics--; | ||
| 944 | return; | ||
| 945 | } | ||
| 946 | mp_ioapics[idx].mpc_apicid = tmpid; | ||
| 941 | mp_ioapics[idx].mpc_apicver = io_apic_get_version(idx); | 947 | mp_ioapics[idx].mpc_apicver = io_apic_get_version(idx); |
| 942 | 948 | ||
| 943 | /* | 949 | /* |
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c index fb00ab7b7612..eba7f53f8b4a 100644 --- a/arch/i386/kernel/smpboot.c +++ b/arch/i386/kernel/smpboot.c | |||
| @@ -898,12 +898,6 @@ static int __devinit do_boot_cpu(int apicid, int cpu) | |||
| 898 | unsigned long start_eip; | 898 | unsigned long start_eip; |
| 899 | unsigned short nmi_high = 0, nmi_low = 0; | 899 | unsigned short nmi_high = 0, nmi_low = 0; |
| 900 | 900 | ||
| 901 | if (!cpu_gdt_descr[cpu].address && | ||
| 902 | !(cpu_gdt_descr[cpu].address = get_zeroed_page(GFP_KERNEL))) { | ||
| 903 | printk("Failed to allocate GDT for CPU %d\n", cpu); | ||
| 904 | return 1; | ||
| 905 | } | ||
| 906 | |||
| 907 | ++cpucount; | 901 | ++cpucount; |
| 908 | 902 | ||
| 909 | /* | 903 | /* |
diff --git a/arch/i386/kernel/topology.c b/arch/i386/kernel/topology.c new file mode 100644 index 000000000000..67a0e1baa28b --- /dev/null +++ b/arch/i386/kernel/topology.c | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | /* | ||
| 2 | * arch/i386/kernel/topology.c - Populate driverfs with topology information | ||
| 3 | * | ||
| 4 | * Written by: Matthew Dobson, IBM Corporation | ||
| 5 | * Original Code: Paul Dorwin, IBM Corporation, Patrick Mochel, OSDL | ||
| 6 | * | ||
| 7 | * Copyright (C) 2002, IBM Corp. | ||
| 8 | * | ||
| 9 | * All rights reserved. | ||
| 10 | * | ||
| 11 | * This program is free software; you can redistribute it and/or modify | ||
| 12 | * it under the terms of the GNU General Public License as published by | ||
| 13 | * the Free Software Foundation; either version 2 of the License, or | ||
| 14 | * (at your option) any later version. | ||
| 15 | * | ||
| 16 | * This program is distributed in the hope that it will be useful, but | ||
| 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
| 19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
| 20 | * details. | ||
| 21 | * | ||
| 22 | * You should have received a copy of the GNU General Public License | ||
| 23 | * along with this program; if not, write to the Free Software | ||
| 24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 25 | * | ||
| 26 | * Send feedback to <colpatch@us.ibm.com> | ||
| 27 | */ | ||
| 28 | #include <linux/init.h> | ||
| 29 | #include <linux/smp.h> | ||
| 30 | #include <linux/nodemask.h> | ||
| 31 | #include <asm/cpu.h> | ||
| 32 | |||
| 33 | static struct i386_cpu cpu_devices[NR_CPUS]; | ||
| 34 | |||
| 35 | int arch_register_cpu(int num){ | ||
| 36 | struct node *parent = NULL; | ||
| 37 | |||
| 38 | #ifdef CONFIG_NUMA | ||
| 39 | int node = cpu_to_node(num); | ||
| 40 | if (node_online(node)) | ||
| 41 | parent = &node_devices[node].node; | ||
| 42 | #endif /* CONFIG_NUMA */ | ||
| 43 | |||
| 44 | return register_cpu(&cpu_devices[num].cpu, num, parent); | ||
| 45 | } | ||
| 46 | |||
| 47 | #ifdef CONFIG_HOTPLUG_CPU | ||
| 48 | |||
| 49 | void arch_unregister_cpu(int num) { | ||
| 50 | struct node *parent = NULL; | ||
| 51 | |||
| 52 | #ifdef CONFIG_NUMA | ||
| 53 | int node = cpu_to_node(num); | ||
| 54 | if (node_online(node)) | ||
| 55 | parent = &node_devices[node].node; | ||
| 56 | #endif /* CONFIG_NUMA */ | ||
| 57 | |||
| 58 | return unregister_cpu(&cpu_devices[num].cpu, parent); | ||
| 59 | } | ||
| 60 | EXPORT_SYMBOL(arch_register_cpu); | ||
| 61 | EXPORT_SYMBOL(arch_unregister_cpu); | ||
| 62 | #endif /*CONFIG_HOTPLUG_CPU*/ | ||
| 63 | |||
| 64 | |||
| 65 | |||
| 66 | #ifdef CONFIG_NUMA | ||
| 67 | #include <linux/mmzone.h> | ||
| 68 | #include <asm/node.h> | ||
| 69 | |||
| 70 | struct i386_node node_devices[MAX_NUMNODES]; | ||
| 71 | |||
| 72 | static int __init topology_init(void) | ||
| 73 | { | ||
| 74 | int i; | ||
| 75 | |||
| 76 | for_each_online_node(i) | ||
| 77 | arch_register_node(i); | ||
| 78 | |||
| 79 | for_each_present_cpu(i) | ||
| 80 | arch_register_cpu(i); | ||
| 81 | return 0; | ||
| 82 | } | ||
| 83 | |||
| 84 | #else /* !CONFIG_NUMA */ | ||
| 85 | |||
| 86 | static int __init topology_init(void) | ||
| 87 | { | ||
| 88 | int i; | ||
| 89 | |||
| 90 | for_each_present_cpu(i) | ||
| 91 | arch_register_cpu(i); | ||
| 92 | return 0; | ||
| 93 | } | ||
| 94 | |||
| 95 | #endif /* CONFIG_NUMA */ | ||
| 96 | |||
| 97 | subsys_initcall(topology_init); | ||
