All of lore.kernel.org
 help / color / mirror / Atom feed
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>,
	qemu-devel@nongnu.org
Subject: [PATCH v2 1/3] hw/ppc/spapr: Do not fallback to raw mode when KVM rejects compat
Date: Sat,  2 May 2026 19:30:19 +0530	[thread overview]
Message-ID: <20260502140021.69712-2-amachhiw@linux.ibm.com> (raw)
In-Reply-To: <20260502140021.69712-1-amachhiw@linux.ibm.com>

During H_CLIENT_ARCHITECTURE_SUPPORT, QEMU attempts to set the requested
CPU compatibility mode via ppc_set_compat_all(). If this fails, the
existing code may fall back to raw mode when supported by the guest.

The current logic treats all failures uniformly and tried to fall back
to raw mode whenever possible. As a result, errors from KVM (e.g.
kvmppc_set_compat() returning -EINVAL) are silently masked, making
debugging difficult and allowing the guest to proceed with an
unsupported or incompatible configuration.

When running with KVM, such failures indicate that the requested
compatibility level is not supported by the host. Do not fallback in
this case; instead, report the error and fail the CAS negotiation.

This makes the failure visible to the user and ensures that invalid
compatibility requests are rejected early rather than being hidden by
fallback behavior. For example, the following error is now reported:

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

Fixes: cc7b35b169e9 ("spapr: fallback to raw mode if best compat mode cannot be set during CAS")
Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
---
 hw/ppc/spapr_hcall.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 032805a8d0db..de2ea6f5e579 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1204,6 +1204,15 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,
         Error *local_err = NULL;
 
         if (ppc_set_compat_all(cas_pvr, &local_err) < 0) {
+            /*
+             * If KVM rejected the compat mode, do not fallback. This indicates
+             * the host cannot support the requested level.
+             */
+            if (kvm_enabled()) {
+                error_report_err(local_err);
+                return H_HARDWARE;
+            }
+
             /* We fail to set compat mode (likely because running with KVM PR),
              * but maybe we can fallback to raw mode if the guest supports it.
              */
-- 
2.50.1 (Apple Git-155)



  reply	other threads:[~2026-05-02 14:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-02 14:00 [PATCH v2 0/3] ppc/kvm: Handle CPU compatibility mode correctly for nested guests Amit Machhiwal
2026-05-02 14:00 ` Amit Machhiwal [this message]
2026-05-02 14:00 ` [PATCH v2 2/3] [DO_NOT_MERGE] linux-headers: Add uapi header changes Amit Machhiwal
2026-05-02 14:00 ` [PATCH v2 3/3] target/ppc/kvm: Use host compatibility mode for nested guests Amit Machhiwal
2026-05-15 10:52 ` [PATCH v2 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=20260502140021.69712-2-amachhiw@linux.ibm.com \
    --to=amachhiw@linux.ibm.com \
    --cc=harshpb@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.