From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web09.29521.1654501665249499650 for ; Mon, 06 Jun 2022 00:47:47 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=T6rJkguR; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: eric.dong@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654501665; x=1686037665; h=from:to:subject:date:message-id:references:in-reply-to: mime-version; bh=A5ujUcdoPo/RryB2uaKzcxt5pgO7lkq1LBHsor2SRDk=; b=T6rJkguRLx/RLeLGz0AcwAll9IhiReyYKsHvs98TA09Tn4NX5Zd4JiOW fHX6Dtaw5A01jYZXahPdEeKktoe9uHe8iewpiiJDb2AV3OsTx7O9tPSV5 K7SZwYDlD7kMMmtxa+jkrfdI0IG1LYAnY85NzDHgCA89tNdmDOJWj308l JGci3SKvPLEYAPBUBeBrf3zPKcODU9uPlwO7iW8angyIp8yrYf9yLhatQ ZQ3BGI3Br2cQkexKf0WzI09z6IaGJ+9J/JC1soLzRKLjkP70AgGn+f4TC r1pokVON+WeP93LS22x/6l1AF26gCsebjGY6Juvsli5d7f7BCz9e0o2ul g==; X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="339836719" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208,217";a="339836719" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 00:47:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208,217";a="722691059" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga001.fm.intel.com with ESMTP; 06 Jun 2022 00:47:24 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 6 Jun 2022 00:47:24 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Mon, 6 Jun 2022 00:47:24 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.172) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Mon, 6 Jun 2022 00:47:24 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PArmDIByabhiYjMGBRgbWgd83fr1lf31MQgUsfy5jMuGyHUdfZ8XESUm8ycOzHiHvX4QRtRuSZvVC7OOy/NS5IevxaELFYoIrmMFsXlFWX3gHgWvMYx2ZGq98wPuuEE9fRPzepcOJPcVLSHLnn+Q1DtlPhHkXyJCKKOIiH2Td1XcvQaKbWJhET4WJE0haEMe8KIKMnoWvWhHtq/MRl+kCBekoGKunpOk5AIR8yhbYnCYF6/hBsvzIYYsRuHe2nOVImgRUWr3ulJYCnAgantg6IjrFzXO2iL4MtiBuj08aYfKRx/INjQfYC1wNX9IaWiZConxiy5meVrfUdXY44YIQQ== 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=y0xA5jt1KOWa5ojJbkpjkqnB5XHcu+/WBmTIjZgeeXo=; b=XqQrGQJSsm+Wk8XpnGndG8AafSKPa2PCzonW9WaiPw1EkvWi+v90qVeB8DypoAG8Iv83hbSuGoETvjwrRXDqVjOxyHwbKodUiTvc0eQA+qla1pYQ6V5lqSBrWI6lhfyun2E9iURi9tKP1U+9PMlOUHfXwNWR3X1pRAbOo3Rvr6ZFoinZdoxUvy8YWIfd+Fl5E4Z4zzOP63uF5r1Lj+HIbqvbfVzHCajjw9W8C5WgdPfsCXTlFoShMndxp8nMnP5pH1d/m3qRojBoleG8sv7frtnjSYezH7ZQ/2HH1kU2FUH0/wTbmWbQy3APyHbyZAyvcvPj7ByDmL58nTKMOBPYOA== 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 DM4PR11MB6480.namprd11.prod.outlook.com (2603:10b6:8:8d::17) by MWHPR1101MB2320.namprd11.prod.outlook.com (2603:10b6:301:53::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.15; Mon, 6 Jun 2022 07:47:20 +0000 Received: from DM4PR11MB6480.namprd11.prod.outlook.com ([fe80::d125:7372:7128:a152]) by DM4PR11MB6480.namprd11.prod.outlook.com ([fe80::d125:7372:7128:a152%7]) with mapi id 15.20.5314.013; Mon, 6 Jun 2022 07:47:20 +0000 From: "Dong, Eric" To: "Ni, Ray" , "Wang, Jian J" , "devel@edk2.groups.io" Subject: Re: [edk2-devel] [PATCH 4/5] CpuException: Remove InitializeCpuInterruptHandlers Thread-Topic: [edk2-devel] [PATCH 4/5] CpuException: Remove InitializeCpuInterruptHandlers Thread-Index: AQHYbFQs2huGLNGtTUGA+4VMFC5Cdq0rGPwAgAKYHgCAFGmBcA== Date: Mon, 6 Jun 2022 07:47:20 +0000 Message-ID: References: <20220520141549.108-1-ray.ni@intel.com> <20220520141549.108-5-ray.ni@intel.com> In-Reply-To: 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-office365-filtering-correlation-id: fd7dfe9b-04d0-49e2-9eb0-08da4790c980 x-ms-traffictypediagnostic: MWHPR1101MB2320:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: E1oshn3CWk0eQCPc3hXgJZgTdj18zh+XPdv+ePqEMUUMYVoG7SgOs2bVMuo+VHuVeWjfgrZKKSqhNLEG3SVYMpKSU8aM9ychwLHGuMPTBN49bCbwObCouwgESXhLaJW9aQRDUqF9sh7le6wAbLUOV/1HXqTTKYSlWfYup5scPTn9J8eMUMjnk9d3kfPKqcEIPDn7juNHd3rt84Wcvz59T1k3el78gjOefVNtJoMV1z0Bd7WYPcDjPoamqN3nN3gkkjz/dyaVeihUMx0MaIsMy5JY62WAUfQxLUAnYMixt+WSWDIBXFcZoZiMYA3Iqwb0lXyLx0SrGhJkbnKSkz1e8tfIMewCgUcAFUH2W5ptyGurp6ukHeKXB5TK7/LOg55l58H3/zJwiF/oP/y4c9LoFw5Ja+lUHp6KJSEzrkG/FwbeX/QPpt0SeKYDuKcRC5l+64UcvSmeSYF0IAhI4XecRu/i4pBEKQK2H9v45QcH7HuSD7fsavDrvLnqHSqxjgzr2ToFDTkV/62mEONa/U4gSTG78JfpTp9Tj6Xgw3zQTDFqRWQfA8mFdp4kKrB3bpWnbTYuvhWKTTKykqssKAXHDyOba8o4hkXjpOaM3dPULxFfkamGKpS3YoaFff6jiiPft/k16vSJN+NJU+qBmfP7ZOvmuksT92PxFzPqofZ1Da7DORKq+5Jpk+9uETkF3k8D9cCGtKLcssNTH4ZIqe9c7QtYs47+o0dBm/Aaga8U2c5mBjuOcI5AWqAO4t7BjTs4ZquPDSg6XDV+garXpbJS0bOOyMPnEUaWw7cH7SZLf8YyDTcS4zRGl3ZK7qcCorrQJfG0tJ4JfWYTCSNY/aBfkQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB6480.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(55016003)(82960400001)(7696005)(66446008)(38070700005)(64756008)(2906002)(76116006)(5660300002)(122000001)(30864003)(53546011)(6506007)(9686003)(26005)(66556008)(66476007)(8676002)(110136005)(38100700002)(83380400001)(166002)(186003)(66946007)(316002)(86362001)(52536014)(8936002)(508600001)(33656002)(71200400001)(966005)(559001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?NTXR3kggSaYLZ0cRazNaCyztRMhRskwYFdvssc7gNebgKLphsAB/Q6sQ/GHR?= =?us-ascii?Q?njnZ+Q6Sgtm0FOts6UG01GgjgaGRLqHDPapbxm+vDGlgX23RuhyrTPE6ko7n?= =?us-ascii?Q?TQq6EqM1YMGFuyl9TI65p+gD3ICBn6DCljc0/eSIQAlR0MZ8JyDl28Iz8ctf?= =?us-ascii?Q?UtIPbVOXipo5oFM1CklLmvDwNITHk1yOXjnRqO7iOhOnmSHkp4QKu07aLTy1?= =?us-ascii?Q?vCR5EVM+VjKeZjQJBFHPYnuszEUC4oVcsi89B7+2WNOZDKn8U72rnx38Xgwr?= =?us-ascii?Q?bRkEX9mYYsACnVj4xKau+b6seArc9V6dvUAKoOI5eeEOuU8iVojL1x1E6ZId?= =?us-ascii?Q?p6Y7DLs5iky97JdsgYKhFuTdS87FViccAWXXwXQn+keZkHJnPHKuLG3FPsU2?= =?us-ascii?Q?Faxwc0CQYDzREOiG6XuS0hO9021RcdPlnVrqtMBCfbbX2g6AVpvNMv89hzvH?= =?us-ascii?Q?OPNAp80WNHMwHSXrpvyWpZPzav2SMjAtyn2Ps/1kxhuWgxred3ZzzuII7wOJ?= =?us-ascii?Q?3eHz1U3LDmH5S6hzEeGIBw9xOzeKD1+e18BHudgWyN785ZlEMTv52Pq06gJB?= =?us-ascii?Q?ZqWjStEII0hjEmDQRyDQ5dTEB183xdK/WT48fWkDhq6u/Dn+myEaO7rBiPJC?= =?us-ascii?Q?AdjeXD4DRy8yqLYbzgBvupnEAEj5XeEwEnOpq2pJD8HhLMUUbS8iEHVb/Th+?= =?us-ascii?Q?5bRjkjN1Q/dUUspH1bTN3ilhjQFvj2+t2NbO4GQtGbjjljdSJONN+WTJGyX+?= =?us-ascii?Q?xzEKffWQs/LeuZy2lx3r0g/Kt1qiAB2b+2T3oq6dY5sjFFuNI/8y6dZTCKpR?= =?us-ascii?Q?/megteguVsDfVmbP7gU/jZ8PyDMr+Gl6m58/LvRl2JRWQDckBa7LhrEXkrFq?= =?us-ascii?Q?RZ5rS0PKZGB8zDiLXBElST/18FwF6SV2n5aKuDNoMcxzRFNjdDCdJZHz0iv3?= =?us-ascii?Q?D1GhCkaugXdmUxUiuvaOyv3VbAuSPRs+eVgjBcXm3Jpj2F308kEK9ltb9pgN?= =?us-ascii?Q?DOm8uF/DIFylE8UxhKeckfEbA3Urv2Nz8zKruX8DF+nUqi8aqTuklV46iBoc?= =?us-ascii?Q?UVZ5wWjb+tasl0WAHymDQR9+Q4t4P84yJx5Gd5z9M69wT0ho6CpkwVveuLve?= =?us-ascii?Q?OHNQTBqFi3xkb7pCXRdUy93yYAjjfAKg/phSzqgL3Jb7XXeyd+/AUYIOvHa/?= =?us-ascii?Q?9YYhydFoYuPCSq+i46zEm9ZDhD0hQ5Uds8JYNIHmLajuvBnxIA16D1LIBFzJ?= =?us-ascii?Q?ZwKRABJvPLSR4NZNYrO2B2RmMLJM7UD1hmlwmmLMTKfSdsxTXEiQWKT2GuSp?= =?us-ascii?Q?4Q+6QukiGc3HOep1Iw1j2HbqmfShJDs5mzb/Ae7ziMF+fR/+mtfv1qfNoF1b?= =?us-ascii?Q?AfcEqLvKyIkgOZnwc1xfPIdknOrNHFQwHcVUWFJ7ZKRO/Wj20/Zj+Qb9q5lZ?= =?us-ascii?Q?ZTf6QkCvFV5cEh2nb4AHFvG7wZOkB9D4EC7bYyDEwyJ6Y2lCnDxJtTzdcfyn?= =?us-ascii?Q?pZqKqa1UhhIFdqiyT/YZAJJQiYz3hUWXkKIyELQxsvLj12yMycTrcx9+b8iV?= =?us-ascii?Q?ARAuxcc3XHBKqLPunovxhrMUjpa+lDt1OaIl9/INepuTcLdviOWLuOVhbYJk?= =?us-ascii?Q?2jxckDRd8WEFgFiVAhLlGInN7uAkGRYgioc7s6RXXr9KqlDemmLBl+wm6izz?= =?us-ascii?Q?2Manpjri2J3WXBIEaP5SCxKSKtxSOMxgpVuHfaHJx+OF/DWk3xd41C4GlMOP?= =?us-ascii?Q?cvzz3HEXNw=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB6480.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd7dfe9b-04d0-49e2-9eb0-08da4790c980 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jun 2022 07:47:20.7389 (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: JvpObE9gt8Gq998Kz7I2BWsV9xZEXuq7GK2dluY6j1T/uMIStXEV8NZ7lFLCGQCMvvpEJQgIGA0/6/FL4J87OQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2320 Return-Path: eric.dong@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_DM4PR11MB64802A7F8CC323014B5E61B0FEA29DM4PR11MB6480namp_" --_000_DM4PR11MB64802A7F8CC323014B5E61B0FEA29DM4PR11MB6480namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Acked-by: Eric Dong eric.dong@intel.com From: Ni, Ray Sent: Tuesday, May 24, 2022 4:04 PM To: Wang, Jian J ; devel@edk2.groups.io Cc: Dong, Eric Subject: Re: [edk2-devel] [PATCH 4/5] CpuException: Remove InitializeCpuInt= erruptHandlers Jian, I think we need discussion on where to put the common CPU_INTERRUPT_NUM def= inition. Do you agree that we can leave that to another patch? ________________________________________ From: Wang, Jian J > Sent: Monday, May 23, 2022 0:27 To: devel@edk2.groups.io; Ni, Ray Cc: Dong, Eric Subject: RE: [edk2-devel] [PATCH 4/5] CpuException: Remove InitializeCpuInt= erruptHandlers Hi Ray, Both CpuDxe.c and CpuExceptionCommon.h have CPU_INTERRUPT_NUM defined. I'd suggest to move it to a common place, such as BaseLib.h. I don't see an= y issue if they are defined to different value. It just gives me a feeling that it = might cause potential problems sometimes in the future. Regards, Jian > -----Original Message----- > From: devel@edk2.groups.io > On Behalf Of Ni, Ray > Sent: Friday, May 20, 2022 10:16 PM > To: devel@edk2.groups.io > Cc: Dong, Eric > > Subject: [edk2-devel] [PATCH 4/5] CpuException: Remove > InitializeCpuInterruptHandlers > > InitializeCpuExceptionHandlers() expects caller allocates IDT while > InitializeCpuInterruptHandlers() allocates 256 IDT entries itself. > > InitializeCpuExceptionHandlers() fills max 32 IDT entries allocated > by caller. If caller allocates 10 entries, the API just fills 10 IDT > entries. > > The inconsistency between the two APIs makes code hard to > unerstand and hard to share. > > Because there is only one caller (CpuDxe) for > InitializeCpuInterruptHandler(), this patch updates CpuDxe driver > to allocates 256 IDT entries then call > InitializeCpuExceptionHandlers(). > > With this change, InitializeCpuInterruptHandlers() is removed > completely. > > And InitializeCpuExceptionHandlers() fills max 32 entries for PEI > and SMM instance, max 256 entries for DXE instance. > Such behavior matches to the original one. > > Signed-off-by: Ray Ni > > Cc: Eric Dong > > --- > .../Include/Library/CpuExceptionHandlerLib.h | 28 +------ > .../CpuExceptionHandlerLibNull.c | 31 +------ > UefiCpuPkg/CpuDxe/CpuDxe.c | 33 ++++++-- > .../CpuExceptionHandlerLib/DxeException.c | 80 ++----------------- > .../CpuExceptionHandlerLib/PeiCpuException.c | 61 +------------- > .../PeiDxeSmmCpuException.c | 19 ++--- > .../SecPeiCpuException.c | 31 +------ > .../CpuExceptionHandlerLib/SmmException.c | 35 ++------ > 8 files changed, 56 insertions(+), 262 deletions(-) > > diff --git a/MdeModulePkg/Include/Library/CpuExceptionHandlerLib.h > b/MdeModulePkg/Include/Library/CpuExceptionHandlerLib.h > index 22a4408f9f..d4649bebe1 100644 > --- a/MdeModulePkg/Include/Library/CpuExceptionHandlerLib.h > +++ b/MdeModulePkg/Include/Library/CpuExceptionHandlerLib.h > @@ -2,7 +2,7 @@ > CPU Exception library provides the default CPU interrupt/exception han= dler. > > It also provides capability to register user interrupt/exception handl= er. > > > > - Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
> > + Copyright (c) 2012 - 2022, Intel Corporation. All rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > @@ -132,28 +132,6 @@ InitializeCpuExceptionHandlersEx ( > IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL > > ); > > > > -/** > > - Initializes all CPU interrupt/exceptions entries and provides the defa= ult > interrupt/exception handlers. > > - > > - Caller should try to get an array of interrupt and/or exception vector= s that are > in use and need to > > - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. > > - If caller cannot get reserved vector list or it does not exists, set V= ectorInfo to > NULL. > > - If VectorInfo is not NULL, the exception vectors will be initialized p= er vector > attribute accordingly. > > - > > - @param[in] VectorInfo Pointer to reserved vector list. > > - > > - @retval EFI_SUCCESS All CPU interrupt/exception entries have= been > successfully initialized > > - with default interrupt/exception handler= s. > > - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content = if > VectorInfo is not NULL. > > - @retval EFI_UNSUPPORTED This function is not supported. > > - > > -**/ > > -EFI_STATUS > > -EFIAPI > > -InitializeCpuInterruptHandlers ( > > - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL > > - ); > > - > > /** > > Registers a function to be called from the processor interrupt handler= . > > > > @@ -161,8 +139,8 @@ InitializeCpuInterruptHandlers ( > interrupt or exception type specified by InterruptType. If InterruptHa= ndler is > NULL, then the > > handler for the processor interrupt or exception type specified by > InterruptType is uninstalled. > > The installed handler is called once for each processor interrupt or e= xception. > > - NOTE: This function should be invoked after InitializeCpuExceptionHand= lers() > or > > - InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED > returned. > > + NOTE: This function should be invoked after InitializeCpuExceptionHand= lers() > is invoked, > > + otherwise EFI_UNSUPPORTED returned. > > > > @param[in] InterruptType Defines which interrupt or exception to = hook. > > @param[in] InterruptHandler A pointer to a function of type > EFI_CPU_INTERRUPT_HANDLER that is called > > diff --git > a/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLib > Null.c > b/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLib > Null.c > index 35ab5a8db5..54f38788fe 100644 > --- > a/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLib > Null.c > +++ > b/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLib > Null.c > @@ -1,7 +1,7 @@ > /** @file > > CPU Exception Handler library implementition with empty functions. > > > > - Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
> > + Copyright (c) 2012 - 2022, Intel Corporation. All rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > @@ -33,31 +33,6 @@ InitializeCpuExceptionHandlers ( > return EFI_SUCCESS; > > } > > > > -/** > > - Initializes all CPU interrupt/exceptions entries and provides the defa= ult > interrupt/exception handlers. > > - > > - Caller should try to get an array of interrupt and/or exception vector= s that are > in use and need to > > - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. > > - If caller cannot get reserved vector list or it does not exists, set V= ectorInfo to > NULL. > > - If VectorInfo is not NULL, the exception vectors will be initialized p= er vector > attribute accordingly. > > - > > - @param[in] VectorInfo Pointer to reserved vector list. > > - > > - @retval EFI_SUCCESS All CPU interrupt/exception entries have= been > successfully initialized > > - with default interrupt/exception handler= s. > > - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content = if > VectorInfo is not NULL. > > - @retval EFI_UNSUPPORTED This function is not supported. > > - > > -**/ > > -EFI_STATUS > > -EFIAPI > > -InitializeCpuInterruptHandlers ( > > - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL > > - ) > > -{ > > - return EFI_SUCCESS; > > -} > > - > > /** > > Registers a function to be called from the processor interrupt handler= . > > > > @@ -65,8 +40,8 @@ InitializeCpuInterruptHandlers ( > interrupt or exception type specified by InterruptType. If InterruptHa= ndler is > NULL, then the > > handler for the processor interrupt or exception type specified by > InterruptType is uninstalled. > > The installed handler is called once for each processor interrupt or e= xception. > > - NOTE: This function should be invoked after InitializeCpuExceptionHand= lers() > or > > - InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED > returned. > > + NOTE: This function should be invoked after InitializeCpuExceptionHand= lers() > is invoked, > > + otherwise EFI_UNSUPPORTED returned. > > > > @param[in] InterruptType Defines which interrupt or exception to = hook. > > @param[in] InterruptHandler A pointer to a function of type > EFI_CPU_INTERRUPT_HANDLER that is called > > diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c > index 00f3cb0957..a6a91507f6 100644 > --- a/UefiCpuPkg/CpuDxe/CpuDxe.c > +++ b/UefiCpuPkg/CpuDxe/CpuDxe.c > @@ -1,7 +1,7 @@ > /** @file > > CPU DXE Module to produce CPU ARCH Protocol. > > > > - Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
> > + Copyright (c) 2008 - 2022, Intel Corporation. All rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > @@ -10,6 +10,8 @@ > #include "CpuMp.h" > > #include "CpuPageTable.h" > > > > +#define CPU_INTERRUPT_NUM 256 > > + > > // > > // Global Variables > > // > > @@ -924,9 +926,12 @@ InitInterruptDescriptorTable ( > VOID > > ) > > { > > - EFI_STATUS Status; > > - EFI_VECTOR_HANDOFF_INFO *VectorInfoList; > > - EFI_VECTOR_HANDOFF_INFO *VectorInfo; > > + EFI_STATUS Status; > > + EFI_VECTOR_HANDOFF_INFO *VectorInfoList; > > + EFI_VECTOR_HANDOFF_INFO *VectorInfo; > > + IA32_IDT_GATE_DESCRIPTOR *IdtTable; > > + IA32_DESCRIPTOR IdtDescriptor; > > + UINTN IdtEntryCount; > > > > VectorInfo =3D NULL; > > Status =3D EfiGetSystemConfigurationTable (&gEfiVectorHandoffTable= Guid, > (VOID **)&VectorInfoList); > > @@ -934,7 +939,25 @@ InitInterruptDescriptorTable ( > VectorInfo =3D VectorInfoList; > > } > > > > - Status =3D InitializeCpuInterruptHandlers (VectorInfo); > > + AsmReadIdtr (&IdtDescriptor); > > + IdtEntryCount =3D (IdtDescriptor.Limit + 1) / sizeof > (IA32_IDT_GATE_DESCRIPTOR); > > + if (IdtEntryCount < CPU_INTERRUPT_NUM) { > > + // > > + // Increase Interrupt Descriptor Table and Copy the old IDT table in > > + // > > + IdtTable =3D AllocateZeroPool (sizeof (IA32_IDT_GATE_DESCRIPTOR) * > CPU_INTERRUPT_NUM); > > + ASSERT (IdtTable !=3D NULL); > > + CopyMem (IdtTable, (VOID *)IdtDescriptor.Base, sizeof > (IA32_IDT_GATE_DESCRIPTOR) * IdtEntryCount); > > + > > + // > > + // Load Interrupt Descriptor Table > > + // > > + IdtDescriptor.Base =3D (UINTN)IdtTable; > > + IdtDescriptor.Limit =3D (UINT16)(sizeof (IA32_IDT_GATE_DESCRIPTOR) * > CPU_INTERRUPT_NUM - 1); > > + AsmWriteIdtr (&IdtDescriptor); > > + } > > + > > + Status =3D InitializeCpuExceptionHandlers (VectorInfo); > > ASSERT_EFI_ERROR (Status); > > } > > > > diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c > index f139131a7c..c7c1fe31d2 100644 > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c > @@ -1,7 +1,7 @@ > /** @file > > CPU exception handler library implemenation for DXE modules. > > > > - Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
> > + Copyright (c) 2013 - 2022, Intel Corporation. All rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > @@ -17,8 +17,8 @@ CONST UINTN mDoFarReturnFlag =3D 0; > RESERVED_VECTORS_DATA mReservedVectorsData[CPU_INTERRUPT_NUM]; > > EFI_CPU_INTERRUPT_HANDLER > mExternalInterruptHandlerTable[CPU_INTERRUPT_NUM]; > > EXCEPTION_HANDLER_DATA mExceptionHandlerData =3D { > > - 0, // To be fixed > > - 0, // To be fixed > > + CPU_INTERRUPT_NUM, > > + 0, // To be fixed > > mReservedVectorsData, > > mExternalInterruptHandlerTable > > }; > > @@ -69,76 +69,6 @@ InitializeCpuExceptionHandlers ( > return InitializeCpuExceptionHandlersWorker (VectorInfo, > &mExceptionHandlerData); > > } > > > > -/** > > - Initializes all CPU interrupt/exceptions entries and provides the defa= ult > interrupt/exception handlers. > > - > > - Caller should try to get an array of interrupt and/or exception vector= s that are > in use and need to > > - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. > > - If caller cannot get reserved vector list or it does not exists, set V= ectorInfo to > NULL. > > - If VectorInfo is not NULL, the exception vectors will be initialized p= er vector > attribute accordingly. > > - > > - @param[in] VectorInfo Pointer to reserved vector list. > > - > > - @retval EFI_SUCCESS All CPU interrupt/exception entries have= been > successfully initialized > > - with default interrupt/exception handler= s. > > - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content = if > VectorInfo is not NULL. > > - @retval EFI_UNSUPPORTED This function is not supported. > > - > > -**/ > > -EFI_STATUS > > -EFIAPI > > -InitializeCpuInterruptHandlers ( > > - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL > > - ) > > -{ > > - EFI_STATUS Status; > > - IA32_IDT_GATE_DESCRIPTOR *IdtTable; > > - IA32_DESCRIPTOR IdtDescriptor; > > - UINTN IdtEntryCount; > > - EXCEPTION_HANDLER_TEMPLATE_MAP TemplateMap; > > - > > - SetMem ((VOID *)mReservedVectorsData, sizeof (RESERVED_VECTORS_DATA) > * CPU_INTERRUPT_NUM, 0xff); > > - if (VectorInfo !=3D NULL) { > > - Status =3D ReadAndVerifyVectorInfo (VectorInfo, mReservedVectorsData= , > CPU_INTERRUPT_NUM); > > - if (EFI_ERROR (Status)) { > > - return EFI_INVALID_PARAMETER; > > - } > > - } > > - > > - // > > - // Read IDT descriptor and calculate IDT size > > - // > > - AsmReadIdtr (&IdtDescriptor); > > - IdtEntryCount =3D (IdtDescriptor.Limit + 1) / sizeof > (IA32_IDT_GATE_DESCRIPTOR); > > - if (IdtEntryCount > CPU_INTERRUPT_NUM) { > > - IdtEntryCount =3D CPU_INTERRUPT_NUM; > > - } > > - > > - // > > - // Create Interrupt Descriptor Table and Copy the old IDT table in > > - // > > - IdtTable =3D AllocateZeroPool (sizeof (IA32_IDT_GATE_DESCRIPTOR) * > CPU_INTERRUPT_NUM); > > - ASSERT (IdtTable !=3D NULL); > > - CopyMem (IdtTable, (VOID *)IdtDescriptor.Base, sizeof > (IA32_IDT_GATE_DESCRIPTOR) * IdtEntryCount); > > - > > - AsmGetTemplateAddressMap (&TemplateMap); > > - ASSERT (TemplateMap.ExceptionStubHeaderSize <=3D HOOKAFTER_STUB_SIZE); > > - > > - mExceptionHandlerData.IdtEntryCount =3D CPU_INTERRUPT_NUM; > > - InitializeSpinLock (&mExceptionHandlerData.DisplayMessageSpinLock); > > - > > - UpdateIdtTable (IdtTable, &TemplateMap, &mExceptionHandlerData); > > - > > - // > > - // Load Interrupt Descriptor Table > > - // > > - IdtDescriptor.Base =3D (UINTN)IdtTable; > > - IdtDescriptor.Limit =3D (UINT16)(sizeof (IA32_IDT_GATE_DESCRIPTOR) * > CPU_INTERRUPT_NUM - 1); > > - AsmWriteIdtr ((IA32_DESCRIPTOR *)&IdtDescriptor); > > - > > - return EFI_SUCCESS; > > -} > > - > > /** > > Registers a function to be called from the processor interrupt handler= . > > > > @@ -146,8 +76,8 @@ InitializeCpuInterruptHandlers ( > interrupt or exception type specified by InterruptType. If InterruptHa= ndler is > NULL, then the > > handler for the processor interrupt or exception type specified by > InterruptType is uninstalled. > > The installed handler is called once for each processor interrupt or e= xception. > > - NOTE: This function should be invoked after InitializeCpuExceptionHand= lers() > or > > - InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED > returned. > > + NOTE: This function should be invoked after InitializeCpuExceptionHand= lers() > is invoked, > > + otherwise EFI_UNSUPPORTED returned. > > > > @param[in] InterruptType Defines which interrupt or exception to = hook. > > @param[in] InterruptHandler A pointer to a function of type > EFI_CPU_INTERRUPT_HANDLER that is called > > diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c > index 687fc4177f..1ae611c75e 100644 > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c > @@ -1,7 +1,7 @@ > /** @file > > CPU exception handler library implementation for PEIM module. > > > > -Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
> > +Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > @@ -133,6 +133,7 @@ InitializeCpuExceptionHandlers ( > > > ExceptionHandlerData =3D AllocatePool (sizeof (EXCEPTION_HANDLER_DATA)= ); > > ASSERT (ExceptionHandlerData !=3D NULL); > > + ExceptionHandlerData->IdtEntryCount =3D CPU_EXCEPTION_NUM; > > ExceptionHandlerData->ReservedVectors =3D ReservedVectors; > > ExceptionHandlerData->ExternalInterruptHandler =3D NULL; > > InitializeSpinLock (&ExceptionHandlerData->DisplayMessageSpinLock); > > @@ -148,64 +149,6 @@ InitializeCpuExceptionHandlers ( > return EFI_SUCCESS; > > } > > > > -/** > > - Initializes all CPU interrupt/exceptions entries and provides the defa= ult > interrupt/exception handlers. > > - > > - Caller should try to get an array of interrupt and/or exception vector= s that are > in use and need to > > - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. > > - If caller cannot get reserved vector list or it does not exists, set V= ectorInfo to > NULL. > > - If VectorInfo is not NULL, the exception vectors will be initialized p= er vector > attribute accordingly. > > - > > - @param[in] VectorInfo Pointer to reserved vector list. > > - > > - @retval EFI_SUCCESS All CPU interrupt/exception entries have= been > successfully initialized > > - with default interrupt/exception handler= s. > > - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content = if > VectorInfo is not NULL. > > - @retval EFI_UNSUPPORTED This function is not supported. > > - > > -**/ > > -EFI_STATUS > > -EFIAPI > > -InitializeCpuInterruptHandlers ( > > - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL > > - ) > > -{ > > - return EFI_UNSUPPORTED; > > -} > > - > > -/** > > - Registers a function to be called from the processor interrupt handler= . > > - > > - This function registers and enables the handler specified by Interrupt= Handler > for a processor > > - interrupt or exception type specified by InterruptType. If InterruptHa= ndler is > NULL, then the > > - handler for the processor interrupt or exception type specified by > InterruptType is uninstalled. > > - The installed handler is called once for each processor interrupt or e= xception. > > - NOTE: This function should be invoked after InitializeCpuExceptionHand= lers() > or > > - InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED > returned. > > - > > - @param[in] InterruptType Defines which interrupt or exception to = hook. > > - @param[in] InterruptHandler A pointer to a function of type > EFI_CPU_INTERRUPT_HANDLER that is called > > - when a processor interrupt occurs. If th= is parameter is NULL, > then the handler > > - will be uninstalled. > > - > > - @retval EFI_SUCCESS The handler for the processor interrupt = was > successfully installed or uninstalled. > > - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a hand= ler > for InterruptType was > > - previously installed. > > - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler = for > InterruptType was not > > - previously installed. > > - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType= is not > supported, > > - or this function is not supported. > > -**/ > > -EFI_STATUS > > -EFIAPI > > -RegisterCpuInterruptHandler ( > > - IN EFI_EXCEPTION_TYPE InterruptType, > > - IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler > > - ) > > -{ > > - return EFI_UNSUPPORTED; > > -} > > - > > /** > > Initializes all CPU exceptions entries with optional extra initializat= ions. > > > > diff --git > a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c > index f47a80dcab..a7d0897ef1 100644 > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c > @@ -1,7 +1,7 @@ > /** @file > > CPU Exception Library provides PEI/DXE/SMM CPU common exception handle= r. > > > > -Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
> > +Copyright (c) 2012 - 2022, Intel Corporation. All rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > @@ -261,31 +261,26 @@ InitializeCpuExceptionHandlersWorker ( > RESERVED_VECTORS_DATA *ReservedVectors; > > > > ReservedVectors =3D ExceptionHandlerData->ReservedVectors; > > - SetMem ((VOID *)ReservedVectors, sizeof (RESERVED_VECTORS_DATA) * > CPU_EXCEPTION_NUM, 0xff); > > + SetMem ((VOID *)ReservedVectors, sizeof (RESERVED_VECTORS_DATA) * > ExceptionHandlerData->IdtEntryCount, 0xff); > > if (VectorInfo !=3D NULL) { > > - Status =3D ReadAndVerifyVectorInfo (VectorInfo, ReservedVectors, > CPU_EXCEPTION_NUM); > > + Status =3D ReadAndVerifyVectorInfo (VectorInfo, ReservedVectors, > ExceptionHandlerData->IdtEntryCount); > > if (EFI_ERROR (Status)) { > > return EFI_INVALID_PARAMETER; > > } > > } > > > > // > > - // Read IDT descriptor and calculate IDT size > > + // Setup the exception handlers according to IDT size, but no more tha= n > > + // ExceptionHandlerData->IdtEntryCount (32 in PEI and SMM, 256 in DX= E) > handlers. > > // > > AsmReadIdtr (&IdtDescriptor); > > - IdtEntryCount =3D (IdtDescriptor.Limit + 1) / sizeof > (IA32_IDT_GATE_DESCRIPTOR); > > - if (IdtEntryCount > CPU_EXCEPTION_NUM) { > > - // > > - // CPU exception library only setup CPU_EXCEPTION_NUM exception hand= ler > at most > > - // > > - IdtEntryCount =3D CPU_EXCEPTION_NUM; > > - } > > + IdtEntryCount =3D (IdtDescriptor.Limit + 1) / si= zeof > (IA32_IDT_GATE_DESCRIPTOR); > > + ExceptionHandlerData->IdtEntryCount =3D MIN (IdtEntryCount, > ExceptionHandlerData->IdtEntryCount); > > > > IdtTable =3D (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor.Base; > > AsmGetTemplateAddressMap (&TemplateMap); > > ASSERT (TemplateMap.ExceptionStubHeaderSize <=3D HOOKAFTER_STUB_SIZE); > > > > - ExceptionHandlerData->IdtEntryCount =3D IdtEntryCount; > > UpdateIdtTable (IdtTable, &TemplateMap, ExceptionHandlerData); > > > > return EFI_SUCCESS; > > diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException= .c > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c > index 6e5216380d..e894ead612 100644 > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c > @@ -1,7 +1,7 @@ > /** @file > > CPU exception handler library implemenation for SEC/PEIM modules. > > > > -Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
> > +Copyright (c) 2012 - 2022, Intel Corporation. All rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > @@ -166,31 +166,6 @@ InitializeCpuExceptionHandlers ( > return EFI_SUCCESS; > > } > > > > -/** > > - Initializes all CPU interrupt/exceptions entries and provides the defa= ult > interrupt/exception handlers. > > - > > - Caller should try to get an array of interrupt and/or exception vector= s that are > in use and need to > > - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. > > - If caller cannot get reserved vector list or it does not exists, set V= ectorInfo to > NULL. > > - If VectorInfo is not NULL, the exception vectors will be initialized p= er vector > attribute accordingly. > > - > > - @param[in] VectorInfo Pointer to reserved vector list. > > - > > - @retval EFI_SUCCESS All CPU interrupt/exception entries have= been > successfully initialized > > - with default interrupt/exception handler= s. > > - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content = if > VectorInfo is not NULL. > > - @retval EFI_UNSUPPORTED This function is not supported. > > - > > -**/ > > -EFI_STATUS > > -EFIAPI > > -InitializeCpuInterruptHandlers ( > > - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL > > - ) > > -{ > > - return EFI_UNSUPPORTED; > > -} > > - > > /** > > Registers a function to be called from the processor interrupt handler= . > > > > @@ -198,8 +173,8 @@ InitializeCpuInterruptHandlers ( > interrupt or exception type specified by InterruptType. If InterruptHa= ndler is > NULL, then the > > handler for the processor interrupt or exception type specified by > InterruptType is uninstalled. > > The installed handler is called once for each processor interrupt or e= xception. > > - NOTE: This function should be invoked after InitializeCpuExceptionHand= lers() > or > > - InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED > returned. > > + NOTE: This function should be invoked after InitializeCpuExceptionHand= lers() > is invoked, > > + otherwise EFI_UNSUPPORTED returned. > > > > @param[in] InterruptType Defines which interrupt or exception to = hook. > > @param[in] InterruptHandler A pointer to a function of type > EFI_CPU_INTERRUPT_HANDLER that is called > > diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c > index 9f0af4120a..ec643556c7 100644 > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c > @@ -1,7 +1,7 @@ > /** @file > > CPU exception handler library implementation for SMM modules. > > > > - Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
> > + Copyright (c) 2013 - 2022, Intel Corporation. All rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > @@ -14,8 +14,8 @@ CONST UINTN mDoFarReturnFlag =3D 1; > RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM]; > > EFI_CPU_INTERRUPT_HANDLER > mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM]; > > EXCEPTION_HANDLER_DATA mExceptionHandlerData =3D { > > - 0, // To be fixed > > - 0, // To be fixed > > + CPU_EXCEPTION_NUM, > > + 0, // To be fixed > > mReservedVectorsData, > > mExternalInterruptHandlerTable > > }; > > @@ -62,31 +62,6 @@ InitializeCpuExceptionHandlers ( > return InitializeCpuExceptionHandlersWorker (VectorInfo, > &mExceptionHandlerData); > > } > > > > -/** > > - Initializes all CPU interrupt/exceptions entries and provides the defa= ult > interrupt/exception handlers. > > - > > - Caller should try to get an array of interrupt and/or exception vector= s that are > in use and need to > > - persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. > > - If caller cannot get reserved vector list or it does not exists, set V= ectorInfo to > NULL. > > - If VectorInfo is not NULL, the exception vectors will be initialized p= er vector > attribute accordingly. > > - > > - @param[in] VectorInfo Pointer to reserved vector list. > > - > > - @retval EFI_SUCCESS All CPU interrupt/exception entries have= been > successfully initialized > > - with default interrupt/exception handler= s. > > - @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content = if > VectorInfo is not NULL. > > - @retval EFI_UNSUPPORTED This function is not supported. > > - > > -**/ > > -EFI_STATUS > > -EFIAPI > > -InitializeCpuInterruptHandlers ( > > - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL > > - ) > > -{ > > - return EFI_UNSUPPORTED; > > -} > > - > > /** > > Registers a function to be called from the processor interrupt handler= . > > > > @@ -94,8 +69,8 @@ InitializeCpuInterruptHandlers ( > interrupt or exception type specified by InterruptType. If InterruptHa= ndler is > NULL, then the > > handler for the processor interrupt or exception type specified by > InterruptType is uninstalled. > > The installed handler is called once for each processor interrupt or e= xception. > > - NOTE: This function should be invoked after InitializeCpuExceptionHand= lers() > or > > - InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED > returned. > > + NOTE: This function should be invoked after InitializeCpuExceptionHand= lers() > is invoked, > > + otherwise EFI_UNSUPPORTED returned. > > > > @param[in] InterruptType Defines which interrupt or exception to = hook. > > @param[in] InterruptHandler A pointer to a function of type > EFI_CPU_INTERRUPT_HANDLER that is called > > -- > 2.35.1.windows.2 > > > > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#89919): https://edk2.groups.io/g/devel/message/89919 > Mute This Topic: https://groups.io/mt/91231770/1768734 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [jian.j.wang@intel.com] > -=3D-=3D-=3D-=3D-=3D-=3D > --_000_DM4PR11MB64802A7F8CC323014B5E61B0FEA29DM4PR11MB6480namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Acked-by: Eric Dong eric.dong@intel.com

 

From: Ni, Ray <ray.ni@intel.com>
Sent: Tuesday, May 24, 2022 4:04 PM
To: Wang, Jian J <jian.j.wang@intel.com>; devel@edk2.groups.io=
Cc: Dong, Eric <eric.dong@intel.com>
Subject: Re: [edk2-devel] [PATCH 4/5] CpuException: Remove Initializ= eCpuInterruptHandlers

 

Jian,
I think we need discussion&= nbsp;on where to put the common CPU_INTERRUPT= _NUM definition.

Do you agree that we c= an leave that to another patch?

________________________________________=
From: Wang, Jian J <jian.j.wang@intel.com> Sent: Monday, May 23, 2022&= nbsp;0:27
To: devel@edk2.groups.io; Ni, Ray
Cc: Dong, Eric
Subject: RE: [edk2-devel] [PATCH=  4/5] CpuException: Remove InitializeCpuInterruptHandle= rs

Hi Ray,

Both CpuDxe.c and CpuExceptionCo= mmon.h have CPU_INTERRUPT_NUM defined.
I'd suggest to move it = ;to a common place, such as BaseLib.h. I=  don't see any issue
if they are defined to = ;different value. It just gives me a fee= ling that it might cause
potential problems sometimes in&= nbsp;the future.


Regards,
Jian

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of = ;Ni, Ray
> Sent: Friday, May 20,=  2022 10:16 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric <eric.dong@intel.com>
> Subject: [edk2-devel] [PAT= CH 4/5] CpuException: Remove
> InitializeCpuInterruptHandlers
>
> InitializeCpuExceptionHandlers()&nbs= p;expects caller allocates IDT while
> InitializeCpuInterruptHandlers()&nbs= p;allocates 256 IDT entries itself.
>
> InitializeCpuExceptionHandlers()&nbs= p;fills max 32 IDT entries allocated
> by caller. If caller&= nbsp;allocates 10 entries, the API just fills=  10 IDT
> entries.
>
> The inconsistency between&= nbsp;the two APIs makes code hard to > unerstand and hard to=  share.
>
> Because there is only=  one caller (CpuDxe) for
> InitializeCpuInterruptHandler(),&nbs= p;this patch updates CpuDxe driver
> to allocates 256 IDT&= nbsp;entries then call
> InitializeCpuExceptionHandlers().
>
> With this change, Ini= tializeCpuInterruptHandlers() is removed
> completely.
>
> And InitializeCpuExceptionHandl= ers() fills max 32 entries for PEI
> and SMM instance, max=  256 entries for DXE instance.
> Such behavior matches = ;to the original one.
>
> Signed-off-by: Ray Ni = ;<ray.ni@intel.com> > Cc: Eric Dong <eric.dong@intel.com>
> ---
>  .../Include/Library/CpuExcepti= onHandlerLib.h  | 28 +------
>  .../CpuExceptionHandlerLibNull= .c            &= nbsp; | 31 +------
>  UefiCpuPkg/CpuDxe/CpuDxe.c&nbs= p;            &= nbsp;      | 33 ++++++--
>  .../CpuExceptionHandlerLib/Dxe= Exception.c     | 80 ++-----------------=
>  .../CpuExceptionHandlerLib/Pei= CpuException.c  | 61 +-------------
>  .../PeiDxeSmmCpuException.c&nb= sp;            =       | 19 ++---
>  .../SecPeiCpuException.c =             &nb= sp;        | 31 +------
>  .../CpuExceptionHandlerLib/Smm= Exception.c     | 35 ++------
>  8 files changed,&nbs= p;56 insertions(+), 262 deletions(-)
>
> diff --git a/MdeModulePkg/= Include/Library/CpuExceptionHandlerLib.h
> b/MdeModulePkg/Include/Library/CpuEx= ceptionHandlerLib.h
> index 22a4408f9f..d4649bebe1&nb= sp;100644
> --- a/MdeModulePkg/Include/Libr= ary/CpuExceptionHandlerLib.h
> +++ b/MdeModulePkg/Include/Libr= ary/CpuExceptionHandlerLib.h
> @@ -2,7 +2,7 @@
>    CPU Exception=  library provides the default CPU interrupt/e= xception handler.
>
>    It also = provides capability to register user interrupt/exc= eption handler.
>
>
>
> -  Copyright (c) = ;2012 - 2018, Intel Corporation. All rights&n= bsp;reserved.<BR>
>
> +  Copyright (c) = ;2012 - 2022, Intel Corporation. All rights&n= bsp;reserved.<BR>
>
>    SPDX-License-Ident= ifier: BSD-2-Clause-Patent
>
>
>
>  **/
>
> @@ -132,28 +132,6 @@&= nbsp;InitializeCpuExceptionHandlersEx (
>    IN CPU_EXCEPT= ION_INIT_DATA  *InitData OPTIONAL
>
>    );
>
>
>
> -/**
>
> -  Initializes all&nb= sp;CPU interrupt/exceptions entries and provides t= he default
> interrupt/exception handlers.
>
> -
>
> -  Caller should = ;try to get an array of interrupt and/or=  exception vectors that are
> in use and need = to
>
> -  persist by EF= I_VECTOR_HANDOFF_INFO defined in PI 1.3 specificat= ion.
>
> -  If caller can= not get reserved vector list or it does&= nbsp;not exists, set VectorInfo to
> NULL.
>
> -  If VectorInfo = ;is not NULL, the exception vectors will = ;be initialized per vector
> attribute accordingly. >
> -
>
> -  @param[in]  V= ectorInfo    Pointer to reserved vector&= nbsp;list.
>
> -
>
> -  @retval EFI_SUCCES= S           All = ;CPU interrupt/exception entries have been
> successfully initialized=
>
> -      = ;            &n= bsp;            = ; with default interrupt/exception handlers.
>
> -  @retval EFI_INVALI= D_PARAMETER VectorInfo includes the invalid conten= t if
> VectorInfo is not NUL= L.
>
> -  @retval EFI_UNSUPP= ORTED       This function is&n= bsp;not supported.
>
> -
>
> -**/
>
> -EFI_STATUS
>
> -EFIAPI
>
> -InitializeCpuInterruptHandlers = ;(
>
> -  IN EFI_VECTOR_HAND= OFF_INFO  *VectorInfo OPTIONAL
>
> -  );
>
> -
>
>  /**
>
>    Registers a&n= bsp;function to be called from the processor&= nbsp;interrupt handler.
>
>
>
> @@ -161,8 +139,8 @@&n= bsp;InitializeCpuInterruptHandlers (
>    interrupt or&= nbsp;exception type specified by InterruptType. If=  InterruptHandler is
> NULL, then the
>
>    handler for&n= bsp;the processor interrupt or exception type = ;specified by
> InterruptType is uninstall= ed.
>
>    The installed=  handler is called once for each process= or interrupt or exception.
>
> -  NOTE: This fu= nction should be invoked after InitializeCpuExcept= ionHandlers()
> or
>
> -  InitializeCpuInterruptH= andlers() invoked, otherwise EFI_UNSUPPORTED
> returned.
>
> +  NOTE: This fu= nction should be invoked after InitializeCpuExcept= ionHandlers()
> is invoked,
>
> +  otherwise EFI_UNSU= PPORTED returned.
>
>
>
>    @param[in] &n= bsp;InterruptType     Defines which inte= rrupt or exception to hook.
>
>    @param[in] &n= bsp;InterruptHandler  A pointer to a function=  of type
> EFI_CPU_INTERRUPT_HANDLER that&= nbsp;is called
>
> diff --git
> a/MdeModulePkg/Library/CpuExceptionH= andlerLibNull/CpuExceptionHandlerLib
> Null.c
> b/MdeModulePkg/Library/CpuExceptionH= andlerLibNull/CpuExceptionHandlerLib
> Null.c
> index 35ab5a8db5..54f38788fe&nb= sp;100644
> ---
> a/MdeModulePkg/Library/CpuExceptionH= andlerLibNull/CpuExceptionHandlerLib
> Null.c
> +++
> b/MdeModulePkg/Library/CpuExceptionH= andlerLibNull/CpuExceptionHandlerLib
> Null.c
> @@ -1,7 +1,7 @@
>  /** @file
>
>    CPU Exception=  Handler library implementition with empty fu= nctions.
>
>
>
> -  Copyright (c) = ;2012 - 2018, Intel Corporation. All rights&n= bsp;reserved.<BR>
>
> +  Copyright (c) = ;2012 - 2022, Intel Corporation. All rights&n= bsp;reserved.<BR>
>
>    SPDX-License-Ident= ifier: BSD-2-Clause-Patent
>
>
>
>  **/
>
> @@ -33,31 +33,6 @@&nb= sp;InitializeCpuExceptionHandlers (
>    return EFI_SU= CCESS;
>
>  }
>
>
>
> -/**
>
> -  Initializes all&nb= sp;CPU interrupt/exceptions entries and provides t= he default
> interrupt/exception handlers.
>
> -
>
> -  Caller should = ;try to get an array of interrupt and/or=  exception vectors that are
> in use and need = to
>
> -  persist by EF= I_VECTOR_HANDOFF_INFO defined in PI 1.3 specificat= ion.
>
> -  If caller can= not get reserved vector list or it does&= nbsp;not exists, set VectorInfo to
> NULL.
>
> -  If VectorInfo = ;is not NULL, the exception vectors will = ;be initialized per vector
> attribute accordingly. >
> -
>
> -  @param[in]  V= ectorInfo    Pointer to reserved vector&= nbsp;list.
>
> -
>
> -  @retval EFI_SUCCES= S           All = ;CPU interrupt/exception entries have been
> successfully initialized=
>
> -      = ;            &n= bsp;            = ; with default interrupt/exception handlers.
>
> -  @retval EFI_INVALI= D_PARAMETER VectorInfo includes the invalid conten= t if
> VectorInfo is not NUL= L.
>
> -  @retval EFI_UNSUPP= ORTED       This function is&n= bsp;not supported.
>
> -
>
> -**/
>
> -EFI_STATUS
>
> -EFIAPI
>
> -InitializeCpuInterruptHandlers = ;(
>
> -  IN EFI_VECTOR_HAND= OFF_INFO  *VectorInfo OPTIONAL
>
> -  )
>
> -{
>
> -  return EFI_SUCCESS= ;
>
> -}
>
> -
>
>  /**
>
>    Registers a&n= bsp;function to be called from the processor&= nbsp;interrupt handler.
>
>
>
> @@ -65,8 +40,8 @@&nbs= p;InitializeCpuInterruptHandlers (
>    interrupt or&= nbsp;exception type specified by InterruptType. If=  InterruptHandler is
> NULL, then the
>
>    handler for&n= bsp;the processor interrupt or exception type = ;specified by
> InterruptType is uninstall= ed.
>
>    The installed=  handler is called once for each process= or interrupt or exception.
>
> -  NOTE: This fu= nction should be invoked after InitializeCpuExcept= ionHandlers()
> or
>
> -  InitializeCpuInterruptH= andlers() invoked, otherwise EFI_UNSUPPORTED
> returned.
>
> +  NOTE: This fu= nction should be invoked after InitializeCpuExcept= ionHandlers()
> is invoked,
>
> +  otherwise EFI_UNSU= PPORTED returned.
>
>
>
>    @param[in] &n= bsp;InterruptType     Defines which inte= rrupt or exception to hook.
>
>    @param[in] &n= bsp;InterruptHandler  A pointer to a function=  of type
> EFI_CPU_INTERRUPT_HANDLER that&= nbsp;is called
>
> diff --git a/UefiCpuPkg/Cp= uDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
> index 00f3cb0957..a6a91507f6&nb= sp;100644
> --- a/UefiCpuPkg/CpuDxe/CpuDxe.= c
> +++ b/UefiCpuPkg/CpuDxe/CpuDxe.= c
> @@ -1,7 +1,7 @@
>  /** @file
>
>    CPU DXE = Module to produce CPU ARCH Protocol.
>
>
>
> -  Copyright (c) = ;2008 - 2018, Intel Corporation. All rights&n= bsp;reserved.<BR>
>
> +  Copyright (c) = ;2008 - 2022, Intel Corporation. All rights&n= bsp;reserved.<BR>
>
>    SPDX-License-Ident= ifier: BSD-2-Clause-Patent
>
>
>
>  **/
>
> @@ -10,6 +10,8 @@
>  #include "CpuMp.h&qu= ot;
>
>  #include "CpuPageTab= le.h"
>
>
>
> +#define CPU_INTERRUPT_NUM = ; 256
>
> +
>
>  //
>
>  // Global Variables<= /span>
>
>  //
>
> @@ -924,9 +926,12 @@&= nbsp;InitInterruptDescriptorTable (
>    VOID
>
>    )
>
>  {
>
> -  EFI_STATUS  &= nbsp;           &nbs= p;Status;
>
> -  EFI_VECTOR_HANDOFF_INFO=   *VectorInfoList;
>
> -  EFI_VECTOR_HANDOFF_INFO=   *VectorInfo;
>
> +  EFI_STATUS  &= nbsp;           &nbs= p; Status;
>
> +  EFI_VECTOR_HANDOFF_INFO=    *VectorInfoList;
>
> +  EFI_VECTOR_HANDOFF_INFO=    *VectorInfo;
>
> +  IA32_IDT_GATE_DESCRIPTO= R  *IdtTable;
>
> +  IA32_DESCRIPTOR &n= bsp;         IdtDescriptor;
>
> +  UINTN   =             &nb= sp;     IdtEntryCount;
>
>
>
>    VectorInfo = =3D NULL;
>
>    Status  =    =3D EfiGetSystemConfigurationTable (&gEfiVe= ctorHandoffTableGuid,
> (VOID **)&VectorInfoList);<= /span>
>
> @@ -934,7 +939,25 @@&= nbsp;InitInterruptDescriptorTable (
>      Vector= Info =3D VectorInfoList;
>
>    }
>
>
>
> -  Status =3D In= itializeCpuInterruptHandlers (VectorInfo);
>
> +  AsmReadIdtr (&= IdtDescriptor);
>
> +  IdtEntryCount =3D&= nbsp;(IdtDescriptor.Limit + 1) / sizeof
> (IA32_IDT_GATE_DESCRIPTOR); >
> +  if (IdtEntryCount&= nbsp;< CPU_INTERRUPT_NUM) {
>
> +    // >
> +    // Inc= rease Interrupt Descriptor Table and Copy the=  old IDT table in
>
> +    // >
> +    IdtTable&nb= sp;=3D AllocateZeroPool (sizeof (IA32_IDT_GATE_DESCRIPTOR)&n= bsp;*
> CPU_INTERRUPT_NUM);
>
> +    ASSERT = ;(IdtTable !=3D NULL);
>
> +    CopyMem&nbs= p;(IdtTable, (VOID *)IdtDescriptor.Base, sizeof
> (IA32_IDT_GATE_DESCRIPTOR) *&nb= sp;IdtEntryCount);
>
> +
>
> +    // >
> +    // Loa= d Interrupt Descriptor Table
>
> +    // >
> +    IdtDescript= or.Base  =3D (UINTN)IdtTable;
>
> +    IdtDescript= or.Limit =3D (UINT16)(sizeof (IA32_IDT_GATE_DESCRIPTOR) = ;*
> CPU_INTERRUPT_NUM - 1);
>
> +    AsmWriteIdt= r (&IdtDescriptor);
>
> +  }
>
> +
>
> +  Status =3D In= itializeCpuExceptionHandlers (VectorInfo);
>
>    ASSERT_EFI_ERROR&n= bsp;(Status);
>
>  }
>
>
>
> diff --git a/UefiCpuPkg/Li= brary/CpuExceptionHandlerLib/DxeException.c
> b/UefiCpuPkg/Library/CpuExceptionHan= dlerLib/DxeException.c
> index f139131a7c..c7c1fe31d2&nb= sp;100644
> --- a/UefiCpuPkg/Library/CpuExc= eptionHandlerLib/DxeException.c
> +++ b/UefiCpuPkg/Library/CpuExc= eptionHandlerLib/DxeException.c
> @@ -1,7 +1,7 @@
>  /** @file
>
>    CPU exception=  handler library implemenation for DXE module= s.
>
>
>
> -  Copyright (c) = ;2013 - 2017, Intel Corporation. All rights&n= bsp;reserved.<BR>
>
> +  Copyright (c) = ;2013 - 2022, Intel Corporation. All rights&n= bsp;reserved.<BR>
>
>    SPDX-License-Ident= ifier: BSD-2-Clause-Patent
>
>
>
>  **/
>
> @@ -17,8 +17,8 @@&nbs= p;CONST UINTN  mDoFarReturnFlag =3D 0;
>  RESERVED_VECTORS_DATA &nb= sp;    mReservedVectorsData[CPU_INTERRUPT_NUM];<= br> >
>  EFI_CPU_INTERRUPT_HANDLER
> mExternalInterruptHandlerTable[CPU_I= NTERRUPT_NUM];
>
>  EXCEPTION_HANDLER_DATA &n= bsp;   mExceptionHandlerData =3D {
>
> -  0,   //&= nbsp;To be fixed
>
> -  0,   //&= nbsp;To be fixed
>
> +  CPU_INTERRUPT_NUM,
>
> +  0,   &nb= sp;            =      // To be fixed
>
>    mReservedVectorsDa= ta,
>
>    mExternalInterrupt= HandlerTable
>
>  };
>
> @@ -69,76 +69,6 @@&nb= sp;InitializeCpuExceptionHandlers (
>    return Initia= lizeCpuExceptionHandlersWorker (VectorInfo,
> &mExceptionHandlerData);<= br> >
>  }
>
>
>
> -/**
>
> -  Initializes all&nb= sp;CPU interrupt/exceptions entries and provides t= he default
> interrupt/exception handlers.
>
> -
>
> -  Caller should = ;try to get an array of interrupt and/or=  exception vectors that are
> in use and need = to
>
> -  persist by EF= I_VECTOR_HANDOFF_INFO defined in PI 1.3 specificat= ion.
>
> -  If caller can= not get reserved vector list or it does&= nbsp;not exists, set VectorInfo to
> NULL.
>
> -  If VectorInfo = ;is not NULL, the exception vectors will = ;be initialized per vector
> attribute accordingly. >
> -
>
> -  @param[in]  V= ectorInfo    Pointer to reserved vector&= nbsp;list.
>
> -
>
> -  @retval EFI_SUCCES= S           All = ;CPU interrupt/exception entries have been
> successfully initialized=
>
> -      = ;            &n= bsp;            = ; with default interrupt/exception handlers.
>
> -  @retval EFI_INVALI= D_PARAMETER VectorInfo includes the invalid conten= t if
> VectorInfo is not NUL= L.
>
> -  @retval EFI_UNSUPP= ORTED       This function is&n= bsp;not supported.
>
> -
>
> -**/
>
> -EFI_STATUS
>
> -EFIAPI
>
> -InitializeCpuInterruptHandlers = ;(
>
> -  IN EFI_VECTOR_HAND= OFF_INFO  *VectorInfo OPTIONAL
>
> -  )
>
> -{
>
> -  EFI_STATUS  &= nbsp;           &nbs= p;       Status;
>
> -  IA32_IDT_GATE_DESCRIPTO= R        *IdtTable;
>
> -  IA32_DESCRIPTOR &n= bsp;            = ;   IdtDescriptor;
>
> -  UINTN   =             &nb= sp;           IdtEnt= ryCount;
>
> -  EXCEPTION_HANDLER_TEMPL= ATE_MAP  TemplateMap;
>
> -
>
> -  SetMem ((VOID = ;*)mReservedVectorsData, sizeof (RESERVED_VECTORS_DATA) > * CPU_INTERRUPT_NUM, 0xff)= ;
>
> -  if (VectorInfo&nbs= p;!=3D NULL) {
>
> -    Status = ;=3D ReadAndVerifyVectorInfo (VectorInfo, mReservedVectorsDa= ta,
> CPU_INTERRUPT_NUM);
>
> -    if (EF= I_ERROR (Status)) {
>
> -      = ;return EFI_INVALID_PARAMETER;
>
> -    } >
> -  }
>
> -
>
> -  //
>
> -  // Read IDT&n= bsp;descriptor and calculate IDT size
>
> -  //
>
> -  AsmReadIdtr (&= IdtDescriptor);
>
> -  IdtEntryCount =3D&= nbsp;(IdtDescriptor.Limit + 1) / sizeof
> (IA32_IDT_GATE_DESCRIPTOR); >
> -  if (IdtEntryCount&= nbsp;> CPU_INTERRUPT_NUM) {
>
> -    IdtEntryCou= nt =3D CPU_INTERRUPT_NUM;
>
> -  }
>
> -
>
> -  //
>
> -  // Create Int= errupt Descriptor Table and Copy the old = ;IDT table in
>
> -  //
>
> -  IdtTable =3D = AllocateZeroPool (sizeof (IA32_IDT_GATE_DESCRIPTOR) *=
> CPU_INTERRUPT_NUM);
>
> -  ASSERT (IdtTable&n= bsp;!=3D NULL);
>
> -  CopyMem (IdtTable,=  (VOID *)IdtDescriptor.Base, sizeof
> (IA32_IDT_GATE_DESCRIPTOR) *&nb= sp;IdtEntryCount);
>
> -
>
> -  AsmGetTemplateAddressMa= p (&TemplateMap);
>
> -  ASSERT (TemplateMa= p.ExceptionStubHeaderSize <=3D HOOKAFTER_STUB_SIZE); >
> -
>
> -  mExceptionHandlerData.I= dtEntryCount          &nb= sp; =3D CPU_INTERRUPT_NUM;
>
> -  InitializeSpinLock = ;(&mExceptionHandlerData.DisplayMessageSpinLock);
>
> -
>
> -  UpdateIdtTable (Id= tTable, &TemplateMap, &mExceptionHandlerData);
>
> -
>
> -  //
>
> -  // Load Inter= rupt Descriptor Table
>
> -  //
>
> -  IdtDescriptor.Base = ; =3D (UINTN)IdtTable;
>
> -  IdtDescriptor.Limit&nbs= p;=3D (UINT16)(sizeof (IA32_IDT_GATE_DESCRIPTOR) * > CPU_INTERRUPT_NUM - 1);
>
> -  AsmWriteIdtr ((IA3= 2_DESCRIPTOR *)&IdtDescriptor);
>
> -
>
> -  return EFI_SUCCESS= ;
>
> -}
>
> -
>
>  /**
>
>    Registers a&n= bsp;function to be called from the processor&= nbsp;interrupt handler.
>
>
>
> @@ -146,8 +76,8 @@&nb= sp;InitializeCpuInterruptHandlers (
>    interrupt or&= nbsp;exception type specified by InterruptType. If=  InterruptHandler is
> NULL, then the
>
>    handler for&n= bsp;the processor interrupt or exception type = ;specified by
> InterruptType is uninstall= ed.
>
>    The installed=  handler is called once for each process= or interrupt or exception.
>
> -  NOTE: This fu= nction should be invoked after InitializeCpuExcept= ionHandlers()
> or
>
> -  InitializeCpuInterruptH= andlers() invoked, otherwise EFI_UNSUPPORTED
> returned.
>
> +  NOTE: This fu= nction should be invoked after InitializeCpuExcept= ionHandlers()
> is invoked,
>
> +  otherwise EFI_UNSU= PPORTED returned.
>
>
>
>    @param[in] &n= bsp;InterruptType     Defines which inte= rrupt or exception to hook.
>
>    @param[in] &n= bsp;InterruptHandler  A pointer to a function=  of type
> EFI_CPU_INTERRUPT_HANDLER that&= nbsp;is called
>
> diff --git a/UefiCpuPkg/Li= brary/CpuExceptionHandlerLib/PeiCpuException.c
> b/UefiCpuPkg/Library/CpuExceptionHan= dlerLib/PeiCpuException.c
> index 687fc4177f..1ae611c75e&nb= sp;100644
> --- a/UefiCpuPkg/Library/CpuExc= eptionHandlerLib/PeiCpuException.c
> +++ b/UefiCpuPkg/Library/CpuExc= eptionHandlerLib/PeiCpuException.c
> @@ -1,7 +1,7 @@
>  /** @file
>
>    CPU exception=  handler library implementation for PEIM modu= le.
>
>
>
> -Copyright (c) 2016 -=  2018, Intel Corporation. All rights reserved= .<BR>
>
> +Copyright (c) 2016 -=  2022, Intel Corporation. All rights reserved= .<BR>
>
>  SPDX-License-Identifier: = BSD-2-Clause-Patent
>
>
>
>  **/
>
> @@ -133,6 +133,7 @@&n= bsp;InitializeCpuExceptionHandlers (
>
>
>    ExceptionHandlerDa= ta =3D AllocatePool (sizeof (EXCEPTION_HANDLER_DATA));<= /span>
>
>    ASSERT (Excep= tionHandlerData !=3D NULL);
>
> +  ExceptionHandlerData-&g= t;IdtEntryCount          =   =3D CPU_EXCEPTION_NUM;
>
>    ExceptionHandlerDa= ta->ReservedVectors         = ; =3D ReservedVectors;
>
>    ExceptionHandlerDa= ta->ExternalInterruptHandler =3D NULL;
>
>    InitializeSpinLock=  (&ExceptionHandlerData->DisplayMessageSpinLock);
>
> @@ -148,64 +149,6 @@&= nbsp;InitializeCpuExceptionHandlers (
>    return EFI_SU= CCESS;
>
>  }
>
>
>
> -/**
>
> -  Initializes all&nb= sp;CPU interrupt/exceptions entries and provides t= he default
> interrupt/exception handlers.
>
> -
>
> -  Caller should = ;try to get an array of interrupt and/or=  exception vectors that are
> in use and need = to
>
> -  persist by EF= I_VECTOR_HANDOFF_INFO defined in PI 1.3 specificat= ion.
>
> -  If caller can= not get reserved vector list or it does&= nbsp;not exists, set VectorInfo to
> NULL.
>
> -  If VectorInfo = ;is not NULL, the exception vectors will = ;be initialized per vector
> attribute accordingly. >
> -
>
> -  @param[in]  V= ectorInfo    Pointer to reserved vector&= nbsp;list.
>
> -
>
> -  @retval EFI_SUCCES= S           All = ;CPU interrupt/exception entries have been
> successfully initialized=
>
> -      = ;            &n= bsp;            = ; with default interrupt/exception handlers.
>
> -  @retval EFI_INVALI= D_PARAMETER VectorInfo includes the invalid conten= t if
> VectorInfo is not NUL= L.
>
> -  @retval EFI_UNSUPP= ORTED       This function is&n= bsp;not supported.
>
> -
>
> -**/
>
> -EFI_STATUS
>
> -EFIAPI
>
> -InitializeCpuInterruptHandlers = ;(
>
> -  IN EFI_VECTOR_HAND= OFF_INFO  *VectorInfo OPTIONAL
>
> -  )
>
> -{
>
> -  return EFI_UNSUPPO= RTED;
>
> -}
>
> -
>
> -/**
>
> -  Registers a f= unction to be called from the processor = interrupt handler.
>
> -
>
> -  This function = ;registers and enables the handler specified = by InterruptHandler
> for a processor
>
> -  interrupt or = exception type specified by InterruptType. If = ;InterruptHandler is
> NULL, then the
>
> -  handler for t= he processor interrupt or exception type spec= ified by
> InterruptType is uninstall= ed.
>
> -  The installed = ;handler is called once for each processor&nb= sp;interrupt or exception.
>
> -  NOTE: This fu= nction should be invoked after InitializeCpuExcept= ionHandlers()
> or
>
> -  InitializeCpuInterruptH= andlers() invoked, otherwise EFI_UNSUPPORTED
> returned.
>
> -
>
> -  @param[in]  I= nterruptType     Defines which interrupt=  or exception to hook.
>
> -  @param[in]  I= nterruptHandler  A pointer to a function = ;of type
> EFI_CPU_INTERRUPT_HANDLER that&= nbsp;is called
>
> -      = ;            &n= bsp;            = ; when a processor interrupt occurs. If = this parameter is NULL,
> then the handler >
> -      = ;            &n= bsp;            = ; will be uninstalled.
>
> -
>
> -  @retval EFI_SUCCES= S           The = ;handler for the processor interrupt was > successfully installed or&= nbsp;uninstalled.
>
> -  @retval EFI_ALREAD= Y_STARTED   InterruptHandler is not NULL,&nbs= p;and a handler
> for InterruptType was
>
> -      = ;            &n= bsp;            = ; previously installed.
>
> -  @retval EFI_INVALI= D_PARAMETER InterruptHandler is NULL, and a h= andler for
> InterruptType was not
>
> -      = ;            &n= bsp;            = ; previously installed.
>
> -  @retval EFI_UNSUPP= ORTED       The interrupt spec= ified by InterruptType is not
> supported,
>
> -      = ;            &n= bsp;            = ; or this function is not supported. >
> -**/
>
> -EFI_STATUS
>
> -EFIAPI
>
> -RegisterCpuInterruptHandler (<= /span>
>
> -  IN EFI_EXCEPTION_T= YPE         InterruptType,
>
> -  IN EFI_CPU_INTERRU= PT_HANDLER  InterruptHandler
>
> -  )
>
> -{
>
> -  return EFI_UNSUPPO= RTED;
>
> -}
>
> -
>
>  /**
>
>    Initializes a= ll CPU exceptions entries with optional extra=  initializations.
>
>
>
> diff --git
> a/UefiCpuPkg/Library/CpuExceptionHan= dlerLib/PeiDxeSmmCpuException.c
> b/UefiCpuPkg/Library/CpuExceptionHan= dlerLib/PeiDxeSmmCpuException.c
> index f47a80dcab..a7d0897ef1&nb= sp;100644
> --- a/UefiCpuPkg/Library/CpuExc= eptionHandlerLib/PeiDxeSmmCpuException.c
> +++ b/UefiCpuPkg/Library/CpuExc= eptionHandlerLib/PeiDxeSmmCpuException.c
> @@ -1,7 +1,7 @@
>  /** @file
>
>    CPU Exception=  Library provides PEI/DXE/SMM CPU common exce= ption handler.
>
>
>
> -Copyright (c) 2012 -=  2018, Intel Corporation. All rights reserved= .<BR>
>
> +Copyright (c) 2012 -=  2022, Intel Corporation. All rights reserved= .<BR>
>
>  SPDX-License-Identifier: = BSD-2-Clause-Patent
>
>
>
>  **/
>
> @@ -261,31 +261,26 @@=  InitializeCpuExceptionHandlersWorker (
>    RESERVED_VECTORS_D= ATA           *Reser= vedVectors;
>
>
>
>    ReservedVectors&nb= sp;=3D ExceptionHandlerData->ReservedVectors;
>
> -  SetMem ((VOID = ;*)ReservedVectors, sizeof (RESERVED_VECTORS_DATA) *<= br> > CPU_EXCEPTION_NUM, 0xff);
>
> +  SetMem ((VOID = ;*)ReservedVectors, sizeof (RESERVED_VECTORS_DATA) *<= br> > ExceptionHandlerData->IdtEntryCou= nt, 0xff);
>
>    if (VectorInf= o !=3D NULL) {
>
> -    Status = ;=3D ReadAndVerifyVectorInfo (VectorInfo, ReservedVectors,
> CPU_EXCEPTION_NUM);
>
> +    Status = ;=3D ReadAndVerifyVectorInfo (VectorInfo, ReservedVectors,
> ExceptionHandlerData->IdtEntryCou= nt);
>
>      if&nbs= p;(EFI_ERROR (Status)) {
>
>       =  return EFI_INVALID_PARAMETER;
>
>      }
>
>    }
>
>
>
>    //
>
> -  // Read IDT&n= bsp;descriptor and calculate IDT size
>
> +  // Setup the&= nbsp;exception handlers according to IDT size,&nbs= p;but no more than
>
> +  //   Exc= eptionHandlerData->IdtEntryCount (32 in PEI and = ;SMM, 256 in DXE)
> handlers.
>
>    //
>
>    AsmReadIdtr (= &IdtDescriptor);
>
> -  IdtEntryCount =3D&= nbsp;(IdtDescriptor.Limit + 1) / sizeof
> (IA32_IDT_GATE_DESCRIPTOR); >
> -  if (IdtEntryCount&= nbsp;> CPU_EXCEPTION_NUM) {
>
> -    // >
> -    // CPU=  exception library only setup CPU_EXCEPTION_NUM&nb= sp;exception handler
> at most
>
> -    // >
> -    IdtEntryCou= nt =3D CPU_EXCEPTION_NUM;
>
> -  }
>
> +  IdtEntryCount &nbs= p;            &= nbsp;        =3D (IdtDescripto= r.Limit + 1) / sizeof
> (IA32_IDT_GATE_DESCRIPTOR); >
> +  ExceptionHandlerData-&g= t;IdtEntryCount =3D MIN (IdtEntryCount,
> ExceptionHandlerData->IdtEntryCou= nt);
>
>
>
>    IdtTable =3D&= nbsp;(IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor.Base;
>
>    AsmGetTemplateAddr= essMap (&TemplateMap);
>
>    ASSERT (Templ= ateMap.ExceptionStubHeaderSize <=3D HOOKAFTER_STUB_SIZE);
>
>
>
> -  ExceptionHandlerData-&g= t;IdtEntryCount =3D IdtEntryCount;
>
>    UpdateIdtTable&nbs= p;(IdtTable, &TemplateMap, ExceptionHandlerData);
>
>
>
>    return EFI_SU= CCESS;
>
> diff --git a/UefiCpuPkg/Li= brary/CpuExceptionHandlerLib/SecPeiCpuException.c
> b/UefiCpuPkg/Library/CpuExceptionHan= dlerLib/SecPeiCpuException.c
> index 6e5216380d..e894ead612&nb= sp;100644
> --- a/UefiCpuPkg/Library/CpuExc= eptionHandlerLib/SecPeiCpuException.c
> +++ b/UefiCpuPkg/Library/CpuExc= eptionHandlerLib/SecPeiCpuException.c
> @@ -1,7 +1,7 @@
>  /** @file
>
>    CPU exception=  handler library implemenation for SEC/PEIM m= odules.
>
>
>
> -Copyright (c) 2012 -=  2018, Intel Corporation. All rights reserved= .<BR>
>
> +Copyright (c) 2012 -=  2022, Intel Corporation. All rights reserved= .<BR>
>
>  SPDX-License-Identifier: = BSD-2-Clause-Patent
>
>
>
>  **/
>
> @@ -166,31 +166,6 @@&= nbsp;InitializeCpuExceptionHandlers (
>    return EFI_SU= CCESS;
>
>  }
>
>
>
> -/**
>
> -  Initializes all&nb= sp;CPU interrupt/exceptions entries and provides t= he default
> interrupt/exception handlers.
>
> -
>
> -  Caller should = ;try to get an array of interrupt and/or=  exception vectors that are
> in use and need = to
>
> -  persist by EF= I_VECTOR_HANDOFF_INFO defined in PI 1.3 specificat= ion.
>
> -  If caller can= not get reserved vector list or it does&= nbsp;not exists, set VectorInfo to
> NULL.
>
> -  If VectorInfo = ;is not NULL, the exception vectors will = ;be initialized per vector
> attribute accordingly. >
> -
>
> -  @param[in]  V= ectorInfo    Pointer to reserved vector&= nbsp;list.
>
> -
>
> -  @retval EFI_SUCCES= S           All = ;CPU interrupt/exception entries have been
> successfully initialized=
>
> -      = ;            &n= bsp;            = ; with default interrupt/exception handlers.
>
> -  @retval EFI_INVALI= D_PARAMETER VectorInfo includes the invalid conten= t if
> VectorInfo is not NUL= L.
>
> -  @retval EFI_UNSUPP= ORTED       This function is&n= bsp;not supported.
>
> -
>
> -**/
>
> -EFI_STATUS
>
> -EFIAPI
>
> -InitializeCpuInterruptHandlers = ;(
>
> -  IN EFI_VECTOR_HAND= OFF_INFO  *VectorInfo OPTIONAL
>
> -  )
>
> -{
>
> -  return EFI_UNSUPPO= RTED;
>
> -}
>
> -
>
>  /**
>
>    Registers a&n= bsp;function to be called from the processor&= nbsp;interrupt handler.
>
>
>
> @@ -198,8 +173,8 @@&n= bsp;InitializeCpuInterruptHandlers (
>    interrupt or&= nbsp;exception type specified by InterruptType. If=  InterruptHandler is
> NULL, then the
>
>    handler for&n= bsp;the processor interrupt or exception type = ;specified by
> InterruptType is uninstall= ed.
>
>    The installed=  handler is called once for each process= or interrupt or exception.
>
> -  NOTE: This fu= nction should be invoked after InitializeCpuExcept= ionHandlers()
> or
>
> -  InitializeCpuInterruptH= andlers() invoked, otherwise EFI_UNSUPPORTED
> returned.
>
> +  NOTE: This fu= nction should be invoked after InitializeCpuExcept= ionHandlers()
> is invoked,
>
> +  otherwise EFI_UNSU= PPORTED returned.
>
>
>
>    @param[in] &n= bsp;InterruptType     Defines which inte= rrupt or exception to hook.
>
>    @param[in] &n= bsp;InterruptHandler  A pointer to a function=  of type
> EFI_CPU_INTERRUPT_HANDLER that&= nbsp;is called
>
> diff --git a/UefiCpuPkg/Li= brary/CpuExceptionHandlerLib/SmmException.c
> b/UefiCpuPkg/Library/CpuExceptionHan= dlerLib/SmmException.c
> index 9f0af4120a..ec643556c7&nb= sp;100644
> --- a/UefiCpuPkg/Library/CpuExc= eptionHandlerLib/SmmException.c
> +++ b/UefiCpuPkg/Library/CpuExc= eptionHandlerLib/SmmException.c
> @@ -1,7 +1,7 @@
>  /** @file
>
>    CPU exception=  handler library implementation for SMM modul= es.
>
>
>
> -  Copyright (c) = ;2013 - 2017, Intel Corporation. All rights&n= bsp;reserved.<BR>
>
> +  Copyright (c) = ;2013 - 2022, Intel Corporation. All rights&n= bsp;reserved.<BR>
>
>    SPDX-License-Ident= ifier: BSD-2-Clause-Patent
>
>
>
>  **/
>
> @@ -14,8 +14,8 @@&nbs= p;CONST UINTN  mDoFarReturnFlag =3D 1;
>  RESERVED_VECTORS_DATA &nb= sp;    mReservedVectorsData[CPU_EXCEPTION_NUM];<= br> >
>  EFI_CPU_INTERRUPT_HANDLER
> mExternalInterruptHandlerTable[CPU_E= XCEPTION_NUM];
>
>  EXCEPTION_HANDLER_DATA &n= bsp;   mExceptionHandlerData =3D {
>
> -  0,   //&= nbsp;To be fixed
>
> -  0,   //&= nbsp;To be fixed
>
> +  CPU_EXCEPTION_NUM,
>
> +  0,   &nb= sp;            =      // To be fixed
>
>    mReservedVectorsDa= ta,
>
>    mExternalInterrupt= HandlerTable
>
>  };
>
> @@ -62,31 +62,6 @@&nb= sp;InitializeCpuExceptionHandlers (
>    return Initia= lizeCpuExceptionHandlersWorker (VectorInfo,
> &mExceptionHandlerData);<= br> >
>  }
>
>
>
> -/**
>
> -  Initializes all&nb= sp;CPU interrupt/exceptions entries and provides t= he default
> interrupt/exception handlers.
>
> -
>
> -  Caller should = ;try to get an array of interrupt and/or=  exception vectors that are
> in use and need = to
>
> -  persist by EF= I_VECTOR_HANDOFF_INFO defined in PI 1.3 specificat= ion.
>
> -  If caller can= not get reserved vector list or it does&= nbsp;not exists, set VectorInfo to
> NULL.
>
> -  If VectorInfo = ;is not NULL, the exception vectors will = ;be initialized per vector
> attribute accordingly. >
> -
>
> -  @param[in]  V= ectorInfo    Pointer to reserved vector&= nbsp;list.
>
> -
>
> -  @retval EFI_SUCCES= S           All = ;CPU interrupt/exception entries have been
> successfully initialized=
>
> -      = ;            &n= bsp;            = ; with default interrupt/exception handlers.
>
> -  @retval EFI_INVALI= D_PARAMETER VectorInfo includes the invalid conten= t if
> VectorInfo is not NUL= L.
>
> -  @retval EFI_UNSUPP= ORTED       This function is&n= bsp;not supported.
>
> -
>
> -**/
>
> -EFI_STATUS
>
> -EFIAPI
>
> -InitializeCpuInterruptHandlers = ;(
>
> -  IN EFI_VECTOR_HAND= OFF_INFO  *VectorInfo OPTIONAL
>
> -  )
>
> -{
>
> -  return EFI_UNSUPPO= RTED;
>
> -}
>
> -
>
>  /**
>
>    Registers a&n= bsp;function to be called from the processor&= nbsp;interrupt handler.
>
>
>
> @@ -94,8 +69,8 @@&nbs= p;InitializeCpuInterruptHandlers (
>    interrupt or&= nbsp;exception type specified by InterruptType. If=  InterruptHandler is
> NULL, then the
>
>    handler for&n= bsp;the processor interrupt or exception type = ;specified by
> InterruptType is uninstall= ed.
>
>    The installed=  handler is called once for each process= or interrupt or exception.
>
> -  NOTE: This fu= nction should be invoked after InitializeCpuExcept= ionHandlers()
> or
>
> -  InitializeCpuInterruptH= andlers() invoked, otherwise EFI_UNSUPPORTED
> returned.
>
> +  NOTE: This fu= nction should be invoked after InitializeCpuExcept= ionHandlers()
> is invoked,
>
> +  otherwise EFI_UNSU= PPORTED returned.
>
>
>
>    @param[in] &n= bsp;InterruptType     Defines which inte= rrupt or exception to hook.
>
>    @param[in] &n= bsp;InterruptHandler  A pointer to a function=  of type
> EFI_CPU_INTERRUPT_HANDLER that&= nbsp;is called
>
> --
> 2.35.1.windows.2
>
>
>
> -=3D-=3D-=3D-=3D-=3D-=3D
> Groups.io Links: You = receive all messages sent to this group.
> View/Reply Online (#89919)= : https://edk= 2.groups.io/g/devel/message/89919
> Mute This Topic: https://groups.io/mt/91231770= /1768734
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub&nbs= p;[jian.j.wang@intel.com]
> -=3D-=3D-=3D-=3D-=3D-=3D
>

--_000_DM4PR11MB64802A7F8CC323014B5E61B0FEA29DM4PR11MB6480namp_--