HyperV detection patch
Subsystems (2)
This is a resend of a patch I had posted a couple of weeks ago. As suggested by Jeremy, I am enclosing a patch that integrates HyperV detection with the current hypervisor detection mechanism in the kernel. A patch for implementing a HyperV clock source based on this patch will be sent out shortly.
From: K. Y. Srinivasan <[email protected]>
Subject: HyperV Detection code.
References: None
Patch-mainline:
This patch integrates HyperV detection within the framework currently used by VmWare. With this patch, we can avoid having to replicate the HyperV detection code in each of the HyperV specific Linux drivers - MSFT Linux Integration Components.
arch/x86/include/asm/processor.h +3 -0
@@ -114,6 +114,8 @@ struct cpuinfo_x86 {u16 cpu_index;#endif unsigned int x86_hyper_vendor; +/* The layout of this field is hypervisor specific */ +unsigned int x86_hyper_features; } __attribute__((__aligned__(SMP_CACHE_BYTES)));#define X86_VENDOR_INTEL 0
@@ -129,6 +131,7 @@ struct cpuinfo_x86 {#define X86_HYPER_VENDOR_NONE 0#define X86_HYPER_VENDOR_VMWARE 1 +#define X86_HYPER_VENDOR_MSFT 2/* * capabilities of CPUs
arch/x86/kernel/cpu/Makefile +1 -1
@@ -14,7 +14,7 @@ CFLAGS_common.o := $(nostackp) obj-y := intel_cacheinfo.o addon_cpuid_features.o obj-y += proc.o capflags.o powerflags.o common.o -obj-y += vmware.o hypervisor.o sched.o +obj-y += vmware.o hypervisor.o sched.o hyperv.o obj-$(CONFIG_X86_32) += bugs.o cmpxchg.o obj-$(CONFIG_X86_64) += bugs_64.o
arch/x86/kernel/cpu/hyperv.c new file +66 -0
66 lines not on this page · raw message
arch/x86/kernel/cpu/hypervisor.c +7 -3
@@ -23,6 +23,7 @@#include <asm/processor.h> #include <asm/vmware.h> +#include <asm/hyperv.h> #include <asm/hypervisor.h> static inline void __cpuinit
@@ -30,6 +31,8 @@ detect_hypervisor_vendor(struct cpuinfo_ {if (vmware_platform ()) c->x86_hyper_vendor =X86_HYPER_VENDOR_VMWARE ; +else if (hyperv_platform ()) + c->x86_hyper_vendor =X86_HYPER_VENDOR_MSFT ;else c->x86_hyper_vendor =X86_HYPER_VENDOR_NONE ; }
@@ -37,10 +40,11 @@ detect_hypervisor_vendor(struct cpuinfo_static inline void __cpuinit hypervisor_set_feature_bits (struct cpuinfo_x86 *c) { -if (boot_cpu_data.x86_hyper_vendor ==X86_HYPER_VENDOR_VMWARE ) { +if (boot_cpu_data.x86_hyper_vendor ==X86_HYPER_VENDOR_VMWARE )vmware_set_feature_bits (c); -return ; - } +else if (boot_cpu_data.x86_hyper_vendor ==X86_HYPER_VENDOR_MSFT ) +hyperv_set_feature_bits (c); +return ; }void __cpuinit init_hypervisor (struct cpuinfo_x86 *c)
arch/x86/include/asm/hyperv.h +10 -0
@@ -2,6 +2,8 @@#define _ASM_X86_KVM_HYPERV_H#include <linux/types.h> +#include <linux/init.h> +#include <asm/processor.h> /* * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
@@ -14,6 +16,9 @@#define HYPERV_CPUID_ENLIGHTMENT_INFO 0x40000004#define HYPERV_CPUID_IMPLEMENT_LIMITS 0x40000005 +#define HYPERV_HYPERVISOR_PRESENT_BIT 0x80000000 +#define HYPERV_CPUID_MIN 0x40000005 +/* * Feature identification. EAX indicates which features are available * to the partition based upon the current partition privileges.
@@ -129,6 +134,9 @@/* MSR used to provide vcpu index */ #define HV_X64_MSR_VP_INDEX 0x40000002 +/* MSR used to read the per-partition time reference counter */ +#define HV_X64_MSR_TIME_REF_COUNT 0x40000020 +/* Define the virtual APIC registers */ #define HV_X64_MSR_EOI 0x40000070#define HV_X64_MSR_ICR 0x40000071
@@ -183,4 +191,6 @@#define HV_STATUS_INVALID_HYPERCALL_INPUT 3#define HV_STATUS_INVALID_ALIGNMENT 4 +int hyperv_platform (void ); +void __cpuinit hyperv_set_feature_bits (struct cpuinfo_x86 *c);#endif
_______________________________________________
Virtualization-Mngt mailing list [email protected]
https://lists.innerweb.novell.com/mailman/listinfo/virtualization-mngt
Search Archives: https://lists.innerweb.novell.com/search