diff options
-rw-r--r-- | xen/arch/ia64/linux-xen/smpboot.c | 13 | ||||
-rw-r--r-- | xen/arch/x86/domain.c | 7 | ||||
-rw-r--r-- | xen/arch/x86/hvm/hvm.c | 8 | ||||
-rw-r--r-- | xen/arch/x86/hvm/svm/svm.c | 19 | ||||
-rw-r--r-- | xen/arch/x86/hvm/vmx/vmcs.c | 10 | ||||
-rw-r--r-- | xen/arch/x86/hvm/vmx/vmx.c | 3 | ||||
-rw-r--r-- | xen/arch/x86/smpboot.c | 6 | ||||
-rw-r--r-- | xen/common/cpu.c | 3 | ||||
-rw-r--r-- | xen/common/softirq.c | 3 | ||||
-rw-r--r-- | xen/common/tasklet.c | 2 | ||||
-rw-r--r-- | xen/include/asm-ia64/linux-xen/asm/smp.h | 3 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/hvm.h | 4 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/vmx/vmcs.h | 3 | ||||
-rw-r--r-- | xen/include/asm-x86/smp.h | 2 | ||||
-rw-r--r-- | xen/include/xen/cpu.h | 15 | ||||
-rw-r--r-- | xen/include/xen/smp.h | 5 |
16 files changed, 61 insertions, 45 deletions
diff --git a/xen/arch/ia64/linux-xen/smpboot.c b/xen/arch/ia64/linux-xen/smpboot.c index 805706241e..20298c52e8 100644 --- a/xen/arch/ia64/linux-xen/smpboot.c +++ b/xen/arch/ia64/linux-xen/smpboot.c @@ -721,16 +721,10 @@ remove_siblinginfo(int cpu) extern void fixup_irqs(void); /* must be called with cpucontrol mutex held */ -int __cpu_disable(void) +void __cpu_disable(void) { int cpu = smp_processor_id(); - /* - * dont permit boot processor for now - */ - if (cpu == 0) - return -EBUSY; - remove_siblinginfo(cpu); cpu_clear(cpu, cpu_online_map); #ifndef XEN @@ -738,12 +732,11 @@ int __cpu_disable(void) #endif local_flush_tlb_all(); cpu_clear(cpu, cpu_callin_map); - return 0; } #else /* !CONFIG_HOTPLUG_CPU */ -int __cpu_disable(void) +void __cpu_disable(void) { - return -ENOSYS; + BUG(); } #endif /* CONFIG_HOTPLUG_CPU */ diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 57b54f21be..166a8be31f 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -98,15 +98,8 @@ static void default_dead_idle(void) static void play_dead(void) { - /* - * Flush pending softirqs if any. They can be queued up before this CPU - * was taken out of cpu_online_map in __cpu_disable(). - */ - do_softirq(); - /* This must be done before dead CPU ack */ cpu_exit_clear(); - hvm_cpu_down(); wbinvd(); mb(); /* Ack it */ diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index cfa0643f95..7f6ba29a06 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -80,7 +80,13 @@ static int cpu_callback( switch ( action ) { case CPU_UP_PREPARE: - rc = hvm_funcs.cpu_prepare(cpu); + rc = hvm_funcs.cpu_up_prepare(cpu); + break; + case CPU_DYING: + hvm_cpu_down(); + break; + case CPU_DEAD: + hvm_funcs.cpu_dead(cpu); break; default: break; diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 4231079d13..194453f03b 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -818,13 +818,25 @@ static int svm_do_pmu_interrupt(struct cpu_user_regs *regs) return vpmu_do_interrupt(regs); } -static int svm_cpu_prepare(unsigned int cpu) +static void svm_cpu_dead(unsigned int cpu) +{ + free_xenheap_page(hsa[cpu]); + hsa[cpu] = NULL; + free_vmcb(root_vmcb[cpu]); + root_vmcb[cpu] = NULL; +} + +static int svm_cpu_up_prepare(unsigned int cpu) { if ( ((hsa[cpu] == NULL) && ((hsa[cpu] = alloc_host_save_area()) == NULL)) || ((root_vmcb[cpu] == NULL) && ((root_vmcb[cpu] = alloc_vmcb()) == NULL)) ) + { + svm_cpu_dead(cpu); return -ENOMEM; + } + return 0; } @@ -842,7 +854,7 @@ static int svm_cpu_up(struct cpuinfo_x86 *c) return 0; } - if ( svm_cpu_prepare(cpu) != 0 ) + if ( svm_cpu_up_prepare(cpu) != 0 ) return 0; write_efer(read_efer() | EFER_SVME); @@ -1328,7 +1340,8 @@ static void svm_invlpg_intercept(unsigned long vaddr) static struct hvm_function_table __read_mostly svm_function_table = { .name = "SVM", - .cpu_prepare = svm_cpu_prepare, + .cpu_up_prepare = svm_cpu_up_prepare, + .cpu_dead = svm_cpu_dead, .cpu_down = svm_cpu_down, .domain_initialise = svm_domain_initialise, .domain_destroy = svm_domain_destroy, diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index 52594de931..83054e7cc3 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -337,7 +337,7 @@ static void vmx_load_vmcs(struct vcpu *v) local_irq_restore(flags); } -int vmx_cpu_prepare(unsigned int cpu) +int vmx_cpu_up_prepare(unsigned int cpu) { if ( per_cpu(host_vmcs, cpu) != NULL ) return 0; @@ -350,6 +350,12 @@ int vmx_cpu_prepare(unsigned int cpu) return -ENOMEM; } +void vmx_cpu_dead(unsigned int cpu) +{ + vmx_free_vmcs(per_cpu(host_vmcs, cpu)); + per_cpu(host_vmcs, cpu) = NULL; +} + int vmx_cpu_up(void) { u32 eax, edx; @@ -398,7 +404,7 @@ int vmx_cpu_up(void) INIT_LIST_HEAD(&this_cpu(active_vmcs_list)); - if ( vmx_cpu_prepare(cpu) != 0 ) + if ( vmx_cpu_up_prepare(cpu) != 0 ) return 0; switch ( __vmxon(virt_to_maddr(this_cpu(host_vmcs))) ) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index b65695378f..d1d82ab6fc 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1379,7 +1379,8 @@ static void vmx_set_info_guest(struct vcpu *v) static struct hvm_function_table __read_mostly vmx_function_table = { .name = "VMX", - .cpu_prepare = vmx_cpu_prepare, + .cpu_up_prepare = vmx_cpu_up_prepare, + .cpu_dead = vmx_cpu_dead, .domain_initialise = vmx_domain_initialise, .domain_destroy = vmx_domain_destroy, .vcpu_initialise = vmx_vcpu_initialise, diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 50ac661926..035e570413 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -1265,9 +1265,9 @@ remove_siblinginfo(int cpu) cpu_clear(cpu, cpu_sibling_setup_map); } -extern void fixup_irqs(void); -int __cpu_disable(void) +void __cpu_disable(void) { + extern void fixup_irqs(void); int cpu = smp_processor_id(); local_irq_disable(); @@ -1287,8 +1287,6 @@ int __cpu_disable(void) fixup_irqs(); cpu_disable_scheduler(cpu); - - return 0; } void __cpu_die(unsigned int cpu) diff --git a/xen/common/cpu.c b/xen/common/cpu.c index 4dfc3351b9..7739a633ad 100644 --- a/xen/common/cpu.c +++ b/xen/common/cpu.c @@ -68,7 +68,8 @@ static int take_cpu_down(void *unused) void *hcpu = (void *)(long)smp_processor_id(); if ( raw_notifier_call_chain(&cpu_chain, CPU_DYING, hcpu) != NOTIFY_DONE ) BUG(); - return __cpu_disable(); + __cpu_disable(); + return 0; } int cpu_down(unsigned int cpu) diff --git a/xen/common/softirq.c b/xen/common/softirq.c index fac59818ac..0a4f1e7914 100644 --- a/xen/common/softirq.c +++ b/xen/common/softirq.c @@ -38,7 +38,8 @@ static void __do_softirq(unsigned long ignore_mask) if ( rcu_pending(cpu) ) rcu_check_callbacks(cpu); - if ( (pending = (softirq_pending(cpu) & ~ignore_mask)) == 0 ) + if ( ((pending = (softirq_pending(cpu) & ~ignore_mask)) == 0) + || cpu_is_offline(cpu) ) break; i = find_first_set_bit(pending); diff --git a/xen/common/tasklet.c b/xen/common/tasklet.c index f9b889d717..b898535223 100644 --- a/xen/common/tasklet.c +++ b/xen/common/tasklet.c @@ -78,7 +78,7 @@ void do_tasklet(void) spin_lock_irq(&tasklet_lock); - if ( unlikely(list_empty(list)) ) + if ( unlikely(list_empty(list) || cpu_is_offline(cpu)) ) goto out; t = list_entry(list->next, struct tasklet, list); diff --git a/xen/include/asm-ia64/linux-xen/asm/smp.h b/xen/include/asm-ia64/linux-xen/asm/smp.h index 7380c773cf..7cee1a3aa6 100644 --- a/xen/include/asm-ia64/linux-xen/asm/smp.h +++ b/xen/include/asm-ia64/linux-xen/asm/smp.h @@ -118,10 +118,7 @@ max_xtp (void) #define hard_smp_processor_id() ia64_get_lid() /* Upping and downing of CPUs */ -extern int __cpu_disable (void); -extern void __cpu_die (unsigned int cpu); extern void cpu_die (void) __attribute__ ((noreturn)); -extern int __cpu_up (unsigned int cpu); extern void __init smp_build_cpu_map(void); extern void __init init_smp_config (void); diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index e5d3fdbab6..8d36e4c9f0 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -115,7 +115,9 @@ struct hvm_function_table { int (*event_pending)(struct vcpu *v); int (*do_pmu_interrupt)(struct cpu_user_regs *regs); - int (*cpu_prepare)(unsigned int cpu); + int (*cpu_up_prepare)(unsigned int cpu); + void (*cpu_dead)(unsigned int cpu); + int (*cpu_up)(void); void (*cpu_down)(void); diff --git a/xen/include/asm-x86/hvm/vmx/vmcs.h b/xen/include/asm-x86/hvm/vmx/vmcs.h index 29172e0d53..8e73573080 100644 --- a/xen/include/asm-x86/hvm/vmx/vmcs.h +++ b/xen/include/asm-x86/hvm/vmx/vmcs.h @@ -26,7 +26,8 @@ extern void start_vmx(void); extern void vmcs_dump_vcpu(struct vcpu *v); extern void setup_vmcs_dump(void); -extern int vmx_cpu_prepare(unsigned int cpu); +extern int vmx_cpu_up_prepare(unsigned int cpu); +extern void vmx_cpu_dead(unsigned int cpu); extern int vmx_cpu_up(void); extern void vmx_cpu_down(void); diff --git a/xen/include/asm-x86/smp.h b/xen/include/asm-x86/smp.h index 3c85b87956..029b25b658 100644 --- a/xen/include/asm-x86/smp.h +++ b/xen/include/asm-x86/smp.h @@ -93,8 +93,6 @@ static __inline int logical_smp_processor_id(void) #endif -extern int __cpu_disable(void); -extern void __cpu_die(unsigned int cpu); #endif /* !__ASSEMBLY__ */ #else /* CONFIG_SMP */ diff --git a/xen/include/xen/cpu.h b/xen/include/xen/cpu.h index 115dec7896..7de315290f 100644 --- a/xen/include/xen/cpu.h +++ b/xen/include/xen/cpu.h @@ -17,8 +17,14 @@ void cpu_hotplug_done(void); int register_cpu_notifier(struct notifier_block *nb); /* - * Notification actions: note that only CPU_{UP,DOWN}_PREPARE may fail --- - * all other handlers *must* return NOTIFY_DONE. + * Possible event sequences for a given CPU: + * CPU_UP_PREPARE -> CPU_UP_CANCELLED -- failed CPU up + * CPU_UP_PREPARE -> CPU_ONLINE -- successful CPU up + * CPU_DOWN_PREPARE -> CPU_DOWN_FAILED -- failed CPU down + * CPU_DOWN_PREPARE -> CPU_DYING -> CPU_DEAD -- successful CPU down + * + * Hence note that only CPU_*_PREPARE handlers are allowed to fail. Also note + * that once CPU_DYING is delivered, an offline action can no longer fail. */ #define CPU_UP_PREPARE 0x0002 /* CPU is coming up */ #define CPU_UP_CANCELED 0x0003 /* CPU is no longer coming up */ @@ -36,4 +42,9 @@ int cpu_up(unsigned int cpu); int disable_nonboot_cpus(void); void enable_nonboot_cpus(void); +/* Private arch-dependent helpers for CPU hotplug. */ +int __cpu_up(unsigned int cpunum); +void __cpu_disable(void); +void __cpu_die(unsigned int cpu); + #endif /* __XEN_CPU_H__ */ diff --git a/xen/include/xen/smp.h b/xen/include/xen/smp.h index f603e001e6..7eac790bf7 100644 --- a/xen/include/xen/smp.h +++ b/xen/include/xen/smp.h @@ -21,11 +21,6 @@ extern void smp_send_state_dump(unsigned int cpu); extern void smp_prepare_cpus(unsigned int max_cpus); /* - * Bring a CPU up - */ -extern int __cpu_up(unsigned int cpunum); - -/* * Final polishing of CPUs */ extern void smp_cpus_done(unsigned int max_cpus); |