public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: ehabkost@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] make PFN_PHYS explicitly return phys_addr_t
Date: Mon, 11 Aug 2008 12:38:56 -0700	[thread overview]
Message-ID: <48A09550.60502@goop.org> (raw)
In-Reply-To: <20080807170617.79ca3ce7.akpm@linux-foundation.org>

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>
Cc: Eduardo Habkost <ehabkost@redhat.com>
---
 arch/m32r/mm/discontig.c   |    2 +-
 include/asm-x86/xen/page.h |    4 ++--
 include/linux/pfn.h        |    6 +++++-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff -r 6b03eb6361dd arch/m32r/mm/discontig.c
--- a/arch/m32r/mm/discontig.c	Mon Aug 11 11:19:24 2008 -0700
+++ b/arch/m32r/mm/discontig.c	Mon Aug 11 11:20:07 2008 -0700
@@ -112,9 +112,9 @@
 				initrd_start, INITRD_SIZE);
 		} else {
 			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));
+			        (unsigned long long)PFN_PHYS(max_low_pfn));
 
 			initrd_start = 0;
 		}
diff -r 6b03eb6361dd include/asm-x86/xen/page.h
--- a/include/asm-x86/xen/page.h	Mon Aug 11 11:19:24 2008 -0700
+++ b/include/asm-x86/xen/page.h	Mon Aug 11 11:20:07 2008 -0700
@@ -76,13 +76,13 @@
 static inline xmaddr_t phys_to_machine(xpaddr_t phys)
 {
 	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)
 {
 	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);
 }
 
 /*
diff -r 6b03eb6361dd include/linux/pfn.h
--- a/include/linux/pfn.h	Mon Aug 11 11:19:24 2008 -0700
+++ b/include/linux/pfn.h	Mon Aug 11 11:20:07 2008 -0700
@@ -1,9 +1,13 @@
 #ifndef _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_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)	((phys_addr_t)(x) << PAGE_SHIFT)
 
 #endif



      parent reply	other threads:[~2008-08-11 19:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <489B6B40.5050705@goop.org>
     [not found] ` <20080807145648.ab3dfa90.akpm@linux-foundation.org>
2008-08-07 22:10   ` [PATCH] Make PFN_PHYS return a properly-formed physical address Jeremy Fitzhardinge
2008-08-07 23:27     ` Andrew Morton
2008-08-07 23:45       ` Jeremy Fitzhardinge
2008-08-08  0:06         ` Andrew Morton
2008-08-08  0:16           ` Jeremy Fitzhardinge
2008-08-11 19:38           ` [PATCH 1/2] add phys_addr_t for holding physical addresses Jeremy Fitzhardinge
2008-08-11 21:58             ` Benjamin Herrenschmidt
2008-08-11 22:15               ` Jeremy Fitzhardinge
2008-08-11 22:32                 ` Benjamin Herrenschmidt
2008-08-11 22:50                   ` Jeremy Fitzhardinge
2008-08-11 22:53                     ` Benjamin Herrenschmidt
2008-08-11 23:02                       ` Jeremy Fitzhardinge
2008-08-11 23:17                         ` Benjamin Herrenschmidt
2008-08-11 19:38           ` Jeremy Fitzhardinge [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48A09550.60502@goop.org \
    --to=jeremy@goop.org \
    --cc=akpm@linux-foundation.org \
    --cc=ehabkost@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox