Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Oct 2014 19:27:27 +0000 (UTC)
From:      Neel Natu <neel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r273179 - projects/bhyve_svm/usr.sbin/bhyve
Message-ID:  <201410161927.s9GJRRtV031183@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: neel
Date: Thu Oct 16 19:27:26 2014
New Revision: 273179
URL: https://svnweb.freebsd.org/changeset/base/273179

Log:
  Emulate the "Hardware Configuration" MSR when running on an AMD host.
  
  This gets rid of the "TSC doesn't count with P0 frequency!" message when
  booting a Linux guest.
  
  Tested on an "AMD Opteron 6320" courtesy of Ben Perrault.

Modified:
  projects/bhyve_svm/usr.sbin/bhyve/xmsr.c

Modified: projects/bhyve_svm/usr.sbin/bhyve/xmsr.c
==============================================================================
--- projects/bhyve_svm/usr.sbin/bhyve/xmsr.c	Thu Oct 16 18:49:50 2014	(r273178)
+++ projects/bhyve_svm/usr.sbin/bhyve/xmsr.c	Thu Oct 16 19:27:26 2014	(r273179)
@@ -46,11 +46,11 @@ __FBSDID("$FreeBSD$");
 static int cpu_vendor_intel, cpu_vendor_amd;
 
 int
-emulate_wrmsr(struct vmctx *ctx, int vcpu, uint32_t code, uint64_t val)
+emulate_wrmsr(struct vmctx *ctx, int vcpu, uint32_t num, uint64_t val)
 {
 
 	if (cpu_vendor_intel) {
-		switch (code) {
+		switch (num) {
 		case 0xd04:		/* Sandy Bridge uncore PMCs */
 		case 0xc24:
 			return (0);
@@ -61,6 +61,16 @@ emulate_wrmsr(struct vmctx *ctx, int vcp
 		default:
 			break;
 		}
+	} else if (cpu_vendor_amd) {
+		switch (num) {
+		case MSR_HWCR:
+			/*
+			 * Ignore writes to hardware configuration MSR.
+			 */
+			return (0);
+		default:
+			break;
+		}
 	}
 	return (-1);
 }
@@ -91,6 +101,21 @@ emulate_rdmsr(struct vmctx *ctx, int vcp
 			error = -1;
 			break;
 		}
+	} else if (cpu_vendor_amd) {
+		switch (num) {
+		case MSR_HWCR:
+			/*
+			 * Bios and Kernel Developer's Guides for AMD Families
+			 * 12H, 14H, 15H and 16H.
+			 */
+			*val = 0x01000010;	/* Reset value */
+			*val |= 1 << 9;		/* MONITOR/MWAIT disable */
+			break;
+		default:
+			break;
+		}
+	} else {
+		error = -1;
 	}
 	return (error);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410161927.s9GJRRtV031183>