Module Name:    src
Committed By:   jym
Date:           Sun Oct  4 21:08:30 UTC 2015

Modified Files:
        src/sys/arch/x86/x86: cpu_ucode_intel.c

Log Message:
Cache CPU index in the non-preemptible part otherwise it can be
unreliable (and report a CPU as patched while it was not).


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x86/x86/cpu_ucode_intel.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/cpu_ucode_intel.c
diff -u src/sys/arch/x86/x86/cpu_ucode_intel.c:1.9 src/sys/arch/x86/x86/cpu_ucode_intel.c:1.10
--- src/sys/arch/x86/x86/cpu_ucode_intel.c:1.9	Sun Oct  4 17:52:50 2015
+++ src/sys/arch/x86/x86/cpu_ucode_intel.c	Sun Oct  4 21:08:30 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_ucode_intel.c,v 1.9 2015/10/04 17:52:50 mrg Exp $ */
+/* $NetBSD: cpu_ucode_intel.c,v 1.10 2015/10/04 21:08:30 jym Exp $ */
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.9 2015/10/04 17:52:50 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.10 2015/10/04 21:08:30 jym Exp $");
 
 #include "opt_xen.h"
 #include "opt_cpu_ucode.h"
@@ -109,7 +109,7 @@ int
 cpu_ucode_intel_apply(struct cpu_ucode_softc *sc, int cpuno)
 {
 	uint32_t ucodetarget, oucodeversion, nucodeversion;
-	int platformid;
+	int platformid, cpuid;
 	struct intel1_ucode_header *uh;
 	void *uha;
 	size_t newbufsize = 0;
@@ -147,6 +147,7 @@ cpu_ucode_intel_apply(struct cpu_ucode_s
 	}
 	wrmsr(MSR_BIOS_UPDT_TRIG, (uintptr_t)uh + 48);
 	intel_getcurrentucode(&nucodeversion, &platformid);
+	cpuid = curcpu()->ci_index;
 
 	kpreempt_enable();
 
@@ -155,7 +156,7 @@ cpu_ucode_intel_apply(struct cpu_ucode_s
 		goto out;
 	}
 
-	printf("cpu %d: ucode 0x%x->0x%x\n", curcpu()->ci_index,
+	printf("cpu %d: ucode 0x%x->0x%x\n", cpuid,
 	       oucodeversion, nucodeversion);
 out:
 	if (newbufsize != 0)

Reply via email to