xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: xen-devel@lists.xenproject.org
Cc: stefano.stabellini@citrix.com,
	Julien Grall <julien.grall@linaro.org>,
	tim@xen.org, ian.campbell@citrix.com
Subject: [PATCH v5 01/14] xen/arm: Introduce flush_tlb_domain
Date: Tue, 13 May 2014 16:50:17 +0100	[thread overview]
Message-ID: <1399996230-18201-2-git-send-email-julien.grall@linaro.org> (raw)
In-Reply-To: <1399996230-18201-1-git-send-email-julien.grall@linaro.org>

The pattern p2m_load_VTTBR(d) -> flush_tlb -> p2m_load_VTTBR(current->domain)
is used in few places.

Replace this usage by flush_tlb_domain which will take care of this pattern.
This will help to the lisibility of apply_p2m_changes which begin to be big.

Signed-off-by: Julien Grall <julien.grall@linaro.org>

---
    Changes in v5:
        - Patch added
---
 xen/arch/arm/p2m.c             |   35 +++++++++++++++++------------------
 xen/include/asm-arm/flushtlb.h |    3 +++
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 603c097..61450cf 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -72,6 +72,21 @@ void p2m_restore_state(struct vcpu *n)
     isb();
 }
 
+void flush_tlb_domain(struct domain *d)
+{
+    /* Update the VTTBR if necessary with the domain d. In this case,
+     * it's only necessary to flush TLBs on every CPUs with the current VMID
+     * (our domain).
+     */
+    if ( d != current->domain )
+        p2m_load_VTTBR(d);
+
+    flush_tlb();
+
+    if ( d != current->domain )
+        p2m_load_VTTBR(current->domain);
+}
+
 static int p2m_first_level_index(paddr_t addr)
 {
     /*
@@ -450,19 +465,7 @@ static int apply_p2m_changes(struct domain *d,
     }
 
     if ( flush )
-    {
-        /* Update the VTTBR if necessary with the domain where mappings
-         * are created. In this case it's only necessary to flush TLBs
-         * on every CPUs with the current VMID (our domain).
-         */
-        if ( d != current->domain )
-            p2m_load_VTTBR(d);
-
-        flush_tlb();
-
-        if ( d != current->domain )
-            p2m_load_VTTBR(current->domain);
-    }
+        flush_tlb_domain(d);
 
     if ( op == ALLOCATE || op == INSERT )
     {
@@ -550,14 +553,10 @@ int p2m_alloc_table(struct domain *d)
     d->arch.vttbr = page_to_maddr(p2m->first_level)
         | ((uint64_t)p2m->vmid&0xff)<<48;
 
-    p2m_load_VTTBR(d);
-
     /* Make sure that all TLBs corresponding to the new VMID are flushed
      * before using it
      */
-    flush_tlb();
-
-    p2m_load_VTTBR(current->domain);
+    flush_tlb_domain(d);
 
     spin_unlock(&p2m->lock);
 
diff --git a/xen/include/asm-arm/flushtlb.h b/xen/include/asm-arm/flushtlb.h
index 329fbb4..5722c67 100644
--- a/xen/include/asm-arm/flushtlb.h
+++ b/xen/include/asm-arm/flushtlb.h
@@ -25,6 +25,9 @@ do {                                                                    \
 /* Flush specified CPUs' TLBs */
 void flush_tlb_mask(const cpumask_t *mask);
 
+/* Flush CPU's TLBs for the speficied domain */
+void flush_tlb_domain(struct domain *d);
+
 #endif /* __ASM_ARM_FLUSHTLB_H__ */
 /*
  * Local variables:
-- 
1.7.10.4

  reply	other threads:[~2014-05-13 15:50 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 15:50 [PATCH v5 00/14] IOMMU support for ARM Julien Grall
2014-05-13 15:50 ` Julien Grall [this message]
2014-05-14 13:28   ` [PATCH v5 01/14] xen/arm: Introduce flush_tlb_domain Ian Campbell
2014-05-14 13:29     ` Julien Grall
2014-05-13 15:50 ` [PATCH v5 02/14] xen/passthrough: amd: Remove domain_id from hvm_iommu Julien Grall
2014-05-13 15:50 ` [PATCH v5 03/14] xen/passthrough: amd: rename iommu_has_feature into amd_iommu_has_feature Julien Grall
2014-05-13 15:50 ` [PATCH v5 04/14] xen/passthrough: vtd: iommu_set_hwdom_mapping is VTD specific Julien Grall
2014-05-13 15:50 ` [PATCH v5 05/14] xen/passthrough: rework hwdom_pvh_reqs to use it also on ARM Julien Grall
2014-05-13 15:50 ` [PATCH v5 06/14] xen/passthrough: iommu: Split generic IOMMU code Julien Grall
2014-05-13 15:50 ` [PATCH v5 07/14] xen/passthrough: iommu: Introduce arch specific code Julien Grall
2014-05-13 15:50 ` [PATCH v5 08/14] xen/passthrough: iommu: Basic support of device tree assignment Julien Grall
2014-05-13 15:50 ` [PATCH v5 09/14] xen/passthrough: Introduce IOMMU ARM architecture Julien Grall
2014-05-13 15:50 ` [PATCH v5 10/14] MAINTAINERS: Add drivers/passthrough/arm Julien Grall
2014-05-13 15:50 ` [PATCH v5 11/14] xen/arm: Don't give IOMMU devices to dom0 when iommu is disabled Julien Grall
2014-05-13 15:50 ` [PATCH v5 12/14] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk Julien Grall
2014-05-14  7:18   ` Jan Beulich
2014-05-14  9:09     ` Julien Grall
2014-05-14  9:25       ` Jan Beulich
2014-05-14 12:45         ` Julien Grall
2014-05-14 13:08           ` Jan Beulich
2014-05-14 13:11             ` Julien Grall
2014-05-14 13:15               ` Jan Beulich
2014-05-14 13:56                 ` Julien Grall
2014-05-13 15:50 ` [PATCH v5 13/14] xen/arm: grant: Add another entry to map MFN 1:1 in dom0 p2m Julien Grall
2014-05-13 15:50 ` [PATCH v5 14/14] drivers/passthrough: arm: Add support for SMMU drivers Julien Grall
2014-05-14  7:29   ` Jan Beulich
2014-05-14 12:47     ` Julien Grall
2014-05-14 14:05 ` [PATCH v5 00/14] IOMMU support for ARM Ian Campbell
2014-05-14 14:13   ` Julien Grall
2014-05-14 14:35   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399996230-18201-2-git-send-email-julien.grall@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=ian.campbell@citrix.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).