[RFC] sh: Take into account the base of physical memory in virt_to_phys()

Simon Horman horms at verge.net.au
Thu Sep 15 07:12:59 EDT 2011


Previously virt_to_phys() assumed that physical memory always started
at address 0. This is not always the case.

Tested on an sh7757lcr (32bit system) whose only System RAM region is
40000000-4effffff

Signed-off-by: Simon Horman <horms at verge.net.au>
---
 kexec/arch/sh/kexec-sh.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/kexec/arch/sh/kexec-sh.c b/kexec/arch/sh/kexec-sh.c
index 4b21ee8..b0381bb 100644
--- a/kexec/arch/sh/kexec-sh.c
+++ b/kexec/arch/sh/kexec-sh.c
@@ -188,10 +188,18 @@ void kexec_sh_setup_zero_page(char *zero_page_buf, size_t zero_page_size,
 unsigned long virt_to_phys(unsigned long addr)
 {
 	unsigned long seg = addr & 0xe0000000;
+	unsigned long long start, end;
+	int ret;
+
+	/* Assume there is only one "System RAM" region */
+	ret = parse_iomem_single("System RAM\n", &start, &end);
+	if (ret)
+		die("Could not parse System RAM region in /proc/iomem\n");
+
 	if (seg != 0x80000000 && seg != 0xc0000000)
 		die("Virtual address %p is not in P1 or P2\n", (void *)addr);
 
-	return addr - seg;
+	return addr - seg + start;
 }
 
 /*
-- 
1.7.5.4




More information about the kexec mailing list