diff --git a/hypervisor/arch/x86/interrupt.c b/hypervisor/arch/x86/interrupt.c index 826ac3aa1..031edbff2 100644 --- a/hypervisor/arch/x86/interrupt.c +++ b/hypervisor/arch/x86/interrupt.c @@ -322,6 +322,16 @@ int vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code) return vcpu_make_request(vcpu, ACRN_REQUEST_EXCP); } +int vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code) +{ + struct run_context *cur_context = + &vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context]; + + cur_context->cr2 = addr; + vcpu_queue_exception(vcpu, IDT_PF, err_code); + return vcpu_make_request(vcpu, ACRN_REQUEST_EXCP); +} + int interrupt_window_vmexit_handler(struct vcpu *vcpu) { int value32; diff --git a/hypervisor/include/arch/x86/irq.h b/hypervisor/include/arch/x86/irq.h index c494a157d..8d5cd1791 100644 --- a/hypervisor/include/arch/x86/irq.h +++ b/hypervisor/include/arch/x86/irq.h @@ -184,6 +184,7 @@ extern spurious_handler_t spurious_handler; int vcpu_inject_extint(struct vcpu *vcpu); int vcpu_inject_nmi(struct vcpu *vcpu); int vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code); +int vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code); int vcpu_make_request(struct vcpu *vcpu, int eventid); int vcpu_queue_exception(struct vcpu *vcpu, int32_t vector, uint32_t err_code);