[coreboot-gerrit] New patch to review for coreboot: 019e5a9 Refactor usage of walkcbfs to permit access to CBFS headers

Alexandru Gagniuc (mr.nuke.me@gmail.com) gerrit at coreboot.org
Sun Dec 8 08:21:15 CET 2013


Alexandru Gagniuc (mr.nuke.me at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4504

-gerrit

commit 019e5a9b650313ea3d1ffe9b0bfe4bd881ae34b2
Author: Alexandru Gagniuc <mr.nuke.me at gmail.com>
Date:   Sun Dec 8 01:13:43 2013 -0600

    Refactor usage of walkcbfs to permit access to CBFS headers
    
    walkcbfs is only used when applying microcode updates during the bootblock
    phase. The function used to return only a pointer to the data of the CBFS
    file, while making the header completely inaccessible. Since the header
    contains the length of the CBFS file, the caller did not have a way to know
    how long the data was. Then, other conventions had to be used to determine
    the EOF, which might present problems if the user replaces the CBFS file.
    
    Refactor walkcbfs_asm to return a pointer to the CBFS file header rather
    than the data, and fix the usage in the one place where walkcbfs is used.
    
    Change-Id: I21cbf19e130e1480e2749754e5d5130d36036f8e
    Signed-off-by: Alexandru Gagniuc <mr.nuke.me at gmail.com>
---
 src/arch/x86/include/arch/cbfs.h    | 4 +++-
 src/arch/x86/lib/walkcbfs.S         | 4 +---
 src/cpu/intel/microcode/microcode.c | 9 ++++++---
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/arch/x86/include/arch/cbfs.h b/src/arch/x86/include/arch/cbfs.h
index 8a61d6e..e9390a0 100644
--- a/src/arch/x86/include/arch/cbfs.h
+++ b/src/arch/x86/include/arch/cbfs.h
@@ -20,7 +20,9 @@
 #ifndef __INCLUDE_ARCH_CBFS__
 #define __INCLUDE_ARCH_CBFS__
 
-static void *walkcbfs(char *target)
+#include <cbfs_core.h>
+
+static struct cbfs_file *walkcbfs(char *target)
 {
 	void *entry;
 	asm volatile (
diff --git a/src/arch/x86/lib/walkcbfs.S b/src/arch/x86/lib/walkcbfs.S
index 2dc9617..3a96d64 100644
--- a/src/arch/x86/lib/walkcbfs.S
+++ b/src/arch/x86/lib/walkcbfs.S
@@ -59,9 +59,7 @@ walker:
 	jnz tryharder
 
 	/* we found it! */
-	mov CBFS_FILE_OFFSET(%ebx), %eax
-	bswap %eax
-	add %ebx, %eax
+	mov %ebx, %eax
 	jmp *%esp
 
 tryharder:
diff --git a/src/cpu/intel/microcode/microcode.c b/src/cpu/intel/microcode/microcode.c
index 3d6af67..ef04e03 100644
--- a/src/cpu/intel/microcode/microcode.c
+++ b/src/cpu/intel/microcode/microcode.c
@@ -109,7 +109,8 @@ void intel_microcode_load_unlocked(const void *microcode_patch)
 
 const void *intel_microcode_find(void)
 {
-	void *microcode_updates;
+	struct cbfs_file *microcode_updates;
+	void *microcode_data;
 	u32 eax;
 	u32 pf, rev, sig;
 	unsigned int x86_model, x86_family;
@@ -152,8 +153,10 @@ const void *intel_microcode_find(void)
 			sig, pf, rev);
 #endif
 
-	m = microcode_updates;
-	for(c = microcode_updates; m->hdrver; m = (const struct microcode *)c) {
+	microcode_data = CBFS_SUBHEADER(microcode_updates);
+
+	m = microcode_data;
+	for(c = microcode_data; m->hdrver; m = (const struct microcode *)c) {
 		if ((m->sig == sig) && (m->pf & pf))
 			return m;
 



More information about the coreboot-gerrit mailing list