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:49 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=mu0kgiyE; 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=1654501669; x=1686037669; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=p2J0XpsFZqe5BHrIlRM6Z+1zfBnlGlXY7qP/G3WdrWU=; b=mu0kgiyERWY57LNtgsdeDHc/EdicpVcYB+s0xY7sG5gXoQctI8/6GaTi x2EXsIf8WzRDEe3JIFsnXOadDofeWrblgMFrdSrhA984VgBiEu7QyWLte a2825L3xUcV0Q+EWNwd8YZWTA6bk47mdQk93D+RW3lX8npFZ37R+4g0GL 6Me5bKcr8eGIa7zcZqs5e3nQ/L5GIpdRavNHa2Hq81c7EJgWa6YgTwugE cdkm34NF8QGc/D3wNvUYV/gGoRFZtQFEnTNCPAE1AON6/OSiX6756eY9D El2GsgS45GEmzerTm4+J+CTgq+6pU5Nzr/9jkohtlPjNMhNi+CYiEsSbc w==; X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="339836785" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="339836785" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 00:47:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="906430243" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by fmsmga005.fm.intel.com with ESMTP; 06 Jun 2022 00:47:37 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx606.amr.corp.intel.com (10.18.126.86) 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:37 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx608.amr.corp.intel.com (10.18.126.88) 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:37 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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:37 -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:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E2g85wg05QJZNLP3mhz2NyBHMVpnvA6gaZ8vVwtmkzo0+HepDZLa6c+puhrm6a8c3bmq4wQyCe25g7jSZp55eCtyxvqFKv/8uW8w/rliXEsuBKS94NqrPn0mpYFusHcoMeh1MUGQHRE/9FLkwq1gS/UMvLF9Pxe8tfAysV6lfv0zUXo4/5Fb7flH7MqKAXhHK3WEQ5BkRgrU9FqOwxV+oUKZVMzQYeZUzEFsHE3q3/+tzZzRwtqs8Xw87egIgrvVYaa7e0mM6dgQCzU2vN67Fb7u0G0gvlDiaeakC/+21qKpoIEUSARqC5gUmpgDevsVitbafqWBvQCBNsskqeyvgg== 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=x3qP5pyaH6rLbT63RUMEG8UoFH5sbkIxZfDmkQSrw00=; b=c3o6ZM2GSu5sK3Z+F+d6IcTsWPncxTG+DJuNWz1p3dUs7IzJK6U0h43A3Bvd2dO+ZmPVTtjVW+UqkvhtmyfnEU2bZu6o7NVU/yxkAZCfFNFJYvO538/Hpr9u91dHNimWkuL35dkRH9sBNAi1V0oepo2buXL4XVPVaExsUAXRqGor30kePlGdL7sFPKMXpTrAlHfj6Pc3aRFXEOVfKdKP1/BDipWKV8YrSZqPSwF/63oz7xJxWLzDqPUejLUYHQ2nrPfpM+BFpcFiH18PBKP+R0vwiRAYjIY0bAmqy17uq6+bwxtgR/RCSfownoYagJva/64aDqkJQOtrH3KD4In7Hw== 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:35 +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:35 +0000 From: "Dong, Eric" To: "Ni, Ray" , "devel@edk2.groups.io" CC: "Wang, Jian J" Subject: Re: [PATCH 5/5] CpuException: Add InitializeSeparateExceptionStacks Thread-Topic: [PATCH 5/5] CpuException: Add InitializeSeparateExceptionStacks Thread-Index: AQHYbFQtnVektXboUEGmMRkHW9szJq1CGq8Q Date: Mon, 6 Jun 2022 07:47:34 +0000 Message-ID: References: <20220520141549.108-1-ray.ni@intel.com> <20220520141549.108-6-ray.ni@intel.com> In-Reply-To: <20220520141549.108-6-ray.ni@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-office365-filtering-correlation-id: caa97e85-b65a-4437-0213-08da4790d1f4 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: rFyFCQyjh+au2k/ljqNotn8ogwVZ70Zfdo7TvxXNQJSLIaWbbfboobgTiMEj7eeXh2J+L9ESLgWHA+z8YB2mBQ14y8xiSfjd9kuhPBRKxCJAMcSN88gX6o7mPQ7b2I3wpFknQ5LDIXrySlYXzUsI4IWnktyLEYt3np5pyOyFDeBjg1dKqCil68VYMuvt8RITns0XiNjp84Jnvag0S2Y70ZT5PRO3ddRSB3okvT+Q+YgDk+azqDKdfYAlpjQHESm5Eyr4Yqi0NQmFXVcAYU9SqeF1kiw4nVHDju+s4HsJXPrrtvq+CYvD6qMCBhZnC+ne6X3dEg3lZP39bgFGfsUhNb8CVPKT+GLNcryjvDDGyNr8HsZ9G8Izpyo4zQ3nEejuOwzY8BNYfJ30UqSJF9BbyJ6TJ8YdUtwc7W9JjabvLB6/fxrQiztQm5KvUeueFvWE2cemQAe2L50AAHDVwx9vB/wfyKqxJ/USlw577JvpEHsASh+LCFl7AhYt+Z90LMThnqkoEajwvjwvSf+NPMegOKRi58l0ZK3ZPcXlr/NmisgHSGa/4EjVFD2BxFvRTRVZ28CdSJe78dP/mpxrLM82Qmua2Ux3HJbXsBlWk67z2885HsLufuow3Hb/GJ3XngH4m6uyTB4M6VkpV7pBUZ/wikonKDXXlfBxdVRNpufUfHXQJsNNNSLPdIUqYA9yu8ij0XriiWICnawyQ3dSCPhDKg== 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)(4326008)(66556008)(66476007)(8676002)(110136005)(38100700002)(83380400001)(107886003)(19627235002)(186003)(66946007)(316002)(86362001)(52536014)(8936002)(508600001)(33656002)(71200400001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?hwYZR2EfNY9ok9o0Tb5yrodgyHy//TlEOp3KPxBdlY1W/VY7MRvuJe4BZG7J?= =?us-ascii?Q?u+ZHDayzSFVtppIBuwMdNoNPshvsaI2lqjVo2ZG00z6Xd8nIxK+LyDQootBL?= =?us-ascii?Q?fytqNZ9h6RkWkgZYF6U7+avgFg1NNOmd20cCK2atnhvZNwPkecX+Pr7jT69d?= =?us-ascii?Q?LWHsV/ESCR19Wt694/9zMCj3l7drbWUtsdHvSRuyHYaFDWeKbP+t/gqf1T07?= =?us-ascii?Q?YxNcAn6PaTyYa1PIQvK+OxbNJYzkWmFTqo6N5QVjnp7WvMm54Olf4VQuUTy2?= =?us-ascii?Q?yymc3ti9aw3XkFDltgrSwPlSJgwrvU2T9XVGLdj6ylW09cMevJMWxwytJ+DH?= =?us-ascii?Q?llQnZPwURvYVHXWwfrtZxnqocmBTU5VsyIwdEafSABp6sgAZkk52oDgE17uZ?= =?us-ascii?Q?rFLlXMjyhgLnTcwDUt4zpflDZZ1J3GXf/NALbXzZg1c6rDwjtXI2UDVzF09f?= =?us-ascii?Q?QALR91/3ZoK6IBp2WFCyXfhnTlRQ2PgUGA6FywWn4EAgG9u5PT1AKfoFrVJu?= =?us-ascii?Q?DTr8ReMForTVFhC/9ASQia1MO+u5Ko8vZj6qqCEyie+qn9/konlu8k1jeaer?= =?us-ascii?Q?hbZfq76RabxEwToaLfFWkQkTrwpMIl4MI2MgJFwQkL00KGH8DLmzsWnSS/+P?= =?us-ascii?Q?aW+buLlgkNfEzW3q2r3DvYBg1BDeidXeU0s7+UipF8Qg3xKRpZKDJKbuAxgo?= =?us-ascii?Q?9v8mGp1I6hN0ydP4A+IX3ew3BDHRSy780gIO/Qsmn8fXVA5jjbosX/62cU9h?= =?us-ascii?Q?a37nfp7uvRsTt8uCymtHeqMIkgAYWQPUrmICLFxhRm3QhvCyJNxFW8tI25Bg?= =?us-ascii?Q?UCFfSSP+5o3r7SUU21Eav8bStWmoR5o8BU/lOudbp9v+xtDb8d8ENSzYVdOB?= =?us-ascii?Q?bmrxCEPNRC+gVW5dhSHMdyPqJsm8U+oWrmwyBo4sWtDYIrScHF0VMMGSoBy5?= =?us-ascii?Q?n3toNnMFLboZj74qCU0tcEJZ7s2XI3CZnVzD3RGYDQ9MaBdj7viwa3N7fGKN?= =?us-ascii?Q?H2TpkNiOZ1X1BUzv/E5b3hGLMg6+GTKEpYVHUYBttsLE6jWYXmft3l8watof?= =?us-ascii?Q?BmRGc/YimglwooFuEGTmd1eoDarQRXcASqd/vffkQLZERYB5VXSsfdKWBORT?= =?us-ascii?Q?TC0K36CdAUT+sqA/B6uVUSdrjKyt3eBYXWmYzpE/39d9MjAmwPsnXB1shVVA?= =?us-ascii?Q?Tj1L2cBzibsW6kaiyk0bkxPrK81BLZEr3BgAXJRGFHhVmqk668DQ6piSt77M?= =?us-ascii?Q?Ga2USPdaCxUN2SYl+SV94cxv23O6OhZxusEQVl3BmjxXQ1eWqTPM+cQMHXm7?= =?us-ascii?Q?QAN0gVoSi7LA4o79k/2wDn731hbIDzum6mqrSh3F7u/Fc4+92f1rbu7QoY6Y?= =?us-ascii?Q?IjqF8rX8UYh8EYXlNgooU3KxUoMgkdZUP7g38P99m3tEybj3B5juoWi1G4Kj?= =?us-ascii?Q?pmBMC3/ObIyawAWaRiwWImn4kOZ4sMqEPYByCG5d+RGNfiKidNTLgM43HsUn?= =?us-ascii?Q?SHHtOrjYn9PCfx/ZYYYzSw4QoqowY2BfbdLpUlERRix8IxxzMyz/WyhUI4VM?= =?us-ascii?Q?IKUNWWB193wINVphsZZtt/6g+ylKJIcdza7vD7cNXqXoo/HS66k8fGhI7G5f?= =?us-ascii?Q?aAJIlcB7PSZe+e2p1SBk4crijPi0w83RIW6p284UjXwk02/UcjmnXzm+Bjsh?= =?us-ascii?Q?NDgJEB3DJzR/sCkBO1QgGv6Nxiyrw8ZIJ7cmv9k0qe6+BWWbHC0FvC4Cj9IV?= =?us-ascii?Q?7y27zCr8gw=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: caa97e85-b65a-4437-0213-08da4790d1f4 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jun 2022 07:47:34.9482 (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: so/chrhOBg8Fh2NOTwY0Gh/plKDi2kXFXLFjsQ/zoMF+wpoEos+TrWteu5xiUmEtokLMXG0OSwptrsi56PG6MQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2320 Return-Path: eric.dong@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Acked-by: Eric Dong -----Original Message----- From: Ni, Ray =20 Sent: Friday, May 20, 2022 10:16 PM To: devel@edk2.groups.io Cc: Dong, Eric ; Wang, Jian J Subject: [PATCH 5/5] CpuException: Add InitializeSeparateExceptionStacks Today InitializeCpuExceptionHandlersEx is called from three modules: 1. DxeCore (links to DxeCpuExceptionHandlerLib) DxeCore expects it initializes the IDT entries as well as assigning separate stacks for #DF and #PF. 2. CpuMpPei (links to PeiCpuExceptionHandlerLib) and CpuDxe (links to DxeCpuExceptionHandlerLib) It's called for each thread for only assigning separate stacks for #DF and #PF. The IDT entries initialization is skipped because caller sets InitData->X64.InitDefaultHandlers to FALSE. Additionally, SecPeiCpuExceptionHandlerLib, SmmCpuExceptionHandlerLib also = implement such API and the behavior of the API is simply to initialize IDT = entries only. Because it mixes the IDT entries initialization and separate stacks assignm= ent for certain exception handlers together, in order to know whether the f= unction call only initializes IDT entries, or assigns stacks, we need to ch= eck: 1. value of InitData->X64.InitDefaultHandlers 2. library instance This patch cleans up the code to separate the stack assignment to a new API= : InitializeSeparateExceptionStacks(). Only when caller calls the new API, the separate stacks are assigned. With this change, the SecPei and Smm instance can return unsupported which = gives caller a very clear status. The old API InitializeCpuExceptionHandlersEx() is removed in this patch. Because no platform module is consuming the old API, the impact is none. Signed-off-by: Ray Ni Cc: Eric Dong Cc: Jian J Wang --- MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 2 +- .../Include/Library/CpuExceptionHandlerLib.h | 24 ++--- .../CpuExceptionHandlerLibNull.c | 26 ++---- UefiCpuPkg/CpuDxe/CpuMp.c | 6 +- UefiCpuPkg/CpuMpPei/CpuMpPei.c | 4 +- .../CpuExceptionHandlerLib/DxeException.c | 91 ++++++------------- .../CpuExceptionHandlerLib/PeiCpuException.c | 51 ++--------- .../SecPeiCpuException.c | 27 ++---- .../CpuExceptionHandlerLib/SmmException.c | 27 ++---- 9 files changed, 74 insertions(+), 184 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dx= e/DxeMain/DxeMain.c index 2c27fc0695..83f49d7c00 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -253,7 +253,7 @@ DxeMain ( VectorInfoList =3D (EFI_VECTOR_HANDOFF_INFO *)(GET_GUID_HOB_DATA (Guid= Hob)); } - Status =3D InitializeCpuExceptionHandlersEx (VectorInfoList, = NULL);+ Status =3D InitializeCpuExceptionHandlers (VectorInfoList); ASSE= RT_EFI_ERROR (Status); //diff --git a/MdeModulePkg/Include/Library/CpuEx= ceptionHandlerLib.h b/MdeModulePkg/Include/Library/CpuExceptionHandlerLib.h index d4649bebe1..9a495081f7 100644 --- a/MdeModulePkg/Include/Library/CpuExceptionHandlerLib.h +++ b/MdeModulePkg/Include/Library/CpuExceptionHandlerLib.h @@ -103,32 +103,20 @@ InitializeCpuExceptionHandlers ( ); /**- Initializes all CPU exceptions entries with optional extra ini= tializations.+ Setup separate stacks for certain exception handlers. - By= default, this method should include all functionalities implemented by- I= nitializeCpuExceptionHandlers(), plus extra initialization works, if any.- = This could be done by calling InitializeCpuExceptionHandlers() directly- = in this method besides the extra works.+ InitData is optional and processo= r arch dependent. - InitData is optional and its use and content are proce= ssor arch dependent.- The typical usage of it is to convey resources which= have to be reserved- elsewhere and are necessary for the extra initializa= tions of exception.+ @param[in] InitData Pointer to data optional fo= r information about how+ to assign stacks for ce= rtain exception handlers. - @param[in] VectorInfo Pointer to reserved = vector list.- @param[in] InitData Pointer to data optional for extra= initializations- of exception.-- @retval EFI_S= UCCESS The exceptions have been successfully- = initialized.- @retval EFI_INVALID_PARAMETER VectorInfo o= r InitData contains invalid- content.+ @r= etval EFI_SUCCESS The stacks are assigned successfully. @retv= al EFI_UNSUPPORTED This function is not supported. **/ EFI_STATUS = EFIAPI-InitializeCpuExceptionHandlersEx (- IN EFI_VECTOR_HANDOFF_INFO *Ve= ctorInfo OPTIONAL,+InitializeSeparateExceptionStacks ( IN CPU_EXCEPTION_I= NIT_DATA *InitData OPTIONAL ); diff --git a/MdeModulePkg/Library/CpuExce= ptionHandlerLibNull/CpuExceptionHandlerLibNull.c b/MdeModulePkg/Library/Cpu= ExceptionHandlerLibNull/CpuExceptionHandlerLibNull.c index 54f38788fe..8aeedcb4d1 100644 --- a/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLi= bNull.c +++ b/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandle +++ rLibNull.c @@ -82,34 +82,22 @@ DumpCpuContext ( } /**- Initializes all CPU exceptions entries with optional extra initia= lizations.+ Setup separate stacks for certain exception handlers. - By de= fault, this method should include all functionalities implemented by- Init= ializeCpuExceptionHandlers(), plus extra initialization works, if any.- Th= is could be done by calling InitializeCpuExceptionHandlers() directly- in = this method besides the extra works.+ InitData is optional and processor a= rch dependent. - InitData is optional and its use and content are processo= r arch dependent.- The typical usage of it is to convey resources which ha= ve to be reserved- elsewhere and are necessary for the extra initializatio= ns of exception.+ @param[in] InitData Pointer to data optional for i= nformation about how+ to assign stacks for certa= in exception handlers. - @param[in] VectorInfo Pointer to reserved vec= tor list.- @param[in] InitData Pointer to data optional for extra in= itializations- of exception.-- @retval EFI_SUCC= ESS The exceptions have been successfully- = initialized.- @retval EFI_INVALID_PARAMETER VectorInfo or I= nitData contains invalid- content.+ @retv= al EFI_SUCCESS The stacks are assigned successfully. @retval = EFI_UNSUPPORTED This function is not supported. **/ EFI_STATUS EFI= API-InitializeCpuExceptionHandlersEx (- IN EFI_VECTOR_HANDOFF_INFO *Vecto= rInfo OPTIONAL,+InitializeSeparateExceptionStacks ( IN CPU_EXCEPTION_INIT= _DATA *InitData OPTIONAL ) {- return InitializeCpuExceptionHandlers (Ve= ctorInfo);+ return EFI_UNSUPPORTED; }diff --git a/UefiCpuPkg/CpuDxe/CpuMp.= c b/UefiCpuPkg/CpuDxe/CpuMp.c index 1f218367b3..e385f585c7 100644 --- a/UefiCpuPkg/CpuDxe/CpuMp.c +++ b/UefiCpuPkg/CpuDxe/CpuMp.c @@ -1,7 +1,7 @@ /** @file CPU DXE Module to produce CPU MP Protocol. - Copyright (c) 20= 08 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2008= - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identif= ier: BSD-2-Clause-Patent **/@@ -617,7 +617,7 @@ GetGdtr ( /** Initializes CPU exceptions handlers for the sake of stack switch req= uirement. - This function is a wrapper of InitializeCpuExceptionHandlersEx= . It's mainly+ This function is a wrapper of InitializeSeparateExceptionSt= acks. It's mainly for the sake of AP's init because of EFI_AP_PROCEDURE A= PI requirement. @param[in,out] Buffer The pointer to private data buffe= r.@@ -641,7 +641,7 @@ InitializeExceptionStackSwitchHandlers ( AsmReadIdtr (&Idtr); EssData->Ia32.IdtTable =3D (VOID *)Idtr.Base;= EssData->Ia32.IdtTableSize =3D Idtr.Limit + 1;- Status = =3D InitializeCpuExceptionHandlersEx (NULL, EssData);+ Status = =3D InitializeSeparateExceptionStacks (EssData); ASSERT_EFI_E= RROR (Status); } diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/C= puMpPei/CpuMpPei.c index 1e68c91d95..d4786979fa 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -432,7 +432,7 @@ GetGdtr ( /** Initializes CPU exceptions handlers for the sake of stack switch req= uirement. - This function is a wrapper of InitializeCpuExceptionHandlersEx= . It's mainly+ This function is a wrapper of InitializeSeparateExceptionSt= acks. It's mainly for the sake of AP's init because of EFI_AP_PROCEDURE A= PI requirement. @param[in,out] Buffer The pointer to private data buffe= r.@@ -456,7 +456,7 @@ InitializeExceptionStackSwitchHandlers ( AsmReadIdtr (&Idtr); EssData->Ia32.IdtTable =3D (VOID *)Idtr.Base;= EssData->Ia32.IdtTableSize =3D Idtr.Limit + 1;- Status = =3D InitializeCpuExceptionHandlersEx (NULL, EssData);+ Status = =3D InitializeSeparateExceptionStacks (EssData); ASSERT_EFI_E= RROR (Status); } diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Dxe= Exception.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c index c7c1fe31d2..e62bb5e6c0 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c @@ -103,82 +103,49 @@ RegisterCpuInterruptHandler ( } /**- Initializes CPU exceptions entries and setup stack switch for giv= en exceptions.+ Setup separate stacks for certain exception handlers. - T= his method will call InitializeCpuExceptionHandlers() to setup default- ex= ception handlers unless indicated not to do it explicitly.+ InitData is op= tional and processor arch dependent. - If InitData is passed with NULL, th= is method will use the resource reserved- by global variables to initializ= e it; Otherwise it will use data in InitData- to setup stack switch. This = is for the different use cases in DxeCore and- Cpu MP exception initializa= tion.+ @param[in] InitData Pointer to data optional for information = about how+ to assign stacks for certain exceptio= n handlers. - @param[in] VectorInfo Pointer to reserved vector list.- = @param[in] InitData Pointer to data required to setup stack switch f= or- given exceptions.-- @retval EFI_SUCCESS = The exceptions have been successfully- = initialized.- @retval EFI_INVALID_PARAMETER VectorInfo or InitData= contains invalid- content.+ @retval EFI_= SUCCESS The stacks are assigned successfully.+ @retval EFI_UNS= UPPORTED This function is not supported. **/ EFI_STATUS EFIAPI-Ini= tializeCpuExceptionHandlersEx (- IN EFI_VECTOR_HANDOFF_INFO *VectorInfo O= PTIONAL,+InitializeSeparateExceptionStacks ( IN CPU_EXCEPTION_INIT_DATA = *InitData OPTIONAL ) {- EFI_STATUS Status; CPU_EXCEPTION= _INIT_DATA EssData; IA32_DESCRIPTOR Idtr; IA32_DESCRIPTOR = Gdtr; - //- // To avoid repeat initialization of default handlers, = the caller should pass- // an extended init data with InitDefaultHandlers = set to FALSE. There's no- // need to call this method to just initialize d= efault handlers. Call non-ex- // version instead; or this method must be i= mplemented as a simple wrapper of- // non-ex version of it, if this versio= n has to be called.- //- if ((InitData =3D=3D NULL) || InitData->X64.Init= DefaultHandlers) {- Status =3D InitializeCpuExceptionHandlers (VectorInf= o);- } else {- Status =3D EFI_SUCCESS;- }-- if (!EFI_ERROR (Status)) = {- //- // Initializing stack switch is only necessary for Stack Guard= functionality.- //- if (PcdGetBool (PcdCpuStackGuard)) {- if (I= nitData =3D=3D NULL) {- SetMem (mNewGdt, sizeof (mNewGdt), 0);-- = AsmReadIdtr (&Idtr);- AsmReadGdtr (&Gdtr);-- EssData.X64.= Revision =3D CPU_EXCEPTION_INIT_DATA_REV;- EssData= .X64.KnownGoodStackTop =3D (UINTN)mNewStack + sizeof (mNewStack);-= EssData.X64.KnownGoodStackSize =3D CPU_KNOWN_GOOD_STACK_SIZ= E;- EssData.X64.StackSwitchExceptions =3D CPU_STACK_SWITCH_EXCE= PTION_LIST;- EssData.X64.StackSwitchExceptionNumber =3D CPU_STACK_SW= ITCH_EXCEPTION_NUMBER;- EssData.X64.IdtTable =3D (= VOID *)Idtr.Base;- EssData.X64.IdtTableSize =3D Idtr.L= imit + 1;- EssData.X64.GdtTable =3D mNewGdt;- = EssData.X64.GdtTableSize =3D sizeof (mNewGdt);- Ess= Data.X64.ExceptionTssDesc =3D mNewGdt + Gdtr.Limit + 1;- E= ssData.X64.ExceptionTssDescSize =3D CPU_TSS_DESC_SIZE;- EssDat= a.X64.ExceptionTss =3D mNewGdt + Gdtr.Limit + 1 + CPU_TSS_DES= C_SIZE;- EssData.X64.ExceptionTssSize =3D CPU_TSS_SIZE;-- = InitData =3D &EssData;- }-- Status =3D ArchSetupExceptionS= tack (InitData);- }+ if (InitData =3D=3D NULL) {+ SetMem (mNewGdt, s= izeof (mNewGdt), 0);++ AsmReadIdtr (&Idtr);+ AsmReadGdtr (&Gdtr);++ = EssData.X64.Revision =3D CPU_EXCEPTION_INIT_DATA_REV;+ = EssData.X64.KnownGoodStackTop =3D (UINTN)mNewStack + sizeof (mN= ewStack);+ EssData.X64.KnownGoodStackSize =3D CPU_KNOWN_GOOD_STA= CK_SIZE;+ EssData.X64.StackSwitchExceptions =3D CPU_STACK_SWITCH_EX= CEPTION_LIST;+ EssData.X64.StackSwitchExceptionNumber =3D CPU_STACK_SWIT= CH_EXCEPTION_NUMBER;+ EssData.X64.IdtTable =3D (VOID *= )Idtr.Base;+ EssData.X64.IdtTableSize =3D Idtr.Limit + 1;+= EssData.X64.GdtTable =3D mNewGdt;+ EssData.X64.Gdt= TableSize =3D sizeof (mNewGdt);+ EssData.X64.ExceptionTssD= esc =3D mNewGdt + Gdtr.Limit + 1;+ EssData.X64.ExceptionTssDes= cSize =3D CPU_TSS_DESC_SIZE;+ EssData.X64.ExceptionTss = =3D mNewGdt + Gdtr.Limit + 1 + CPU_TSS_DESC_SIZE;+ EssData.X64.Except= ionTssSize =3D CPU_TSS_SIZE;++ InitData =3D &EssData; } - r= eturn Status;+ return ArchSetupExceptionStack (InitData); }diff --git a/Ue= fiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c b/UefiCpuPkg/Libr= ary/CpuExceptionHandlerLib/PeiCpuException.c index 1ae611c75e..494c2ab433 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c @@ -150,57 +150,26 @@ InitializeCpuExceptionHandlers ( } /**- Initializes all CPU exceptions entries with optional extra initia= lizations.+ Setup separate stacks for certain exception handlers. - By de= fault, this method should include all functionalities implemented by- Init= ializeCpuExceptionHandlers(), plus extra initialization works, if any.- Th= is could be done by calling InitializeCpuExceptionHandlers() directly- in = this method besides the extra works.+ InitData is optional and processor a= rch dependent. - InitData is optional and its use and content are processo= r arch dependent.- The typical usage of it is to convey resources which ha= ve to be reserved- elsewhere and are necessary for the extra initializatio= ns of exception.+ @param[in] InitData Pointer to data optional for i= nformation about how+ to assign stacks for certa= in exception handlers. - @param[in] VectorInfo Pointer to reserved vec= tor list.- @param[in] InitData Pointer to data optional for extra in= itializations- of exception.-- @retval EFI_SUCC= ESS The exceptions have been successfully- = initialized.- @retval EFI_INVALID_PARAMETER VectorInfo or I= nitData contains invalid- content.+ @retv= al EFI_SUCCESS The stacks are assigned successfully.+ @retval = EFI_UNSUPPORTED This function is not supported. **/ EFI_STATUS EFI= API-InitializeCpuExceptionHandlersEx (- IN EFI_VECTOR_HANDOFF_INFO *Vecto= rInfo OPTIONAL,+InitializeSeparateExceptionStacks ( IN CPU_EXCEPTION_INIT= _DATA *InitData OPTIONAL ) {- EFI_STATUS Status;-- //- // To avoid r= epeat initialization of default handlers, the caller should pass- // an ex= tended init data with InitDefaultHandlers set to FALSE. There's no- // nee= d to call this method to just initialize default handlers. Call non-ex- //= version instead; or this method must be implemented as a simple wrapper of= - // non-ex version of it, if this version has to be called.- //- if ((I= nitData =3D=3D NULL) || InitData->Ia32.InitDefaultHandlers) {- Status = =3D InitializeCpuExceptionHandlers (VectorInfo);- } else {- Status =3D = EFI_SUCCESS;- }-- if (!EFI_ERROR (Status)) {- //- // Initializing s= tack switch is only necessary for Stack Guard functionality.- //- if = (PcdGetBool (PcdCpuStackGuard) && (InitData !=3D NULL)) {- Status =3D = ArchSetupExceptionStack (InitData);- }+ if (InitData =3D=3D NULL) {+ = return EFI_UNSUPPORTED; } - return Status;+ return ArchSetupExceptionS= tack (InitData); }diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Se= cPeiCpuException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExc= eption.c index e894ead612..4313cc5582 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c @@ -200,33 +200,22 @@ RegisterCpuInterruptHandler ( } /**- Initializes all CPU exceptions entries with optional extra initia= lizations.+ Setup separate stacks for certain exception handlers. - By de= fault, this method should include all functionalities implemented by- Init= ializeCpuExceptionHandlers(), plus extra initialization works, if any.- Th= is could be done by calling InitializeCpuExceptionHandlers() directly- in = this method besides the extra works.+ InitData is optional and processor a= rch dependent. - InitData is optional and its use and content are processo= r arch dependent.- The typical usage of it is to convey resources which ha= ve to be reserved- elsewhere and are necessary for the extra initializatio= ns of exception.+ @param[in] InitData Pointer to data optional for i= nformation about how+ to assign stacks for certa= in exception handlers. - @param[in] VectorInfo Pointer to reserved vec= tor list.- @param[in] InitData Pointer to data optional for extra in= itializations- of exception.-- @retval EFI_SUCC= ESS The exceptions have been successfully- = initialized.- @retval EFI_INVALID_PARAMETER VectorInfo or I= nitData contains invalid- content.+ @retv= al EFI_SUCCESS The stacks are assigned successfully.+ @retval = EFI_UNSUPPORTED This function is not supported. **/ EFI_STATUS EFI= API-InitializeCpuExceptionHandlersEx (- IN EFI_VECTOR_HANDOFF_INFO *Vecto= rInfo OPTIONAL,+InitializeSeparateExceptionStacks ( IN CPU_EXCEPTION_INIT= _DATA *InitData OPTIONAL ) {- return InitializeCpuExceptionHandlers (Ve= ctorInfo);+ return EFI_UNSUPPORTED; }diff --git a/UefiCpuPkg/Library/CpuEx= ceptionHandlerLib/SmmException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLi= b/SmmException.c index ec643556c7..1c97dab926 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c @@ -96,33 +96,22 @@ RegisterCpuInterruptHandler ( } /**- Initializes all CPU exceptions entries with optional extra initia= lizations.+ Setup separate stacks for certain exception handlers. - By de= fault, this method should include all functionalities implemented by- Init= ializeCpuExceptionHandlers(), plus extra initialization works, if any.- Th= is could be done by calling InitializeCpuExceptionHandlers() directly- in = this method besides the extra works.+ InitData is optional and processor a= rch dependent. - InitData is optional and its use and content are processo= r arch dependent.- The typical usage of it is to convey resources which ha= ve to be reserved- elsewhere and are necessary for the extra initializatio= ns of exception.+ @param[in] InitData Pointer to data optional for i= nformation about how+ to assign stacks for certa= in exception handlers. - @param[in] VectorInfo Pointer to reserved vec= tor list.- @param[in] InitData Pointer to data optional for extra in= itializations- of exception.-- @retval EFI_SUCC= ESS The exceptions have been successfully- = initialized.- @retval EFI_INVALID_PARAMETER VectorInfo or I= nitData contains invalid- content.+ @retv= al EFI_SUCCESS The stacks are assigned successfully.+ @retval = EFI_UNSUPPORTED This function is not supported. **/ EFI_STATUS EFI= API-InitializeCpuExceptionHandlersEx (- IN EFI_VECTOR_HANDOFF_INFO *Vecto= rInfo OPTIONAL,+InitializeSeparateExceptionStacks ( IN CPU_EXCEPTION_INIT= _DATA *InitData OPTIONAL ) {- return InitializeCpuExceptionHandlers (Ve= ctorInfo);+ return EFI_UNSUPPORTED; }--=20 2.35.1.windows.2