提交 947d0496 编写于 作者: J Jeremy Fitzhardinge 提交者: Ingo Molnar

generic: make PFN_PHYS explicitly return phys_addr_t

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

Make sure we cast to phys_addr_t to return a complete result.
Signed-off-by: NJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 600715dc
...@@ -111,9 +111,9 @@ unsigned long __init setup_memory(void) ...@@ -111,9 +111,9 @@ unsigned long __init setup_memory(void)
initrd_start, INITRD_SIZE); initrd_start, INITRD_SIZE);
} else { } else {
printk("initrd extends beyond end of memory " 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, INITRD_START + INITRD_SIZE,
PFN_PHYS(max_low_pfn)); (unsigned long long)PFN_PHYS(max_low_pfn));
initrd_start = 0; initrd_start = 0;
} }
......
...@@ -76,13 +76,13 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn) ...@@ -76,13 +76,13 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
static inline xmaddr_t phys_to_machine(xpaddr_t phys) static inline xmaddr_t phys_to_machine(xpaddr_t phys)
{ {
unsigned offset = phys.paddr & ~PAGE_MASK; unsigned offset = phys.paddr & ~PAGE_MASK;
return XMADDR(PFN_PHYS((u64)pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset); return XMADDR(PFN_PHYS(pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset);
} }
static inline xpaddr_t machine_to_phys(xmaddr_t machine) static inline xpaddr_t machine_to_phys(xmaddr_t machine)
{ {
unsigned offset = machine.maddr & ~PAGE_MASK; unsigned offset = machine.maddr & ~PAGE_MASK;
return XPADDR(PFN_PHYS((u64)mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset); return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
} }
/* /*
......
#ifndef _LINUX_PFN_H_ #ifndef _LINUX_PFN_H_
#define _LINUX_PFN_H_ #define _LINUX_PFN_H_
#ifndef __ASSEMBLY__
#include <linux/types.h>
#endif
#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK) #define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
#define PFN_PHYS(x) ((x) << PAGE_SHIFT) #define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册