From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web08.4007.1666946888579783672 for ; Fri, 28 Oct 2022 01:48:08 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=ahEZw2Wn; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666946888; x=1698482888; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Gps0nwEeWaoKSwnmkBfBul3Uq1CPdF6vW5AgQHTu31M=; b=ahEZw2WnmTujVrqTlXFo2zfbLjGwhdcg4rM5lnbXX2ENOBZyRbDp67O7 BV65izw5KXj4havcvfkp3o3ID59hPq9Hp3X/wsLeSjVRZtoMMcIiujjOs 5VLXSsbuEgaQbw3+dJsVLhjqux65X3NeCXM/d9ARACHiChSi/zFWUpXez w8A7mgOqLstb1kC31BeSNwmHc5GHjMmyKbtpdq1HkwHMsP/+lS6IYoQM5 /M7qcBEksY1iXwZxzZLpwEcc+mUqHm9TI1YpdBX18KRydeTs/u+LQPYZx sA9PinYaV573unaNAiYN9ygNhwJiJCeNGzbh7TWQIHw9BfpZZWZUzu77q A==; X-IronPort-AV: E=McAfee;i="6500,9779,10513"; a="308436288" X-IronPort-AV: E=Sophos;i="5.95,220,1661842800"; d="scan'208";a="308436288" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2022 01:47:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10513"; a="635227498" X-IronPort-AV: E=Sophos;i="5.95,220,1661842800"; d="scan'208";a="635227498" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga007.fm.intel.com with ESMTP; 28 Oct 2022 01:47:57 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 28 Oct 2022 01:47:56 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Fri, 28 Oct 2022 01:47:56 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.170) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Fri, 28 Oct 2022 01:47:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HrER/rhhSJX0whAcNPSuSN7QBiNn9dZaADBdxrQE2ecH9vg+quVAg9ihXis/jh++4cRY7U6L2RcFNdbjedq4Wonn5M5Ge7YpG8DtIRaK53nLy/JjFjrMWuHTjPe+MvaBTlaPHX460jFIhFYFM6YU6+pyalP3vT1zToa+xlU/d+3cHU4iWex+PdryaqX4T9wy/N0nadpPN83eePXHLkgcQwE+vDiqP5gZGGdEqqOJP568FiUkUv19rbn5M5eeqyifioXcPWqs93A+RDL5uas/h/MkdsSj293Eg5OIcAKo7QCb/o+tjx+EnDjkRLJr3rlji1hioaJ6nObbC+yJH8c0+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FfdSMe1SRCXf/3BRPRBsMU01QDmQ34cBtnI9lZ6Csmo=; b=eCreRKanXan9gPanfBh9HAqP2rno86fPkkTHYWkDzL1OyKKJv2Roe7LUtv44wf4WeKCdKDV8L7EuIn64v4ZVadNcNf9m4JkFgjJHJeuX6sfBUaOEPP5Q9fogzLNTIkYqczNy9CEbex6ucg1+fPG3+Oo7Osg4yKFUITyU9MqPKR2Z4Q6Pp1OIsuBRKOt2By9CIbTDaGPIO/YXMyCLKbUJRFRYcMkh4Aiuq5GFCz5dAHY46c6HIYe515SsgWTQp06HiSLTfz6wN5aV3G2lBtg998SSBNuxUy3wfmwmCHAj2QiPiO6UimdCB8I24MKHgOm1SdJ1M27D97K3Ja0ERdOoIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MWHPR11MB1631.namprd11.prod.outlook.com (2603:10b6:301:10::10) by PH7PR11MB7148.namprd11.prod.outlook.com (2603:10b6:510:1ef::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28; Fri, 28 Oct 2022 08:47:50 +0000 Received: from MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::965:d00f:9151:e676]) by MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::965:d00f:9151:e676%10]) with mapi id 15.20.5769.015; Fri, 28 Oct 2022 08:47:50 +0000 From: "Ni, Ray" To: "Tan, Dun" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" , "Kinney, Michael D" Subject: Re: [Patch V2] UefiCpuPkg: Restore HpetTimer after CpuExceptionHandlerLib test Thread-Topic: [Patch V2] UefiCpuPkg: Restore HpetTimer after CpuExceptionHandlerLib test Thread-Index: AQHY6oCaOnM3F6+utkeJlk476klPqq4jfrTQ Date: Fri, 28 Oct 2022 08:47:49 +0000 Message-ID: References: <20221028035118.1828-1-dun.tan@intel.com> In-Reply-To: <20221028035118.1828-1-dun.tan@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MWHPR11MB1631:EE_|PH7PR11MB7148:EE_ x-ms-office365-filtering-correlation-id: c8f23c57-4ef3-40c9-3d7d-08dab8c1182f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: b7NOB6APE6eWCLsVKCvpz864LZ2HmP3vCWCpkzdSd7XSTeaNsgHlCOh2BLvLYO+SVWtek6AAiLl4rxmUrLRk43KHTssrkDPI0l2g3lfx0ok52+ZQBfopKuUswL9iS0pAA4b0SMABtEtu3FcCiWenSZcgKsiW3S4dMOEvJW74/uSEs2AKmVCZ8mJBWixldb/GwEpMu4phxdkvoyqIv4sxt/tJ43IqdkBXdCWBCRsUB7e5Rqkh3I7vEx9GZMgwPIsvkrMYrY/kSa/u8BCq48tWRqbj2KK/0DDDC0tUwvvO5Yj7Urqq9S6S0f6pYPSAVbI8+hgtHhet0g0EXCSV+UIpuRFfPb0EEvzrD+mDUfAdd3BPO03mIVnnOjSSkbFPTr7io0sKIBz7FsY8pwLLDHUr+brw/h5DXyKhnAaas7OH/2Hw5phXmEbbQjoowQXofGaS8WsCdtApNG4keIDyv/zbi2jJzOIE8PSvX3P9hHso1FEeGMZHZ6Np0W9SL2SOZxOxiCme6G+ScAV2EpS5Ynb+ZCFPMbvN8qwUZ8Uob49JFqTXaxTb6PlBKmnkmurhKit6jCyykq1nreum5+oCOm1Jc964Nnh4QNHd61HOQxf5upKHUK6cMy1UIkrNMArfRDipEtLCjuhJ+dH0FGDOy9M/VwywpJVtSrVCOk0YiPJLPlZJHZVlDfYOAZ47yz1Sd9zWqyp6rL/jZUs7YUG7oloCVmXB+MRgVbpwT8VKSVCMb+9SOJrBfoSbohnuW5O0/rggoVTskUfLAPcOZi1DVrstLQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR11MB1631.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199015)(122000001)(41300700001)(186003)(38100700002)(9686003)(4326008)(64756008)(66946007)(66446008)(26005)(38070700005)(76116006)(8676002)(82960400001)(2906002)(316002)(66476007)(66556008)(5660300002)(55016003)(86362001)(110136005)(54906003)(52536014)(8936002)(478600001)(33656002)(83380400001)(71200400001)(107886003)(7696005)(6506007)(53546011);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?zzqaG50pGbQ6P2ATwXgwoLKMzj29lTdFfqMt/W3RVTzSpb9zS805VrEirk8z?= =?us-ascii?Q?h+DU985AsAz8lZn9YAcKkijrAqKOidrb2lcICO02tQGSYl8SIy79tU3ouHI/?= =?us-ascii?Q?lAKC7Uac4MxUGlH0OPxqLK3uCGSylX98j5P5ej16/6a8so4h+ELdixgZspk1?= =?us-ascii?Q?AJPra0kWaj3fZaRwkqljTOrDkjLv2yw1lE9bVMqJ5nNoGWxozrA1qWOaWuCl?= =?us-ascii?Q?pfFe88a/ckyi9ps7X+zxCmG3AVyKn9yQtlUuVg3P0KklHA7+8ONC4TtQPdty?= =?us-ascii?Q?WdHjnZKWdmkUsPKZ8EOwluzipe3mZEiiLaSv3sPYWISCioQg7qCUUixEA0i3?= =?us-ascii?Q?umXFAaT9EK7x5WtpbJm36VTPWD6EozqKHtEHCnT1JwsvouGSDA/AKUy422jy?= =?us-ascii?Q?RCGhrDXLrkPf+05l+JDPqdhQV+7v7alWO4L7sDN5qJSMmpV6kpnYS7dp2pI7?= =?us-ascii?Q?uTISSHW+Em+CreHr37XP4uG+YQK5lOybzo56SA/KGpJliIR9+3jZa8CKCj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lnWQjFeFHilwp1VS33sTQU?= =?us-ascii?Q?kgTqkwft+PkZLBO/CNoUy+QQrpKaY0MXQ6m/nBI4W6oa/CwK7huHyCEb1Hdn?= =?us-ascii?Q?OfgvoFY0aeHLj5jLLwcEfdr3yzESlWWrJ4DQqg8mxFLEe9LfyeLbA68m0DQy?= =?us-ascii?Q?QLRQtI5v4tAJSehVUGY=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1631.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8f23c57-4ef3-40c9-3d7d-08dab8c1182f X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Oct 2022 08:47:49.9669 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: zevZduQgPd7AggPT7SU4fpVQBP5GqV+u1DGDcUJiKaw53l3t09s+c7LBw5H7eLmSFsBC+UMiLW3SQzloB1jKHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB7148 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: Tan, Dun > Sent: Friday, October 28, 2022 11:51 AM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Ni, Ray ; Kumar, > Rahul R ; Kinney, Michael D > > Subject: [Patch V2] UefiCpuPkg: Restore HpetTimer after > CpuExceptionHandlerLib test >=20 > Disable/Restore HpetTimer before and after running the Dxe > CpuExceptionHandlerLib unit test module. During the UnitTest, a > new Idt is initialized for the test. There is no handler for timer > intrrupt in this new idt. After the test module, HpetTimer does > not work any more since the comparator value register and main > counter value register for timer does not match. To fix this issue, > disable/restore HpetTimer before and after Unit Test if HpetTimer > driver has been dispatched. We don't need to send Apic Eoi in this > unit test module.When disabling timer, after RaiseTPL(), if there > is a pending timer interrupt, bit64 of Interrupt Request Register > (IRR) will be set to 1 to indicate there is a pending timer > interrupt. After RestoreTPL(), CPU will handle the pending > interrupt in IRR.Then TimerInterruptHandler calls SendApicEoi(). >=20 > Signed-off-by: Dun Tan > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > Cc: Michael D Kinney > --- >=20 > UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHan > dlerLibUnitTest.inf | 1 + >=20 > UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHan > dlerUnitTest.c | 30 +++++++++++++++++++++++++++++- > 2 files changed, 30 insertions(+), 1 deletion(-) >=20 > diff --git > a/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerLibUnitTest.inf > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerLibUnitTest.inf > index e3dbe7b9ab..a904eb2504 100644 > --- > a/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerLibUnitTest.inf > +++ > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerLibUnitTest.inf > @@ -53,6 +53,7 @@ >=20 > [Protocols] > gEfiMpServiceProtocolGuid > + gEfiTimerArchProtocolGuid >=20 > [Depex] > gEfiMpServiceProtocolGuid > diff --git > a/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerUnitTest.c > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerUnitTest.c > index 917fc549bf..1cec3ed809 100644 > --- > a/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerUnitTest.c > +++ > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerUnitTest.c > @@ -8,6 +8,7 @@ >=20 > #include "CpuExceptionHandlerTest.h" > #include > +#include >=20 > /** > Initialize Bsp Idt with a new Idt table and return the IA32_DESCRIPTOR > buffer. > @@ -162,8 +163,12 @@ CpuExceptionHandlerTestEntry ( > { > EFI_STATUS Status; > UNIT_TEST_FRAMEWORK_HANDLE Framework; > + EFI_TIMER_ARCH_PROTOCOL *TimerArchProtocol; > + UINT64 TimerPeriod; >=20 > - Framework =3D NULL; > + Framework =3D NULL; > + TimerArchProtocol =3D NULL; > + TimerPeriod =3D 0; >=20 > DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, > UNIT_TEST_APP_VERSION)); >=20 > @@ -182,11 +187,34 @@ CpuExceptionHandlerTestEntry ( > goto EXIT; > } >=20 > + // > + // If HpetTimer driver has been dispatched, disable HpetTimer before U= nit > Test. > + // > + gBS->LocateProtocol (&gEfiTimerArchProtocolGuid, NULL, (VOID > **)&TimerArchProtocol); > + if (TimerArchProtocol !=3D NULL) { > + Status =3D TimerArchProtocol->GetTimerPeriod (TimerArchProtocol, > &TimerPeriod); > + ASSERT_EFI_ERROR (Status); > + if (TimerPeriod > 0) { > + DEBUG ((DEBUG_INFO, "HpetTimer has been dispatched. Disable > HpetTimer.\n")); > + Status =3D TimerArchProtocol->SetTimerPeriod (TimerArchProtocol, 0= ); > + ASSERT_EFI_ERROR (Status); > + } > + } > + > // > // Execute the tests. > // > Status =3D RunAllTestSuites (Framework); >=20 > + // > + // Restore HpetTimer after Unit Test. > + // > + if ((TimerArchProtocol !=3D NULL) && (TimerPeriod > 0)) { > + DEBUG ((DEBUG_INFO, "Restore HpetTimer after > DxeCpuExceptionHandlerLib UnitTest.\n")); > + Status =3D TimerArchProtocol->SetTimerPeriod (TimerArchProtocol, > TimerPeriod); > + ASSERT_EFI_ERROR (Status); > + } > + > EXIT: > if (Framework) { > FreeUnitTestFramework (Framework); > -- > 2.31.1.windows.1