UefiCpuPkg/PiSmmCpu: Restrict access per PcdCpuSmmRestrictedMemoryAccess

Today's behavior is to always restrict access to non-SMRAM regardless
the value of PcdCpuSmmRestrictedMemoryAccess.

Because RAS components require to access all non-SMRAM memory, the
patch changes the code logic to honor PcdCpuSmmRestrictedMemoryAccess
so that only when the PCD is true, the restriction takes affect and
page table memory is also protected.

Because IA32 build doesn't reference this PCD, such restriction
always takes affect in IA32 build.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Ray Ni 2019-08-26 06:13:17 +08:00
parent 09f7c82b4c
commit 79186ddcdd
4 changed files with 49 additions and 8 deletions

View File

@ -336,3 +336,17 @@ RestoreCr2 (
{
return ;
}
/**
Return whether access to non-SMRAM is restricted.
@retval TRUE Access to non-SMRAM is restricted.
@retval FALSE Access to non-SMRAM is not restricted.
*/
BOOLEAN
IsRestrictedMemoryAccess (
VOID
)
{
return TRUE;
}

View File

@ -1431,15 +1431,17 @@ PerformRemainingTasks (
//
SetMemMapAttributes ();
//
// For outside SMRAM, we only map SMM communication buffer or MMIO.
//
SetUefiMemMapAttributes ();
if (IsRestrictedMemoryAccess ()) {
//
// For outside SMRAM, we only map SMM communication buffer or MMIO.
//
SetUefiMemMapAttributes ();
//
// Set page table itself to be read-only
//
SetPageTableAttributes ();
//
// Set page table itself to be read-only
//
SetPageTableAttributes ();
}
//
// Configure SMM Code Access Check feature if available.

View File

@ -1450,4 +1450,15 @@ InitializeDataForMmMp (
VOID
);
/**
Return whether access to non-SMRAM is restricted.
@retval TRUE Access to non-SMRAM is restricted.
@retval FALSE Access to non-SMRAM is not restricted.
*/
BOOLEAN
IsRestrictedMemoryAccess (
VOID
);
#endif

View File

@ -1252,3 +1252,17 @@ RestoreCr2 (
AsmWriteCr2 (Cr2);
}
}
/**
Return whether access to non-SMRAM is restricted.
@retval TRUE Access to non-SMRAM is restricted.
@retval FALSE Access to non-SMRAM is not restricted.
*/
BOOLEAN
IsRestrictedMemoryAccess (
VOID
)
{
return mCpuSmmRestrictedMemoryAccess;
}