Arthur Heymans has uploaded this change for review.

View Change

cpu/x86/smm: Add a helper function returning top of save state

Some entries like smm base and smm revision have a fixed location in
the save w.r.t. the save state top.

Change-Id: I82dadcb966ee686c1652c7a1298dcb9938ae888c
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
M src/cpu/x86/smm/smihandler.c
M src/cpu/x86/smm/smm_module_handler.c
M src/include/cpu/x86/smm.h
3 files changed, 21 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/08/37008/1
diff --git a/src/cpu/x86/smm/smihandler.c b/src/cpu/x86/smm/smihandler.c
index 20417d1..79a3936 100644
--- a/src/cpu/x86/smm/smihandler.c
+++ b/src/cpu/x86/smm/smihandler.c
@@ -132,6 +132,13 @@
return (void *)base;
}

+uint8_t *smm_get_save_state_top(int cpu)
+{
+ const uint32_t smm_base = 0xa0000;
+
+ return (uint8_t *)smm_base + SMM_ENTRY_OFFSET * 2 - (cpu * 0x400);
+}
+
/**
* @brief Interrupt handler for SMI#
*
diff --git a/src/cpu/x86/smm/smm_module_handler.c b/src/cpu/x86/smm/smm_module_handler.c
index bd4d48c..80bff9f 100644
--- a/src/cpu/x86/smm/smm_module_handler.c
+++ b/src/cpu/x86/smm/smm_module_handler.c
@@ -114,6 +114,19 @@
return base;
}

+uint8_t *smm_get_save_state_top(int cpu)
+{
+ uint8_t *base;
+
+ /* This function assumes all save states start at top of default
+ * SMRAM size space and are staggered down by save state size. */
+ base = (void *)smm_runtime->smbase;
+ base += SMM_DEFAULT_SIZE;
+ base -= cpu * smm_runtime->save_state_size;
+
+ return base;
+}
+
asmlinkage void smm_handler_start(void *arg)
{
const struct smm_module_params *p;
diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h
index cf107b1..0ade970 100644
--- a/src/include/cpu/x86/smm.h
+++ b/src/include/cpu/x86/smm.h
@@ -94,6 +94,7 @@
/* Retrieve SMM save state for a given CPU. WARNING: This does not take into
* account CPUs which are configured to not save their state to RAM. */
void *smm_get_save_state(int cpu);
+uint8_t *smm_get_save_state_top(int cpu);

/* SMM Module Loading API */


To view, visit change 37008. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I82dadcb966ee686c1652c7a1298dcb9938ae888c
Gerrit-Change-Number: 37008
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur@aheymans.xyz>
Gerrit-MessageType: newchange