UefiCpuPkg/CpuPageTableLib: Add check for input Length

Add check for input Length in PageTableMap (). Return
RETURN_SUCCESS when input Length is 0.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Dun Tan 2023-03-07 11:51:32 +08:00 committed by mergify[bot]
parent da3dad181e
commit c18fbd2c31
2 changed files with 7 additions and 3 deletions
UefiCpuPkg
Include/Library
Library/CpuPageTableLib

View File

@ -1,7 +1,7 @@
/** @file
Public include file for PageTableLib library.
Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2022 - 2023, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@ -81,7 +81,7 @@ typedef enum {
@retval RETURN_BUFFER_TOO_SMALL The buffer is too small for page table creation/updating.
BufferSize is updated to indicate the expected buffer size.
Caller may still get RETURN_BUFFER_TOO_SMALL with the new BufferSize.
@retval RETURN_SUCCESS PageTable is created/updated successfully.
@retval RETURN_SUCCESS PageTable is created/updated successfully or the input Length is 0.
**/
RETURN_STATUS
EFIAPI

View File

@ -544,7 +544,7 @@ PageTableLibMapInLevel (
@retval RETURN_BUFFER_TOO_SMALL The buffer is too small for page table creation/updating.
BufferSize is updated to indicate the expected buffer size.
Caller may still get RETURN_BUFFER_TOO_SMALL with the new BufferSize.
@retval RETURN_SUCCESS PageTable is created/updated successfully.
@retval RETURN_SUCCESS PageTable is created/updated successfully or the input Length is 0.
**/
RETURN_STATUS
EFIAPI
@ -567,6 +567,10 @@ PageTableMap (
IA32_PAGE_LEVEL MaxLeafLevel;
IA32_MAP_ATTRIBUTE ParentAttribute;
if (Length == 0) {
return RETURN_SUCCESS;
}
if ((PagingMode == Paging32bit) || (PagingMode == PagingPae) || (PagingMode >= PagingModeMax)) {
//
// 32bit paging is never supported.