Skip to contentSkip to conversation

makedumpfile: ppc64: read cur_mmu_type from vmcoreinfo

PATCH In review Aditya Gupta 2 participants 3 messages Feb 23, 2024

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

PATCH 1/1 makedumpfile: ppc64: read cur_mmu_type from vmcoreinfo

Currently makedumpfile depends on reading the 'cur_cpu_spec' kernel symbol to get the current MMU type on PowerPC64.

The disadvantage with this approach was that it depends on bit '0x40' ('MMU_FTR_TYPE_RADIX') being set in 'cur_cpu_spec->mmu_features', which implies kernel developers have to be careful of modifying MMU_FTR_* defines

Instead a more stable approach was suggested by contributors in
https://lore.kernel.org/linuxppc-dev/[email protected]/, to pass information about the MMU type in vmcoreinfo itself, instead of depending on the MMU_FTR_* defines

This was implemented in linux kernel in:
commit 36e826b568e4 ("powerpc/vmcore: Add MMU information to vmcoreinfo")

With this commit, if RADIX_MMU is there in the vmcoreinfo, we prefer it to get current mmu type, instead of 'cur_cpu_spec'.
On older kernels, where RADIX_MMU number is not there, makedumpfile will simply fall back to using 'cur_cpu_spec'.

The earlier defines for 'RADIX_MMU' have been renamed to 'MMU_TYPE_RADIX' which avoids conflict with the vmcoreinfo string 'RADIX_MMU', as well as being more clear about the value 0x40 with a comment about MMU_FTR_TYPE_RADIX

---
 arch/ppc64.c   | 15 ++++++++++-----
 makedumpfile.c |  1 +
 makedumpfile.h |  9 ++++++---
 3 files changed, 17 insertions(+), 8 deletions(-)
arch/ppc64.c +10 -5
index 96c357cb0335..3b4f91981f71 100644
@@ -250,7 +250,7 @@ ppc64_vmalloc_init(void)
 		/*
 		 * 64K pagesize
 		 */
