Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Amit Machhiwal" <amachhiw@linux.ibm.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v7 2/4] KVM: PPC: Book3S HV: Implement compat CPU capability retrieval for KVM on PowerVM
Date: Thu, 06 Aug 2026 17:25:48 +0000	[thread overview]
Message-ID: <20260806172549.50A9E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806170645.11892-3-amachhiw@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] KVM_CAP_PPC_COMPAT_CAPS incorrectly advertises support on non-nestedv2 pseries hosts, but KVM_PPC_GET_COMPAT_CAPS unconditionally fails with -EINVAL.
--

--- Patch [2]: [PATCH v7 2/4] KVM: PPC: Book3S HV: Implement compat CPU capability retrieval for KVM on PowerVM ---
commit 7fc253c4f6dbfb301a4c2d7a89c141048079da6c
Author: Amit Machhiwal <amachhiw@linux.ibm.com>

    KVM: PPC: Book3S HV: Implement compat CPU capability retrieval for KVM on PowerVM
    
    On POWER systems, the host CPU may run in a compatibility mode (e.g., a
    Power11 processor operating in Power10 compatibility mode). In such
    cases, the effective CPU level exposed to guests differs from the
    physical processor generation. This patch exposes host CPU compatibility
    mode capabilities to userspace for nested KVM guests via a new ioctl.

> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 61dbeea317f3b..8799124b80960 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -6510,6 +6510,25 @@ static bool kvmppc_hash_v3_possible(void)
>  	return true;
>  }
>  
> +
> +static int kvmppc_get_compat_caps(struct kvm_ppc_compat_caps *host_caps)
> +{
> +	unsigned long capabilities = 0;
> +	long rc = -EINVAL;
> +
> +	if (kvmhv_on_pseries()) {
> +		if (kvmhv_is_nestedv2()) {
> +			WARN_ON_ONCE(!nested_capabilities);
> +			capabilities = nested_capabilities;
> +			rc = 0;
> +		}
> +	}
> +
> +	host_caps->compat_capabilities = capabilities & KVM_PPC_COMPAT_BITMASK;
> +
> +	return rc;
> +}

[Severity: High]
Does this code break guest initialization on non-nestedv2 pseries hosts?

In arch/powerpc/kvm/powerpc.c, kvm_vm_ioctl_check_extension() advertises
KVM_CAP_PPC_COMPAT_CAPS support on all pseries hosts:

    case KVM_CAP_PPC_COMPAT_CAPS:
        r = 0;
        if (hv_enabled && kvmhv_on_pseries())
            r = 1;
        break;

But here in kvmppc_get_compat_caps(), if kvmhv_on_pseries() is true and
kvmhv_is_nestedv2() is false, rc remains -EINVAL.

When userspace (like QEMU) sees the capability is supported, it will call the
KVM_PPC_GET_COMPAT_CAPS ioctl. Receiving an unexpected -EINVAL here causes
QEMU to fail VM initialization, breaking guest boots on standard pseries
hosts.

Should the check extension logic be updated to also require
kvmhv_is_nestedv2(), or should this function handle non-nestedv2 pseries
hosts without returning an error?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806170645.11892-1-amachhiw@linux.ibm.com?part=2

  reply	other threads:[~2026-08-06 17:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 17:06 [PATCH v7 0/4] KVM: PPC: Expose CPU compatibility modes for nested guests Amit Machhiwal
2026-08-06 17:06 ` [PATCH v7 1/4] KVM: PPC: Introduce KVM_CAP_PPC_COMPAT_CAPS and wire up ioctl Amit Machhiwal
2026-08-06 17:20   ` sashiko-bot
2026-08-07  3:08   ` Ritesh Harjani
2026-08-07 10:55     ` Amit Machhiwal
2026-08-07 11:36       ` Ritesh Harjani
2026-08-07 12:15         ` Ritesh Harjani
2026-08-07 13:04         ` Amit Machhiwal
2026-08-06 17:06 ` [PATCH v7 2/4] KVM: PPC: Book3S HV: Implement compat CPU capability retrieval for KVM on PowerVM Amit Machhiwal
2026-08-06 17:25   ` sashiko-bot [this message]
2026-08-07  4:31   ` Ritesh Harjani
2026-08-07 10:58     ` Amit Machhiwal
2026-08-06 17:06 ` [PATCH v7 3/4] KVM: PPC: Book3S HV: Add support for compat CPU capabilities for KVM on PowerNV Amit Machhiwal
2026-08-07  4:54   ` Ritesh Harjani
2026-08-07 12:07     ` Amit Machhiwal
2026-08-07 12:13       ` Ritesh Harjani
2026-08-06 17:06 ` [PATCH v7 4/4] KVM: PPC: Document KVM_PPC_GET_COMPAT_CAPS ioctl Amit Machhiwal
2026-08-06 17:29   ` sashiko-bot
2026-08-07  4:35   ` Ritesh Harjani
2026-08-07 13:36     ` Amit Machhiwal

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=20260806172549.50A9E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=amachhiw@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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