/** @file\r
\r
-Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
BaseAddress and Length cannot be modified.\r
@retval EFI_INVALID_PARAMETER Length is zero.\r
Attributes specified an illegal combination of attributes that\r
- cannot be set together.\r
+ cannot be cleared together.\r
@retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of\r
the memory resource range.\r
@retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory\r
resource range specified by BaseAddress and Length.\r
- The bit mask of attributes is not support for the memory resource\r
+ The bit mask of attributes is not supported for the memory resource\r
range specified by BaseAddress and Length.\r
\r
**/\r
the memory resource range.\r
@retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory\r
resource range specified by BaseAddress and Length.\r
- The bit mask of attributes is not support for the memory resource\r
+ The bit mask of attributes is not supported for the memory resource\r
range specified by BaseAddress and Length.\r
\r
**/\r
BaseAddress and Length cannot be modified.\r
@retval EFI_INVALID_PARAMETER Length is zero.\r
Attributes specified an illegal combination of attributes that\r
- cannot be set together.\r
+ cannot be cleared together.\r
@retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of\r
the memory resource range.\r
@retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory\r
resource range specified by BaseAddress and Length.\r
- The bit mask of attributes is not support for the memory resource\r
+ The bit mask of attributes is not supported for the memory resource\r
range specified by BaseAddress and Length.\r
\r
**/\r
);\r
}\r
\r
+/**\r
+ This function sets GDT/IDT buffer to be RO and XP.\r
+**/\r
+VOID\r
+PatchGdtIdtMap (\r
+ VOID\r
+ )\r
+{\r
+ EFI_PHYSICAL_ADDRESS BaseAddress;\r
+ UINTN Size;\r
+\r
+ //\r
+ // GDT\r
+ //\r
+ DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - GDT:\n"));\r
+\r
+ BaseAddress = mGdtBuffer;\r
+ Size = ALIGN_VALUE(mGdtBufferSize, SIZE_4KB);\r
+ //\r
+ // The range should have been set to RO\r
+ // if it is allocated with EfiRuntimeServicesCode.\r
+ //\r
+ SmmSetMemoryAttributes (\r
+ BaseAddress,\r
+ Size,\r
+ EFI_MEMORY_XP\r
+ );\r
+\r
+ //\r
+ // IDT\r
+ //\r
+ DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - IDT:\n"));\r
+\r
+ BaseAddress = gcSmiIdtr.Base;\r
+ Size = ALIGN_VALUE(gcSmiIdtr.Limit + 1, SIZE_4KB);\r
+ //\r
+ // The range should have been set to RO\r
+ // if it is allocated with EfiRuntimeServicesCode.\r
+ //\r
+ SmmSetMemoryAttributes (\r
+ BaseAddress,\r
+ Size,\r
+ EFI_MEMORY_XP\r
+ );\r
+}\r
+\r
/**\r
This function sets memory attribute according to MemoryAttributesTable.\r
**/\r
@retval EFI_UNSUPPORTED The processor does not support one or more\r
bytes of the memory resource range specified\r
by BaseAddress and Length.\r
- The bit mask of attributes is not support for\r
+ The bit mask of attributes is not supported for\r
the memory resource range specified by\r
BaseAddress and Length.\r
\r
@param BaseAddress The physical address that is the start address of\r
a memory region.\r
@param Length The size in bytes of the memory region.\r
- @param Attributes The bit mask of attributes to set for the memory\r
+ @param Attributes The bit mask of attributes to clear for the memory\r
region.\r
\r
- @retval EFI_SUCCESS The attributes were set for the memory region.\r
+ @retval EFI_SUCCESS The attributes were cleared for the memory region.\r
@retval EFI_INVALID_PARAMETER Length is zero.\r
Attributes specified an illegal combination of\r
- attributes that cannot be set together.\r
+ attributes that cannot be cleared together.\r
@retval EFI_UNSUPPORTED The processor does not support one or more\r
bytes of the memory resource range specified\r
by BaseAddress and Length.\r
- The bit mask of attributes is not support for\r
+ The bit mask of attributes is not supported for\r
the memory resource range specified by\r
BaseAddress and Length.\r
\r
}\r
\r
/**\r
- This function retrieve the attributes of the memory region specified by\r
+ This function retrieves the attributes of the memory region specified by\r
BaseAddress and Length. If different attributes are got from different part\r
of the memory region, EFI_NO_MAPPING will be returned.\r
\r
@retval EFI_UNSUPPORTED The processor does not support one or more\r
bytes of the memory resource range specified\r
by BaseAddress and Length.\r
- The bit mask of attributes is not support for\r
- the memory resource range specified by\r
- BaseAddress and Length.\r
\r
**/\r
EFI_STATUS\r