linux-stable/arch/powerpc/kvm
Amit Machhiwal 20c8c4dafe KVM: PPC: Book3S HV: Fix L2 guest reboot failure due to empty 'arch_compat'
Currently, rebooting a pseries nested qemu-kvm guest (L2) results in
below error as L1 qemu sends PVR value 'arch_compat' == 0 via
ppc_set_compat ioctl. This triggers a condition failure in
kvmppc_set_arch_compat() resulting in an EINVAL.

qemu-system-ppc64: Unable to set CPU compatibility mode in KVM: Invalid
argument

Also, a value of 0 for arch_compat generally refers the default
compatibility of the host. But, arch_compat, being a Guest Wide Element
in nested API v2, cannot be set to 0 in GSB as PowerVM (L0) expects a
non-zero value. A value of 0 triggers a kernel trap during a reboot and
consequently causes it to fail:

[   22.106360] reboot: Restarting system
KVM: unknown exit, hardware reason ffffffffffffffea
NIP 0000000000000100   LR 000000000000fe44 CTR 0000000000000000 XER 0000000020040092 CPU#0
MSR 0000000000001000 HID0 0000000000000000  HF 6c000000 iidx 3 didx 3
TB 00000000 00000000 DECR 0
GPR00 0000000000000000 0000000000000000 c000000002a8c300 000000007fe00000
GPR04 0000000000000000 0000000000000000 0000000000001002 8000000002803033
GPR08 000000000a000000 0000000000000000 0000000000000004 000000002fff0000
GPR12 0000000000000000 c000000002e10000 0000000105639200 0000000000000004
GPR16 0000000000000000 000000010563a090 0000000000000000 0000000000000000
GPR20 0000000105639e20 00000001056399c8 00007fffe54abab0 0000000105639288
GPR24 0000000000000000 0000000000000001 0000000000000001 0000000000000000
GPR28 0000000000000000 0000000000000000 c000000002b30840 0000000000000000
CR 00000000  [ -  -  -  -  -  -  -  -  ]     RES 000@ffffffffffffffff
 SRR0 0000000000000000  SRR1 0000000000000000    PVR 0000000000800200 VRSAVE 0000000000000000
SPRG0 0000000000000000 SPRG1 0000000000000000  SPRG2 0000000000000000  SPRG3 0000000000000000
SPRG4 0000000000000000 SPRG5 0000000000000000  SPRG6 0000000000000000  SPRG7 0000000000000000
HSRR0 0000000000000000 HSRR1 0000000000000000
 CFAR 0000000000000000
 LPCR 0000000000020400
 PTCR 0000000000000000   DAR 0000000000000000  DSISR 0000000000000000

 kernel:trap=0xffffffea | pc=0x100 | msr=0x1000

This patch updates kvmppc_set_arch_compat() to use the host PVR value if
'compat_pvr' == 0 indicating that qemu doesn't want to enforce any
specific PVR compat mode.

The relevant part of the code might need a rework if PowerVM implements
a support for `arch_compat == 0` in nestedv2 API.

Fixes: 19d31c5f11 ("KVM: PPC: Add support for nestedv2 guests")
Reviewed-by: "Aneesh Kumar K.V (IBM)" <aneesh.kumar@kernel.org>
Reviewed-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240207054526.3720087-1-amachhiw@linux.ibm.com
2024-02-20 22:32:20 +11:00
..
Kconfig KVM: introduce CONFIG_KVM_COMMON 2024-01-08 08:09:38 -05:00
Makefile KVM: PPC: Add support for nestedv2 guests 2023-09-14 22:04:24 +10:00
book3s.c KVM: PPC: Book3S HV nestedv2: Do not inject certain interrupts 2023-12-07 23:33:07 +11:00
book3s.h
book3s_32_mmu.c
book3s_32_mmu_host.c
book3s_32_sr.S
book3s_64_entry.S docs: move powerpc under arch 2023-10-10 13:35:55 -06:00
book3s_64_mmu.c
book3s_64_mmu_host.c KVM: Rename mmu_notifier_* to mmu_invalidate_* 2022-08-19 04:05:41 -04:00
book3s_64_mmu_hv.c KVM: PPC: Book3s HV: Hold LPIDs in an unsigned long 2023-09-14 22:04:24 +10:00
book3s_64_mmu_radix.c KVM: PPC: Book3S HV nestedv2: Do not call H_COPY_TOFROM_GUEST 2023-12-07 23:33:08 +11:00
book3s_64_slb.S
book3s_64_vio.c Kill sched.h dependency on rcupdate.h 2023-12-27 11:50:20 -05:00
book3s_emulate.c
book3s_exports.c
book3s_hv.c KVM: PPC: Book3S HV: Fix L2 guest reboot failure due to empty 'arch_compat' 2024-02-20 22:32:20 +11:00
book3s_hv.h KVM: PPC: Add support for nestedv2 guests 2023-09-14 22:04:24 +10:00
book3s_hv_builtin.c KVM: PPC: Book3S HV: Introduce low level MSR accessor 2023-09-14 22:04:24 +10:00
book3s_hv_hmi.c
book3s_hv_interrupts.S powerpc: Fix objtool unannotated intra-function call warnings 2022-11-15 20:11:47 +11:00
book3s_hv_nested.c KVM: PPC: Book3S HV nestedv2: Invalidate RPT before deleting a guest 2023-12-07 23:33:07 +11:00
book3s_hv_nestedv2.c KVM: PPC: Book3S HV: Fix L2 guest reboot failure due to empty 'arch_compat' 2024-02-20 22:32:20 +11:00
book3s_hv_p9_entry.c KVM: PPC: Use accessors for VCPU registers 2023-09-14 22:04:24 +10:00
book3s_hv_p9_perf.c
book3s_hv_ras.c KVM: PPC: Use accessors for VCORE registers 2023-09-14 22:04:24 +10:00
book3s_hv_rm_mmu.c KVM: PPC: Always use the GPR accessors 2023-09-14 22:04:23 +10:00
book3s_hv_rm_xics.c KVM: PPC: Always use the GPR accessors 2023-09-14 22:04:23 +10:00
book3s_hv_rmhandlers.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
book3s_hv_tm.c
book3s_hv_tm_builtin.c
book3s_hv_uvmem.c KVM: PPC: Book3s HV: Hold LPIDs in an unsigned long 2023-09-14 22:04:24 +10:00
book3s_interrupts.S
book3s_mmu_hpte.c
book3s_paired_singles.c KVM: PPC: Make kvmppc_get_last_inst() produce a ppc_inst_t 2023-04-03 15:45:41 +10:00
book3s_pr.c powerpc: Add PVN support for HeXin C2000 processor 2023-12-01 21:15:33 +11:00
book3s_pr_papr.c KVM: remove KVM_REQ_UNHALT 2022-09-26 12:37:21 -04:00
book3s_rmhandlers.S KVM: PPC: Enable prefixed instructions for HV KVM and disable for PR KVM 2023-04-03 15:45:59 +10:00
book3s_rtas.c
book3s_segment.S
book3s_xics.c
book3s_xics.h
book3s_xive.c KVM: PPC: Book3s HV: Hold LPIDs in an unsigned long 2023-09-14 22:04:24 +10:00
book3s_xive.h powerpc/xive: remove unused parameter 2022-11-24 23:12:18 +11:00
book3s_xive_native.c powerpc: Use NULL instead of 0 for null pointers 2023-10-19 17:12:47 +11:00
booke.c KVM: PPC: Fetch prefixed instructions from the guest 2023-04-03 15:45:50 +10:00
booke.h KVM: PPC: BookE: Fix W=1 warnings 2023-04-03 14:54:20 +10:00
booke_emulate.c
booke_interrupts.S powerpc: Remove CONFIG_FSL_BOOKE 2022-09-26 22:47:37 +10:00
bookehv_interrupts.S KVM: PPC: Fetch prefixed instructions from the guest 2023-04-03 15:45:50 +10:00
e500.c KVM: Drop kvm_arch_check_processor_compat() hook 2022-12-29 15:41:28 -05:00
e500.h powerpc: Remove CONFIG_PPC_BOOK3E_MMU 2022-09-26 23:00:14 +10:00
e500_emulate.c
e500_mmu.c
e500_mmu_host.c KVM: PPC: Fetch prefixed instructions from the guest 2023-04-03 15:45:50 +10:00
e500_mmu_host.h
e500mc.c powerpc/inst: add PPC_TLBILX_LPID 2023-08-16 23:54:48 +10:00
emulate.c KVM: PPC: Fetch prefixed instructions from the guest 2023-04-03 15:45:50 +10:00
emulate_loadstore.c KVM: PPC: Reduce reliance on analyse_instr() in mmio emulation 2023-12-07 23:33:08 +11:00
fpu.S powerpc/32: Fix objtool unannotated intra-function call warnings 2022-11-18 19:00:06 +11:00
guest-state-buffer.c KVM: PPC: Add support for nestedv2 guests 2023-09-14 22:04:24 +10:00
mpic.c
powerpc.c Common KVM changes for 6.8: 2024-01-08 08:09:57 -05:00
test-guest-state-buffer.c KVM: PPC: Add helper library for Guest State Buffers 2023-09-14 22:04:24 +10:00
timing.c
timing.h
tm.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
trace.h
trace_book3s.h
trace_booke.h
trace_hv.h
trace_pr.h