From nobody Mon Sep 16 19:53:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+108571+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+108571+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1694579256; cv=none; d=zohomail.com; s=zohoarc; b=KLzy67At57bELAkcEqrVs1BjZAO1HFvO6qRGd2EMTQsAIiCNrRc+KAKSndoDw//f5f1fQgJauoSWhtkaQLKnhlEmXL7GWGi9LarZn1YxKDyOtt88WBHvaNvPKTD4lU+wNmgEQr/QQXlhvWy+DFaD5+cN2xqeGHQLbTElv13WREE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694579256; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=oxvbL/YlL8XzmpKSOB8RtSR7Mp5kEPB4H2HDTeE3V+s=; b=K1k7KXZoash0wZKHt0zGNCCKjhB1wPHD/7VqvsZJYKNPVkroK9B1omSZfwQtZvvc2ndISSTgaw3LmdssDXhw3Q9DvQ7K8zNbEv68a5cDECuQ/TpCgNKGMoJ23HdPijNahLnQbHWhMBnN0y9MbPbtpWmtCXMG9tJONatxt8+FEPs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+108571+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1694579256747731.5817274506109; Tue, 12 Sep 2023 21:27:36 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=lhzuzd3SAqGLp/ikiHrqfbcnd4pXs/QzYXa6hDkOEGE=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1694579256; v=1; b=wrUk4tfyR0zb2FJ+cebkC9+Vkm+ko8E/3iTOSptYIULiUqzNaFOOkuFbiuC84kJHU8S5pP/Z eocZd+NcWUPWkjIEbR0PrL6JJgVYWVDNFkdMqa8jVljIE4Ap65RtAM4y527gTqmX98BO2uM7ZLI Jbqq9wGdSKeZvdOXlDpIF/eI= X-Received: by 127.0.0.2 with SMTP id eKrbYY1788612x8nmJGYmOZQ; Tue, 12 Sep 2023 21:27:36 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.4645.1694579216558329653 for ; Tue, 12 Sep 2023 21:27:35 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="363595508" X-IronPort-AV: E=Sophos;i="6.02,142,1688454000"; d="scan'208";a="363595508" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 21:27:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="859093688" X-IronPort-AV: E=Sophos;i="6.02,142,1688454000"; d="scan'208";a="859093688" X-Received: from shwdeopenlab705.ccr.corp.intel.com ([10.239.55.100]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 21:27:33 -0700 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: Ray Ni , Yuanhao Xie , Eric Dong , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [PATCH 15/16] UefiCpuPkg/MtrrUnitTest: Add Unit test of setting/getting memory attributes Date: Wed, 13 Sep 2023 12:26:38 +0800 Message-Id: <20230913042639.2066-16-yuanhao.xie@intel.com> In-Reply-To: <20230913042639.2066-1-yuanhao.xie@intel.com> References: <20230913042639.2066-1-yuanhao.xie@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,yuanhao.xie@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: vujCaRXfKSQCgNbkpdwZzbtbx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1694579258615100019 Content-Type: text/plain; charset="utf-8" Add Unit test of trrGetMemoryAttributesInMtrrSettings and MtrrSetMemoryAttributesInMtrrSettings. Signed-off-by: Ray Ni Signed-off-by: Yuanhao Xie Cc: Eric Dong Cc: Rahul Kumar Cc: Gerd Hoffmann --- UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c | 36 +++++++++++++++= +++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c b/UefiCp= uPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c index dc348ef0a3..b252eacf34 100644 --- a/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c +++ b/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c @@ -177,7 +177,8 @@ GenerateRandomMemoryTypeCombination ( } =20 /** - Unit test of MtrrLib service MtrrSetMemoryAttribute() + Unit test of MtrrLib service MtrrGetMemoryAttributesInMtrrSettings() and + MtrrSetMemoryAttributesInMtrrSettings() =20 @param[in] Context Ignored =20 @@ -188,7 +189,7 @@ GenerateRandomMemoryTypeCombination ( **/ UNIT_TEST_STATUS EFIAPI -UnitTestMtrrSetMemoryAttributesInMtrrSettings ( +UnitTestMtrrSetAndGetMemoryAttributesInMtrrSettings ( IN UNIT_TEST_CONTEXT Context ) { @@ -214,6 +215,9 @@ UnitTestMtrrSetMemoryAttributesInMtrrSettings ( UINT32 ActualVariableMtrrUsage; UINTN ActualMemoryRangesCount; =20 + MTRR_MEMORY_RANGE ReturnedMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR * si= zeof (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1]; + UINTN ReturnedMemoryRangesCount; + MTRR_SETTINGS *Mtrrs[2]; =20 SystemParameter =3D (MTRR_LIB_SYSTEM_PARAMETER *)Context; @@ -292,12 +296,22 @@ UnitTestMtrrSetMemoryAttributesInMtrrSettings ( &ActualMemoryRangesCount, &ActualVariableMtrrUsage ); - UT_LOG_INFO ("--- Actual Memory Ranges [%d] ---\n", ActualMemoryRanges= Count); DumpMemoryRanges (ActualMemoryRanges, ActualMemoryRangesCount); VerifyMemoryRanges (ExpectedMemoryRanges, ExpectedMemoryRangesCount, A= ctualMemoryRanges, ActualMemoryRangesCount); UT_ASSERT_TRUE (ExpectedVariableMtrrUsage >=3D ActualVariableMtrrUsage= ); =20 + ReturnedMemoryRangesCount =3D ARRAY_SIZE (ReturnedMemoryRanges); + Status =3D MtrrGetMemoryAttributesInMtrrSettings ( + Mtrrs[MtrrIndex], + ReturnedMemoryRanges, + &ReturnedMemoryRangesCount + ); + UT_ASSERT_STATUS_EQUAL (Status, RETURN_SUCCESS); + UT_LOG_INFO ("--- Returned Memory Ranges [%d] ---\n", ReturnedMemoryRa= ngesCount); + DumpMemoryRanges (ReturnedMemoryRanges, ReturnedMemoryRangesCount); + VerifyMemoryRanges (ExpectedMemoryRanges, ExpectedMemoryRangesCount, R= eturnedMemoryRanges, ReturnedMemoryRangesCount); + ZeroMem (&LocalMtrrs, sizeof (LocalMtrrs)); } =20 @@ -1041,6 +1055,9 @@ UnitTestMtrrSetMemoryAttributeInMtrrSettings ( UINT32 ActualVariableMtrrUsage; UINTN ActualMemoryRangesCount; =20 + MTRR_MEMORY_RANGE ReturnedMemoryRanges[MTRR_NUMBER_OF_FIXED_MTRR * size= of (UINT64) + 2 * MTRR_NUMBER_OF_VARIABLE_MTRR + 1]; + UINTN ReturnedMemoryRangesCount; + MTRR_SETTINGS *Mtrrs[2]; =20 SystemParameter =3D (MTRR_LIB_SYSTEM_PARAMETER *)Context; @@ -1117,6 +1134,17 @@ UnitTestMtrrSetMemoryAttributeInMtrrSettings ( VerifyMemoryRanges (ExpectedMemoryRanges, ExpectedMemoryRangesCount, A= ctualMemoryRanges, ActualMemoryRangesCount); UT_ASSERT_TRUE (ExpectedVariableMtrrUsage >=3D ActualVariableMtrrUsage= ); =20 + ReturnedMemoryRangesCount =3D ARRAY_SIZE (ReturnedMemoryRanges); + Status =3D MtrrGetMemoryAttributesInMtrrSettings ( + &LocalMtrrs, + ReturnedMemoryRanges, + &ReturnedMemoryRangesCount + ); + UT_ASSERT_STATUS_EQUAL (Status, RETURN_SUCCESS); + UT_LOG_INFO ("--- Returned Memory Ranges [%d] ---\n", ReturnedMemoryRa= ngesCount); + DumpMemoryRanges (ReturnedMemoryRanges, ReturnedMemoryRangesCount); + VerifyMemoryRanges (ExpectedMemoryRanges, ExpectedMemoryRangesCount, R= eturnedMemoryRanges, ReturnedMemoryRangesCount); + ZeroMem (&LocalMtrrs, sizeof (LocalMtrrs)); } =20 @@ -1226,7 +1254,7 @@ UnitTestingEntry ( for (Index =3D 0; Index < Iteration; Index++) { AddTestCase (MtrrApiTests, "Test InvalidMemoryLayouts", "InvalidMemo= ryLayouts", UnitTestInvalidMemoryLayouts, InitializeSystem, NULL, &mSystemP= arameters[SystemIndex]); AddTestCase (MtrrApiTests, "Test MtrrSetMemoryAttributeInMtrrSetting= s", "MtrrSetMemoryAttributeInMtrrSettings", UnitTestMtrrSetMemoryAttributeI= nMtrrSettings, InitializeSystem, NULL, &mSystemParameters[SystemIndex]); - AddTestCase (MtrrApiTests, "Test MtrrSetMemoryAttributesInMtrrSettin= gs", "MtrrSetMemoryAttributesInMtrrSettings", UnitTestMtrrSetMemoryAttribut= esInMtrrSettings, InitializeSystem, NULL, &mSystemParameters[SystemIndex]); + AddTestCase (MtrrApiTests, "Test MtrrSetAndGetMemoryAttributesInMtrr= Settings", "MtrrSetAndGetMemoryAttributesInMtrrSettings", UnitTestMtrrSetAn= dGetMemoryAttributesInMtrrSettings, InitializeSystem, NULL, &mSystemParamet= ers[SystemIndex]); } } =20 --=20 2.36.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108571): https://edk2.groups.io/g/devel/message/108571 Mute This Topic: https://groups.io/mt/101331034/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-