History

KVM: PPC: Book3S HV: Introduce new capability for 2nd DAWR

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.

Ravi Bangoria committed 5 years ago

Commit d9a47ed1 parent bd1de1a6 files · +35 −0Browse files

Unified · Split

6 files
  1. Documentation/virt/kvm/api.rst +10 −0
  2. arch/powerpc/include/asm/kvm_ppc.h +1 −0
  3. arch/powerpc/kvm/book3s_hv.c +12 −0
  4. arch/powerpc/kvm/powerpc.c +10 −0
  5. include/uapi/linux/kvm.h +1 −0
  6. tools/include/uapi/linux/kvm.h +1 −0
Documentation/virt/kvm/api.rst+10−0
@@ -6215,6 +6215,16 @@ the bus lock vm exit can be preempted by a higher priority VM exit, the exit · 6214 unmodified lines
6215notifications to userspace can be KVM_EXIT_BUS_LOCK or other reasons.6215notifications to userspace can be KVM_EXIT_BUS_LOCK or other reasons.
6216KVM_RUN_BUS_LOCK flag is used to distinguish between them.6216KVM_RUN_BUS_LOCK flag is used to distinguish between them.
6217 6217
62187.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
6225This capability can be used to check / enable 2nd DAWR feature provided
6226by POWER10 processor.
6227
62188. Other capabilities.62288. Other capabilities.
6219======================6229======================
6220 6230
arch/powerpc/include/asm/kvm_ppc.h+1−0
@@ -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
319extern struct kvmppc_ops *kvmppc_hv_ops;320extern struct kvmppc_ops *kvmppc_hv_ops;
arch/powerpc/kvm/book3s_hv.c+12−0
@@ -5642,6 +5642,17 @@ out: · 5641 unmodified lines
5642 return ret;5642 return ret;
5643}5643}
5644 5644
5645static 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
5645static struct kvmppc_ops kvm_ops_hv = {5656static 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
5690static int kvm_init_subcore_bitmap(void)5702static int kvm_init_subcore_bitmap(void)
arch/powerpc/kvm/powerpc.c+10−0
@@ -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#endif685#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#endif2200#endif
2191 default:2201 default:
2192 r = -EINVAL;2202 r = -EINVAL;
include/uapi/linux/kvm.h+1−0
@@ -1077,6 +1077,7 @@ struct kvm_ppc_resize_hpt { · 1076 unmodified lines
1077#define KVM_CAP_SYS_HYPERV_CPUID 1911077#define KVM_CAP_SYS_HYPERV_CPUID 191
1078#define KVM_CAP_DIRTY_LOG_RING 1921078#define KVM_CAP_DIRTY_LOG_RING 192
1079#define KVM_CAP_X86_BUS_LOCK_EXIT 1931079#define KVM_CAP_X86_BUS_LOCK_EXIT 193
1080#define KVM_CAP_PPC_DAWR1 194
1080 1081
1081#ifdef KVM_CAP_IRQ_ROUTING1082#ifdef KVM_CAP_IRQ_ROUTING
1082 1083
tools/include/uapi/linux/kvm.h+1−0
@@ -1056,6 +1056,7 @@ struct kvm_ppc_resize_hpt { · 1055 unmodified lines
1056#define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 1901056#define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190
1057#define KVM_CAP_SYS_HYPERV_CPUID 1911057#define KVM_CAP_SYS_HYPERV_CPUID 191
1058#define KVM_CAP_DIRTY_LOG_RING 1921058#define KVM_CAP_DIRTY_LOG_RING 192
1059#define KVM_CAP_PPC_DAWR1 194
1059 1060
1060#ifdef KVM_CAP_IRQ_ROUTING1061#ifdef KVM_CAP_IRQ_ROUTING
1061 1062

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t