[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v6 02/14] arm/mem_access: Move PAGE_*_* macros to xen/page-defs.h



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 <proskurin@xxxxxxxxxxxxx>
---
Cc: Jan Beulich <jbeulich@xxxxxxxx>
---
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.
---
 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 <xen/init.h>
+#include <xen/page-defs.h>
 #include <xen/spinlock.h>
 #include <xen/pci.h>
 #include <public/hvm/ioreq.h>
@@ -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..5e2a944db2
--- /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)        (1UL << PAGE_SHIFT_##gran)
+#define PAGE_MASK_GRAN(gran)        (~(0ULL) << PAGE_SHIFT_##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__ */
-- 
2.13.2


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.