From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.1996.1666836505232402999 for ; Wed, 26 Oct 2022 19:08:25 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=YrhgiS6X; spf=pass (domain: intel.com, ip: 192.55.52.120, 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=1666836505; x=1698372505; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=l5fpxSeuovA421gBjRNeCmh0gRrfcPQnQg4V3lRVMmo=; b=YrhgiS6Xpui8dAbTYOXtxw0k4bZjPg9EjvRi4E+3PChW0Y019aPsw+2B R6Txt+It4/nQeUoqxtLkVDfGNwkAxt+pJS5cQA1PQCl+KVbIXfOs0z7jj vS559MPBNi20oVjgPGAQSFRspMUSJ8yK6V7ne1aekir920GreBepmzfVi o5i7jOKidSsLr3261DmKR0BG1f4/NqLeIPwvs+YIe6pgIvDLcg4gM8b1g +vtqDmliEVYYsFDyRC55mX6+CTBzWtlDtBPJbbPdO3gp1MHwCV44etoWX F27bRMnGxgKCI7VbRuv4A9h6I74LdBiiyP5i0mq6g0CVIO0dMBdogQn+g w==; X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="306838585" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="306838585" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 19:08:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="583377781" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="583377781" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga003.jf.intel.com with ESMTP; 26 Oct 2022 19:08:10 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 26 Oct 2022 19:08:09 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Wed, 26 Oct 2022 19:08:09 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.48) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Wed, 26 Oct 2022 19:08:09 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Be3xsQ0jo+S+6H0xypVGG3g6sBeQgQD5CUM7UBSAIPA9nsxmMCuhukr1itMHMdLLaukzzAYmdYcJ/GINFOGEfxNN37XV4XltOMyS2Cnv4qOX8SbzuH98+VWBlvoeNxFz3GOSUqzK3oB6HzbqVkaDAiHd3EeSfT23TUEg9O79PCuBW2kztMKP9T5cTo5bVoN1dnrUENpBGNZ3SqtdH1NLqmGzmarDX4kKOcIXGCW57tb891JVPVOPQCHwhv37Dp1YSK7BFAoOKV/xY7cj5bLu2S595UFOz7HbnBNIEVa46PswEAScOCYXpeRnftOkFE8TGr8m4GgZhMWElGVUuCCc3w== 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=d1yeOXs2XJD0+UVu1x+w44+FR2kdAt7qrrgiZAZH/Mg=; b=YkT9yUetOsuH/CLRVzJzgfOH593JAvC8Cz02YvSusPZaN07NAPBBiOAd5PD/uv9pgwr/QkbIHeMqQjLixYsk60nVTCO+n+xMsFxI4+xH2WEkcnaHiAL/6IaPGGP1p3DoJhJhUlGMP5Zsyfh+QwDK7zMR5I0hrDAZZkupQyNTV8D4cX6axXan8wTRynv5JxRtVZrrXMX5j/8BjynUkl66CrP6VCjYnEvp0AqKow8KjzzJjJXpyEC/SIUdqoDLXSLLnAFxlziThLO/GPiZBBKit3L7c6MzGd2/LwQAOxLdsXFPVucC9nW7fSiMTYY9qzrnA0smf6lJcwS873FoE6e4Sg== 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 CY8PR11MB7337.namprd11.prod.outlook.com (2603:10b6:930:9d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34; Thu, 27 Oct 2022 02:08:07 +0000 Received: from MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::965:d00f:9151:e676]) by MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::965:d00f:9151:e676%9]) with mapi id 15.20.5746.028; Thu, 27 Oct 2022 02:08:07 +0000 From: "Ni, Ray" To: "Tan, Dun" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" Subject: Re: [PATCH] UefiCpuPkg: Restore HpetTimer after CpuExceptionHandlerLib test Thread-Topic: [PATCH] UefiCpuPkg: Restore HpetTimer after CpuExceptionHandlerLib test Thread-Index: AQHY5DBK+uP1U36chU+8OSjX4+mJbq4hiYUg Date: Thu, 27 Oct 2022 02:08:07 +0000 Message-ID: References: <20221020030055.815-1-dun.tan@intel.com> In-Reply-To: <20221020030055.815-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_|CY8PR11MB7337:EE_ x-ms-office365-filtering-correlation-id: 5586d148-b882-4d3e-9696-08dab7c0170b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: OdtcCCD5lUcI+9xYjbSQ5p9prtusJs5nSz5vbLsuyThi4cl3ViF3EpVH/hXMTMB5hHboBL25rW6ceHCJ2Uwfo7Ej03RR5q90zXsq8tYhl35OyIEwOLkEAaaElCLTV07ckeqnEN0eZHSO/hmkIjfcVB6m5uqLHWUfYp+0YVGTsq2Sk8rqjXn0U7Qo5Mh55TrPE59i1kEkypcrs1oMWGgEpCnyPThQezmbIwy0iuE9GrIMFkZYleLtV9Z4YjOKX4tDp6gXkpEvqcCeVtQl6Q5LoXgdXIdEm/eBNoWJ1DgVkch6rdt/AL4cZYrof4t8MZhk4ZHSaSqYxy0P/Uk6Qi2mIzoBPKgap5HBwPITTULLRPmUy8nIO5dVH8Hvr92C4rHJLR9N2KmzbOI52XsqI3ErFLMGQlMjTfhRS+goRgDkZeq0J9hPoZMqEQyNrfnL3njXQthfmAcwlflwjOZdlavikQQpQA+XOiPcLi4/9MNL7fkWy/j1XAjHvqYKie+nmJm0J9tHAqK4PhMxWEPxDEAs/1BYPwRf9Zk3qVn+8NOOgun81vInr1pMf8LoRhdMfunfRkHlIg8eUSylDtr8nCFfgChGV8TxtobYZTW0tdodGvb18NvaeuIzQOc5dbXM8VMC9vcgPYKFG1GznJSF8syG9Z3j3fPWX0wDeRnQXuiD5I2eAdjuFWYeIZziOZc77ns2lQmnFbAKG8axmI856pXvJs3n269IP7EHujOQc3kBsaSbmKMFoVYmR7hYwQfsauQV+dH9U5MvIJIwQD5zlwGTkg== 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)(136003)(396003)(39860400002)(376002)(366004)(346002)(451199015)(26005)(478600001)(76116006)(83380400001)(2906002)(71200400001)(54906003)(6506007)(52536014)(86362001)(316002)(66556008)(9686003)(8936002)(4326008)(66446008)(107886003)(41300700001)(53546011)(186003)(64756008)(7696005)(110136005)(82960400001)(55016003)(8676002)(33656002)(66946007)(66476007)(122000001)(38100700002)(5660300002)(38070700005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?uRPSa+aSAdSlRXr53So/+KdL4rEmxUOgyCtpPXLHc6huHKtWbGXVqPOUfoRt?= =?us-ascii?Q?tTf/0CNqoz7yLf1dcpzIm/Zuvx9tmp/TC0uF+z50X4TP48jo6L5++eblJZpU?= =?us-ascii?Q?dHEpQZlao5BveejAbihqd4tTnTCeL2ndQSYgbDPdzOAu3ey52oyEKtma5T4q?= =?us-ascii?Q?wEATD2WLolno7tu43afKSByyHjdXpuDXYwsSrZygi5ijjxa8avOHgvVoDkgP?= =?us-ascii?Q?XkiMmYbJoQxfzJUmBtneb8l23N1aljHahbSAHN+KFjD5wQdX2gFQOuz0yGQ+?= =?us-ascii?Q?+yFPbp7wLwfN1gFpQFuJXtsHCH0QEbUCg/FrgX8gX5lnkj9awD87JWSIlnfu?= =?us-ascii?Q?B9zrwLXfbZ/w5JtwtSNAyxnOWuqVMfleY0IzvGZAvYYSV5id3txmSSooRYn3?= =?us-ascii?Q?pCWqdEPp4CnmAPtVCZCjEpuxu3YQ4iVvYCbeH7EcxQaRMZk/qvUoFTmxThqL?= =?us-ascii?Q?5GhgcT+ztZWilqJVjopiNdHk6SCsD2753Qe85fKvi0ejLo6vJz/8rjbHVR8X?= =?us-ascii?Q?7uEReKxv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?= =?us-ascii?Q?yRYToZU0srgWAapfDSilL2eGg1QJuTyUGR8w16yYBBN1swxQ91xFfK8cCY9/?= =?us-ascii?Q?Lnb003W1X72KCsZCyR0LKtVewPOmx7iXJn8eXjAWZUhpsJ3WXv9V/jLBiOnn?= =?us-ascii?Q?KBN52zKeDe7Z1D0J1BE=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: 5586d148-b882-4d3e-9696-08dab7c0170b X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Oct 2022 02:08:07.3960 (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: KsxgNOxRkt+V5vwLCgITuMKOrUqqEszKPArSsXFjdar0Nt3Dq87A+5W9VpEJbfEJ91ORKMNEeZJkKuZjFsP07Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR11MB7337 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: Thursday, October 20, 2022 11:01 AM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Ni, Ray ; Kumar, > Rahul R > Subject: [PATCH] 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. Besides, send Apic EOI before restore > HpetTimer. >=20 > Signed-off-by: Dun Tan > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > --- >=20 > UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHan > dlerLibUnitTest.inf | 2 ++ >=20 > UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHan > dlerUnitTest.c | 33 ++++++++++++++++++++++++++++++++- > 2 files changed, 34 insertions(+), 1 deletion(-) >=20 > diff --git > a/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerLibUnitTest.inf > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerLibUnitTest.inf > index e3dbe7b9ab..24f905936c 100644 > --- > a/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerLibUnitTest.inf > +++ > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerLibUnitTest.inf > @@ -43,6 +43,7 @@ > HobLib > UefiBootServicesTableLib > CpuPageTableLib > + LocalApicLib >=20 > [Guids] > gEfiHobMemoryAllocStackGuid > @@ -53,6 +54,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..045f39fa00 100644 > --- > a/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerUnitTest.c > +++ > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionH > andlerUnitTest.c > @@ -8,6 +8,8 @@ >=20 > #include "CpuExceptionHandlerTest.h" > #include > +#include > +#include >=20 > /** > Initialize Bsp Idt with a new Idt table and return the IA32_DESCRIPTOR > buffer. > @@ -162,8 +164,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 +188,36 @@ 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. > + // Send APIC EOI before SetTimerPeriod. > + // > + if ((TimerArchProtocol !=3D NULL) && (TimerPeriod > 0)) { > + DEBUG ((DEBUG_INFO, "Restore HpetTimer after > DxeCpuExceptionHandlerLib UnitTest.\n")); > + SendApicEoi (); > + Status =3D TimerArchProtocol->SetTimerPeriod (TimerArchProtocol, > TimerPeriod); > + ASSERT_EFI_ERROR (Status); > + } > + > EXIT: > if (Framework) { > FreeUnitTestFramework (Framework); > -- > 2.31.1.windows.1