Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/sys/arch/x86/x86 Pull up following revision(s) (requested...
details: https://anonhg.NetBSD.org/src/rev/07d8b9918d94
branches: netbsd-6
changeset: 774101:07d8b9918d94
user: riz <riz%NetBSD.org@localhost>
date: Thu May 17 18:17:32 2012 +0000
description:
Pull up following revision(s) (requested by cegger in ticket #248):
sys/arch/x86/x86/cpu_ucode_amd.c: revision 1.2
fix crash when booting with -x.
diffstat:
sys/arch/x86/x86/cpu_ucode_amd.c | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diffs (76 lines):
diff -r f348b7d19334 -r 07d8b9918d94 sys/arch/x86/x86/cpu_ucode_amd.c
--- a/sys/arch/x86/x86/cpu_ucode_amd.c Thu May 17 18:12:50 2012 +0000
+++ b/sys/arch/x86/x86/cpu_ucode_amd.c Thu May 17 18:17:32 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_ucode_amd.c,v 1.1 2012/01/13 16:05:15 cegger Exp $ */
+/* $NetBSD: cpu_ucode_amd.c,v 1.1.2.1 2012/05/17 18:17:32 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_amd.c,v 1.1 2012/01/13 16:05:15 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_amd.c,v 1.1.2.1 2012/05/17 18:17:32 riz Exp $");
#include "opt_xen.h"
#include "opt_cpu_ucode.h"
@@ -150,12 +150,14 @@
struct microcode_amd mc_amd;
struct mc_buf mc;
device_t dev;
+ int s;
memcpy(&mc, arg1, sizeof(mc));
mc_amd.mpb = mc.mc_amd->mpb;
mc_amd.mpb_size = mc.mc_amd->mpb_size;
dev = curcpu()->ci_dev;
+ s = splhigh();
do {
uint64_t patchlevel;
@@ -168,7 +170,7 @@
hdr = (struct microcode_amd_header *)mc_amd.mpb;
if (hdr->ah_processor_rev_id != mc.mc_equiv_cpuid) {
- aprint_debug_dev(dev, "ucode: patch does not"
+ aprint_debug_dev(dev, "ucode: patch does not "
"match this cpu "
"(patch is for cpu id %x, cpu id is %x)\n",
hdr->ah_processor_rev_id, mc.mc_equiv_cpuid);
@@ -196,6 +198,16 @@
}
next:
+ /* Check for race:
+ * When we booted with -x a cpu might already finished
+ * (why doesn't xc_wait() wait for *all* cpus?)
+ * and sc->sc_blob is already freed.
+ * In this case the calculation below touches
+ * non-allocated memory and results in a crash.
+ */
+ if (sc->sc_blob == NULL)
+ break;
+
mc.mc_buf += mc.mc_mpbuf->mpb_len +
sizeof(mc.mc_mpbuf->mpb_type) +
sizeof(mc.mc_mpbuf->mpb_len);
@@ -211,6 +223,7 @@
out:
if (error)
((struct mc_buf *)(arg1))->mc_error = error;
+ splx(s);
}
int
@@ -277,7 +290,7 @@
/* Apply it on all cpus */
mc.mc_error = 0;
- where = xc_broadcast(XC_HIGHPRI, cpu_apply_cb, sc, &mc);
+ where = xc_broadcast(0, cpu_apply_cb, sc, &mc);
/* Wait for completion */
xc_wait(where);
Home |
Main Index |
Thread Index |
Old Index