Skip to contentSkip to conversation

makedumpfile: mips64: Replace hardcoded values with macros

PATCH Applied Chetan Kankotiya 2 participants 2 messages Sep 14, 2022 – Sep 15, 2022

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

PATCH 1/1 makedumpfile: mips64: Replace hardcoded values with macros

Replace hardcoded values of PAGE_OFFSET, XKPHS start and end address, and _MAX_PHYSMEM_BITS with macros that may differ based on kernel-defined values for different MIPS SoCs. We can override these macros to align with kernel values at compile time.

---
 arch/mips64.c  |  4 ++--
 makedumpfile.h | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)
arch/mips64.c +2 -2
index d541c3e..ab45b6e 100644
@@ -52,7 +52,7 @@ get_machdep_info_mips64(void)
 int
 get_versiondep_info_mips64(void)
 {
-	info->page_offset  = 0x9800000000000000ULL;
+	info->page_offset  = _PAGE_OFFSET;
 
 	DEBUG_MSG("page_offset : %lx\n", info->page_offset);
 
@@ -79,7 +79,7 @@ vaddr_to_paddr_mips64(unsigned long vaddr)
 	/*
 	 * XKPHYS
 	 */
-	if (vaddr >= 0x9000000000000000ULL && vaddr < 0xc000000000000000ULL)
+	if (vaddr >= _XKPHYS_START_ADDR && vaddr < _XKPHYS_END_ADDR)
 		return vaddr & ((1ULL << MAX_PHYSMEM_BITS()) - 1);
 
 	if (SYMBOL(swapper_pg_dir) == NOT_FOUND_SYMBOL) {
makedumpfile.h +17 -0
index 2084ed5..49b9242 100644
@@ -965,8 +965,25 @@ typedef unsigned long pgd_t;
 
 #ifdef __mips64__ /* mips64 */
 #define KVBASE			PAGE_OFFSET
+
+#ifndef _XKPHYS_START_ADDR
+#define _XKPHYS_START_ADDR	0x9000000000000000ULL /* _LOONGSON_XKPHYS_START_ADDR */
+#endif
+
+#ifndef _XKPHYS_END_ADDR
+#define _XKPHYS_END_ADDR	0xc000000000000000ULL /* _LOONGSON_XKPHYS_END_ADDR */
+#endif
+
+#ifndef _PAGE_OFFSET
+#define _PAGE_OFFSET		0x9800000000000000ULL
+#endif
+
 #define _SECTION_SIZE_BITS	(28)
+
+#ifndef _MAX_PHYSMEM_BITS
 #define _MAX_PHYSMEM_BITS	(48)
+#endif
+
 #define _PAGE_PRESENT		(1 << 0)
 #define _PAGE_HUGE		(1 << 4)
 
Signature · 7 lines
2.26.2.Cisco


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw
Quoted 6 lines · Chetan Kankotiya

Replace hardcoded values of PAGE_OFFSET, XKPHS start and end address, and _MAX_PHYSMEM_BITS with macros that may differ based on kernel-defined values for different MIPS SoCs. We can override these macros to align with kernel values at compile time.

Thanks, applied.
https://github.com/makedumpfile/makedumpfile/commit/36cdfd91d7870649c186457c5051f5c435ab199e

Kazu

Quoted 47 lines
---
  arch/mips64.c  |  4 ++--
  makedumpfile.h | 17 +++++++++++++++++
  2 files changed, 19 insertions(+), 2 deletions(-)
arch/mips64.c +2 -2
index d541c3e..ab45b6e 100644
@@ -52,7 +52,7 @@ get_machdep_info_mips64(void)
  int
  get_versiondep_info_mips64(void)
  {
-	info->page_offset  = 0x9800000000000000ULL;
+	info->page_offset  = _PAGE_OFFSET;
 
  	DEBUG_MSG("page_offset : %lx\n", info->page_offset);
 
@@ -79,7 +79,7 @@ vaddr_to_paddr_mips64(unsigned long vaddr)
  	/*
  	 * XKPHYS
  	 */
-	if (vaddr >= 0x9000000000000000ULL && vaddr < 0xc000000000000000ULL)
+	if (vaddr >= _XKPHYS_START_ADDR && vaddr < _XKPHYS_END_ADDR)
  		return vaddr & ((1ULL << MAX_PHYSMEM_BITS()) - 1);
 
  	if (SYMBOL(swapper_pg_dir) == NOT_FOUND_SYMBOL) {
makedumpfile.h +12 -0
index 2084ed5..49b9242 100644
@@ -965,8 +965,25 @@ typedef unsigned long pgd_t;
 
  #ifdef __mips64__ /* mips64 */
  #define KVBASE			PAGE_OFFSET
+
+#ifndef _XKPHYS_START_ADDR
+#define _XKPHYS_START_ADDR	0x9000000000000000ULL /* _LOONGSON_XKPHYS_START_ADDR */
+#endif
+
+#ifndef _XKPHYS_END_ADDR
+#define _XKPHYS_END_ADDR	0xc000000000000000ULL /* _LOONGSON_XKPHYS_END_ADDR */
+#endif
+
+#ifndef _PAGE_OFFSET
+#define _PAGE_OFFSET		0x9800000000000000ULL
+#endif

makedumpfile.h typedef unsigned long pgd_t; · line 989

Quoted 10 lines
makedumpfile.h +5 -0
+
  #define _SECTION_SIZE_BITS	(28)
+
+#ifndef _MAX_PHYSMEM_BITS
  #define _MAX_PHYSMEM_BITS	(48)
+#endif
+
  #define _PAGE_PRESENT		(1 << 0)
  #define _PAGE_HUGE		(1 << 4)
 

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