powerpc: add `cur_cpu_spec` symbol to vmcoreinfo
PATCH v2 1/2 powerpc: add `cur_cpu_spec` symbol to vmcoreinfo
Since below commit, address mapping for vmemmap has changed for Radix MMU, where address mapping is stored in kernel page table itself, instead of earlier used 'vmemmap_list'.
commit 368a0590d954 ("powerpc/book3s64/vmemmap: switch radix to use a different vmemmap handling function")
Hence with upstream kernel, in case of Radix MMU, makedumpfile fails to do address translation for vmemmap addresses, as it depended on vmemmap_list, which can now be empty.
While fixing the address translation in makedumpfile, it was identified that currently makedumpfile cannot distinguish between Hash MMU and Radix MMU, unless VMLINUX is passed with -x flag to makedumpfile. And hence fails to assign offsets and shifts correctly (such as in L4 to PGDIR offset calculation in makedumpfile).
For getting the MMU, makedumpfile uses cur_cpu_spec.mmu_features.
Add cur_cpu_spec symbol and offset of mmu_features in the cpu_spec struct, to VMCOREINFO, so that makedumpfile can assign the offsets correctly, without needing a VMLINUX.
---
Corresponding makedumpfile patches to fix address translation, in Radix MMU case:
---
--- arch/powerpc/kexec/core.c | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/kexec/core.c +2 -0
@@ -63,6 +63,8 @@ void arch_crash_save_vmcoreinfo(void)#ifndef CONFIG_NUMA VMCOREINFO_SYMBOL (contig_page_data);#endif +VMCOREINFO_SYMBOL (cur_cpu_spec); +VMCOREINFO_OFFSET (cpu_spec, mmu_features);#if defined(CONFIG_PPC64 ) && defined(CONFIG_SPARSEMEM_VMEMMAP )VMCOREINFO_SYMBOL (vmemmap_list);VMCOREINFO_SYMBOL (mmu_vmemmap_psize);
Signature · 1 line
2.41.0
PATCH v2 2/2 powerpc: add cpu_spec.cpu_features to vmcoreinfo
CPU features can be determined in makedumpfile, using 'cur_cpu_spec.cpu_features'.
This provides more data to makedumpfile about the crashed system, and can help in filtering the vmcore accordingly.
--- arch/powerpc/kexec/core.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kexec/core.c +1 -0
@@ -64,6 +64,7 @@ void arch_crash_save_vmcoreinfo(void)VMCOREINFO_SYMBOL (contig_page_data);#endif VMCOREINFO_SYMBOL (cur_cpu_spec); +VMCOREINFO_OFFSET (cpu_spec, cpu_features);VMCOREINFO_OFFSET (cpu_spec, mmu_features);#if defined(CONFIG_PPC64 ) && defined(CONFIG_SPARSEMEM_VMEMMAP )VMCOREINFO_SYMBOL (vmemmap_list);
Signature · 1 line
2.41.0
Quoted 44 lines · Aditya Gupta
Since below commit, address mapping for vmemmap has changed for Radix MMU, where address mapping is stored in kernel page table itself, instead of earlier used '
vmemmap_list'.commit
368a0590d954("powerpc/book3s64/vmemmap: switch radix to use a different vmemmap handling function")Hence with upstream kernel, in case of Radix MMU, makedumpfile fails to do address translation for vmemmap addresses, as it depended on
vmemmap_list, which can now be empty.While fixing the address translation in makedumpfile, it was identified that currently makedumpfile cannot distinguish between Hash MMU and Radix MMU, unless VMLINUX is passed with -x flag to makedumpfile. And hence fails to assign offsets and shifts correctly (such as in L4 to PGDIR offset calculation in makedumpfile).
For getting the MMU, makedumpfile uses
cur_cpu_spec.mmu_features.Add
cur_cpu_specsymbol and offset ofmmu_featuresin thecpu_specstruct, to VMCOREINFO, so that makedumpfile can assign the offsets correctly, without needing a VMLINUX.Fixes 368a0590d954 ("powerpc/book3s64/vmemmap: switch radix to use a different vmemmap handling function")Reported-by Sachin Sant <[email protected]>Tested-by Sachin Sant <[email protected]>Signed-off-by Aditya Gupta <[email protected]>---
Corresponding makedumpfile patches to fix address translation, in Radix MMU case:---
--- arch/powerpc/kexec/core.c | 2 ++ 1 file changed, 2 insertions(+)arch/powerpc/kexec/core.c +0
-0
arch/powerpc/kexec/core.c void arch_crash_save_vmcoreinfo(void) · line 70
Quoted 8 lines
arch/powerpc/kexec/core.c +2
-0@@ -63,6 +63,8 @@ void arch_crash_save_vmcoreinfo(void)#ifndef CONFIG_NUMA VMCOREINFO_SYMBOL (contig_page_data);#endif +VMCOREINFO_SYMBOL (cur_cpu_spec); +VMCOREINFO_OFFSET (cpu_spec, mmu_features);#if defined(CONFIG_PPC64 ) && defined(CONFIG_SPARSEMEM_VMEMMAP )VMCOREINFO_SYMBOL (vmemmap_list);VMCOREINFO_SYMBOL (mmu_vmemmap_psize);
That implies we now have to be careful when updating MMU_FTR_* #defines. It is not bad considering other hacks we do in crash to identify kernel changes tied to version number. But i am wondering if there another way to identify radix vs hash?
-aneesh
Quoted 51 lines · Aneesh Kumar K.V
Quoted 49 lines · Aditya Gupta
Since below commit, address mapping for vmemmap has changed for Radix MMU, where address mapping is stored in kernel page table itself, instead of earlier used '
vmemmap_list'.commit
368a0590d954("powerpc/book3s64/vmemmap: switch radix to use a different vmemmap handling function")Hence with upstream kernel, in case of Radix MMU, makedumpfile fails to do address translation for vmemmap addresses, as it depended on
vmemmap_list, which can now be empty.While fixing the address translation in makedumpfile, it was identified that currently makedumpfile cannot distinguish between Hash MMU and Radix MMU, unless VMLINUX is passed with -x flag to makedumpfile. And hence fails to assign offsets and shifts correctly (such as in L4 to PGDIR offset calculation in makedumpfile).
For getting the MMU, makedumpfile uses
cur_cpu_spec.mmu_features.Add
cur_cpu_specsymbol and offset ofmmu_featuresin thecpu_specstruct, to VMCOREINFO, so that makedumpfile can assign the offsets correctly, without needing a VMLINUX.Fixes 368a0590d954 ("powerpc/book3s64/vmemmap: switch radix to use a different vmemmap handling function")Reported-by Sachin Sant <[email protected]>Tested-by Sachin Sant <[email protected]>Signed-off-by Aditya Gupta <[email protected]>---
Corresponding makedumpfile patches to fix address translation, in Radix MMU case:---
--- arch/powerpc/kexec/core.c | 2 ++ 1 file changed, 2 insertions(+)arch/powerpc/kexec/core.c +2
-0@@ -63,6 +63,8 @@ void arch_crash_save_vmcoreinfo(void)#ifndef CONFIG_NUMA VMCOREINFO_SYMBOL (contig_page_data);#endif +VMCOREINFO_SYMBOL (cur_cpu_spec); +VMCOREINFO_OFFSET (cpu_spec, mmu_features);#if defined(CONFIG_PPC64 ) && defined(CONFIG_SPARSEMEM_VMEMMAP )
Quoted 9 lines
arch/powerpc/kexec/core.c void arch_crash_save_vmcoreinfo(void) · line 70
Quoted 3 lines
arch/powerpc/kexec/core.c +0
-0VMCOREINFO_SYMBOL (vmemmap_list);VMCOREINFO_SYMBOL (mmu_vmemmap_psize);That implies we now have to be careful when updating MMU_FTR_* #defines. It is not bad considering other hacks we do in crash to identify kernel changes tied to version number. But i am wondering if there another way to identify radix vs hash?
I could not find another way to get any other flag for RADIX vs HASH in makedumpfile. And currently I don't know of any other way.
Both makedumpfile and crash look for '0x40' flag set in 'cur_cpu_spec.mmu_features', so only requirement for 'MMU_FTR_TYPE_RADIX' is to be '0x40', or we will need to change the value accordingly in the tools.
Thanks,
- Aditya Gupta
Quoted 62 lines · Aditya Gupta
Quoted 51 lines · Aneesh Kumar K.V
Quoted 49 lines · Aditya Gupta
Since below commit, address mapping for vmemmap has changed for Radix MMU, where address mapping is stored in kernel page table itself, instead of earlier used '
vmemmap_list'.commit
368a0590d954("powerpc/book3s64/vmemmap: switch radix to use a different vmemmap handling function")Hence with upstream kernel, in case of Radix MMU, makedumpfile fails to do address translation for vmemmap addresses, as it depended on
vmemmap_list, which can now be empty.While fixing the address translation in makedumpfile, it was identified that currently makedumpfile cannot distinguish between Hash MMU and Radix MMU, unless VMLINUX is passed with -x flag to makedumpfile. And hence fails to assign offsets and shifts correctly (such as in L4 to PGDIR offset calculation in makedumpfile).
For getting the MMU, makedumpfile uses
cur_cpu_spec.mmu_features.Add
cur_cpu_specsymbol and offset ofmmu_featuresin thecpu_specstruct, to VMCOREINFO, so that makedumpfile can assign the offsets correctly, without needing a VMLINUX.Fixes 368a0590d954 ("powerpc/book3s64/vmemmap: switch radix to use a different vmemmap handling function")Reported-by Sachin Sant <[email protected]>Tested-by Sachin Sant <[email protected]>Signed-off-by Aditya Gupta <[email protected]>---
Corresponding makedumpfile patches to fix address translation, in Radix MMU case:---
--- arch/powerpc/kexec/core.c | 2 ++ 1 file changed, 2 insertions(+)arch/powerpc/kexec/core.c +2
-0@@ -63,6 +63,8 @@ void arch_crash_save_vmcoreinfo(void)#ifndef CONFIG_NUMA VMCOREINFO_SYMBOL (contig_page_data);#endif +VMCOREINFO_SYMBOL (cur_cpu_spec); +VMCOREINFO_OFFSET (cpu_spec, mmu_features);#if defined(CONFIG_PPC64 ) && defined(CONFIG_SPARSEMEM_VMEMMAP )Quoted 9 lines
arch/powerpc/kexec/core.c void arch_crash_save_vmcoreinfo(void) · line 70
Quoted 3 lines
arch/powerpc/kexec/core.c +0
-0VMCOREINFO_SYMBOL (vmemmap_list);VMCOREINFO_SYMBOL (mmu_vmemmap_psize);That implies we now have to be careful when updating MMU_FTR_* #defines. It is not bad considering other hacks we do in crash to identify kernel changes tied to version number. But i am wondering if there another way to identify radix vs hash?
Quoted 7 lines
I could not find another way to get any other flag for RADIX vs HASH in makedumpfile. And currently I don't know of any other way.
Both makedumpfile and crash look for '
0x40' flag set in 'cur_cpu_spec.mmu_features', so only requirement for 'MMU_FTR_TYPE_RADIX' is to be '0x40', or we will need to change the value accordingly in the tools.
Instead of exporting cur_cpu_spec.mmu_feature, you could do coreinfo_mmu_features that does
if (radix_enabled())
coreinfo_mmu_feature = VMCORE_INFO_RADIX_TRANSLATION;
-aneesh
Michael Ellerman
reviewerQuoted 70 lines · Aneesh Kumar K.V
Quoted 62 lines · Aditya Gupta
Quoted 51 lines · Aneesh Kumar K.V
Quoted 49 lines · Aditya Gupta
Since below commit, address mapping for vmemmap has changed for Radix MMU, where address mapping is stored in kernel page table itself, instead of earlier used '
vmemmap_list'.commit
368a0590d954("powerpc/book3s64/vmemmap: switch radix to use a different vmemmap handling function")Hence with upstream kernel, in case of Radix MMU, makedumpfile fails to do address translation for vmemmap addresses, as it depended on
vmemmap_list, which can now be empty.While fixing the address translation in makedumpfile, it was identified that currently makedumpfile cannot distinguish between Hash MMU and Radix MMU, unless VMLINUX is passed with -x flag to makedumpfile. And hence fails to assign offsets and shifts correctly (such as in L4 to PGDIR offset calculation in makedumpfile).
For getting the MMU, makedumpfile uses
cur_cpu_spec.mmu_features.Add
cur_cpu_specsymbol and offset ofmmu_featuresin thecpu_specstruct, to VMCOREINFO, so that makedumpfile can assign the offsets correctly, without needing a VMLINUX.Fixes 368a0590d954 ("powerpc/book3s64/vmemmap: switch radix to use a different vmemmap handling function")Reported-by Sachin Sant <[email protected]>Tested-by Sachin Sant <[email protected]>Signed-off-by Aditya Gupta <[email protected]>---
Corresponding makedumpfile patches to fix address translation, in Radix MMU case:---
--- arch/powerpc/kexec/core.c | 2 ++ 1 file changed, 2 insertions(+)arch/powerpc/kexec/core.c +2
-0@@ -63,6 +63,8 @@ void arch_crash_save_vmcoreinfo(void)#ifndef CONFIG_NUMA VMCOREINFO_SYMBOL (contig_page_data);#endif +VMCOREINFO_SYMBOL (cur_cpu_spec); +VMCOREINFO_OFFSET (cpu_spec, mmu_features);#if defined(CONFIG_PPC64 ) && defined(CONFIG_SPARSEMEM_VMEMMAP )Quoted 9 lines
arch/powerpc/kexec/core.c void arch_crash_save_vmcoreinfo(void) · line 70
Quoted 3 lines
arch/powerpc/kexec/core.c +0
-0VMCOREINFO_SYMBOL (vmemmap_list);VMCOREINFO_SYMBOL (mmu_vmemmap_psize);That implies we now have to be careful when updating MMU_FTR_* #defines. It is not bad considering other hacks we do in crash to identify kernel changes tied to version number. But i am wondering if there another way to identify radix vs hash?
Quoted 6 lines
I could not find another way to get any other flag for RADIX vs HASH in makedumpfile. And currently I don't know of any other way.
Both makedumpfile and crash look for '
0x40' flag set in 'cur_cpu_spec.mmu_features', so only requirement for 'MMU_FTR_TYPE_RADIX' is to be '0x40', or we will need to change the value accordingly in the tools.
Quoted 5 lines
Instead of exporting cur_cpu_spec.mmu_feature, you could do
coreinfo_mmu_featuresthat doesif (
radix_enabled())
coreinfo_mmu_feature=VMCORE_INFO_RADIX_TRANSLATION;
On other arches they seem to use vmcoreinfo_append_str() for more things than we do on powerpc.
eg. x86:
vmcoreinfo_append_str("NUMBER(pgtable_l5_enabled)=%d\n", pgtable_l5_enabled());Could we do something like that instead:
vmcoreinfo_append_str("RADIX_MMU=%d\n", early_radix_enabled());cheers
Michael Ellerman
reviewerQuoted 40 lines · Aneesh Kumar K.V
Quoted 38 lines · Aditya Gupta
Since below commit, address mapping for vmemmap has changed for Radix MMU, where address mapping is stored in kernel page table itself, instead of earlier used '
vmemmap_list'.commit
368a0590d954("powerpc/book3s64/vmemmap: switch radix to use a different vmemmap handling function")Hence with upstream kernel, in case of Radix MMU, makedumpfile fails to do address translation for vmemmap addresses, as it depended on
vmemmap_list, which can now be empty.While fixing the address translation in makedumpfile, it was identified that currently makedumpfile cannot distinguish between Hash MMU and Radix MMU, unless VMLINUX is passed with -x flag to makedumpfile. And hence fails to assign offsets and shifts correctly (such as in L4 to PGDIR offset calculation in makedumpfile).
For getting the MMU, makedumpfile uses
cur_cpu_spec.mmu_features.Add
cur_cpu_specsymbol and offset ofmmu_featuresin thecpu_specstruct, to VMCOREINFO, so that makedumpfile can assign the offsets correctly, without needing a VMLINUX.Fixes 368a0590d954 ("powerpc/book3s64/vmemmap: switch radix to use a different vmemmap handling function")Reported-by Sachin Sant <[email protected]>Tested-by Sachin Sant <[email protected]>Signed-off-by Aditya Gupta <[email protected]>---
Corresponding makedumpfile patches to fix address translation, in Radix MMU case:---
--- arch/powerpc/kexec/core.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 16 lines
Quoted 6 lines
arch/powerpc/kexec/core.c +0
-0arch/powerpc/kexec/core.c void arch_crash_save_vmcoreinfo(void) · line 70
Quoted 8 lines
arch/powerpc/kexec/core.c +2
-0@@ -63,6 +63,8 @@ void arch_crash_save_vmcoreinfo(void)#ifndef CONFIG_NUMA VMCOREINFO_SYMBOL (contig_page_data);#endif +VMCOREINFO_SYMBOL (cur_cpu_spec); +VMCOREINFO_OFFSET (cpu_spec, mmu_features);#if defined(CONFIG_PPC64 ) && defined(CONFIG_SPARSEMEM_VMEMMAP )VMCOREINFO_SYMBOL (vmemmap_list);VMCOREINFO_SYMBOL (mmu_vmemmap_psize);That implies we now have to be careful when updating MMU_FTR_* #defines.
Yeah, that's a good point.
Quoted 3 lines
It is not bad considering other hacks we do in crash to identify kernel changes tied to version number. But i am wondering if there another way to identify radix vs hash?
Ultimately crash just has to accept that the kernel will change over time, and some times crash will have to adapt.
We can try not to change values unnecessarily, but given the knowledge of kernel internals crash has there will be breakage from time to time.
The only other alternative I think is to create a well defined data structure that is explicitly provided by the kernel for crash with various information in a set format. With a committment that the data structure will be maintained in a forward-compatible manner. Which sounds like a bunch of work :)
cheers
Quoted 8 lines · Aditya Gupta
Since below commit, address mapping for vmemmap has changed for Radix MMU, where address mapping is stored in kernel page table itself, instead of earlier used '
vmemmap_list'.commit
368a0590d954("powerpc/book3s64/vmemmap: switch radix to use a different vmemmap handling function")[...]
Patch 2 applied to powerpc/next.
[2/2] powerpc: add cpu_spec.cpu_features to vmcoreinfo
https://git.kernel.org/powerpc/c/a143892cb77c5397fd4356bbef9982abe4f3c5a5
cheers