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.web11.17707.1653235517132917561 for ; Sun, 22 May 2022 09:05:17 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=ACaLT3IL; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: jian.j.wang@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653235517; x=1684771517; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=yO9qN0pU9BaP5AjbdvHkHEpvMgCFhyz6Mch3QMFz6s0=; b=ACaLT3IL39o9HEoUJFCQLPzrqz3AxAAJ0xPD3Y1I1l8vodqPok5rrQdu kyiS7WhSgT4PGfjf+eY3Z6yK1MfcAQQdrFef+TYqeMrdVf4ATcxuuovqU pR/tDaWtsbC5MtuwTYQ8Z7AaeX41hRHmTYKSBowdAsrJvzT+MY0JD8hY3 fgj8gHEgHgEVWVAvLxSIjpKVu58O7wKle2uTfXSbd5aeDlHfIjqJhkN8H 9TEcdaB+lZse00owghrg+A73YUb6PS+U8P+r8Zq6BpENJT64atZX2ljMi ue28irGEXc7Sg5VZQjODrwBkIGE/Ez6kDzMVGGoImKgi4Tfmy8JUjSgdR Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10355"; a="336068829" X-IronPort-AV: E=Sophos;i="5.91,244,1647327600"; d="scan'208";a="336068829" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2022 09:05:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,244,1647327600"; d="scan'208";a="571667432" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga007.jf.intel.com with ESMTP; 22 May 2022 09:05:16 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) 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; Sun, 22 May 2022 09:05:15 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) 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 via Frontend Transport; Sun, 22 May 2022 09:05:15 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.173) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Sun, 22 May 2022 09:05:15 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZeP5I+qbh4l6PHfbA1rZ+oPYLfnDcbb9ADMm/Yze3Is0/FI7nzhI66JSU6tZlnAtJ7SVFFyzm6CGBmnq8itBWnRXbx2ar0KFT9igFxkIcOVq7m5DaTjwHKAeygM8rnTuz9KULsCXHKiy0ZRUduWReZG0AG+bptERHJwYa7DXQng0AeVIO3eBfgkfDj3hBTMap5xRCxCpqumjvi0atsbZeiVWX3cWoQ1KCke8+mVc1xsBo7+4CZs9ZHweimIHauuHo7K1aAh2hSqzJaG8R9gPHDl9kRmanqDOs7mx+briYDkrN3u1GCSO44unSCQEhJ6xD2Lmh9U6uYwa4pElG8xL4A== 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=mV1M7qJYlqOrZDrNaUCB8L6HXG/DxkEDloCv2mATN5g=; b=jJR/a3rZqd9N7DLRtfdmh5mM/pRhAecxWzI2U1li00/L2EAlNcfAmDhoJwGfwTLk0JLkmPmpP0rqEkYbkAt2gg9uKogKXOqNN3QaxvPB4zQCm8SooifxSKt1Fr3tXHMOfG4rVv8+UDPDQORdBvQ9ULvLQksvf/835P9deTtAeaRaepQMoF+uFrVYZmvdN2jEfLGH+bljx3rzyc+3G50jmSefJhUxq6mpySlOju6ze1rkD23YDppu8Vu7cXJCqhincdiwLTB6Mb+t7dBtwvFhv4bPDt1NXWl9WsBIZVu4lmiGR1/1ezhk5VXhQMhRJz393eNiSYI/+lieAeXeopUYrQ== 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 CO1PR11MB4945.namprd11.prod.outlook.com (2603:10b6:303:9c::8) by BN9PR11MB5545.namprd11.prod.outlook.com (2603:10b6:408:102::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.22; Sun, 22 May 2022 16:05:13 +0000 Received: from CO1PR11MB4945.namprd11.prod.outlook.com ([fe80::a420:db2c:31db:7906]) by CO1PR11MB4945.namprd11.prod.outlook.com ([fe80::a420:db2c:31db:7906%9]) with mapi id 15.20.5273.022; Sun, 22 May 2022 16:05:13 +0000 From: "Wang, Jian J" To: "Ni, Ray" , "devel@edk2.groups.io" CC: "Dong, Eric" Subject: Re: [PATCH 5/5] CpuException: Add InitializeSeparateExceptionStacks Thread-Topic: [PATCH 5/5] CpuException: Add InitializeSeparateExceptionStacks Thread-Index: AQHYbFQuAvNKfnIXIE2OXk4YWk5hBa0rErpQ Date: Sun, 22 May 2022 16:05:13 +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: dlp-reaction: no-action dlp-version: 11.6.401.20 dlp-product: dlpe-windows 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: 7885037a-adb7-41a1-e714-08da3c0cdad8 x-ms-traffictypediagnostic: BN9PR11MB5545: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: iHY+h9Jgmslo/3i/uluEYkXyJb07D69CwbTm9V3lpI+K/ElJJmALdyM3aTalXo8x6kt72MVtUwZe9baTBzcoHhygKSCfg2TETUhXYRE9z2ukXJi+TV8voZOE0TO4fRCxo+r1yuKMaxjlAl1fUbSY+gKuNLkl6eSzsurBWCW24O7ws9wFuOZP9CB1lGqLoww/VKrysLiaFhUJexK7LcHwnSymR5gfWZHK7+nKcO4RdyKdfXsWYppeWeG+ZRHy4V3Aadx5sXJI3xeLSrlNGw7OlLAHLWJa5+Fu1u8Jp0Ar3eLk8DTwL9R4d/K++18HMLzfUQs95yD7hyJYrEqJllIsfRyJaUcAzYU+9NKVwhyCtA+LrEXCy0lO51PlQvmIbYiRHFk7TMoFhPdOXH3WRa35MbdkqYHVrA45xfxsAOPC7hu209TGnb0ncTDPsTFY5JR6dFAXEmIikI6L5TbKoB3+fabnIvnMjFYtN+qd/Anj5lv0zXeFnUhElbmpYpUbFGNr7lRLl7vADO6P9xZdBwuUGHRxs6VKv42wvBSIpURSRVT6rWK3cdWLt0T4VVbX0ILxqbITH3TkBZF8sHb9tKnOjLmlUeD5MLsekc/SEaWP6DMF/hoGTtrJ8BrphwXuYcpZo/Wfemvwa7EbbSVRLjV3Gypb9s9GpAKw4fL/B33gmQBWqWsxvygJ35/FgqXdZTy25UjpiOjJUW+q6H31ddKjdA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR11MB4945.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(66946007)(64756008)(66446008)(66476007)(66556008)(38070700005)(38100700002)(316002)(107886003)(33656002)(8676002)(110136005)(19627235002)(76116006)(4326008)(82960400001)(122000001)(55016003)(83380400001)(508600001)(8936002)(9686003)(52536014)(30864003)(5660300002)(6506007)(71200400001)(2906002)(26005)(86362001)(186003)(7696005)(53546011)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?CQ1/9B6slRGDKmP3MuW2JTKxM2WI3n25DbSfcsFB719q0sZphalbqRli+qar?= =?us-ascii?Q?3044B+tsWIZNcU129Gq3SlJYrnI9ClssWXEuDKk3sTp7CvLgtZ+kqpylbMIt?= =?us-ascii?Q?EioeZMjwCrEuum5Rr+IkTpYQWwW1+4MtO6GJvmYW0eDVkiYRP5S6sVxCMz8f?= =?us-ascii?Q?xKdLGXFqLb8u4P9io/jfrOFLxQLM7xfzOblGUI+/pFxu2hqqnv9/ECnEKAOl?= =?us-ascii?Q?gyOWlTHNujQAmvAp+r0h3NiBBiMONxNKHmE/T8B78zDwesuJvhZW3Hk+A3JO?= =?us-ascii?Q?ia/m9/+eV1QJ/PkM1RtEghTEiZAw26uCsvSzmm67p2W0SzdkbwLQwr/kLaT3?= =?us-ascii?Q?3v78yWGV9T1TdgFnrBLSuNfMVKkJWzCbuk6E0P4gTDXvghBzXAGGzqXCTjFe?= =?us-ascii?Q?zPwjRIwC90bxXhUIpGyd5+qYfkIbnbfYiphSFRkG+jeQmamXIu3DCs09c4F6?= =?us-ascii?Q?rRJDrI6QiI+uclVRZtwSYWGHBjU+3P9QzH3G0aHCGTEyqcPc5DtpxUaRLB1L?= =?us-ascii?Q?avmKE88Grrfd80oWOvMCY2OScdr0sNyvwSsAoqWS3A3O350RtNFruqMuRIaP?= =?us-ascii?Q?bWJ9rcpdLEaULVBGRcNUbyM//Q3CWA+6/6nZHtP6AYA9dI5K0RsEyZ6/6u+z?= =?us-ascii?Q?YkJBwScVh1B7H62DWHw06XdWtkcRqkZR+NGCTiP1wH7gQu3tks5k3nj8QKUb?= =?us-ascii?Q?edGhZUjCRhvs/oQ27G49nfPLcahToZJyHMcjrVxBw15YdBaMktjGtWM+sLhr?= =?us-ascii?Q?sq85mZy3h3MYA1AKH04p2KP1MGghP1v8BNnTlfN/yLLx0KsPz0G25kba8OgQ?= =?us-ascii?Q?8NmvLmYrYPlG0MQ2hbFx+nJj8qHycL104G9RhkGVGJSfoy+rMGRaFrdLFULT?= =?us-ascii?Q?WH6PGy15nsJ7r61ZbfWWp+VRofsOFBRzEkRe+3EPwb1heZKqADJIOPmpaUr9?= =?us-ascii?Q?+e5U/QIXcJjBDby85JiyMD0y38dSDHXiSR2tWjviv6g4D/IfcQoLx2mNsp3a?= =?us-ascii?Q?nOPVi0IXUzk5F+zcsV0fcgfEsNPAQl4x/TIaC+5lWEE2TZLzsPZeTleRn0wu?= =?us-ascii?Q?8Qywqee5UjYAvB3nfMEcXkmCNcH6fNY6aOTu09vkVG5whaOg/juVCiL/BN18?= =?us-ascii?Q?45AXQIJ4ZCP9XfaXEJbANWCputRSenJkzhuSE6XjtpfLXEuBQB6XM9Ww4X5y?= =?us-ascii?Q?bX9/wVYJNme1i9uqakIoE72ItHC44x5LPcUCYRp14FfzhfG0HkG1p4XhTKi5?= =?us-ascii?Q?c3F0TDrCtgSnLBkLAWSPdlCB5tTUg8gwGVwBnsWr88nU1S4/bFtgz9NDta1E?= =?us-ascii?Q?D05TxVuHfm1J+mF0eHETY2Q0vsyqfSn5pZP12HahmFOr1+jdWNBWMH5ozEBG?= =?us-ascii?Q?Z2GC/DG8JvppppDGsKVZhFJk9L+8r35tBIPNKrHXbcZvfP8FnAnpVF0wUb4+?= =?us-ascii?Q?bAFI+lJGzB06rr7jxa79QtfOdxUSo1QEWGTWGm+lPWJFRp4Ny6/rTMS2qH40?= =?us-ascii?Q?ep3ahcNIaZBXx03airNt9jZlizpRD7kX80baTZk8k4cWbzcll31LHfLYTjPZ?= =?us-ascii?Q?NuHRV3qQSk03eENpatO+GlDcvmxwdDcX6YeapqJO73onzv3qkWHIMpU6hPZT?= =?us-ascii?Q?yPYWx1G/p7+FhLxKGaf9joEnANW2r/a6vPqCvrzoUjc9WeBm3+FnRvXkskjA?= =?us-ascii?Q?DouL6Vkc5HYjuOy1/KZUdh/Nw6ZKCavb5ujW9ikV49/v/dl40MGJdFH0vcwG?= =?us-ascii?Q?kv9uA2NVyw=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4945.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7885037a-adb7-41a1-e714-08da3c0cdad8 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 May 2022 16:05:13.4643 (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: Dt0uEeOrN9o+s6usGEvDx4sCUUUTfn7G6L/z6Dey36l++QuTDGSajk9nXFN/IAYxoKbwKRsvQOaZr7NO8CPpxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5545 Return-Path: jian.j.wang@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jian J Wang Regards, Jian > -----Original Message----- > From: Ni, Ray > 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 >=20 > 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. >=20 > Additionally, SecPeiCpuExceptionHandlerLib, SmmCpuExceptionHandlerLib > also implement such API and the behavior of the API is simply to initiali= ze > IDT entries only. >=20 > Because it mixes the IDT entries initialization and separate stacks > assignment for certain exception handlers together, in order to know > whether the function call only initializes IDT entries, or assigns stacks= , > we need to check: > 1. value of InitData->X64.InitDefaultHandlers > 2. library instance >=20 > This patch cleans up the code to separate the stack assignment to a new A= PI: > InitializeSeparateExceptionStacks(). >=20 > Only when caller calls the new API, the separate stacks are assigned. > With this change, the SecPei and Smm instance can return unsupported whic= h > gives caller a very clear status. >=20 > The old API InitializeCpuExceptionHandlersEx() is removed in this patch. > Because no platform module is consuming the old API, the impact is none. >=20 > 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(-) >=20 > diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c > b/MdeModulePkg/Core/Dxe/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 > (GuidHob)); >=20 > } >=20 >=20 >=20 > - Status =3D InitializeCpuExceptionHandlersEx (VectorInfoList, NULL); >=20 > + Status =3D InitializeCpuExceptionHandlers (VectorInfoList); >=20 > ASSERT_EFI_ERROR (Status); >=20 >=20 >=20 > // >=20 > diff --git a/MdeModulePkg/Include/Library/CpuExceptionHandlerLib.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 ( > ); >=20 >=20 >=20 > /** >=20 > - Initializes all CPU exceptions entries with optional extra initializat= ions. >=20 > + Setup separate stacks for certain exception handlers. >=20 >=20 >=20 > - By default, this method should include all functionalities implemented= by >=20 > - InitializeCpuExceptionHandlers(), plus extra initialization works, if = any. >=20 > - This could be done by calling InitializeCpuExceptionHandlers() directl= y >=20 > - in this method besides the extra works. >=20 > + InitData is optional and processor arch dependent. >=20 >=20 >=20 > - InitData is optional and its use and content are processor arch depend= ent. >=20 > - The typical usage of it is to convey resources which have to be reserv= ed >=20 > - elsewhere and are necessary for the extra initializations of exception= . >=20 > + @param[in] InitData Pointer to data optional for information abo= ut how >=20 > + to assign stacks for certain exception handl= ers. >=20 >=20 >=20 > - @param[in] VectorInfo Pointer to reserved vector list. >=20 > - @param[in] InitData Pointer to data optional for extra initializ= ations >=20 > - of exception. >=20 > - >=20 > - @retval EFI_SUCCESS The exceptions have been successfully >=20 > - initialized. >=20 > - @retval EFI_INVALID_PARAMETER VectorInfo or InitData contains invali= d >=20 > - content. >=20 > + @retval EFI_SUCCESS The stacks are assigned successfully. >=20 > @retval EFI_UNSUPPORTED This function is not supported. >=20 >=20 >=20 > **/ >=20 > EFI_STATUS >=20 > EFIAPI >=20 > -InitializeCpuExceptionHandlersEx ( >=20 > - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL, >=20 > +InitializeSeparateExceptionStacks ( >=20 > IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL >=20 > ); >=20 >=20 >=20 > diff --git > a/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLib > Null.c > b/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLib > Null.c > index 54f38788fe..8aeedcb4d1 100644 > --- > a/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLib > Null.c > +++ > b/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLib > Null.c > @@ -82,34 +82,22 @@ DumpCpuContext ( > } >=20 >=20 >=20 > /** >=20 > - Initializes all CPU exceptions entries with optional extra initializat= ions. >=20 > + Setup separate stacks for certain exception handlers. >=20 >=20 >=20 > - By default, this method should include all functionalities implemented= by >=20 > - InitializeCpuExceptionHandlers(), plus extra initialization works, if = any. >=20 > - This could be done by calling InitializeCpuExceptionHandlers() directl= y >=20 > - in this method besides the extra works. >=20 > + InitData is optional and processor arch dependent. >=20 >=20 >=20 > - InitData is optional and its use and content are processor arch depend= ent. >=20 > - The typical usage of it is to convey resources which have to be reserv= ed >=20 > - elsewhere and are necessary for the extra initializations of exception= . >=20 > + @param[in] InitData Pointer to data optional for information abo= ut how >=20 > + to assign stacks for certain exception handl= ers. >=20 >=20 >=20 > - @param[in] VectorInfo Pointer to reserved vector list. >=20 > - @param[in] InitData Pointer to data optional for extra initializ= ations >=20 > - of exception. >=20 > - >=20 > - @retval EFI_SUCCESS The exceptions have been successfully >=20 > - initialized. >=20 > - @retval EFI_INVALID_PARAMETER VectorInfo or InitData contains invali= d >=20 > - content. >=20 > + @retval EFI_SUCCESS The stacks are assigned successfully. >=20 > @retval EFI_UNSUPPORTED This function is not supported. >=20 >=20 >=20 > **/ >=20 > EFI_STATUS >=20 > EFIAPI >=20 > -InitializeCpuExceptionHandlersEx ( >=20 > - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL, >=20 > +InitializeSeparateExceptionStacks ( >=20 > IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL >=20 > ) >=20 > { >=20 > - return InitializeCpuExceptionHandlers (VectorInfo); >=20 > + return EFI_UNSUPPORTED; >=20 > } >=20 > 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 >=20 > CPU DXE Module to produce CPU MP Protocol. >=20 >=20 >=20 > - Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
>=20 > + Copyright (c) 2008 - 2022, Intel Corporation. All rights reserved.
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 >=20 >=20 > **/ >=20 > @@ -617,7 +617,7 @@ GetGdtr ( > /** >=20 > Initializes CPU exceptions handlers for the sake of stack switch requi= rement. >=20 >=20 >=20 > - This function is a wrapper of InitializeCpuExceptionHandlersEx. It's m= ainly >=20 > + This function is a wrapper of InitializeSeparateExceptionStacks. It's = mainly >=20 > for the sake of AP's init because of EFI_AP_PROCEDURE API requirement. >=20 >=20 >=20 > @param[in,out] Buffer The pointer to private data buffer. >=20 > @@ -641,7 +641,7 @@ InitializeExceptionStackSwitchHandlers ( > AsmReadIdtr (&Idtr); >=20 > EssData->Ia32.IdtTable =3D (VOID *)Idtr.Base; >=20 > EssData->Ia32.IdtTableSize =3D Idtr.Limit + 1; >=20 > - Status =3D InitializeCpuExceptionHandlersEx (NULL,= EssData); >=20 > + Status =3D InitializeSeparateExceptionStacks (EssD= ata); >=20 > ASSERT_EFI_ERROR (Status); >=20 > } >=20 >=20 >=20 > diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c > b/UefiCpuPkg/CpuMpPei/CpuMpPei.c > index 1e68c91d95..d4786979fa 100644 > --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c > +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c > @@ -432,7 +432,7 @@ GetGdtr ( > /** >=20 > Initializes CPU exceptions handlers for the sake of stack switch requi= rement. >=20 >=20 >=20 > - This function is a wrapper of InitializeCpuExceptionHandlersEx. It's m= ainly >=20 > + This function is a wrapper of InitializeSeparateExceptionStacks. It's = mainly >=20 > for the sake of AP's init because of EFI_AP_PROCEDURE API requirement. >=20 >=20 >=20 > @param[in,out] Buffer The pointer to private data buffer. >=20 > @@ -456,7 +456,7 @@ InitializeExceptionStackSwitchHandlers ( > AsmReadIdtr (&Idtr); >=20 > EssData->Ia32.IdtTable =3D (VOID *)Idtr.Base; >=20 > EssData->Ia32.IdtTableSize =3D Idtr.Limit + 1; >=20 > - Status =3D InitializeCpuExceptionHandlersEx (NULL,= EssData); >=20 > + Status =3D InitializeSeparateExceptionStacks (EssD= ata); >=20 > ASSERT_EFI_ERROR (Status); >=20 > } >=20 >=20 >=20 > diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.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 ( > } >=20 >=20 >=20 > /** >=20 > - Initializes CPU exceptions entries and setup stack switch for given ex= ceptions. >=20 > + Setup separate stacks for certain exception handlers. >=20 >=20 >=20 > - This method will call InitializeCpuExceptionHandlers() to setup defaul= t >=20 > - exception handlers unless indicated not to do it explicitly. >=20 > + InitData is optional and processor arch dependent. >=20 >=20 >=20 > - If InitData is passed with NULL, this method will use the resource res= erved >=20 > - by global variables to initialize it; Otherwise it will use data in In= itData >=20 > - to setup stack switch. This is for the different use cases in DxeCore = and >=20 > - Cpu MP exception initialization. >=20 > + @param[in] InitData Pointer to data optional for information abo= ut how >=20 > + to assign stacks for certain exception handl= ers. >=20 >=20 >=20 > - @param[in] VectorInfo Pointer to reserved vector list. >=20 > - @param[in] InitData Pointer to data required to setup stack swit= ch for >=20 > - given exceptions. >=20 > - >=20 > - @retval EFI_SUCCESS The exceptions have been successfully >=20 > - initialized. >=20 > - @retval EFI_INVALID_PARAMETER VectorInfo or InitData contains invali= d >=20 > - content. >=20 > + @retval EFI_SUCCESS The stacks are assigned successfully. >=20 > + @retval EFI_UNSUPPORTED This function is not supported. >=20 >=20 >=20 > **/ >=20 > EFI_STATUS >=20 > EFIAPI >=20 > -InitializeCpuExceptionHandlersEx ( >=20 > - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL, >=20 > +InitializeSeparateExceptionStacks ( >=20 > IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL >=20 > ) >=20 > { >=20 > - EFI_STATUS Status; >=20 > CPU_EXCEPTION_INIT_DATA EssData; >=20 > IA32_DESCRIPTOR Idtr; >=20 > IA32_DESCRIPTOR Gdtr; >=20 >=20 >=20 > - // >=20 > - // To avoid repeat initialization of default handlers, the caller shou= ld pass >=20 > - // an extended init data with InitDefaultHandlers set to FALSE. There'= s no >=20 > - // need to call this method to just initialize default handlers. Call = non-ex >=20 > - // version instead; or this method must be implemented as a simple wra= pper > of >=20 > - // non-ex version of it, if this version has to be called. >=20 > - // >=20 > - if ((InitData =3D=3D NULL) || InitData->X64.InitDefaultHandlers) { >=20 > - Status =3D InitializeCpuExceptionHandlers (VectorInfo); >=20 > - } else { >=20 > - Status =3D EFI_SUCCESS; >=20 > - } >=20 > - >=20 > - if (!EFI_ERROR (Status)) { >=20 > - // >=20 > - // Initializing stack switch is only necessary for Stack Guard funct= ionality. >=20 > - // >=20 > - if (PcdGetBool (PcdCpuStackGuard)) { >=20 > - if (InitData =3D=3D NULL) { >=20 > - SetMem (mNewGdt, sizeof (mNewGdt), 0); >=20 > - >=20 > - AsmReadIdtr (&Idtr); >=20 > - AsmReadGdtr (&Gdtr); >=20 > - >=20 > - EssData.X64.Revision =3D CPU_EXCEPTION_INIT_DA= TA_REV; >=20 > - EssData.X64.KnownGoodStackTop =3D (UINTN)mNewStack + si= zeof > (mNewStack); >=20 > - EssData.X64.KnownGoodStackSize =3D > CPU_KNOWN_GOOD_STACK_SIZE; >=20 > - EssData.X64.StackSwitchExceptions =3D > CPU_STACK_SWITCH_EXCEPTION_LIST; >=20 > - EssData.X64.StackSwitchExceptionNumber =3D > CPU_STACK_SWITCH_EXCEPTION_NUMBER; >=20 > - EssData.X64.IdtTable =3D (VOID *)Idtr.Base; >=20 > - EssData.X64.IdtTableSize =3D Idtr.Limit + 1; >=20 > - EssData.X64.GdtTable =3D mNewGdt; >=20 > - EssData.X64.GdtTableSize =3D sizeof (mNewGdt); >=20 > - EssData.X64.ExceptionTssDesc =3D mNewGdt + Gdtr.Limit = + 1; >=20 > - EssData.X64.ExceptionTssDescSize =3D CPU_TSS_DESC_SIZE; >=20 > - EssData.X64.ExceptionTss =3D mNewGdt + Gdtr.Limit = + 1 + > CPU_TSS_DESC_SIZE; >=20 > - EssData.X64.ExceptionTssSize =3D CPU_TSS_SIZE; >=20 > - >=20 > - InitData =3D &EssData; >=20 > - } >=20 > - >=20 > - Status =3D ArchSetupExceptionStack (InitData); >=20 > - } >=20 > + if (InitData =3D=3D NULL) { >=20 > + SetMem (mNewGdt, sizeof (mNewGdt), 0); >=20 > + >=20 > + AsmReadIdtr (&Idtr); >=20 > + AsmReadGdtr (&Gdtr); >=20 > + >=20 > + EssData.X64.Revision =3D CPU_EXCEPTION_INIT_DATA_R= EV; >=20 > + EssData.X64.KnownGoodStackTop =3D (UINTN)mNewStack + sizeof > (mNewStack); >=20 > + EssData.X64.KnownGoodStackSize =3D CPU_KNOWN_GOOD_STACK_SIZE= ; >=20 > + EssData.X64.StackSwitchExceptions =3D > CPU_STACK_SWITCH_EXCEPTION_LIST; >=20 > + EssData.X64.StackSwitchExceptionNumber =3D > CPU_STACK_SWITCH_EXCEPTION_NUMBER; >=20 > + EssData.X64.IdtTable =3D (VOID *)Idtr.Base; >=20 > + EssData.X64.IdtTableSize =3D Idtr.Limit + 1; >=20 > + EssData.X64.GdtTable =3D mNewGdt; >=20 > + EssData.X64.GdtTableSize =3D sizeof (mNewGdt); >=20 > + EssData.X64.ExceptionTssDesc =3D mNewGdt + Gdtr.Limit + 1; >=20 > + EssData.X64.ExceptionTssDescSize =3D CPU_TSS_DESC_SIZE; >=20 > + EssData.X64.ExceptionTss =3D mNewGdt + Gdtr.Limit + 1 = + > CPU_TSS_DESC_SIZE; >=20 > + EssData.X64.ExceptionTssSize =3D CPU_TSS_SIZE; >=20 > + >=20 > + InitData =3D &EssData; >=20 > } >=20 >=20 >=20 > - return Status; >=20 > + return ArchSetupExceptionStack (InitData); >=20 > } >=20 > diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c > index 1ae611c75e..494c2ab433 100644 > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c > @@ -150,57 +150,26 @@ InitializeCpuExceptionHandlers ( > } >=20 >=20 >=20 > /** >=20 > - Initializes all CPU exceptions entries with optional extra initializat= ions. >=20 > + Setup separate stacks for certain exception handlers. >=20 >=20 >=20 > - By default, this method should include all functionalities implemented= by >=20 > - InitializeCpuExceptionHandlers(), plus extra initialization works, if = any. >=20 > - This could be done by calling InitializeCpuExceptionHandlers() directl= y >=20 > - in this method besides the extra works. >=20 > + InitData is optional and processor arch dependent. >=20 >=20 >=20 > - InitData is optional and its use and content are processor arch depend= ent. >=20 > - The typical usage of it is to convey resources which have to be reserv= ed >=20 > - elsewhere and are necessary for the extra initializations of exception= . >=20 > + @param[in] InitData Pointer to data optional for information abo= ut how >=20 > + to assign stacks for certain exception handl= ers. >=20 >=20 >=20 > - @param[in] VectorInfo Pointer to reserved vector list. >=20 > - @param[in] InitData Pointer to data optional for extra initializ= ations >=20 > - of exception. >=20 > - >=20 > - @retval EFI_SUCCESS The exceptions have been successfully >=20 > - initialized. >=20 > - @retval EFI_INVALID_PARAMETER VectorInfo or InitData contains invali= d >=20 > - content. >=20 > + @retval EFI_SUCCESS The stacks are assigned successfully. >=20 > + @retval EFI_UNSUPPORTED This function is not supported. >=20 >=20 >=20 > **/ >=20 > EFI_STATUS >=20 > EFIAPI >=20 > -InitializeCpuExceptionHandlersEx ( >=20 > - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL, >=20 > +InitializeSeparateExceptionStacks ( >=20 > IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL >=20 > ) >=20 > { >=20 > - EFI_STATUS Status; >=20 > - >=20 > - // >=20 > - // To avoid repeat initialization of default handlers, the caller shou= ld pass >=20 > - // an extended init data with InitDefaultHandlers set to FALSE. There'= s no >=20 > - // need to call this method to just initialize default handlers. Call = non-ex >=20 > - // version instead; or this method must be implemented as a simple wra= pper > of >=20 > - // non-ex version of it, if this version has to be called. >=20 > - // >=20 > - if ((InitData =3D=3D NULL) || InitData->Ia32.InitDefaultHandlers) { >=20 > - Status =3D InitializeCpuExceptionHandlers (VectorInfo); >=20 > - } else { >=20 > - Status =3D EFI_SUCCESS; >=20 > - } >=20 > - >=20 > - if (!EFI_ERROR (Status)) { >=20 > - // >=20 > - // Initializing stack switch is only necessary for Stack Guard funct= ionality. >=20 > - // >=20 > - if (PcdGetBool (PcdCpuStackGuard) && (InitData !=3D NULL)) { >=20 > - Status =3D ArchSetupExceptionStack (InitData); >=20 > - } >=20 > + if (InitData =3D=3D NULL) { >=20 > + return EFI_UNSUPPORTED; >=20 > } >=20 >=20 >=20 > - return Status; >=20 > + return ArchSetupExceptionStack (InitData); >=20 > } >=20 > diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException= .c > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c > index e894ead612..4313cc5582 100644 > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c > @@ -200,33 +200,22 @@ RegisterCpuInterruptHandler ( > } >=20 >=20 >=20 > /** >=20 > - Initializes all CPU exceptions entries with optional extra initializat= ions. >=20 > + Setup separate stacks for certain exception handlers. >=20 >=20 >=20 > - By default, this method should include all functionalities implemented= by >=20 > - InitializeCpuExceptionHandlers(), plus extra initialization works, if = any. >=20 > - This could be done by calling InitializeCpuExceptionHandlers() directl= y >=20 > - in this method besides the extra works. >=20 > + InitData is optional and processor arch dependent. >=20 >=20 >=20 > - InitData is optional and its use and content are processor arch depend= ent. >=20 > - The typical usage of it is to convey resources which have to be reserv= ed >=20 > - elsewhere and are necessary for the extra initializations of exception= . >=20 > + @param[in] InitData Pointer to data optional for information abo= ut how >=20 > + to assign stacks for certain exception handl= ers. >=20 >=20 >=20 > - @param[in] VectorInfo Pointer to reserved vector list. >=20 > - @param[in] InitData Pointer to data optional for extra initializ= ations >=20 > - of exception. >=20 > - >=20 > - @retval EFI_SUCCESS The exceptions have been successfully >=20 > - initialized. >=20 > - @retval EFI_INVALID_PARAMETER VectorInfo or InitData contains invali= d >=20 > - content. >=20 > + @retval EFI_SUCCESS The stacks are assigned successfully. >=20 > + @retval EFI_UNSUPPORTED This function is not supported. >=20 >=20 >=20 > **/ >=20 > EFI_STATUS >=20 > EFIAPI >=20 > -InitializeCpuExceptionHandlersEx ( >=20 > - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL, >=20 > +InitializeSeparateExceptionStacks ( >=20 > IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL >=20 > ) >=20 > { >=20 > - return InitializeCpuExceptionHandlers (VectorInfo); >=20 > + return EFI_UNSUPPORTED; >=20 > } >=20 > diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c > index ec643556c7..1c97dab926 100644 > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c > @@ -96,33 +96,22 @@ RegisterCpuInterruptHandler ( > } >=20 >=20 >=20 > /** >=20 > - Initializes all CPU exceptions entries with optional extra initializat= ions. >=20 > + Setup separate stacks for certain exception handlers. >=20 >=20 >=20 > - By default, this method should include all functionalities implemented= by >=20 > - InitializeCpuExceptionHandlers(), plus extra initialization works, if = any. >=20 > - This could be done by calling InitializeCpuExceptionHandlers() directl= y >=20 > - in this method besides the extra works. >=20 > + InitData is optional and processor arch dependent. >=20 >=20 >=20 > - InitData is optional and its use and content are processor arch depend= ent. >=20 > - The typical usage of it is to convey resources which have to be reserv= ed >=20 > - elsewhere and are necessary for the extra initializations of exception= . >=20 > + @param[in] InitData Pointer to data optional for information abo= ut how >=20 > + to assign stacks for certain exception handl= ers. >=20 >=20 >=20 > - @param[in] VectorInfo Pointer to reserved vector list. >=20 > - @param[in] InitData Pointer to data optional for extra initializ= ations >=20 > - of exception. >=20 > - >=20 > - @retval EFI_SUCCESS The exceptions have been successfully >=20 > - initialized. >=20 > - @retval EFI_INVALID_PARAMETER VectorInfo or InitData contains invali= d >=20 > - content. >=20 > + @retval EFI_SUCCESS The stacks are assigned successfully. >=20 > + @retval EFI_UNSUPPORTED This function is not supported. >=20 >=20 >=20 > **/ >=20 > EFI_STATUS >=20 > EFIAPI >=20 > -InitializeCpuExceptionHandlersEx ( >=20 > - IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL, >=20 > +InitializeSeparateExceptionStacks ( >=20 > IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL >=20 > ) >=20 > { >=20 > - return InitializeCpuExceptionHandlers (VectorInfo); >=20 > + return EFI_UNSUPPORTED; >=20 > } >=20 > -- > 2.35.1.windows.2