MdeModulePkg/Gcd: Fix bug of attribute conversion
authorHeyi Guo <heyi.guo@linaro.org>
Thu, 29 Mar 2018 08:19:50 +0000 (16:19 +0800)
committerStar Zeng <star.zeng@intel.com>
Mon, 2 Apr 2018 05:57:28 +0000 (13:57 +0800)
For gDS->SetMemorySpaceAttributes(), when user passes a combined
memory attribute including CPU arch attribute and other attributes,
like EFI_MEMORY_RUNTIME, ConverToCpuArchAttributes() will return
INVALID_CPU_ARCH_ATTRIBUTES and skip setting page/cache attribute for
the specified memory space.

We don't see any reason to forbid combining CPU arch attributes and
non-CPU-arch attributes when calling gDS->SetMemorySpaceAttributes(),
so we remove the check code in ConverToCpuArchAttributes(); the
remaining code is enough to grab the interested bits for
Cpu->SetMemoryAttributes().

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Signed-off-by: Yi Li <phoenix.liyi@huawei.com>
Signed-off-by: Renhao Liang <liangrenhao@huawei.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
MdeModulePkg/Core/Dxe/Gcd/Gcd.c

index 77f4adb4bc0181a0900a1734698c4ba9ee432b4b..907245a3f512c2eeb5424cdf166744b57c1df2ce 100644 (file)
@@ -673,11 +673,6 @@ ConverToCpuArchAttributes (
 {\r
   UINT64      CpuArchAttributes;\r
 \r
 {\r
   UINT64      CpuArchAttributes;\r
 \r
-  if ((Attributes & ~(EXCLUSIVE_MEMORY_ATTRIBUTES |\r
-                      NONEXCLUSIVE_MEMORY_ATTRIBUTES)) != 0) {\r
-    return INVALID_CPU_ARCH_ATTRIBUTES;\r
-  }\r
-\r
   CpuArchAttributes = Attributes & NONEXCLUSIVE_MEMORY_ATTRIBUTES;\r
 \r
   if ( (Attributes & EFI_MEMORY_UC) == EFI_MEMORY_UC) {\r
   CpuArchAttributes = Attributes & NONEXCLUSIVE_MEMORY_ATTRIBUTES;\r
 \r
   if ( (Attributes & EFI_MEMORY_UC) == EFI_MEMORY_UC) {\r