ANDROID: virtio_balloon: New module parameter "pkvm"

This specifies that the driver is running on a PKVM hypervisor
and must use the memrelinquish service to cooperatively release
memory. If this service is unavailable, virtio_balloon cannot be
used.

Bug: 240239989
Change-Id: I8800c4435d8fae9df6f1ab108cc61c8f93020773
Signed-off-by: Keir Fraser <keirf@google.com>
This commit is contained in:
Keir Fraser
2022-11-17 15:24:40 +00:00
parent b1d965d624
commit 87bcd3edf3

View File

@@ -21,6 +21,11 @@
#include <linux/magic.h>
#include <linux/pseudo_fs.h>
#include <linux/page_reporting.h>
#include <linux/mem_relinquish.h>
static bool pkvm;
module_param(pkvm, bool, 0);
MODULE_PARM_DESC(pkvm, "Running on PKVM. Must use MEM_RELINQUISH.");
/*
* Balloon device works in 4K page units. So each page is pointed to by
@@ -887,6 +892,12 @@ static int virtballoon_probe(struct virtio_device *vdev)
struct virtio_balloon *vb;
int err;
if (pkvm && !kvm_has_memrelinquish_services()) {
dev_err(&vdev->dev, "%s failure: pkvm but no memrelinquish\n",
__func__);
return -EINVAL;
}
if (!vdev->config->get) {
dev_err(&vdev->dev, "%s failure: config access disabled\n",
__func__);