From 77183380082b6eaf0f6ffa28b73501623451bf3b Mon Sep 17 00:00:00 2001 From: Jason Chen CJ Date: Fri, 25 May 2018 14:02:50 +0800 Subject: [PATCH] exception: add vcpu_inject_pf support add page fault exception injection support Signed-off-by: Jason Chen CJ Acked-by: Tian, Kevin --- hypervisor/arch/x86/interrupt.c | 10 ++++++++++ hypervisor/include/arch/x86/irq.h | 1 + 2 files changed, 11 insertions(+) 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);