]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
KVM: PPC: Book3S HV: Add capability to report possible virtual SMT modes
authorPaul Mackerras <paulus@ozlabs.org>
Wed, 21 Jun 2017 06:01:27 +0000 (16:01 +1000)
committerPaul Mackerras <paulus@ozlabs.org>
Thu, 22 Jun 2017 01:25:31 +0000 (11:25 +1000)
Now that userspace can set the virtual SMT mode by enabling the
KVM_CAP_PPC_SMT capability, it is useful for userspace to be able
to query the set of possible virtual SMT modes.  This provides a
new capability, KVM_CAP_PPC_SMT_POSSIBLE, to provide this
information.  The return value is a bitmap of possible modes, with
bit N set if virtual SMT mode 2^N is available.  That is, 1 indicates
SMT1 is available, 2 indicates that SMT2 is available, 3 indicates
that both SMT1 and SMT2 are available, and so on.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Documentation/virtual/kvm/api.txt
arch/powerpc/kvm/powerpc.c
include/uapi/linux/kvm.h

index 1531a3cd548fa57e47c9138bae0d4d68b13d5c98..63875dbb6ef5dab29899ab0b81437747536c5cb5 100644 (file)
@@ -4010,6 +4010,8 @@ be 0.  A successful call to enable this capability will result in
 vsmt_mode being returned when the KVM_CAP_PPC_SMT capability is
 subsequently queried for the VM.  This capability is only supported by
 HV KVM, and can only be set before any VCPUs have been created.
+The KVM_CAP_PPC_SMT_POSSIBLE capability indicates which virtual SMT
+modes are available.
 
 7.12 KVM_CAP_PPC_FWNMI
 
@@ -4183,3 +4185,12 @@ Currently the following bits are defined for the device_irq_level bitmap:
 Future versions of kvm may implement additional events. These will get
 indicated by returning a higher number from KVM_CHECK_EXTENSION and will be
 listed above.
+
+8.10 KVM_CAP_PPC_SMT_POSSIBLE
+
+Architectures: ppc
+
+Querying this capability returns a bitmap indicating the possible
+virtual SMT modes that can be set using KVM_CAP_PPC_SMT.  If bit N
+(counting from the right) is set, then a virtual SMT mode of 2^N is
+available.
index ccaa7a407c15c42d8dffe7c32ad4603079647062..b14736f3870beff7515fead4729ef2084657bafe 100644 (file)
@@ -566,6 +566,16 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
                                r = threads_per_subcore;
                }
                break;
+       case KVM_CAP_PPC_SMT_POSSIBLE:
+               r = 1;
+               if (hv_enabled) {
+                       if (!cpu_has_feature(CPU_FTR_ARCH_300))
+                               r = ((threads_per_subcore << 1) - 1);
+                       else
+                               /* P9 can emulate dbells, so allow any mode */
+                               r = 8 | 4 | 2 | 1;
+               }
+               break;
        case KVM_CAP_PPC_RMA:
                r = 0;
                break;
index 89bc145b40515f5c320c3018183d01faeabc21bc..36ea74aa34220ab890a54e3446c0d0fa49502f52 100644 (file)
@@ -896,6 +896,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_X86_GUEST_MWAIT 143
 #define KVM_CAP_ARM_USER_IRQ 144
 #define KVM_CAP_PPC_FWNMI 145
+#define KVM_CAP_PPC_SMT_POSSIBLE 146
 
 #ifdef KVM_CAP_IRQ_ROUTING