On Thu, 07 Aug 2008 14:38:08 -0700
Jeremy Fitzhardinge <jeremy@xxxxxxxx> wrote:
PFN_PHYS, as its name suggests, turns a pfn into a physical address.
However, it is a macro which just operates on its argument without
modifying its type. pfns are typed unsigned long, but an unsigned
long may not be long enough to hold a physical address (32-bit systems
with more than 32 bits of physcial address). This means that the
resulting address could be truncated if it doesn't fit within an
unsigned long. This isn't generally a problem because most users end
up using it for "low" memory, but there's no reason why PFN_PHYS
couldn't be used for any possible pfn.
Please copy a mailing list on patches. So you can get your titties
toasted off ;)
Fortunately, resource_size_t is the right size, and has approximately
the right meaning. It's 64-bits on platforms where that's
appropriate, but 32-bits where the extra bits are not needed.
aww maaan. Hack or what?
#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
-#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
+#define PFN_PHYS(x) ((resource_size_t)(x) << PAGE_SHIFT)
Busted on PAE with CONFIG_RESOURCES_64BIT=n, surely?
Can we please do this properly, whatever that is? Even a dumb
always-return-u64 would be better?
printk("initrd extends beyond end of memory "
- "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
+ "(0x%08lx > 0x%08llx)\ndisabling initrd\n",
INITRD_START + INITRD_SIZE,
PFN_PHYS(max_low_pfn));
that'll generate a compile warning if m32r can set CONFIG_RESOURCES_64BIT=n.