From patchwork Wed May 10 14:03:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 9719903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D07F46035D for ; Wed, 10 May 2017 14:06:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C247C28607 for ; Wed, 10 May 2017 14:06:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B718828608; Wed, 10 May 2017 14:06:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2E1642860C for ; Wed, 10 May 2017 14:05:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8SDL-00076j-KP; Wed, 10 May 2017 14:03:39 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8SDK-00076U-8g for xen-devel@lists.xenproject.org; Wed, 10 May 2017 14:03:38 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id 93/E9-01999-9BD13195; Wed, 10 May 2017 14:03:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsXiVRvkpLtDVjj S4ORlS4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNeNEp3/BNd6KWX9UGhgbubsYuTiEBKYwShyc s4kRxGEReMki8XDFUnYQR0Kgn1Vi/YN5QBlOICdO4sS6x6xdjBxAdpXEnYtJIGEhASWJ1zs3M 0FMmsUk8fnnZyaQBJuAgcT+d0/YQWwRoKJ7qyaDxZkFyiV6Zi5jA7GFBUIl1szfwApiswioSi y/s4sZxOYVcJZYMGMjK8ReOYmb5zrB4pwCLhI7Xt9hgVjsLPH/43fWCYwCCxgZVjFqFKcWlaU W6Rqa6CUVZaZnlOQmZuboGhqY6uWmFhcnpqfmJCYV6yXn525iBIYVAxDsYDx72vMQoyQHk5Io r+4uoUghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErxXpYUjhQSLUtNTK9Iyc4ABDpOW4OBREuE9K gGU5i0uSMwtzkyHSJ1i1OV4tPLHeyYhlrz8vFQpcV4hGaAiAZCijNI8uBGwaLvEKCslzMsIdJ QQT0FqUW5mCar8K0ZxDkYlYV4FkCk8mXklcJteAR3BBHREIIMAyBEliQgpqQbGJXfflvuELu2 KcVQ5Gfn65+87RjWN0h8z78XPyL98Osp/pf+l4o2cfnI2Pu+Vjx1fnKW/a+4Tlbd638U/2nuF bKnfZS9sHXExhjlvetBF7TdMWSuVb5Tk/Hd5//LfzJQ5GcY3HmhI+dSY2dyc68ofvaBbMGou+ 7HyxD+pybnHreZfslAqXzJDiaU4I9FQi7moOBEAsyMR2bECAAA= X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1494425016!76699134!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63602 invoked from network); 10 May 2017 14:03:36 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-2.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 May 2017 14:03:36 -0000 Received: by mail-wm0-f66.google.com with SMTP id v4so43905wmb.2 for ; Wed, 10 May 2017 07:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LPCW+Fjbezj+9BzX4wo7Z66VF1I2lEz4AYO62z+7Tsw=; b=oBNS/Vy6i2/xtp5CsLWptXhyzkbd+1MFMNKoxo+r3OZAwSUVJncmLvTpBKYVpfn1GV Yt8kedqZXiG5IM8OiDheOPG+qXZ165Tw4IpqKVm6FWmzErVeM7sYnqUmMFFlgl823/+R LbWJfjSwvbZFi36wqzXSxUlY0ufV/ucukBmn0IA6H9T6Rs9/oJxBGFtCsMQJTn/is5n/ aCkHkp1/FHUqsOfKLxipyvXN1GNw/SjGXNtAtWI1r04x9hr6Ew8TPbZLyaR4KXNBNF08 /QZIXEuiMAF+VYhxV7St5/TRrkIG1Ick5xpTK2IVkklhDOygg+EMV/iVm4mA1C/rVvN0 m+Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LPCW+Fjbezj+9BzX4wo7Z66VF1I2lEz4AYO62z+7Tsw=; b=RUNgM2mtRU7euuzwxFhVOA+WWpAOyEE5+Vl/2mI2hLXqCg/8wqO4h7TS9I3Xv/DiLG 1V+kcEMg1t56zlHjyN2z9QsogynW/ufnBRuyBw8pO9qLmAtHDN/OlF0rDSUeXbFNgF36 2iBxKJC39gRnoMxu3+UaCz1j30W7CO/0ZkZbd+NF8HAHhDUgRAogy/O97EwaetP5W4Ay BmPdZBg/VZo0AdEHGLj5p51cQCZC1BIbAlQZCUGMPRsHTtUdgQgBlRxiTmTpaUMRtKpR l+g/vuBffXONkGUPx5pOxsWOJWxAOLNsBQJ/IJrySHc4naMARlQoeBurnElIC356fUrI QseA== X-Gm-Message-State: AODbwcDeC/WVkgcliJhBbC3eGJryJ9gEyzCXDHJfveRwWlu5FvN+FPVi d9ry4JTirS7I7A== X-Received: by 10.28.136.146 with SMTP id k140mr3752467wmd.55.1494425016557; Wed, 10 May 2017 07:03:36 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-54.209.223.85.sovam.net.ua. [85.223.209.54]) by smtp.gmail.com with ESMTPSA id c34sm3378304wrc.7.2017.05.10.07.03.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 May 2017 07:03:35 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Wed, 10 May 2017 17:03:07 +0300 Message-Id: <1494424994-26232-4-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494424994-26232-1-git-send-email-olekstysh@gmail.com> References: <1494424994-26232-1-git-send-email-olekstysh@gmail.com> Cc: wei.liu2@citrix.com, julien.grall@arm.com, sstabellini@kernel.org, ian.jackson@eu.citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH v1 03/10] xen/arm: p2m: Add helper to convert p2m type to IOMMU flags X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Tyshchenko The helper has the same purpose as existing for x86 one. It is used for choosing IOMMU mapping attribute according to the memory type. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Julien Grall --- Changes in v1: - Add Julien's reviewed-by --- xen/include/asm-arm/p2m.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 18c57f9..9082ba0 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -5,6 +5,7 @@ #include #include #include +#include #include /* for vm_event_response_t */ #include #include @@ -357,6 +358,39 @@ static inline gfn_t gfn_next_boundary(gfn_t gfn, unsigned int order) return gfn_add(gfn, 1UL << order); } +/* + * p2m type to IOMMU flags + */ +static inline unsigned int p2m_get_iommu_flags(p2m_type_t p2mt) +{ + unsigned int flags; + + switch( p2mt ) + { + case p2m_ram_rw: + case p2m_iommu_map_rw: + case p2m_map_foreign: + case p2m_grant_map_rw: + case p2m_mmio_direct_dev: + case p2m_mmio_direct_nc: + case p2m_mmio_direct_c: + flags = IOMMUF_readable | IOMMUF_writable; + break; + case p2m_ram_ro: + case p2m_iommu_map_ro: + case p2m_grant_map_ro: + flags = IOMMUF_readable; + break; + default: + flags = 0; + break; + } + + /* TODO Do we need to handle access permissions here? */ + + return flags; +} + #endif /* _XEN_P2M_H */ /*