From e2f1990548e47318a0a872ec8bf24c0ebfe9a837 Mon Sep 17 00:00:00 2001 From: Wen Qian Date: Wed, 26 Jan 2022 10:37:56 +0800 Subject: [PATCH] hv: change error code of undefined hypercall This patch adds ENOTTY and ENOSYS to indicate undefined and obsoleted request hyercall respectively, and uses ENOTTY as error code for undefined hypercall instead of EINVAL to consistent with the ACRN kernel's return value. Tracked-On: #7029 Signed-off-by: Wen Qian Signed-off-by: Li Fei Acked-by: Wang, Yu1 --- hypervisor/arch/x86/guest/vmcall.c | 4 ++-- hypervisor/include/lib/errno.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hypervisor/arch/x86/guest/vmcall.c b/hypervisor/arch/x86/guest/vmcall.c index 13ae5a880..04cb7d368 100644 --- a/hypervisor/arch/x86/guest/vmcall.c +++ b/hypervisor/arch/x86/guest/vmcall.c @@ -205,7 +205,7 @@ struct acrn_vm *parse_target_vm(struct acrn_vm *service_vm, uint64_t hcall_id, u static int32_t dispatch_hypercall(struct acrn_vcpu *vcpu) { - int32_t ret = -EINVAL; + int32_t ret = -ENOTTY; struct acrn_vm *vm = vcpu->vm; uint64_t guest_flags = get_vm_config(vm->vm_id)->guest_flags; /* hypercall ID from guest */ uint64_t hcall_id = vcpu_get_gpreg(vcpu, CPU_REG_R8); /* hypercall ID from guest */ @@ -237,7 +237,7 @@ static int32_t dispatch_hypercall(struct acrn_vcpu *vcpu) ((guest_flags & permission_flags) != 0UL)) { ret = dispatch->handler(vcpu, vcpu->vm, param1, param2); } else { - /* The vCPU is not allowed to invoke the given hypercall. Keep `ret` as -EINVAL and no + /* The vCPU is not allowed to invoke the given hypercall. Keep `ret` as -ENOTTY and no * further actions required. */ } diff --git a/hypervisor/include/lib/errno.h b/hypervisor/include/lib/errno.h index bc8c0db75..3d682c5c3 100644 --- a/hypervisor/include/lib/errno.h +++ b/hypervisor/include/lib/errno.h @@ -23,6 +23,10 @@ #define ENODEV 19 /** Indicates that argument is not valid. */ #define EINVAL 22 +/** Indicates the operation is undefined. */ +#define ENOTTY 25 +/** Indicates the operation is obsoleted. */ +#define ENOSYS 38 /** Indicates that timeout occurs. */ #define ETIMEDOUT 110