@samitouri / QOSamiQemu / commits / 16c955cb31

target/ppc/kvm: Use host compatibility mode for nested guests

On POWER systems, the host CPU may run in a compatibility mode (e.g., a Power11 processor operating in Power10 compatibility mode). When running nested KVM guests, QEMU currently derives the host CPU type using mfpvr(), which reflects the physical processor version. This can result in a mismatch between the CPU model used by QEMU and the compatibility mode enforced by the host, leading to guest boot failures such as "KVM-NESTEDv2: couldn't set guest wide elements". Update kvm_ppc_get_host_cpu_class() to check if the host is running in a compatibility mode using kvm_ppc_host_compat_pvr(). When available, use the compatibility PVR instead of the raw hardware PVR when selecting the CPU model. This ensures that QEMU selects a CPU model consistent with the host compatibility mode, allowing nested guests to boot correctly. The guard uses #if defined(TARGET_PPC64) to prevent build breakage on ppc32 targets where the POWER9/10/11 PVR constants are not defined. Tested-by: Gautam Menghani <gautam@linux.ibm.com> Reviewed-by: Gautam Menghani <gautam@linux.ibm.com> Tested-by: Anushree Mathur <anushree.mathur@linux.ibm.com> Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260812170854.58709-4-amachhiw@linux.ibm.com Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>

Amit Machhiwal committed Aug 12, 2026 at 22:38 UTC 16c955cb31e008dbde42be399eda48271db2498a
1 file changed +9
target/ppc/kvm.c
+9
@@ -2682,6 +2682,15 @@ PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
2682 uint32_t host_pvr = mfpvr();
2683 PowerPCCPUClass *pvr_pcc;
2684
2685 +#if defined(TARGET_PPC64)
2686 + uint32_t compat_host_pvr;
2687 +
2688 + compat_host_pvr = kvm_ppc_host_compat_pvr();
2689 + if (compat_host_pvr) {
2690 + host_pvr = compat_host_pvr;
2691 + }
2692 +#endif /* TARGET_PPC64 */
2693 +
2694 pvr_pcc = ppc_cpu_class_by_pvr(host_pvr);
2695 if (pvr_pcc == NULL) {
2696 pvr_pcc = ppc_cpu_class_by_pvr_mask(host_pvr);