From: "Yan, Like" <like.yan@...>
Replace ASSERT which should not pause hypervisor with CHECK or
CHECK_RET in hypercall and vmexit handling.
Change-Id: If80b6be0abb808365e0208557a2682e67d245277
Signed-off-by: Yan, Like <like.yan@...>
---
arch/x86/vmexit.c | 7 +++++--
common/hypercall.c | 18 ++++++++++--------
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/arch/x86/vmexit.c b/arch/x86/vmexit.c
index 3b1b536..25e7e95 100644
--- a/arch/x86/vmexit.c
+++ b/arch/x86/vmexit.c
@@ -349,7 +349,9 @@ int cr_access_handler(struct vcpu *vcpu)
};
int idx = VM_EXIT_CR_ACCESS_REG_IDX(vcpu->arch_vcpu.exit_qualification);
- ASSERT(idx != 4, "index should not be 4 (target SP)");
+ CHECK_RET(idx != 4, -EINVAL,
+ "%s: index should not be 4 (target SP)", __func__);
+
regptr = cur_context->guest_cpu_regs.longs + reg_trans_tab[idx];
switch ((VM_EXIT_CR_ACCESS_ACCESS_TYPE
@@ -389,7 +391,8 @@ int cr_access_handler(struct vcpu *vcpu)
*regptr = vlapic_get_cr8(vcpu->arch_vcpu.vlapic);
break;
default:
- panic("Unhandled CR access");
+ pr_fatal("Unhandled CR access");
+ dump_contexts();
return -EINVAL;
}
diff --git a/common/hypercall.c b/common/hypercall.c
index a3218bf..4693622 100644
--- a/common/hypercall.c
+++ b/common/hypercall.c
@@ -379,7 +379,8 @@ int64_t hcall_notify_req_finish(uint64_t vmid, uint64_t vcpu_id)
vmid, vcpu_id);
vcpu = vcpu_from_vid(target_vm, vcpu_id);
- ASSERT(vcpu != NULL, "Failed to get VCPU context.");
+ CHECK_RET(vcpu != NULL, -1,
+ "%s: Failed to get VCPU context.", __func__);
req_buf = (struct vhm_request_buffer *)target_vm->sw.req_buf;
req = req_buf->req_queue + vcpu_id;
@@ -541,12 +542,14 @@ int64_t hcall_assign_ptdev(struct vm *vm, uint64_t vmid, uint64_t param)
/* create a iommu domain for target VM if not created */
if (!target_vm->iommu_domain) {
- ASSERT(target_vm->arch_vm.ept, "EPT of VM not set!");
+ CHECK_RET(target_vm->arch_vm.ept, -1,
+ "%s: EPT of VM not set!", __func__);
/* TODO: how to get vm's address width? */
target_vm->iommu_domain = create_iommu_domain(vmid,
target_vm->arch_vm.ept, 48);
- ASSERT(target_vm->iommu_domain,
- "failed to created iommu domain!");
+ CHECK_RET(target_vm->iommu_domain, -1,
+ "%s: failed to created iommu domain!",
+ __func__);
}
ret = assign_iommu_device(target_vm->iommu_domain,
(uint8_t)(bdf >> 8), (uint8_t)(bdf & 0xff));
@@ -672,7 +675,7 @@ static void fire_vhm_interrupt(void)
ASSERT(vm0, "VM Pointer is NULL");
vcpu = vcpu_from_vid(vm0, 0);
- ASSERT(vcpu, "vcpu_from_vid failed");
+ CHECK(vcpu, "%s: vcpu_from_vid failed", __func__);
vlapic_intr_edge(vcpu, VECTOR_VIRT_IRQ_VHM);
}
@@ -720,9 +723,8 @@ int acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req)
(void *)HPA2HVA(vcpu->vm->sw.req_buf);
long cur;
- ASSERT(sizeof(*req) == (4096/VHM_REQUEST_MAX),
- "vhm_request page broken!");
-
+ CHECK_RET(sizeof(*req) == (4096/VHM_REQUEST_MAX), -1,
+ "%s: vhm_request page broken!", __func__);
if (!vcpu || !req || vcpu->vm->sw.req_buf == 0)
return -1;
--
2.7.4