From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.67098.1679557268568440146 for ; Thu, 23 Mar 2023 00:41:13 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=bERF6wGK; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: dun.tan@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679557273; x=1711093273; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DVYNlmU0dF0Ovn6U+l0ZQJesNrE6B+rV51cinCXrulQ=; b=bERF6wGK7FvpX2LJRBGoEwpwWeIYY/vJqfENS0xkh6KWQpdz/ezvc0JP t/woAfzGMaK67aIhBCqUEaWEOik08Id0L5toRotzXAZGpe0nhxGz7BXlD bR3sfAgjTKj3e9exoz8hQDSLgPYMAAZcNIaO61WCcsf5HZQDK3OayltWB 6DbtfdeAu0djLdEIuvQySGLzc7G53SSRZ3Ugzk34q+ajeiD1a3DbslefF Swj/XMgP+2H2NnSalOkqwYZB1gBYcUIQpZFHGbuWDiy4i5dNeyu1o1xoE CjX6X9flKwVYhP2oHzimf0mcwLFA2V1WGuhxkIdXv/wBsG81b10R5w1Zn w==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="425699490" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="425699490" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 00:41:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="684616809" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="684616809" Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.92]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 00:41:11 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [Patch V4 02/21] UefiCpuPkg/CpuPageTableLib: Add check for input Length Date: Thu, 23 Mar 2023 15:40:38 +0800 Message-Id: <20230323074057.549-3-dun.tan@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20230323074057.549-1-dun.tan@intel.com> References: <20230323074057.549-1-dun.tan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add check for input Length in PageTableMap (). Return RETURN_SUCCESS when input Length is 0. Signed-off-by: Dun Tan Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann --- UefiCpuPkg/Include/Library/CpuPageTableLib.h | 4 ++-- UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/Include/Library/CpuPageTableLib.h b/UefiCpuPkg/Include/Library/CpuPageTableLib.h index 2dc9b7d18e..5f44ece548 100644 --- a/UefiCpuPkg/Include/Library/CpuPageTableLib.h +++ b/UefiCpuPkg/Include/Library/CpuPageTableLib.h @@ -1,7 +1,7 @@ /** @file Public include file for PageTableLib library. - Copyright (c) 2022, Intel Corporation. All rights reserved.
+ Copyright (c) 2022 - 2023, Intel Corporation. All rights reserved.
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 diff --git a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c index 52535e5a8d..218068a3e1 100644 --- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c +++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c @@ -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. -- 2.31.1.windows.1