]> xenbits.xensource.com Git - ovmf.git/commitdiff
UefiCpuPkg/CpuPageTableLib: Add check for input Length
authorDun Tan <dun.tan@intel.com>
Tue, 7 Mar 2023 03:51:32 +0000 (11:51 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 27 Mar 2023 08:21:58 +0000 (08:21 +0000)
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>
UefiCpuPkg/Include/Library/CpuPageTableLib.h
UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c

index 2dc9b7d18edbffb406a543ced875dc315a7a2e22..5f44ece548915d530e7bd885bbd367d5ddc4f30e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Public include file for PageTableLib library.\r
 \r
-  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2022 - 2023, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -81,7 +81,7 @@ typedef enum {
   @retval RETURN_BUFFER_TOO_SMALL   The buffer is too small for page table creation/updating.\r
                                     BufferSize is updated to indicate the expected buffer size.\r
                                     Caller may still get RETURN_BUFFER_TOO_SMALL with the new BufferSize.\r
-  @retval RETURN_SUCCESS            PageTable is created/updated successfully.\r
+  @retval RETURN_SUCCESS            PageTable is created/updated successfully or the input Length is 0.\r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
index 52535e5a8d11b5d93499e95f6b6c7da365eb9356..218068a3e1fcdbcfc2846205a71b6466a44eb7d8 100644 (file)
@@ -544,7 +544,7 @@ PageTableLibMapInLevel (
   @retval RETURN_BUFFER_TOO_SMALL   The buffer is too small for page table creation/updating.\r
                                     BufferSize is updated to indicate the expected buffer size.\r
                                     Caller may still get RETURN_BUFFER_TOO_SMALL with the new BufferSize.\r
-  @retval RETURN_SUCCESS            PageTable is created/updated successfully.\r
+  @retval RETURN_SUCCESS            PageTable is created/updated successfully or the input Length is 0.\r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
@@ -567,6 +567,10 @@ PageTableMap (
   IA32_PAGE_LEVEL     MaxLeafLevel;\r
   IA32_MAP_ATTRIBUTE  ParentAttribute;\r
 \r
+  if (Length == 0) {\r
+    return RETURN_SUCCESS;\r
+  }\r
+\r
   if ((PagingMode == Paging32bit) || (PagingMode == PagingPae) || (PagingMode >= PagingModeMax)) {\r
     //\r
     // 32bit paging is never supported.\r