[PATCH] makedumpfile: ppc64: read cur_mmu_type from vmcoreinfo
HAGIO KAZUHITO(萩尾 一仁)
k-hagio-ab at nec.com
Tue Feb 27 16:25:04 PST 2024
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 at 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 {
More information about the kexec
mailing list