Paul Menzel (paulepanter(a)users.sourceforge.net) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2990
-gerrit
commit 70aed6232764e3f9c9231e648db19fb50c2b55c2
Author: Vladimir Serbinenko <phcoder(a)gmail.com>
Date: Sat Mar 30 12:04:23 2013 +0100
Intel microcode: Return when `microcode_updates` is `NULL`
Add a safety check in function `intel_update_microcode` to return when
accidentally `NULL` is passed as `microcode_updates`, which would lead
to a null pointer dereference later on.
for (c = microcode_updates; m->hdrver; m = (const struct microcode *)c) {
While at it, use `return NULL` for clarity in function
`intel_microcode_find` and include the header file `stddef.h`. for it.
The review of this patch had some more discussion on adding more
comments and more detailed error messages. But this should be done in
a separate patch.
For clarity here some history, on how this was found and what caused
the discussion and confusion.
Originally when Vladimir made this improvement, selecting
`CPU_MICROCODE_IN_CBFS` in Kconfig but not having the microcode blob
`cpu_microcode_blob.bin` in CBFS resulted in a null pointer dereference
later on causing a crash.
for (c = microcode_updates; m->hdrver; m = (const struct microcode *)c) {
Vladimir fixed this by returning if `microcode_updates` is `NULL`,
that means no file is found and successfully tested this on his
Lenovo X201.
When pushing the patch to Gerrit for review, the code was rewritten
though by Aaron in commit »intel microcode: split up microcode loading
stages« (98ffb426) [1], which also returns when no file is found. So
the other parts of the code were checked and the safety check as
described above is added.
[1] http://review.coreboot.org/2778
Change-Id: I6e18fd37256910bf047061e4633a66cf29ad7b69
Signed-off-by: Vladimir Serbinenko <phcoder(a)gmail.com>
Signed-off-by: Paul Menzel <paulepanter(a)users.sourceforge.net>
---
src/cpu/intel/microcode/microcode.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/cpu/intel/microcode/microcode.c b/src/cpu/intel/microcode/microcode.c
index d908c25..1991ed8 100644
--- a/src/cpu/intel/microcode/microcode.c
+++ b/src/cpu/intel/microcode/microcode.c
@@ -21,6 +21,7 @@
/* Microcode update for Intel PIII and later CPUs */
#include <stdint.h>
+#include <stddef.h>
#if !defined(__ROMCC__)
#include <console/console.h>
#endif
@@ -131,7 +132,7 @@ const void *intel_microcode_find(void)
#endif
if (!microcode_updates)
- return microcode_updates;
+ return NULL;
/* CPUID sets MSR 0x8B iff a microcode update has been loaded. */
msr.lo = 0;
@@ -202,6 +203,13 @@ void intel_update_microcode(const void *microcode_updates)
const char *c;
msr_t msr;
+ if (!microcode_updates) {
+#if !defined(__ROMCC__)
+ printk(BIOS_WARNING, "No microcode updates found.\n");
+#endif
+ return;
+ }
+
/* CPUID sets MSR 0x8B iff a microcode update has been loaded. */
msr.lo = 0;
msr.hi = 0;
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2990
-gerrit
commit 0edd4cbf2e76ce92a80ff19dff5b85f9b1b5c813
Author: Vladimir Serbinenko <phcoder(a)gmail.com>
Date: Sat Mar 30 12:04:23 2013 +0100
Intel: Return on missing microcode file to fix null pointer dereference
Selecting `CPU_MICROCODE_IN_CBFS` in Kconfig but not having the
microcode blob `cpu_microcode_blob.bin` in CBFS results in a
null pointer dereference later on resulting in a crash.
for(c = microcode_updates; m->hdrver; m = (const struct microcode *)c) {
Fix this by returning if `microcode_updates` is `NULL`, that means
no file is found.
This patch is successfully tested on the Lenovo X201.
Change-Id: I6e18fd37256910bf047061e4633a66cf29ad7b69
Signed-off-by: Vladimir Serbinenko <phcoder(a)gmail.com>
Signed-off-by: Paul Menzel <paulepanter(a)users.sourceforge.net>
---
src/cpu/intel/microcode/microcode.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/cpu/intel/microcode/microcode.c b/src/cpu/intel/microcode/microcode.c
index d908c25..1991ed8 100644
--- a/src/cpu/intel/microcode/microcode.c
+++ b/src/cpu/intel/microcode/microcode.c
@@ -21,6 +21,7 @@
/* Microcode update for Intel PIII and later CPUs */
#include <stdint.h>
+#include <stddef.h>
#if !defined(__ROMCC__)
#include <console/console.h>
#endif
@@ -131,7 +132,7 @@ const void *intel_microcode_find(void)
#endif
if (!microcode_updates)
- return microcode_updates;
+ return NULL;
/* CPUID sets MSR 0x8B iff a microcode update has been loaded. */
msr.lo = 0;
@@ -202,6 +203,13 @@ void intel_update_microcode(const void *microcode_updates)
const char *c;
msr_t msr;
+ if (!microcode_updates) {
+#if !defined(__ROMCC__)
+ printk(BIOS_WARNING, "No microcode updates found.\n");
+#endif
+ return;
+ }
+
/* CPUID sets MSR 0x8B iff a microcode update has been loaded. */
msr.lo = 0;
msr.hi = 0;
the following patch was just integrated into master:
commit 69743962617b9de1a0263dc372bd9116671b5025
Author: Paul Menzel <paulepanter(a)users.sourceforge.net>
Date: Fri Apr 19 10:05:57 2013 +0200
AMD SB800 based boards: Use `#include <sb_cimx.h>` instead of `"sb_cimx.h"`
Due to
$ more src/southbridge/amd/cimx/sb800/Makefile.inc
[…]
romstage-y += cfg.c
romstage-y += early.c
romstage-y += smbus.c
ramstage-y += cfg.c
ramstage-y += late.c
[…]
`src/southbridge/amd/cimx/sb800/` is passed with the switch `-I` to
the compiler, where it is also going to find the header file
`sb_cimx.h`. Therefore use `#include <sb_cimx>` everywhere, which is
what some AMD SB800 based boards already do.
The only effect is, that the compiler will not needlessly look into
directories which do not contain the header file [1].
The following command was used for the replacement.
$ git grep -l sb_cimx.h src/mainboard/ | xargs sed -i 's/#include "sb_cimx.h"/#include <sb_cimx.h>/'
[1] http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html
Change-Id: I96ab34bac1524e6c38c85dfe9d99cb6ef55e6d7c
Signed-off-by: Paul Menzel <paulepanter(a)users.sourceforge.net>
Reviewed-on: http://review.coreboot.org/3118
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich(a)gmail.com>
Build-Tested: build bot (Jenkins) at Sat Apr 20 05:12:11 2013, giving +1
Reviewed-By: Ronald G. Minnich <rminnich(a)gmail.com> at Sat Apr 20 18:57:19 2013, giving +2
See http://review.coreboot.org/3118 for details.
-gerrit