target: ppc: Use MSR_HVB bit to get the target endianness for memory dump
PATCH v4 1/1 target: ppc: Use MSR_HVB bit to get the target endianness for memory dump
Currently on PPC64 qemu always dumps the guest memory in Big Endian (BE) format even though the guest running in Little Endian (LE) mode. So crash tool fails to load the dump as illustrated below:
Log :
$ virsh dump DOMAIN --memory-only dump.file
Domain 'DOMAIN' dumped to dump.file
$ crash vmlinux dump.file
<snip>
crash 8.0.2-1.el9
WARNING: endian mismatch:
crash utility: little-endian
dump.file: big-endian
WARNING: machine type mismatch:
crash utility: PPC64
dump.file: (unknown)
crash: dump.file: not a supported file format
<snip>
This happens because cpu_get_dump_info() passes cpu->env->has_hv_mode to function ppc_interrupts_little_endian(), the cpu->env->has_hv_mode always set for powerNV even though the guest is not running in hv mode. The hv mode should be taken from msr_mask MSR_HVB bit (cpu->env.msr_mask & MSR_HVB). This patch fixes the issue by passing MSR_HVB value to ppc_interrupts_little_endian() in order to determine the guest endianness.
The crash tool also expects guest kernel endianness should match the endianness of the dump.
The patch was tested on POWER9 box booted with Linux as host in following cases:
Host-Endianess Qemu-Target-Machine Qemu-Generated-Guest
Memory-Dump-Format
BE powernv(OPAL/PowerNV) LE BE powernv(OPAL/PowerNV) BE LE powernv(OPAL/PowerNV) LE LE powernv(OPAL/PowerNV) BE LE pseries(OPAL/PowerNV/pSeries) KVMHV LE LE pseries TCG LE
dumps")
---
Changes since V3:
commit message modified as per feedback from Greg Kurz, Cédric Le Goater and Nicholas Piggin.
Changes since V2:
commit message modified as per feedback from Nicholas Piggin. Changes since V1:
https://lore.kernel.org/qemu-devel/[email protected]/
The approach to solve the issue was changed based on feedback from Fabiano Rosas on patch V1.
--- target/ppc/arch_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/arch_dump.c +1 -1
@@ -237,7 +237,7 @@ int cpu_get_dump_info(ArchDumpInfo *info, info->d_machine =PPC_ELF_MACHINE ; info->d_class =ELFCLASS ; -if (ppc_interrupts_little_endian (cpu, cpu->env.has_hv_mode)) { +if (ppc_interrupts_little_endian (cpu, !!(cpu->env.msr_mask &MSR_HVB ))) { info->d_endian =ELFDATA2LSB ; }else { info->d_endian =ELFDATA2MSB ;
Signature · 1 line
2.39.2
Quoted 48 lines · Narayana Murty N
Currently on PPC64 qemu always dumps the guest memory in Big Endian (BE) format even though the guest running in Little Endian (LE) mode. So crash tool fails to load the dump as illustrated below:
Log :
$ virsh dump DOMAIN --memory-only dump.fileDomain 'DOMAIN' dumped to dump.file
$ crash vmlinux dump.file<snip>
crash 8.0.2-1.el9WARNING: endian mismatch:
crash utility: little-endian
dump.file: big-endianWARNING: machine type mismatch:
crash utility: PPC64
dump.file: (unknown)crash: dump.file: not a supported file format
<snip>This happens because
cpu_get_dump_info()passescpu->env->has_hv_modeto functionppc_interrupts_little_endian(), thecpu->env->has_hv_modealways set for powerNV even though the guest is not running in hv mode. The hv mode should be taken frommsr_maskMSR_HVBbit (cpu->env.msr_mask&MSR_HVB). This patch fixes the issue by passingMSR_HVBvalue toppc_interrupts_little_endian()in order to determine the guest endianness.The crash tool also expects guest kernel endianness should match the endianness of the dump.
The patch was tested on POWER9 box booted with Linux as host in following cases:
Host-Endianess Qemu-Target-Machine Qemu-Generated-Guest
Memory-Dump-FormatBE powernv(OPAL/PowerNV) LE BE powernv(OPAL/PowerNV) BE LE powernv(OPAL/PowerNV) LE LE powernv(OPAL/PowerNV) BE LE pseries(OPAL/PowerNV/pSeries) KVMHV LE LE pseries TCG LE
Quoted 3 lines
Fixes 5609400a4228 ("target/ppc: Set the correct endianness for powernv memorydumps")
Signed-off-by Narayana Murty N <[email protected]>
Did I forget to send RB? It looks good to me now, thanks for clearing up my confusion.
Thanks,
Nick
Quoted 27 lines
---
Changes since V3:
commit message modified as per feedback from Greg Kurz, Cédric Le Goater and Nicholas Piggin.
Changes since V2:
commit message modified as per feedback from Nicholas Piggin. Changes since V1:
https://lore.kernel.org/qemu-devel/[email protected]/
The approach to solve the issue was changed based on feedback from Fabiano Rosas on patch V1.--- target/ppc/arch_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/ppc/arch_dump.c +1
-1@@ -237,7 +237,7 @@ int cpu_get_dump_info(ArchDumpInfo *info, info->d_machine =PPC_ELF_MACHINE ; info->d_class =ELFCLASS ; -if (ppc_interrupts_little_endian (cpu, cpu->env.has_hv_mode)) { +if (ppc_interrupts_little_endian (cpu, !!(cpu->env.msr_mask &MSR_HVB ))) { info->d_endian =ELFDATA2LSB ; }else { info->d_endian =ELFDATA2MSB ;
Quoted 48 lines · On Fri, 23 Jun 2023 03:25:06 -0400 Narayana Murty N <[email protected]>…
Currently on PPC64 qemu always dumps the guest memory in Big Endian (BE) format even though the guest running in Little Endian (LE) mode. So crash tool fails to load the dump as illustrated below:
Log :
$ virsh dump DOMAIN --memory-only dump.fileDomain 'DOMAIN' dumped to dump.file
$ crash vmlinux dump.file<snip>
crash 8.0.2-1.el9WARNING: endian mismatch:
crash utility: little-endian
dump.file: big-endianWARNING: machine type mismatch:
crash utility: PPC64
dump.file: (unknown)crash: dump.file: not a supported file format
<snip>This happens because
cpu_get_dump_info()passescpu->env->has_hv_modeto functionppc_interrupts_little_endian(), thecpu->env->has_hv_modealways set for powerNV even though the guest is not running in hv mode. The hv mode should be taken frommsr_maskMSR_HVBbit (cpu->env.msr_mask&MSR_HVB). This patch fixes the issue by passingMSR_HVBvalue toppc_interrupts_little_endian()in order to determine the guest endianness.The crash tool also expects guest kernel endianness should match the endianness of the dump.
The patch was tested on POWER9 box booted with Linux as host in following cases:
Host-Endianess Qemu-Target-Machine Qemu-Generated-Guest
Memory-Dump-FormatBE powernv(OPAL/PowerNV) LE BE powernv(OPAL/PowerNV) BE LE powernv(OPAL/PowerNV) LE LE powernv(OPAL/PowerNV) BE LE pseries(OPAL/PowerNV/pSeries) KVMHV LE LE pseries TCG LE
Quoted 4 lines
Fixes 5609400a4228 ("target/ppc: Set the correct endianness for powernv memorydumps")
Signed-off-by Narayana Murty N <[email protected]>---
Thanks !
Quoted 26 lines
Changes since V3:
commit message modified as per feedback from Greg Kurz, Cédric Le Goater and Nicholas Piggin.
Changes since V2:
commit message modified as per feedback from Nicholas Piggin. Changes since V1:
https://lore.kernel.org/qemu-devel/[email protected]/
The approach to solve the issue was changed based on feedback from Fabiano Rosas on patch V1.--- target/ppc/arch_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/ppc/arch_dump.c +1
-1@@ -237,7 +237,7 @@ int cpu_get_dump_info(ArchDumpInfo *info, info->d_machine =PPC_ELF_MACHINE ; info->d_class =ELFCLASS ; -if (ppc_interrupts_little_endian (cpu, cpu->env.has_hv_mode)) { +if (ppc_interrupts_little_endian (cpu, !!(cpu->env.msr_mask &MSR_HVB ))) { info->d_endian =ELFDATA2LSB ; }else { info->d_endian =ELFDATA2MSB ;
Signature · 1 line
Greg
Daniel Henrique Barboza
AppliedQueued in gitlab.com/danielhb/qemu/tree/ppc-next. Thanks,
Daniel
Quoted 78 lines · Narayana Murty N
Currently on PPC64 qemu always dumps the guest memory in Big Endian (BE) format even though the guest running in Little Endian (LE) mode. So crash tool fails to load the dump as illustrated below:
Log :
$ virsh dump DOMAIN --memory-only dump.fileDomain 'DOMAIN' dumped to dump.file
$ crash vmlinux dump.file<snip>
crash 8.0.2-1.el9WARNING: endian mismatch:
crash utility: little-endian
dump.file: big-endianWARNING: machine type mismatch:
crash utility: PPC64
dump.file: (unknown)crash: dump.file: not a supported file format
<snip>This happens because
cpu_get_dump_info()passescpu->env->has_hv_modeto functionppc_interrupts_little_endian(), thecpu->env->has_hv_modealways set for powerNV even though the guest is not running in hv mode. The hv mode should be taken frommsr_maskMSR_HVBbit (cpu->env.msr_mask&MSR_HVB). This patch fixes the issue by passingMSR_HVBvalue toppc_interrupts_little_endian()in order to determine the guest endianness.The crash tool also expects guest kernel endianness should match the endianness of the dump.
The patch was tested on POWER9 box booted with Linux as host in following cases:
Host-Endianess Qemu-Target-Machine Qemu-Generated-Guest
Memory-Dump-FormatBE powernv(OPAL/PowerNV) LE BE powernv(OPAL/PowerNV) BE LE powernv(OPAL/PowerNV) LE LE powernv(OPAL/PowerNV) BE LE pseries(OPAL/PowerNV/pSeries) KVMHV LE LE pseries TCG LEFixes 5609400a4228 ("target/ppc: Set the correct endianness for powernv memorydumps")
Signed-off-by Narayana Murty N <[email protected]>---
Changes since V3:
commit message modified as per feedback from Greg Kurz, Cédric Le Goater and Nicholas Piggin.
Changes since V2:
commit message modified as per feedback from Nicholas Piggin. Changes since V1:
https://lore.kernel.org/qemu-devel/[email protected]/
The approach to solve the issue was changed based on feedback from Fabiano Rosas on patch V1.--- target/ppc/arch_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/ppc/arch_dump.c +1
-1@@ -237,7 +237,7 @@ int cpu_get_dump_info(ArchDumpInfo *info, info->d_machine =PPC_ELF_MACHINE ; info->d_class =ELFCLASS ; -if (ppc_interrupts_little_endian (cpu, cpu->env.has_hv_mode)) { +if (ppc_interrupts_little_endian (cpu, !!(cpu->env.msr_mask &MSR_HVB ))) { info->d_endian =ELFDATA2LSB ; }else { info->d_endian =ELFDATA2MSB ;
Thanks for fixing this Narayana,
Quoted 48 lines · Narayana Murty N
Currently on PPC64 qemu always dumps the guest memory in Big Endian (BE) format even though the guest running in Little Endian (LE) mode. So crash tool fails to load the dump as illustrated below:
Log :
$ virsh dump DOMAIN --memory-only dump.fileDomain 'DOMAIN' dumped to dump.file
$ crash vmlinux dump.file<snip>
crash 8.0.2-1.el9WARNING: endian mismatch:
crash utility: little-endian
dump.file: big-endianWARNING: machine type mismatch:
crash utility: PPC64
dump.file: (unknown)crash: dump.file: not a supported file format
<snip>This happens because
cpu_get_dump_info()passescpu->env->has_hv_modeto functionppc_interrupts_little_endian(), thecpu->env->has_hv_modealways set for powerNV even though the guest is not running in hv mode. The hv mode should be taken frommsr_maskMSR_HVBbit (cpu->env.msr_mask&MSR_HVB). This patch fixes the issue by passingMSR_HVBvalue toppc_interrupts_little_endian()in order to determine the guest endianness.The crash tool also expects guest kernel endianness should match the endianness of the dump.
The patch was tested on POWER9 box booted with Linux as host in following cases:
Host-Endianess Qemu-Target-Machine Qemu-Generated-Guest
Memory-Dump-FormatBE powernv(OPAL/PowerNV) LE BE powernv(OPAL/PowerNV) BE LE powernv(OPAL/PowerNV) LE LE powernv(OPAL/PowerNV) BE LE pseries(OPAL/PowerNV/pSeries) KVMHV LE LE pseries TCG LE
Quoted 3 lines
Fixes 5609400a4228 ("target/ppc: Set the correct endianness for powernv memorydumps")
Signed-off-by Narayana Murty N <[email protected]>
Signature · 2 lines
Cheers ~ Vaibhav