From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.619.1665197871562856608 for ; Fri, 07 Oct 2022 19:57:51 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=A803GIVv; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665197871; x=1696733871; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=ODx8km3ke0Jf/mbaRzGpjBwjdOE1j6iLGNdeUZJP7Mw=; b=A803GIVvvreniKJKcDh79+u5l4uFS4J9m9qdHak1tqIMm6vFwPSTs9Mo XzM9AhWIbC2Ia1w/cjh7c7HsVYj0mBAHDAR4t4GOz6LlU1UQ9M5aHwLlH zaVZpJjiM0kI3625H73Zh5DuiHlIBCo4sTomxjFJuz/b6xbQyEoPpysF8 TF53I6hYMZcYArm1krhrz4Jx1Rulc8hH556uzBQjCv1D8dcoHRpz/OQs4 4Ws3l0pi8nAWXy1H0TU2L2ILJQmg6ZfVLxWo+3yEbf2Uhdi73mnuApEkz C1/F30I29m1U4Dn59z9B7Nd5N3tfvR6buEKJqQ5aCA9ODD1bl1o9Qm5JJ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10493"; a="287114471" X-IronPort-AV: E=Sophos;i="5.95,168,1661842800"; d="scan'208";a="287114471" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2022 19:57:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10493"; a="603094095" X-IronPort-AV: E=Sophos;i="5.95,168,1661842800"; d="scan'208";a="603094095" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga006.jf.intel.com with ESMTP; 07 Oct 2022 19:57:49 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 7 Oct 2022 19:57:49 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 7 Oct 2022 19:57:49 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Fri, 7 Oct 2022 19:57:49 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.45) 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.2375.31; Fri, 7 Oct 2022 19:57:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TUfgJh83Hb/YYb59rhX3UqLXR0+ilslw+hkVbn3l4bNKfekv9QZuLWovotwUdjVyoNlSqLpjfHzVh57dCeujBZlt+TKKxoj9eURwahriKwbVcw9n37EhrNUU18AYEpgHTR2Mq9hzK5HqgmoCmHMiYa/QiyAWfDdZwfHHUMyONJaDndxreYAOpdbYmdLAhArDTRYaNlXvm9SlQxuDnf//xcyQyLE8tdlEnzzHT/rC0BNQUTLGp6kyBD97E/kq4biTUj51Rh3fFzJwteWMgFtPE0TAp3sFkvmMCNdwAZbHtid8U1i1a3y2eejhVxAxIA7842edS2fuxcX7uJrt2sz/Zw== 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=lywuv9uwgvY2My1Lvm3bbfbjlA7J1qvqR1kzC4NeYUs=; b=LvCEJmC8sBcesXGjXv/bjfbHjoT3xQ7Y0Pj8dwABfkfDTubiO//34GPRu42PCezthWZaxdeWQpUcOLuOaAY9RqGnYV1EcBoR8QRBcqXcgitNh5lqs1AUGLy2LQqMtXSjG2nxRg6S65S4NBDv6RYtHlp5XyjyCDI8QDJSJvIsa3LA5j0SjQ1UGlS0TuNl+55+gT044vRrDNVtfNzI9a3htk418J8aUQYh7E0qE+uvlo8ar1TuB42tbehbPe4bLsIwcWFhmfub5ndGR6MD0XMxcpGzFgQ0uTwRbKpajyT9rb2a6r9JqeLW25G2BVTzfG5LnX58LYRu8zyOyCc1QqSbkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MWHPR11MB1631.namprd11.prod.outlook.com (2603:10b6:301:10::10) by BN9PR11MB5340.namprd11.prod.outlook.com (2603:10b6:408:119::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23; Sat, 8 Oct 2022 02:57:42 +0000 Received: from MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::483f:4bb5:a15f:f571]) by MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::483f:4bb5:a15f:f571%11]) with mapi id 15.20.5676.036; Sat, 8 Oct 2022 02:57:42 +0000 From: "Ni, Ray" To: "Tan, Dun" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" Subject: Re: [Patch V2] UefiCpuPkg/CpuExceptionHandlerLib: Code optimization to allow bigger stack Thread-Topic: [Patch V2] UefiCpuPkg/CpuExceptionHandlerLib: Code optimization to allow bigger stack Thread-Index: AQHY0+Lj5SVpZRi+ckulrOG5YAl3oa4D29QA Date: Sat, 8 Oct 2022 02:57:41 +0000 Message-ID: References: <20220929090651.1438-1-dun.tan@intel.com> In-Reply-To: <20220929090651.1438-1-dun.tan@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MWHPR11MB1631:EE_|BN9PR11MB5340:EE_ x-ms-office365-filtering-correlation-id: 21dcfb3d-e318-4a67-9c65-08daa8d8de27 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: FlQlZj6BvAVg+oTF8F75n9UMjnJKTmlAtxTimQyLZ4dp+GlOc4EHsIrhFUbiJlp+m/Tvig9y7Vb4DmBeNBg08252QG9R1uwAClWDTNynQw19Fw7FXZ/ClVUTvwDfKBYUVsj+3zMCr0u1cVYWWFZ+OO9mMkBXRNpySLDTovTuj0aY4IO4Bg8A3u5aR8fOWeZl6n3h/W+sTqhMmNAgxClO6kUqdVoFFYV2MWsn0k9cLALCcdAKUPRW3ekd7dwDViDSMVeR07N5eYRuCuNRvFxG9u/LSsXV1/ioOKGhsqz15GnbLfs8QiFTE4MhNALJBDlVt5F8fF86aXafdbTsI5UmigPuzX1iMHvK4Ir4UHpl7Jtr3haaUClBiVd/yLqeLEkajWRGdVf/hGfHj8SmAtsXNZyvLItmsTRviHQNnPqnvkVwsRBBd/g6jx5sI8rjzDppmcUoEyz05vHCzQKTbPS9lIDSn806MaabmYaHMd8XrN/xIzizNfJ8/8IUeW+HfEi2x3UFbvU4ZQVQO5q0y49DUbM+nsm1R/S/CWwsEfWlC5qS80y+HOdVqWWwLdGoCEJc0dl76OA6ZzTScFgvw91OWCOumTQEwhdfY86C/jRpl/dccGFtPCEk5gpHebm4kldk6EgNHBn7QrqSmwd0VaJOeNIzxPFnmNZTvDy+5xfTBs5Qn3vCbkDoukd1UvQ6RvJi94Rfu1tQrsfuqkQtAMl8XT6b4H+ppvYVTDI7ghL3Q/EokJ2vbVvSR6KSZEiLK6JAo1TjBXiEpFG6JvGlbHhpyAPbUogcIrBWF5oygvYqQgQ= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR11MB1631.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(396003)(346002)(136003)(451199015)(186003)(82960400001)(52536014)(38070700005)(122000001)(38100700002)(2906002)(8936002)(5660300002)(83380400001)(55016003)(41300700001)(8676002)(66476007)(26005)(478600001)(53546011)(71200400001)(107886003)(7696005)(64756008)(6506007)(76116006)(9686003)(316002)(66556008)(4326008)(54906003)(66446008)(110136005)(33656002)(66946007)(86362001)(135533001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?WjSTULTX8LmNNu4janLdTuBpjboOsUrScvYcOfOzfQcp9cYrOygFGvLX1D2E?= =?us-ascii?Q?dmz4F4ZN+MlSztMVgLVZE5DvOmNjddexH3Fc9SFtuZR8hPrm95pkOGu5KOks?= =?us-ascii?Q?AJbLDlw5CihB5/ZrOlWxU0l4tBwbL56SDZwHhmWwLS05YgRdVjp4ydnNH/TM?= =?us-ascii?Q?C2cgMIzrswj75m+4icUqW8Y4YOSqk3KrWzR/42/YyvYltiKDIuOVV3sKx2gY?= =?us-ascii?Q?f03jquvPSlOeRzezDW6ug5wqpnAcTwwpIoZ2mXbx4tQStvSDXNV8qjAP9QRf?= =?us-ascii?Q?Nl23OfH8fqe1IbAtHcfsCnKBdKLTLzMKRbvd6FLBHyGuuZnaRuNROEERKGWt?= =?us-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QJ2DiH+YSRhhZH6?= =?us-ascii?Q?uagXs8gsIt0xzRR1vcHqIhDFEXBH2llXPwbqf0jH4bSrx9kDl5/h/OJjSGc/?= =?us-ascii?Q?ZjhtvJZ1EB/sQNTIUF2Qol59q/JZ3iHsT0wg9DNJIJPm0ANmoY5Skb4r6XnC?= =?us-ascii?Q?o78XjcIxanRoVP0UkZduT1N5p3LQNtbHbAQJwoCeX6Av4P2pGR4aHSnOnkJG?= =?us-ascii?Q?hfIUa0KGEc7j9UrD/Xa8jw6zBQ9pB6xH7I0XXgc6RATCjXUdLrGX04RlnaO0?= =?us-ascii?Q?JbhKHtjlLsqDLZVLhPynoSAxrML9yy733+kakbbwg8LCPW3FrY4zahwPIVbS?= =?us-ascii?Q?hj9Q9EYRnpxhmI/+ydA=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1631.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21dcfb3d-e318-4a67-9c65-08daa8d8de27 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Oct 2022 02:57:41.9574 (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: S8VUDjL114tb9jZoq4AhCuOYiph0nqLGzi8EfX12tDZMQK4MgHcr3XjRgpjqKcpxKg58qVHi/4HShssltu9zaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5340 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: Tan, Dun > Sent: Thursday, September 29, 2022 5:07 PM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Ni, Ray ; Kumar, > Rahul R > Subject: [Patch V2] UefiCpuPkg/CpuExceptionHandlerLib: Code optimization > to allow bigger stack >=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/ArchExceptionHandler. > 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