lkml.org 
[lkml]   [2008]   [Feb]   [15]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] Fix left over EFI cache mapping problems
From"Huang, Ying" <>
DateFri, 15 Feb 2008 14:24:40 +0800
On Thu, 2008-02-14 at 21:44 -0800, Linus Torvalds wrote:
> 
> On Fri, 15 Feb 2008, Huang, Ying wrote:
> > 
> > I think the patch following may be better, because it is possible that
> > the EFI_PAGE_SHIFT and PAGE_SHIFT are different.
> 
> If this is a problem in practice, we'd be better off having a helper 
> function to do it, to avoid overflows. Right now, doing
> 
> > +		unsigned long num_pages;
> > +		num_pages = (md->num_pages << EFI_PAGE_SHIFT) >> PAGE_SHIFT;
> 
> overflows at 4GB on x86-32. And maybe you never have areas that big, and 
> people are moving over to 64-bit anyway, it still sounds like a bug 
> waiting to happen.
> 
> So *if* we care (I doubt we do, since EFI_PAGE_SHIFT at least right now 
> matches PAGE_SHIFT on x86), you'd probably want to do something like
> 
>   static inline unsigned long efi_pages_to_native_pages(unsigned long efi_pages)
>   {
>   #if EFI_PAGE_SHIFT > PAGE_SHIFT
> 	return efi_pages << (EFI_PAGE_SHIFT - PAGE_SHIFT);
>   #else
> 	return efi_pages >> (PAGE_SHIFT - EFI_PAGE_SHIFT);
>   #endif
>   }
> 
> or whatever.
> 
> Otherwise, trying to avoid a bug with different page sizes is actually 
> more likely to *introduce* one rather than fix one..

Yes, I will fix this.

Best Regards,
Huang Ying



\
 
 \ /
  Last update: 2008-02-15 07:27    [from the cache]
©2003-2008