From: Stanislav Kinsburskii <[email protected]> Sent: Thursday, 
October 2, 2025 9:36 AM
> 
> Simplify and unify memory region management to improve code clarity and
> reliability. Consolidate pinning and invalidation logic, adopt consistent
> naming, and remove redundant checks to reduce complexity.
> 
> Enhance documentation and update call sites for maintainability.
> 
> Signed-off-by: Stanislav Kinsburskii <[email protected]>
> ---
>  drivers/hv/mshv_root_main.c |   78 
> +++++++++++++++++++------------------------
>  1 file changed, 35 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index fa42c40e1e02f..29d0c2c9ae4c8 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c

[snip]

> @@ -1264,17 +1248,25 @@ static int mshv_partition_create_region(struct 
> mshv_partition *partition,
>       return 0;
>  }
> 
> -/*
> - * Map guest ram. if snp, make sure to release that from the host first
> - * Side Effects: In case of failure, pages are unpinned when feasible.
> +/**
> + * mshv_prepare_pinned_region - Pin and map memory regions
> + * @region: Pointer to the memory region structure
> + *
> + * This function processes memory regions that are explicitly marked as 
> pinned.
> + * Pinned regions are preallocated, mapped upfront, and do not rely on 
> fault-based
> + * population. The function ensures the region is properly populated, handles
> + * encryption requirements for SNP partitions if applicable, maps the region,
> + * and performs necessary sharing or eviction operations based on the mapping
> + * result.
> + *
> + * Return: 0 on success, negative error code on failure.
>   */
> -static int
> -mshv_partition_mem_region_map(struct mshv_mem_region *region)
> +static int mshv_prepare_pinned_region(struct mshv_mem_region *region)
>  {
>       struct mshv_partition *partition = region->partition;
>       int ret;
> 
> -     ret = mshv_region_populate(region);
> +     ret = mshv_region_pin(region);
>       if (ret) {
>               pt_err(partition, "Failed to populate memory region: %d\n",

Nit: This error message should probably use the new "pin" terminology
instead of "populate".

Michael

Reply via email to