* [PATCH v4] target: ppc: Use MSR_HVB bit to get the target endianness for memory dump
@ 2023-06-23 7:25 Narayana Murty N
2023-07-01 10:26 ` Nicholas Piggin
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Narayana Murty N @ 2023-06-23 7:25 UTC (permalink / raw)
To: danielhb413, clg, david, groug, npiggin
Cc: qemu-ppc, qemu-devel, farosas, npiggin, vaibhav, harshpb, sbhat,
nnmlinux
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
Fixes: 5609400a4228 ("target/ppc: Set the correct endianness for powernv memory
dumps")
Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
---
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/20230420145055.10196-1-nnmlinux@linux.ibm.com/
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(-)
diff --git a/target/ppc/arch_dump.c b/target/ppc/arch_dump.c
index f58e6359d5..a8315659d9 100644
--- a/target/ppc/arch_dump.c
+++ b/target/ppc/arch_dump.c
@@ -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;
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4] target: ppc: Use MSR_HVB bit to get the target endianness for memory dump
2023-06-23 7:25 [PATCH v4] target: ppc: Use MSR_HVB bit to get the target endianness for memory dump Narayana Murty N
@ 2023-07-01 10:26 ` Nicholas Piggin
2023-07-03 9:35 ` Greg Kurz
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2023-07-01 10:26 UTC (permalink / raw)
To: Narayana Murty N, danielhb413, clg, david, groug
Cc: qemu-ppc, qemu-devel, farosas, npiggin, vaibhav, harshpb, sbhat
On Fri Jun 23, 2023 at 5:25 PM AEST, Narayana Murty N wrote:
> 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
>
> Fixes: 5609400a4228 ("target/ppc: Set the correct endianness for powernv memory
> dumps")
> Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
Did I forget to send RB? It looks good to me now, thanks for clearing
up my confusion.
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Thanks,
Nick
> ---
> 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/20230420145055.10196-1-nnmlinux@linux.ibm.com/
> 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(-)
>
> diff --git a/target/ppc/arch_dump.c b/target/ppc/arch_dump.c
> index f58e6359d5..a8315659d9 100644
> --- a/target/ppc/arch_dump.c
> +++ b/target/ppc/arch_dump.c
> @@ -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;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] target: ppc: Use MSR_HVB bit to get the target endianness for memory dump
2023-06-23 7:25 [PATCH v4] target: ppc: Use MSR_HVB bit to get the target endianness for memory dump Narayana Murty N
2023-07-01 10:26 ` Nicholas Piggin
@ 2023-07-03 9:35 ` Greg Kurz
2023-07-03 13:50 ` Daniel Henrique Barboza
2023-07-04 7:48 ` Vaibhav Jain
3 siblings, 0 replies; 5+ messages in thread
From: Greg Kurz @ 2023-07-03 9:35 UTC (permalink / raw)
To: Narayana Murty N
Cc: danielhb413, clg, david, npiggin, qemu-ppc, qemu-devel, farosas,
npiggin, vaibhav, harshpb, sbhat
On Fri, 23 Jun 2023 03:25:06 -0400
Narayana Murty N <nnmlinux@linux.ibm.com> wrote:
> 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
>
> Fixes: 5609400a4228 ("target/ppc: Set the correct endianness for powernv memory
> dumps")
> Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
> ---
Thanks !
Reviewed-by: Greg Kurz <groug@kaod.org>
> 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/20230420145055.10196-1-nnmlinux@linux.ibm.com/
> 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(-)
>
> diff --git a/target/ppc/arch_dump.c b/target/ppc/arch_dump.c
> index f58e6359d5..a8315659d9 100644
> --- a/target/ppc/arch_dump.c
> +++ b/target/ppc/arch_dump.c
> @@ -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;
--
Greg
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] target: ppc: Use MSR_HVB bit to get the target endianness for memory dump
2023-06-23 7:25 [PATCH v4] target: ppc: Use MSR_HVB bit to get the target endianness for memory dump Narayana Murty N
2023-07-01 10:26 ` Nicholas Piggin
2023-07-03 9:35 ` Greg Kurz
@ 2023-07-03 13:50 ` Daniel Henrique Barboza
2023-07-04 7:48 ` Vaibhav Jain
3 siblings, 0 replies; 5+ messages in thread
From: Daniel Henrique Barboza @ 2023-07-03 13:50 UTC (permalink / raw)
To: Narayana Murty N, clg, david, groug, npiggin
Cc: qemu-ppc, qemu-devel, farosas, npiggin, vaibhav, harshpb, sbhat
Queued in gitlab.com/danielhb/qemu/tree/ppc-next. Thanks,
Daniel
On 6/23/23 04:25, Narayana Murty N wrote:
> 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
>
> Fixes: 5609400a4228 ("target/ppc: Set the correct endianness for powernv memory
> dumps")
> Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
> ---
> 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/20230420145055.10196-1-nnmlinux@linux.ibm.com/
> 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(-)
>
> diff --git a/target/ppc/arch_dump.c b/target/ppc/arch_dump.c
> index f58e6359d5..a8315659d9 100644
> --- a/target/ppc/arch_dump.c
> +++ b/target/ppc/arch_dump.c
> @@ -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;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] target: ppc: Use MSR_HVB bit to get the target endianness for memory dump
2023-06-23 7:25 [PATCH v4] target: ppc: Use MSR_HVB bit to get the target endianness for memory dump Narayana Murty N
` (2 preceding siblings ...)
2023-07-03 13:50 ` Daniel Henrique Barboza
@ 2023-07-04 7:48 ` Vaibhav Jain
3 siblings, 0 replies; 5+ messages in thread
From: Vaibhav Jain @ 2023-07-04 7:48 UTC (permalink / raw)
To: Narayana Murty N, danielhb413, clg, david, groug, npiggin
Cc: qemu-ppc, qemu-devel, farosas, npiggin, harshpb, sbhat, nnmlinux
Thanks for fixing this Narayana,
Narayana Murty N <nnmlinux@linux.ibm.com> writes:
> 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
>
> Fixes: 5609400a4228 ("target/ppc: Set the correct endianness for powernv memory
> dumps")
> Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
Reviewed-by: Vaibhav Jain<vaibhav@linux.ibm.com>
--
Cheers
~ Vaibhav
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-04 7:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-23 7:25 [PATCH v4] target: ppc: Use MSR_HVB bit to get the target endianness for memory dump Narayana Murty N
2023-07-01 10:26 ` Nicholas Piggin
2023-07-03 9:35 ` Greg Kurz
2023-07-03 13:50 ` Daniel Henrique Barboza
2023-07-04 7:48 ` Vaibhav Jain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).