From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.76]) by mx.groups.io with SMTP id smtpd.web12.9521.1664454268960199095 for ; Thu, 29 Sep 2022 05:24:29 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=hwUg2wsP; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.223.76, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c9K+46Wd66UWve3hpU8CYmxs7aa+DXKTsjrHMNg/CO821Kij78p4ZN2pelpu9XBsb1m4+HZxH4+EbxmsNrhXp7uE/joGWek5v64VcdV/eCg+nqn6Oi5PzR6QRfbTWHIXVyV2K7CxwMWSvNlHMiA6TMiz0abEG63ZasDqok06Ch0zQ+mCwPzhbUvE9gZJYjOL6n+00HL+uLo6raqoOHni6ItDh7HCUaa6Po9K7nqD8DAGUmSlzDbSC9t2C44lYHdboBsHFyDg1Tm6ab00qC+8RvRVqyc0yLYQJaLQGQYyhak2kQU+FU+BEXdf/G8lz6PQsEdbXhJWQrNoD59MViK6Lw== 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=18y9CoEi7Qdur/SrfBq1aC51LswijLun4MGLyBP0GvY=; b=W6C02PM5lkWRb3u1Ylwy5lQr9y7JRUnKWGAPbV24Pw/dqmOMi7x+G75K1FXgUvM/8XAj6YX/N6mpSVtbXumCyBEx+kJ31atRw+hHutTAYta57ksre6OrN3+NtSClUuZH3yOvfQY2CzC/bVSHn1cXM7z2iafHb9xIoDIAOXEIb4kYQ0k4EU0XFHcEDiTaWKyqRiD5KHbhBso5iV+5gb4cz3QIsPmLuoRxqGT+sEytO+fl1q4qEVI4/MdM2uQMf8mj2DEEii5Ag9DEOQqvIz1twE3DwDxraJmG8dmPgfuI5vc9aHwopeWQE4udZkbM5w0phyWFwMeytbeJ8lGXSBGWjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=18y9CoEi7Qdur/SrfBq1aC51LswijLun4MGLyBP0GvY=; b=hwUg2wsPj4rthV9+YUgnEt0sxNFtoJTqSUxlcuuqHSMZyg/Q5+9Kpi6pYEN2LBBL67/SzJA77LhTb+n9yXbPlzjjp589oMonhWpw4fYR57fhSjfScirtwr9fzKs6bdEXNIVpPzi4YU4xrO6Me136xfRzi+4lBMkUb1+STqEl1e0= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by BN9PR12MB5276.namprd12.prod.outlook.com (2603:10b6:408:101::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.20; Thu, 29 Sep 2022 12:24:27 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::998b:f1a2:b183:43be]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::998b:f1a2:b183:43be%4]) with mapi id 15.20.5676.020; Thu, 29 Sep 2022 12:24:27 +0000 From: "Chang, Abner" To: "devel@edk2.groups.io" , "dun.tan@intel.com" CC: Eric Dong , Ray Ni , Rahul Kumar Subject: Re: [edk2-devel] [Patch V2] UefiCpuPkg/CpuExceptionHandlerLib: Code optimization to allow bigger stack Thread-Topic: [edk2-devel] [Patch V2] UefiCpuPkg/CpuExceptionHandlerLib: Code optimization to allow bigger stack Thread-Index: AQHY0+LjywupEpPeWk2dCpk/Q8v32632VP4Q Date: Thu, 29 Sep 2022 12:24:26 +0000 Message-ID: References: <20220929090651.1438-1-dun.tan@intel.com> In-Reply-To: <20220929090651.1438-1-dun.tan@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2022-09-29T12:24:25Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=5904b252-3547-4273-bdf3-6085ae2bd92a; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|BN9PR12MB5276:EE_ x-ms-office365-filtering-correlation-id: a82546e9-a821-4184-c5a1-08daa2158cff x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: y+fl2RX3bAs74eQp2FN8OvQ5rbZrQIh7uDQm+9TmBovr5iVgEN194XJEBckf9cotpY3cjJYPnCLDITdWbDTx9gEJuSwzoJPc8C+/1folY0pIylb6/LZRw5RLg+cOmhRORx9g0tyROIWqglD88zs7tn1ivqubWrIPl1Gbs6E6+HczleHR8ku7h/wONXkKC5CXcDqwXSVAm0v13xgh7ume5XSd5Rxidh8niLxF/VNT1lQDDYm3bsLK7HtoIpfvyHHqN3hNlVdta5yG79ZMI/HEfEDPtOYbEDVuO3sglpR0Plt9OB00jR4VSSXL2oxJOVuLD1OKEczc3PYEeHKVuINhdXTTZLm3eTt0a7la1L2BfrFYoGFCHd6H8HINxuTrUGvqe3IDXcINWEkYAcNSgOegE7RCpOxO26Eau+BnjJFvuCoeNBpIKKo7Hw70Ogl4WQN9QcN/JHYB+Cd4fkLcorNc55Mbo+fFQZlqYtBF/NEVqqDj0w1ctD4QqVVJTwSmEgevd6/MROSKTNnW042eniU+C3QpkKK7i8XqS/4ikUjFYOVE+PNU2azFemeuyaF5h+6HeNwQlDzMATIvySFC6VS79GLtH5A8r8W2f+PI/buh8p4Y9a9GFmxubx2ctrYe/KyGyd3OTIMQgX/QPr2FJykH6/y+LKvZZOdxliVhFQpActqk/2/OVkcptCSfTmHupcnxtks7ipZ7yO6XgWXTr6g3t2oStg16MadzRQNsRLaBXKb4O9acM04VA0GsoFFxm6xAqLBItdzu7Ouo4yuDBLtjQtEn2hv3BWoiMYILrIlsOMA1PZKKqxCLTs3CTo1RZ4hmj72klb+gKSvchSqgaAP3Og== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(39860400002)(396003)(136003)(366004)(376002)(451199015)(110136005)(54906003)(316002)(45080400002)(66899015)(5660300002)(478600001)(4326008)(71200400001)(41300700001)(38100700002)(53546011)(7696005)(6506007)(26005)(186003)(966005)(64756008)(66446008)(8676002)(33656002)(9686003)(76116006)(66946007)(66556008)(66476007)(38070700005)(86362001)(8936002)(122000001)(2906002)(55016003)(52536014)(83380400001)(135533001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?yT8TIwQ8cFPuvKtqajSltd1J47DM7gKjtOjXwhAmq5ttaqPDfSuCPcQLGTSG?= =?us-ascii?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hEDMuQ4/6Vstn?= =?us-ascii?Q?cjf2SOVg6pWIjycKn2qUYr+zYMpWRdoxmylKu/ChGtVsmXvSxS6rqtNKkAD7?= =?us-ascii?Q?4c8wxnFUMrOsrq3PjvTpWvs4iEN9jm0P+z+5Zan1hN0+u25V+Grhcj29mQQp?= =?us-ascii?Q?XOS4h6qT93ERtQF7LWTjvnPNtkEwWyvY4wxpg4+pEbwJRuIqNdXeV7h4hauF?= =?us-ascii?Q?z2scFGFq+qRqnJJKlixR6EYV9X00cLdcE5E7bvIo9M/+3Eg3y8WSMt5xgAhX?= =?us-ascii?Q?T/p0cjj9XC1arMKUFtnrbETlFxIcrf4pRp8nMCrPT3UkBqxfqyVODJDHLa1p?= =?us-ascii?Q?pRnXlRJ22/hXP0ytfErIR9DVcgA1BomdL/Y1Yx6acA2Il/8+1jgbm6mCf0nn?= =?us-ascii?Q?mTy2DGs+cunJgrOKAy1nafIqN/5sjBeSTHPLjnCTdmVyUykBridz5/G2LbeA?= =?us-ascii?Q?pzppUErYsAjD8nifUlejbTACT23O3q+buo/x74MKkhSKBp3eXjLtTLYFa05z?= =?us-ascii?Q?1sI0YQ+7i75bDVYDs9rx0YaeoGUPHjO869rJeKHqbeLwLNputrQjqGXkmosY?= =?us-ascii?Q?Cg4ajrliE73I1epspWg/ue66Nhny2EC9ShWYRd5CQrwUlJ4iw4nOCOCv3GZU?= =?us-ascii?Q?HbymdninXZzEv1XNQ7c=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a82546e9-a821-4184-c5a1-08daa2158cff X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Sep 2022 12:24:26.9775 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: kPp0Cs+mTLTZnUXu9ZM/df3YB0Rt3yQCE39jKHDEQlEuDbzP+fCAhJOK/cgnWbjEKzzuAxbAEG3u1Lg4gBgguQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5276 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Not the maintainer or reviewer, however Reviewed-by: Abner Chang > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of duntan via > groups.io > Sent: Thursday, September 29, 2022 5:07 PM > To: devel@edk2.groups.io > Cc: Eric Dong ; Ray Ni ; Rahul Kum= ar > > Subject: [edk2-devel] [Patch V2] UefiCpuPkg/CpuExceptionHandlerLib: Code > optimization to allow bigger stack >=20 > Caution: This message originated from an External Source. Use proper caut= ion > when opening attachments, clicking links, or responding. >=20 >=20 > This commit is a code optimization to allow bigger seperate stack size in > ArchSetupExceptionStack. In previous code logic, CPU_STACK_ALIGNMENT > bytes will be wasted if StackTop is already CPU_STACK_ALIGNMENT aligned. >=20 > Signed-off-by: Dun Tan > Cc: Eric Dong > Reviewed-by: Ray Ni > Cc: Rahul Kumar > --- > UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c | = 5 > ++++- > UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c | 5 > ++++- > 2 files changed, 8 insertions(+), 2 deletions(-) >=20 > diff --git > a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c > index 8c398ebc5b..c30ece1dc9 100644 > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler= .c > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandle > +++ r.c > @@ -215,7 +215,10 @@ ArchSetupExceptionStack ( > // Fixup exception task descriptor and task-state segment > // > AsmGetTssTemplateMap (&TemplateMap); > - StackTop =3D StackTop - CPU_STACK_ALIGNMENT; > + // > + // Plus 1 byte is for compact stack layout in case StackTop is already= aligned. > + // > + StackTop =3D StackTop - CPU_STACK_ALIGNMENT + 1; > StackTop =3D (UINTN)ALIGN_POINTER (StackTop, CPU_STACK_ALIGNMENT); > IdtTable =3D (IA32_IDT_GATE_DESCRIPTOR *)Idtr.Base; > for (Index =3D 0; Index < CPU_STACK_SWITCH_EXCEPTION_NUMBER; ++Index) > { diff --git > a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c > b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c > index 80e9f08e5b..4e85880ed4 100644 > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.= c > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler > +++ .c > @@ -223,7 +223,10 @@ ArchSetupExceptionStack ( > // Fixup exception task descriptor and task-state segment > // > ZeroMem (Tss, sizeof (*Tss)); > - StackTop =3D StackTop - CPU_STACK_ALIGNMENT; > + // > + // Plus 1 byte is for compact stack layout in case StackTop is already= aligned. > + // > + StackTop =3D StackTop - CPU_STACK_ALIGNMENT + 1; > StackTop =3D (UINTN)ALIGN_POINTER (StackTop, CPU_STACK_ALIGNMENT); > IdtTable =3D (IA32_IDT_GATE_DESCRIPTOR *)Idtr.Base; > for (Index =3D 0; Index < CPU_STACK_SWITCH_EXCEPTION_NUMBER; ++Index) = { > -- > 2.31.1.windows.1 >=20 >=20 >=20 >=20 >=20