From patchwork Mon May 19 16:23:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 30390 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1D5E4203AB for ; Mon, 19 May 2014 16:25:49 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id c1sf12179481igq.10 for ; Mon, 19 May 2014 09:25:48 -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=Te7oVJhYHOa3Wz/6FTLJiVfJQm05m1us1Z5x6P8wqiw=; b=MyZ5Il6+4+1lKf8ytUtmXxNxOMzxUREg4Z07dPZsr4W9ImvnqJPq1MNuymrtUtqkYD ULGRNKMkcZhM5IoUX6QcCDl/QjCnCcmL+uir+sv4GIXJmnc5vA2xVSTiLKaMIqPLAbql Oczc4PNUOXyPnK6T47+PfL5MGLJU+4vU+fu+iC2/wdbMX56VDXqtVu0XDNeKfvMFa0FK WhKsti5A3djvUzpj/5Vcb0LN/kYKvPa1NB83NLdnb0h8nGRKX3BfhjMKT8kMZXZavAuN 8lrTi7s/czvrzDWkS4oAoRT9OGg/0z3lBYZGfLjixcjnLB1s7CaTfpIKPTCqK9s7Jiip Xjpw== X-Gm-Message-State: ALoCoQmcsmvZK9VtA9hRU0LgvPsiDezKZrhp7USfGcwzEtL6zGYn9bg+0PE+mclklQD/s8+oL8Rt X-Received: by 10.182.176.8 with SMTP id ce8mr9778449obc.7.1400516748632; Mon, 19 May 2014 09:25:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.87 with SMTP id v81ls1841907qge.0.gmail; Mon, 19 May 2014 09:25:48 -0700 (PDT) X-Received: by 10.52.139.6 with SMTP id qu6mr1048646vdb.67.1400516748479; Mon, 19 May 2014 09:25:48 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id sq9si4052985vdc.107.2014.05.19.09.25.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 May 2014 09:25:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.173 as permitted sender) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id pa12so6709039veb.18 for ; Mon, 19 May 2014 09:25:48 -0700 (PDT) X-Received: by 10.52.181.132 with SMTP id dw4mr949026vdc.86.1400516748403; Mon, 19 May 2014 09:25:48 -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 ib8csp247555vcb; Mon, 19 May 2014 09:25:47 -0700 (PDT) X-Received: by 10.224.60.71 with SMTP id o7mr49629971qah.38.1400516746436; Mon, 19 May 2014 09:25:46 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id di5si8939200qcb.20.2014.05.19.09.25.45 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 19 May 2014 09:25:46 -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 1WmQMG-0000nl-51; Mon, 19 May 2014 16:24:12 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WmQME-0000mw-RG for xen-devel@lists.xenproject.org; Mon, 19 May 2014 16:24:11 +0000 Received: from [85.158.143.35:16549] by server-3.bemta-4.messagelabs.com id CC/4F-13602-A203A735; Mon, 19 May 2014 16:24:10 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-12.tower-21.messagelabs.com!1400516647!5880466!1 X-Originating-IP: [74.125.83.50] 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 22776 invoked from network); 19 May 2014 16:24:08 -0000 Received: from mail-ee0-f50.google.com (HELO mail-ee0-f50.google.com) (74.125.83.50) by server-12.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 19 May 2014 16:24:08 -0000 Received: by mail-ee0-f50.google.com with SMTP id e51so3775838eek.23 for ; Mon, 19 May 2014 09:24:07 -0700 (PDT) X-Received: by 10.14.173.194 with SMTP id v42mr5695409eel.84.1400516647814; Mon, 19 May 2014 09:24:07 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id p9sm42954653eeg.32.2014.05.19.09.24.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 May 2014 09:24:07 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 19 May 2014 17:23:58 +0100 Message-Id: <1400516640-7175-3-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1400516640-7175-1-git-send-email-julien.grall@linaro.org> References: <1400516640-7175-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com, Jan Beulich Subject: [Xen-devel] [PATCH v8 2/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.173 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 --- 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 2ec7834..8eb764a 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);