Skip to content

Commit fc73373

Browse files
praritavikivity
authored andcommitted
KVM: Add x86_hyper_kvm to complete detect_hypervisor_platform check
While debugging I noticed that unlike all the other hypervisor code in the kernel, kvm does not have an entry for x86_hyper which is used in detect_hypervisor_platform() which results in a nice printk in the syslog. This is only really a stub function but it does make kvm more consistent with the other hypervisors. Signed-off-by: Prarit Bhargava <[email protected]> Cc: Avi Kivity <[email protected]> Cc: Gleb Natapov <[email protected]> Cc: Alex Williamson <[email protected]> Cc: Konrad Rzeszutek Wilk <[email protected]> Cc: Marcelo Tostatti <[email protected]> Cc: [email protected] Signed-off-by: Avi Kivity <[email protected]>
1 parent 58d8b17 commit fc73373

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

arch/x86/include/asm/hypervisor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ extern const struct hypervisor_x86 *x86_hyper;
4949
extern const struct hypervisor_x86 x86_hyper_vmware;
5050
extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
5151
extern const struct hypervisor_x86 x86_hyper_xen_hvm;
52+
extern const struct hypervisor_x86 x86_hyper_kvm;
5253

5354
static inline bool hypervisor_x2apic_available(void)
5455
{

arch/x86/kernel/cpu/hypervisor.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
3737
#endif
3838
&x86_hyper_vmware,
3939
&x86_hyper_ms_hyperv,
40+
&x86_hyper_kvm,
4041
};
4142

4243
const struct hypervisor_x86 *x86_hyper;

arch/x86/kernel/kvm.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <asm/idle.h>
4242
#include <asm/apic.h>
4343
#include <asm/apicdef.h>
44+
#include <asm/hypervisor.h>
4445

4546
static int kvmapf = 1;
4647

@@ -483,6 +484,19 @@ void __init kvm_guest_init(void)
483484
#endif
484485
}
485486

487+
static bool __init kvm_detect(void)
488+
{
489+
if (!kvm_para_available())
490+
return false;
491+
return true;
492+
}
493+
494+
const struct hypervisor_x86 x86_hyper_kvm __refconst = {
495+
.name = "KVM",
496+
.detect = kvm_detect,
497+
};
498+
EXPORT_SYMBOL_GPL(x86_hyper_kvm);
499+
486500
static __init int activate_jump_labels(void)
487501
{
488502
if (has_steal_clock) {

0 commit comments

Comments
 (0)