cpuid.c (573cc0e5cf142d9992d2de3502800890fc717bc0) | cpuid.c (b4f69df0f65e97fec439130a0d0a8b9c7cc02df2) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Kernel-based Virtual Machine driver for Linux 4 * cpuid support routines 5 * 6 * derived from arch/x86/kvm/x86.c 7 * 8 * Copyright 2011 Red Hat, Inc. and/or its affiliates. --- 300 unchanged lines hidden (view full) --- 309void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu) 310{ 311 __kvm_update_cpuid_runtime(vcpu, vcpu->arch.cpuid_entries, vcpu->arch.cpuid_nent); 312} 313EXPORT_SYMBOL_GPL(kvm_update_cpuid_runtime); 314 315static bool kvm_cpuid_has_hyperv(struct kvm_cpuid_entry2 *entries, int nent) 316{ | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Kernel-based Virtual Machine driver for Linux 4 * cpuid support routines 5 * 6 * derived from arch/x86/kvm/x86.c 7 * 8 * Copyright 2011 Red Hat, Inc. and/or its affiliates. --- 300 unchanged lines hidden (view full) --- 309void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu) 310{ 311 __kvm_update_cpuid_runtime(vcpu, vcpu->arch.cpuid_entries, vcpu->arch.cpuid_nent); 312} 313EXPORT_SYMBOL_GPL(kvm_update_cpuid_runtime); 314 315static bool kvm_cpuid_has_hyperv(struct kvm_cpuid_entry2 *entries, int nent) 316{ |
317#ifdef CONFIG_KVM_HYPERV |
|
317 struct kvm_cpuid_entry2 *entry; 318 319 entry = cpuid_entry2_find(entries, nent, HYPERV_CPUID_INTERFACE, 320 KVM_CPUID_INDEX_NOT_SIGNIFICANT); 321 return entry && entry->eax == HYPERV_CPUID_SIGNATURE_EAX; | 318 struct kvm_cpuid_entry2 *entry; 319 320 entry = cpuid_entry2_find(entries, nent, HYPERV_CPUID_INTERFACE, 321 KVM_CPUID_INDEX_NOT_SIGNIFICANT); 322 return entry && entry->eax == HYPERV_CPUID_SIGNATURE_EAX; |
323#else 324 return false; 325#endif |
|
322} 323 324static void kvm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu) 325{ 326 struct kvm_lapic *apic = vcpu->arch.apic; 327 struct kvm_cpuid_entry2 *best; 328 bool allow_gbpages; 329 --- 98 unchanged lines hidden (view full) --- 428 r = kvm_cpuid_check_equal(vcpu, e2, nent); 429 if (r) 430 return r; 431 432 kvfree(e2); 433 return 0; 434 } 435 | 326} 327 328static void kvm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu) 329{ 330 struct kvm_lapic *apic = vcpu->arch.apic; 331 struct kvm_cpuid_entry2 *best; 332 bool allow_gbpages; 333 --- 98 unchanged lines hidden (view full) --- 432 r = kvm_cpuid_check_equal(vcpu, e2, nent); 433 if (r) 434 return r; 435 436 kvfree(e2); 437 return 0; 438 } 439 |
440#ifdef CONFIG_KVM_HYPERV |
|
436 if (kvm_cpuid_has_hyperv(e2, nent)) { 437 r = kvm_hv_vcpu_init(vcpu); 438 if (r) 439 return r; 440 } | 441 if (kvm_cpuid_has_hyperv(e2, nent)) { 442 r = kvm_hv_vcpu_init(vcpu); 443 if (r) 444 return r; 445 } |
446#endif |
|
441 442 r = kvm_check_cpuid(vcpu, e2, nent); 443 if (r) 444 return r; 445 446 kvfree(vcpu->arch.cpuid_entries); 447 vcpu->arch.cpuid_entries = e2; 448 vcpu->arch.cpuid_nent = nent; --- 15 unchanged lines hidden (view full) --- 464 int r, i; 465 struct kvm_cpuid_entry *e = NULL; 466 struct kvm_cpuid_entry2 *e2 = NULL; 467 468 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES) 469 return -E2BIG; 470 471 if (cpuid->nent) { | 447 448 r = kvm_check_cpuid(vcpu, e2, nent); 449 if (r) 450 return r; 451 452 kvfree(vcpu->arch.cpuid_entries); 453 vcpu->arch.cpuid_entries = e2; 454 vcpu->arch.cpuid_nent = nent; --- 15 unchanged lines hidden (view full) --- 470 int r, i; 471 struct kvm_cpuid_entry *e = NULL; 472 struct kvm_cpuid_entry2 *e2 = NULL; 473 474 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES) 475 return -E2BIG; 476 477 if (cpuid->nent) { |
472 e = vmemdup_array_user(entries, cpuid->nent, sizeof(*e)); | 478 e = vmemdup_user(entries, array_size(sizeof(*e), cpuid->nent)); |
473 if (IS_ERR(e)) 474 return PTR_ERR(e); 475 476 e2 = kvmalloc_array(cpuid->nent, sizeof(*e2), GFP_KERNEL_ACCOUNT); 477 if (!e2) { 478 r = -ENOMEM; 479 goto out_free_cpuid; 480 } --- 27 unchanged lines hidden (view full) --- 508{ 509 struct kvm_cpuid_entry2 *e2 = NULL; 510 int r; 511 512 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES) 513 return -E2BIG; 514 515 if (cpuid->nent) { | 479 if (IS_ERR(e)) 480 return PTR_ERR(e); 481 482 e2 = kvmalloc_array(cpuid->nent, sizeof(*e2), GFP_KERNEL_ACCOUNT); 483 if (!e2) { 484 r = -ENOMEM; 485 goto out_free_cpuid; 486 } --- 27 unchanged lines hidden (view full) --- 514{ 515 struct kvm_cpuid_entry2 *e2 = NULL; 516 int r; 517 518 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES) 519 return -E2BIG; 520 521 if (cpuid->nent) { |
516 e2 = vmemdup_array_user(entries, cpuid->nent, sizeof(*e2)); | 522 e2 = vmemdup_user(entries, array_size(sizeof(*e2), cpuid->nent)); |
517 if (IS_ERR(e2)) 518 return PTR_ERR(e2); 519 } 520 521 r = kvm_set_cpuid(vcpu, e2, cpuid->nent); 522 if (r) 523 kvfree(e2); 524 --- 1053 unchanged lines hidden --- | 523 if (IS_ERR(e2)) 524 return PTR_ERR(e2); 525 } 526 527 r = kvm_set_cpuid(vcpu, e2, cpuid->nent); 528 if (r) 529 kvfree(e2); 530 --- 1053 unchanged lines hidden --- |