From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.13861.1676033819535277379 for ; Fri, 10 Feb 2023 04:57:00 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=GkzBOsbA; spf=pass (domain: intel.com, ip: 134.134.136.20, 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=1676033820; x=1707569820; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=vS5MCasemIARXMPneuK5HaRhhTReSTc6w+NSontQ2C4=; b=GkzBOsbAmxhCTOjF8N3Tom6LFRBzioqJUt/DwJ6UoVjrHjdo9B4WnRVl tFqZvOZbNx5SUpgdtqgiX1Co0Y774tnu1arv/+PAE/W9gTfNrqj5xqOCe RBBFeJjvID+7llrLUSt+oJRaI7JGjOB1ElNpJT4t8jWVHAaSbrln9zwZd 6nWECMHl7p+xlWmLpDkXL9CcAysJw9GEP0he/6GAtqsjpaua4mO1Fyo73 uxrWCQmIpS2MzqnAM4gQyi+HMH7WDkICM3dGYEq0CSN4EI7NbTPq3SvoY GjTrkGntjWcbmw8+Qadcj0zq37cJ0uNKmM3Doi46PrQlQaw25bPq/ii6v g==; X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="318429113" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="318429113" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 04:56:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="645617981" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="645617981" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga006.jf.intel.com with ESMTP; 10 Feb 2023 04:56:52 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) 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.2507.16; Fri, 10 Feb 2023 04:56:51 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 10 Feb 2023 04:56:51 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) 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.2507.16 via Frontend Transport; Fri, 10 Feb 2023 04:56:51 -0800 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.176) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Fri, 10 Feb 2023 04:56:51 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F51AKTqL9w3h7Eh+879b3SxAl4vEFR8rNJ+fpQFr5gEV9s0eYx4dO0thWSKnkRyMcR8gKgnYpPQs8M4WxMgQx4XHYkR8bdL0UxtyMsEGaMdT9Ty0kteQnZixHCk7bsAk+ISWXrPY7T212JHdYCZgZ6gjXsULGk4oVuIGFn/bshbnaHKQOGq17bBb4UPY2oSdo5sTwpw612RsZ538w+0PcaD6ciev96TlG7uGwEI46226snUNq8s+osXNBP0xtNx+eI5S8jAlz83sCA9OrA8Dp5u4P49fQGyexJqKwV8aEyA3ZYfd3yxKkEiCpPqH7bwOnIj2ETQZKkf62sNXq9g9aw== 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=iSF/gGelaeYKFvbIgAD0ZUdyIyE/yt1pWUnaT1Vdxjw=; b=cpTyIhPJo2LXx7mQsdgcpKYi4t9sgGT90xvJZr2zz+LoyN0UHvn9I0B+iEgu5njip5VlX2WzopdBZLATWDFGFqcwitZ3fSpBui9kN++9IHy9xPmfKL8RdHt+w3nVCcX7Ov42Pgxyktf9YkyIbCBexuqoSMr7Yw51RUQI7/UX4qTKazgV+E+8mCL6/0EKQrIVnf2VYblmmTIk4FcQoBniow6YSv8mz4wIaUgJlUnWsO9pvS9eq0z3RK8+wGIuAwHN9e4GOH6L+27Dd4OkVTffWx/Acdjrt5/zCdq5z5rtew5oUXg4l8RkukXraCE8E82+8oaT41bAiVZ2QazhAJvlsw== 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 MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by SA1PR11MB6782.namprd11.prod.outlook.com (2603:10b6:806:25e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.19; Fri, 10 Feb 2023 12:56:49 +0000 Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::f890:e4ec:e2d8:5831]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::f890:e4ec:e2d8:5831%3]) with mapi id 15.20.6086.017; Fri, 10 Feb 2023 12:56:48 +0000 From: "Ni, Ray" To: "devel@edk2.groups.io" , "Wu, Jiaxin" Subject: Re: [edk2-devel] [PATCH v4 0/5] Simplify SMM Relocation Process Thread-Topic: [edk2-devel] [PATCH v4 0/5] Simplify SMM Relocation Process Thread-Index: AQHZPRX3zrQUMxZbVEObhAe9dx1Znq7II+Xw Date: Fri, 10 Feb 2023 12:56:48 +0000 Message-ID: References: <20230210060519.11100-1-jiaxin.wu@intel.com> In-Reply-To: <20230210060519.11100-1-jiaxin.wu@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: MN6PR11MB8244:EE_|SA1PR11MB6782:EE_ x-ms-office365-filtering-correlation-id: 4fdbeed5-ef43-413d-6cec-08db0b6645b8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kZNvHlMTZ7UVPtmLXXI3kZDxbqCrBgi7royuSFSHfB57YeDBXPosAXJcrqQuZj3VLBqdaXPVzSx3XcqMR30pjO+tOgV13h1nocOHsGRA/1CQ1JZloWAEYPHjfQL5dTglPlVvmpvZCWIGZ666GpqvpXllr3fwLft/vGVP0Xk/oIuC8y9de4u5xULhqIsMub31FdJZIhRqw4pXGmMVL49fWJrQ34kltjIjxL+sCvpc9Q9a5gFyKRH6rWZcy54IBkxcaQjzMC3jkCA3X5M5bpqtxVkZc68dvqXFd2wfu4qKSJkHCNaUL68IZa/GF6bYgQpBFdUakx8wxz801BQOGfFBLVUBmCP1M6kfoz/3tGsUkcDAqypHSlcm/7iq9g+Rds69/eNHR5kyfYUr6j/YEZOpCMh/DwhM++bXxhFC/6Ali2qPwgQ+NIxWPOLhEem+sugFdu4sPA3xwJKaV2/AQqvesjaoigqH6bHD2MHW2QU6+R6sTUh+C6QZ/iEVWf+xzLcLIZCvClXFGG2H8Vy9DFbRv8yHWom4aeebKAM0JH7s7WA7pEUGo6mNOuJQHoQh9QdsuADfK3rc75PjkEO9V6DvIyFnZE5u3QOKEoqsngsU39jXCrKvpQGl4w20XOLBJOgSYI14Mgb0r2YDW95Rh2fU9STleQmihwBwHH2M8lYCrSu7e9z7ZNgijhvBSFgaE1afUHNgR2h8Jje25ev+2rrgMxtEchvbL3IOI9KYXyaCEA2ag/XtplO9AwtUfgzK8KsZi7A+RWxRHSUuk31a50+pQw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN6PR11MB8244.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(39860400002)(376002)(346002)(396003)(136003)(451199018)(33656002)(55016003)(83380400001)(66899018)(82960400001)(38100700002)(186003)(9686003)(6506007)(71200400001)(478600001)(53546011)(2906002)(26005)(6636002)(19627235002)(966005)(316002)(7696005)(38070700005)(41300700001)(8936002)(5660300002)(122000001)(86362001)(66946007)(66556008)(76116006)(66446008)(8676002)(64756008)(110136005)(66476007)(52536014);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Tvl3xezvrkJLpp/k1c9ITUO3/MmNdEyjbL61oPLdFBDvxLEBkMx/5AraW1TV?= =?us-ascii?Q?IK1CGBX/iyScv5KfS2THFJwC4RJREMguIfn+r0oRXpqGivjmVpusly32IxKg?= =?us-ascii?Q?Owqlv8EfJjxNsU8JZWnWwN2CkvLLFpwvpJPN/CKTM2rrAF4s4PTZYhQC3qj1?= =?us-ascii?Q?SJ0tiNjmnrL+yEwmc+QLAWiUOcLFjPvSLMVJiX8LKkHt97lKAJWfMG6g75DU?= =?us-ascii?Q?/zf/HQHCFqfbLH+M5OQoyMEu8EKZQ296VZGCTGWOwcfEI0GI6omn1celP3/9?= =?us-ascii?Q?LTj+g10L+nlxBK9Yv/kqvh5b9Dgwvyg8o5nSurOjc64adMxLL2Ql5l2wGXNC?= =?us-ascii?Q?5HFe5TcnurGb+VLUjWxkJikWTzjrOF28Es3rnPf6QDGaaf3N9MlfRonCYF0+?= =?us-ascii?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imvIRai3yCU20o?= =?us-ascii?Q?bq8Pc6V5VXr/5VWEf6nYPuRAfHcQCibWebWLZL6hNbZXRWrKjVGLe4ZyuNFS?= =?us-ascii?Q?zPy2ASM1GP/GDLUvxpNVpT3SbEidKyCOpaywLMHaA/i+6J7bWoKttxxc91PN?= =?us-ascii?Q?iuxFxNL5om3V9mcvi7yrpcKmqxfTy+DgquXmMSngpbpks83EyhJKcnDL2+oJ?= =?us-ascii?Q?H0VdF6P+g/4Fnz1/sjPNch6dneW9ra+UJV//ONY3zJMHCyoXfXNwS0BkAsJd?= =?us-ascii?Q?io/pEY4Nj+Po7QhIypDGAWmVFv18+XhJWX2sV0KF?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4fdbeed5-ef43-413d-6cec-08db0b6645b8 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Feb 2023 12:56:48.7184 (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: eFYaMs6+c+M2CHUd4nIG/XH7vdYk0ZqLItgXKsBqtl0OSOphRFUPT346o4Zk31+D9ywza55Yl200aDEQDRQHlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB6782 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 Jiaxin, I provide separate review comments for each patch. Can you please make sure the copy right year is updated for every file chan= ge? I may not emphasize this for each patch. > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Wu, Jiaxin > Sent: Friday, February 10, 2023 2:05 PM > To: devel@edk2.groups.io > Subject: [edk2-devel] [PATCH v4 0/5] Simplify SMM Relocation Process >=20 > Existing SMBASE Relocation is in the PiSmmCpuDxeSmm driver, which > will relocate the SMBASE of each processor by setting the SMBASE > field in the saved state map (at offset 7EF8h) to a new value. > The RSM instruction reloads the internal SMBASE register with the > value in SMBASE field when each time it exits SMM. All subsequent > SMI requests will use the new SMBASE to find the starting address > for the SMI handler (at SMBASE + 8000h). >=20 > Due to the default SMBASE for all x86 processors is 0x30000, the > APs' 1st SMI for rebase has to be executed one by one to avoid > the CPUs over-writing each other's SMM Save State Area (see > existing SmmRelocateBases() function), which means the next AP has > to wait for the previous AP to finish its 1st SMI, then it can call > into its 1st SMI for rebase via Smi Ipi command, thus leading the > existing SMBASE Relocation has to be running in series. Besides, it > needs very complex code to handle the AP exit semaphore > (mRebased[Index]), which will hook return address of SMM Save State > so that semaphore code can be executed immediately after AP exits > SMM for SMBASE relocation (see existing SemaphoreHook() function). >=20 > This series is to add the new SMM Base HOB for any PEI module to do > the SmBase relocation ahead of PiSmmCpuDxeSmm driver and store the > relocated SmBase address in array for each Processors. When the > SMBASE relocation happens in a PEI module, the PEI module shall > produce the SMM_BASE_HOB in HOB database which tells the > PiSmmCpuDxeSmm driver (runs at a later phase) about the new SMBASE > for each CPU thread. PiSmmCpuDxeSmm driver installs the SMI handler > at the SMM_BASE_HOB.SmBase[Index]+0x8000 for CPU thread Index. When > the HOB doesn't exist, PiSmmCpuDxeSmm driver shall relocate and > program the new SMBASE itself (keep existing SMBASE Relocation way). >=20 > With SMM Base Hob support, PiSmmCpuDxeSmm does not need the RSM > instruction to do the SMBASE Relocation. SMBASE Register for each > processors have already been programmed and all SMBASE address have > recorded in SMM Base Hob. So the same default SMBASE Address > (0x30000) will not be used, thus the CPUs over-writing each other's > SMM Save State Area will not happen in PiSmmCpuDxeSmm driver. This > way makes the first SMI init can be executed in parallel and save > boot time on multi-core system. Besides, Semaphore Hook code logic > is also not required, which will greatly simplify the SMBASE > Relocation flow. >=20 > Note: > This is the new way that firmware can program the SMBASE > independently of the RSM instruction. The PEI code performing > this logic will not be open sourced, similarly to other things > that are kept binary-only in the FSP. Due to the register > difference in different vender, and it has not been documented > in the Intel SDM yet, we need a new binary-only interface for > SMM Base HOB. >=20 > Jiaxin Wu (5): > UefiCpuPkg/PiSmmCpuDxeSmm: Fix invalid InitializeMpSyncData call > UefiCpuPkg/SmmBaseHob.h: Add SMM Base HOB Data > UefiCpuPkg/PiSmmCpuDxeSmm: Consume SMM Base Hob for SmBase info > UefiCpuPkg/SmmCpuFeaturesLib: Skip SMBASE configuration > OvmfPkg/SmmCpuFeaturesLib: Check SmBase relocation supported or not >=20 > .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 8 + > .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 4 + > UefiCpuPkg/Include/Guid/SmmBaseHob.h | 64 +++++++ > .../Library/SmmCpuFeaturesLib/CpuFeaturesLib.h | 2 + > .../SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c | 23 ++- > .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 4 + > .../SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf | 1 + > UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c | 1 - > .../StandaloneMmCpuFeaturesLib.inf | 4 + > UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 29 +++- > UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 23 +++ > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 191 > ++++++++++++++++----- > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 24 +++ > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 1 + > UefiCpuPkg/UefiCpuPkg.dec | 3 + > 15 files changed, 332 insertions(+), 50 deletions(-) > create mode 100644 UefiCpuPkg/Include/Guid/SmmBaseHob.h >=20 > -- > 2.16.2.windows.1 >=20 >=20 >=20 >=20 >=20