Revision dd87f8a6 target-i386/kvm.c

b/target-i386/kvm.c
98 98
    return cpuid;
99 99
}
100 100

  
101
/* Run KVM_GET_SUPPORTED_CPUID ioctl(), allocating a buffer large enough
102
 * for all entries.
103
 */
104
static struct kvm_cpuid2 *get_supported_cpuid(KVMState *s)
105
{
106
    struct kvm_cpuid2 *cpuid;
107
    int max = 1;
108
    while ((cpuid = try_get_cpuid(s, max)) == NULL) {
109
        max *= 2;
110
    }
111
    return cpuid;
112
}
113

  
101 114
struct kvm_para_features {
102 115
    int cap;
103 116
    int feature;
......
166 179
                                      uint32_t index, int reg)
167 180
{
168 181
    struct kvm_cpuid2 *cpuid;
169
    int max;
170 182
    uint32_t ret = 0;
171 183
    uint32_t cpuid_1_edx;
172 184
    bool found = false;
173 185

  
174
    max = 1;
175
    while ((cpuid = try_get_cpuid(s, max)) == NULL) {
176
        max *= 2;
177
    }
186
    cpuid = get_supported_cpuid(s);
178 187

  
179 188
    struct kvm_cpuid_entry2 *entry = cpuid_find_entry(cpuid, function, index);
180 189
    if (entry) {

Also available in: Unified diff