[PATCH 4/4] xen: select grant interface version
From: Juergen Gross
Date: Fri Sep 08 2017 - 12:04:25 EST
Based on the maximum page number of the host select either grant v1 or
grant v2.
For testing purposes add a way to specify the grant interface version
via a boot parameter.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
drivers/xen/grant-table.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 573af785c425..c8479cb4c0dc 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -43,6 +43,7 @@
#include <linux/hardirq.h>
#include <linux/workqueue.h>
#include <linux/ratelimit.h>
+#include <linux/moduleparam.h>
#include <xen/xen.h>
#include <xen/interface/xen.h>
@@ -68,6 +69,8 @@ static int gnttab_free_count;
static grant_ref_t gnttab_free_head;
static DEFINE_SPINLOCK(gnttab_list_lock);
struct grant_frames xen_auto_xlat_grant_frames;
+static unsigned int xen_gnttab_version;
+module_param_named(version, xen_gnttab_version, uint, 0);
static union {
struct grant_entry_v1 *v1;
@@ -1191,10 +1194,16 @@ static const struct gnttab_ops gnttab_v2_ops = {
static void gnttab_request_version(void)
{
- int rc;
+ long rc;
struct gnttab_set_version gsv;
- gsv.version = 1;
+ rc = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
+ if (rc < 0 || !(rc >> 32))
+ gsv.version = 1;
+ else
+ gsv.version = 2;
+ if (xen_gnttab_version >= 1 && xen_gnttab_version <= 2)
+ gsv.version = xen_gnttab_version;
rc = HYPERVISOR_grant_table_op(GNTTABOP_set_version, &gsv, 1);
if (rc == 0 && gsv.version == 2)
--
2.12.3