Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] makedumpfile: ppc64: read cur_mmu_type from vmcoreinfo
@ 2024-02-23  5:53 Aditya Gupta
  2024-02-23  7:54 ` Baoquan He
  0 siblings, 1 reply; 6+ messages in thread
From: Aditya Gupta @ 2024-02-23  5:53 UTC (permalink / raw)
  To: kexec; +Cc: Hari Bathini, Mahesh J Salgaonkar, Sourabh Jain

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/87v8c3m70t.fsf@mail.lhotse/, 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

Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
---
 arch/ppc64.c   | 15 ++++++++++-----
 makedumpfile.c |  1 +
 makedumpfile.h |  9 ++++++---
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/arch/ppc64.c b/arch/ppc64.c
index 96c357cb0335..3b4f91981f71 100644
--- a/arch/ppc64.c
+++ b/arch/ppc64.c
@@ -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;
 		}
 	}
 
diff --git a/makedumpfile.c b/makedumpfile.c
index 3705bdd93deb..1bd7305f49ca 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -2987,6 +2987,7 @@ read_vmcoreinfo(void)
 #endif
 
 	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
+	READ_NUMBER("RADIX_MMU", RADIX_MMU);
 
 	return TRUE;
 }
diff --git a/makedumpfile.h b/makedumpfile.h
index 3ed3ba551d96..a7b344974636 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -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 {
-- 
2.43.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] makedumpfile: ppc64: read cur_mmu_type from vmcoreinfo
  2024-02-23  5:53 [PATCH] makedumpfile: ppc64: read cur_mmu_type from vmcoreinfo Aditya Gupta
@ 2024-02-23  7:54 ` Baoquan He
  2024-02-23  8:37   ` Aditya Gupta
  0 siblings, 1 reply; 6+ messages in thread
From: Baoquan He @ 2024-02-23  7:54 UTC (permalink / raw)
  To: Aditya Gupta, k-hagio-ab
  Cc: kexec, Hari Bathini, Mahesh J Salgaonkar, Sourabh Jain

Add maintainer Kazu to CC.

On 02/23/24 at 11:23am, Aditya Gupta wrote:
> 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/87v8c3m70t.fsf@mail.lhotse/, 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
> 
> Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
> ---
>  arch/ppc64.c   | 15 ++++++++++-----
>  makedumpfile.c |  1 +
>  makedumpfile.h |  9 ++++++---
>  3 files changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/ppc64.c b/arch/ppc64.c
> index 96c357cb0335..3b4f91981f71 100644
> --- a/arch/ppc64.c
> +++ b/arch/ppc64.c
> @@ -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;
>  		}
>  	}
>  
> diff --git a/makedumpfile.c b/makedumpfile.c
> index 3705bdd93deb..1bd7305f49ca 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -2987,6 +2987,7 @@ read_vmcoreinfo(void)
>  #endif
>  
>  	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
> +	READ_NUMBER("RADIX_MMU", RADIX_MMU);
>  
>  	return TRUE;
>  }
> diff --git a/makedumpfile.h b/makedumpfile.h
> index 3ed3ba551d96..a7b344974636 100644
> --- a/makedumpfile.h
> +++ b/makedumpfile.h
> @@ -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 {
> -- 
> 2.43.0
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
> 


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] makedumpfile: ppc64: read cur_mmu_type from vmcoreinfo
  2024-02-23  7:54 ` Baoquan He
