aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2008-02-11 11:37:23 -0500
committerAvi Kivity <avi@qumranet.com>2008-03-03 04:22:25 -0500
commit674eea0fc4d1d693250b5d3ddad42ca931c87dfd (patch)
treea7995dd52f6715081cac74484a84351003e48480 /arch/x86/kvm/x86.c
parentd730616384211436cfc84e6c2c1aa45351706a96 (diff)
KVM: Make the supported cpuid list a host property rather than a vm property
One of the use cases for the supported cpuid list is to create a "greatest common denominator" of cpu capabilities in a server farm. As such, it is useful to be able to get the list without creating a virtual machine first. Since the code does not depend on the vm in any way, all that is needed is to move it to the device ioctl handler. The capability identifier is also changed so that binaries made against -rc1 will fail gracefully. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c42
1 files changed, 22 insertions, 20 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
49static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid,
50 struct kvm_cpuid_entry2 __user *entries);
51
49struct kvm_x86_ops *kvm_x86_ops; 52struct kvm_x86_ops *kvm_x86_ops;
50 53
51struct kvm_stats_debugfs_item debugfs_entries[] = { 54struct 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
977static int kvm_vm_ioctl_get_supported_cpuid(struct kvm *kvm, 998static 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 }