* [PATCH RFC 2/2] xen/arm: patches for 32bit page shift operations
@ 2013-09-17 15:30 ChanJu Park
2013-09-17 15:44 ` Ian Campbell
0 siblings, 1 reply; 3+ messages in thread
From: ChanJu Park @ 2013-09-17 15:30 UTC (permalink / raw)
To: xen-devel@lists.xen.org
Cc: julien.grall@linaro.org, ian.campbell@citrix.com,
stefano.stabellini@eu.citrix.com
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@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH RFC 2/2] xen/arm: patches for 32bit page shift operations
@ 2013-09-17 15:30 ChanJu Park
0 siblings, 0 replies; 3+ messages in thread
From: ChanJu Park @ 2013-09-17 15:30 UTC (permalink / raw)
To: xen-devel@lists.xen.org; +Cc: julien.grall, ian.campbell, stefano.stabellini
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 cloud 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@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RFC 2/2] xen/arm: patches for 32bit page shift operations
2013-09-17 15:30 [PATCH RFC 2/2] xen/arm: patches for 32bit page shift operations ChanJu Park
@ 2013-09-17 15:44 ` Ian Campbell
0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2013-09-17 15:44 UTC (permalink / raw)
To: bestworld
Cc: julien.grall@linaro.org, stefano.stabellini@eu.citrix.com,
xen-devel@lists.xen.org
On Tue, 2013-09-17 at 15:30 +0000, ChanJu Park wrote:
> 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
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-09-17 15:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-17 15:30 [PATCH RFC 2/2] xen/arm: patches for 32bit page shift operations ChanJu Park
2013-09-17 15:44 ` Ian Campbell
-- strict thread matches above, loose matches on Subject: below --
2013-09-17 15:30 ChanJu Park
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).