From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 14EAE222EDCD8 for ; Fri, 5 Jan 2018 02:59:27 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jan 2018 03:04:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,318,1511856000"; d="scan'208";a="8304180" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga008.jf.intel.com with ESMTP; 05 Jan 2018 03:04:33 -0800 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 5 Jan 2018 03:04:32 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 5 Jan 2018 03:04:32 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.189]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.152]) with mapi id 14.03.0319.002; Fri, 5 Jan 2018 19:04:30 +0800 From: "Zeng, Star" To: Wasim Khan , "edk2-devel@lists.01.org" CC: "Zeng, Star" , "Gao, Liming" Thread-Topic: Memory space entry is not removed after calling FreeMemorySpace and RemoveMemorySpace Thread-Index: AdOGC9ELVQ4yvX0oRxySz+o11ogX7AAB/zdQ Date: Fri, 5 Jan 2018 11:04:30 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9F8894@shsmsx102.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: Memory space entry is not removed after calling FreeMemorySpace and RemoveMemorySpace X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jan 2018 10:59:28 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable PI spec has clear description below in AddMemorySpace(). "If the memory range specified by BaseAddress and Length is of type EfiGcdM= emoryTypeSystemMemory or EfiGcdMemoryTypeMoreReliable, then the memory range may be *automatically allocated for use by the UEFI memory ser= vices*." But PI spec has no clear description about removing the use from the UEFI m= emory services in FreeMemorySpace() and RemoveMemorySpace(). I think it is very hard (may be not possible) as the added memory space may= have been used by UEFI memory (page) services for drivers after the memory= space is added by AddMemorySpace(). What is the usage that the memory space needs to be added first and removed= later? Could the memory space be added as EfiGcdMemoryTypeReserved type instead of= EfiGcdMemoryTypeSystemMemory type? Thanks, Star -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Wasi= m Khan Sent: Friday, January 5, 2018 5:59 PM To: edk2-devel@lists.01.org Subject: [edk2] Memory space entry is not removed after calling FreeMemoryS= pace and RemoveMemorySpace Hi All, I am facing a problem that if a add a memory space using 'gDS->AddMemorySpa= ce' and then remove it using 'gDS->FreeMemorySpace' followed by 'gDS->Remo= veMemorySpace'. I can still see the entry of added memory space in the table shown by 'memm= ap' command. I enabled DEBUG_GCD and as per logs , the entry is removed from GcdMemorySp= aceMap , but when I run 'memmap' command which gets the memory map using 'g= BS->GetMemoryMap', I can see that entry for the added memory space is still= present. Steps and Logs are below for reference Do I need to perform any other steps in order to cleanly remove the memory = space entry ? Regards, Wasim Below are the steps and GCD debug logs. Steps 1 : Add a memory space . We can see that an entry from system memory = is added. Status =3D gDS->AddMemorySpace ( EfiGcdMemoryTypeSystemMemory, FixedPcdGet64(PcdSystemMemoryEx= Base), SystemMemoryExSize, EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB ); Logs: GCD:AddMemorySpace(Base=3D0000008080000000,Le= ngth=3D0000000380000000) GcdMemoryType =3D SystemMem Capabilities =3D 000000000000000E CoreConvertSpace 774 Status =3D Success GCDMemType Range Capabilities Attributes =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D NonExist 0000000000000000-000000009FFFFFFF 0000000000000000 0000000000000= 000 SystemMem 00000000A0000000-00000000DFFFFFFF 800000000000000E 0000000000000= 008* NonExist 00000000E0000000-00000000E01BFFFF 0000000000000000 0000000000000= 000 SystemMem 00000000E01C0000-00000000FFFFFFFF 800000000000000E 0000000000000= 008* NonExist 0000000100000000-000000807FFFFFFF 0000000000000000 0000000000000= 000 SystemMem 0000008080000000-00000083FFFFFFFF 800000000000000E 0000000000000= 000 NonExist 0000008400000000-0000FFFFFFFFFFFF 0000000000000000 0000000000000= 000 GCD:AllocateMemorySpace(Base=3D0000008080000000,Length=3D0000000380000000) GcdAllocateType =3D AtAddress GcdMemoryType =3D SystemMem Alignment =3D 0000000000001000 ImageHandle =3D FED1FF98 DeviceHandle =3D 0 Status =3D Success (BaseAddress =3D 0000008080000000) GCDMemType Range Capabilities Attributes =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D NonExist 0000000000000000-000000009FFFFFFF 0000000000000000 0000000000000= 000 SystemMem 00000000A0000000-00000000DFFFFFFF 800000000000000E 0000000000000= 008* NonExist 00000000E0000000-00000000E01BFFFF 0000000000000000 0000000000000= 000 SystemMem 00000000E01C0000-00000000FFFFFFFF 800000000000000E 0000000000000= 008* NonExist 0000000100000000-000000807FFFFFFF 0000000000000000 0000000000000= 000 SystemMem 0000008080000000-00000083FFFFFFFF 800000000000000E 0000000000000= 000* NonExist 0000008400000000-0000FFFFFFFFFFFF 0000000000000000 0000000000000= 000 Step2: Free the memory space Status =3D gDS->FreeMemorySpace ( FixedPcdGet64(PcdSystemMemoryExBase), SystemMemoryExSize ); Logs: GCD:FreeMemorySpace(Base=3D0000008080000000,L= ength=3D0000000380000000) Status =3D Success GCDMemType Range Capabilities Attributes =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D NonExist 0000000000000000-000000009FFFFFFF 0000000000000000 0000000000000= 000 SystemMem 00000000A0000000-00000000DFFFFFFF 800000000000000E 0000000000000= 008* NonExist 00000000E0000000-00000000E01BFFFF 0000000000000000 0000000000000= 000 SystemMem 00000000E01C0000-00000000FFFFFFFF 800000000000000E 0000000000000= 008* NonExist 0000000100000000-000000807FFFFFFF 0000000000000000 0000000000000= 000 SystemMem 0000008080000000-00000083FFFFFFFF 800000000000000E 0000000000000= 000 NonExist 0000008400000000-0000FFFFFFFFFFFF 0000000000000000 0000000000000= 000 Step3: Remove the memory space , As we can see that entry 'SystemMem 00000= 08080000000-00000083FFFFFFFF' is removed. Status =3D gDS->RemoveMemorySpace ( FixedPcdGet64(PcdSystemMemoryExBase), SystemMemoryExSize ); Logs: GCD:RemoveMemorySpace(Base=3D0000008080000000= ,Length=3D0000000380000000) Status =3D Success GCDMemType Range Capabilities Attributes =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D NonExist 0000000000000000-000000009FFFFFFF 0000000000000000 0000000000000= 000 SystemMem 00000000A0000000-00000000DFFFFFFF 800000000000000E 0000000000000= 008* NonExist 00000000E0000000-00000000E01BFFFF 0000000000000000 0000000000000= 000 SystemMem 00000000E01C0000-00000000FFFFFFFF 800000000000000E 0000000000000= 008* NonExist 0000000100000000-0000FFFFFFFFFFFF 0000000000000000 0000000000000= 000 Step4 : Run the 'memmap' command. As we can see that entry is still present= . Shell> memmap Type Start End # Pages Attributes Available 00000000A0000000-00000000DFFFFFFF 0000000000040000 0000000000000= 00E Available 00000000E01C0000-00000000E53C0FFF 0000000000005201 000000000= 000000E BS_Data 00000000E53C1000-00000000E5D99FFF 00000000000009D9 0000000000000= 00E ... Available 0000008080000000-00000083FFFFFFFF 0000000000380000 0000000000000= 00E ... _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel