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