linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen_alloc_ptpage: cast PFN_PHYS() argument to unsigned long
@ 2008-07-28 21:32 Eduardo Habkost
  2008-07-31 15:11 ` Ingo Molnar
  0 siblings, 1 reply; 2+ messages in thread
From: Eduardo Habkost @ 2008-07-28 21:32 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Jeremy Fitzhardinge, Eduardo Habkost, linux-kernel

[Oops, I forgot to CC lkml when sending this patch previously. Sorry]

Currently paravirt_ops alloc_p*() uses u32 for the pfn args. We should
change that later, but while the pfn parameter is still u32, we need to
cast the PFN_PHYS() argument at xen_alloc_ptpage() to unsigned long,
otherwise it will lose bits on the shift.

I think PFN_PHYS() should behave better when fed with smaller integers,
but a cast to unsigned long won't be enough for all cases on 32-bit PAE,
and a cast to u64 would be overkill for most users of PFN_PHYS().

We could have two different flavors of PFN_PHYS: one for low pages
only (unsigned long) and another that works for any page (u64)),
but while we don't have it, we will need the cast to unsigned long on
xen_alloc_ptpage().

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 arch/x86/xen/enlighten.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index fc4db93..4b50c0a 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -942,7 +942,7 @@ static void xen_alloc_ptpage(struct mm_struct *mm, u32 pfn, unsigned level)
 		SetPagePinned(page);
 
 		if (!PageHighMem(page)) {
-			make_lowmem_page_readonly(__va(PFN_PHYS(pfn)));
+			make_lowmem_page_readonly(__va(PFN_PHYS((unsigned long)pfn)));
 			if (level == PT_PTE)
 				pin_pagetable_pfn(MMUEXT_PIN_L1_TABLE, pfn);
 		} else
-- 
1.5.5.GIT



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] xen_alloc_ptpage: cast PFN_PHYS() argument to unsigned long
  2008-07-28 21:32 [PATCH] xen_alloc_ptpage: cast PFN_PHYS() argument to unsigned long Eduardo Habkost
@ 2008-07-31 15:11 ` Ingo Molnar
  0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2008-07-31 15:11 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: Jeremy Fitzhardinge, linux-kernel


* Eduardo Habkost <ehabkost@redhat.com> wrote:

> Currently paravirt_ops alloc_p*() uses u32 for the pfn args. We should 
> change that later, but while the pfn parameter is still u32, we need 
> to cast the PFN_PHYS() argument at xen_alloc_ptpage() to unsigned 
> long, otherwise it will lose bits on the shift.
> 
> I think PFN_PHYS() should behave better when fed with smaller 
> integers, but a cast to unsigned long won't be enough for all cases on 
> 32-bit PAE, and a cast to u64 would be overkill for most users of 
> PFN_PHYS().
> 
> We could have two different flavors of PFN_PHYS: one for low pages 
> only (unsigned long) and another that works for any page (u64)), but 
> while we don't have it, we will need the cast to unsigned long on 
> xen_alloc_ptpage().
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> Acked-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

applied to tip/x86/xen - thanks Eduardo.

	Ingo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-07-31 15:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-28 21:32 [PATCH] xen_alloc_ptpage: cast PFN_PHYS() argument to unsigned long Eduardo Habkost
2008-07-31 15:11 ` Ingo Molnar

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).