From 44af2690f6c21f3b8a1a95442f52d04c52695e4e Mon Sep 17 00:00:00 2001 From: Jason Chen CJ Date: Mon, 28 May 2018 13:00:04 +0800 Subject: [PATCH] add triple fault request support if vcpu meet triple fault, the vcpu should exit. Signed-off-by: Jason Chen CJ Acked-by: Tian, Kevin --- hypervisor/arch/x86/interrupt.c | 5 +++++ hypervisor/common/hv_main.c | 7 ++++++- hypervisor/include/arch/x86/guest/guest.h | 1 + hypervisor/include/lib/errno.h | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hypervisor/arch/x86/interrupt.c b/hypervisor/arch/x86/interrupt.c index 9d10de1ee..9fe314b5f 100644 --- a/hypervisor/arch/x86/interrupt.c +++ b/hypervisor/arch/x86/interrupt.c @@ -304,6 +304,11 @@ int acrn_handle_pending_request(struct vcpu *vcpu) bool intr_pending = false; uint64_t *pending_req_bits = &vcpu->arch_vcpu.pending_req; + if (bitmap_test_and_clear(ACRN_REQUEST_TRP_FAULT, pending_req_bits)) { + pr_fatal("Triple fault happen -> shutdown!"); + return -EFAULT; + } + if (bitmap_test_and_clear(ACRN_REQUEST_TLB_FLUSH, pending_req_bits)) invept(vcpu); diff --git a/hypervisor/common/hv_main.c b/hypervisor/common/hv_main.c index 6793cda8e..b2b9d7a98 100644 --- a/hypervisor/common/hv_main.c +++ b/hypervisor/common/hv_main.c @@ -64,7 +64,12 @@ void vcpu_thread(struct vcpu *vcpu) CPU_IRQ_DISABLE(); /* Check and process pending requests(including interrupt) */ - acrn_handle_pending_request(vcpu); + ret = acrn_handle_pending_request(vcpu); + if (ret < 0) { + pr_fatal("vcpu handling pending request fail"); + pause_vcpu(vcpu, VCPU_ZOMBIE); + continue; + } if (need_rescheduled(vcpu->pcpu_id)) { /* diff --git a/hypervisor/include/arch/x86/guest/guest.h b/hypervisor/include/arch/x86/guest/guest.h index d7dd1fb65..076350347 100644 --- a/hypervisor/include/arch/x86/guest/guest.h +++ b/hypervisor/include/arch/x86/guest/guest.h @@ -70,6 +70,7 @@ int get_req_info(char *str, int str_max); #define ACRN_REQUEST_GP 3 #define ACRN_REQUEST_TMR_UPDATE 4 #define ACRN_REQUEST_TLB_FLUSH 5 +#define ACRN_REQUEST_TRP_FAULT 6 #define E820_MAX_ENTRIES 32 diff --git a/hypervisor/include/lib/errno.h b/hypervisor/include/lib/errno.h index b06635e89..30cad2e01 100644 --- a/hypervisor/include/lib/errno.h +++ b/hypervisor/include/lib/errno.h @@ -41,5 +41,7 @@ #define EIO 4 /** Indicates that target is busy. */ #define EBUSY 5 +/** Indicates there is fault. */ +#define EFAULT 6 #endif /* ERRNO_H */