From: Amit Machhiwal <amachhiw@linux.ibm.com>
To: qemu-ppc@nongnu.org, Harsh Prateek Bora <harshpb@linux.ibm.com>
Cc: Amit Machhiwal <amachhiw@linux.ibm.com>,
Vaibhav Jain <vaibhav@linux.ibm.com>,
Nicholas Piggin <npiggin@gmail.com>,
Chinmay Rath <rathc@linux.ibm.com>,
Glenn Miles <milesg@linux.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Gautam Menghani <gautam@linux.ibm.com>,
kvm@vger.kernel.org, qemu-devel@nongnu.org
Subject: [PATCH v5 0/3] ppc/kvm: Handle CPU compatibility mode correctly for nested guests
Date: Tue, 4 Aug 2026 23:59:11 +0530 [thread overview]
Message-ID: <20260804182914.83091-1-amachhiw@linux.ibm.com> (raw)
On POWER systems, newer processor generations can operate in compatibility
modes corresponding to earlier generations (e.g., a Power11 system running
in Power10 compatibility mode). In such cases, the effective CPU level
exposed to guests differs from the physical processor generation.
This creates issues for nested virtualization. When booting a nested KVM
guest, QEMU may derive the CPU model from the raw hardware PVR and attempt
to configure the guest accordingly. However, the host is constrained by the
compatibility level negotiated with the hypervisor, and requests exceeding
that level are rejected by KVM, leading to guest boot failures such as:
KVM-NESTEDv2: couldn't set guest wide elements
This series addresses the issue by preventing fallback to raw mode when the
host itself is booted in a compatibility mode, and by querying the effective
CPU compatibility modes supported by the host via KVM. The kernel interface
uses copy_struct_from/to_user() for forward and backward ABI compatibility.
With these changes, QEMU ensures that nested guests are configured with CPU
models consistent with the host compatibility mode, allowing them to boot
correctly.
Patch summary:
[1/3] [DO_NOT_MERGE] linux-headers: Add uapi header changes
[2/3] target/ppc/kvm: Add support for querying host compatibility mode
[3/3] target/ppc/kvm: Use host compatibility mode for nested guests
Changes in v5:
- Patch 1: Updated KVM_PPC_GET_COMPAT_CAPS ioctl number from 0xe4 to
0xb8 to match the corresponding Linux kernel v6 series change; the
0xe0-0xe3 range is reserved for KVM_CREATE_DEVICE fd ioctls
Testing (with kernel v6 patches):
KVM APIv1 Testing
=================
On P10 PowerNV machine (L0)
---------------------------
- P10 L1 KVM guest -> works
- P10 nested L2 KVM guest -> works
- P9 compat nested L2 KVM guest -> works
- P9 compat L1 KVM guest -> works
- P9 nested L2 KVM guest -> works
On Powernv11 TCG Guest (L0)
---------------------------
- P11 PowerNV TCG L0 guest -> works
- P11 L1 KVM guest -> works
- P11 L2 KVM guest -> works
- P10 compat L1 KVM guest -> works
- P10 L2 KVM guest -> works
- P9 compat L1 KVM guest -> works
- P9 L2 KVM guest -> works
KVM APIv2 Testing
=================
On P11 PowerVM LPAR (L1)
------------------------
- P11 L2 KVM guest -> works
- P10 compat L2 KVM guest -> works
- P9 compat L2 KVM guest fails to boot as expected
- Without QEMU patches but Linux patches
- P11 L2 KVM guest -> works
- P10 compat L2 KVM guest -> works
- P9 compat L2 KVM guest fails to boot as expected
- Without Linux patches but QEMU patches
- P11 L2 KVM guest -> works
- P10 compat L2 KVM guest -> works
On P11 LPAR in P10 compat (L1)
------------------------------
- P10 (host compat) L2 KVM guest -> works
- Without QEMU patch but Linux patches
- P10 guest fails to boot as expected (error: kvm run failed Invalid argument)
- Without Linux patch but QEMU patches
- P10 guest fails to boot as expected (KVM: unknown exit, hardware reason ffffffffffffffea)
On P10 PowerVM LPAR (L1)
------------------------
- P10 L2 KVM guest -> works
- P9 compat L2 KVM guest fails to boot as expected
TCG pSeries Guest
=================
- P11 (default) pSeries guest boots fine
ABI Extensibility Testing (struct size 32, extra member)
=========================================================
- Newer struct on QEMU, older kernel -> works (kernel returns -E2BIG,
QEMU retries with correct size)
- New struct on Linux kernel, older QEMU -> works (kernel zero-pads
trailing fields, QEMU gets correct data)
Note: Patch 1 is marked DO_NOT_MERGE as it contains linux-headers updates
that will be synced separately once the corresponding kernel patches are
merged.
The corresponding Linux kernel patches (v6) are being posted concurrently.
v4: https://lore.kernel.org/all/20260701052341.62289-1-amachhiw@linux.ibm.com/
v3: https://lore.kernel.org/all/20260616113915.25589-1-amachhiw@linux.ibm.com/
v2: https://lore.kernel.org/all/20260502140021.69712-1-amachhiw@linux.ibm.com/
v1: https://lore.kernel.org/all/20260430061333.37905-1-amachhiw@linux.ibm.com/
Previous kernel patch versions:
v6: https://lore.kernel.org/all/20260804180705.59160-1-amachhiw@linux.ibm.com/
v5: https://lore.kernel.org/all/20260701051409.51820-1-amachhiw@linux.ibm.com/
v4: https://lore.kernel.org/all/20260616123314.82721-1-amachhiw@linux.ibm.com/
v3: https://lore.kernel.org/all/20260522152744.55251-1-amachhiw@linux.ibm.com/
v2: https://lore.kernel.org/all/20260513100755.83195-1-amachhiw@linux.ibm.com/
v1: https://lore.kernel.org/all/20260430054906.94401-1-amachhiw@linux.ibm.com/
Amit Machhiwal (3):
[DO_NOT_MERGE] linux-headers: Add uapi header changes
target/ppc/kvm: Add support for querying host compatibility mode
target/ppc/kvm: Use host compatibility mode for nested guests
hw/ppc/spapr_hcall.c | 14 ++++++
linux-headers/asm-powerpc/kvm.h | 19 +++++++
linux-headers/linux/kvm.h | 3 ++
target/ppc/kvm.c | 87 +++++++++++++++++++++++++++++++++
target/ppc/kvm_ppc.h | 7 +++
5 files changed, 130 insertions(+)
base-commit: b428fe036233cbd15d37e3c027ab6ca4d3661a80
--
2.50.1 (Apple Git-155)
next reply other threads:[~2026-08-04 18:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 18:29 Amit Machhiwal [this message]
2026-08-04 18:29 ` [PATCH v5 1/3] [DO_NOT_MERGE] linux-headers: Add uapi header changes Amit Machhiwal
2026-08-04 18:29 ` [PATCH v5 2/3] target/ppc/kvm: Add support for querying host compatibility mode Amit Machhiwal
2026-08-04 18:29 ` [PATCH v5 3/3] target/ppc/kvm: Use host compatibility mode for nested guests Amit Machhiwal
2026-08-04 19:55 ` BALATON Zoltan
2026-08-05 14:33 ` Amit Machhiwal
2026-08-05 8:25 ` [PATCH v5 0/3] ppc/kvm: Handle CPU compatibility mode correctly " Anushree Mathur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260804182914.83091-1-amachhiw@linux.ibm.com \
--to=amachhiw@linux.ibm.com \
--cc=gautam@linux.ibm.com \
--cc=harshpb@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=milesg@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rathc@linux.ibm.com \
--cc=vaibhav@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox