xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: xen-devel@lists.xen.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [PATCH 07/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_decrease_reservation
Date: Wed, 13 Sep 2017 18:59:45 +0100	[thread overview]
Message-ID: <20170913175953.16942-8-julien.grall@arm.com> (raw)
In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com>

Signed-off-by: Julien Grall <julien.grall@arm.com>

---

Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/arm/p2m.c           |  3 +--
 xen/arch/x86/mm/p2m-pod.c    | 20 +++++++++-----------
 xen/common/memory.c          |  3 ++-
 xen/include/asm-arm/p2m.h    | 13 -------------
 xen/include/asm-x86/p2m.h    |  7 -------
 xen/include/xen/p2m-common.h | 13 +++++++++++++
 6 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index c484469e6c..e321d78818 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -393,8 +393,7 @@ int guest_physmap_mark_populate_on_demand(struct domain *d,
     return -ENOSYS;
 }
 
-int p2m_pod_decrease_reservation(struct domain *d,
-                                 xen_pfn_t gpfn,
+int p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn,
                                  unsigned int order)
 {
     return -ENOSYS;
diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 34f5239b6d..eb74e5c01f 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -511,9 +511,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn);
  * allow decrease_reservation() to handle everything else.
  */
 int
-p2m_pod_decrease_reservation(struct domain *d,
-                             xen_pfn_t gpfn,
-                             unsigned int order)
+p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, unsigned int order)
 {
     int ret = 0;
     unsigned long i, n;
@@ -521,7 +519,7 @@ p2m_pod_decrease_reservation(struct domain *d,
     bool_t steal_for_cache;
     long pod, nonpod, ram;
 
-    gfn_lock(p2m, gpfn, order);
+    gfn_lock(p2m, gfn, order);
     pod_lock(p2m);
 
     /*
@@ -545,7 +543,7 @@ p2m_pod_decrease_reservation(struct domain *d,
         p2m_type_t t;
         unsigned int cur_order;
 
-        p2m->get_entry(p2m, gpfn + i, &t, &a, 0, &cur_order, NULL);
+        p2m->get_entry(p2m, gfn_x(gfn) + i, &t, &a, 0, &cur_order, NULL);
         n = 1UL << min(order, cur_order);
         if ( t == p2m_populate_on_demand )
             pod += n;
@@ -567,7 +565,7 @@ p2m_pod_decrease_reservation(struct domain *d,
          * All PoD: Mark the whole region invalid and tell caller
          * we're done.
          */
-        p2m_set_entry(p2m, gpfn, INVALID_MFN, order, p2m_invalid,
+        p2m_set_entry(p2m, gfn_x(gfn), INVALID_MFN, order, p2m_invalid,
                       p2m->default_access);
         p2m->pod.entry_count -= 1UL << order;
         BUG_ON(p2m->pod.entry_count < 0);
@@ -584,7 +582,7 @@ p2m_pod_decrease_reservation(struct domain *d,
      * - not all of the pages were RAM (now knowing order < SUPERPAGE_ORDER)
      */
     if ( steal_for_cache && order < SUPERPAGE_ORDER && ram == (1UL << order) &&
-         p2m_pod_zero_check_superpage(p2m, gpfn & ~(SUPERPAGE_PAGES - 1)) )
+         p2m_pod_zero_check_superpage(p2m, gfn_x(gfn) & ~(SUPERPAGE_PAGES - 1)) )
     {
         pod = 1UL << order;
         ram = nonpod = 0;
@@ -605,13 +603,13 @@ p2m_pod_decrease_reservation(struct domain *d,
         p2m_access_t a;
         unsigned int cur_order;
 
-        mfn = p2m->get_entry(p2m, gpfn + i, &t, &a, 0, &cur_order, NULL);
+        mfn = p2m->get_entry(p2m, gfn_x(gfn) + i, &t, &a, 0, &cur_order, NULL);
         if ( order < cur_order )
             cur_order = order;
         n = 1UL << cur_order;
         if ( t == p2m_populate_on_demand )
         {
-            p2m_set_entry(p2m, gpfn + i, INVALID_MFN, cur_order,
+            p2m_set_entry(p2m, gfn_x(gfn) + i, INVALID_MFN, cur_order,
                           p2m_invalid, p2m->default_access);
             p2m->pod.entry_count -= n;
             BUG_ON(p2m->pod.entry_count < 0);
@@ -633,7 +631,7 @@ p2m_pod_decrease_reservation(struct domain *d,
 
             page = mfn_to_page(mfn);
 
-            p2m_set_entry(p2m, gpfn + i, INVALID_MFN, cur_order,
+            p2m_set_entry(p2m, gfn_x(gfn) + i, INVALID_MFN, cur_order,
                           p2m_invalid, p2m->default_access);
             p2m_tlb_flush_sync(p2m);
             for ( j = 0; j < n; ++j )
@@ -663,7 +661,7 @@ out_entry_check:
 
 out_unlock:
     pod_unlock(p2m);
-    gfn_unlock(p2m, gpfn, order);
+    gfn_unlock(p2m, gfn, order);
     return ret;
 }
 
diff --git a/xen/common/memory.c b/xen/common/memory.c
index a2abf554e3..ad987e0f29 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -417,7 +417,8 @@ static void decrease_reservation(struct memop_args *a)
 
         /* See if populate-on-demand wants to handle this */
         if ( is_hvm_domain(a->domain)
-             && p2m_pod_decrease_reservation(a->domain, gmfn, a->extent_order) )
+             && p2m_pod_decrease_reservation(a->domain, _gfn(gmfn),
+                                             a->extent_order) )
             continue;
 
         for ( j = 0; j < (1 << a->extent_order); j++ )
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index aa0d60ae3a..3c511feee5 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -266,19 +266,6 @@ static inline int guest_physmap_add_page(struct domain *d,
 
 mfn_t gfn_to_mfn(struct domain *d, gfn_t gfn);
 
-/*
- * Populate-on-demand
- */
-
-/*
- * Call when decreasing memory reservation to handle PoD entries properly.
- * Will return '1' if all entries were handled and nothing more need be done.
- */
-int
-p2m_pod_decrease_reservation(struct domain *d,
-                             xen_pfn_t gpfn,
-                             unsigned int order);
-
 /* Look up a GFN and take a reference count on the backing page. */
 typedef unsigned int p2m_query_t;
 #define P2M_ALLOC    (1u<<0)   /* Populate PoD and paged-out entries */
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 10cdfc09a9..8f3409b400 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -643,13 +643,6 @@ int p2m_pod_empty_cache(struct domain *d);
  * domain matches target */
 int p2m_pod_set_mem_target(struct domain *d, unsigned long target);
 
-/* Call when decreasing memory reservation to handle PoD entries properly.
- * Will return '1' if all entries were handled and nothing more need be done.*/
-int
-p2m_pod_decrease_reservation(struct domain *d,
-                             xen_pfn_t gpfn,
-                             unsigned int order);
-
 /* Scan pod cache when offline/broken page triggered */
 int
 p2m_pod_offline_or_broken_hit(struct page_info *p);
diff --git a/xen/include/xen/p2m-common.h b/xen/include/xen/p2m-common.h
index 2b5696cf33..27f89208f5 100644
--- a/xen/include/xen/p2m-common.h
+++ b/xen/include/xen/p2m-common.h
@@ -20,4 +20,17 @@ int unmap_mmio_regions(struct domain *d,
                        unsigned long nr,
                        mfn_t mfn);
 
+/*
+ * Populate-on-Demand
+ */
+
+/*
+ * Call when decreasing memory reservation to handle PoD entries properly.
+ * Will return '1' if all entries were handled and nothing more need be done.
+ */
+int
+p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn,
+                             unsigned int order);
+
+
 #endif /* _XEN_P2M_COMMON_H */
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-09-13 17:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-13 17:59 [PATCH 00/15] xen/x86: Clean-up the PoD code Julien Grall
2017-09-13 17:59 ` [PATCH 01/15] xen/x86: p2m-pod: Clean-up includes Julien Grall
2017-09-13 17:59 ` [PATCH 02/15] xen/x86: p2m-pod: Remove trailing whitespaces Julien Grall
2017-09-13 17:59 ` [PATCH 03/15] xen/x86: p2m-pod: Fix coding style for comments Julien Grall
2017-09-13 17:59 ` [PATCH 04/15] xen/x86: p2m-pod: Fix coding style Julien Grall
2017-09-13 17:59 ` [PATCH 05/15] xen/x86: p2m-pod: Avoid redundant assignments in p2m_pod_demand_populate Julien Grall
2017-09-13 17:59 ` [PATCH 06/15] xen/x86: p2m-pod: Clean-up use of typesafe MFN Julien Grall
2017-09-13 17:59 ` Julien Grall [this message]
2017-09-13 17:59 ` [PATCH 08/15] xen/x86: p2m: Use typesafe gfn for the P2M callbacks get_entry and set_entry Julien Grall
2017-09-13 18:22   ` Andrew Cooper
2017-09-13 18:27     ` Julien Grall
2017-09-13 19:10       ` Razvan Cojocaru
2017-09-13 19:08   ` Razvan Cojocaru
2017-09-13 19:32     ` Julien Grall
2017-09-20  6:57   ` Tian, Kevin
2017-09-13 17:59 ` [PATCH 09/15] xen/x86: p2m: Use typesafe GFN in p2m_set_entry Julien Grall
2017-09-13 20:16   ` Tamas K Lengyel
2017-09-13 17:59 ` [PATCH 10/15] xen/x86: p2m-pod: Use typesafe GFN in pod_eager_record Julien Grall
2017-09-13 17:59 ` [PATCH 11/15] xen/x86: p2m-pod: Clean-up p2m_pod_zero_check Julien Grall
2017-09-13 17:59 ` [PATCH 12/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_zero_check Julien Grall
2017-09-13 17:59 ` [PATCH 13/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_demand_populate Julien Grall
2017-09-13 17:59 ` [PATCH 14/15] xen/x86: p2m-pod: Use typesafe gfn for the fields reclaim_single and max_guest Julien Grall
2017-09-13 17:59 ` [PATCH 15/15] xen/x86: p2m-pod: Rework prototype of p2m_pod_demand_populate Julien Grall
2017-09-13 18:30 ` [PATCH 00/15] xen/x86: Clean-up the PoD code Andrew Cooper

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=20170913175953.16942-8-julien.grall@arm.com \
    --to=julien.grall@arm.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xen.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).