summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveState.c
diff options
context:
space:
mode:
Diffstat (limited to 'UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveState.c')
-rw-r--r--UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveState.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveState.c b/UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveState.c
index f9485b7cd8..ac143e64fb 100644
--- a/UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveState.c
+++ b/UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveState.c
@@ -10,10 +10,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "MmSaveState.h"
#include <Register/Amd/SmramSaveStateMap.h>
#include <Library/BaseLib.h>
+#include <Register/Amd/Msr.h>
-// EFER register LMA bit
-#define LMA BIT10
-#define EFER_ADDRESS 0xC0000080ul
#define AMD_MM_SAVE_STATE_REGISTER_SMMREVID_INDEX 1
#define AMD_MM_SAVE_STATE_REGISTER_MAX_INDEX 2
@@ -280,6 +278,16 @@ MmSaveStateGetRegisterLma (
VOID
)
{
+ UINT32 LMAValue;
+
+ MSR_IA32_EFER_REGISTER Msr;
+
+ Msr.Uint64 = AsmReadMsr64 (MSR_IA32_EFER);
+ LMAValue = Msr.Bits.LMA;
+ if (LMAValue) {
+ return EFI_MM_SAVE_STATE_REGISTER_LMA_64BIT;
+ }
+
//
// AMD64 processors support EFI_SMM_SAVE_STATE_REGISTER_LMA_64BIT only
//