diff options
author | Paul Mackerras <paulus@ozlabs.org> | 2017-06-21 02:01:27 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@ozlabs.org> | 2017-06-21 21:25:31 -0400 |
commit | 2ed4f9dd19c0f76f7fb56c4b201696d29149325c (patch) | |
tree | dc386c28edb9885280d62e1fb51fe2dd5b693a94 | |
parent | e20bbd3d8d5c4432db8fd6f091b096963236064f (diff) |
KVM: PPC: Book3S HV: Add capability to report possible virtual SMT modes
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>
-rw-r--r-- | Documentation/virtual/kvm/api.txt | 11 | ||||
-rw-r--r-- | arch/powerpc/kvm/powerpc.c | 10 | ||||
-rw-r--r-- | include/uapi/linux/kvm.h | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index 1531a3cd548f..63875dbb6ef5 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt | |||
@@ -4010,6 +4010,8 @@ be 0. A successful call to enable this capability will result in | |||
4010 | vsmt_mode being returned when the KVM_CAP_PPC_SMT capability is | 4010 | vsmt_mode being returned when the KVM_CAP_PPC_SMT capability is |
4011 | subsequently queried for the VM. This capability is only supported by | 4011 | subsequently queried for the VM. This capability is only supported by |
4012 | HV KVM, and can only be set before any VCPUs have been created. | 4012 | HV KVM, and can only be set before any VCPUs have been created. |
4013 | The KVM_CAP_PPC_SMT_POSSIBLE capability indicates which virtual SMT | ||
4014 | modes are available. | ||
4013 | 4015 | ||
4014 | 7.12 KVM_CAP_PPC_FWNMI | 4016 | 7.12 KVM_CAP_PPC_FWNMI |
4015 | 4017 | ||
@@ -4183,3 +4185,12 @@ Currently the following bits are defined for the device_irq_level bitmap: | |||
4183 | Future versions of kvm may implement additional events. These will get | 4185 | Future versions of kvm may implement additional events. These will get |
4184 | indicated by returning a higher number from KVM_CHECK_EXTENSION and will be | 4186 | indicated by returning a higher number from KVM_CHECK_EXTENSION and will be |
4185 | listed above. | 4187 | listed above. |
4188 | |||
4189 | 8.10 KVM_CAP_PPC_SMT_POSSIBLE | ||
4190 | |||
4191 | Architectures: ppc | ||
4192 | |||
4193 | Querying this capability returns a bitmap indicating the possible | ||
4194 | virtual SMT modes that can be set using KVM_CAP_PPC_SMT. If bit N | ||
4195 | (counting from the right) is set, then a virtual SMT mode of 2^N is | ||
4196 | available. | ||
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index ccaa7a407c15..b14736f3870b 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c | |||
@@ -566,6 +566,16 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) | |||
566 | r = threads_per_subcore; | 566 | r = threads_per_subcore; |
567 | } | 567 | } |
568 | break; | 568 | break; |
569 | case KVM_CAP_PPC_SMT_POSSIBLE: | ||
570 | r = 1; | ||
571 | if (hv_enabled) { | ||
572 | if (!cpu_has_feature(CPU_FTR_ARCH_300)) | ||
573 | r = ((threads_per_subcore << 1) - 1); | ||
574 | else | ||
575 | /* P9 can emulate dbells, so allow any mode */ | ||
576 | r = 8 | 4 | 2 | 1; | ||
577 | } | ||
578 | break; | ||
569 | case KVM_CAP_PPC_RMA: | 579 | case KVM_CAP_PPC_RMA: |
570 | r = 0; | 580 | r = 0; |
571 | break; | 581 | break; |
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 89bc145b4051..36ea74aa3422 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h | |||
@@ -896,6 +896,7 @@ struct kvm_ppc_resize_hpt { | |||
896 | #define KVM_CAP_X86_GUEST_MWAIT 143 | 896 | #define KVM_CAP_X86_GUEST_MWAIT 143 |
897 | #define KVM_CAP_ARM_USER_IRQ 144 | 897 | #define KVM_CAP_ARM_USER_IRQ 144 |
898 | #define KVM_CAP_PPC_FWNMI 145 | 898 | #define KVM_CAP_PPC_FWNMI 145 |
899 | #define KVM_CAP_PPC_SMT_POSSIBLE 146 | ||
899 | 900 | ||
900 | #ifdef KVM_CAP_IRQ_ROUTING | 901 | #ifdef KVM_CAP_IRQ_ROUTING |
901 | 902 | ||