From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.7066.1682066249739051879 for ; Fri, 21 Apr 2023 01:37:31 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=lsEIiq6/; spf=pass (domain: intel.com, ip: 192.55.52.88, 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=1682066251; x=1713602251; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xmRSP5coITGh1eWUGBVko8AO78ADntu3d9tZaGaN0MA=; b=lsEIiq6/dnkpWAZxuWAJdtUqxlwf8NOng4Lz5Co0FT+ejzY2vYSk8R8Q 7VxaxOj0DD6APapLGuRaGCAA7nS8WdzHIT+yW7qRNwEIuFAVX20jgysFh GndKNmhFIFwsft3BCS9c+tZZjvFciYEDIdyCX9jSKgNUim/8EWZDsN1G9 mTXkSe9m6euyOHNs6KiiMpmlX459PX2oLHy6fwoKui6UErTZmT0U6iqHh KgoEdvGFOQ5fBJ2MCGs0SUpTH/wzgiIt/GWscNIk5v0HS+Jp8Xdtd2b54 S6AxK5OOtaNXp3CTFn2fL+mMwufvfQqAX8zR9EaDu7tTz0InqpAxK6iJo Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="373869799" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="373869799" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2023 01:37:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="669650499" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="669650499" Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.92]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2023 01:37:12 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [Patch V3 11/11] UefiCpuPkg/PiSmmCpuDxeSmm: Remove unnecessary function Date: Fri, 21 Apr 2023 16:36:28 +0800 Message-Id: <20230421083628.1408-12-dun.tan@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20230421083628.1408-1-dun.tan@intel.com> References: <20230421083628.1408-1-dun.tan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Remove unnecessary function SetNotPresentPage(). We can directly use ConvertMemoryPageAttributes to set a range to non-present. Signed-off-by: Dun Tan Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 8 ++++++-- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 16 ---------------- UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 22 ---------------------- 3 files changed, 6 insertions(+), 40 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index c0e368ea94..5316ba7b5a 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -1074,10 +1074,14 @@ PiCpuSmmEntry ( mSmmShadowStackSize ); if (FeaturePcdGet (PcdCpuSmmStackGuard)) { - SetNotPresentPage ( + ConvertMemoryPageAttributes ( Cr3, + mPagingMode, (EFI_PHYSICAL_ADDRESS)(UINTN)Stacks + mSmmStackSize + EFI_PAGES_TO_SIZE (1) + (mSmmStackSize + mSmmShadowStackSize) * Index, - EFI_PAGES_TO_SIZE (1) + EFI_PAGES_TO_SIZE (1), + EFI_MEMORY_RP, + TRUE, + NULL ); } } diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h index 37366d6803..5f1f1698fa 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h @@ -1235,22 +1235,6 @@ SetShadowStack ( IN UINT64 Length ); -/** - Set not present memory. - - @param[in] Cr3 The page table base address. - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - - @retval EFI_SUCCESS The not present memory is set. -**/ -EFI_STATUS -SetNotPresentPage ( - IN UINTN Cr3, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length - ); - /** Initialize the shadow stack related data structure. diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c index 9a0619ce51..7cebc16a1d 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c @@ -708,28 +708,6 @@ SetShadowStack ( return Status; } -/** - Set not present memory. - - @param[in] Cr3 The page table base address. - @param[in] BaseAddress The physical address that is the start address of a memory region. - @param[in] Length The size in bytes of the memory region. - - @retval EFI_SUCCESS The not present memory is set. -**/ -EFI_STATUS -SetNotPresentPage ( - IN UINTN Cr3, - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length - ) -{ - EFI_STATUS Status; - - Status = SmmSetMemoryAttributesEx (Cr3, mPagingMode, BaseAddress, Length, EFI_MEMORY_RP); - return Status; -} - /** Retrieves a pointer to the system configuration table from the SMM System Table based on a specified GUID. -- 2.39.1.windows.1