From 795a33ac56e8ddc041a7e502443988c72c89e411 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Fri, 17 May 2024 10:28:56 +0800 Subject: [PATCH] hv: ENODEV should be able to be set into RAX as hypercall return value Some hypercalls return -ENODEV which should be set into RAX as return value, e.g. HC_ASSIGN_PCIDEV. So, remove the check in vmcall_vmexit_handler() and change return value to -EACCESS if the hypercall is not sent from Service VM or allowed VM. Tracked-On: #8598 Signed-off-by: Yi Sun --- hypervisor/arch/x86/guest/vmcall.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hypervisor/arch/x86/guest/vmcall.c b/hypervisor/arch/x86/guest/vmcall.c index e7ad68940..16ad8c600 100644 --- a/hypervisor/arch/x86/guest/vmcall.c +++ b/hypervisor/arch/x86/guest/vmcall.c @@ -257,7 +257,7 @@ static int32_t dispatch_hypercall(struct acrn_vcpu *vcpu) */ int32_t vmcall_vmexit_handler(struct acrn_vcpu *vcpu) { - int32_t ret; + int32_t ret = -EACCES; struct acrn_vm *vm = vcpu->vm; /* hypercall ID from guest*/ uint64_t hypcall_id = vcpu_get_gpreg(vcpu, CPU_REG_R8); @@ -275,17 +275,13 @@ int32_t vmcall_vmexit_handler(struct acrn_vcpu *vcpu) */ if (!is_service_vm(vm) && !is_guest_hypercall(vm)) { vcpu_inject_ud(vcpu); - ret = -ENODEV; } else if (!is_hypercall_from_ring0()) { vcpu_inject_gp(vcpu, 0U); - ret = -EACCES; } else { ret = dispatch_hypercall(vcpu); - } - - if ((ret != -EACCES) && (ret != -ENODEV)) { vcpu_set_gpreg(vcpu, CPU_REG_RAX, (uint64_t)ret); } + if (ret < 0) { pr_err("ret=%d hypercall=0x%lx failed in %s\n", ret, hypcall_id, __func__); }