[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v7 13/14] xen/arm: p2m: Use typesafe gfn for {max, lowest}_mapped_gfn



Signed-off-by: Julien Grall <julien.grall@xxxxxxx>
Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>

---
    Changes in v6:
        - Add Stefano's acked-by

    Changes in v4:
        - Patch added
---
 xen/arch/arm/mm.c         |  2 +-
 xen/arch/arm/p2m.c        | 18 +++++++++---------
 xen/include/asm-arm/p2m.h |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index b5fc034..4e256c2 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -1004,7 +1004,7 @@ int page_is_ram_type(unsigned long mfn, unsigned long 
mem_type)
 
 unsigned long domain_get_maximum_gpfn(struct domain *d)
 {
-    return d->arch.p2m.max_mapped_gfn;
+    return gfn_x(d->arch.p2m.max_mapped_gfn);
 }
 
 void share_xen_page_with_guest(struct page_info *page,
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index dd890c2..de2ab05 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -976,7 +976,7 @@ static int apply_p2m_changes(struct domain *d,
                  * This is set in preempt_count_limit.
                  *
                  */
-                p2m->lowest_mapped_gfn = addr >> PAGE_SHIFT;
+                p2m->lowest_mapped_gfn = _gfn(addr >> PAGE_SHIFT);
                 rc = -ERESTART;
                 goto out;
 
@@ -1117,8 +1117,8 @@ static int apply_p2m_changes(struct domain *d,
 
     if ( op == INSERT )
     {
-        p2m->max_mapped_gfn = max(p2m->max_mapped_gfn, egfn);
-        p2m->lowest_mapped_gfn = min(p2m->lowest_mapped_gfn, sgfn);
+        p2m->max_mapped_gfn = gfn_max(p2m->max_mapped_gfn, _gfn(egfn));
+        p2m->lowest_mapped_gfn = gfn_min(p2m->lowest_mapped_gfn, _gfn(sgfn));
     }
 
     rc = 0;
@@ -1383,8 +1383,8 @@ int p2m_init(struct domain *d)
 
     p2m->root = NULL;
 
-    p2m->max_mapped_gfn = 0;
-    p2m->lowest_mapped_gfn = ULONG_MAX;
+    p2m->max_mapped_gfn = _gfn(0);
+    p2m->lowest_mapped_gfn = _gfn(ULONG_MAX);
 
     p2m->default_access = p2m_access_rwx;
     p2m->mem_access_enabled = false;
@@ -1401,8 +1401,8 @@ int relinquish_p2m_mapping(struct domain *d)
     struct p2m_domain *p2m = &d->arch.p2m;
 
     return apply_p2m_changes(d, RELINQUISH,
-                              pfn_to_paddr(p2m->lowest_mapped_gfn),
-                              pfn_to_paddr(p2m->max_mapped_gfn),
+                              pfn_to_paddr(gfn_x(p2m->lowest_mapped_gfn)),
+                              pfn_to_paddr(gfn_x(p2m->max_mapped_gfn)),
                               pfn_to_paddr(mfn_x(INVALID_MFN)),
                               MATTR_MEM, 0, p2m_invalid,
                               d->arch.p2m.default_access);
@@ -1413,8 +1413,8 @@ int p2m_cache_flush(struct domain *d, gfn_t start, 
unsigned long nr)
     struct p2m_domain *p2m = &d->arch.p2m;
     gfn_t end = gfn_add(start, nr);
 
-    start = gfn_max(start, _gfn(p2m->lowest_mapped_gfn));
-    end = gfn_min(end, _gfn(p2m->max_mapped_gfn));
+    start = gfn_max(start, p2m->lowest_mapped_gfn);
+    end = gfn_min(end, p2m->max_mapped_gfn);
 
     return apply_p2m_changes(d, CACHEFLUSH,
                              pfn_to_paddr(gfn_x(start)),
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 6e258b9..34096bc 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -34,13 +34,13 @@ struct p2m_domain {
     /* Highest guest frame that's ever been mapped in the p2m
      * Only takes into account ram and foreign mapping
      */
-    unsigned long max_mapped_gfn;
+    gfn_t max_mapped_gfn;
 
     /* Lowest mapped gfn in the p2m. When releasing mapped gfn's in a
      * preemptible manner this is update to track recall where to
      * resume the search. Apart from during teardown this can only
      * decrease. */
-    unsigned long lowest_mapped_gfn;
+    gfn_t lowest_mapped_gfn;
 
     /* Gather some statistics for information purposes only */
     struct {
-- 
1.9.1


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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.