Message ID | 1400158608-9617-4-git-send-email-julien.grall@linaro.org |
---|---|
State | Superseded, archived |
Headers | show |
>>> On 15.05.14 at 14:56, <julien.grall@linaro.org> wrote: > Also add IOMMU_PAGE_* helper macros to help creating PAGE_* defines. > > Signed-off-by: Julien Grall <julien.grall@linaro.org> Acked-by: Jan Beulich <jbeulich@suse.com> with a small nit: > #define PAGE_SHIFT_4K (12) > -#define PAGE_SIZE_4K (1UL << PAGE_SHIFT_4K) > -#define PAGE_MASK_4K (((u64)-1) << PAGE_SHIFT_4K) > -#define PAGE_ALIGN_4K(addr) (((addr) + PAGE_SIZE_4K - 1) & PAGE_MASK_4K) > +#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)) Pointless parentheses around 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)) Same here. Jan
diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index a431ac6..b93a436 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -35,10 +35,19 @@ extern bool_t iommu_hap_pt_share; extern bool_t iommu_debug; extern bool_t amd_iommu_perdev_intremap; +#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 (1UL << PAGE_SHIFT_4K) -#define PAGE_MASK_4K (((u64)-1) << PAGE_SHIFT_4K) -#define PAGE_ALIGN_4K(addr) (((addr) + PAGE_SIZE_4K - 1) & PAGE_MASK_4K) +#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);
Also add IOMMU_PAGE_* helper macros to help creating PAGE_* defines. Signed-off-by: Julien Grall <julien.grall@linaro.org> Cc: Xiantao Zhang <xiantao.zhang@intel.com> Cc: Jan Beulich <jbeulich@suse.com> --- xen/include/xen/iommu.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)