Skip to contentSkip to conversation

arm64: Memstart should not be before the kernel start address

PATCH New Sameer Goel 1 participant 1 message Apr 19, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: Memstart should not be before the kernel start address

Starting 4.6-rc4 the kernel memblock start is rounded down to a desirable alignment. So, the kernel can see reserved memory regions before the kernel start address in the iomem query.
Need to make sure that the right kernel start address is picked from the iomem query.

---
 kexec/arch/arm64/kexec-arm64.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
kexec/arch/arm64/kexec-arm64.c +10 -2
index 776596a..5e39f4f 100644
@@ -30,6 +30,12 @@
 #include "kexec-syscall.h"
 #include "arch/options.h"
 
+#define SZ_2M 0x200000
+
+#define __round_mask(x, y) ((__typeof__(x))((y)-1))
+#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
+#define round_down(x, y) ((x) & ~__round_mask(x, y))
+
 /* Global varables the core kexec routines expect. */
 
 unsigned char reuse_initrd;
@@ -944,6 +950,10 @@ static int get_memory_ranges_iomem(struct memory_range *array,
 		str = line + consumed;
 		r.end++;
 
+		if (memcmp(str, "Kernel code\n", 12)==0) {
+			set_memstart(round_down(r.start,SZ_2M));
+		}
+
 		if (memcmp(str, "System RAM\n", 11)) {
 			dbgprintf("%s:%d: SKIP: %016Lx - %016Lx : %s", __func__,
 				__LINE__, r.start, r.end, str);
@@ -956,8 +966,6 @@ static int get_memory_ranges_iomem(struct memory_range *array,
 			__LINE__, r.start, r.end, str);
 
 		array[(*count)++] = r;
-
-		set_memstart(r.start);
 	}
 
 	fclose(fp);
Signature · 7 lines
Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec