Module Name: src Committed By: riz Date: Fri Nov 6 22:50:56 UTC 2015
Modified Files: src/sys/arch/x86/x86 [netbsd-7]: cpu_ucode_intel.c Log Message: Pull up following revision(s) (requested by jym in ticket #994): sys/arch/x86/x86/cpu_ucode_intel.c: revision 1.10 sys/arch/x86/x86/cpu_ucode_intel.c: revision 1.9 kmem_free() the address returned by kmem_alloc(). found by Brainy. use the newly aligned location if we needed it. found by kre. 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.5.4.2 -r1.5.4.3 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.5.4.2 src/sys/arch/x86/x86/cpu_ucode_intel.c:1.5.4.3 --- src/sys/arch/x86/x86/cpu_ucode_intel.c:1.5.4.2 Tue Aug 11 05:13:44 2015 +++ src/sys/arch/x86/x86/cpu_ucode_intel.c Fri Nov 6 22:50:56 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_ucode_intel.c,v 1.5.4.2 2015/08/11 05:13:44 snj Exp $ */ +/* $NetBSD: cpu_ucode_intel.c,v 1.5.4.3 2015/11/06 22:50:56 riz 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.5.4.2 2015/08/11 05:13:44 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.5.4.3 2015/11/06 22:50:56 riz Exp $"); #include "opt_xen.h" #include "opt_cpu_ucode.h" @@ -109,8 +109,9 @@ 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; int rv = 0; @@ -126,12 +127,12 @@ cpu_ucode_intel_apply(struct cpu_ucode_s if ((uintptr_t)(sc->sc_blob) & 15) { /* Make the buffer 16 byte aligned */ newbufsize = sc->sc_blobsize + 15; - uh = kmem_alloc(newbufsize, KM_SLEEP); - if (uh == NULL) { + uha = kmem_alloc(newbufsize, KM_SLEEP); + if (uha == NULL) { printf("%s: memory allocation failed\n", __func__); return EINVAL; } - uh = (struct intel1_ucode_header *)roundup2((uintptr_t)uh, 16); + uh = (struct intel1_ucode_header *)roundup2((uintptr_t)uha, 16); /* Copy to the new area */ memcpy(uh, sc->sc_blob, sc->sc_blobsize); } @@ -144,8 +145,9 @@ cpu_ucode_intel_apply(struct cpu_ucode_s rv = EEXIST; /* ??? */ goto out; } - wrmsr(MSR_BIOS_UPDT_TRIG, (uintptr_t)(sc->sc_blob) + 48); + wrmsr(MSR_BIOS_UPDT_TRIG, (uintptr_t)uh + 48); intel_getcurrentucode(&nucodeversion, &platformid); + cpuid = curcpu()->ci_index; kpreempt_enable(); @@ -154,11 +156,11 @@ 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) - kmem_free(uh, newbufsize); + kmem_free(uha, newbufsize); return rv; } #endif /* ! XEN */