Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/44318 )
Change subject: cpu/x86/smm.h: Add function to return the SMM revision ......................................................................
cpu/x86/smm.h: Add function to return the SMM revision
Change-Id: I3e4450088adbb654050e7420956cf58ee1170a98 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, 20 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/18/44318/1
diff --git a/src/cpu/x86/smm/smihandler.c b/src/cpu/x86/smm/smihandler.c index 8fd95bb..8f7ebfb 100644 --- a/src/cpu/x86/smm/smihandler.c +++ b/src/cpu/x86/smm/smihandler.c @@ -120,6 +120,14 @@ return (void *)base; }
+/* This returns the SMM revision from the savestate of CPU0, + which is assumed to be the same for all CPU's. See the memory + map in smmhandler.S */ +uint32_t smm_revision(void) +{ + return *(uint32_t *)(SMM_BASE + SMM_ENTRY_OFFSET * 2 - SMM_REVISION_OFFSET_FROM_TOP); +} + bool smm_region_overlaps_handler(const struct region *r) { const struct region r_smm = {SMM_BASE, SMM_DEFAULT_SIZE}; diff --git a/src/cpu/x86/smm/smm_module_handler.c b/src/cpu/x86/smm/smm_module_handler.c index 02682b4..e50061d 100644 --- a/src/cpu/x86/smm/smm_module_handler.c +++ b/src/cpu/x86/smm/smm_module_handler.c @@ -106,6 +106,13 @@ return base; }
+uint32_t smm_revision(void) +{ + const uintptr_t save_state = (uintptr_t)(smm_get_save_state(0)); + + return *(uint32_t *)(save_state + smm_runtime->save_state_size - SMM_REVISION_OFFSET_FROM_TOP); +} + bool smm_region_overlaps_handler(const struct region *r) { const struct region r_smm = {smm_runtime->smbase, smm_runtime->smm_size}; diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h index a3101e5..ff91c96 100644 --- a/src/include/cpu/x86/smm.h +++ b/src/include/cpu/x86/smm.h @@ -175,4 +175,9 @@ /* Print the SMM memory layout on console. */ void smm_list_regions(void);
+#define SMM_REVISION_OFFSET_FROM_TOP (0x8000 - 0x7efc) +/* Return the SMM revision. The revision is can be fetched from the smm savestate + which is always at the same offset downward from the top of the save state. */ +uint32_t smm_revision(void); + #endif /* CPU_X86_SMM_H */
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44318 )
Change subject: cpu/x86/smm.h: Add function to return the SMM revision ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/44318/1/src/cpu/x86/smm/smm_module_... File src/cpu/x86/smm/smm_module_handler.c:
https://review.coreboot.org/c/coreboot/+/44318/1/src/cpu/x86/smm/smm_module_... PS1, Line 113: return *(uint32_t *)(save_state + smm_runtime->save_state_size - SMM_REVISION_OFFSET_FROM_TOP); line over 96 characters
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44318 )
Change subject: cpu/x86/smm.h: Add function to return the SMM revision ......................................................................
Patch Set 1: Code-Review+1
(2 comments)
https://review.coreboot.org/c/coreboot/+/44318/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/44318/1//COMMIT_MSG@8 PS1, Line 8: It would be nice to explain what `SMM revision` means here.
https://review.coreboot.org/c/coreboot/+/44318/1/src/include/cpu/x86/smm.h File src/include/cpu/x86/smm.h:
https://review.coreboot.org/c/coreboot/+/44318/1/src/include/cpu/x86/smm.h@1... PS1, Line 179: is can can
Hello build bot (Jenkins), Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/44318
to look at the new patch set (#2).
Change subject: cpu/x86/smm.h: Add function to return the SMM save state revision ......................................................................
cpu/x86/smm.h: Add function to return the SMM save state revision
Change-Id: I3e4450088adbb654050e7420956cf58ee1170a98 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, 20 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/18/44318/2
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44318 )
Change subject: cpu/x86/smm.h: Add function to return the SMM save state revision ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/44318/2/src/cpu/x86/smm/smm_module_... File src/cpu/x86/smm/smm_module_handler.c:
https://review.coreboot.org/c/coreboot/+/44318/2/src/cpu/x86/smm/smm_module_... PS2, Line 113: return *(uint32_t *)(save_state + smm_runtime->save_state_size - SMM_REVISION_OFFSET_FROM_TOP); line over 96 characters
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44318 )
Change subject: cpu/x86/smm.h: Add function to return the SMM save state revision ......................................................................
Patch Set 2: Code-Review+2
(2 comments)
https://review.coreboot.org/c/coreboot/+/44318/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/44318/1//COMMIT_MSG@8 PS1, Line 8:
It would be nice to explain what `SMM revision` means here.
Ah, SMM save state revision.
https://review.coreboot.org/c/coreboot/+/44318/1/src/include/cpu/x86/smm.h File src/include/cpu/x86/smm.h:
https://review.coreboot.org/c/coreboot/+/44318/1/src/include/cpu/x86/smm.h@1... PS1, Line 179: is can
can
Done
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/44318 )
Change subject: cpu/x86/smm.h: Add function to return the SMM save state revision ......................................................................
cpu/x86/smm.h: Add function to return the SMM save state revision
Change-Id: I3e4450088adbb654050e7420956cf58ee1170a98 Signed-off-by: Arthur Heymans arthur@aheymans.xyz Reviewed-on: https://review.coreboot.org/c/coreboot/+/44318 Reviewed-by: Angel Pons th3fanbus@gmail.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- 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, 20 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved
diff --git a/src/cpu/x86/smm/smihandler.c b/src/cpu/x86/smm/smihandler.c index 8fd95bb..8f7ebfb 100644 --- a/src/cpu/x86/smm/smihandler.c +++ b/src/cpu/x86/smm/smihandler.c @@ -120,6 +120,14 @@ return (void *)base; }
+/* This returns the SMM revision from the savestate of CPU0, + which is assumed to be the same for all CPU's. See the memory + map in smmhandler.S */ +uint32_t smm_revision(void) +{ + return *(uint32_t *)(SMM_BASE + SMM_ENTRY_OFFSET * 2 - SMM_REVISION_OFFSET_FROM_TOP); +} + bool smm_region_overlaps_handler(const struct region *r) { const struct region r_smm = {SMM_BASE, SMM_DEFAULT_SIZE}; diff --git a/src/cpu/x86/smm/smm_module_handler.c b/src/cpu/x86/smm/smm_module_handler.c index 0884819..d987ddc 100644 --- a/src/cpu/x86/smm/smm_module_handler.c +++ b/src/cpu/x86/smm/smm_module_handler.c @@ -106,6 +106,13 @@ return base; }
+uint32_t smm_revision(void) +{ + const uintptr_t save_state = (uintptr_t)(smm_get_save_state(0)); + + return *(uint32_t *)(save_state + smm_runtime->save_state_size - SMM_REVISION_OFFSET_FROM_TOP); +} + bool smm_region_overlaps_handler(const struct region *r) { const struct region r_smm = {smm_runtime->smbase, smm_runtime->smm_size}; diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h index de16a43..1073d03 100644 --- a/src/include/cpu/x86/smm.h +++ b/src/include/cpu/x86/smm.h @@ -193,4 +193,9 @@ /* Print the SMM memory layout on console. */ void smm_list_regions(void);
+#define SMM_REVISION_OFFSET_FROM_TOP (0x8000 - 0x7efc) +/* Return the SMM save state revision. The revision can be fetched from the smm savestate + which is always at the same offset downward from the top of the save state. */ +uint32_t smm_revision(void); + #endif /* CPU_X86_SMM_H */