From owner-svn-src-stable-10@freebsd.org Thu Jun 16 05:12:30 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 390B0A4704E; Thu, 16 Jun 2016 05:12:30 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 149C01E70; Thu, 16 Jun 2016 05:12:30 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5G5CTkV095228; Thu, 16 Jun 2016 05:12:29 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5G5CTR4095225; Thu, 16 Jun 2016 05:12:29 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606160512.u5G5CTR4095225@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 16 Jun 2016 05:12:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301951 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 05:12:30 -0000 Author: sephe Date: Thu Jun 16 05:12:28 2016 New Revision: 301951 URL: https://svnweb.freebsd.org/changeset/base/301951 Log: 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 Modified: stable/10/sys/dev/hyperv/vmbus/hv_hv.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/hv_hv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_hv.c Thu Jun 16 04:32:11 2016 (r301950) +++ stable/10/sys/dev/hyperv/vmbus/hv_hv.c Thu Jun 16 05:12:28 2016 (r301951) @@ -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 */ @@ -74,47 +78,6 @@ hv_get_timecount(struct timecounter *tc) } /** - * @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 */ static uint64_t @@ -163,7 +126,6 @@ hv_vmbus_do_hypercall(uint64_t control, 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" /* 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" - "\001VPRUNTIME" - "\002TMREFCNT" - "\003SYNCIC" - "\004SYNCTM" - "\005APIC" - "\006HYERCALL" - "\007VPINDEX" - "\010RESET" - "\011STATS" - "\012REFTSC" - "\013IDLE" - "\014TMFREQ" - "\015DEBUG"); + "\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); Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Thu Jun 16 04:32:11 2016 (r301950) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c Thu Jun 16 05:12:28 2016 (r301951) @@ -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(); Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Thu Jun 16 04:32:11 2016 (r301950) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Thu Jun 16 05:12:28 2016 (r301951) @@ -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,