From db766c702ac297ffe12c182d982fd0c1743a0c4c Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Wed, 26 Oct 2022 11:49:32 +0200 Subject: [PATCH] cpu/x86/smm: Don't save EFER The EFER MSR is in the SMM save state and RSM properly restores it. Returning to 32bit mode was only done so that fxsave was done in the same mode as fxrstor, but this is no longer done. See commit 1efca4d570 (cpu/x86/smm: Drop fxsave/fxrstor logic) TESTED on qemu: the smihandler works fine. Change-Id: Ie0e9584afd1f08f51ca57da5c4350042699f130d Signed-off-by: Arthur Heymans Reviewed-on: https://review.coreboot.org/c/coreboot/+/68895 Reviewed-by: Paul Menzel Tested-by: build bot (Jenkins) Reviewed-by: Elyes Haouas --- src/cpu/x86/smm/smm_stub.S | 45 +++++--------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/src/cpu/x86/smm/smm_stub.S b/src/cpu/x86/smm/smm_stub.S index 673ab2c50c..f97ab59cd9 100644 --- a/src/cpu/x86/smm/smm_stub.S +++ b/src/cpu/x86/smm/smm_stub.S @@ -183,37 +183,22 @@ apicid_end: movl $0, 4(%ebx) #endif - /* Create stack frame by pushing a NULL stack base pointer */ - pushl $0x0 - mov %esp, %ebp - - /* Allocate locals (efer_backup) */ - subl $0x8, %esp - align_stack: /* Align stack to 16 bytes. Another 32 bytes are pushed below. */ andl $0xfffffff0, %esp -#if ENV_X86_64 - mov %ecx, %edi - /* Backup IA32_EFER. Preserves ebx. */ - movl $(IA32_EFER), %ecx - rdmsr - movl %eax, -0x4(%ebp) - movl %edx, -0x8(%ebp) - - /* entry64.inc preserves ebx, esi, edi, ebp */ -#include - mov %edi, %ecx - -#endif - /* Call into the c-based SMM relocation function with the platform * parameters. Equivalent to: * struct arg = { cpu_num, canary }; * c_handler(&arg) */ #if ENV_X86_64 + mov %ecx, %edi + /* entry64.inc preserves ebx, esi, edi, ebp */ +#include + mov %edi, %ecx + + push %rbx /* uintptr_t *canary */ push %rcx /* size_t cpu */ @@ -221,24 +206,6 @@ align_stack: movabs c_handler, %eax call *%rax - - /* - * The only reason to go back to protected mode is that RSM doesn't restore - * MSR registers and MSR IA32_EFER was modified by entering long mode. - * Drop to protected mode to safely operate on the IA32_EFER MSR. - */ - - /* Disable long mode. */ - #include - - /* Restore IA32_EFER as RSM doesn't restore MSRs. */ - movl $(IA32_EFER), %ecx - rdmsr - movl -0x4(%ebp), %eax - movl -0x8(%ebp), %edx - - wrmsr - #else push $0x0 /* Padding */ push %ebx /* uintptr_t *canary */