mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-26 16:41:25 +00:00
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>
This commit is contained in:
parent
3e4bb3ac9e
commit
71c4dfafc0
2 changed files with 16 additions and 5 deletions
|
@ -155,11 +155,16 @@ void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long addr,
|
||||||
u32 error_code)
|
u32 error_code)
|
||||||
{
|
{
|
||||||
++vcpu->stat.pf_guest;
|
++vcpu->stat.pf_guest;
|
||||||
if (vcpu->arch.exception.pending && vcpu->arch.exception.nr == PF_VECTOR) {
|
if (vcpu->arch.exception.pending) {
|
||||||
printk(KERN_DEBUG "kvm: inject_page_fault:"
|
if (vcpu->arch.exception.nr == PF_VECTOR) {
|
||||||
" double fault 0x%lx\n", addr);
|
printk(KERN_DEBUG "kvm: inject_page_fault:"
|
||||||
vcpu->arch.exception.nr = DF_VECTOR;
|
" double fault 0x%lx\n", addr);
|
||||||
vcpu->arch.exception.error_code = 0;
|
vcpu->arch.exception.nr = DF_VECTOR;
|
||||||
|
vcpu->arch.exception.error_code = 0;
|
||||||
|
} else if (vcpu->arch.exception.nr == DF_VECTOR) {
|
||||||
|
/* triple fault -> shutdown */
|
||||||
|
set_bit(KVM_REQ_TRIPLE_FAULT, &vcpu->requests);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vcpu->arch.cr2 = addr;
|
vcpu->arch.cr2 = addr;
|
||||||
|
@ -2676,6 +2681,11 @@ again:
|
||||||
r = 0;
|
r = 0;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
if (test_and_clear_bit(KVM_REQ_TRIPLE_FAULT, &vcpu->requests)) {
|
||||||
|
kvm_run->exit_reason = KVM_EXIT_SHUTDOWN;
|
||||||
|
r = 0;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kvm_inject_pending_timer_irqs(vcpu);
|
kvm_inject_pending_timer_irqs(vcpu);
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#define KVM_REQ_MIGRATE_TIMER 1
|
#define KVM_REQ_MIGRATE_TIMER 1
|
||||||
#define KVM_REQ_REPORT_TPR_ACCESS 2
|
#define KVM_REQ_REPORT_TPR_ACCESS 2
|
||||||
#define KVM_REQ_MMU_RELOAD 3
|
#define KVM_REQ_MMU_RELOAD 3
|
||||||
|
#define KVM_REQ_TRIPLE_FAULT 4
|
||||||
|
|
||||||
struct kvm_vcpu;
|
struct kvm_vcpu;
|
||||||
extern struct kmem_cache *kvm_vcpu_cache;
|
extern struct kmem_cache *kvm_vcpu_cache;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue