The loongarch64 SECTION_SIZE_BITS does not match the mainline kernel code.
crash test failed with mem_section init failure due to access non exist
memory address for mem sections caused by wrong NR_SECTION_ROOTS
According to Wang Ming, there was some historic reason, upstream kernel
did not take the SECTION_SIZE_BITS 28, but 28 is still better. Downstream
kernels took the 28 as default.
Thus fix this by setting the related values first according to vmcoreinfo
And falling back to the 29 which aligns to current upstrem kernel.
Signed-off-by: Dave Young <yangrr.2009(a)tsinghua.org.cn>
---
[v1->v2: use vmcoreinfo exported value first]
[future work: share code between arches for converting str to number]
defs.h | 2 +-
loongarch64.c | 18 ++++++++++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/defs.h b/defs.h
index 134e7597e966..7c25754afbcd 100644
--- a/defs.h
+++ b/defs.h
@@ -3903,7 +3903,7 @@ typedef signed int s32;
#define TIF_SIGPENDING (1)
-#define _SECTION_SIZE_BITS 28
+#define _SECTION_SIZE_BITS 29
#define _MAX_PHYSMEM_BITS 48
#endif /* LOONGARCH64 */
diff --git a/loongarch64.c b/loongarch64.c
index 39a05b854832..c95910f5ea4a 100644
--- a/loongarch64.c
+++ b/loongarch64.c
@@ -1876,6 +1876,8 @@ pt_level_alloc(char **lvl, char *name)
void
loongarch64_init(int when)
{
+ char *string;
+
switch (when) {
case SETUP_ENV:
machdep->process_elf_notes = process_elf64_notes;
@@ -1933,8 +1935,20 @@ loongarch64_init(int when)
break;
case POST_GDB:
- machdep->section_size_bits = _SECTION_SIZE_BITS;
- machdep->max_physmem_bits = _MAX_PHYSMEM_BITS;
+ string = pc->read_vmcoreinfo("NUMBER(SECTION_SIZE_BITS)");
+ if (string) {
+ machdep->section_size_bits = strtoul(string, NULL, 10);
+ free(string);
+ } else
+ machdep->section_size_bits = _SECTION_SIZE_BITS;
+
+
+ string = pc->read_vmcoreinfo("NUMBER(MAX_PHYSMEM_BITS)");
+ if (string) {
+ machdep->max_physmem_bits = strtoul(string, NULL, 10);
+ free(string);
+ } else
+ machdep->max_physmem_bits = _MAX_PHYSMEM_BITS;
if (symbol_exists("irq_desc"))
ARRAY_LENGTH_INIT(machdep->nr_irqs, irq_desc,
--
2.51.1