X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=UefiCpuPkg%2FPiSmmCpuDxeSmm%2FSmmCpuMemoryManagement.c;h=85e06b2e6a0d08064754bf11430e0dbf8d0bfdf9;hp=2d7dba59bf30370241c06f22bb4e690a9533846d;hb=5a1bfda4bd04815ed8c7489e2db47f9a1f245566;hpb=827330ccd1d0983fe4d059fee518bf42c70ef31e diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c index 2d7dba59bf..85e06b2e6a 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 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 @@ -552,12 +552,12 @@ SmmSetMemoryAttributesEx ( BaseAddress and Length cannot be modified. @retval EFI_INVALID_PARAMETER Length is zero. Attributes specified an illegal combination of attributes that - cannot be set together. + cannot be cleared together. @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of the memory resource range. @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource + The bit mask of attributes is not supported for the memory resource range specified by BaseAddress and Length. **/ @@ -604,7 +604,7 @@ SmmClearMemoryAttributesEx ( the memory resource range. @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource + The bit mask of attributes is not supported for the memory resource range specified by BaseAddress and Length. **/ @@ -632,12 +632,12 @@ SmmSetMemoryAttributes ( BaseAddress and Length cannot be modified. @retval EFI_INVALID_PARAMETER Length is zero. Attributes specified an illegal combination of attributes that - cannot be set together. + cannot be cleared together. @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of the memory resource range. @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for the memory resource + The bit mask of attributes is not supported for the memory resource range specified by BaseAddress and Length. **/ @@ -768,6 +768,52 @@ PatchSmmSaveStateMap ( ); } +/** + This function sets GDT/IDT buffer to be RO and XP. +**/ +VOID +PatchGdtIdtMap ( + VOID + ) +{ + EFI_PHYSICAL_ADDRESS BaseAddress; + UINTN Size; + + // + // GDT + // + DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - GDT:\n")); + + BaseAddress = mGdtBuffer; + Size = ALIGN_VALUE(mGdtBufferSize, SIZE_4KB); + // + // The range should have been set to RO + // if it is allocated with EfiRuntimeServicesCode. + // + SmmSetMemoryAttributes ( + BaseAddress, + Size, + EFI_MEMORY_XP + ); + + // + // IDT + // + DEBUG ((DEBUG_INFO, "PatchGdtIdtMap - IDT:\n")); + + BaseAddress = gcSmiIdtr.Base; + Size = ALIGN_VALUE(gcSmiIdtr.Limit + 1, SIZE_4KB); + // + // The range should have been set to RO + // if it is allocated with EfiRuntimeServicesCode. + // + SmmSetMemoryAttributes ( + BaseAddress, + Size, + EFI_MEMORY_XP + ); +} + /** This function sets memory attribute according to MemoryAttributesTable. **/ @@ -1139,7 +1185,7 @@ IsSmmCommBufferForbiddenAddress ( @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for + The bit mask of attributes is not supported for the memory resource range specified by BaseAddress and Length. @@ -1164,17 +1210,17 @@ EdkiiSmmSetMemoryAttributes ( @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 Attributes The bit mask of attributes to set for the memory + @param Attributes The bit mask of attributes to clear for the memory region. - @retval EFI_SUCCESS The attributes were set for the memory region. + @retval EFI_SUCCESS The attributes were cleared for the memory region. @retval EFI_INVALID_PARAMETER Length is zero. Attributes specified an illegal combination of - attributes that cannot be set together. + attributes that cannot be cleared together. @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for + The bit mask of attributes is not supported for the memory resource range specified by BaseAddress and Length. @@ -1192,7 +1238,7 @@ EdkiiSmmClearMemoryAttributes ( } /** - This function retrieve the attributes of the memory region specified by + This function retrieves the attributes of the memory region specified by BaseAddress and Length. If different attributes are got from different part of the memory region, EFI_NO_MAPPING will be returned. @@ -1210,9 +1256,6 @@ EdkiiSmmClearMemoryAttributes ( @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. - The bit mask of attributes is not support for - the memory resource range specified by - BaseAddress and Length. **/ EFI_STATUS