x86_64 SMP support for xen linux
PATCH 1/1 x86_64 SMP support for xen linux
The following patch provides x86_64 SMP support for xen linux. Many, many thanks to the help for bug fixes, cleanups, good domU support, and more from Jun and Xin. I've tested this on a couple different machines, and made sure the UP build still boots and works. dom0 and domU smp both work. There's still some cleanups to do, but we'd prefer to do the last bit in tree. This doesn't update defconfigs just yet. That'll be a follow-on patch shortly, so for now, you'll have to manually enable CONFIG_SMP if you'd like to test.
Signed-off-by Chris Wright <[email protected]>
Signed-off-by Xin Li <[email protected]>
Signed-off-by Jun Nakajima <[email protected]>
---
linux-2.6-xen-sparse/arch/xen/x86_64/Kconfig | 4 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/Makefile | 5 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/apic.c | 2 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic.c | 123 ++++++ linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic_xen.c | 167 +++++++++ linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head.S | 3 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/irq.c | 5 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c | 20 + linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c | 2 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smp.c | 58 +++ linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c | 254 ++++++++++++++ linux-2.6-xen-sparse/arch/xen/x86_64/kernel/traps.c | 11 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/xen_entry.S | 9 13 files changed, 656 insertions(+), 7 deletions(-)
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/Makefile +3 -2
@@ -25,11 +25,12 @@ obj-$(CONFIG_ACPI_BOOT) += acpi/ c-obj-$(CONFIG_X86_MSR) += msr.o obj-$(CONFIG_MICROCODE) += microcode.o obj-$(CONFIG_X86_CPUID) += cpuid.o -#obj-$(CONFIG_SMP) += smp.o smpboot.o trampoline.o +obj-$(CONFIG_SMP) += smp.o smpboot.o obj-$(CONFIG_X86_LOCAL_APIC) += apic.o c-obj-$(CONFIG_X86_LOCAL_APIC) += nmi.o obj-$(CONFIG_X86_IO_APIC) += io_apic.o mpparse.o -c-obj-$(CONFIG_X86_IO_APIC) += genapic.o genapic_cluster.o genapic_flat.o +obj-$(CONFIG_X86_XEN_GENAPIC) += genapic.o genapic_xen.o +c-obj-$(CONFIG_X86_IO_APIC) += genapic_cluster.o genapic_flat.o #obj-$(CONFIG_PM) += suspend.o #obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend_asm.o #obj-$(CONFIG_CPU_FREQ) += cpufreq/
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/apic.c +1 -1
@@ -48,7 +48,7 @@ void smp_local_timer_interrupt(struct ptint cpu =smp_processor_id ();profile_tick (CPU_PROFILING , regs); -#if 0 +#ifndef CONFIG_XEN if (--per_cpu (prof_counter, cpu) <=0 ) {/* * The multiplier may have changed since the last time we got
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head.S +2 -1
@@ -41,7 +41,6 @@ startup_64: ENTRY(_start) cld - movq init_rsp(%rip),%rsp /* Copy the necessary stuff from xen_start_info structure. */ movq $xen_start_info_union,%rdi movq $64,%rcx /* sizeof (union xen_start_info_union) / sizeof (long) */
@@ -52,6 +51,7 @@ ENTRY(_start) cld #endif /* CONFIG_SMP */ + movq init_rsp(%rip),%rsp /* zero EFLAGS after setting rsp */ pushq $0 popfq
@@ -204,6 +204,7 @@ ENTRY(cpu_gdt_table) .quad 0,0 /* TSS */ .quad 0,0 /* LDT */ .quad 0,0,0 /* three TLS descriptors */ + .quad 0 /* unused now? __KERNEL16_CS - 16bit PM for S3 wakeup. */ gdt_end: /* asm/segment.h:GDT_ENTRIES must match this */
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/irq.c +5 -0
@@ -21,6 +21,11 @@atomic_t irq_err_count; +#ifdef CONFIG_X86_IO_APIC +#ifdef APIC_MISMATCH_DEBUG +atomic_t irq_mis_count; +#endif +#endif /* * Generic, controller-independent functions:
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c +20 -0
@@ -200,12 +200,14 @@ static struct resource adapter_rom_resou#define ADAPTER_ROM_RESOURCES \ (sizeof adapter_rom_resources / sizeof adapter_rom_resources[0]) +#ifdef CONFIG_XEN_PRIVILEGED_GUEST static struct resource video_rom_resource = { .name ="Video ROM" , .start =0xc0000 , .end =0xc7fff , .flags =IORESOURCE_ROM , }; +#endif static struct resource video_ram_resource = { .name ="Video RAM area" ,
@@ -599,6 +601,19 @@ static void __init print_memory_map(char } } +#ifdef CONFIG_XEN +void __init smp_alloc_memory (void ) +{ +int cpu; + +for (cpu =1 ; cpu <NR_CPUS ; cpu++) { + cpu_gdt_descr[cpu].address = (unsigned long ) +alloc_bootmem_low_pages (PAGE_SIZE ); +/* XXX free unused pages later */ + } +} +#endif +void __init setup_arch (char **cmdline_p) {int i, j;
@@ -740,6 +755,11 @@ void __init setup_arch(char **cmdline_p) } }#endif +#ifdef CONFIG_SMP +#ifdef CONFIG_XEN +smp_alloc_memory (); +#endif +#endif paging_init ();#ifdef CONFIG_X86_LOCAL_APIC /*
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c +2 -0
@@ -276,9 +276,11 @@ void __init cpu_init (void)* Initialize the per-CPU GDT with the boot GDT, * and set up the GDT descriptor: */ +#ifndef CONFIG_XEN if (cpu) {memcpy (cpu_gdt_table[cpu], cpu_gdt_table[0 ],GDT_SIZE ); } +#endif cpu_gdt_descr[cpu].size =GDT_SIZE ; cpu_gdt_descr[cpu].address = (unsigned long )cpu_gdt_table[cpu];
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smp.c +58 -0
150 lines not on this page · raw message
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c +254 -0
510 lines not on this page · raw message
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/traps.c +11 -0
@@ -953,6 +953,17 @@ void __init trap_init(void)cpu_init (); } +void smp_trap_init (trap_info_t *trap_ctxt) +{ +trap_info_t *t = trap_table; + +for (t = trap_table; t->address; t++) { + trap_ctxt[t->vector].flags = t->flags; + trap_ctxt[t->vector].cs = t->cs; + trap_ctxt[t->vector].address = t->address; + } +} +/* Actual parsing is done early in setup.c. */ static int __init oops_dummy (char *s)
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/xen_entry.S +6 -3
@@ -8,11 +8,14 @@ #define sizeof_vcpu_shift 3 #ifdef CONFIG_SMP -#define preempt_disable(reg) incl threadinfo_preempt_count(reg) -#define preempt_enable(reg) decl threadinfo_preempt_count(reg) +//#define preempt_disable(reg) incl threadinfo_preempt_count(reg) +//#define preempt_enable(reg) decl threadinfo_preempt_count(reg) +#define preempt_disable(reg) +#define preempt_enable(reg) #define XEN_GET_VCPU_INFO(reg) preempt_disable(%rbp) ; \ movq %gs:pda_cpunumber,reg ; \ - shl $sizeof_vcpu_shift,reg ; \ + shl $32, reg ; \ + shr $32-sizeof_vcpu_shift,reg ; \ addq HYPERVISOR_shared_info,reg #define XEN_PUT_VCPU_INFO(reg) preempt_enable(%rbp) ; \ #define XEN_PUT_VCPU_INFO_fixup .byte 0xff,0xff,0xff
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic.c new file +123 -0
123 lines not on this page · raw message
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic_xen.c new file +167 -0
167 lines not on this page · raw message
linux-2.6-xen-sparse/arch/xen/x86_64/Kconfig +4 -0
@@ -126,6 +126,10 @@ config X86_IO_APIC bool default XEN_PRIVILEGED_GUEST +config X86_XEN_GENAPIC + bool + default XEN_PRIVILEGED_GUEST || SMP + config X86_LOCAL_APIC bool default XEN_PRIVILEGED_GUEST