[PATCH 2/4] arm64: Decide VA Bits on the basis of _stext symbol value

Pratyush Anand panand at redhat.com
Sat Dec 5 08:30:01 PST 2015


Currently we assume that there are only two possible configuration
supported by kernel.
1) Page Table Level:2, Page Size 64K and VA Bits 42
1) Page Table Level:3, Page Size 4K and VA Bits 39
Ideally, we should have some mechanism to decide these from kernel
symbols, but we have limited symbols in vmcore,  and we can not do much.
So until some one comes with a better way, we use _stext symbol value
for VA bits determination.
We also assume that when VA Bits are 39, Page table level will be 3 and
Page size will be 4K, while when VA Bits are 42, Page table level will
be 2 an Page size will be 64K.

Signed-off-by: Pratyush Anand <panand at redhat.com>
---
 arch/arm64.c | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/arch/arm64.c b/arch/arm64.c
index 643c21f8feb1..4d50012529c3 100644
--- a/arch/arm64.c
+++ b/arch/arm64.c
@@ -115,16 +115,36 @@ get_page_shift_arm64(void)
 	return page_shift;
 }
 
+#define PAGE_OFFSET_39 (0xffffffffffffffffUL << 39)
+#define PAGE_OFFSET_42 (0xffffffffffffffffUL << 42)
 static int calculate_plat_config(void)
 {
-	/*
-	 * TODO: Keep it fixed for page level 2, size 64K and VA bits as
-	 * 42, as of now. Will calculate them from symbol address values
-	 * latter.
+	unsigned long long stext;
+
+	/* Currently we assume that there are only two possible
+	 * configuration supported by kernel.
+	 * 1) Page Table Level:2, Page Size 64K and VA Bits 42
+	 * 1) Page Table Level:3, Page Size 4K and VA Bits 39
+	 * Ideally, we should have some mechanism to decide these values
+	 * from kernel symbols, but we have limited symbols in vmcore,
+	 * and we can not do much. So until some one comes with a better
+	 * way, we use following.
 	 */
-	pgtable_level = 2;
-	va_bits = 42;
-	page_shift = 16;
+	stext = SYMBOL(_stext);
+
+	/* condition for minimum VA bits must be checked first and so on */
+	if ((stext & PAGE_OFFSET_39) == PAGE_OFFSET_39) {
+		pgtable_level = 3;
+		va_bits = 39;
+		page_shift = 12;
+	} else if ((stext & PAGE_OFFSET_42) == PAGE_OFFSET_42) {
+		pgtable_level = 2;
+		va_bits = 42;
+		page_shift = 16;
+	} else {
+		ERRMSG("Kernel Configuration not supported\n");
+		return FALSE;
+	}
 
 	return TRUE;
 }
-- 
2.5.0




More information about the kexec mailing list