xen/arm: patches for 32bit page shift operations
RFC PATCH 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(-)
xen/arch/arm/mm.c +1 -1
@@ -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 )
xen/arch/arm/p2m.c +0 -0
@@ -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;xen/arch/arm/setup.c +0 -0
@@ -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);xen/include/asm-arm/mm.h +0 -0
@@ -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))
xen/include/asm-arm/p2m.h +0 -0
@@ -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
Signature · 5 lines
1.7.9.5 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 4 lines · ChanJu Park
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
I think we want to use the pfn_to_paddr macro for all of these rather than open coding the cast + shift and/or changing the types.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel