Introduce KVM_CAP_PPC_DAWR1 which can be used by QEMU to query whether KVM supports 2nd DAWR or not. The capability is by default disabled even when the underlying CPU supports 2nd DAWR. QEMU needs to check and enable it manually to use the feature.
Unified · Split
| @@ -6215,6 +6215,16 @@ the bus lock vm exit can be preempted by a higher priority VM exit, the exit · 6214 unmodified lines | |||
| 6215 | notifications to userspace can be KVM_EXIT_BUS_LOCK or other reasons. | 6215 | notifications to userspace can be KVM_EXIT_BUS_LOCK or other reasons. |
| 6216 | KVM_RUN_BUS_LOCK flag is used to distinguish between them. | 6216 | KVM_RUN_BUS_LOCK flag is used to distinguish between them. |
| 6217 | 6217 | ||
| 6218 | 7.22 KVM_CAP_PPC_DAWR1 | ||
| 6219 | ---------------------- | ||
| 6220 | |||
| 6221 | :Architectures: ppc | ||
| 6222 | :Parameters: none | ||
| 6223 | :Returns: 0 on success, -EINVAL when CPU doesn't support 2nd DAWR | ||
| 6224 | |||
| 6225 | This capability can be used to check / enable 2nd DAWR feature provided | ||
| 6226 | by POWER10 processor. | ||
| 6227 | |||
| 6218 | 8. Other capabilities. | 6228 | 8. Other capabilities. |
| 6219 | ====================== | 6229 | ====================== |
| 6220 | 6230 | ||
| @@ -314,6 +314,7 @@ struct kvmppc_ops { · 313 unmodified lines | |||
| 314 | int size); | 314 | int size); |
| 315 | int (*enable_svm)(struct kvm *kvm); | 315 | int (*enable_svm)(struct kvm *kvm); |
| 316 | int (*svm_off)(struct kvm *kvm); | 316 | int (*svm_off)(struct kvm *kvm); |
| 317 | int (*enable_dawr1)(struct kvm *kvm); | ||
| 317 | }; | 318 | }; |
| 318 | 319 | ||
| 319 | extern struct kvmppc_ops *kvmppc_hv_ops; | 320 | extern struct kvmppc_ops *kvmppc_hv_ops; |
| @@ -5642,6 +5642,17 @@ out: · 5641 unmodified lines | |||
| 5642 | return ret; | 5642 | return ret; |
| 5643 | } | 5643 | } |
| 5644 | 5644 | ||
| 5645 | static int kvmhv_enable_dawr1(struct kvm *kvm) | ||
| 5646 | { | ||
| 5647 | if (!cpu_has_feature(CPU_FTR_DAWR1)) | ||
| 5648 | return -ENODEV; | ||
| 5649 | |||
| 5650 | /* kvm == NULL means the caller is testing if the capability exists */ | ||
| 5651 | if (kvm) | ||
| 5652 | kvm->arch.dawr1_enabled = true; | ||
| 5653 | return 0; | ||
| 5654 | } | ||
| 5655 | |||
| 5645 | static struct kvmppc_ops kvm_ops_hv = { | 5656 | static struct kvmppc_ops kvm_ops_hv = { |
| 5646 | .get_sregs = kvm_arch_vcpu_ioctl_get_sregs_hv, | 5657 | .get_sregs = kvm_arch_vcpu_ioctl_get_sregs_hv, |
| 5647 | .set_sregs = kvm_arch_vcpu_ioctl_set_sregs_hv, | 5658 | .set_sregs = kvm_arch_vcpu_ioctl_set_sregs_hv, |
| @@ -5685,6 +5696,7 @@ static struct kvmppc_ops kvm_ops_hv = { · 37 unmodified lines | |||
| 5685 | .store_to_eaddr = kvmhv_store_to_eaddr, | 5696 | .store_to_eaddr = kvmhv_store_to_eaddr, |
| 5686 | .enable_svm = kvmhv_enable_svm, | 5697 | .enable_svm = kvmhv_enable_svm, |
| 5687 | .svm_off = kvmhv_svm_off, | 5698 | .svm_off = kvmhv_svm_off, |
| 5699 | .enable_dawr1 = kvmhv_enable_dawr1, | ||
| 5688 | }; | 5700 | }; |
| 5689 | 5701 | ||
| 5690 | static int kvm_init_subcore_bitmap(void) | 5702 | static int kvm_init_subcore_bitmap(void) |
| @@ -678,6 +678,10 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) · 677 unmodified lines | |||
| 678 | r = hv_enabled && kvmppc_hv_ops->enable_svm && | 678 | r = hv_enabled && kvmppc_hv_ops->enable_svm && |
| 679 | !kvmppc_hv_ops->enable_svm(NULL); | 679 | !kvmppc_hv_ops->enable_svm(NULL); |
| 680 | break; | 680 | break; |
| 681 | case KVM_CAP_PPC_DAWR1: | ||
| 682 | r = !!(hv_enabled && kvmppc_hv_ops->enable_dawr1 && | ||
| 683 | !kvmppc_hv_ops->enable_dawr1(NULL)); | ||
| 684 | break; | ||
| 681 | #endif | 685 | #endif |
| 682 | default: | 686 | default: |
| 683 | r = 0; | 687 | r = 0; |
| @@ -2187,6 +2191,12 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, · 1503 unmodified lines | |||
| 2187 | break; | 2191 | break; |
| 2188 | r = kvm->arch.kvm_ops->enable_svm(kvm); | 2192 | r = kvm->arch.kvm_ops->enable_svm(kvm); |
| 2189 | break; | 2193 | break; |
| 2194 | case KVM_CAP_PPC_DAWR1: | ||
| 2195 | r = -EINVAL; | ||
| 2196 | if (!is_kvmppc_hv_enabled(kvm) || !kvm->arch.kvm_ops->enable_dawr1) | ||
| 2197 | break; | ||
| 2198 | r = kvm->arch.kvm_ops->enable_dawr1(kvm); | ||
| 2199 | break; | ||
| 2190 | #endif | 2200 | #endif |
| 2191 | default: | 2201 | default: |
| 2192 | r = -EINVAL; | 2202 | r = -EINVAL; |
| @@ -1077,6 +1077,7 @@ struct kvm_ppc_resize_hpt { · 1076 unmodified lines | |||
| 1077 | #define KVM_CAP_SYS_HYPERV_CPUID 191 | 1077 | #define KVM_CAP_SYS_HYPERV_CPUID 191 |
| 1078 | #define KVM_CAP_DIRTY_LOG_RING 192 | 1078 | #define KVM_CAP_DIRTY_LOG_RING 192 |
| 1079 | #define KVM_CAP_X86_BUS_LOCK_EXIT 193 | 1079 | #define KVM_CAP_X86_BUS_LOCK_EXIT 193 |
| 1080 | #define KVM_CAP_PPC_DAWR1 194 | ||
| 1080 | 1081 | ||
| 1081 | #ifdef KVM_CAP_IRQ_ROUTING | 1082 | #ifdef KVM_CAP_IRQ_ROUTING |
| 1082 | 1083 | ||
| @@ -1056,6 +1056,7 @@ struct kvm_ppc_resize_hpt { · 1055 unmodified lines | |||
| 1056 | #define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190 | 1056 | #define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190 |
| 1057 | #define KVM_CAP_SYS_HYPERV_CPUID 191 | 1057 | #define KVM_CAP_SYS_HYPERV_CPUID 191 |
| 1058 | #define KVM_CAP_DIRTY_LOG_RING 192 | 1058 | #define KVM_CAP_DIRTY_LOG_RING 192 |
| 1059 | #define KVM_CAP_PPC_DAWR1 194 | ||
| 1059 | 1060 | ||
| 1060 | #ifdef KVM_CAP_IRQ_ROUTING | 1061 | #ifdef KVM_CAP_IRQ_ROUTING |
| 1061 | 1062 | ||