aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/kvm/api.txt35
-rw-r--r--arch/powerpc/kvm/powerpc.c27
-rw-r--r--include/linux/kvm.h11
3 files changed, 73 insertions, 0 deletions
diff --git a/Documentation/kvm/api.txt b/Documentation/kvm/api.txt
index 2cc0120ccdb5..f9724dc8d079 100644
--- a/Documentation/kvm/api.txt
+++ b/Documentation/kvm/api.txt
@@ -813,6 +813,41 @@ This ioctl is required on Intel-based hosts. This is needed on Intel hardware
813because of a quirk in the virtualization implementation (see the internals 813because of a quirk in the virtualization implementation (see the internals
814documentation when it pops into existence). 814documentation when it pops into existence).
815 815
8164.36 KVM_ENABLE_CAP
817
818Capability: KVM_CAP_ENABLE_CAP
819Architectures: ppc
820Type: vcpu ioctl
821Parameters: struct kvm_enable_cap (in)
822Returns: 0 on success; -1 on error
823
824+Not all extensions are enabled by default. Using this ioctl the application
825can enable an extension, making it available to the guest.
826
827On systems that do not support this ioctl, it always fails. On systems that
828do support it, it only works for extensions that are supported for enablement.
829
830To check if a capability can be enabled, the KVM_CHECK_EXTENSION ioctl should
831be used.
832
833struct kvm_enable_cap {
834 /* in */
835 __u32 cap;
836
837The capability that is supposed to get enabled.
838
839 __u32 flags;
840
841A bitfield indicating future enhancements. Has to be 0 for now.
842
843 __u64 args[4];
844
845Arguments for enabling a feature. If a feature needs initial values to
846function properly, this is the place to put them.
847
848 __u8 pad[64];
849};
850
8165. The kvm_run structure 8515. The kvm_run structure
817 852
818Application code obtains a pointer to the kvm_run structure by 853Application code obtains a pointer to the kvm_run structure by
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 0bb6a7e826d1..646bfd256e5d 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -150,6 +150,7 @@ int kvm_dev_ioctl_check_extension(long ext)
150 case KVM_CAP_PPC_SEGSTATE: 150 case KVM_CAP_PPC_SEGSTATE:
151 case KVM_CAP_PPC_PAIRED_SINGLES: 151 case KVM_CAP_PPC_PAIRED_SINGLES:
152 case KVM_CAP_PPC_UNSET_IRQ: 152 case KVM_CAP_PPC_UNSET_IRQ:
153 case KVM_CAP_ENABLE_CAP:
153 r = 1; 154 r = 1;
154 break; 155 break;
155 case KVM_CAP_COALESCED_MMIO: 156 case KVM_CAP_COALESCED_MMIO:
@@ -465,6 +466,23 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
465 return 0; 466 return 0;
466} 467}
467 468
469static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
470 struct kvm_enable_cap *cap)
471{
472 int r;
473
474 if (cap->flags)
475 return -EINVAL;
476
477 switch (cap->cap) {
478 default:
479 r = -EINVAL;
480 break;
481 }
482
483 return r;
484}
485
468int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, 486int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
469 struct kvm_mp_state *mp_state) 487 struct kvm_mp_state *mp_state)
470{ 488{
@@ -493,6 +511,15 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
493 r = kvm_vcpu_ioctl_interrupt(vcpu, &irq); 511 r = kvm_vcpu_ioctl_interrupt(vcpu, &irq);
494 break; 512 break;
495 } 513 }
514 case KVM_ENABLE_CAP:
515 {
516 struct kvm_enable_cap cap;
517 r = -EFAULT;
518 if (copy_from_user(&cap, argp, sizeof(cap)))
519 goto out;
520 r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap);
521 break;
522 }
496 default: 523 default:
497 r = -EINVAL; 524 r = -EINVAL;
498 } 525 }
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index c36d093e9806..ecb68e433558 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -400,6 +400,15 @@ struct kvm_ioeventfd {
400 __u8 pad[36]; 400 __u8 pad[36];
401}; 401};
402 402
403/* for KVM_ENABLE_CAP */
404struct kvm_enable_cap {
405 /* in */
406 __u32 cap;
407 __u32 flags;
408 __u64 args[4];
409 __u8 pad[64];
410};
411
403#define KVMIO 0xAE 412#define KVMIO 0xAE
404 413
405/* 414/*
@@ -508,6 +517,7 @@ struct kvm_ioeventfd {
508#endif 517#endif
509#define KVM_CAP_X86_ROBUST_SINGLESTEP 51 518#define KVM_CAP_X86_ROBUST_SINGLESTEP 51
510#define KVM_CAP_PPC_UNSET_IRQ 53 519#define KVM_CAP_PPC_UNSET_IRQ 53
520#define KVM_CAP_ENABLE_CAP 54
511 521
512#ifdef KVM_CAP_IRQ_ROUTING 522#ifdef KVM_CAP_IRQ_ROUTING
513 523
@@ -697,6 +707,7 @@ struct kvm_clock_data {
697/* Available with KVM_CAP_DEBUGREGS */ 707/* Available with KVM_CAP_DEBUGREGS */
698#define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs) 708#define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs)
699#define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs) 709#define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs)
710#define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap)
700 711
701#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) 712#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
702 713