Messages in this thread |  | | Date | Tue, 5 May 2026 14:16:00 +0530 | | Subject | Re: [PATCH 3/6] KVM: PPC: Wire up KVM_PPC_GET_COMPAT_CAPS ioctl | | From | Harsh Prateek Bora <> |
| |
On 30/04/26 11:19 am, Amit Machhiwal wrote: > Add handling for KVM_PPC_GET_COMPAT_CAPS in kvm_arch_vm_ioctl() and > advertise support via KVM_CAP_PPC_COMPAT_CAPS. > > The ioctl retrieves host CPU compatibility capabilities via a > PowerPC-specific backend implementation when available. If the > capability is not supported, the ioctl returns success with no > capabilities set, allowing userspace to fall back gracefully. > > Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com> > --- > arch/powerpc/include/asm/kvm_ppc.h | 1 + > arch/powerpc/kvm/powerpc.c | 19 +++++++++++++++++++ > 2 files changed, 20 insertions(+) > > diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h > index 0953f2daa466..cadfb839e836 100644 > --- a/arch/powerpc/include/asm/kvm_ppc.h > +++ b/arch/powerpc/include/asm/kvm_ppc.h > @@ -319,6 +319,7 @@ struct kvmppc_ops { > bool (*hash_v3_possible)(void); > int (*create_vm_debugfs)(struct kvm *kvm); > int (*create_vcpu_debugfs)(struct kvm_vcpu *vcpu, struct dentry *debugfs_dentry); > + int (*get_compat_cpu_ver)(struct kvm_ppc_compat_caps *host_caps); > }; > > extern struct kvmppc_ops *kvmppc_hv_ops; > diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c > index 00302399fc37..f35017d83d77 100644 > --- a/arch/powerpc/kvm/powerpc.c > +++ b/arch/powerpc/kvm/powerpc.c > @@ -697,6 +697,12 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) > } > } > break; > +#if defined(CONFIG_KVM_BOOK3S_HV_POSSIBLE) > + case KVM_CAP_PPC_COMPAT_CAPS: > + if (kvmhv_on_pseries())
What about PowerNV ? Also, can't we just check if get_compat_cpu_ver is initialized and return accordingly ?
> + r = 1; > + break; > +#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ > default: > r = 0; > break; > @@ -2463,6 +2469,19 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) > r = kvm->arch.kvm_ops->svm_off(kvm); > break; > } > + case KVM_PPC_GET_COMPAT_CAPS: { > + struct kvm_ppc_compat_caps host_caps; > + > + memset(&host_caps, 0, sizeof(host_caps)); > + if (!kvm->arch.kvm_ops->get_compat_cpu_ver) > + goto out;
I guess we want to init r = 0 before returning in this case. Also prefer break over goto unless really needed.
> + > + r = kvm->arch.kvm_ops->get_compat_cpu_ver(&host_caps); > + if (!r && copy_to_user(argp, &host_caps, > + sizeof(host_caps))) > + r = -EFAULT; > + break; > + } > default: { > struct kvm *kvm = filp->private_data; > r = kvm->arch.kvm_ops->arch_vm_ioctl(filp, ioctl, arg);
|  |