It would be used later by KVM_CAP_MSIX_MASK related interfaces. Signed-off-by: Sheng Yang <sheng@xxxxxxxxxxxxxxx> --- Documentation/kvm/api.txt | 8 +++++--- arch/x86/kvm/x86.c | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Documentation/kvm/api.txt b/Documentation/kvm/api.txt index b336266..d82d637 100644 --- a/Documentation/kvm/api.txt +++ b/Documentation/kvm/api.txt @@ -817,7 +817,7 @@ documentation when it pops into existence). 4.36 KVM_ENABLE_CAP Capability: KVM_CAP_ENABLE_CAP -Architectures: ppc +Architectures: ppc, x86 Type: vcpu ioctl Parameters: struct kvm_enable_cap (in) Returns: 0 on success; -1 on error @@ -828,8 +828,10 @@ can enable an extension, making it available to the guest. On systems that do not support this ioctl, it always fails. On systems that do support it, it only works for extensions that are supported for enablement. -To check if a capability can be enabled, the KVM_CHECK_EXTENSION ioctl should -be used. +For PPC, to check if a capability can be enabled, the KVM_CHECK_EXTENSION +ioctl should be used. + +For x86, only some specific capabilities need to be enabled before use. struct kvm_enable_cap { /* in */ diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f3f86b2..fc62546 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1926,6 +1926,7 @@ int kvm_dev_ioctl_check_extension(long ext) case KVM_CAP_DEBUGREGS: case KVM_CAP_X86_ROBUST_SINGLESTEP: case KVM_CAP_XSAVE: + case KVM_CAP_ENABLE_CAP: r = 1; break; case KVM_CAP_COALESCED_MMIO: @@ -2707,6 +2708,23 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu, return r; } +static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, + struct kvm_enable_cap *cap) +{ + int r; + + if (cap->flags) + return -EINVAL; + + switch (cap->cap) { + default: + r = -EINVAL; + break; + } + + return r; +} + long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) { @@ -2970,6 +2988,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp, r = kvm_vcpu_ioctl_x86_set_xcrs(vcpu, u.xcrs); break; } + case KVM_ENABLE_CAP: { + struct kvm_enable_cap cap; + r = -EFAULT; + if (copy_from_user(&cap, argp, sizeof(cap))) + goto out; + r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap); + break; + } default: r = -EINVAL; } -- 1.7.0.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html