Re: [PATCH] Drivers: hv: Use meaningful errnos for hypercall status codes

Naman Jain <[email protected]> Wed, 29 Jul 2026 10:48:55 +0530
Newsgroups org.kernel.vger.linux-hyperv,org.kernel.vger.linux-kernel
Message-ID <[email protected]>

On 7/28/2026 2:53 AM, Easwar Hariharan wrote:
> Hi Hardik,
> 
> On 7/27/2026 14:11, Hardik Garg wrote:
>> Commit 3817854ba892 ("hyperv: Log hypercall status codes as strings")
>> converted hv_result_to_errno() from a switch to a table and added status
>> codes used for string logging. Statuses without an existing specific
>> mapping were assigned the generic -EIO fallback even when a more specific
>> errno was available.
>>
>> Map HV_STATUS_ACCESS_DENIED and HV_STATUS_OPERATION_DENIED to -EACCES,
>> HV_STATUS_UNKNOWN_PROPERTY and HV_STATUS_PROPERTY_VALUE_OUT_OF_RANGE to
>> -EINVAL, and HV_STATUS_PROCESSOR_FEATURE_NOT_SUPPORTED to -EOPNOTSUPP.
>> This lets callers distinguish permission, argument, and capability
>> failures from generic I/O errors.
>>
>> The table conversion also added duplicate HV_STATUS_INVALID_LP_INDEX and
>> HV_STATUS_INVALID_REGISTER_VALUE entries. Remove the later -EIO entries,
>> which are unreachable because find_hv_status_info() returns the first
>> match.
>>
>> Signed-off-by: Hardik Garg <[email protected]>
>> ---
>>   drivers/hv/hv_common.c | 12 +++++-------
>>   1 file changed, 5 insertions(+), 7 deletions(-)
>>
> Glad to see that this was something that bothered you as well. If you like, you
> can pick up feedback from Nuno on my attempt to solve this [1] and do a de-facto v3.
> 
> [1] https://lore.kernel.org/all/[email protected]/
> 
> Thanks,
> Easwar (he/him)

I see no harm but only benefits in returning meaningful error code 
corresponding to HV_STATUS_*, where we can, specially when such an error 
code exists. So I agree with the motivation of this exercise.

On this patch or a new v3 of previous patch, feel free to pick my review:

Reviewed-by: Naman Jain <[email protected]>

Regards,
Naman