From patchwork Tue Jul 18 12:24:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergej Proskurin X-Patchwork-Id: 9848245 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A8BAA602A7 for ; Tue, 18 Jul 2017 12:28:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A6A42859A for ; Tue, 18 Jul 2017 12:28:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F4A52859F; Tue, 18 Jul 2017 12:28:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 26FFA2859A for ; Tue, 18 Jul 2017 12:28:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXRZw-0005to-OH; Tue, 18 Jul 2017 12:26:16 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXRZu-0005qp-Cq for xen-devel@lists.xenproject.org; Tue, 18 Jul 2017 12:26:14 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id FB/A0-03612-56EFD695; Tue, 18 Jul 2017 12:26:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsXSPJ+BQzflX26 kwcSPlhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b3p13MBc9lK35+6WNpYPwk0cXIySEksJFR oq9Nv4uRC8jexCix8NV6RpAEm4CBxJTXK1lBbBEBJYl7qyYzgRQxC0xhlrj79x4zSEJYIFDi3 90PLCA2i4CqxMNn19lAbF4BG4m/rXfBbAkBeYldbRfBBnEK2Eo87HkGtIADaJuNxMafdhMYuR cwMqxi1ChOLSpLLdI1NNVLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAj0LwMQ7GD 8tizgEKMkB5OSKO/qA7mRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4zf8C5QSLUtNTK9Iyc4CB BpOW4OBREuG99gsozVtckJhbnJkOkTrFqMvxasL/b0xCLHn5ealS4rw//gAVCYAUZZTmwY2AB f0lRlkpYV5GoKOEeApSi3IzS1DlXzGKczAqCfN2gkzhycwrgdv0CugIJqAjhH1zQI4oSURIST Uw5tjPzWPakFmtXnj96nQmHtVPi09PyFjeefRtw/1JXIFWz19fnX9P+GXKotxnm45lZ3PM+WW 8a7L1cRXjWa6Whd5h4WeSVYX1Zf57X7EwcqgxLe+q3rHm4cKkpPmXNl3/0v4gZj6zlFJbidqE w0JftglqrfzoH2uqeSnL71Tzv6lmbA1MizZoKbEUZyQaajEXFScCAEq+z7t1AgAA X-Env-Sender: proskurin@sec.in.tum.de X-Msg-Ref: server-14.tower-27.messagelabs.com!1500380772!95261479!1 X-Originating-IP: [131.159.0.8] X-SpamReason: No, hits=0.0 required=7.0 tests=UPPERCASE_25_50 X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2810 invoked from network); 18 Jul 2017 12:26:12 -0000 Received: from mail-out1.informatik.tu-muenchen.de (HELO mail-out1.informatik.tu-muenchen.de) (131.159.0.8) by server-14.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 Jul 2017 12:26:12 -0000 Received: from files.sec.in.tum.de (files.sec.in.tum.de [131.159.50.1]) by services.sec.in.tum.de (Postfix) with ESMTP id 0B4C9108ACA37; Tue, 18 Jul 2017 14:26:01 +0200 (CEST) Received: from thanatos.sec.in.tum.de (thanatos.sec.in.tum.de [131.159.50.57]) by files.sec.in.tum.de (Postfix) with ESMTP id 06BE223CDA; Tue, 18 Jul 2017 14:26:01 +0200 (CEST) From: Sergej Proskurin To: xen-devel@lists.xenproject.org Date: Tue, 18 Jul 2017 14:24:55 +0200 Message-Id: <20170718122507.11873-3-proskurin@sec.in.tum.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170718122507.11873-1-proskurin@sec.in.tum.de> References: <20170718122507.11873-1-proskurin@sec.in.tum.de> Cc: Stefano Stabellini , Wei Liu , George Dunlap , Sergej Proskurin , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH v7 02/14] arm/mem_access: Move PAGE_*_* macros to xen/page-defs.h X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The following commits introduce a software guest page table walk software implementation that supports varying guest page size granularities. This commit moves already existing PAGE_(SHIFT|SIZE|MASK|ALIGN)_(4K|64K) and introduces corresponding defines for 16K page granularity to a common place in xen/page-defs.h as to allow the following commits to use the consolidated defines. Signed-off-by: Sergej Proskurin --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu --- v6: Move in addition to PAGE_SHIFT_* also PAGE_(SIZE|MASK|ALIGN)_(4K|64K) macros and introduce the corresponding macros for 16K. Also, move the macros mentioned above into xen/page-defs.h instead of xen/lib.h. v7: Use the type paddr_t for PAGE_SIZE_GRAN instead of UL as it was used before. Also, use PAGE_SIZE_GRAN to define PAGE_MASK_GRAN and thus avoid these defines to have a differing type. Remove unnecessary parenthesis. --- xen/include/xen/iommu.h | 15 +-------------- xen/include/xen/page-defs.h | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 xen/include/xen/page-defs.h diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 5803e3f95b..08f43c5daf 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -20,6 +20,7 @@ #define _IOMMU_H_ #include +#include #include #include #include @@ -37,20 +38,6 @@ extern bool_t amd_iommu_perdev_intremap; extern unsigned int iommu_dev_iotlb_timeout; -#define IOMMU_PAGE_SIZE(sz) (1UL << PAGE_SHIFT_##sz) -#define IOMMU_PAGE_MASK(sz) (~(u64)0 << PAGE_SHIFT_##sz) -#define IOMMU_PAGE_ALIGN(sz, addr) (((addr) + ~PAGE_MASK_##sz) & PAGE_MASK_##sz) - -#define PAGE_SHIFT_4K (12) -#define PAGE_SIZE_4K IOMMU_PAGE_SIZE(4K) -#define PAGE_MASK_4K IOMMU_PAGE_MASK(4K) -#define PAGE_ALIGN_4K(addr) IOMMU_PAGE_ALIGN(4K, addr) - -#define PAGE_SHIFT_64K (16) -#define PAGE_SIZE_64K IOMMU_PAGE_SIZE(64K) -#define PAGE_MASK_64K IOMMU_PAGE_MASK(64K) -#define PAGE_ALIGN_64K(addr) IOMMU_PAGE_ALIGN(64K, addr) - int iommu_setup(void); int iommu_add_device(struct pci_dev *pdev); diff --git a/xen/include/xen/page-defs.h b/xen/include/xen/page-defs.h new file mode 100644 index 0000000000..15a90779b5 --- /dev/null +++ b/xen/include/xen/page-defs.h @@ -0,0 +1,24 @@ +#ifndef __XEN_PAGE_DEFS_H__ +#define __XEN_PAGE_DEFS_H__ + +/* Helpers for different page granularities. */ +#define PAGE_SIZE_GRAN(gran) ((paddr_t)1 << PAGE_SHIFT_##gran) +#define PAGE_MASK_GRAN(gran) (-PAGE_SIZE_GRAN(gran)) +#define PAGE_ALIGN_GRAN(gran, addr) ((addr + ~PAGE_MASK_##gran) & PAGE_MASK_##gran) + +#define PAGE_SHIFT_4K 12 +#define PAGE_SIZE_4K PAGE_SIZE_GRAN(4K) +#define PAGE_MASK_4K PAGE_MASK_GRAN(4K) +#define PAGE_ALIGN_4K(addr) PAGE_ALIGN_GRAN(4K, addr) + +#define PAGE_SHIFT_16K 14 +#define PAGE_SIZE_16K PAGE_SIZE_GRAN(16K) +#define PAGE_MASK_16K PAGE_MASK_GRAN(16K) +#define PAGE_ALIGN_16K(addr) PAGE_ALIGN_GRAN(16K, addr) + +#define PAGE_SHIFT_64K 16 +#define PAGE_SIZE_64K PAGE_SIZE_GRAN(64K) +#define PAGE_MASK_64K PAGE_MASK_GRAN(64K) +#define PAGE_ALIGN_64K(addr) PAGE_ALIGN_GRAN(64K, addr) + +#endif /* __XEN_PAGE_DEFS_H__ */