This is a preparatory change for blocking kexec is there are any pages deposited, as this information is lost after kexec and the pages aren't accessible by kernel.
Signed-off-by: Stanislav Kinsburskii <[email protected]> --- drivers/hv/hv_proc.c | 4 ++++ drivers/hv/mshv_root.h | 1 + drivers/hv/mshv_root_hv_call.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/drivers/hv/hv_proc.c b/drivers/hv/hv_proc.c index 89870c1b0087..39bbbedb0340 100644 --- a/drivers/hv/hv_proc.c +++ b/drivers/hv/hv_proc.c @@ -15,6 +15,8 @@ */ #define HV_DEPOSIT_MAX (HV_HYP_PAGE_SIZE / sizeof(u64) - 1) +atomic_t hv_pages_deposited; + /* Deposits exact number of pages. Must be called with interrupts enabled. */ int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages) { @@ -93,6 +95,8 @@ int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages) goto err_free_allocations; } + atomic_add(page_count, &hv_pages_deposited); + ret = 0; goto free_buf; diff --git a/drivers/hv/mshv_root.h b/drivers/hv/mshv_root.h index 3c1d88b36741..c792afce0839 100644 --- a/drivers/hv/mshv_root.h +++ b/drivers/hv/mshv_root.h @@ -319,6 +319,7 @@ int hv_call_get_partition_property_ex(u64 partition_id, u64 property_code, u64 a extern struct mshv_root mshv_root; extern enum hv_scheduler_type hv_scheduler_type; extern u8 * __percpu *hv_synic_eventring_tail; +extern atomic_t hv_pages_deposited; struct mshv_mem_region *mshv_region_create(u64 guest_pfn, u64 nr_pages, u64 uaddr, u32 flags); diff --git a/drivers/hv/mshv_root_hv_call.c b/drivers/hv/mshv_root_hv_call.c index 06f2bac8039d..4203af5190ee 100644 --- a/drivers/hv/mshv_root_hv_call.c +++ b/drivers/hv/mshv_root_hv_call.c @@ -73,6 +73,8 @@ int hv_call_withdraw_memory(u64 count, int node, u64 partition_id) for (i = 0; i < completed; i++) __free_page(pfn_to_page(output_page->gpa_page_list[i])); + atomic_sub(completed, &hv_pages_deposited); + if (!hv_result_success(status)) { if (hv_result(status) == HV_STATUS_NO_RESOURCES) status = HV_STATUS_SUCCESS;
