MFC 297636,297800,297801,297805,297807,297808
297636 hyperv: Typo in r297634 Noticed by: hiren MFC after: 1 week Sponsored by: Microsoft OSTC 297800 hyperv/vmbus: Nuke unused function MFC after: 1 week Sponsored by: Microsoft OSTC 297801 hyperv/vmbus: Get rid of max_leaf detection; this is actually not used. It will be replaced by a new one. MFC after: 1 week Sponsored by: Microsoft OSTC 297805 hyperv: Break long line MFC after: 1 week Sponsored by: Microsoft OSTC 297807 hyperv: Print more features And add comment about the MSR features. MFC after: 1 week Sponsored by: Microsoft OSTC 297808 hyperv: Define macro for Hyper-V interface Suggested by: rpokala MFC after: 1 week Sponsored by: Microsoft OSTC
This commit is contained in:
parent
53328344ab
commit
18225d8f93
@ -48,12 +48,16 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#define HV_NANOSECONDS_PER_SEC 1000000000L
|
||||
|
||||
#define HYPERV_INTERFACE 0x31237648 /* HV#1 */
|
||||
|
||||
static u_int hv_get_timecount(struct timecounter *tc);
|
||||
|
||||
u_int hyperv_features;
|
||||
u_int hyperv_recommends;
|
||||
|
||||
static u_int hyperv_pm_features;
|
||||
static u_int hyperv_features3;
|
||||
|
||||
/**
|
||||
* Globals
|
||||
*/
|
||||
@ -73,47 +77,6 @@ hv_get_timecount(struct timecounter *tc)
|
||||
return (now);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Query the cpuid for presence of windows hypervisor
|
||||
*/
|
||||
int
|
||||
hv_vmbus_query_hypervisor_presence(void)
|
||||
{
|
||||
if (vm_guest != VM_GUEST_HV)
|
||||
return (0);
|
||||
|
||||
return (hv_high >= HV_X64_CPUID_MIN && hv_high <= HV_X64_CPUID_MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get version of the windows hypervisor
|
||||
*/
|
||||
static int
|
||||
hv_vmbus_get_hypervisor_version(void)
|
||||
{
|
||||
u_int regs[4];
|
||||
unsigned int maxLeaf;
|
||||
unsigned int op;
|
||||
|
||||
/*
|
||||
* Its assumed that this is called after confirming that
|
||||
* Viridian is present
|
||||
* Query id and revision.
|
||||
*/
|
||||
op = HV_CPU_ID_FUNCTION_HV_VENDOR_AND_MAX_FUNCTION;
|
||||
do_cpuid(op, regs);
|
||||
|
||||
maxLeaf = regs[0];
|
||||
op = HV_CPU_ID_FUNCTION_HV_INTERFACE;
|
||||
do_cpuid(op, regs);
|
||||
|
||||
if (maxLeaf >= HV_CPU_ID_FUNCTION_MS_HV_VERSION) {
|
||||
op = HV_CPU_ID_FUNCTION_MS_HV_VERSION;
|
||||
do_cpuid(op, regs);
|
||||
}
|
||||
return (maxLeaf);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Invoke the specified hypercall
|
||||
*/
|
||||
@ -163,7 +126,6 @@ hv_vmbus_do_hypercall(uint64_t control, void* input, void* output)
|
||||
int
|
||||
hv_vmbus_init(void)
|
||||
{
|
||||
int max_leaf;
|
||||
hv_vmbus_x64_msr_hypercall_contents hypercall_msr;
|
||||
void* virt_addr = 0;
|
||||
|
||||
@ -180,8 +142,6 @@ hv_vmbus_init(void)
|
||||
if (vm_guest != VM_GUEST_HV)
|
||||
goto cleanup;
|
||||
|
||||
max_leaf = hv_vmbus_get_hypervisor_version();
|
||||
|
||||
/*
|
||||
* Write our OS info
|
||||
*/
|
||||
@ -457,7 +417,7 @@ hyperv_identify(void)
|
||||
|
||||
op = HV_CPU_ID_FUNCTION_HV_INTERFACE;
|
||||
do_cpuid(op, regs);
|
||||
if (regs[0] != 0x31237648 /* HV#1 */)
|
||||
if (regs[0] != HYPERV_INTERFACE)
|
||||
return (false);
|
||||
|
||||
op = HV_CPU_ID_FUNCTION_MS_HV_FEATURES;
|
||||
@ -470,27 +430,50 @@ hyperv_identify(void)
|
||||
return (false);
|
||||
}
|
||||
hyperv_features = regs[0];
|
||||
hyperv_pm_features = regs[2];
|
||||
hyperv_features3 = regs[3];
|
||||
|
||||
op = HV_CPU_ID_FUNCTION_MS_HV_VERSION;
|
||||
do_cpuid(op, regs);
|
||||
printf("Hyper-V Version: %d.%d.%d [SP%d]\n",
|
||||
regs[1] >> 16, regs[1] & 0xffff, regs[0], regs[2]);
|
||||
|
||||
printf(" Features: 0x%b\n", hyperv_features,
|
||||
printf(" Features=0x%b\n", hyperv_features,
|
||||
"\020"
|
||||
"\001VPRUNTIME"
|
||||
"\002TMREFCNT"
|
||||
"\003SYNCIC"
|
||||
"\004SYNCTM"
|
||||
"\005APIC"
|
||||
"\006HYERCALL"
|
||||
"\007VPINDEX"
|
||||
"\010RESET"
|
||||
"\011STATS"
|
||||
"\012REFTSC"
|
||||
"\013IDLE"
|
||||
"\014TMFREQ"
|
||||
"\015DEBUG");
|
||||
"\001VPRUNTIME" /* MSR_VP_RUNTIME */
|
||||
"\002TMREFCNT" /* MSR_TIME_REF_COUNT */
|
||||
"\003SYNIC" /* MSRs for SynIC */
|
||||
"\004SYNTM" /* MSRs for SynTimer */
|
||||
"\005APIC" /* MSR_{EOI,ICR,TPR} */
|
||||
"\006HYERCALL" /* MSR_{GUEST_OS_ID,HYPERCALL} */
|
||||
"\007VPINDEX" /* MSR_VP_INDEX */
|
||||
"\010RESET" /* MSR_RESET */
|
||||
"\011STATS" /* MSR_STATS_ */
|
||||
"\012REFTSC" /* MSR_REFERENCE_TSC */
|
||||
"\013IDLE" /* MSR_GUEST_IDLE */
|
||||
"\014TMFREQ" /* MSR_{TSC,APIC}_FREQUENCY */
|
||||
"\015DEBUG"); /* MSR_SYNTH_DEBUG_ */
|
||||
printf(" PM Features=max C%u, 0x%b\n",
|
||||
HV_PM_FEATURE_CSTATE(hyperv_pm_features),
|
||||
(hyperv_pm_features & ~HV_PM_FEATURE_CSTATE_MASK),
|
||||
"\020"
|
||||
"\005C3HPET"); /* HPET is required for C3 state */
|
||||
printf(" Features3=0x%b\n", hyperv_features3,
|
||||
"\020"
|
||||
"\001MWAIT" /* MWAIT */
|
||||
"\002DEBUG" /* guest debug support */
|
||||
"\003PERFMON" /* performance monitor */
|
||||
"\004PCPUDPE" /* physical CPU dynamic partition event */
|
||||
"\005XMMHC" /* hypercall input through XMM regs */
|
||||
"\006IDLE" /* guest idle support */
|
||||
"\007SLEEP" /* hypervisor sleep support */
|
||||
"\010NUMA" /* NUMA distance query support */
|
||||
"\011TMFREQ" /* timer frequency query (TSC, LAPIC) */
|
||||
"\012SYNCMC" /* inject synthetic machine checks */
|
||||
"\013CRASH" /* MSRs for guest crash */
|
||||
"\014DEBUGMSR" /* MSRs for guest debug */
|
||||
"\015NPIEP" /* NPIEP */
|
||||
"\016HVDIS"); /* disabling hypervisor */
|
||||
|
||||
op = HV_CPU_ID_FUNCTION_MS_HV_ENLIGHTENMENT_INFORMATION;
|
||||
do_cpuid(op, regs);
|
||||
@ -528,4 +511,5 @@ hyperv_init(void *dummy __unused)
|
||||
tc_init(&hv_timecounter);
|
||||
}
|
||||
}
|
||||
SYSINIT(hyperv_initialize, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, hyperv_init, NULL);
|
||||
SYSINIT(hyperv_initialize, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, hyperv_init,
|
||||
NULL);
|
||||
|
@ -120,7 +120,7 @@ handled:
|
||||
*
|
||||
* NOTE:
|
||||
* mb() is used here, since atomic_thread_fence_seq_cst()
|
||||
* will become compler fence on UP kernel.
|
||||
* will become compiler fence on UP kernel.
|
||||
*/
|
||||
mb();
|
||||
|
||||
@ -197,7 +197,7 @@ hv_vmbus_isr(struct trapframe *frame)
|
||||
*
|
||||
* NOTE:
|
||||
* mb() is used here, since atomic_thread_fence_seq_cst()
|
||||
* will become compler fence on UP kernel.
|
||||
* will become compiler fence on UP kernel.
|
||||
*/
|
||||
mb();
|
||||
|
||||
|
@ -475,12 +475,23 @@ typedef enum {
|
||||
HV_CPU_ID_FUNCTION_MS_HV_HARDWARE_FEATURE = 0x40000006
|
||||
} hv_vmbus_cpuid_function;
|
||||
|
||||
#define HV_FEATURE_MSR_TIME_REFCNT (1 << 1)
|
||||
#define HV_FEATURE_MSR_SYNCIC (1 << 2)
|
||||
#define HV_FEATURE_MSR_STIMER (1 << 3)
|
||||
#define HV_FEATURE_MSR_APIC (1 << 4)
|
||||
#define HV_FEATURE_MSR_HYPERCALL (1 << 5)
|
||||
#define HV_FEATURE_MSR_GUEST_IDLE (1 << 10)
|
||||
#define HV_FEATURE_MSR_TIME_REFCNT 0x0002 /* MSR_TIME_REF_COUNT */
|
||||
#define HV_FEATURE_MSR_SYNIC 0x0004 /* MSRs for SynIC */
|
||||
#define HV_FEATURE_MSR_SYNTIMER 0x0008 /* MSRs for SynTimer */
|
||||
#define HV_FEATURE_MSR_APIC 0x0010 /* MSR_{EOI,ICR,TPR} */
|
||||
#define HV_FEATURE_MSR_HYPERCALL 0x0020 /* MSR_{GUEST_OS_ID,HYPERCALL} */
|
||||
#define HV_FEATURE_MSR_GUEST_IDLE 0x0400 /* MSR_GUEST_IDLE */
|
||||
|
||||
#define HV_PM_FEATURE_CSTATE_MASK 0x000f
|
||||
#define HV_PM_FEATURE_C3_HPET 0x0010 /* C3 requires HPET */
|
||||
#define HV_PM_FEATURE_CSTATE(f) ((f) & HV_PM_FEATURE_CSTATE_MASK)
|
||||
|
||||
#define HV_FEATURE3_MWAIT 0x0001 /* MWAIT */
|
||||
#define HV_FEATURE3_XMM_HYPERCALL 0x0010 /* hypercall input through XMM regs */
|
||||
#define HV_FEATURE3_GUEST_IDLE 0x0020 /* guest idle support */
|
||||
#define HV_FEATURE3_NUMA 0x0080 /* NUMA distance query support */
|
||||
#define HV_FEATURE3_TIME_FREQ 0x0100 /* timer frequency query (TSC, LAPIC) */
|
||||
#define HV_FEATURE3_MSR_CRASH 0x0400 /* MSRs for guest crash */
|
||||
|
||||
/*
|
||||
* Define the format of the SIMP register
|
||||
@ -714,7 +725,6 @@ uint16_t hv_vmbus_post_msg_via_msg_ipc(
|
||||
uint16_t hv_vmbus_signal_event(void *con_id);
|
||||
void hv_vmbus_synic_init(void *irq_arg);
|
||||
void hv_vmbus_synic_cleanup(void *arg);
|
||||
int hv_vmbus_query_hypervisor_presence(void);
|
||||
|
||||
struct hv_device* hv_vmbus_child_device_create(
|
||||
hv_guid device_type,
|
||||
|
Loading…
x
Reference in New Issue
Block a user