From owner-svn-src-head@freebsd.org Sat May 12 15:34:36 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0E5C0FAB86D; Sat, 12 May 2018 15:34:36 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B4D9B85D81; Sat, 12 May 2018 15:34:35 +0000 (UTC) (envelope-from emaste@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 92DB2203D2; Sat, 12 May 2018 15:34:35 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4CFYZo7031243; Sat, 12 May 2018 15:34:35 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4CFYZn5031242; Sat, 12 May 2018 15:34:35 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201805121534.w4CFYZn5031242@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sat, 12 May 2018 15:34:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333569 - head/usr.sbin/cpucontrol X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/usr.sbin/cpucontrol X-SVN-Commit-Revision: 333569 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 May 2018 15:34:36 -0000 Author: emaste Date: Sat May 12 15:34:35 2018 New Revision: 333569 URL: https://svnweb.freebsd.org/changeset/base/333569 Log: cpucontrol: improve Intel microcode revision check According to the Intel SDM (Volme 3, 9.11.7) the BIOS signature MSR should be zeroed before executing cpuid (although in practice it does not seem to matter). PR: 192487 Submitted by: Dan Lukes Reported by: Henrique de Moraes Holschuh MFC after: 3 days Modified: head/usr.sbin/cpucontrol/intel.c Modified: head/usr.sbin/cpucontrol/intel.c ============================================================================== --- head/usr.sbin/cpucontrol/intel.c Sat May 12 15:20:39 2018 (r333568) +++ head/usr.sbin/cpucontrol/intel.c Sat May 12 15:34:35 2018 (r333569) @@ -95,7 +95,8 @@ intel_update(const char *dev, const char *path) void *fw_data; size_t data_size, total_size; cpuctl_msr_args_t msrargs = { - .msr = MSR_IA32_PLATFORM_ID, + .msr = MSR_BIOS_SIGN, + .data = 0, }; cpuctl_cpuid_args_t idargs = { .level = 1, /* Signature. */ @@ -115,12 +116,18 @@ intel_update(const char *dev, const char *path) WARN(0, "could not open %s for writing", dev); return; } + error = ioctl(devfd, CPUCTL_WRMSR, &msrargs); + if (error < 0) { + WARN(0, "ioctl(%s)", dev); + goto fail; + } error = ioctl(devfd, CPUCTL_CPUID, &idargs); if (error < 0) { WARN(0, "ioctl(%s)", dev); goto fail; } signature = idargs.data[0]; + msrargs.msr = MSR_IA32_PLATFORM_ID; error = ioctl(devfd, CPUCTL_RDMSR, &msrargs); if (error < 0) { WARN(0, "ioctl(%s)", dev);