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

[Xen-devel] [PATCH RFC 2/2] xen/arm: patches for 32bit page shift operations



Current some 32bit variables make errors when large physical memory accessed. 
(more than 4GB)
For example, left page shifting for the 32bit ‘idx’ or ‘gpfn’ variable cuts the 
highest value after this operation.
To resolve this, following cast can be applied as a intermediate method.
   (paddr_t)idx << PAGE_SHIFT,  (paddr_t)gpfn << PAGE_SHIFT

But 64 bit variables could remove all these issues as follows.


Singed-off-by: ChanJu Park 
Singed-off-by: Min Kang 
---
xen/arch/arm/mm.c         |    4 ++--
xen/arch/arm/p2m.c        |   10 +++++-----
xen/arch/arm/setup.c      |    8 ++++----
xen/include/asm-arm/mm.h  |    4 ++--
xen/include/asm-arm/p2m.h |   10 +++++-----
5 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index bdfb7af..2e9fb7e 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -911,10 +911,10 @@ static int xenmem_add_to_physmap_one(
     struct domain *d,
     uint16_t space,
     domid_t foreign_domid,
-    unsigned long idx,
+    xen_ulong_t idx,
     xen_pfn_t gpfn)
{
-    unsigned long mfn = 0;
+    xen_pfn_t mfn = 0;
     int rc;

     switch ( space )
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 307c6d4..7bc0e84 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -254,8 +254,8 @@ int map_mmio_regions(struct domain *d,
}

int guest_physmap_add_page(struct domain *d,
-                           unsigned long gpfn,
-                           unsigned long mfn,
+                           xen_pfn_t gpfn,
+                           xen_pfn_t mfn,
                            unsigned int page_order)
{
     return create_p2m_entries(d, INSERT, gpfn << PAGE_SHIFT,
@@ -264,8 +264,8 @@ int guest_physmap_add_page(struct domain *d,
}

void guest_physmap_remove_page(struct domain *d,
-                               unsigned long gpfn,
-                               unsigned long mfn, unsigned int page_order)
+                               xen_pfn_t gpfn,
+                               xen_pfn_t mfn, unsigned int page_order)
{
     create_p2m_entries(d, REMOVE, gpfn << PAGE_SHIFT,
                        (gpfn + (1<@@ -339,7 +339,7 @@ int p2m_init(struct 
domain *d)
     return 0;
}

-unsigned long gmfn_to_mfn(struct domain *d, unsigned long gpfn)
+unsigned long gmfn_to_mfn(struct domain *d, xen_pfn_t gpfn)
{
     paddr_t p = p2m_lookup(d, gpfn << PAGE_SHIFT);
     return p >> PAGE_SHIFT;
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 4b31623..b1822c5 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -172,7 +172,7 @@ void __init discard_initial_modules(void)
  * modules and Xen itself) or 1 (all modules but not Xen).
  */
static paddr_t __init consider_modules(paddr_t s, paddr_t e,
-                                       uint32_t size, paddr_t align,
+                                       paddr_t size, paddr_t align,
                                        int first_mod)
{
     const struct dt_module_info *mi = &early_info.modules;
@@ -327,7 +327,7 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t 
dtb_size)

     do
     {
-        e = consider_modules(ram_start, ram_end, xenheap_pages<+        e = 
consider_modules(ram_start, ram_end, ((paddr_t)xenheap_pages) << PAGE_SHIFT,
                              32<<20, 0);
         if ( e )
             break;
@@ -380,8 +380,8 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t 
dtb_size)
         }

         /* Avoid the xenheap */
-        if ( s < ((xenheap_mfn_start+xenheap_pages) << PAGE_SHIFT)
-             && (xenheap_mfn_start << PAGE_SHIFT) < e )
+        if ( s < (((paddr_t)xenheap_mfn_start+xenheap_pages) << PAGE_SHIFT)
+             && (((paddr_t)xenheap_mfn_start) << PAGE_SHIFT) < e )
         {
             e = pfn_to_paddr(xenheap_mfn_start);
             n = pfn_to_paddr(xenheap_mfn_start+xenheap_pages);
diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
index 97c2ee0..874bfe6 100644
--- a/xen/include/asm-arm/mm.h
+++ b/xen/include/asm-arm/mm.h
@@ -131,8 +131,8 @@ extern unsigned long xenheap_virt_end;
#endif

#define is_xen_fixed_mfn(mfn)                                   \
-    ((((mfn) << PAGE_SHIFT) >= virt_to_maddr(&_start)) &&       \
-     (((mfn) << PAGE_SHIFT) <= virt_to_maddr(&_end)))
+    ((((paddr_t)(mfn) << PAGE_SHIFT) >= virt_to_maddr(&_start)) &&       \
+     (((paddr_t)(mfn) << PAGE_SHIFT) <= virt_to_maddr(&_end)))

#define page_get_owner(_p)    (_p)->v.inuse.domain
#define page_set_owner(_p,_d) ((_p)->v.inuse.domain = (_d))
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index a00069b..dd52725 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -48,14 +48,14 @@ int map_mmio_regions(struct domain *d, paddr_t start_gaddr,

/* Untyped version for RAM only, for compatibility */
int guest_physmap_add_page(struct domain *d,
-                           unsigned long gfn,
-                           unsigned long mfn,
+                           xen_pfn_t gpfn,
+                           xen_pfn_t mfn,
                            unsigned int page_order);
void guest_physmap_remove_page(struct domain *d,
-                               unsigned long gpfn,
-                               unsigned long mfn, unsigned int page_order);
+                               xen_pfn_t gpfn,
+                               xen_pfn_t mfn, unsigned int page_order);

-unsigned long gmfn_to_mfn(struct domain *d, unsigned long gpfn);
+unsigned long gmfn_to_mfn(struct domain *d, xen_pfn_t gpfn);

/*
  * Populate-on-demand
-- 
1.7.9.5
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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