[coreboot-gerrit] New patch to review for coreboot: arch/x86/walkcbfs.S: Take in return address in ebp instead of esp

Alexandru Gagniuc (mr.nuke.me@gmail.com) gerrit at coreboot.org
Sun Oct 11 10:34:23 CEST 2015


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/11859

-gerrit

commit 22ee28220dcbb19c03ace9b7db9f6117f12d6539
Author: Alexandru Gagniuc <mr.nuke.me at gmail.com>
Date:   Sun Oct 11 00:12:05 2015 -0700

    arch/x86/walkcbfs.S: Take in return address in ebp instead of esp
    
    esp, or the stack pointer, is a very special register. It's OK to
    clobber esp when we don't have a stack, but that also makes walkcbfs
    uncallable from C code. However in the case of running a C environment
    bootblock, we might still want the ability to use walkcbfs instead of
    the heavier CBFS APIs. This is mostly done to reduce the size of the
    bootblock in the event walkcbfs is used.
    
    Change-Id: I7eb227c3ed00ad98859d870eded62b3c96037320
    Signed-off-by: Alexandru Gagniuc <mr.nuke.me at gmail.com>
---
 src/arch/x86/include/arch/cbfs.h | 4 ++--
 src/arch/x86/walkcbfs.S          | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/arch/x86/include/arch/cbfs.h b/src/arch/x86/include/arch/cbfs.h
index 195c06f..719f8f5 100644
--- a/src/arch/x86/include/arch/cbfs.h
+++ b/src/arch/x86/include/arch/cbfs.h
@@ -29,9 +29,9 @@ static struct cbfs_file *walkcbfs_head(char *target)
 {
 	void *entry;
 	asm volatile (
-		"mov $1f, %%esp\n\t"
+		"mov $1f, %%ebp\n\t"
 		"jmp walkcbfs_asm\n\t"
-		"1:\n\t" : "=a" (entry) : "S" (target) : "ebx", "ecx", "edi", "esp");
+		"1:\n\t" : "=a" (entry) : "S" (target) : "ebx", "ecx", "edi", "ebp");
 	return entry;
 }
 
diff --git a/src/arch/x86/walkcbfs.S b/src/arch/x86/walkcbfs.S
index ac2d134..4f9dd83 100644
--- a/src/arch/x86/walkcbfs.S
+++ b/src/arch/x86/walkcbfs.S
@@ -23,7 +23,7 @@
 
 /*
  * input %esi: filename
- * input %esp: return address (not pointer to return address!)
+ * input %ebp: return address (not pointer to return address!)
  * output %eax: pointer to CBFS header
  * clobbers %ebx, %ecx, %edi
  */
@@ -66,7 +66,7 @@ walker:
 
 	/* we found it! */
 	mov %ebx, %eax
-	jmp *%esp
+	jmp *%ebp
 
 tryharder:
 	sub %ebx, %edi
@@ -104,7 +104,7 @@ check_for_exit:
 
 out:
 	mov $0, %eax
-	jmp *%esp
+	jmp *%ebp
 
 
 searchfile:



More information about the coreboot-gerrit mailing list