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>] [day] [month] [year] [list]
Message-Id: <1670328213-9471-1-git-send-email-shradhagupta@linux.microsoft.com>
Date:   Tue,  6 Dec 2022 04:03:33 -0800
From:   Shradha Gupta <shradhagupta@...ux.microsoft.com>
To:     linux-kernel@...r.kernel.org, linux-hyperv@...r.kernel.org
Cc:     Shradha Gupta <shradhagupta@...ux.microsoft.com>,
        "K. Y. Srinivasan" <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        Stephen Hemminger <sthemmin@...rosoft.com>,
        Wei Liu <wei.liu@...nel.org>, Dexuan Cui <decui@...rosoft.com>,
        Long Li <longli@...rosoft.com>,
        Michael Kelley <mikelley@...rosoft.com>
Subject: [PATCH v2] hv_balloon: Fix committed value in post_status() if dynamic memory is disabled

If Dynamic memory is disabled for VM, the committed value reported by the
post_status() call by hv_balloon driver includes compute_balloon_floor().
This is not needed if balloon_up operations or hot_add operations were
never requested on the VM(or if Dynamic memory was disabled for the VM)

Fixes: 1c7db96f6feac ("Prevent the host from ballooning the guest too low")

Signed-off-by: Shradha Gupta <shradhagupta@...ux.microsoft.com>
---

Changes in v2:
  * Add Fixes: tag in the patch

---
 drivers/hv/hv_balloon.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index fdf6decacf06..a6f5321d4a2e 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -1129,11 +1129,23 @@ static unsigned long compute_balloon_floor(void)
 
 static unsigned long get_pages_committed(struct hv_dynmem_device *dm)
 {
-	return vm_memory_committed() +
-		dm->num_pages_ballooned +
-		(dm->num_pages_added > dm->num_pages_onlined ?
-		 dm->num_pages_added - dm->num_pages_onlined : 0) +
-		compute_balloon_floor();
+	unsigned long pages_committed;
+
+	pages_committed = vm_memory_committed();
+
+	/*
+	 * If no balloon_up or hot_add operation was performed do not add
+	 * num_pages_ballooned, number of pages offline or
+	 * compute_balloon_floor() to the pages_committed value
+	 */
+	if (dm->num_pages_ballooned || dm->num_pages_added) {
+		pages_committed += dm->num_pages_ballooned +
+			(dm->num_pages_added > dm->num_pages_onlined ?
+			 dm->num_pages_added - dm->num_pages_onlined : 0) +
+			 compute_balloon_floor();
+	}
+
+	return pages_committed;
 }
 
 /*
-- 
2.37.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