Arthur Heymans has uploaded this change for review.

View Change

[UNTESTED]cpu/amd: Lock down paging and EFER in SMM

Changing page tables or the value of EFER in SMM is undesirable in the
coreboot use case.

Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Change-Id: I96fb75759444e9c2afa3bec719045ece1ec2daf8
---
M src/cpu/x86/smm/smm_stub.S
M src/include/cpu/amd/msr.h
2 files changed, 17 insertions(+), 1 deletion(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/87/80187/1
diff --git a/src/cpu/x86/smm/smm_stub.S b/src/cpu/x86/smm/smm_stub.S
index f97ab59..cd01611 100644
--- a/src/cpu/x86/smm/smm_stub.S
+++ b/src/cpu/x86/smm/smm_stub.S
@@ -9,6 +9,7 @@
* found in smm.h.
*/

+#include <cpu/amd/msr.h>
#include <cpu/x86/cr.h>
#include <cpu/x86/msr.h>
#include <cpu/x86/lapic_def.h>
@@ -196,9 +197,15 @@
mov %ecx, %edi
/* entry64.inc preserves ebx, esi, edi, ebp */
#include <cpu/x86/64bit/entry64.inc>
+#if CONFIG(CPU_AMD_PI) || CONFIG(SOC_AMD_COMMON)
+ /* Lock down paging */
+ movl $HWCR_MSR, %ecx
+ rdmsr
+ or $SMM_PGCFG_LOCK, %eax
+ wrmsr
+#endif
mov %edi, %ecx

-
push %rbx /* uintptr_t *canary */
push %rcx /* size_t cpu */

@@ -211,6 +218,14 @@
push %ebx /* uintptr_t *canary */
push %ecx /* size_t cpu */
push %esp /* smm_module_params *arg (allocated on stack). */
+
+#if CONFIG(CPU_AMD_PI) || CONFIG(SOC_AMD_COMMON)
+ /* Lock down paging */
+ movl $HWCR_MSR, %ecx
+ rdmsr
+ or $SMM_PGCFG_LOCK, %eax
+ wrmsr
+#endif
mov c_handler, %eax
call *%eax
#endif
diff --git a/src/include/cpu/amd/msr.h b/src/include/cpu/amd/msr.h
index 3f7febc..8ad7a2f 100644
--- a/src/include/cpu/amd/msr.h
+++ b/src/include/cpu/amd/msr.h
@@ -16,6 +16,7 @@
#define FS_Base 0xC0000100
#define HWCR_MSR 0xC0010015
#define SMM_LOCK (1 << 0)
+#define SMM_PGCFG_LOCK (1 << 3)
#define NB_CFG_MSR 0xC001001f
#define FidVidStatus 0xC0010042
#define MC0_CTL_MASK 0xC0010044

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

Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I96fb75759444e9c2afa3bec719045ece1ec2daf8
Gerrit-Change-Number: 80187
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur@aheymans.xyz>
Gerrit-MessageType: newchange