[PATCH V2 1/4] mshv: Add gfp_flags parameter to hv_call_deposit_pages()
From: Mukesh R
Date: Tue Sep 29 2026 - 18:36:48 EST
Currently GFP_KERNEL is hard coded in hv_call_deposit_pages(). Add
gfp_flags parameter so it can be called in atomic context from
map_pages callback in struct iommu_domain_ops and other places in
future.
Signed-off-by: Mukesh R <mrathor@xxxxxxxxxxxxxxxxxxx>
---
drivers/hv/hv_proc.c | 14 +++++++-------
drivers/hv/mshv_root_hv_call.c | 6 ++++--
include/asm-generic/mshyperv.h | 6 ++++--
3 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/hv/hv_proc.c b/drivers/hv/hv_proc.c
index 57b2c64197cb..ce4276d37d45 100644
--- a/drivers/hv/hv_proc.c
+++ b/drivers/hv/hv_proc.c
@@ -15,8 +15,8 @@
*/
#define HV_DEPOSIT_MAX (HV_HYP_PAGE_SIZE / sizeof(u64) - 1)
-/* Deposits exact number of pages. Must be called with interrupts enabled. */
-int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
+int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages,
+ gfp_t gfp_flags)
{
struct page **pages, *page;
int *counts;
@@ -35,12 +35,12 @@ int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
return 0;
/* One buffer for page pointers and counts */
- page = alloc_page(GFP_KERNEL);
+ page = alloc_page(gfp_flags);
if (!page)
return -ENOMEM;
pages = page_address(page);
- counts = kzalloc_objs(int, HV_DEPOSIT_MAX);
+ counts = kzalloc_objs(int, HV_DEPOSIT_MAX, gfp_flags);
if (!counts) {
free_page((unsigned long)pages);
return -ENOMEM;
@@ -54,7 +54,7 @@ int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
order = 31 - __builtin_clz(num_pages);
while (1) {
- pages[i] = alloc_pages_node(node, GFP_KERNEL, order);
+ pages[i] = alloc_pages_node(node, gfp_flags, order);
if (pages[i])
break;
if (!order) {
@@ -137,7 +137,7 @@ int hv_deposit_memory_node(int node, u64 partition_id,
hv_status_err(hv_status, "Unexpected!\n");
return -ENOMEM;
}
- return hv_call_deposit_pages(node, partition_id, num_pages);
+ return hv_call_deposit_pages(node, partition_id, num_pages, GFP_KERNEL);
}
EXPORT_SYMBOL_GPL(hv_deposit_memory_node);
@@ -206,7 +206,7 @@ int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags)
/* Root VPs don't seem to need pages deposited */
if (partition_id != hv_current_partition_id) {
/* The value 90 is empirically determined. It may change. */
- ret = hv_call_deposit_pages(node, partition_id, 90);
+ ret = hv_call_deposit_pages(node, partition_id, 90, GFP_KERNEL);
if (ret)
return ret;
}
diff --git a/drivers/hv/mshv_root_hv_call.c b/drivers/hv/mshv_root_hv_call.c
index cb55d4d4be2e..bd975239f3bc 100644
--- a/drivers/hv/mshv_root_hv_call.c
+++ b/drivers/hv/mshv_root_hv_call.c
@@ -141,7 +141,8 @@ int hv_call_initialize_partition(u64 partition_id)
input.partition_id = partition_id;
ret = hv_call_deposit_pages(NUMA_NO_NODE, partition_id,
- HV_INIT_PARTITION_DEPOSIT_PAGES);
+ HV_INIT_PARTITION_DEPOSIT_PAGES,
+ GFP_KERNEL);
if (ret)
return ret;
@@ -249,7 +250,8 @@ static int hv_do_map_gpa_hcall(u64 partition_id, u64 gfn, u64 page_struct_count,
if (hv_result_needs_memory(status)) {
ret = hv_call_deposit_pages(NUMA_NO_NODE, partition_id,
- HV_MAP_GPA_DEPOSIT_PAGES);
+ HV_MAP_GPA_DEPOSIT_PAGES,
+ GFP_KERNEL);
if (ret)
break;
diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
index bf601d67cecb..af65dd3e3725 100644
--- a/include/asm-generic/mshyperv.h
+++ b/include/asm-generic/mshyperv.h
@@ -345,7 +345,8 @@ static inline bool hv_parent_partition(void)
bool hv_result_needs_memory(u64 status);
int hv_deposit_memory_node(int node, u64 partition_id, u64 status);
-int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages);
+int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages,
+ gfp_t gfp_flags);
int hv_call_add_logical_proc(int node, u32 lp_index, u32 acpi_id);
int hv_call_notify_all_processors_started(void);
bool hv_lp_exists(u32 lp_index);
@@ -360,7 +361,8 @@ static inline int hv_deposit_memory_node(int node, u64 partition_id, u64 status)
{
return -EOPNOTSUPP;
}
-static inline int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
+static inline int hv_call_deposit_pages(int node, u64 partition_id,
+ u32 num_pages, gfp_t gfp_flags)
{
return -EOPNOTSUPP;
}
--
2.51.2.vfs.0.1