qemu/target/ppc
Narayana Murty N 93c691a003 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

Fixes: 5609400a42 ("target/ppc: Set the correct endianness for powernv memory
dumps")
Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Message-ID: <20230623072506.34713-1-nnmlinux@linux.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2023-07-07 04:46:12 -03:00
..
translate target/ppc: Inline gen_icount_io_start() 2023-06-05 12:04:29 -07:00
arch_dump.c target: ppc: Use MSR_HVB bit to get the target endianness for memory dump 2023-07-07 04:46:12 -03:00
compat.c powerpc tcg: Fix Lesser GPL version number 2020-11-15 16:38:50 +01:00
cpu_init.c target/ppc: Add TFMR SPR implementation with read and write helpers 2023-07-07 04:18:26 -03:00
cpu-models.c target/ppc: Add POWER9 DD2.2 model 2023-05-28 13:25:11 -03:00
cpu-models.h target/ppc: Add POWER9 DD2.2 model 2023-05-28 13:25:11 -03:00
cpu-param.h target/ppc: Remove NB_MMU_MODES define 2023-03-13 06:44:37 -07:00
cpu-qom.h target/ppc: Restrict 'qapi-commands-machine.h' to system emulation 2023-03-02 07:51:33 +01:00
cpu.c ppc: spapr: cleanup cr get/set with helpers. 2023-05-05 12:34:22 -03:00
cpu.h target/ppc: Restrict KVM-specific fields from ArchCPU 2023-06-28 14:27:59 +02:00
dfp_helper.c target/ppc: Fix warning with clang-15 2023-02-27 22:29:01 +01:00
excp_helper.c target/ppc: Get CPUState in one step 2023-07-07 04:46:12 -03:00
fpu_helper.c target/ppc: Merge COMPUTE_CLASS and COMPUTE_FPRF 2023-05-28 07:13:54 -03:00
gdbstub.c target/ppc: gdbstub init spr gdb_id for all CPUs 2023-06-25 22:41:30 +02:00
helper_regs.c target: Widen pc/cs_base in cpu_get_tb_cpu_state 2023-06-26 17:32:59 +02:00
helper_regs.h target/ppc: Fix PMU hflags calculation 2023-06-10 10:19:24 -03:00
helper.h target/ppc: Add TFMR SPR implementation with read and write helpers 2023-07-07 04:18:26 -03:00
insn32.decode target/ppc: Fix fallback to MFSS for MFFS* instructions on pre 3.0 ISAs 2023-05-27 08:25:19 -03:00
insn64.decode target/ppc: Implemented [pm]xvbf16ger2* 2022-05-26 17:11:33 -03:00
int_helper.c target/ppc: Move VABSDU[BHW] to decodetree and use gvec 2022-10-28 13:15:22 -03:00
internal.h target/ppc/internal: Restrict MMU declarations to sysemu 2023-02-27 22:29:01 +01:00
Kconfig meson: Introduce target-specific Kconfig 2021-07-09 18:21:34 +02:00
kvm_ppc.h spapr: Add SPAPR_CAP_AIL_MODE_3 for AIL mode 3 support for H_SET_MODE hcall 2023-05-28 07:13:54 -03:00
kvm-stub.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
kvm.c target/ppc: Fix timer register accessors when !KVM 2023-06-25 22:41:30 +02:00
machine.c target/ppc: Fix PMU hflags calculation 2023-06-10 10:19:24 -03:00
mem_helper.c target/ppc: Use tcg_gen_qemu_{ld,st}_i128 for LQARX, LQ, STQ 2023-05-23 16:51:19 -07:00
meson.build target/ppc: Only generate decodetree files when TCG is enabled 2023-07-07 04:18:26 -03:00
misc_helper.c target/ppc: Add msgsnd/p and DPDES SMT support 2023-06-25 22:41:30 +02:00
mmu_common.c target/ppc: Restrict KVM-specific fields from ArchCPU 2023-06-28 14:27:59 +02:00
mmu_helper.c target/ppc: Move ppcemb_tlb_search() to mmu_common.c 2023-06-10 10:19:24 -03:00
mmu-book3s-v3.c ppc: Check partition and process table alignment 2022-07-18 13:59:43 -03:00
mmu-book3s-v3.h target/ppc: Implement ISA 3.00 tlbie[l] 2022-07-18 13:59:43 -03:00
mmu-books.h target/ppc: introduce mmu-books.h 2021-07-09 10:38:19 +10:00
mmu-hash32.c bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
mmu-hash32.h target/ppc: Remove PowerPC 601 CPUs 2022-02-09 09:08:55 +01:00
mmu-hash64.c bulk: Rename TARGET_FMT_plx -> HWADDR_FMT_plx 2023-01-18 11:14:34 +01:00
mmu-hash64.h target/ppc: fix Hash64 MMU update of PTE bit R 2021-11-29 21:00:08 +01:00
mmu-radix64.c target/ppc: Add SRR1 prefix indication to interrupt handlers 2023-06-25 22:41:30 +02:00
mmu-radix64.h target/ppc: Check effective address validity 2022-01-04 07:55:34 +01:00
power8-pmu-regs.c.inc target/ppc: Inline gen_icount_io_start() 2023-06-05 12:04:29 -07:00
power8-pmu.c target/ppc: PMU implement PERFM interrupts 2023-06-10 10:19:24 -03:00
power8-pmu.h target/ppc: Fix PMU hflags calculation 2023-06-10 10:19:24 -03:00
ppc-qmp-cmds.c ppc: spapr: cleanup cr get/set with helpers. 2023-05-05 12:34:22 -03:00
spr_common.h target/ppc: Add TFMR SPR implementation with read and write helpers 2023-07-07 04:18:26 -03:00
tcg-stub.c target/ppc: created tcg-stub.c file 2021-06-03 13:22:06 +10:00
timebase_helper.c target/ppc: Add TFMR SPR implementation with read and write helpers 2023-07-07 04:18:26 -03:00
trace-events target/ppc: Improve KVM hypercall trace 2022-04-20 18:00:30 -03:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
translate.c target/ppd: Remove unused define 2023-07-07 04:46:12 -03:00
user_only_helper.c target/ppc: Implement ppc_cpu_record_sigsegv 2021-11-02 07:00:52 -04:00