]> Git Repo - qemu.git/commitdiff
i386: kvm: extract try_get_cpuid() loop to get_supported_cpuid() function
authorEduardo Habkost <[email protected]>
Thu, 4 Oct 2012 20:48:58 +0000 (17:48 -0300)
committerMarcelo Tosatti <[email protected]>
Wed, 31 Oct 2012 01:39:46 +0000 (23:39 -0200)
No behavior change, just code movement.

Signed-off-by: Eduardo Habkost <[email protected]>
Signed-off-by: Marcelo Tosatti <[email protected]>
target-i386/kvm.c

index c94897f5d370dc12007433bf6c0c2835644dfcca..d74dbc152ccef67ce3f5060d5ec53709368b22f0 100644 (file)
@@ -98,6 +98,19 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
     return cpuid;
 }
 
+/* Run KVM_GET_SUPPORTED_CPUID ioctl(), allocating a buffer large enough
+ * for all entries.
+ */
+static struct kvm_cpuid2 *get_supported_cpuid(KVMState *s)
+{
+    struct kvm_cpuid2 *cpuid;
+    int max = 1;
+    while ((cpuid = try_get_cpuid(s, max)) == NULL) {
+        max *= 2;
+    }
+    return cpuid;
+}
+
 struct kvm_para_features {
     int cap;
     int feature;
@@ -166,15 +179,11 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
                                       uint32_t index, int reg)
 {
     struct kvm_cpuid2 *cpuid;
-    int max;
     uint32_t ret = 0;
     uint32_t cpuid_1_edx;
     bool found = false;
 
-    max = 1;
-    while ((cpuid = try_get_cpuid(s, max)) == NULL) {
-        max *= 2;
-    }
+    cpuid = get_supported_cpuid(s);
 
     struct kvm_cpuid_entry2 *entry = cpuid_find_entry(cpuid, function, index);
     if (entry) {
This page took 0.032457 seconds and 4 git commands to generate.