Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756413AbdIHQEI (ORCPT ); Fri, 8 Sep 2017 12:04:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:59196 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756387AbdIHQEG (ORCPT ); Fri, 8 Sep 2017 12:04:06 -0400 From: Juergen Gross To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Cc: boris.ostrovsky@oracle.com, Juergen Gross Subject: [PATCH 4/4] xen: select grant interface version Date: Fri, 8 Sep 2017 16:48:49 +0200 Message-Id: <20170908144849.2958-5-jgross@suse.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170908144849.2958-1-jgross@suse.com> References: <20170908144849.2958-1-jgross@suse.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1552 Lines: 53 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 --- 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 #include #include +#include #include #include @@ -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