From patchwork Thu Jul 9 20:42:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 6759341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C78369F319 for ; Thu, 9 Jul 2015 20:46:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E95442078A for ; Thu, 9 Jul 2015 20:46:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1627320553 for ; Thu, 9 Jul 2015 20:46:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZDIgu-0001y6-0D; Thu, 09 Jul 2015 20:45:08 +0000 Received: from smtp02.citrix.com ([66.165.176.63]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZDIgH-0000eV-IO for linux-arm-kernel@lists.infradead.org; Thu, 09 Jul 2015 20:44:30 +0000 X-IronPort-AV: E=Sophos;i="5.15,442,1432598400"; d="scan'208";a="282741510" From: Julien Grall To: Subject: [PATCH v2 02/20] xen: Introduce a function to split a Linux page into Xen page Date: Thu, 9 Jul 2015 21:42:14 +0100 Message-ID: <1436474552-31789-3-git-send-email-julien.grall@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436474552-31789-1-git-send-email-julien.grall@citrix.com> References: <1436474552-31789-1-git-send-email-julien.grall@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150709_134429_780470_B6CDB4BE X-CRM114-Status: GOOD ( 10.99 ) X-Spam-Score: -4.6 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ian.campbell@citrix.com, Konrad Rzeszutek Wilk , stefano.stabellini@eu.citrix.com, linux-kernel@vger.kernel.org, Julien Grall , David Vrabel , Boris Ostrovsky , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Xen interface is always using 4KB page. This means that a Linux page may be split across multiple Xen page when the page granularity is not the same. This helper will break down a Linux page into 4KB chunk and call the helper on each of them. Signed-off-by: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Boris Ostrovsky Cc: David Vrabel Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- include/xen/page.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/xen/page.h b/include/xen/page.h index 8ebd37b..b1f7722 100644 --- a/include/xen/page.h +++ b/include/xen/page.h @@ -39,4 +39,24 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS]; extern unsigned long xen_released_pages; +typedef int (*xen_pfn_fn_t)(struct page *page, unsigned long pfn, void *data); + +/* Break down the page in 4KB granularity and call fn foreach xen pfn */ +static inline int xen_apply_to_page(struct page *page, xen_pfn_fn_t fn, + void *data) +{ + unsigned long pfn = xen_page_to_pfn(page); + int i; + int ret; + + for (i = 0; i < XEN_PFN_PER_PAGE; i++, pfn++) { + ret = fn(page, pfn, data); + if (ret) + return ret; + } + + return ret; +} + + #endif /* _XEN_PAGE_H */