From patchwork Thu May 15 14:16:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 30262 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D053620446 for ; Thu, 15 May 2014 14:18:30 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f73sf12912080yha.3 for ; Thu, 15 May 2014 07:18:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=1wd2tczxTD+SscmG4AgZO/A4qJ7K7OhYzaVSA4UJaWY=; b=B8ftWluioMY25WrSXb8zxqAxZb0mQqDKYOiW0L6UYiDeoTJN0rXTE5AdricY0kNE4B tCy0h/vGdTc0mdh8xqtcz2MHMQWho+z8aivmfOjbVTDteMggq9t37L5fyqVXZ5ovNM6X CTWluza2zbCI5EHG6yblZiz5NXZB3zured4Pi05XvA7MwdYpg5HOsEuGNYnILxG8xkTA Zbk8cD3qbhnQpcNSc1WymGMhxlGib//FMzIqtVq0jWCz0EYA7pAAPxuiZAtfNENJe+/c 7Qg24J1sDH6HjDmeknG5TcaARubP6mPPXVDW9tADidWvGESzD+mz9EchJpmDiwZUeE5l h2lw== X-Gm-Message-State: ALoCoQlTqPWoewlx/KvRrRRDyj+jArXKPD6CRY+dTeQwtkmnkpyJ3hiLyza6ItuR4sAsHgVOAfdD X-Received: by 10.58.245.132 with SMTP id xo4mr4861375vec.11.1400163510645; Thu, 15 May 2014 07:18:30 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.26.183 with SMTP id 52ls202135qgv.15.gmail; Thu, 15 May 2014 07:18:30 -0700 (PDT) X-Received: by 10.58.54.12 with SMTP id f12mr375649vep.75.1400163510563; Thu, 15 May 2014 07:18:30 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id l2si969064vcf.43.2014.05.15.07.18.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 May 2014 07:18:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jw12so1349509veb.6 for ; Thu, 15 May 2014 07:18:30 -0700 (PDT) X-Received: by 10.220.7.131 with SMTP id d3mr506174vcd.45.1400163510466; Thu, 15 May 2014 07:18:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp326365vcb; Thu, 15 May 2014 07:18:30 -0700 (PDT) X-Received: by 10.58.47.36 with SMTP id a4mr501552ven.63.1400163509907; Thu, 15 May 2014 07:18:29 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id d20si962434veu.151.2014.05.15.07.18.29 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 15 May 2014 07:18:29 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WkwSb-0002hh-AZ; Thu, 15 May 2014 14:16:37 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WkwSZ-0002gh-SM for xen-devel@lists.xenproject.org; Thu, 15 May 2014 14:16:36 +0000 Received: from [85.158.137.68:5140] by server-1.bemta-3.messagelabs.com id A8/91-11134-34CC4735; Thu, 15 May 2014 14:16:35 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-9.tower-31.messagelabs.com!1400163393!405977!1 X-Originating-IP: [74.125.83.51] X-SpamReason: No, hits=0.0 required=7.0 tests=UPPERCASE_25_50 X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29001 invoked from network); 15 May 2014 14:16:34 -0000 Received: from mail-ee0-f51.google.com (HELO mail-ee0-f51.google.com) (74.125.83.51) by server-9.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 15 May 2014 14:16:34 -0000 Received: by mail-ee0-f51.google.com with SMTP id e51so718315eek.10 for ; Thu, 15 May 2014 07:16:33 -0700 (PDT) X-Received: by 10.14.207.6 with SMTP id m6mr3945265eeo.79.1400163393717; Thu, 15 May 2014 07:16:33 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id x45sm12956780eee.37.2014.05.15.07.16.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 May 2014 07:16:32 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 15 May 2014 15:16:24 +0100 Message-Id: <1400163385-19863-4-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1400163385-19863-1-git-send-email-julien.grall@linaro.org> References: <1400163385-19863-1-git-send-email-julien.grall@linaro.org> Cc: ian.campbell@citrix.com, Julien Grall , tim@xen.org, stefano.stabellini@citrix.com, Jan Beulich , Xiantao Zhang Subject: [Xen-devel] [PATCH v7 3/4] xen: iommu: Define PAGE_{SHIFT, SIZE, ALIGN, MASK)_64K X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Also add IOMMU_PAGE_* helper macros to help creating PAGE_* defines. Signed-off-by: Julien Grall Acked-by: Jan Beulich Cc: Xiantao Zhang --- Changes in v7: - Drop pointless parentheses Changes in v6: - Patch added --- xen/include/xen/iommu.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 4c633bf..2229716 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);