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.web11.5455.1676254783883635037 for ; Sun, 12 Feb 2023 18:19:44 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=n1LFmXNA; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: jiaxin.wu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676254783; x=1707790783; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=HO2N4g5ssG7fx8SaCeXY6gV6wDOcg2UobsvFGuvoPc0=; b=n1LFmXNAtW3IX4rbzWRCHAamT3IQBoJo2nVRyjX6q6QCUE/BnkOVe6jU pcYy+SzVV7gyC3Duh/t6FRW5nfOD5UaF5UOTkCgOs9V9dr0GaboE0xg3x KE7qJFZr5+4dJtzmQN2djgyiEs5eDiBz5jrCQOwC8v/fGUZEZHD+4SpYt XaoH/1pGU+UifS00Ivi84J669al64suCmxHagnCKSAesUpYUOS6+N6vwz BlgnrtNThK9xDP/on9dOnnMZOLDUarDwz602ucbc6JUcXwi6HK4+FPDK1 LV266S+P4+LIoZDl1GTtkRSwKlkR42dK/Z0XgibZdtti+4x0V17IFe9AB Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="318815403" X-IronPort-AV: E=Sophos;i="5.97,291,1669104000"; d="scan'208";a="318815403" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2023 18:19:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="811429873" X-IronPort-AV: E=Sophos;i="5.97,291,1669104000"; d="scan'208";a="811429873" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2023 18:19:42 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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.2507.16; Sun, 12 Feb 2023 18:19:41 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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; Sun, 12 Feb 2023 18:19:41 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) 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; Sun, 12 Feb 2023 18:19:41 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.107) 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.2507.16; Sun, 12 Feb 2023 18:19:41 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kGgOg5pqVwM+AjVcx23yGI829OP5aulwQIr80J0n7nq8U/oL9TK5EA0n64gUhrOT8/vxwUaMxTn4nCO1rn++BkL+KpWWVDtQ290v1r44rnR/KUifbvn+YQy7li81Nqi87ffJvC2GE1jqoEMy3jOuJEi8fJRRJo+3LskOC+zLrtRDGcJoQpAOZnVO+Fz6Pf0SnoMECa98n8F2KcDw8UcQQuhkiEh4HHi1TfL2mgzUHKhuYrsa5iJX2HZeyhgm5rbWaylPH+U9lwhHHwdAt0+ZcSq+2V3e/aEgvurx49DRSMp20e4IlkSJPhuJM+deYyCSKg3IhlhXEW2UhZVNWpNEtQ== 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=2N4NC4ho2nj5Nlj9HudXP7qYdBSEzNc+j42rffchTZw=; b=LQkGLNN0W6Fr8XCXijv3kD9pH1ueoHQY0V2Yp+AJ3FR6sipdClMmfh4FAlh/IHu04uTC2uQdhvJLigTYpXV+8wnWa6mbIYdWlOH8WtDQFznW2nUgFkhceJ7Nh4OGwjcP00pMP5HHT/KP7Jg1TQdRJxKMmCRzP/c0IogdLt6EWiChLLRKxpsNplN+Fl2zXvK6gNzasGRdRasufl7HivZBU65U0H7GaLKNN7CLGza25mrJH09kohXr2ie7+ECrCzd6huXZqRAxTBpCBtnjiOFYXrmo/Mcpe6DK7JATti/B5wTXpTlK0/DJacUEA3Z2YhgIxqG0ZvjI2lTKpoYP2htkvQ== 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 MN0PR11MB6158.namprd11.prod.outlook.com (2603:10b6:208:3ca::18) by MW3PR11MB4588.namprd11.prod.outlook.com (2603:10b6:303:54::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.24; Mon, 13 Feb 2023 02:19:38 +0000 Received: from MN0PR11MB6158.namprd11.prod.outlook.com ([fe80::e5d9:d16e:172b:aa01]) by MN0PR11MB6158.namprd11.prod.outlook.com ([fe80::e5d9:d16e:172b:aa01%3]) with mapi id 15.20.6086.022; Mon, 13 Feb 2023 02:19:38 +0000 From: "Wu, Jiaxin" To: "Ni, Ray" , "devel@edk2.groups.io" 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+XwgAQFGRA= Date: Mon, 13 Feb 2023 02:19:38 +0000 Message-ID: References: <20230210060519.11100-1-jiaxin.wu@intel.com> In-Reply-To: Accept-Language: zh-CN, 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: MN0PR11MB6158:EE_|MW3PR11MB4588:EE_ x-ms-office365-filtering-correlation-id: c5e1e557-5fa8-40c6-fb5e-08db0d68c1ea x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: uEU0CdybM972tEoOrY4f0M5nwW7EkfYYB+PJ8qBHUUY4FOSKmXJdgIq4pU0wynx29lGbVWNOI7aWYnwaIls6rOD7tEAuTQrLXmzicd2R0WunCICAH6kzpe3xwnT1aphx3mwKI4M7FPGlJ6XNlDg7aRQfs1M+uQXvIYpFp4loBpr8R46Hk/8onYdhhrO2aKFIqypgjdmU1g5aCIRgNhXILXDaDCDmhvsQn3YzuUT+iIRHhUjlLSWRkQe6FrWfOBbVg6hFqhfPu9O1DMTa/i1GohuJmhXGUHe/TPocAIMmeatZQqgxWy8yrsFHeJ9A+VhT2FxqZwldb0Zt4wbgF3OvZAEXMCJTMMRTRMwPgffpRGdOj843lShJqdpgzxRTsahVqimkvA0Wz9ASGMVvdZKiiatMCTB/9ZuxUtK/O/lNDFW5djOS5lPSf5RpIiddEM1NsQsB3rUkq6k54o3jVYyeZfOnNLBMuv4haycJI3/ZZRoTjrO8LHKRLlyKZlGSOrTaxDCM65MeiNgXGJ5fJpzIga6YrMpZBLIWIT0+/Q8VJ/yIBr50vQ3t0u6X42e/CPZU905g95N5GQAPRz9BsM3N9f3/RuNw06VnP+kHCaGAHziB0f878I1E1gTLrlfCeHAzh7eCVg4crBwTiVMAhQcbgnwlb+yxfroQWPL1qeuFOpCN+Q9b/wNQEyWVJw7VhVPkypMIQysi7mMDX7OnlgR8IEYHn8ZWmfFGSPu03ajKow/wasYSoIa8pdhF+Ltu9gcuoP5SUTqhrkFHplkD8Csntg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN0PR11MB6158.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(396003)(346002)(39860400002)(366004)(136003)(451199018)(33656002)(86362001)(19627235002)(122000001)(110136005)(316002)(8676002)(76116006)(66946007)(966005)(71200400001)(7696005)(478600001)(2906002)(41300700001)(66476007)(8936002)(66446008)(5660300002)(52536014)(82960400001)(64756008)(66556008)(55016003)(38070700005)(38100700002)(26005)(9686003)(53546011)(6506007)(186003)(83380400001)(66899018);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?JzbxA6Uah7wJoIC4UTbO5qjhC5+PxhZ5O3X981sXsa08kAHK3ECuLYVQWDfd?= =?us-ascii?Q?riX0LaDGhK1nQFN9bhIxSXVj7LdYOqVohFNDT1tZxJHR3CMS3PElk2FyLMFN?= =?us-ascii?Q?zy8/j/d9RvtK8O9JgeBI/EjmLdmwXgTHOsdzthySM22YKDHC/6SkV84+SxS+?= =?us-ascii?Q?k7h+Ll8CQ9526zyDSIr48HobScvvpr1JSzfeeAm64xy1azyCG1/6NAwRR4p9?= =?us-ascii?Q?bFItOweCk5K71D2WEM67Y+2UOUni2nfiA8jQADI1j3aL0Kp/arUie7NmTxcu?= =?us-ascii?Q?9yyC7AGhx3OL0L319nbBsmleIiLFFxqURLuMKv1q7cAfWDQjaHuas2j8S1Tz?= =?us-ascii?Q?qJL6v5HZILIHOJCsMwFfDIhpYamaxHXQc+7aA6UH1/gRiZGFbb9ZTwivKFLt?= =?us-ascii?Q?eRQR4/KADH+/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j?= =?us-ascii?Q?HTt3I6SvrdZSbCEJxdNzGtRA21I0nEDkDg7EzcChgEkla8C4ktS6wJhjjBae?= =?us-ascii?Q?HeMswl0OFvIbYPcK6W399dazz0axunAkvrNS20S2itsWc/GkF2UshCQ18Ydm?= =?us-ascii?Q?7H1P0OXcbx/Kv2duFCFD1R0b0+/B0gfTUNSOEoA2NOu8E7vnfaw6Q7FYqNUO?= =?us-ascii?Q?H8929ATIPlumE2YTTT2yw000fkv7s/+uq5PGciU1v0DElkxhL6BabGQQrrLM?= =?us-ascii?Q?qDexsVY8r1QY6kbV1v0HHPmam8TZi3rUtpmZzmOy?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN0PR11MB6158.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c5e1e557-5fa8-40c6-fb5e-08db0d68c1ea X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Feb 2023 02:19:38.4063 (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: Rc8bxWH+a1ZQfm17lJzq5Wgpld4lrlbSwamyv8C5OyxNIzP6WuwVDNlFlmNl7Mv726lccU7wdGl34QBECR2g1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4588 Return-Path: jiaxin.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks Ray, I will update all. > -----Original Message----- > From: Ni, Ray > Sent: Friday, February 10, 2023 8:57 PM > To: devel@edk2.groups.io; Wu, Jiaxin > Subject: RE: [edk2-devel] [PATCH v4 0/5] Simplify SMM Relocation Process >=20 > Jiaxin, > I provide separate review comments for each patch. >=20 > Can you please make sure the copy right year is updated for every file > change? > I may not emphasize this for each patch. >=20 > > -----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 > > > > 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). > > > > 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). > > > > 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). > > > > 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. > > > > 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. > > > > 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 > > > > .../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 > > > > -- > > 2.16.2.windows.1 > > > > > > > >=20 > >