Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/sys/arch/x86/x86 Pull up following revision(s) (requested...
details: https://anonhg.NetBSD.org/src/rev/b8c57e80fb60
branches: netbsd-7
changeset: 799564:b8c57e80fb60
user: snj <snj%NetBSD.org@localhost>
date: Tue Aug 11 05:13:44 2015 +0000
description:
Pull up following revision(s) (requested by msaitoh in ticket #945):
sys/arch/x86/x86/cpu_ucode_intel.c: revisions 1.7, 1.8
Re-allocale buffer if a buffer for microcode is not 16byte aligned.
--
Use roundup2() and uintptr_t. Adviced by riastradh@.
diffstat:
sys/arch/x86/x86/cpu_ucode_intel.c | 40 +++++++++++++++++++++++++------------
1 files changed, 27 insertions(+), 13 deletions(-)
diffs (84 lines):
diff -r 3e9664355931 -r b8c57e80fb60 sys/arch/x86/x86/cpu_ucode_intel.c
--- a/sys/arch/x86/x86/cpu_ucode_intel.c Tue Aug 11 05:11:08 2015 +0000
+++ b/sys/arch/x86/x86/cpu_ucode_intel.c Tue Aug 11 05:13:44 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_ucode_intel.c,v 1.5.4.1 2015/01/09 10:33:07 martin Exp $ */
+/* $NetBSD: cpu_ucode_intel.c,v 1.5.4.2 2015/08/11 05:13:44 snj 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.1 2015/01/09 10:33:07 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.5.4.2 2015/08/11 05:13:44 snj Exp $");
#include "opt_xen.h"
#include "opt_cpu_ucode.h"
@@ -111,40 +111,54 @@
uint32_t ucodetarget, oucodeversion, nucodeversion;
int platformid;
struct intel1_ucode_header *uh;
+ size_t newbufsize = 0;
+ int rv = 0;
if (sc->loader_version != CPU_UCODE_LOADER_INTEL1
|| cpuno != CPU_UCODE_CURRENT_CPU)
return EINVAL;
- /* XXX relies on malloc alignment */
- if ((uintptr_t)(sc->sc_blob) & 15) {
- printf("ucode alignment bad\n");
- return EINVAL;
- }
-
uh = (struct intel1_ucode_header *)(sc->sc_blob);
if (uh->uh_header_ver != 1 || uh->uh_loader_rev != 1)
return EINVAL;
ucodetarget = uh->uh_rev;
+ 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) {
+ printf("%s: memory allocation failed\n", __func__);
+ return EINVAL;
+ }
+ uh = (struct intel1_ucode_header *)roundup2((uintptr_t)uh, 16);
+ /* Copy to the new area */
+ memcpy(uh, sc->sc_blob, sc->sc_blobsize);
+ }
+
kpreempt_disable();
intel_getcurrentucode(&oucodeversion, &platformid);
if (oucodeversion >= ucodetarget) {
kpreempt_enable();
- return EEXIST; /* ??? */
+ rv = EEXIST; /* ??? */
+ goto out;
}
wrmsr(MSR_BIOS_UPDT_TRIG, (uintptr_t)(sc->sc_blob) + 48);
intel_getcurrentucode(&nucodeversion, &platformid);
kpreempt_enable();
- if (nucodeversion != ucodetarget)
- return EIO;
+ if (nucodeversion != ucodetarget) {
+ rv = EIO;
+ goto out;
+ }
printf("cpu %d: ucode 0x%x->0x%x\n", curcpu()->ci_index,
oucodeversion, nucodeversion);
-
- return 0;
+out:
+ if (newbufsize != 0)
+ kmem_free(uh, newbufsize);
+ return rv;
}
#endif /* ! XEN */
Home |
Main Index |
Thread Index |
Old Index