public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Harsh Prateek Bora <harshpb@linux.ibm.com>
To: Amit Machhiwal <amachhiw@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org,
	Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Vaibhav Jain <vaibhav@linux.ibm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/6] KVM: PPC: Introduce KVM_CAP_PPC_COMPAT_CAPS and KVM_PPC_GET_COMPAT_CAPS
Date: Tue, 5 May 2026 14:01:44 +0530	[thread overview]
Message-ID: <8c72bee5-664d-4ecc-b4c5-03f825febc75@linux.ibm.com> (raw)
In-Reply-To: <20260430054906.94431-3-amachhiw@linux.ibm.com>



On 30/04/26 11:19 am, Amit Machhiwal wrote:
> Introduce a new capability and ioctl to expose CPU compatibility modes
> supported by the host processor for nested guests.
> 
> Introduce a new KVM capability, KVM_CAP_PPC_COMPAT_CAPS, and a
> corresponding vm ioctl, KVM_PPC_GET_COMPAT_CAPS, to expose processor
> compatibility modes supported by the host.
> 
> On IBM POWER systems, newer processor generations (N) can operate in
> compatibility modes corresponding to earlier generations, like (N-1) and
> (N-2). This is particularly relevant for nested virtualization, where
> nested KVM guests may need to run with a specific processor compatibility
> level.
> 
> The new ioctl returns a bitmap describing the compatibility modes
> supported by the host in respective bit numbers. This allows userspace
> to select an appropriate compatibility level when configuring nested KVM
> guests.
> 
> Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
> ---
>   arch/powerpc/include/uapi/asm/kvm.h | 6 ++++++
>   include/uapi/linux/kvm.h            | 4 ++++
>   2 files changed, 10 insertions(+)
> 
> diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/include/uapi/asm/kvm.h
> index 077c5437f521..a38dff7a8aea 100644
> --- a/arch/powerpc/include/uapi/asm/kvm.h
> +++ b/arch/powerpc/include/uapi/asm/kvm.h
> @@ -437,6 +437,12 @@ struct kvm_ppc_cpu_char {
>   	__u64	behaviour_mask;		/* valid bits in behaviour */
>   };
>   
> +/* For KVM_PPC_GET_COMPAT_CAPS */
> +struct kvm_ppc_compat_caps {
> +	__u32	flags;

You may either want flags to be __u64, or rearrange to keep variables in 
descending order of size or add padding as appropriate.
Also, if we are not using flags with this series, we need to document 
comment as /* reserved for future use */

> +	__u64	compat_capabilities;	/* Capabilities supported by the host */
> +};
> +
>   /*
>    * Values for character and character_mask.
>    * These are identical to the values used by H_GET_CPU_CHARACTERISTICS.
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> index 6c8afa2047bf..1788a0068662 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -996,6 +996,7 @@ struct kvm_enable_cap {
>   #define KVM_CAP_S390_USER_OPEREXEC 246
>   #define KVM_CAP_S390_KEYOP 247
>   #define KVM_CAP_S390_VSIE_ESAMODE 248
> +#define KVM_CAP_PPC_COMPAT_CAPS 249
>   
>   struct kvm_irq_routing_irqchip {
>   	__u32 irqchip;
> @@ -1349,6 +1350,9 @@ struct kvm_s390_keyop {
>   #define KVM_GET_DEVICE_ATTR	  _IOW(KVMIO,  0xe2, struct kvm_device_attr)
>   #define KVM_HAS_DEVICE_ATTR	  _IOW(KVMIO,  0xe3, struct kvm_device_attr)
>   
> +/* Available with KVM_CAP_PPC_COMPAT_CAPS */
> +#define KVM_PPC_GET_COMPAT_CAPS	_IOR(KVMIO,  0xe4, struct kvm_ppc_compat_caps)
> +


This patch can actually be squashed with next patch where the struct, 
macros are actually being used.

>   /*
>    * ioctls for vcpu fds
>    */


  reply	other threads:[~2026-05-05  8:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30  5:48 [PATCH 0/6] KVM: PPC: Handle CPU compatibility mode for nested guests Amit Machhiwal
2026-04-30  5:49 ` [PATCH 1/6] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode Amit Machhiwal
2026-05-05  6:44   ` Harsh Prateek Bora
2026-04-30  5:49 ` [PATCH 2/6] KVM: PPC: Introduce KVM_CAP_PPC_COMPAT_CAPS and KVM_PPC_GET_COMPAT_CAPS Amit Machhiwal
2026-05-05  8:31   ` Harsh Prateek Bora [this message]
2026-04-30  5:49 ` [PATCH 3/6] KVM: PPC: Wire up KVM_PPC_GET_COMPAT_CAPS ioctl Amit Machhiwal
2026-05-05  8:46   ` Harsh Prateek Bora
2026-04-30  5:49 ` [PATCH 4/6] KVM: PPC: Book3S HV: Implement compat CPU capability retrieval for KVM on PowerVM Amit Machhiwal
2026-05-05  9:25   ` Harsh Prateek Bora
2026-04-30  5:49 ` [PATCH 5/6] KVM: PPC: Book3S HV: Add support for compat CPU capabilities for KVM on PowerNV Amit Machhiwal
2026-05-05  9:49   ` Harsh Prateek Bora
2026-04-30  5:49 ` [PATCH 6/6] KVM: PPC: Document KVM_PPC_GET_COMPAT_CAPS ioctl Amit Machhiwal
2026-05-05  9:55   ` Harsh Prateek Bora

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=8c72bee5-664d-4ecc-b4c5-03f825febc75@linux.ibm.com \
    --to=harshpb@linux.ibm.com \
    --cc=amachhiw@linux.ibm.com \
    --cc=chleroy@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=pbonzini@redhat.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