@ 2024-02-23  8:37   ` Aditya Gupta
  0 siblings, 0 replies; 6+ messages in thread
From: Aditya Gupta @ 2024-02-23  8:37 UTC (permalink / raw)
  To: Baoquan He
  Cc: k-hagio-ab, kexec, Hari Bathini, Mahesh J Salgaonkar,
	Sourabh Jain

On Fri, Feb 23, 2024 at 03:54:12PM +0800, Baoquan He wrote:
> Add maintainer Kazu to CC.

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

Thanks,
Aditya Gupta

> 
> On 02/23/24 at 11:23am, Aditya Gupta wrote:
> > 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/87v8c3m70t.fsf@mail.lhotse/, 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
> > 
> > Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
> > ---
> >  arch/ppc64.c   | 15 ++++++++++-----
> >  makedumpfile.c |  1 +
> >  makedumpfile.h |  9 ++++++---
> >  3 files changed, 17 insertions(+), 8 deletions(-)
> > 
> > diff --git a/arch/ppc64.c b/arch/ppc64.c
> > index 96c357cb0335..3b4f91981f71 100644
> > --- a/arch/ppc64.c
> > +++ b/arch/ppc64.c
> > @@ -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;
> >  		}
> >  	}
> >  
> > diff --git a/makedumpfile.c b/makedumpfile.c
> > index 3705bdd93deb..1bd7305f49ca 100644
> > --- a/makedumpfile.c
> > +++ b/makedumpfile.c
> > @@ -2987,6 +2987,7 @@ read_vmcoreinfo(void)
> >  #endif
> >  
> >  	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
> > +	READ_NUMBER("RADIX_MMU", RADIX_MMU);
> >  
> >  	return TRUE;
> >  }
> > diff --git a/makedumpfile.h b/makedumpfile.h
> > index 3ed3ba551d96..a7b344974636 100644
> > --- a/makedumpfile.h
> > +++ b/makedumpfile.h
> > @@ -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 {
> > -- 
> > 2.43.0
> > 
> > 
> > _______________________________________________
> > kexec mailing list
> > kexec@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/kexec
> > 
> 

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] makedumpfile: ppc64: read cur_mmu_type from vmcoreinfo
@ 2024-02-23  8:39 Aditya Gupta
  2024-02-28  0:25 ` HAGIO KAZUHITO(萩尾 一仁)
  0 siblings, 1 reply; 6+ messages in thread
From: Aditya Gupta @ 2024-02-23  8:39 UTC (permalink / raw)
  To: kexec
  Cc: HAGIO KAZUHITO(萩尾 一仁), Baoquan He,
	Hari Bathini, Mahesh J Salgaonkar, Sourabh Jain

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/87v8c3m70t.fsf@mail.lhotse/, 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

Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
---
 arch/ppc64.c   | 15 ++++++++++-----
 makedumpfile.c |  1 +
 makedumpfile.h |  9 ++++++---
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/arch/ppc64.c b/arch/ppc64.c
index 96c357cb0335..3b4f91981f71 100644
--- a/arch/ppc64.c
+++ b/arch/ppc64.c
@@ -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;
 		}
 	}
 
diff --git a/makedumpfile.c b/makedumpfile.c
index 3705bdd93deb..1bd7305f49ca 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -2987,6 +2987,7 @@ read_vmcoreinfo(void)
 #endif
 
 	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
+	READ_NUMBER("RADIX_MMU", RADIX_MMU);
 
 	return TRUE;
 }
diff --git a/makedumpfile.h b/makedumpfile.h
index 3ed3ba551d96..a7b344974636 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -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 {
-- 
2.43.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] makedumpfile: ppc64: read cur_mmu_type from vmcoreinfo
  2024-02-23  8:39 Aditya Gupta
@ 2024-02-28  0:25 ` HAGIO KAZUHITO(萩尾 一仁)
  2024-02-28  9:37   ` Aditya Gupta
  0 siblings, 1 reply; 6+ messages in thread
From: HAGIO KAZUHITO(萩尾 一仁) @ 2024-02-28  0:25 UTC (permalink / raw)
  To: Aditya Gupta, kexec@lists.infradead.org
  Cc: Baoquan He, Hari Bathini, Mahesh J Salgaonkar, Sourabh Jain

On 2024/02/23 17:39, Aditya Gupta wrote:
> 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/87v8c3m70t.fsf@mail.lhotse/, 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
> 
> Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>

Thanks, applied.
https://github.com/makedumpfile/makedumpfile/commit/71ac00c8a3464608ac19f7c89d7220073d7374a9

