forked from luck/tmp_suning_uos_patched
KVM: x86: drop KVM_PV_REASON_PAGE_READY case from kvm_handle_page_fault()
KVM guest code in Linux enables APF only when KVM_FEATURE_ASYNC_PF_INT is supported, this means we will never see KVM_PV_REASON_PAGE_READY when handling page fault vmexit in KVM. While on it, make sure we only follow genuine page fault path when APF reason is zero. If we happen to see something else this means that the underlying hypervisor is misbehaving. Leave WARN_ON_ONCE() to catch that. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
6c6165f83b
commit
9ce372b33a
|
@ -4156,6 +4156,7 @@ int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code,
|
||||||
u64 fault_address, char *insn, int insn_len)
|
u64 fault_address, char *insn, int insn_len)
|
||||||
{
|
{
|
||||||
int r = 1;
|
int r = 1;
|
||||||
|
u32 flags = vcpu->arch.apf.host_apf_flags;
|
||||||
|
|
||||||
#ifndef CONFIG_X86_64
|
#ifndef CONFIG_X86_64
|
||||||
/* A 64-bit CR2 should be impossible on 32-bit KVM. */
|
/* A 64-bit CR2 should be impossible on 32-bit KVM. */
|
||||||
|
@ -4164,28 +4165,22 @@ int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vcpu->arch.l1tf_flush_l1d = true;
|
vcpu->arch.l1tf_flush_l1d = true;
|
||||||
switch (vcpu->arch.apf.host_apf_flags) {
|
if (!flags) {
|
||||||
default:
|
|
||||||
trace_kvm_page_fault(fault_address, error_code);
|
trace_kvm_page_fault(fault_address, error_code);
|
||||||
|
|
||||||
if (kvm_event_needs_reinjection(vcpu))
|
if (kvm_event_needs_reinjection(vcpu))
|
||||||
kvm_mmu_unprotect_page_virt(vcpu, fault_address);
|
kvm_mmu_unprotect_page_virt(vcpu, fault_address);
|
||||||
r = kvm_mmu_page_fault(vcpu, fault_address, error_code, insn,
|
r = kvm_mmu_page_fault(vcpu, fault_address, error_code, insn,
|
||||||
insn_len);
|
insn_len);
|
||||||
break;
|
} else if (flags & KVM_PV_REASON_PAGE_NOT_PRESENT) {
|
||||||
case KVM_PV_REASON_PAGE_NOT_PRESENT:
|
|
||||||
vcpu->arch.apf.host_apf_flags = 0;
|
vcpu->arch.apf.host_apf_flags = 0;
|
||||||
local_irq_disable();
|
local_irq_disable();
|
||||||
kvm_async_pf_task_wait_schedule(fault_address);
|
kvm_async_pf_task_wait_schedule(fault_address);
|
||||||
local_irq_enable();
|
local_irq_enable();
|
||||||
break;
|
} else {
|
||||||
case KVM_PV_REASON_PAGE_READY:
|
WARN_ONCE(1, "Unexpected host async PF flags: %x\n", flags);
|
||||||
vcpu->arch.apf.host_apf_flags = 0;
|
|
||||||
local_irq_disable();
|
|
||||||
kvm_async_pf_task_wake(fault_address);
|
|
||||||
local_irq_enable();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(kvm_handle_page_fault);
|
EXPORT_SYMBOL_GPL(kvm_handle_page_fault);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user