Commit 947d0496cf3e12ebfa70b3eaf561c25403247ce9
Committed by
Ingo Molnar
1 parent
600715dcdf
Exists in
master
and in
39 other branches
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: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Showing 3 changed files with 9 additions and 5 deletions Side-by-side Diff
arch/m32r/mm/discontig.c
... | ... | @@ -111,9 +111,9 @@ |
111 | 111 | initrd_start, INITRD_SIZE); |
112 | 112 | } else { |
113 | 113 | printk("initrd extends beyond end of memory " |
114 | - "(0x%08lx > 0x%08lx)\ndisabling initrd\n", | |
114 | + "(0x%08lx > 0x%08llx)\ndisabling initrd\n", | |
115 | 115 | INITRD_START + INITRD_SIZE, |
116 | - PFN_PHYS(max_low_pfn)); | |
116 | + (unsigned long long)PFN_PHYS(max_low_pfn)); | |
117 | 117 | |
118 | 118 | initrd_start = 0; |
119 | 119 | } |
include/asm-x86/xen/page.h
... | ... | @@ -76,13 +76,13 @@ |
76 | 76 | static inline xmaddr_t phys_to_machine(xpaddr_t phys) |
77 | 77 | { |
78 | 78 | unsigned offset = phys.paddr & ~PAGE_MASK; |
79 | - return XMADDR(PFN_PHYS((u64)pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset); | |
79 | + return XMADDR(PFN_PHYS(pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset); | |
80 | 80 | } |
81 | 81 | |
82 | 82 | static inline xpaddr_t machine_to_phys(xmaddr_t machine) |
83 | 83 | { |
84 | 84 | unsigned offset = machine.maddr & ~PAGE_MASK; |
85 | - return XPADDR(PFN_PHYS((u64)mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset); | |
85 | + return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset); | |
86 | 86 | } |
87 | 87 | |
88 | 88 | /* |
include/linux/pfn.h
1 | 1 | #ifndef _LINUX_PFN_H_ |
2 | 2 | #define _LINUX_PFN_H_ |
3 | 3 | |
4 | +#ifndef __ASSEMBLY__ | |
5 | +#include <linux/types.h> | |
6 | +#endif | |
7 | + | |
4 | 8 | #define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK) |
5 | 9 | #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) |
6 | 10 | #define PFN_DOWN(x) ((x) >> PAGE_SHIFT) |
7 | -#define PFN_PHYS(x) ((x) << PAGE_SHIFT) | |
11 | +#define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT) | |
8 | 12 | |
9 | 13 | #endif |