Kazu

> ---
>   arch/ppc64.c   | 15 ++++++++++-----
>   makedumpfile.c |  1 +
>   makedumpfile.h |  9 ++++++---
>   3 files changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/ppc64.c b/arch/ppc64.c
> index 96c357cb0335..3b4f91981f71 100644
> --- a/arch/ppc64.c
> +++ b/arch/ppc64.c
> @@ -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;
>   		}
>   	}
>   
> diff --git a/makedumpfile.c b/makedumpfile.c
> index 3705bdd93deb..1bd7305f49ca 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -2987,6 +2987,7 @@ read_vmcoreinfo(void)
>   #endif
>   
>   	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
> +	READ_NUMBER("RADIX_MMU", RADIX_MMU);
>   
>   	return TRUE;
>   }
> diff --git a/makedumpfile.h b/makedumpfile.h
> index 3ed3ba551d96..a7b344974636 100644
> --- a/makedumpfile.h
> +++ b/makedumpfile.h
> @@ -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 {
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] makedumpfile: ppc64: read cur_mmu_type from vmcoreinfo
  2024-02-28  0:25 ` HAGIO KAZUHITO(萩尾 一仁)
@ 2024-02-28  9:37   ` Aditya Gupta
  0 siblings, 0 replies; 6+ messages in thread
From: Aditya Gupta @ 2024-02-28  9:37 UTC (permalink / raw)
  To: HAGIO KAZUHITO(萩尾 一仁)
  Cc: kexec@lists.infradead.org, Baoquan He, Hari Bathini,
	Mahesh J Salgaonkar, Sourabh Jain

Hi Kazu,

On Wed, Feb 28, 2024 at 12:25:04AM +0000, HAGIO KAZUHITO(萩尾 一仁) wrote:
> On 2024/02/23 17:39, Aditya Gupta wrote:
> > 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/87v8c3m70t.fsf@mail.lhotse/, 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
> > 
> > Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
> 
> Thanks, applied.
> https://github.com/makedumpfile/makedumpfile/commit/71ac00c8a3464608ac19f7c89d7220073d7374a9

Thank you.

- Aditya Gupta

> 
> Kazu
> 
> > ---
> >   arch/ppc64.c   | 15 ++++++++++-----
> >   makedumpfile.c |  1 +
> >   makedumpfile.h |  9 ++++++---
> >   3 files changed, 17 insertions(+), 8 deletions(-)
> > 
> > diff --git a/arch/ppc64.c b/arch/ppc64.c
> > index 96c357cb0335..3b4f91981f71 100644
> > --- a/arch/ppc64.c
> > +++ b/arch/ppc64.c
> > @@ -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;
> >   		}
> >   	}
> >   
> > diff --git a/makedumpfile.c b/makedumpfile.c
> > index 3705bdd93deb..1bd7305f49ca 100644
> > --- a/makedumpfile.c
> > +++ b/makedumpfile.c
> > @@ -2987,6 +2987,7 @@ read_vmcoreinfo(void)
> >   #endif
> >   
> >   	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
> > +	READ_NUMBER("RADIX_MMU", RADIX_MMU);
> >   
> >   	return TRUE;
> >   }
> > diff --git a/makedumpfile.h b/makedumpfile.h
> > index 3ed3ba551d96..a7b344974636 100644
> > --- a/makedumpfile.h
> > +++ b/makedumpfile.h
> > @@ -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 {

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-28  9:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-23  5:53 [PATCH] makedumpfile: ppc64: read cur_mmu_type from vmcoreinfo Aditya Gupta
2024-02-23  7:54 ` Baoquan He
2024-02-23  8:37   ` Aditya Gupta
  -- strict thread matches above, loose matches on Subject: below --
2024-02-23  8:39 Aditya Gupta
2024-02-28  0:25 ` HAGIO KAZUHITO(萩尾 一仁)
2024-02-28  9:37   ` Aditya Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox