From patchwork Wed May 10 14:03:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 9719899 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 A6ED8603F9 for ; Wed, 10 May 2017 14:05:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98E2828602 for ; Wed, 10 May 2017 14:05:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DB1328609; Wed, 10 May 2017 14:05:59 +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 CD13328608 for ; Wed, 10 May 2017 14:05:58 +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 1d8SDM-00077V-Ue; Wed, 10 May 2017 14:03:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8SDL-00076c-8x for xen-devel@lists.xenproject.org; Wed, 10 May 2017 14:03:39 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id A9/76-03613-ABD13195; Wed, 10 May 2017 14:03:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsXiVRvkortLVjj S4PsBTovvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP5+evMBT08FRdP3mFqYDzC2cXIxSEkMIVR 4vPqI0xdjJwcLAIvWSSezckDSUgI9LNKHFi/CSwhIRAncWRzJxuEXS2x+sNTsLiQgJLE652bo exZTBKHz/uC2GwCBhL73z1hB7FFgGrurZoMVsMsUC7RM3MZ2BxhgSyJfS83M0MsVpX4d2YWmM 0r4Cwx/eNSFohdchI3z3WCxTkFXCR2vL7DArHLWeL/x++sExgFFjAyrGLUKE4tKkst0jUy0Es qykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECAwsBiDYwfhrWcAhRkkOJiVRXt1dQpFC fEn5KZUZicUZ8UWlOanFhxhlODiUJHi9ZIQjhQSLUtNTK9Iyc4AhDpOW4OBREuE9KgGU5i0uS MwtzkyHSJ1i1OV4tPLHeyYhlrz8vFQpcV4hkBkCIEUZpXlwI2DxdolRVkqYlxHoKCGegtSi3M wSVPlXjOIcjErCvBdBpvBk5pXAbXoFdAQT0BGBDAIgR5QkIqSkGhhnvtjsk9rz4+fKRu/fp3g u7Sg8Pcvp+XSD3UsFYjxNOzutJ29Il7lqfEH6ut6J124qvBv9/rGZKOo+OD1NMTCTZaLLJZGC 7Qt23eyvmxR3uzy0n5/xA8vS2GP/Hu6pnuIm+jihNF/mw3S9xWLH3nDcfOXbqrDB/bHlG/sJJ 6aKMRTWxWa+iupWYinOSDTUYi4qTgQAV16x97ICAAA= X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1494425018!67698007!1 X-Originating-IP: [74.125.82.68] 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 58032 invoked from network); 10 May 2017 14:03:38 -0000 Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by server-7.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 May 2017 14:03:38 -0000 Received: by mail-wm0-f68.google.com with SMTP id v4so44079wmb.2 for ; Wed, 10 May 2017 07:03:38 -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=gtIC3duitfOPFvGkXHdAdiRgqCn20v5fj8gMOFEUslw=; b=HU2XkyKEoncyyaefHBLCGhrBNxU+iAh07uSJhRS2NmtCmxVZ2tmUlqsyTgIoW0X2Y/ 94ZEDVTgOUol7ezFxGvCeqSQ1TM61kTeXlLtumYqj5zWFFlsz+fPiRoIyt8QazyreGvR xWl1SEHYivFM1TwFRsXYrHvKvj+mOTXYpzrxa4aqOdHtr/djXnhmvLoygds5hgpsSso1 3g3VGBMOzzcPa4hY+2/rp6MV2EQIpMZ+KLnPVR3uZwnXJvhlN8JmhL2Kw128k64eqNcQ jb2HG3qQA5SiTxJGG7LmZf2kpkCMiDMAzZOrANhi+fgoKNqboaS/evyG4YOSbPLKENS5 KspA== 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=gtIC3duitfOPFvGkXHdAdiRgqCn20v5fj8gMOFEUslw=; b=EyzxGfWXG9KaN8UHliuNyK1ohkfCZAtTO9HrU8CnS2OBNe+RJEcNannvR2YUnGBtGC Nr9O0HsmFohvsecBYJiPFGSAOhcfM4XFGhaldhrR7mZEyv1L5H6ZlRsLolzllbjpTwhS 9CmoIqUTwxmPRPIZW3pkhq+jojk9RH12h3Pyq9jkCPE2wmNj2kGTb5h2X/ZaFeblUQDs 1zinlQRHdouPBh5iIVHFohb3mo3iBdrs0lYl3is66dkov9eEi7xlmJcRom1GEKt4S5VE u9TI0MWk+kBhXlhJ6vqzRcdBzvA8xFXgq15IDCiTxxltun/i50culj4GTbpjU094z3iU TwZg== X-Gm-Message-State: AODbwcBhCy4Db39eu4xnRqxwFar9R8n0zcUOmaB6TxOP4iJXre3h/KFI Ho1HPe706e/O5g== X-Received: by 10.28.197.137 with SMTP id v131mr3685469wmf.101.1494425017797; Wed, 10 May 2017 07:03:37 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 May 2017 07:03:37 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Wed, 10 May 2017 17:03:08 +0300 Message-Id: <1494424994-26232-5-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 04/10] 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 CC: Julien Grall 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. --- 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 34d5776..9ca491b 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;