diff options
Diffstat (limited to 'arch/x86/kernel/kvm.c')
-rw-r--r-- | arch/x86/kernel/kvm.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 6dd802c6d780..713f1b3bad52 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c | |||
@@ -500,6 +500,38 @@ void __init kvm_guest_init(void) | |||
500 | #endif | 500 | #endif |
501 | } | 501 | } |
502 | 502 | ||
503 | static noinline uint32_t __kvm_cpuid_base(void) | ||
504 | { | ||
505 | if (boot_cpu_data.cpuid_level < 0) | ||
506 | return 0; /* So we don't blow up on old processors */ | ||
507 | |||
508 | if (cpu_has_hypervisor) | ||
509 | return hypervisor_cpuid_base("KVMKVMKVM\0\0\0", 0); | ||
510 | |||
511 | return 0; | ||
512 | } | ||
513 | |||
514 | static inline uint32_t kvm_cpuid_base(void) | ||
515 | { | ||
516 | static int kvm_cpuid_base = -1; | ||
517 | |||
518 | if (kvm_cpuid_base == -1) | ||
519 | kvm_cpuid_base = __kvm_cpuid_base(); | ||
520 | |||
521 | return kvm_cpuid_base; | ||
522 | } | ||
523 | |||
524 | bool kvm_para_available(void) | ||
525 | { | ||
526 | return kvm_cpuid_base() != 0; | ||
527 | } | ||
528 | EXPORT_SYMBOL_GPL(kvm_para_available); | ||
529 | |||
530 | unsigned int kvm_arch_para_features(void) | ||
531 | { | ||
532 | return cpuid_eax(kvm_cpuid_base() | KVM_CPUID_FEATURES); | ||
533 | } | ||
534 | |||
503 | static uint32_t __init kvm_detect(void) | 535 | static uint32_t __init kvm_detect(void) |
504 | { | 536 | { |
505 | return kvm_cpuid_base(); | 537 | return kvm_cpuid_base(); |
@@ -673,7 +705,7 @@ static cpumask_t waiting_cpus; | |||
673 | /* Track spinlock on which a cpu is waiting */ | 705 | /* Track spinlock on which a cpu is waiting */ |
674 | static DEFINE_PER_CPU(struct kvm_lock_waiting, klock_waiting); | 706 | static DEFINE_PER_CPU(struct kvm_lock_waiting, klock_waiting); |
675 | 707 | ||
676 | static void kvm_lock_spinning(struct arch_spinlock *lock, __ticket_t want) | 708 | __visible void kvm_lock_spinning(struct arch_spinlock *lock, __ticket_t want) |
677 | { | 709 | { |
678 | struct kvm_lock_waiting *w; | 710 | struct kvm_lock_waiting *w; |
679 | int cpu; | 711 | int cpu; |