diff options
-rw-r--r-- | arch/x86/kvm/x86.c | 42 | ||||
-rw-r--r-- | include/linux/kvm.h | 4 |
2 files changed, 24 insertions, 22 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index ec60409299a3..a7069ec2267c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -46,6 +46,9 @@ | |||
46 | #define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM | 46 | #define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM |
47 | #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU | 47 | #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU |
48 | 48 | ||
49 | static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, | ||
50 | struct kvm_cpuid_entry2 __user *entries); | ||
51 | |||
49 | struct kvm_x86_ops *kvm_x86_ops; | 52 | struct kvm_x86_ops *kvm_x86_ops; |
50 | 53 | ||
51 | struct kvm_stats_debugfs_item debugfs_entries[] = { | 54 | struct kvm_stats_debugfs_item debugfs_entries[] = { |
@@ -727,6 +730,24 @@ long kvm_arch_dev_ioctl(struct file *filp, | |||
727 | r = 0; | 730 | r = 0; |
728 | break; | 731 | break; |
729 | } | 732 | } |
733 | case KVM_GET_SUPPORTED_CPUID: { | ||
734 | struct kvm_cpuid2 __user *cpuid_arg = argp; | ||
735 | struct kvm_cpuid2 cpuid; | ||
736 | |||
737 | r = -EFAULT; | ||
738 | if (copy_from_user(&cpuid, cpuid_arg, sizeof cpuid)) | ||
739 | goto out; | ||
740 | r = kvm_dev_ioctl_get_supported_cpuid(&cpuid, | ||
741 | cpuid_arg->entries); | ||
742 | if (r) | ||
743 | goto out; | ||
744 | |||
745 | r = -EFAULT; | ||
746 | if (copy_to_user(cpuid_arg, &cpuid, sizeof cpuid)) | ||
747 | goto out; | ||
748 | r = 0; | ||
749 | break; | ||
750 | } | ||
730 | default: | 751 | default: |
731 | r = -EINVAL; | 752 | r = -EINVAL; |
732 | } | 753 | } |
@@ -974,8 +995,7 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, | |||
974 | put_cpu(); | 995 | put_cpu(); |
975 | } | 996 | } |
976 | 997 | ||
977 | static int kvm_vm_ioctl_get_supported_cpuid(struct kvm *kvm, | 998 | static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, |
978 | struct kvm_cpuid2 *cpuid, | ||
979 | struct kvm_cpuid_entry2 __user *entries) | 999 | struct kvm_cpuid_entry2 __user *entries) |
980 | { | 1000 | { |
981 | struct kvm_cpuid_entry2 *cpuid_entries; | 1001 | struct kvm_cpuid_entry2 *cpuid_entries; |
@@ -1487,24 +1507,6 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
1487 | r = 0; | 1507 | r = 0; |
1488 | break; | 1508 | break; |
1489 | } | 1509 | } |
1490 | case KVM_GET_SUPPORTED_CPUID: { | ||
1491 | struct kvm_cpuid2 __user *cpuid_arg = argp; | ||
1492 | struct kvm_cpuid2 cpuid; | ||
1493 | |||
1494 | r = -EFAULT; | ||
1495 | if (copy_from_user(&cpuid, cpuid_arg, sizeof cpuid)) | ||
1496 | goto out; | ||
1497 | r = kvm_vm_ioctl_get_supported_cpuid(kvm, &cpuid, | ||
1498 | cpuid_arg->entries); | ||
1499 | if (r) | ||
1500 | goto out; | ||
1501 | |||
1502 | r = -EFAULT; | ||
1503 | if (copy_to_user(cpuid_arg, &cpuid, sizeof cpuid)) | ||
1504 | goto out; | ||
1505 | r = 0; | ||
1506 | break; | ||
1507 | } | ||
1508 | default: | 1510 | default: |
1509 | ; | 1511 | ; |
1510 | } | 1512 | } |
diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 4de4fd2d8607..c1ec04fd000d 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h | |||
@@ -221,6 +221,7 @@ struct kvm_vapic_addr { | |||
221 | * Get size for mmap(vcpu_fd) | 221 | * Get size for mmap(vcpu_fd) |
222 | */ | 222 | */ |
223 | #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ | 223 | #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ |
224 | #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) | ||
224 | 225 | ||
225 | /* | 226 | /* |
226 | * Extension capability list. | 227 | * Extension capability list. |
@@ -230,8 +231,8 @@ struct kvm_vapic_addr { | |||
230 | #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 | 231 | #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 |
231 | #define KVM_CAP_USER_MEMORY 3 | 232 | #define KVM_CAP_USER_MEMORY 3 |
232 | #define KVM_CAP_SET_TSS_ADDR 4 | 233 | #define KVM_CAP_SET_TSS_ADDR 4 |
233 | #define KVM_CAP_EXT_CPUID 5 | ||
234 | #define KVM_CAP_VAPIC 6 | 234 | #define KVM_CAP_VAPIC 6 |
235 | #define KVM_CAP_EXT_CPUID 7 | ||
235 | 236 | ||
236 | /* | 237 | /* |
237 | * ioctls for VM fds | 238 | * ioctls for VM fds |
@@ -249,7 +250,6 @@ struct kvm_vapic_addr { | |||
249 | #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) | 250 | #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) |
250 | #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) | 251 | #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) |
251 | #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) | 252 | #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) |
252 | #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x48, struct kvm_cpuid2) | ||
253 | /* Device model IOC */ | 253 | /* Device model IOC */ |
254 | #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) | 254 | #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) |
255 | #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) | 255 | #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) |