MdeModulePkg/Core: Fix out-of-sync issue in GCD

From GCD perspective, its SetMemorySpaceAttributes() method doesn't accept page
related attributes. That means users cannot use it to change page attributes,
and have to turn to CPU arch protocol to do it, which is not be allowed by PI
spec.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Suggested-by: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
Jian J Wang 2017-09-19 13:52:11 +08:00 committed by Star Zeng
parent c1cab54ce5
commit 14dde9e903
1 changed files with 28 additions and 19 deletions

View File

@ -40,6 +40,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define PRESENT_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT)
#define EXCLUSIVE_MEMORY_ATTRIBUTES (EFI_MEMORY_UC | EFI_MEMORY_WC | \
EFI_MEMORY_WT | EFI_MEMORY_WB | \
EFI_MEMORY_WP | EFI_MEMORY_UCE)
#define NONEXCLUSIVE_MEMORY_ATTRIBUTES (EFI_MEMORY_XP | EFI_MEMORY_RP | \
EFI_MEMORY_RO)
#define INVALID_CPU_ARCH_ATTRIBUTES 0xffffffff
//
@ -654,28 +661,30 @@ ConverToCpuArchAttributes (
UINT64 Attributes
)
{
if ( (Attributes & EFI_MEMORY_UC) == EFI_MEMORY_UC) {
return EFI_MEMORY_UC;
}
if ( (Attributes & EFI_MEMORY_WC ) == EFI_MEMORY_WC) {
return EFI_MEMORY_WC;
}
if ( (Attributes & EFI_MEMORY_WT ) == EFI_MEMORY_WT) {
return EFI_MEMORY_WT;
}
if ( (Attributes & EFI_MEMORY_WB) == EFI_MEMORY_WB) {
return EFI_MEMORY_WB;
}
if ( (Attributes & EFI_MEMORY_WP) == EFI_MEMORY_WP) {
return EFI_MEMORY_WP;
}
UINT64 CpuArchAttributes;
if ((Attributes & ~(EXCLUSIVE_MEMORY_ATTRIBUTES |
NONEXCLUSIVE_MEMORY_ATTRIBUTES)) != 0) {
return INVALID_CPU_ARCH_ATTRIBUTES;
}
CpuArchAttributes = Attributes & NONEXCLUSIVE_MEMORY_ATTRIBUTES;
if ( (Attributes & EFI_MEMORY_UC) == EFI_MEMORY_UC) {
CpuArchAttributes |= EFI_MEMORY_UC;
} else if ( (Attributes & EFI_MEMORY_WC ) == EFI_MEMORY_WC) {
CpuArchAttributes |= EFI_MEMORY_WC;
} else if ( (Attributes & EFI_MEMORY_WT ) == EFI_MEMORY_WT) {
CpuArchAttributes |= EFI_MEMORY_WT;
} else if ( (Attributes & EFI_MEMORY_WB) == EFI_MEMORY_WB) {
CpuArchAttributes |= EFI_MEMORY_WB;
} else if ( (Attributes & EFI_MEMORY_UCE) == EFI_MEMORY_UCE) {
CpuArchAttributes |= EFI_MEMORY_UCE;
} else if ( (Attributes & EFI_MEMORY_WP) == EFI_MEMORY_WP) {
CpuArchAttributes |= EFI_MEMORY_WP;
}
return CpuArchAttributes;
}