lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tc2av6i3kccwo37zykj4zs4nsrcdmc3xs72hnpnn6vwxk67chi@njto2c3ahbu5>
Date: Thu, 5 Feb 2026 23:28:03 +0530
From: Anirudh Rayabharam <anirudh@...rudhrb.com>
To: Stanislav Kinsburskii <skinsburskii@...ux.microsoft.com>
Cc: kys@...rosoft.com, haiyangz@...rosoft.com, wei.liu@...nel.org, 
	decui@...rosoft.com, longli@...rosoft.com, linux-hyperv@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/4] mshv: Introduce hv_result_needs_memory() helper
 function

On Mon, Feb 02, 2026 at 05:58:57PM +0000, Stanislav Kinsburskii wrote:
> Replace direct comparisons of hv_result(status) against
> HV_STATUS_INSUFFICIENT_MEMORY with a new hv_result_needs_memory() helper
> function.
> This improves code readability and provides a consistent and extendable
> interface for checking out-of-memory conditions in hypercall results.
> 
> No functional changes intended.
> 
> Signed-off-by: Stanislav Kinsburskii <skinsburskii@...ux.microsoft.com>
> ---
>  drivers/hv/hv_proc.c           |   14 ++++++++++++--
>  drivers/hv/mshv_root_hv_call.c |   20 ++++++++++----------
>  drivers/hv/mshv_root_main.c    |    2 +-
>  include/asm-generic/mshyperv.h |    3 +++
>  4 files changed, 26 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/hv/hv_proc.c b/drivers/hv/hv_proc.c
> index fbb4eb3901bb..e53204b9e05d 100644
> --- a/drivers/hv/hv_proc.c
> +++ b/drivers/hv/hv_proc.c
> @@ -110,6 +110,16 @@ int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
>  }
>  EXPORT_SYMBOL_GPL(hv_call_deposit_pages);
>  
> +bool hv_result_needs_memory(u64 status)
> +{
> +	switch (hv_result(status)) {
> +	case HV_STATUS_INSUFFICIENT_MEMORY:
> +		return true;
> +	}
> +	return false;
> +}
> +EXPORT_SYMBOL_GPL(hv_result_needs_memory);
> +
>  int hv_call_add_logical_proc(int node, u32 lp_index, u32 apic_id)
>  {
>  	struct hv_input_add_logical_processor *input;
> @@ -137,7 +147,7 @@ int hv_call_add_logical_proc(int node, u32 lp_index, u32 apic_id)
>  					 input, output);
>  		local_irq_restore(flags);
>  
> -		if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> +		if (!hv_result_needs_memory(status)) {
>  			if (!hv_result_success(status)) {
>  				hv_status_err(status, "cpu %u apic ID: %u\n",
>  					      lp_index, apic_id);
> @@ -179,7 +189,7 @@ int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags)
>  		status = hv_do_hypercall(HVCALL_CREATE_VP, input, NULL);
>  		local_irq_restore(irq_flags);
>  
> -		if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> +		if (!hv_result_needs_memory(status)) {
>  			if (!hv_result_success(status)) {
>  				hv_status_err(status, "vcpu: %u, lp: %u\n",
>  					      vp_index, flags);
> diff --git a/drivers/hv/mshv_root_hv_call.c b/drivers/hv/mshv_root_hv_call.c
> index 598eaff4ff29..89afeeda21dd 100644
> --- a/drivers/hv/mshv_root_hv_call.c
> +++ b/drivers/hv/mshv_root_hv_call.c
> @@ -115,7 +115,7 @@ int hv_call_create_partition(u64 flags,
>  		status = hv_do_hypercall(HVCALL_CREATE_PARTITION,
>  					 input, output);
>  
> -		if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> +		if (!hv_result_needs_memory(status)) {
>  			if (hv_result_success(status))
>  				*partition_id = output->partition_id;
>  			local_irq_restore(irq_flags);
> @@ -147,7 +147,7 @@ int hv_call_initialize_partition(u64 partition_id)
>  		status = hv_do_fast_hypercall8(HVCALL_INITIALIZE_PARTITION,
>  					       *(u64 *)&input);
>  
> -		if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> +		if (!hv_result_needs_memory(status)) {
>  			ret = hv_result_to_errno(status);
>  			break;
>  		}
> @@ -239,7 +239,7 @@ static int hv_do_map_gpa_hcall(u64 partition_id, u64 gfn, u64 page_struct_count,
>  
>  		completed = hv_repcomp(status);
>  
> -		if (hv_result(status) == HV_STATUS_INSUFFICIENT_MEMORY) {
> +		if (hv_result_needs_memory(status)) {
>  			ret = hv_call_deposit_pages(NUMA_NO_NODE, partition_id,
>  						    HV_MAP_GPA_DEPOSIT_PAGES);
>  			if (ret)
> @@ -455,7 +455,7 @@ int hv_call_get_vp_state(u32 vp_index, u64 partition_id,
>  
>  		status = hv_do_hypercall(control, input, output);
>  
> -		if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> +		if (!hv_result_needs_memory(status)) {
>  			if (hv_result_success(status) && ret_output)
>  				memcpy(ret_output, output, sizeof(*output));
>  
> @@ -518,7 +518,7 @@ int hv_call_set_vp_state(u32 vp_index, u64 partition_id,
>  
>  		status = hv_do_hypercall(control, input, NULL);
>  
> -		if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> +		if (!hv_result_needs_memory(status)) {
>  			local_irq_restore(flags);
>  			ret = hv_result_to_errno(status);
>  			break;
> @@ -563,7 +563,7 @@ static int hv_call_map_vp_state_page(u64 partition_id, u32 vp_index, u32 type,
>  		status = hv_do_hypercall(HVCALL_MAP_VP_STATE_PAGE, input,
>  					 output);
>  
> -		if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> +		if (!hv_result_needs_memory(status)) {
>  			if (hv_result_success(status))
>  				*state_page = pfn_to_page(output->map_location);
>  			local_irq_restore(flags);
> @@ -718,7 +718,7 @@ hv_call_create_port(u64 port_partition_id, union hv_port_id port_id,
>  		if (hv_result_success(status))
>  			break;
>  
> -		if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> +		if (!hv_result_needs_memory(status)) {
>  			ret = hv_result_to_errno(status);
>  			break;
>  		}
> @@ -772,7 +772,7 @@ hv_call_connect_port(u64 port_partition_id, union hv_port_id port_id,
>  		if (hv_result_success(status))
>  			break;
>  
> -		if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> +		if (!hv_result_needs_memory(status)) {
>  			ret = hv_result_to_errno(status);
>  			break;
>  		}
> @@ -843,7 +843,7 @@ static int hv_call_map_stats_page2(enum hv_stats_object_type type,
>  		if (!ret)
>  			break;
>  
> -		if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> +		if (!hv_result_needs_memory(status)) {
>  			hv_status_debug(status, "\n");
>  			break;
>  		}
> @@ -878,7 +878,7 @@ static int hv_call_map_stats_page(enum hv_stats_object_type type,
>  		pfn = output->map_location;
>  
>  		local_irq_restore(flags);
> -		if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> +		if (!hv_result_needs_memory(status)) {
>  			ret = hv_result_to_errno(status);
>  			if (hv_result_success(status))
>  				break;
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index 6a6bf641b352..ee30bfa6bb2e 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -261,7 +261,7 @@ static int mshv_ioctl_passthru_hvcall(struct mshv_partition *partition,
>  		if (hv_result_success(status))
>  			break;
>  
> -		if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY)
> +		if (!hv_result_needs_memory(status))
>  			ret = hv_result_to_errno(status);
>  		else
>  			ret = hv_call_deposit_pages(NUMA_NO_NODE,
> diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
> index ecedab554c80..452426d5b2ab 100644
> --- a/include/asm-generic/mshyperv.h
> +++ b/include/asm-generic/mshyperv.h
> @@ -342,6 +342,8 @@ static inline bool hv_parent_partition(void)
>  {
>  	return hv_root_partition() || hv_l1vh_partition();
>  }
> +
> +bool hv_result_needs_memory(u64 status);
>  int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages);
>  int hv_call_add_logical_proc(int node, u32 lp_index, u32 acpi_id);
>  int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags);
> @@ -350,6 +352,7 @@ int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags);
>  static inline bool hv_root_partition(void) { return false; }
>  static inline bool hv_l1vh_partition(void) { return false; }
>  static inline bool hv_parent_partition(void) { return false; }
> +static inline bool hv_result_needs_memory(u64 status) { return false; }
>  static inline int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
>  {
>  	return -EOPNOTSUPP;
> 
> 

Reviewed-by: Anirudh Rayabharam (Microsoft) <anirudh@...rudhrb.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