Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932608AbbHGQsO (ORCPT ); Fri, 7 Aug 2015 12:48:14 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:50681 "EHLO SMTP02.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932410AbbHGQsL (ORCPT ); Fri, 7 Aug 2015 12:48:11 -0400 X-IronPort-AV: E=Sophos;i="5.15,630,1432598400"; d="scan'208";a="292474698" From: Julien Grall To: CC: , , , , "Julien Grall" , Julien Grall , David Vrabel , Konrad Rzeszutek Wilk , Boris Ostrovsky Subject: [PATCH v3 05/20] xen/grant: Add helper gnttab_page_grant_foreign_access_ref_one Date: Fri, 7 Aug 2015 17:46:44 +0100 Message-ID: <1438966019-19322-6-git-send-email-julien.grall@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438966019-19322-1-git-send-email-julien.grall@citrix.com> References: <1438966019-19322-1-git-send-email-julien.grall@citrix.com> MIME-Version: 1.0 Content-Type: text/plain X-DLP: MIA1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2315 Lines: 68 Many PV drivers contain the idiom: pfn = page_to_gfn(...) /* Or similar */ gnttab_grant_foreign_access_ref Replace it by a new helper. Note that when Linux is using a different page granularity than Xen, the helper only gives access to the first 4KB grant. This is useful where drivers are allocating a full Linux page for each grant. Also include xen/interface/grant_table.h rather than xen/grant_table.h in asm/page.h for x86 to fix a compilation issue [1]. Only the former is useful in order to get the structure definition. [1] Interdependency between asm/page.h and xen/grant_table.h which result to page_mfn not being defined when necessary. Signed-off-by: Julien Grall Reviewed-by: David Vrabel Reviewed-by: Stefano Stabellini --- Cc: Konrad Rzeszutek Wilk Cc: Boris Ostrovsky Changes in v3: - Rename gnttab_page_grant_foreign_access_ref into gnttab_page_grant_foreign_access_ref_one - Fix typo in the commit message - s/mfn/gfn based on the new naming - Add David and Stefano's reviewed-by Changes in v2: - Patch added --- include/xen/grant_table.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h index 2a8ebe8..1c1ddd9 100644 --- a/include/xen/grant_table.h +++ b/include/xen/grant_table.h @@ -131,6 +131,15 @@ void gnttab_cancel_free_callback(struct gnttab_free_callback *callback); void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid, unsigned long frame, int readonly); +/* Give access to the first 4K of the page */ +static inline void gnttab_page_grant_foreign_access_ref_one( + grant_ref_t ref, domid_t domid, + struct page *page, int readonly) +{ + gnttab_grant_foreign_access_ref(ref, domid, xen_page_to_gfn(page), + readonly); +} + void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid, unsigned long pfn); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/