This adds a new powerpc-specific KVM_CAP_SPAPR_RESIZE_HPT capability to advertise whether KVM is capable of handling the PAPR extensions for resizing the hashed page table during guest runtime.
At present, HPT resizing is possible with KVM PR without kernel modification, since the HPT is managed within qemu. It's not possible yet with KVM HV, because the HPT is managed by KVM. At present, qemu has to use other capabilities which (by accident) reveal whether PR or HV is in use to know if it can advertise HPT resizing capability to the guest. To avoid ambiguity with existing kernels, the encoding is a bit odd. 0 means "unknown" since that's what previous kernels will return 1 means "HPT resize possible if available if and only if the HPT is allocated in userspace, rather than in the kernel". In practice this is the same test as userspace already uses, but this makes it explicit. 2 will mean "HPT resize available and implemented in-kernel" For now we always return 1, but the intention is to return 2 once HPT resize is implemented for KVM HV. Signed-off-by: David Gibson <da...@gibson.dropbear.id.au> --- arch/powerpc/kvm/powerpc.c | 3 +++ include/uapi/linux/kvm.h | 1 + 2 files changed, 4 insertions(+) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 1803c96..55ab059 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -587,6 +587,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) case KVM_CAP_SPAPR_MULTITCE: r = 1; break; + case KVM_CAP_SPAPR_RESIZE_HPT: + r = 1; /* resize allowed only if HPT is outside kernel */ + break; #endif default: r = 0; diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index a7f1f80..5374bd8 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -865,6 +865,7 @@ struct kvm_ppc_smmu_info { #define KVM_CAP_SPAPR_TCE_64 125 #define KVM_CAP_ARM_PMU_V3 126 #define KVM_CAP_VCPU_ATTRIBUTES 127 +#define KVM_CAP_SPAPR_RESIZE_HPT 128 #ifdef KVM_CAP_IRQ_ROUTING -- 2.5.0 _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev