From owner-svn-src-projects@FreeBSD.ORG Thu Oct 16 19:27:27 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9E0CD30C; Thu, 16 Oct 2014 19:27:27 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 8B7141E1; Thu, 16 Oct 2014 19:27:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9GJRRg5031184; Thu, 16 Oct 2014 19:27:27 GMT (envelope-from neel@FreeBSD.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9GJRRtV031183; Thu, 16 Oct 2014 19:27:27 GMT (envelope-from neel@FreeBSD.org) Message-Id: <201410161927.s9GJRRtV031183@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: neel set sender to neel@FreeBSD.org using -f From: Neel Natu Date: Thu, 16 Oct 2014 19:27:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r273179 - projects/bhyve_svm/usr.sbin/bhyve X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Oct 2014 19:27:27 -0000 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); }