-		if (info->cur_mmu_type & RADIX_MMU) {
+		if (info->cur_mmu_type & MMU_TYPE_RADIX) {
 			info->l1_index_size = PTE_INDEX_SIZE_RADIX_64K;
 			info->l2_index_size = PMD_INDEX_SIZE_RADIX_64K;
 			info->l3_index_size = PUD_INDEX_SIZE_RADIX_64K;
@@ -300,7 +300,7 @@ ppc64_vmalloc_init(void)
 		/*
 		 * 4K pagesize
 		 */
-		if (info->cur_mmu_type & RADIX_MMU) {
+		if (info->cur_mmu_type & MMU_TYPE_RADIX) {
 			info->l1_index_size = PTE_INDEX_SIZE_RADIX_4K;
 			info->l2_index_size = PMD_INDEX_SIZE_RADIX_4K;
 			info->l3_index_size = PUD_INDEX_SIZE_RADIX_4K;
@@ -635,14 +635,19 @@ get_versiondep_info_ppc64()
 	 * On PowerISA 3.0 based server processors, a kernel can run with
 	 * radix MMU or standard MMU. Get the current MMU type.
 	 */
-	info->cur_mmu_type = STD_MMU;
-	if ((SYMBOL(cur_cpu_spec) != NOT_FOUND_SYMBOL)
+	info->cur_mmu_type = MMU_TYPE_STD;
+
+	if (NUMBER(RADIX_MMU) != NOT_FOUND_SYMBOL) {
+		if (NUMBER(RADIX_MMU) == 1) {
+			info->cur_mmu_type = MMU_TYPE_RADIX;
+		}
+	} else if ((SYMBOL(cur_cpu_spec) != NOT_FOUND_SYMBOL)
 	    && (OFFSET(cpu_spec.mmu_features) != NOT_FOUND_STRUCTURE)) {
 		if (readmem(VADDR, SYMBOL(cur_cpu_spec), &cur_cpu_spec,
 		    sizeof(cur_cpu_spec))) {
 			if (readmem(VADDR, cur_cpu_spec + OFFSET(cpu_spec.mmu_features),
 			    &mmu_features, sizeof(mmu_features)))
-				info->cur_mmu_type = mmu_features & RADIX_MMU;
+				info->cur_mmu_type = mmu_features & MMU_TYPE_RADIX;
 		}
 	}
 
makedumpfile.c +1 -0
index 3705bdd93deb..1bd7305f49ca 100644
@@ -2987,6 +2987,7 @@ read_vmcoreinfo(void)
 #endif
 
 	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
+	READ_NUMBER("RADIX_MMU", RADIX_MMU);
 
 	return TRUE;
 }
makedumpfile.h +6 -3
index 3ed3ba551d96..a7b344974636 100644
@@ -747,12 +747,13 @@ unsigned long get_kvbase_arm64(void);
 /*
  * Supported MMU types
  */
-#define STD_MMU         0x0
+#define MMU_TYPE_STD         0x0
 /*
  * The flag bit for radix MMU in cpu_spec.mmu_features
- * in the kernel. Use the same flag here.
+ * in the kernel (MMU_FTR_TYPE_RADIX).
+ * Use the same flag here.
  */
-#define RADIX_MMU       0x40
+#define MMU_TYPE_RADIX       0x40
 
 
 #define PGD_MASK_L4		\
@@ -2258,6 +2259,8 @@ struct number_table {
 	unsigned long kernel_link_addr;
 	unsigned long va_kernel_pa_offset;
 #endif
+
+	unsigned long RADIX_MMU;
 };
 
 struct srcfile_table {
Signature · 7 lines
2.43.0


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

Add maintainer Kazu to CC.

Quoted 128 lines · Aditya Gupta

Currently makedumpfile depends on reading the 'cur_cpu_spec' kernel symbol to get the current MMU type on PowerPC64.

The disadvantage with this approach was that it depends on bit '0x40' ('MMU_FTR_TYPE_RADIX') being set in 'cur_cpu_spec->mmu_features', which implies kernel developers have to be careful of modifying MMU_FTR_* defines

Instead a more stable approach was suggested by contributors in
https://lore.kernel.org/linuxppc-dev/[email protected]/, to pass information about the MMU type in vmcoreinfo itself, instead of depending on the MMU_FTR_* defines

This was implemented in linux kernel in:
commit 36e826b568e4 ("powerpc/vmcore: Add MMU information to vmcoreinfo")

With this commit, if RADIX_MMU is there in the vmcoreinfo, we prefer it to get current mmu type, instead of 'cur_cpu_spec'.
On older kernels, where RADIX_MMU number is not there, makedumpfile will simply fall back to using 'cur_cpu_spec'.

The earlier defines for 'RADIX_MMU' have been renamed to 'MMU_TYPE_RADIX' which avoids conflict with the vmcoreinfo string 'RADIX_MMU', as well as being more clear about the value 0x40 with a comment about MMU_FTR_TYPE_RADIX

---
 arch/ppc64.c   | 15 ++++++++++-----
 makedumpfile.c |  1 +
 makedumpfile.h |  9 ++++++---
 3 files changed, 17 insertions(+), 8 deletions(-)
arch/ppc64.c +10 -5
index 96c357cb0335..3b4f91981f71 100644
@@ -250,7 +250,7 @@ ppc64_vmalloc_init(void)
 		/*
 		 * 64K pagesize
 		 */
-		if (info->cur_mmu_type & RADIX_MMU) {
+		if (info->cur_mmu_type & MMU_TYPE_RADIX) {
 			info->l1_index_size = PTE_INDEX_SIZE_RADIX_64K;
 			info->l2_index_size = PMD_INDEX_SIZE_RADIX_64K;
 			info->l3_index_size = PUD_INDEX_SIZE_RADIX_64K;
@@ -300,7 +300,7 @@ ppc64_vmalloc_init(void)
 		/*
 		 * 4K pagesize
 		 */
-		if (info->cur_mmu_type & RADIX_MMU) {
+		if (info->cur_mmu_type & MMU_TYPE_RADIX) {
 			info->l1_index_size = PTE_INDEX_SIZE_RADIX_4K;
 			info->l2_index_size = PMD_INDEX_SIZE_RADIX_4K;
 			info->l3_index_size = PUD_INDEX_SIZE_RADIX_4K;
@@ -635,14 +635,19 @@ get_versiondep_info_ppc64()
 	 * On PowerISA 3.0 based server processors, a kernel can run with
 	 * radix MMU or standard MMU. Get the current MMU type.
 	 */
-	info->cur_mmu_type = STD_MMU;
-	if ((SYMBOL(cur_cpu_spec) != NOT_FOUND_SYMBOL)
+	info->cur_mmu_type = MMU_TYPE_STD;
+
+	if (NUMBER(RADIX_MMU) != NOT_FOUND_SYMBOL) {
+		if (NUMBER(RADIX_MMU) == 1) {
+			info->cur_mmu_type = MMU_TYPE_RADIX;
+		}
+	} else if ((SYMBOL(cur_cpu_spec) != NOT_FOUND_SYMBOL)
 	    && (OFFSET(cpu_spec.mmu_features) != NOT_FOUND_STRUCTURE)) {
 		if (readmem(VADDR, SYMBOL(cur_cpu_spec), &cur_cpu_spec,
 		    sizeof(cur_cpu_spec))) {
 			if (readmem(VADDR, cur_cpu_spec + OFFSET(cpu_spec.mmu_features),
 			    &mmu_features, sizeof(mmu_features)))
-				info->cur_mmu_type = mmu_features & RADIX_MMU;
+				info->cur_mmu_type = mmu_features & MMU_TYPE_RADIX;
 		}
 	}
 
makedumpfile.c +1 -0
index 3705bdd93deb..1bd7305f49ca 100644
@@ -2987,6 +2987,7 @@ read_vmcoreinfo(void)
 #endif
 
 	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
+	READ_NUMBER("RADIX_MMU", RADIX_MMU);
 
 	return TRUE;
 }
makedumpfile.h +6 -3
index 3ed3ba551d96..a7b344974636 100644
@@ -747,12 +747,13 @@ unsigned long get_kvbase_arm64(void);
 /*
  * Supported MMU types
  */
-#define STD_MMU         0x0
+#define MMU_TYPE_STD         0x0
 /*
  * The flag bit for radix MMU in cpu_spec.mmu_features
- * in the kernel. Use the same flag here.
+ * in the kernel (MMU_FTR_TYPE_RADIX).
+ * Use the same flag here.
  */
-#define RADIX_MMU       0x40
+#define MMU_TYPE_RADIX       0x40
 
 
 #define PGD_MASK_L4		\
@@ -2258,6 +2259,8 @@ struct number_table {
 	unsigned long kernel_link_addr;
 	unsigned long va_kernel_pa_offset;
 #endif
+
+	unsigned long RADIX_MMU;
 };
 
 struct srcfile_table {
Signature · 7 lines
2.43.0


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

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

#2 lore raw
Quoted 1 line · Baoquan He

Add maintainer Kazu to CC.

Thanks, I missed him, will resend this patch with him in CC.

Thanks,
Aditya Gupta

Quoted 125 lines · Aditya Gupta
Quoted 123 lines

Currently makedumpfile depends on reading the 'cur_cpu_spec' kernel symbol to get the current MMU type on PowerPC64.

The disadvantage with this approach was that it depends on bit '0x40' ('MMU_FTR_TYPE_RADIX') being set in 'cur_cpu_spec->mmu_features', which implies kernel developers have to be careful of modifying MMU_FTR_* defines

Instead a more stable approach was suggested by contributors in
https://lore.kernel.org/linuxppc-dev/[email protected]/, to pass information about the MMU type in vmcoreinfo itself, instead of depending on the MMU_FTR_* defines

This was implemented in linux kernel in:
commit 36e826b568e4 ("powerpc/vmcore: Add MMU information to vmcoreinfo")

With this commit, if RADIX_MMU is there in the vmcoreinfo, we prefer it to get current mmu type, instead of 'cur_cpu_spec'.
On older kernels, where RADIX_MMU number is not there, makedumpfile will simply fall back to using 'cur_cpu_spec'.

The earlier defines for 'RADIX_MMU' have been renamed to 'MMU_TYPE_RADIX' which avoids conflict with the vmcoreinfo string 'RADIX_MMU', as well as being more clear about the value 0x40 with a comment about MMU_FTR_TYPE_RADIX

---
 arch/ppc64.c   | 15 ++++++++++-----
 makedumpfile.c |  1 +
 makedumpfile.h |  9 ++++++---
 3 files changed, 17 insertions(+), 8 deletions(-)
arch/ppc64.c +10 -5
index 96c357cb0335..3b4f91981f71 100644
@@ -250,7 +250,7 @@ ppc64_vmalloc_init(void)
 		/*
 		 * 64K pagesize
 		 */
-		if (info->cur_mmu_type & RADIX_MMU) {
+		if (info->cur_mmu_type & MMU_TYPE_RADIX) {
 			info->l1_index_size = PTE_INDEX_SIZE_RADIX_64K;
 			info->l2_index_size = PMD_INDEX_SIZE_RADIX_64K;
 			info->l3_index_size = PUD_INDEX_SIZE_RADIX_64K;
@@ -300,7 +300,7 @@ ppc64_vmalloc_init(void)
 		/*
 		 * 4K pagesize
 		 */
-		if (info->cur_mmu_type & RADIX_MMU) {
+		if (info->cur_mmu_type & MMU_TYPE_RADIX) {
 			info->l1_index_size = PTE_INDEX_SIZE_RADIX_4K;
 			info->l2_index_size = PMD_INDEX_SIZE_RADIX_4K;
 			info->l3_index_size = PUD_INDEX_SIZE_RADIX_4K;
@@ -635,14 +635,19 @@ get_versiondep_info_ppc64()
 	 * On PowerISA 3.0 based server processors, a kernel can run with
 	 * radix MMU or standard MMU. Get the current MMU type.
 	 */
-	info->cur_mmu_type = STD_MMU;
-	if ((SYMBOL(cur_cpu_spec) != NOT_FOUND_SYMBOL)
+	info->cur_mmu_type = MMU_TYPE_STD;
+
+	if (NUMBER(RADIX_MMU) != NOT_FOUND_SYMBOL) {
+		if (NUMBER(RADIX_MMU) == 1) {
+			info->cur_mmu_type = MMU_TYPE_RADIX;
+		}
+	} else if ((SYMBOL(cur_cpu_spec) != NOT_FOUND_SYMBOL)
 	    && (OFFSET(cpu_spec.mmu_features) != NOT_FOUND_STRUCTURE)) {
 		if (readmem(VADDR, SYMBOL(cur_cpu_spec), &cur_cpu_spec,
 		    sizeof(cur_cpu_spec))) {
 			if (readmem(VADDR, cur_cpu_spec + OFFSET(cpu_spec.mmu_features),
 			    &mmu_features, sizeof(mmu_features)))
-				info->cur_mmu_type = mmu_features & RADIX_MMU;
+				info->cur_mmu_type = mmu_features & MMU_TYPE_RADIX;
 		}
 	}
 
makedumpfile.c +1 -0
index 3705bdd93deb..1bd7305f49ca 100644
@@ -2987,6 +2987,7 @@ read_vmcoreinfo(void)
 #endif
 
 	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
+	READ_NUMBER("RADIX_MMU", RADIX_MMU);
 
 	return TRUE;
 }
makedumpfile.h +6 -3
index 3ed3ba551d96..a7b344974636 100644
@@ -747,12 +747,13 @@ unsigned long get_kvbase_arm64(void);
 /*
  * Supported MMU types
  */
-#define STD_MMU         0x0
+#define MMU_TYPE_STD         0x0
 /*
  * The flag bit for radix MMU in cpu_spec.mmu_features
- * in the kernel. Use the same flag here.
+ * in the kernel (MMU_FTR_TYPE_RADIX).
+ * Use the same flag here.
  */
-#define RADIX_MMU       0x40
+#define MMU_TYPE_RADIX       0x40
 
 
 #define PGD_MASK_L4		\
@@ -2258,6 +2259,8 @@ struct number_table {
 	unsigned long kernel_link_addr;
 	unsigned long va_kernel_pa_offset;
 #endif
+
+	unsigned long RADIX_MMU;
 };
 
 struct srcfile_table {
Signature · 1 line
2.43.0
Quoted 6 lines
Quoted 5 lines

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

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