From nobody Fri May 3 14:11:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1524639983744660.5456154309916; Wed, 25 Apr 2018 00:06:23 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3BCA7226847A5; Wed, 25 Apr 2018 00:06:22 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0796F2041B281 for ; Wed, 25 Apr 2018 00:06:20 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2018 00:06:20 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.4]) by orsmga002.jf.intel.com with ESMTP; 25 Apr 2018 00:06:19 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,325,1520924400"; d="scan'208";a="53454225" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 25 Apr 2018 15:06:16 +0800 Message-Id: <20180425070616.18108-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [edk2] [PATCH] IntelFrameworkModule/LegacyBios: Use reserved memory for legacy data X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Certain Legacy USB implementation needs to access legacy data (BDA, etc.) from SMM environment. While currently it's not allowed to access BS memory from SMM after EndofDxe, change the legacy data to use reserved memory type. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng --- IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c | 13 +++++++++= ++-- .../Csm/LegacyBiosDxe/LegacyBiosInterface.h | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c b/Intel= FrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c index fca08a8fa2..a96f9b5610 100644 --- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c +++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c @@ -46,7 +46,8 @@ BOOLEAN mEndOfDxe =3D FALSE; Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode memory. =20 - @param AllocateType Allocated Legacy Memory Type + @param AllocateType The type of allocation to perform. + @param MemoryType The type of memory to allocate. @param StartPageAddress Start address of range @param Pages Number of pages to allocate @param Result Result of allocation @@ -58,6 +59,7 @@ BOOLEAN mEndOfDxe =3D FALSE; EFI_STATUS AllocateLegacyMemory ( IN EFI_ALLOCATE_TYPE AllocateType, + IN EFI_MEMORY_TYPE MemoryType, IN EFI_PHYSICAL_ADDRESS StartPageAddress, IN UINTN Pages, OUT EFI_PHYSICAL_ADDRESS *Result @@ -72,7 +74,7 @@ AllocateLegacyMemory ( MemPage =3D (EFI_PHYSICAL_ADDRESS) (UINTN) StartPageAddress; Status =3D gBS->AllocatePages ( AllocateType, - EfiBootServicesCode, + MemoryType, Pages, &MemPage ); @@ -974,6 +976,7 @@ LegacyBiosInstall ( // AllocateLegacyMemory ( AllocateAddress, + EfiReservedMemoryType, 0, 1, &MemoryAddress @@ -999,6 +1002,7 @@ LegacyBiosInstall ( =20 Status =3D AllocateLegacyMemory ( AllocateAddress, + EfiReservedMemoryType, CONVENTIONAL_MEMORY_TOP - MemorySize, EFI_SIZE_TO_PAGES (MemorySize), &MemoryAddress @@ -1027,6 +1031,7 @@ LegacyBiosInstall ( for (MemStart =3D MemoryAddress; MemStart < MemoryAddress + MemorySize; = MemStart +=3D 0x1000) { Status =3D AllocateLegacyMemory ( AllocateAddress, + EfiBootServicesCode, MemStart, 1, &StartAddress @@ -1046,6 +1051,7 @@ LegacyBiosInstall ( ASSERT ((MemorySize & 0xFFF) =3D=3D 0); =20 Status =3D AllocateLegacyMemory ( AllocateMaxAddress, + EfiBootServicesCode, CONVENTIONAL_MEMORY_TOP, EFI_SIZE_TO_PAGES (MemorySize), &MemoryAddressUnder1MB @@ -1059,6 +1065,7 @@ LegacyBiosInstall ( // Status =3D AllocateLegacyMemory ( AllocateMaxAddress, + EfiReservedMemoryType, CONVENTIONAL_MEMORY_TOP, (sizeof (LOW_MEMORY_THUNK) / EFI_PAGE_SIZE) + 2, &MemoryAddress @@ -1086,6 +1093,7 @@ LegacyBiosInstall ( // =20 Status =3D AllocateLegacyMemory ( AllocateMaxAddress, + EfiBootServicesCode, 0x1000000, EFI_SIZE_TO_PAGES (MemorySize), &MemoryAddress @@ -1096,6 +1104,7 @@ LegacyBiosInstall ( // =20 Status =3D AllocateLegacyMemory ( AllocateMaxAddress, + EfiBootServicesCode, 0xFFFFFFFF, EFI_SIZE_TO_PAGES (MemorySize), &MemoryAddress diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.= h b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h index cc2fc9fc13..595fe0eade 100644 --- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h +++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h @@ -1264,7 +1264,8 @@ GenerateSoftInit ( Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode memory. =20 - @param AllocateType Allocated Legacy Memory Type + @param AllocateType The type of allocation to perform. + @param MemoryType The type of memory to allocate. @param StartPageAddress Start address of range @param Pages Number of pages to allocate @param Result Result of allocation @@ -1276,6 +1277,7 @@ GenerateSoftInit ( EFI_STATUS AllocateLegacyMemory ( IN EFI_ALLOCATE_TYPE AllocateType, + IN EFI_MEMORY_TYPE MemoryType, IN EFI_PHYSICAL_ADDRESS StartPageAddress, IN UINTN Pages, OUT EFI_PHYSICAL_ADDRESS *Result --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel