Index: MdeModulePkg/Core/Dxe/DxeMain.h
===================================================================
--- MdeModulePkg/Core/Dxe/DxeMain.h	(revision 16342)
+++ MdeModulePkg/Core/Dxe/DxeMain.h	(working copy)
@@ -1863,7 +1863,7 @@
                                 resource range specified by BaseAddress and Length.
   @retval EFI_UNSUPPORTED       The bit mask of attributes is not support for the memory resource
                                 range specified by BaseAddress and Length.
-  @retval EFI_ACCESS_DEFINED    The attributes for the memory resource range specified by
+  @retval EFI_ACCESS_DENIED     The attributes for the memory resource range specified by
                                 BaseAddress and Length cannot be modified.
   @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the attributes of
                                 the memory resource range.
@@ -1881,6 +1881,32 @@
 
 
 /**
+  Modifies the capabilities for a memory region in the global coherency domain of the
+  processor.
+
+  @param  BaseAddress      The physical address that is the start address of a memory region.
+  @param  Length           The size in bytes of the memory region.
+  @param  Capabilities     The bit mask of capabilities that the memory region supports.
+
+  @retval EFI_SUCCESS           The capabilities were set for the memory region.
+  @retval EFI_INVALID_PARAMETER Length is zero.
+  @retval EFI_UNSUPPORTED       The capabilities specified by Capabilities do not include the
+                                memory region attributes currently in use.
+  @retval EFI_ACCESS_DENIED     The capabilities for the memory resource range specified by
+                                BaseAddress and Length cannot be modified.
+  @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the capabilities
+                                of the memory resource range.
+**/
+EFI_STATUS
+EFIAPI
+CoreSetMemorySpaceCapabilities (
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN UINT64                Length,
+  IN UINT64                Capabilities
+  );
+
+
+/**
   Returns a map of the memory resources in the global coherency domain of the
   processor.
 
@@ -2816,4 +2842,26 @@
   IN VOID                   *Buffer
   );
 
+/**
+  Internal function.  Converts a memory range to use new attributes.
+
+  @param  Start                  The first address of the range Must be page
+                                 aligned
+  @param  NumberOfPages          The number of pages to convert
+  @param  NewAttributes          The new attributes value for the range.
+
+  @retval EFI_INVALID_PARAMETER  Invalid parameter
+  @retval EFI_NOT_FOUND          Could not find a descriptor cover the specified
+                                 range  or convertion not allowed.
+  @retval EFI_SUCCESS            Successfully converts the memory range to the
+                                 specified attributes.
+
+**/
+VOID
+CoreUpdateMemoryAttributes (
+  IN EFI_PHYSICAL_ADDRESS  Start,
+  IN UINT64                NumberOfPages,
+  IN UINT64                NewAttributes
+  );
+
 #endif
Index: MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
===================================================================
--- MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c	(revision 16342)
+++ MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c	(working copy)
@@ -123,6 +123,7 @@
   (EFI_SCHEDULE)                     CoreSchedule,                        // Schedule
   (EFI_TRUST)                        CoreTrust,                           // Trust
   (EFI_PROCESS_FIRMWARE_VOLUME)      CoreProcessFirmwareVolume,           // ProcessFirmwareVolume
+  (EFI_SET_MEMORY_SPACE_CAPABILITIES)CoreSetMemorySpaceCapabilities,      // SetMemorySpaceCapabilities
 };
 
 EFI_SYSTEM_TABLE mEfiSystemTableTemplate = {
Index: MdeModulePkg/Core/Dxe/Gcd/Gcd.c
===================================================================
--- MdeModulePkg/Core/Dxe/Gcd/Gcd.c	(revision 16342)
+++ MdeModulePkg/Core/Dxe/Gcd/Gcd.c	(working copy)
@@ -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 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
 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
@@ -798,7 +798,7 @@
       }
       break;
     //
-    // Set attribute operations
+    // Set attributes operation
     //
     case GCD_SET_ATTRIBUTES_MEMORY_OPERATION:
       if ((Attributes & EFI_MEMORY_RUNTIME) != 0) {
@@ -812,6 +812,23 @@
         goto Done;
       }
       break;
+    //
+    // Set capabilities operation
+    //
+    case GCD_SET_CAPABILITIES_MEMORY_OPERATION:
+      if ((BaseAddress & EFI_PAGE_MASK) != 0 || (Length & EFI_PAGE_MASK) != 0) {
+        Status = EFI_INVALID_PARAMETER;
+
+        goto Done;
+      }
+      //
+      // Current attributes must still be supported with new capabilities
+      //
+      if ((Capabilities & Entry->Attributes) != Entry->Attributes) {
+        Status = EFI_UNSUPPORTED;
+        goto Done;
+      }
+      break;
     }
     Link = Link->ForwardLink;
   }
@@ -891,11 +908,17 @@
       Entry->GcdIoType = EfiGcdIoTypeNonExistent;
       break;
     //
-    // Set attribute operations
+    // Set attributes operation
     //
     case GCD_SET_ATTRIBUTES_MEMORY_OPERATION:
       Entry->Attributes = Attributes;
       break;
+    //
+    // Set capabilities operation
+    //
+    case GCD_SET_CAPABILITIES_MEMORY_OPERATION:
+      Entry->Capabilities = Capabilities;
+      break;
     }
     Link = Link->ForwardLink;
   }
@@ -1559,6 +1582,45 @@
 
 
 /**
+  Modifies the capabilities for a memory region in the global coherency domain of the
+  processor.
+
+  @param  BaseAddress      The physical address that is the start address of a memory region.
+  @param  Length           The size in bytes of the memory region.
+  @param  Capabilities     The bit mask of capabilities that the memory region supports.
+
+  @retval EFI_SUCCESS           The capabilities were set for the memory region.
+  @retval EFI_INVALID_PARAMETER Length is zero.
+  @retval EFI_UNSUPPORTED       The capabilities specified by Capabilities do not include the
+                                memory region attributes currently in use.
+  @retval EFI_ACCESS_DENIED     The capabilities for the memory resource range specified by
+                                BaseAddress and Length cannot be modified.
+  @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the capabilities
+                                of the memory resource range.
+**/
+EFI_STATUS
+EFIAPI
+CoreSetMemorySpaceCapabilities (
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN UINT64                Length,
+  IN UINT64                Capabilities
+  )
+{
+  EFI_STATUS    Status;
+
+  DEBUG ((DEBUG_GCD, "GCD:CoreSetMemorySpaceCapabilities(Base=%016lx,Length=%016lx)\n", BaseAddress, Length));
+  DEBUG ((DEBUG_GCD, "  Capabilities  = %016lx\n", Capabilities));
+
+  Status = CoreConvertSpace (GCD_SET_CAPABILITIES_MEMORY_OPERATION, (EFI_GCD_MEMORY_TYPE) 0, (EFI_GCD_IO_TYPE) 0, BaseAddress, Length, Capabilities, 0);
+  if (!EFI_ERROR(Status)) {
+    CoreUpdateMemoryAttributes(BaseAddress, RShiftU64(Length, EFI_PAGE_SHIFT), Capabilities);
+  }
+
+  return Status;
+}
+
+
+/**
   Returns a map of the memory resources in the global coherency domain of the
   processor.
 
Index: MdeModulePkg/Core/Dxe/Gcd/Gcd.h
===================================================================
--- MdeModulePkg/Core/Dxe/Gcd/Gcd.h	(revision 16342)
+++ MdeModulePkg/Core/Dxe/Gcd/Gcd.h	(working copy)
@@ -2,7 +2,7 @@
   GCD Operations and data structure used to
   convert from GCD attributes to EFI Memory Map attributes.
 
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
 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
@@ -22,16 +22,17 @@
 #define GCD_MEMORY_SPACE_OPERATION 0x20
 #define GCD_IO_SPACE_OPERATION     0x40
 
-#define GCD_ADD_MEMORY_OPERATION             (GCD_MEMORY_SPACE_OPERATION | 0)
-#define GCD_ALLOCATE_MEMORY_OPERATION        (GCD_MEMORY_SPACE_OPERATION | 1)
-#define GCD_FREE_MEMORY_OPERATION            (GCD_MEMORY_SPACE_OPERATION | 2)
-#define GCD_REMOVE_MEMORY_OPERATION          (GCD_MEMORY_SPACE_OPERATION | 3)
-#define GCD_SET_ATTRIBUTES_MEMORY_OPERATION  (GCD_MEMORY_SPACE_OPERATION | 4)
+#define GCD_ADD_MEMORY_OPERATION               (GCD_MEMORY_SPACE_OPERATION | 0)
+#define GCD_ALLOCATE_MEMORY_OPERATION          (GCD_MEMORY_SPACE_OPERATION | 1)
+#define GCD_FREE_MEMORY_OPERATION              (GCD_MEMORY_SPACE_OPERATION | 2)
+#define GCD_REMOVE_MEMORY_OPERATION            (GCD_MEMORY_SPACE_OPERATION | 3)
+#define GCD_SET_ATTRIBUTES_MEMORY_OPERATION    (GCD_MEMORY_SPACE_OPERATION | 4)
+#define GCD_SET_CAPABILITIES_MEMORY_OPERATION  (GCD_MEMORY_SPACE_OPERATION | 5)
 
-#define GCD_ADD_IO_OPERATION                 (GCD_IO_SPACE_OPERATION | 0)
-#define GCD_ALLOCATE_IO_OPERATION            (GCD_IO_SPACE_OPERATION | 1)
-#define GCD_FREE_IO_OPERATION                (GCD_IO_SPACE_OPERATION | 2)
-#define GCD_REMOVE_IO_OPERATION              (GCD_IO_SPACE_OPERATION | 3)
+#define GCD_ADD_IO_OPERATION                   (GCD_IO_SPACE_OPERATION | 0)
+#define GCD_ALLOCATE_IO_OPERATION              (GCD_IO_SPACE_OPERATION | 1)
+#define GCD_FREE_IO_OPERATION                  (GCD_IO_SPACE_OPERATION | 2)
+#define GCD_REMOVE_IO_OPERATION                (GCD_IO_SPACE_OPERATION | 3)
 
 //
 // The data structure used to convert from GCD attributes to EFI Memory Map attributes
Index: MdeModulePkg/Core/Dxe/Mem/Page.c
===================================================================
--- MdeModulePkg/Core/Dxe/Mem/Page.c	(revision 16342)
+++ MdeModulePkg/Core/Dxe/Mem/Page.c	(working copy)
@@ -671,13 +671,17 @@
 
 
 /**
-  Internal function.  Converts a memory range to the specified type.
-  The range must exist in the memory map.
+  Internal function.  Converts a memory range to the specified type or attributes.
+  The range must exist in the memory map.  Either ChangingType or
+  ChangingAttributes must be set, but not both.
 
   @param  Start                  The first address of the range Must be page
                                  aligned
   @param  NumberOfPages          The number of pages to convert
+  @param  ChangingType           Boolean indicating that type value should be changed
   @param  NewType                The new type for the memory range
+  @param  ChangingAttributes     Boolean indicating that attributes value should be changed
+  @param  NewAttributes          The new attributes for the memory range
 
   @retval EFI_INVALID_PARAMETER  Invalid parameter
   @retval EFI_NOT_FOUND          Could not find a descriptor cover the specified
@@ -687,10 +691,13 @@
 
 **/
 EFI_STATUS
-CoreConvertPages (
+CoreConvertPagesEx (
   IN UINT64           Start,
   IN UINT64           NumberOfPages,
-  IN EFI_MEMORY_TYPE  NewType
+  IN BOOLEAN          ChangingType,
+  IN EFI_MEMORY_TYPE  NewType,
+  IN BOOLEAN          ChangingAttributes,
+  IN UINT64           NewAttributes
   )
 {
 
@@ -698,6 +705,7 @@
   UINT64          End;
   UINT64          RangeEnd;
   UINT64          Attribute;
+  EFI_MEMORY_TYPE MemType;
   LIST_ENTRY      *Link;
   MEMORY_MAP      *Entry;
 
@@ -709,6 +717,7 @@
   ASSERT ((Start & EFI_PAGE_MASK) == 0);
   ASSERT (End > Start) ;
   ASSERT_LOCKED (&gMemoryLock);
+  ASSERT ( (ChangingType == FALSE) || (ChangingAttributes == FALSE) );
 
   if (NumberOfPages == 0 || ((Start & EFI_PAGE_MASK) != 0) || (Start > (Start + NumberOfBytes))) {
     return EFI_INVALID_PARAMETER;
@@ -747,36 +756,38 @@
       RangeEnd = Entry->End;
     }
 
-    DEBUG ((DEBUG_PAGE, "ConvertRange: %lx-%lx to %d\n", Start, RangeEnd, NewType));
+    DEBUG ((DEBUG_PAGE, "ConvertRange: %lx-%lx to %d attr %x\n", Start, RangeEnd, NewType, NewAttributes));
 
-    //
-    // Debug code - verify conversion is allowed
-    //
-    if (!(NewType == EfiConventionalMemory ? 1 : 0) ^ (Entry->Type == EfiConventionalMemory ? 1 : 0)) {
-      DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: Incompatible memory types\n"));
-      return EFI_NOT_FOUND;
-    }
+    if (ChangingType) {
+      //
+      // Debug code - verify conversion is allowed
+      //
+      if (!(NewType == EfiConventionalMemory ? 1 : 0) ^ (Entry->Type == EfiConventionalMemory ? 1 : 0)) {
+        DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: Incompatible memory types\n"));
+        return EFI_NOT_FOUND;
+      }
 
-    //
-    // Update counters for the number of pages allocated to each memory type
-    //
-    if ((UINT32)Entry->Type < EfiMaxMemoryType) {
-      if ((Start >= mMemoryTypeStatistics[Entry->Type].BaseAddress && Start <= mMemoryTypeStatistics[Entry->Type].MaximumAddress) ||
-          (Start >= mDefaultBaseAddress && Start <= mDefaultMaximumAddress)                                                          ) {
-        if (NumberOfPages > mMemoryTypeStatistics[Entry->Type].CurrentNumberOfPages) {
-          mMemoryTypeStatistics[Entry->Type].CurrentNumberOfPages = 0;
-        } else {
-          mMemoryTypeStatistics[Entry->Type].CurrentNumberOfPages -= NumberOfPages;
+      //
+      // Update counters for the number of pages allocated to each memory type
+      //
+      if ((UINT32)Entry->Type < EfiMaxMemoryType) {
+        if ((Start >= mMemoryTypeStatistics[Entry->Type].BaseAddress && Start <= mMemoryTypeStatistics[Entry->Type].MaximumAddress) ||
+            (Start >= mDefaultBaseAddress && Start <= mDefaultMaximumAddress)                                                          ) {
+          if (NumberOfPages > mMemoryTypeStatistics[Entry->Type].CurrentNumberOfPages) {
+            mMemoryTypeStatistics[Entry->Type].CurrentNumberOfPages = 0;
+          } else {
+            mMemoryTypeStatistics[Entry->Type].CurrentNumberOfPages -= NumberOfPages;
+          }
         }
       }
-    }
 
-    if ((UINT32)NewType < EfiMaxMemoryType) {
-      if ((Start >= mMemoryTypeStatistics[NewType].BaseAddress && Start <= mMemoryTypeStatistics[NewType].MaximumAddress) ||
-          (Start >= mDefaultBaseAddress && Start <= mDefaultMaximumAddress)                                                  ) {
-        mMemoryTypeStatistics[NewType].CurrentNumberOfPages += NumberOfPages;
-        if (mMemoryTypeStatistics[NewType].CurrentNumberOfPages > gMemoryTypeInformation[mMemoryTypeStatistics[NewType].InformationIndex].NumberOfPages) {
-          gMemoryTypeInformation[mMemoryTypeStatistics[NewType].InformationIndex].NumberOfPages = (UINT32)mMemoryTypeStatistics[NewType].CurrentNumberOfPages;
+      if ((UINT32)NewType < EfiMaxMemoryType) {
+        if ((Start >= mMemoryTypeStatistics[NewType].BaseAddress && Start <= mMemoryTypeStatistics[NewType].MaximumAddress) ||
+            (Start >= mDefaultBaseAddress && Start <= mDefaultMaximumAddress)                                                  ) {
+          mMemoryTypeStatistics[NewType].CurrentNumberOfPages += NumberOfPages;
+          if (mMemoryTypeStatistics[NewType].CurrentNumberOfPages > gMemoryTypeInformation[mMemoryTypeStatistics[NewType].InformationIndex].NumberOfPages) {
+            gMemoryTypeInformation[mMemoryTypeStatistics[NewType].InformationIndex].NumberOfPages = (UINT32)mMemoryTypeStatistics[NewType].CurrentNumberOfPages;
+          }
         }
       }
     }
@@ -830,9 +841,15 @@
 
     //
     // The new range inherits the same Attribute as the Entry
-    //it is being cut out of
+    // it is being cut out of unless attributes are being changed
     //
-    Attribute = Entry->Attribute;
+    if (ChangingType) {
+      Attribute = Entry->Attribute;
+      MemType = NewType;
+    } else {
+      Attribute = NewAttributes;
+      MemType = Entry->Type;
+    }
 
     //
     // If the descriptor is empty, then remove it from the map
@@ -845,8 +862,8 @@
     //
     // Add our new range in
     //
-    CoreAddRange (NewType, Start, RangeEnd, Attribute);
-    if (NewType == EfiConventionalMemory) {
+    CoreAddRange (MemType, Start, RangeEnd, Attribute);
+    if (ChangingType && (MemType == EfiConventionalMemory)) {
       //
       // Avoid calling DEBUG_CLEAR_MEMORY() for an address of 0 because this
       // macro will ASSERT() if address is 0.  Instead, CoreAddRange() guarantees
@@ -880,8 +897,67 @@
 }
 
 
+/**
+  Internal function.  Converts a memory range to the specified type.
+  The range must exist in the memory map.
 
+  @param  Start                  The first address of the range Must be page
+                                 aligned
+  @param  NumberOfPages          The number of pages to convert
+  @param  NewType                The new type for the memory range
+
+  @retval EFI_INVALID_PARAMETER  Invalid parameter
+  @retval EFI_NOT_FOUND          Could not find a descriptor cover the specified
+                                 range  or convertion not allowed.
+  @retval EFI_SUCCESS            Successfully converts the memory range to the
+                                 specified type.
+
+**/
+EFI_STATUS
+CoreConvertPages (
+  IN UINT64           Start,
+  IN UINT64           NumberOfPages,
+  IN EFI_MEMORY_TYPE  NewType
+  )
+{
+  return CoreConvertPagesEx(Start, NumberOfPages, TRUE, NewType, FALSE, 0);
+}
+
+
 /**
+  Internal function.  Converts a memory range to use new attributes.
+
+  @param  Start                  The first address of the range Must be page
+                                 aligned
+  @param  NumberOfPages          The number of pages to convert
+  @param  NewAttributes          The new attributes value for the range.
+
+  @retval EFI_INVALID_PARAMETER  Invalid parameter
+  @retval EFI_NOT_FOUND          Could not find a descriptor cover the specified
+                                 range  or convertion not allowed.
+  @retval EFI_SUCCESS            Successfully converts the memory range to the
+                                 specified attributes.
+
+**/
+VOID
+CoreUpdateMemoryAttributes (
+  IN EFI_PHYSICAL_ADDRESS  Start,
+  IN UINT64                NumberOfPages,
+  IN UINT64                NewAttributes
+  )
+{
+  CoreAcquireMemoryLock ();
+
+  //
+  // Update the attributes to the new value
+  //
+  CoreConvertPagesEx(Start, NumberOfPages, FALSE, (EFI_MEMORY_TYPE)0, TRUE, NewAttributes);
+
+  CoreReleaseMemoryLock ();
+}
+
+
+/**
   Internal function. Finds a consecutive free page range below
   the requested address.
 
Index: MdePkg/Include/Pi/PiDxeCis.h
===================================================================
--- MdePkg/Include/Pi/PiDxeCis.h	(revision 16342)
+++ MdePkg/Include/Pi/PiDxeCis.h	(working copy)
@@ -1,7 +1,7 @@
 /** @file
   Include file matches things in PI.
 
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials are licensed and made available under 
 the terms and conditions of the BSD License that accompanies this distribution.  
 The full text of the license may be found at
@@ -365,7 +365,7 @@
                                 resource range specified by BaseAddress and Length.
   @retval EFI_UNSUPPORTED       The bit mask of attributes is not support for the memory resource
                                 range specified by BaseAddress and Length.
-  @retval EFI_ACCESS_DEFINED    The attributes for the memory resource range specified by
+  @retval EFI_ACCESS_DENIED     The attributes for the memory resource range specified by
                                 BaseAddress and Length cannot be modified.
   @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the attributes of
                                 the memory resource range.
@@ -381,6 +381,31 @@
   );
 
 /**
+  Modifies the capabilities for a memory region in the global coherency domain of the
+  processor.
+
+  @param  BaseAddress      The physical address that is the start address of a memory region.
+  @param  Length           The size in bytes of the memory region.
+  @param  Capabilities     The bit mask of capabilities that the memory region supports.
+
+  @retval EFI_SUCCESS           The capabilities were set for the memory region.
+  @retval EFI_INVALID_PARAMETER Length is zero.
+  @retval EFI_UNSUPPORTED       The capabilities specified by Capabilities do not include the
+                                memory region attributes currently in use.
+  @retval EFI_ACCESS_DENIED     The capabilities for the memory resource range specified by
+                                BaseAddress and Length cannot be modified.
+  @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the capabilities
+                                of the memory resource range.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SET_MEMORY_SPACE_CAPABILITIES) (
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN UINT64                Length,
+  IN UINT64                Capabilities
+  );
+
+/**
   Returns a map of the memory resources in the global coherency domain of the
   processor.
 
@@ -694,6 +719,10 @@
   // Service to process a single firmware volume found in a capsule
   //
   EFI_PROCESS_FIRMWARE_VOLUME     ProcessFirmwareVolume;
+  //
+  // Extensions to Global Coherency Domain Services
+  //
+  EFI_SET_MEMORY_SPACE_CAPABILITIES SetMemorySpaceCapabilities;
 } DXE_SERVICES;
 
 typedef DXE_SERVICES EFI_DXE_SERVICES;
