Re: [PATCH v2 1/3] hyperv: Convert hypercall statuses to linux error codes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/20/2025 10:33 AM, Nuno Das Neves wrote:
> Return linux-friendly error codes from hypercall helper functions,
> which allows them to be used more flexibly.
> 
> Introduce hv_result_to_errno() for this purpose, which also handles
> the special value U64_MAX returned from hv_do_hypercall().
> 
> Signed-off-by: Nuno Das Neves <nunodasneves@xxxxxxxxxxxxxxxxxxx>
> ---
>  drivers/hv/hv_common.c         | 34 ++++++++++++++++++++++++++++++++++
>  drivers/hv/hv_proc.c           |  6 +++---
>  include/asm-generic/mshyperv.h |  1 +
>  3 files changed, 38 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> index ee3083937b4f..2120aead98d9 100644
> --- a/drivers/hv/hv_common.c
> +++ b/drivers/hv/hv_common.c
> @@ -683,3 +683,37 @@ u64 __weak hv_tdx_hypercall(u64 control, u64 param1, u64 param2)
>  	return HV_STATUS_INVALID_PARAMETER;
>  }
>  EXPORT_SYMBOL_GPL(hv_tdx_hypercall);
> +
> +/* Convert a hypercall result into a linux-friendly error code. */
> +int hv_result_to_errno(u64 status)
> +{
> +	/* hv_do_hypercall() may return U64_MAX, hypercalls aren't possible */
> +	if (unlikely(status == U64_MAX))
> +		return -EOPNOTSUPP;
> +	/*
> +	 * A failed hypercall is usually only recoverable (or loggable) near
> +	 * the call site where the HV_STATUS_* code is known. So the errno
> +	 * it gets converted to is not too useful further up the stack.
> +	 * Provice a few mappings that could be useful, and revert to -EIO

Typo: Provide

Otherwise, looks good to me.

Reviewed-by: Easwar Hariharan <eahariha@xxxxxxxxxxxxxxxxxxx>

Thanks,
Easwar (he/him)




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux