[Top] [All Lists]

[PATCH 5/5] Fix PHYS_OFFSET for 64-bits kernels with 32-bits symbols

Subject: [PATCH 5/5] Fix PHYS_OFFSET for 64-bits kernels with 32-bits symbols
From: Franck Bui-Huu <>
Date: Mon, 4 Jun 2007 17:46:35 +0200
Dkim-signature: a=rsa-sha1; c=relaxed/relaxed;; s=beta; h=domainkey-signature:received:received:received:to:cc:subject:date:message-id:x-mailer:in-reply-to:references:from; b=szTJG0icWA/dOFQHlzBC7v1Bw2DvRPsBWHeEqOObXJIt7sEiiCH8+eh+qPxfUwVaPJt5bSzQo1rJRz6OaYtnTby84uVOuHfno+ZU77HxAjyXMhG/TCdhFLKNQCar/8X8ZjFoTxaCE4fqu0J0ittJR5dITGsYiyQaJ69UWTLmgOc=
Domainkey-signature: a=rsa-sha1; c=nofws;; s=beta; h=received:to:cc:subject:date:message-id:x-mailer:in-reply-to:references:from; b=CvJ+4yH1ZedFC7eQD8+3Sm4rWuRzJjvYMmF05i1IBJCor6w1YWt4DYc4UGru7pzOJzeinyMfFifNf8QS4pTlTjwVVOYdZKw/541CH5nTMuMqYKoDUitk5vu+mXxRLs8ENJwjrYSspNMEiwg+v0LyqcwutWaPiXVPL6a4ywTuv3U=
In-reply-to: <>
Original-recipient: rfc822;
References: <>
From: Franck Bui-Huu <>

The current implementation of __pa() for 64-bits kernels with 32-bits
symbols is broken. In this configuration, we need 2 values for
PAGE_OFFSET, one in XKPHYS and the other in CKSEG0 space.

When the value in CKSEG0 space is used, it doesn't take into account
of PHYS_OFFSET. Even worse we can't redefine this value.

The patch restores CPHYSADDR() but in __pa()'s implementation because
it removes the need of 2 PAGE_OFFSET.

OTOH, CPHYSADDR() is quite bad when dealing with mapped kernels. So
this patch assumes there's no need to deal with such kernel in 64-bits

Signed-off-by: Franck Bui-Huu <>
 include/asm-mips/page.h |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index 09c60d5..b92dd8c 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -143,11 +143,15 @@ typedef struct { unsigned long pgprot; } pgprot_t;
  * __pa()/__va() should be used only during mem init.
 #if defined(CONFIG_64BIT) && !defined(CONFIG_BUILD_ELF64)
-#define __pa_page_offset(x)    ((unsigned long)(x) < CKSEG0 ? PAGE_OFFSET : 
+#define __pa(x)                                                                
+({                                                                     \
+    unsigned long __x = (unsigned long)(x);                            \
+    __x < CKSEG0 ? XPHYSADDR(__x) : CPHYSADDR(__x);                    \
-#define __pa_page_offset(x)    PAGE_OFFSET
+#define __pa(x)                                                                
+    ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET)
-#define __pa(x)                ((unsigned long)(x) - __pa_page_offset(x) + 
 #define __va(x)                ((void *)((unsigned long)(x) + PAGE_OFFSET - 
 #define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x),0))

<Prev in Thread] Current Thread [Next in Thread>