From patchwork Tue Jul 25 17:26:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 9862561 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 1BDBD601A1 for ; Tue, 25 Jul 2017 17:30:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FD0227FB2 for ; Tue, 25 Jul 2017 17:30:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02E5A286EB; Tue, 25 Jul 2017 17:30:06 +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 099B827FB2 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 1da3c5-0008T1-3z; Tue, 25 Jul 2017 17:27:17 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1da3c3-0008S2-A6 for xen-devel@lists.xenproject.org; Tue, 25 Jul 2017 17:27:15 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 22/E4-03582-27F77795; Tue, 25 Jul 2017 17:27:14 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsVyMfS6s25RfXm kwbNrLBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aB149ZCg7zVJz79YCtgfEVZxcjF4eQwHRG iYlz7rOCOCwCL1kkVp7awgziSAj0s0qcPXyLrYuRE8iJk7jQs5u9i5EDyC6TWP41CCQsJKAk8 XrnZiaISbOZJNYvmM0OkmATMJDY/+4JmC0CVHRv1WQmEJtZwEKi+fgsFhBbWCBLYsrK7WA1LA KqEh3/boLZvALOEutmX2aC2CsncfNcJzOIzSngIrH10zYWiMXOEuuPHWCewCiwgJFhFaNGcWp RWWqRrrGhXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZGYGgxAMEOxqZFgYcYJTmY lER5v+mWRwrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4DWsA8oJFqWmp1akZeYAgxwmLcHBoyTCe wckzVtckJhbnJkOkTrFaMlx5cq6L0wcUw5sB5KvJvz/xiTEkpeflyolzvuxFqhBAKQhozQPbh wsEi8xykoJ8zICHSjEU5BalJtZgir/ilGcg1FJmFcdZC1PZl4J3NZXQAcxAR00Z0YpyEEliQg pqQbGUF37xvdGZfPuSzYYVh07l+Z4htPhwO2AhtKjSxymJc9PLme9w+8RLbauZcHxTJPQshiv +dIfb3qmmt8R7f43P2SBxIdfa8yzTJOm382dfElQw9Jnf3B78qvCCXyKt7JW9Encevro++y/v z50/7ZljH+yq0jlTzhPq//visevDKMn/HgofWSnEktxRqKhFnNRcSIAKSXWLL8CAAA= X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-8.tower-21.messagelabs.com!1501003633!74784784!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 63663 invoked from network); 25 Jul 2017 17:27:14 -0000 Received: from mail-lf0-f67.google.com (HELO mail-lf0-f67.google.com) (209.85.215.67) by server-8.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 25 Jul 2017 17:27:14 -0000 Received: by mail-lf0-f67.google.com with SMTP id x16so5140259lfb.4 for ; Tue, 25 Jul 2017 10:27:13 -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=7wmGecddEh2TMzP6hv1rRJ4QlDNcMYFfwDFJzsPaJqs=; b=Url6u3Y5k0ukDsSvHROmH9DpuSyYIssTk2tZc+adbwqxFmC3GDREpvqYbjEAn6y3jU Bb5mJ1pOxbKQmchpPVgTduBjLIT5Kv2XoeXXcJCyvc3tZ+ds1qZ87dz8WOEa1dr+JEqC B8xGlkogGH3k4dnfryCY7X0bH2i0Ex+v0Iw70dmwhrc6LIv1GS6jNwVDFMP6Jg9ddmAg bXFqfhTJ47QcbfRKgrAUzBfrCL1klUG5EwX2+Ct4L/A67qMdBod5Pf5oj9H63s5q/TGe BZjt6yOp8h+xzRGBhn7AWIGpJZNZjDG9mZ5xMmLJdeTmqIo5uOs2AitrFDL94OWlgT/5 F+4A== 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=7wmGecddEh2TMzP6hv1rRJ4QlDNcMYFfwDFJzsPaJqs=; b=DAhKQGO1sRO1rYMdowO3Ln7qxVV9W1yb6qOcJAh9SGIYqzK0uqRmcPXi7pI6uK1UTp bQ7Eq82frsQiMdAVO6PnJwbjk99/05504N7LSdGzWwJudG7i7neMidi5z2PvI5CpJBzK DCpklrFcybXFXoXcOxGVfljCL7ua7OJBewXToQMTtSWnClATVbJFST927Pd2u9XwAwCJ LkCKzFg0YA1ZnTFHvTcFviImkOorOGg3q5DZhZdW1TVyL5piAra+neyYohH1vTJBRRNQ Dc3NNPWOUbhFNiAQItL7vCyOIfMm7wbtyx4jY5aw9qZeOPcwWky0YWziUWtu/af1/0Y+ J4Eg== X-Gm-Message-State: AIVw113g2EFeWyxMzNbLR8+rD5dXt3LsbtnEWl3bSpAbauox1PS6V/Hs 7JLh5Z58wHmDVVA0 X-Received: by 10.25.163.9 with SMTP id m9mr6939288lfe.77.1501003632862; Tue, 25 Jul 2017 10:27:12 -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.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 10:27:12 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Tue, 25 Jul 2017 20:26:46 +0300 Message-Id: <1501003615-15274-5-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 04/13] xen/arm: p2m: Update IOMMU mapping whenever possible if page table is not shared 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 Update IOMMU mapping if the IOMMU doesn't share page table with the CPU. The best place to do so on ARM is __p2m_set_entry(). Use mfn as an indicator of the required action. If mfn is valid call iommu_map_pages(), otherwise - iommu_unmap_pages(). Signed-off-by: Oleksandr Tyshchenko Acked-by: Julien Grall --- Changes in v1: - Update IOMMU mapping in __p2m_set_entry() instead of p2m_set_entry(). - Pass order argument to IOMMU APIs instead of page_count. Changes in v2: - Add Julien's acked-by --- xen/arch/arm/p2m.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index fc2a106..729ed94 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -984,7 +984,15 @@ static int __p2m_set_entry(struct p2m_domain *p2m, p2m_free_entry(p2m, orig_pte, level); if ( need_iommu(p2m->domain) && (p2m_valid(orig_pte) || p2m_valid(*entry)) ) - rc = iommu_iotlb_flush(p2m->domain, gfn_x(sgfn), 1UL << page_order); + { + if ( iommu_use_hap_pt(p2m->domain) ) + rc = iommu_iotlb_flush(p2m->domain, gfn_x(sgfn), 1UL << page_order); + else if ( !mfn_eq(smfn, INVALID_MFN) ) + rc = iommu_map_pages(p2m->domain, gfn_x(sgfn), mfn_x(smfn), + page_order, p2m_get_iommu_flags(t)); + else + rc = iommu_unmap_pages(p2m->domain, gfn_x(sgfn), page_order); + } else rc = 0;