aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2010-12-02 10:52:50 -0500
committerAvi Kivity <avi@redhat.com>2011-01-12 04:30:18 -0500
commitb7c4145ba2eb0717db0ddac1b5f7f48012189c53 (patch)
tree9b259970f56451ecb0f5d84ecd81d67386f63224
parent4cc703100b1fd97c71804e2fa5c9c377c5b37dc5 (diff)
KVM: Don't spin on virt instruction faults during reboot
Since vmx blocks INIT signals, we disable virtualization extensions during reboot. This leads to virtualization instructions faulting; we trap these faults and spin while the reboot continues. Unfortunately spinning on a non-preemptible kernel may block a task that reboot depends on; this causes the reboot to hang. Fix by skipping over the instruction and hoping for the best. Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/x86/include/asm/kvm_host.h8
-rw-r--r--virt/kvm/kvm_main.c13
2 files changed, 10 insertions, 11 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 56e45a2ed2de..d968cc501799 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -786,14 +786,18 @@ enum {
786 * reboot turns off virtualization while processes are running. 786 * reboot turns off virtualization while processes are running.
787 * Trap the fault and ignore the instruction if that happens. 787 * Trap the fault and ignore the instruction if that happens.
788 */ 788 */
789asmlinkage void kvm_handle_fault_on_reboot(void); 789asmlinkage void kvm_spurious_fault(void);
790extern bool kvm_rebooting;
790 791
791#define __kvm_handle_fault_on_reboot(insn) \ 792#define __kvm_handle_fault_on_reboot(insn) \
792 "666: " insn "\n\t" \ 793 "666: " insn "\n\t" \
794 "668: \n\t" \
793 ".pushsection .fixup, \"ax\" \n" \ 795 ".pushsection .fixup, \"ax\" \n" \
794 "667: \n\t" \ 796 "667: \n\t" \
797 "cmpb $0, kvm_rebooting \n\t" \
798 "jne 668b \n\t" \
795 __ASM_SIZE(push) " $666b \n\t" \ 799 __ASM_SIZE(push) " $666b \n\t" \
796 "jmp kvm_handle_fault_on_reboot \n\t" \ 800 "call kvm_spurious_fault \n\t" \
797 ".popsection \n\t" \ 801 ".popsection \n\t" \
798 ".pushsection __ex_table, \"a\" \n\t" \ 802 ".pushsection __ex_table, \"a\" \n\t" \
799 _ASM_PTR " 666b, 667b \n\t" \ 803 _ASM_PTR " 666b, 667b \n\t" \
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index ee99b77e4451..7f686251f711 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -90,7 +90,8 @@ static void hardware_disable_all(void);
90 90
91static void kvm_io_bus_destroy(struct kvm_io_bus *bus); 91static void kvm_io_bus_destroy(struct kvm_io_bus *bus);
92 92
93static bool kvm_rebooting; 93bool kvm_rebooting;
94EXPORT_SYMBOL_GPL(kvm_rebooting);
94 95
95static bool largepages_enabled = true; 96static bool largepages_enabled = true;
96 97
@@ -2171,18 +2172,12 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val,
2171} 2172}
2172 2173
2173 2174
2174asmlinkage void kvm_handle_fault_on_reboot(void) 2175asmlinkage void kvm_spurious_fault(void)
2175{ 2176{
2176 if (kvm_rebooting) {
2177 /* spin while reset goes on */
2178 local_irq_enable();
2179 while (true)
2180 cpu_relax();
2181 }
2182 /* Fault while not rebooting. We want the trace. */ 2177 /* Fault while not rebooting. We want the trace. */
2183 BUG(); 2178 BUG();
2184} 2179}
2185EXPORT_SYMBOL_GPL(kvm_handle_fault_on_reboot); 2180EXPORT_SYMBOL_GPL(kvm_spurious_fault);
2186 2181
2187static int kvm_reboot(struct notifier_block *notifier, unsigned long val, 2182static int kvm_reboot(struct notifier_block *notifier, unsigned long val,
2188 void *v) 2183 void *v)