@@ -156,6 +156,12 @@ struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct kvm_vcpu *vcpu,
156
156
}
157
157
EXPORT_SYMBOL_GPL (kvm_find_cpuid_entry );
158
158
159
+ /*
160
+ * cpuid_entry2_find() and KVM_CPUID_INDEX_NOT_SIGNIFICANT should never be used
161
+ * directly outside of kvm_find_cpuid_entry() and kvm_find_cpuid_entry_index().
162
+ */
163
+ #undef KVM_CPUID_INDEX_NOT_SIGNIFICANT
164
+
159
165
static int kvm_check_cpuid (struct kvm_vcpu * vcpu )
160
166
{
161
167
struct kvm_cpuid_entry2 * best ;
@@ -165,8 +171,7 @@ static int kvm_check_cpuid(struct kvm_vcpu *vcpu)
165
171
* The existing code assumes virtual address is 48-bit or 57-bit in the
166
172
* canonical address checks; exit if it is ever changed.
167
173
*/
168
- best = cpuid_entry2_find (vcpu , 0x80000008 ,
169
- KVM_CPUID_INDEX_NOT_SIGNIFICANT );
174
+ best = kvm_find_cpuid_entry (vcpu , 0x80000008 );
170
175
if (best ) {
171
176
int vaddr_bits = (best -> eax & 0xff00 ) >> 8 ;
172
177
@@ -178,7 +183,7 @@ static int kvm_check_cpuid(struct kvm_vcpu *vcpu)
178
183
* Exposing dynamic xfeatures to the guest requires additional
179
184
* enabling in the FPU, e.g. to expand the guest XSAVE state size.
180
185
*/
181
- best = cpuid_entry2_find (vcpu , 0xd , 0 );
186
+ best = kvm_find_cpuid_entry_index (vcpu , 0xd , 0 );
182
187
if (!best )
183
188
return 0 ;
184
189
@@ -232,7 +237,7 @@ static struct kvm_hypervisor_cpuid kvm_get_hypervisor_cpuid(struct kvm_vcpu *vcp
232
237
u32 base ;
233
238
234
239
for_each_possible_hypervisor_cpuid_base (base ) {
235
- entry = cpuid_entry2_find (vcpu , base , KVM_CPUID_INDEX_NOT_SIGNIFICANT );
240
+ entry = kvm_find_cpuid_entry (vcpu , base );
236
241
237
242
if (entry ) {
238
243
u32 signature [3 ];
@@ -279,7 +284,7 @@ static u64 cpuid_get_supported_xcr0(struct kvm_vcpu *vcpu)
279
284
{
280
285
struct kvm_cpuid_entry2 * best ;
281
286
282
- best = cpuid_entry2_find (vcpu , 0xd , 0 );
287
+ best = kvm_find_cpuid_entry_index (vcpu , 0xd , 0 );
283
288
if (!best )
284
289
return 0 ;
285
290
@@ -290,7 +295,7 @@ void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu)
290
295
{
291
296
struct kvm_cpuid_entry2 * best ;
292
297
293
- best = cpuid_entry2_find (vcpu , 1 , KVM_CPUID_INDEX_NOT_SIGNIFICANT );
298
+ best = kvm_find_cpuid_entry (vcpu , 1 );
294
299
if (best ) {
295
300
/* Update OSXSAVE bit */
296
301
if (boot_cpu_has (X86_FEATURE_XSAVE ))
@@ -301,22 +306,22 @@ void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu)
301
306
vcpu -> arch .apic_base & MSR_IA32_APICBASE_ENABLE );
302
307
}
303
308
304
- best = cpuid_entry2_find (vcpu , 7 , 0 );
309
+ best = kvm_find_cpuid_entry_index (vcpu , 7 , 0 );
305
310
if (best && boot_cpu_has (X86_FEATURE_PKU ) && best -> function == 0x7 )
306
311
cpuid_entry_change (best , X86_FEATURE_OSPKE ,
307
312
kvm_is_cr4_bit_set (vcpu , X86_CR4_PKE ));
308
313
309
- best = cpuid_entry2_find (vcpu , 0xD , 0 );
314
+ best = kvm_find_cpuid_entry_index (vcpu , 0xD , 0 );
310
315
if (best )
311
316
best -> ebx = xstate_required_size (vcpu -> arch .xcr0 , false);
312
317
313
- best = cpuid_entry2_find (vcpu , 0xD , 1 );
318
+ best = kvm_find_cpuid_entry_index (vcpu , 0xD , 1 );
314
319
if (best && (cpuid_entry_has (best , X86_FEATURE_XSAVES ) ||
315
320
cpuid_entry_has (best , X86_FEATURE_XSAVEC )))
316
321
best -> ebx = xstate_required_size (vcpu -> arch .xcr0 , true);
317
322
318
323
if (!kvm_check_has_quirk (vcpu -> kvm , KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT )) {
319
- best = cpuid_entry2_find (vcpu , 0x1 , KVM_CPUID_INDEX_NOT_SIGNIFICANT );
324
+ best = kvm_find_cpuid_entry (vcpu , 0x1 );
320
325
if (best )
321
326
cpuid_entry_change (best , X86_FEATURE_MWAIT ,
322
327
vcpu -> arch .ia32_misc_enable_msr &
@@ -330,8 +335,7 @@ static bool kvm_cpuid_has_hyperv(struct kvm_vcpu *vcpu)
330
335
#ifdef CONFIG_KVM_HYPERV
331
336
struct kvm_cpuid_entry2 * entry ;
332
337
333
- entry = cpuid_entry2_find (vcpu , HYPERV_CPUID_INTERFACE ,
334
- KVM_CPUID_INDEX_NOT_SIGNIFICANT );
338
+ entry = kvm_find_cpuid_entry (vcpu , HYPERV_CPUID_INTERFACE );
335
339
return entry && entry -> eax == HYPERV_CPUID_SIGNATURE_EAX ;
336
340
#else
337
341
return false;
0 commit comments