X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FCore%2FDxe%2FGcd%2FGcd.c;h=e17e98230b79beb063c5a00cbe38c251e86e9fc3;hp=907245a3f512c2eeb5424cdf166744b57c1df2ce;hb=e037e88cd81d4ac63dd627719c87c305bf0b439e;hpb=5b91bf82c67b586b9588cbe4bbffa1588f6b5926 diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c index 907245a3f5..e17e98230b 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -3,7 +3,7 @@ The GCD services are used to manage the memory and I/O regions that are accessible to the CPU that is executing the DXE core. -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -48,8 +48,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define NONEXCLUSIVE_MEMORY_ATTRIBUTES (EFI_MEMORY_XP | EFI_MEMORY_RP | \ EFI_MEMORY_RO) -#define INVALID_CPU_ARCH_ATTRIBUTES 0xffffffff - // // Module Variables // @@ -868,12 +866,30 @@ CoreConvertSpace ( } ASSERT (TopEntry != NULL && BottomEntry != NULL); + // + // Initialize CpuArchAttributes to suppress incorrect compiler/analyzer warnings. + // + CpuArchAttributes = 0; if (Operation == GCD_SET_ATTRIBUTES_MEMORY_OPERATION) { // // Call CPU Arch Protocol to attempt to set attributes on the range // CpuArchAttributes = ConverToCpuArchAttributes (Attributes); - if (CpuArchAttributes != INVALID_CPU_ARCH_ATTRIBUTES) { + // + // CPU arch attributes include page attributes and cache attributes. + // Only page attributes supports to be cleared, but not cache attributes. + // Caller is expected to use GetMemorySpaceDescriptor() to get the current + // attributes, AND/OR attributes, and then calls SetMemorySpaceAttributes() + // to set the new attributes. + // So 0 CPU arch attributes should not happen as memory should always have + // a cache attribute (no matter UC or WB, etc). + // + // Here, 0 CPU arch attributes will be filtered to be compatible with the + // case that caller just calls SetMemorySpaceAttributes() with none CPU + // arch attributes (for example, RUNTIME) as the purpose of the case is not + // to clear CPU arch attributes. + // + if (CpuArchAttributes != 0) { if (gCpu == NULL) { Status = EFI_NOT_AVAILABLE_YET; } else { @@ -936,6 +952,13 @@ CoreConvertSpace ( // Set attributes operation // case GCD_SET_ATTRIBUTES_MEMORY_OPERATION: + if (CpuArchAttributes == 0) { + // + // Keep original CPU arch attributes when caller just calls + // SetMemorySpaceAttributes() with none CPU arch attributes (for example, RUNTIME). + // + Attributes |= (Entry->Attributes & (EXCLUSIVE_MEMORY_ATTRIBUTES | NONEXCLUSIVE_MEMORY_ATTRIBUTES)); + } Entry->Attributes = Attributes; break; //