From patchwork Tue Jul 25 17:26:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 9862569 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 A8376601A1 for ; Tue, 25 Jul 2017 17:30:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AD4F286F8 for ; Tue, 25 Jul 2017 17:30:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EB52286E0; Tue, 25 Jul 2017 17:30:08 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, 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 09EA1286F7 for ; Tue, 25 Jul 2017 17:30:04 +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 1da3c4-0008So-TK; Tue, 25 Jul 2017 17:27:16 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1da3c2-0008RZ-Uh for xen-devel@lists.xenproject.org; Tue, 25 Jul 2017 17:27:15 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 82/89-01729-27F77795; Tue, 25 Jul 2017 17:27:14 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFIsWRWlGSWpSXmKPExsVyMfS6s25BfXm kwdMpChbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a3bxeZCj7yVjT1rGBsYOzj7mLk5BASmMEo 8WFnZRcjFweLwEsWiT2HGtlAHAmBflaJiX/uMoNUSQjEScz5vZENwq6QeHO1iRmiW0ni9c7NT CANQgKzmSTOfuhnAUmwCRhI7H/3hB3EFgEqurdqMhOIzSxgIdF8fBZQDQeHsECoxIu5YFewCK hK/N+ymxXE5hVwltjXMpMJYpecxM1znWC7OAVcJLZ+2sYCsddZYv2xA8wTGAUWMDKsYlQvTi0 qSy3SNdZLKspMzyjJTczM0TU0MNXLTS0uTkxPzUlMKtZLzs/dxAgMKwYg2MG495/TIUZJDiYl Ud5vuuWRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4DeuAcoJFqempFWmZOcAAh0lLcPAoifBur gVK8xYXJOYWZ6ZDpE4xWnJcubLuCxPHlAPbgeSrCf+/MQmx5OXnpUqJ8/qAzBMAacgozYMbB4 vCS4yyUsK8jEAHCvEUpBblZpagyr9iFOdgVBLmfQ2yliczrwRu6yugg5iADpozoxTkoJJEhJR UA2OZzufopOs7mi9IGxosVr4wa62w2VblNM/gOE1Gd7//d9hvWC7I+TBLdHWHdNcHHr395jvk JaVvXoxR3tL6MnDVYi/p2YofpzrWd2amehd7Vzy9tdLjwxfGoIADVw3uMzwOfKpxZn1HoV317 D3bZnE9XPbB77L7NNHNsd98o6MsD73wvzY331GJpTgj0VCLuag4EQDXtAnkvQIAAA== X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1501003632!68193940!1 X-Originating-IP: [209.85.215.67] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44815 invoked from network); 25 Jul 2017 17:27:12 -0000 Received: from mail-lf0-f67.google.com (HELO mail-lf0-f67.google.com) (209.85.215.67) by server-12.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 25 Jul 2017 17:27:12 -0000 Received: by mail-lf0-f67.google.com with SMTP id t128so5040293lff.3 for ; Tue, 25 Jul 2017 10:27:12 -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=dh69Cla8ZGwVbPKxCuL0VyN2dAsZhx8g1YNik4mEnwE=; b=d/gE2Se3WWn/9DScnZtqjAbj4b26OTIpJ48mqMCRfIBKw0l0ldWExbu/yHuY3AhtlB NjxFnoNu6AXkJWoGNz0+oqFC4Bu1Qzu7g24gd7w/+Xwjb0UI0jCboFNqI7Y3uBcibutE DHBT6ZLwngl8xpKYq7QLrV6VDnGHF0xkT0NkF2kS7P7Q1WFEJiCGpb0cldbg3KyrR31Z SstJi5tQ03I71HFGzxxLiaBRsdr/YD5eIyiBq6UXaEFWzXmZlOtheXox3QYGxWPvDxzS 9zqcpmTq9ywyID2dPUM/hkc6PdsrWuFjEeRUZFKgdZPznh4x/cmtELxUOM6Z0TcGoSaN Mm7w== 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=dh69Cla8ZGwVbPKxCuL0VyN2dAsZhx8g1YNik4mEnwE=; b=oqKw6fBhuN2Fjpsj3rv/Bahqq1E6mWf7nmFxQ69ZPAI2v58O21X5cg4yT414p2QaDK mmq4LkPLrYT1NhVCNWRyBqSI+9LRlOTK7pBFZBmHYsQRRzc9BjHCCl73/TxZBxj0i4wj GP0vekwn9AWQWkL3dUS0vbq28Tv+HdSTOknu8zz9Q73AhifSxuDwt+wR2WtM6sj00qlF 1f4rByGPngkcuFHedR7f51YVGm3y58r1v+Eiw6fIlyG96oIDwoaOFaGqY3vEFOibdoTM Rq+KJvIZIDYocJpqDkBKEeFLAAaJGbt5cmixHVsA9hWeSsOYhH0HsjcXCemJiSPp6v6p D7Qw== X-Gm-Message-State: AIVw112yVlQYoZJvma9BR0xm2nr2ndIxcbuH42YbqYBJbgOxPCdm0t7x zIx6zjnUTMKRri2x X-Received: by 10.25.74.83 with SMTP id x80mr5708481lfa.252.1501003631584; Tue, 25 Jul 2017 10:27:11 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-59.209.223.85.sovam.net.ua. [85.223.209.59]) by smtp.gmail.com with ESMTPSA id v145sm411748lfa.21.2017.07.25.10.27.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 10:27:10 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Tue, 25 Jul 2017 20:26:45 +0300 Message-Id: <1501003615-15274-4-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501003615-15274-1-git-send-email-olekstysh@gmail.com> References: <1501003615-15274-1-git-send-email-olekstysh@gmail.com> Cc: Oleksandr Tyshchenko Subject: [Xen-devel] [PATCH v2 03/13] 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 Changes in v2: - --- 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 1269052..635cc25 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 @@ -353,6 +354,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 */ /*