]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuDxe/CpuPageTable.c
UefiCpuPkg/CpuDxe: fix incorrect check of SMM mode
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuPageTable.c
index 850eed60e7bc53c83759801e39eae8c3ff95af12..df021798c00988e2668b0ae1cb9b4a9b43e528e8 100644 (file)
@@ -136,7 +136,14 @@ IsInSmm (
     mSmmBase2->InSmm (mSmmBase2, &InSmm);\r
   }\r
 \r
-  return InSmm;\r
+  //\r
+  // mSmmBase2->InSmm() can only detect if the caller is running in SMRAM\r
+  // or from SMM driver. It cannot tell if the caller is running in SMM mode.\r
+  // Check page table base address to guarantee that because SMM mode willl\r
+  // load its own page table.\r
+  //\r
+  return (InSmm &&\r
+          mPagingContext.ContextData.X64.PageTableBase != (UINT64)AsmReadCr3());\r
 }\r
 \r
 /**\r