[coreboot-gerrit] Change in coreboot[master]: smm: Make local variables relative to ebp

Raul Rangel (Code Review) gerrit at coreboot.org
Mon Jun 25 20:06:32 CEST 2018


Raul Rangel has uploaded this change for review. ( https://review.coreboot.org/27225


Change subject: smm: Make local variables relative to ebp
......................................................................

smm: Make local variables relative to ebp

This reduces the cognitive overhead of referencing locals via esp since
it changes with every push.

BUG=b:80539294
TEST=built and booted on grunt.

Change-Id: Ib7eb98ce3483d4fc803696c1b2496d8384317536
Signed-off-by: Raul E Rangel <rrangel at chromium.org>
---
M src/cpu/x86/smm/smm_stub.S
1 file changed, 10 insertions(+), 10 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/25/27225/1

diff --git a/src/cpu/x86/smm/smm_stub.S b/src/cpu/x86/smm/smm_stub.S
index 32435a0..5162c95 100644
--- a/src/cpu/x86/smm/smm_stub.S
+++ b/src/cpu/x86/smm/smm_stub.S
@@ -131,10 +131,13 @@
 	jmp	2f
 1:
 	movl	stack_size, %eax
-	mul	%ecx
+	mul	%ecx # %eax(stack_size) * %ecx(cpu) = %eax(offset)
 	movl	stack_top, %edx
-	subl	%eax, %edx
+	subl	%eax, %edx # %edx(stack_top) - %eax(offset) = %edx(stack_top)
 	mov	%edx, %esp
+	mov	%esp, %ebp
+
+	subl	$0x4, %esp # Allocate locals (fxsave)
 
 	/* calculate fxsave location */
 	mov	fxsave_area, %edi
@@ -146,8 +149,7 @@
 
 2:
 	/* Save location of fxsave area. */
-	push	%edi
-	mov	%esp, %ebp
+	mov	%edi, -4(%ebp)
 	test	%edi, %edi
 	jz	1f
 
@@ -165,20 +167,18 @@
 
 	/* Call into the c-based SMM relocation function with the platform
 	 * parameters. Equivalent to:
-	 *   struct arg = { c_handler_params, cpu_num, smm_runtime {;
+	 *   struct arg = { c_handler_params, cpu_num, smm_runtime };
 	 *   c_handler(&arg)
 	 */
 	push	$(smm_runtime)
-	push	%ecx
+	push	%ecx # cpu
 	push	c_handler_arg
-	push	%esp
+	push	%esp # smm_module_params *arg (allocated on stack).
 	mov	c_handler, %eax
 	call	*%eax
 
-	/* Restore stack from call frame */
-	mov	%ebp, %esp
 	/* Retrieve fxsave location. */
-	pop	%edi
+	mov	-4(%ebp), %edi
 	test	%edi, %edi
 	jz	1f
 

-- 
To view, visit https://review.coreboot.org/27225
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7eb98ce3483d4fc803696c1b2496d8384317536
Gerrit-Change-Number: 27225
Gerrit-PatchSet: 1
Gerrit-Owner: Raul Rangel <rrangel at chromium.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180625/acaff76b/attachment.html>


More information about the coreboot-gerrit mailing list