From patchwork Thu May 15 12:56:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 30255 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 128D0202E6 for ; Thu, 15 May 2014 12:59:01 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id ar20sf5184161iec.0 for ; Thu, 15 May 2014 05:59:00 -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=yyOVIueZ+gse5PeathZud6Yn1AR61qNb+dynIedmLdQ=; b=dhMY2SRO4jCe8niCMKkfjNDzwKAEQ4xpLHWR5CRitUhGHm27F6lRay8MPXDtgeSVZW DNiDJmsHeHkq6pJTU9JCCEKExVvuolhvj19IorzL4/0upw+B8MwFNdZGz0b4Q0w6FuEF cMd3pDUWJEzQmpnqFzrnNsTzqiyKk8nQX3o6RQQqHKbhRfRTSrryW99gAsucC/LB8gT8 Rnaq15HP09LMNwZ+gna/gt+sp115nQsbwdUg1RZga4iHJuvdKtG6K3PLKHVpJDPK5oIg YnnTwrry9RDa3Rp1Xy1Lo4y6YJu/FFdGmReI1heU7GcWwdGzprXjwhs4e0MSlOcgGpTd otrQ== X-Gm-Message-State: ALoCoQmt0r0xwJKFbwBOJF2yyACofRUR9T054x/5rsPx3NbUZhnZGrR+og9ABwcXyl20EZabSXpC X-Received: by 10.183.1.7 with SMTP id bc7mr4865034obd.47.1400158740554; Thu, 15 May 2014 05:59:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.33.164 with SMTP id j33ls222041qgj.73.gmail; Thu, 15 May 2014 05:59:00 -0700 (PDT) X-Received: by 10.58.132.228 with SMTP id ox4mr186467veb.54.1400158740477; Thu, 15 May 2014 05:59:00 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id aw3si174162vdd.201.2014.05.15.05.59.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 May 2014 05:59:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.176 as permitted sender) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id jz11so1199057veb.7 for ; Thu, 15 May 2014 05:59:00 -0700 (PDT) X-Received: by 10.58.116.175 with SMTP id jx15mr8403280veb.9.1400158740294; Thu, 15 May 2014 05:59:00 -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 ib8csp320211vcb; Thu, 15 May 2014 05:58:59 -0700 (PDT) X-Received: by 10.229.239.4 with SMTP id ku4mr15291613qcb.17.1400158738431; Thu, 15 May 2014 05:58:58 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id d5si2494125qad.132.2014.05.15.05.58.57 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 15 May 2014 05:58:58 -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 1WkvDY-0004xv-R6; Thu, 15 May 2014 12:57:00 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WkvDX-0004xG-L2 for xen-devel@lists.xenproject.org; Thu, 15 May 2014 12:56:59 +0000 Received: from [85.158.139.211:55486] by server-17.bemta-5.messagelabs.com id F5/75-09046-A99B4735; Thu, 15 May 2014 12:56:58 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-11.tower-206.messagelabs.com!1400158618!360651!1 X-Originating-IP: [74.125.83.46] 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 23813 invoked from network); 15 May 2014 12:56:58 -0000 Received: from mail-ee0-f46.google.com (HELO mail-ee0-f46.google.com) (74.125.83.46) by server-11.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 15 May 2014 12:56:58 -0000 Received: by mail-ee0-f46.google.com with SMTP id t10so634724eei.33 for ; Thu, 15 May 2014 05:56:58 -0700 (PDT) X-Received: by 10.14.218.201 with SMTP id k49mr14264390eep.16.1400158618022; Thu, 15 May 2014 05:56:58 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id a4sm12518554eep.12.2014.05.15.05.56.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 May 2014 05:56:57 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 15 May 2014 13:56:47 +0100 Message-Id: <1400158608-9617-4-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1400158608-9617-1-git-send-email-julien.grall@linaro.org> References: <1400158608-9617-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 v6 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.176 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 Cc: Xiantao Zhang Cc: Jan Beulich Acked-by: Jan Beulich --- 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 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);