From nobody Mon Dec 23 05:25:52 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 1520307583469386.6378268976997; Mon, 5 Mar 2018 19:39:43 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 522CC2257C2BB; Mon, 5 Mar 2018 19:33:27 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 E9FDA223CDC21 for ; Mon, 5 Mar 2018 19:33:24 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2018 19:39:37 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.44]) by fmsmga006.fm.intel.com with ESMTP; 05 Mar 2018 19:39:37 -0800 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=134.134.136.65; helo=mga03.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.47,430,1515484800"; d="scan'208";a="209154730" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Tue, 6 Mar 2018 11:39:32 +0800 Message-Id: <20180306033933.278752-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180306033933.278752-1-ruiyu.ni@intel.com> References: <20180306033933.278752-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 1/2] MdeModulePkg/NullMemoryTest: Change prototype of ConvertToTestedMemory 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: , Cc: Liming Gao 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" The patch should not impact the functionality. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Liming Gao Reviewed-by: Liming Gao Reviewed-by: Michael D Kinney --- .../MemoryTest/NullMemoryTestDxe/NullMemoryTest.c | 37 ++++++++++++++----= ---- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemory= Test.c b/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest= .c index 11af8ea77f..c66f3fd208 100644 --- a/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c +++ b/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c @@ -59,37 +59,40 @@ GenericMemoryTestEntryPoint ( } =20 /** - Convert the memory descriptor to tested. + Convert the memory range to tested. =20 - @param Descriptor Pointer to EFI_GCD_MEMORY_SPACE_DESCRIPTOR + @param BaseAddress Base address of the memory range. + @param Length Length of the memory range. + @param Capabilities Capabilities of the memory range. =20 - @retval EFI_SUCCESS The memory descriptor is converted to tested. + @retval EFI_SUCCESS The memory range is converted to tested. @retval others Error happens. **/ EFI_STATUS ConvertToTestedMemory ( - IN CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor + IN UINT64 BaseAddress, + IN UINT64 Length, + IN UINT64 Capabilities ) { EFI_STATUS Status; Status =3D gDS->RemoveMemorySpace ( - Descriptor->BaseAddress, - Descriptor->Length + BaseAddress, + Length ); if (!EFI_ERROR (Status)) { Status =3D gDS->AddMemorySpace ( - ((Descriptor->Capabilities & EFI_MEMORY_MORE_RELIABLE)= =3D=3D EFI_MEMORY_MORE_RELIABLE) ? + ((Capabilities & EFI_MEMORY_MORE_RELIABLE) =3D=3D EFI_= MEMORY_MORE_RELIABLE) ? EfiGcdMemoryTypeMoreReliable : EfiGcdMemoryTypeSystemM= emory, - Descriptor->BaseAddress, - Descriptor->Length, - Descriptor->Capabilities &~ + BaseAddress, + Length, + Capabilities &~ (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEM= ORY_TESTED | EFI_MEMORY_RUNTIME) ); } return Status; } =20 - /** Initialize the generic memory test. =20 @@ -129,7 +132,11 @@ InitializeMemoryTest ( // // For those reserved memory that have not been tested, simply promo= te to system memory. // - Status =3D ConvertToTestedMemory (&MemorySpaceMap[Index]); + Status =3D ConvertToTestedMemory ( + MemorySpaceMap[Index].BaseAddress, + MemorySpaceMap[Index].Length, + MemorySpaceMap[Index].Capabilities + ); ASSERT_EFI_ERROR (Status); mTestedSystemMemory +=3D MemorySpaceMap[Index].Length; mTotalSystemMemory +=3D MemorySpaceMap[Index].Length; @@ -236,7 +243,11 @@ GenCompatibleRangeTest ( =20 Status =3D gDS->GetMemorySpaceDescriptor (StartAddress, &Descriptor); if (!EFI_ERROR (Status)) { - Status =3D ConvertToTestedMemory (&Descriptor); + Status =3D ConvertToTestedMemory ( + Descriptor.BaseAddress, + Descriptor.Length, + Descriptor.Capabilities + ); } return Status; } --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 05:25:52 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 152030758601971.4464991337976; Mon, 5 Mar 2018 19:39:46 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B7E8E2257C2CB; Mon, 5 Mar 2018 19:33:28 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 631E1223CDC1F for ; Mon, 5 Mar 2018 19:33:25 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2018 19:39:38 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.44]) by fmsmga006.fm.intel.com with ESMTP; 05 Mar 2018 19:39:38 -0800 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=134.134.136.65; helo=mga03.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.47,430,1515484800"; d="scan'208";a="209154733" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Tue, 6 Mar 2018 11:39:33 +0800 Message-Id: <20180306033933.278752-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180306033933.278752-1-ruiyu.ni@intel.com> References: <20180306033933.278752-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 2/2] MdeModulePkg/NullMemoryTest: Fix bug in CompatibleRangeTest 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: , Cc: Michael D Kinney , Liming Gao 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" CompatibleRangeTest() contains two bugs: 1. It doesn't reject the memory above 16MB 2. it cannot handle the case when the partial or whole range of requested memory is already tested. The patch fixes the two bugs. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Michael D Kinney Cc: Liming Gao Reviewed-by: Liming Gao Reviewed-by: Michael D Kinney --- .../MemoryTest/NullMemoryTestDxe/NullMemoryTest.c | 55 ++++++++++++++++++= ---- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemory= Test.c b/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest= .c index c66f3fd208..a9bd101501 100644 --- a/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c +++ b/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c @@ -240,14 +240,51 @@ GenCompatibleRangeTest ( { EFI_STATUS Status; EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor; - - Status =3D gDS->GetMemorySpaceDescriptor (StartAddress, &Descriptor); - if (!EFI_ERROR (Status)) { - Status =3D ConvertToTestedMemory ( - Descriptor.BaseAddress, - Descriptor.Length, - Descriptor.Capabilities - ); + EFI_PHYSICAL_ADDRESS CurrentBase; + UINT64 CurrentLength; + + // + // Check if the parameter is below 16MB + // + if (StartAddress + Length > SIZE_16MB) { + return EFI_INVALID_PARAMETER; } - return Status; + CurrentBase =3D StartAddress; + do { + // + // Check the required memory range status; if the required memory rang= e span + // the different GCD memory descriptor, it may be cause different acti= on. + // + Status =3D gDS->GetMemorySpaceDescriptor ( + CurrentBase, + &Descriptor + ); + if (EFI_ERROR (Status)) { + return Status; + } + + if (Descriptor.GcdMemoryType =3D=3D EfiGcdMemoryTypeReserved && + (Descriptor.Capabilities & (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIA= LIZED | EFI_MEMORY_TESTED)) =3D=3D + (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED) + ) { + CurrentLength =3D Descriptor.BaseAddress + Descriptor.Length - Curre= ntBase; + if (CurrentBase + CurrentLength > StartAddress + Length) { + CurrentLength =3D StartAddress + Length - CurrentBase; + } + Status =3D ConvertToTestedMemory ( + CurrentBase, + CurrentLength, + Descriptor.Capabilities + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + CurrentBase =3D Descriptor.BaseAddress + Descriptor.Length; + } while (CurrentBase < StartAddress + Length); + // + // Here means the required range already be tested, so just return succe= ss. + // + return EFI_SUCCESS; } + --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel