diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2008-02-26 10:49:16 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-04-27 04:53:27 -0400 |
commit | 71c4dfafc0932d92cc99c7e839d25174b0ce10a1 (patch) | |
tree | 991320ed3bce4cc2665721454c7f10a69fb98b1a /arch | |
parent | 3e4bb3ac9e0ada5df5f6729648d403ea9f071d10 (diff) |
KVM: detect if VCPU triple faults
In the current inject_page_fault path KVM only checks if there is another PF
pending and injects a DF then. But it has to check for a pending DF too to
detect a shutdown condition in the VCPU. If this is not detected the VCPU goes
to a PF -> DF -> PF loop when it should triple fault. This patch detects this
condition and handles it with an KVM_SHUTDOWN exit to userspace.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/x86.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index dbcff38dfcc3..491eda308289 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -155,11 +155,16 @@ void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long addr, | |||
155 | u32 error_code) | 155 | u32 error_code) |
156 | { | 156 | { |
157 | ++vcpu->stat.pf_guest; | 157 | ++vcpu->stat.pf_guest; |
158 | if (vcpu->arch.exception.pending && vcpu->arch.exception.nr == PF_VECTOR) { | 158 | if (vcpu->arch.exception.pending) { |
159 | printk(KERN_DEBUG "kvm: inject_page_fault:" | 159 | if (vcpu->arch.exception.nr == PF_VECTOR) { |
160 | " double fault 0x%lx\n", addr); | 160 | printk(KERN_DEBUG "kvm: inject_page_fault:" |
161 | vcpu->arch.exception.nr = DF_VECTOR; | 161 | " double fault 0x%lx\n", addr); |
162 | vcpu->arch.exception.error_code = 0; | 162 | vcpu->arch.exception.nr = DF_VECTOR; |
163 | vcpu->arch.exception.error_code = 0; | ||
164 | } else if (vcpu->arch.exception.nr == DF_VECTOR) { | ||
165 | /* triple fault -> shutdown */ | ||
166 | set_bit(KVM_REQ_TRIPLE_FAULT, &vcpu->requests); | ||
167 | } | ||
163 | return; | 168 | return; |
164 | } | 169 | } |
165 | vcpu->arch.cr2 = addr; | 170 | vcpu->arch.cr2 = addr; |
@@ -2676,6 +2681,11 @@ again: | |||
2676 | r = 0; | 2681 | r = 0; |
2677 | goto out; | 2682 | goto out; |
2678 | } | 2683 | } |
2684 | if (test_and_clear_bit(KVM_REQ_TRIPLE_FAULT, &vcpu->requests)) { | ||
2685 | kvm_run->exit_reason = KVM_EXIT_SHUTDOWN; | ||
2686 | r = 0; | ||
2687 | goto out; | ||
2688 | } | ||
2679 | } | 2689 | } |
2680 | 2690 | ||
2681 | kvm_inject_pending_timer_irqs(vcpu); | 2691 | kvm_inject_pending_timer_irqs(vcpu); |