Page MenuHomeFreeBSD

D6553.diff
No OneTemporary

D6553.diff

Index: head/sys/dev/hyperv/vmbus/hv_hv.c
===================================================================
--- head/sys/dev/hyperv/vmbus/hv_hv.c
+++ head/sys/dev/hyperv/vmbus/hv_hv.c
@@ -52,34 +52,24 @@
#define HYPERV_INTERFACE 0x31237648 /* HV#1 */
-/*
- * The guest OS needs to register the guest ID with the hypervisor.
- * The guest ID is a 64 bit entity and the structure of this ID is
- * specified in the Hyper-V specification:
- *
- * http://msdn.microsoft.com/en-us/library/windows/
- * hardware/ff542653%28v=vs.85%29.aspx
- *
- * While the current guideline does not specify how FreeBSD guest ID(s)
- * need to be generated, our plan is to publish the guidelines for
- * FreeBSD and other guest operating systems that currently are hosted
- * on Hyper-V. The implementation here conforms to this yet
- * unpublished guidelines.
- *
- * Bit(s)
- * 63 - Indicates if the OS is Open Source or not; 1 is Open Source
- * 62:56 - Os Type: FreeBSD is 0x02
- * 55:48 - Distro specific identification
- * 47:16 - FreeBSD kernel version number
- * 15:0 - Distro specific identification
- */
-#define HYPERV_GUESTID_OSS (0x1ULL << 63)
-#define HYPERV_GUESTID_FREEBSD (0x02ULL << 56)
-#define HYPERV_GUESTID(id) \
- (HYPERV_GUESTID_OSS | HYPERV_GUESTID_FREEBSD | \
- (((uint64_t)(((id) & 0xff0000) >> 16)) << 48) |\
- (((uint64_t)__FreeBSD_version) << 16) | \
- ((uint64_t)((id) & 0x00ffff)))
+#define HYPERV_FREEBSD_BUILD 0ULL
+#define HYPERV_FREEBSD_VERSION ((uint64_t)__FreeBSD_version)
+#define HYPERV_FREEBSD_OSID 0ULL
+
+#define MSR_HV_GUESTID_BUILD_FREEBSD \
+ (HYPERV_FREEBSD_BUILD & MSR_HV_GUESTID_BUILD_MASK)
+#define MSR_HV_GUESTID_VERSION_FREEBSD \
+ ((HYPERV_FREEBSD_VERSION << MSR_HV_GUESTID_VERSION_SHIFT) & \
+ MSR_HV_GUESTID_VERSION_MASK)
+#define MSR_HV_GUESTID_OSID_FREEBSD \
+ ((HYPERV_FREEBSD_OSID << MSR_HV_GUESTID_OSID_SHIFT) & \
+ MSR_HV_GUESTID_OSID_MASK)
+
+#define MSR_HV_GUESTID_FREEBSD \
+ (MSR_HV_GUESTID_BUILD_FREEBSD | \
+ MSR_HV_GUESTID_VERSION_FREEBSD | \
+ MSR_HV_GUESTID_OSID_FREEBSD | \
+ MSR_HV_GUESTID_OSTYPE_FREEBSD)
struct hypercall_ctx {
void *hc_addr;
@@ -321,8 +311,8 @@
return;
}
- /* Write guest id */
- wrmsr(HV_X64_MSR_GUEST_OS_ID, HYPERV_GUESTID(0));
+ /* Set guest id */
+ wrmsr(MSR_HV_GUEST_OS_ID, MSR_HV_GUESTID_FREEBSD);
if (hyperv_features & HV_FEATURE_MSR_TIME_REFCNT) {
/* Register virtual timecount */
Index: head/sys/dev/hyperv/vmbus/hyperv_reg.h
===================================================================
--- head/sys/dev/hyperv/vmbus/hyperv_reg.h
+++ head/sys/dev/hyperv/vmbus/hyperv_reg.h
@@ -29,6 +29,20 @@
#ifndef _HYPERV_REG_H_
#define _HYPERV_REG_H_
+#define MSR_HV_GUEST_OS_ID 0x40000000
+#define MSR_HV_GUESTID_BUILD_MASK 0xffffULL
+#define MSR_HV_GUESTID_VERSION_MASK 0x0000ffffffff0000ULL
+#define MSR_HV_GUESTID_VERSION_SHIFT 16
+#define MSR_HV_GUESTID_OSID_MASK 0x00ff000000000000ULL
+#define MSR_HV_GUESTID_OSID_SHIFT 48
+#define MSR_HV_GUESTID_OSTYPE_MASK 0x7f00000000000000ULL
+#define MSR_HV_GUESTID_OSTYPE_SHIFT 56
+#define MSR_HV_GUESTID_OPENSRC 0x8000000000000000ULL
+#define MSR_HV_GUESTID_OSTYPE_LINUX \
+ ((0x01ULL << MSR_HV_GUESTID_OSTYPE_SHIFT) | MSR_HV_GUESTID_OPENSRC)
+#define MSR_HV_GUESTID_OSTYPE_FREEBSD \
+ ((0x02ULL << MSR_HV_GUESTID_OSTYPE_SHIFT) | MSR_HV_GUESTID_OPENSRC)
+
#define MSR_HV_HYPERCALL 0x40000001
#define MSR_HV_HYPERCALL_ENABLE 0x0001ULL
#define MSR_HV_HYPERCALL_RSVD_MASK 0x0ffeULL

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 5, 5:28 AM (17 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30872147
Default Alt Text
D6553.diff (3 KB)

Event Timeline