The overall logic looks good to me and I agree to add an internal function like the patch.
Some minor comments:
Can you please separate the patch to two patches? One is to correct the Cr3 typo, the other is to fix the bug.
Can you please add comments in Is5LevelPageTableBase() to explain why directly checking CR4 doesn't work sometimes? And when (For example, when the function is called from entrypoint and the CR3/CR4 haven't been written)?
"When mInternalCr3 is used, get paging level type by a variable which is set when mInternalCr3 is generated." This commit message isn't so meaningful. It just translates the C logic to plain text. Better to explain the case when the functions called from entrypoint the page table is set to mInternalCr3, gSmmFeatureEnable5LevelPaging reflects the page table type pointed by mInternalCr3.
I cannot find below variable. Did you miss some code change in the patch? // // Variables from Protected Mode SMI Entry Template // extern BOOLEAN gSmmFeatureEnable5LevelPaging;