From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.80111.1682430543562464776 for ; Tue, 25 Apr 2023 06:49:03 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=clsN+VSc; spf=pass (domain: intel.com, ip: 192.55.52.120, 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=1682430543; x=1713966543; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=DDms7Sm2U6VP/EjDwPB1YDuZHTbXLOAYqcZPOkKV3nA=; b=clsN+VScksXFDuvPGFOLCaOf8RGIWNbKnPu/Mzp3VD7wRAEW0pQiWnS+ 3w964M/52pj8oyyZE38aStqRVJLmY3vWKUkdIMFVbFpxPuixlZf3qSMLI 18qoV60k4Yn/1wtEKVhsdiNKCZ/tS2kBOqNjwld7NL0ODK9FypmvWo+C0 iXCutqbr9w6EV4xya1gIvTfUyzpO+cM8yw+3j6w3Qw3FJVfmbwbcZWL7W DSW4wFwdAEfg3ZtEO/+uCTMxrNfTIeGyBd+tMVaXjQa4pB+vHAOF54dE7 VKEmtYVsfeLwVhEVMHJjhDpCdrsZjjw6jkbSDYtYFLqo2UNJgRHwaQk/A A==; X-IronPort-AV: E=McAfee;i="6600,9927,10691"; a="345522271" X-IronPort-AV: E=Sophos;i="5.99,225,1677571200"; d="scan'208";a="345522271" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2023 06:49:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10691"; a="724037065" X-IronPort-AV: E=Sophos;i="5.99,225,1677571200"; d="scan'208";a="724037065" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga008.jf.intel.com with ESMTP; 25 Apr 2023 06:48:58 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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.23; Tue, 25 Apr 2023 06:48:57 -0700 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.23 via Frontend Transport; Tue, 25 Apr 2023 06:48:57 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.108) 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.23; Tue, 25 Apr 2023 06:48:57 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oHYJkKax8tjDIZXf2mF6uTYlWvASJs8M8RKCxc2nqDU8M4phJWzwTvHaxi5Ix61ik3u6WBy4mMMZ1PBpU5tC1wXPQn1QNwddQSvCZe3hgSyO7I8kRqcWQjFHGKlJHV5IFaJdF7wPejZ1h1Lb862lhMNK8WZbTpW1XXcWgAwzbhEaLvB+0t/MccbQ0vGYRqlVYDMaCATUVuHiCVy1bFDAo1FdKIcoi/+vYVqIGyCD58I1DLZKEuHBMttxcI2JxBBkYdsssA8Pg/30pbGDHcepK/Ed99AaiI4Y6sxzDoSr2v+RC61OXIYqJgel4crYXS7MFw9frpRSr1pfIBVB9kwe6Q== 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=WDSgzufrDpkH0h7XiAuST+TXhaya9PaGz1Togjq+kvU=; b=e9aOyhXpHeiIT1e3NCUBmUr6F/TLmqUZMqCuhcftusRNoGbn5kb+9QPnJWoJPapHw/sMYAImhgyrD6Kl/8e/U74tXX9B4FodaXKiFaNrQ8xm6kc2YECs7R25mZ/VAqUFkj55Q6mdmAJF+EaSfwpV/va2TtRuFeolQUAup6xuTDNEPTleTE9Xx3YUNI9ts/G/2MRnyRJhIvcAYmA/JMIRYxhWCLqqidhguCsUVzDRo1E5SwUxcIFYhk2Z4fBiw7hA4vf6haj5oX57UlsbrRqJfL/f0awfcTs0O3YgLQ51qHfs1Q4JcKpNZkOfAEHCBphOEiJ8Ak4RSEOBuddWB/3iQg== 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 DM4PR11MB6017.namprd11.prod.outlook.com (2603:10b6:8:5c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 13:48:56 +0000 Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::892b:b8e6:bab7:635d]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::892b:b8e6:bab7:635d%5]) with mapi id 15.20.6319.033; Tue, 25 Apr 2023 13:48:55 +0000 From: "Ni, Ray" To: "Liu, Zhiguang" , "devel@edk2.groups.io" CC: "Desimone, Nathaniel L" Subject: Re: [PATCH 1/5] SimicsOpenBoardPkg: Build gEfiSmmSmramMemoryGuid Hob in S3 path Thread-Topic: [PATCH 1/5] SimicsOpenBoardPkg: Build gEfiSmmSmramMemoryGuid Hob in S3 path Thread-Index: AQHZd0QRKVp6HlWFzUCtikd632EUC688ChkA Date: Tue, 25 Apr 2023 13:48:55 +0000 Message-ID: References: <20230425070304.2120-1-zhiguang.liu@intel.com> <20230425070304.2120-2-zhiguang.liu@intel.com> In-Reply-To: <20230425070304.2120-2-zhiguang.liu@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_|DM4PR11MB6017:EE_ x-ms-office365-filtering-correlation-id: 4e1c89b2-0228-4ff9-1ab0-08db4593d038 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: g8Y7+T4lgiYDYSV1gI2n80OL7OunlHltkPez+vQycHt/Xs4poT+Jo53o1gkQ9SjBqKGbSb5pLnlWMB6q3ZAgRMkHSx0uumKgHrWe0uv0Kl84HbbUlaRjzrdUFUY3ueVoFZOmMe2NphmlK+ooNvUij3iZ5UwA/U3TOPCSuTswa+ZBq4j8Vmjthp9IjxW4MuslxSV3f62FibM3yz3R2kVMyNxOTag3bznCZ9HiEK8cf+foIHcuWTstt+7V8+4906BSmM8J47KveA2pQcpMSA7tIqOVJcnMq/Qtd9FJaFKOQTgcfyF00x1c2i9Ro3G0wHROL8nKdRO33+iNCfrqQHmiwoYcq4ZCRqTSah8MhatBqbju6YHtEKqcans2Lyni+wbzzLmpm4EgfKmcKX0UKcFrctEiFHAMW2NTaPw0hRkwwjy3dBBjXqY2poTaM2SUFVbwbw07grTpF1BcLqPHztbzGbGcVTfqsNde7qFi7TWP6wcAeYCyj1Jil1aNQYi9GF0G5Q+7zn3ynfxWt8yTpXayM6/Ok883X0lsQAPyaA5rCNtZNUfFriLqs5w3Za/UHOrOq1pzxmSfCZEFGWCzsHBfT1kdb3oHWVJz3o9fJm/n5OqjbgkIsb3zBO1jwGoXNw3qNMi9siC/v7FHySjlnWQadTRlxP9C+sx6TfZOcnfkJrU= 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:(13230028)(136003)(396003)(376002)(39860400002)(346002)(366004)(451199021)(19627235002)(110136005)(38070700005)(33656002)(86362001)(478600001)(38100700002)(41300700001)(122000001)(8936002)(8676002)(2906002)(4326008)(64756008)(66446008)(66476007)(55016003)(66556008)(316002)(82960400001)(52536014)(76116006)(66946007)(5660300002)(107886003)(186003)(6506007)(26005)(9686003)(53546011)(83380400001)(7696005)(71200400001)(145543001)(213903007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?J/4txy6UYKwCiWjPiapFs9fh6Fp+r1YaZBnfn54QrCIHdh0PdR/4al32PuT1?= =?us-ascii?Q?yCV0v1QLTyDe1x1IzcLEhMLxICF6tZxmzELE8VILjRHU/TCZNVqnwKGY88vZ?= =?us-ascii?Q?NGfiGPI19EX85l12JShVjUGP9/KQGjP1WRdep4xqp1WhgdPZP1jMwF/wAwu5?= =?us-ascii?Q?3gzGr6SwJb8gU24hs1fh726EqNjMNCyaAmKW1vYxOZCFCuR/3Jc+bWx0hW34?= =?us-ascii?Q?vQKpZ8bBwVj40vztTHk7Ws732lYFWn4wdq+Q16aZS0W7ouhIKdJ8w8WI7Q3/?= =?us-ascii?Q?5gtOCce0+CorcVtxdRGUkGozNo6/V43K0NFfp8SikRRIQWN6pAe2ZTfR9RFB?= =?us-ascii?Q?+905zEBT6IJOvlDQS8QDSE5NWGxlCJArIvklV8aFJZrIc6D+almFHnq0+VBB?= =?us-ascii?Q?Lz4K9yq5VJok5+DmunV0nV6kzrH72m7Du9ZE1c+QDp279rf49zl/ZqQ3gUIP?= =?us-ascii?Q?v0GvgB9sWRw6ujJ4JsPPhWur8rArbhd3doVgEHz7LobtiT4vKGKdOYvSAftj?= =?us-ascii?Q?+wagH1FBM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?us-ascii?Q?d1XYA3HsMtVH3smTyjJ5llUe/4+CQTd2qw7pkiKXRJBq36IM4Yns1RLfrMYu?= =?us-ascii?Q?i6NQviLumrtRkYwZpCYa/rJi3O3hUddPwGqd6fXk9Npzb1uoYXepc7JWzxi4?= =?us-ascii?Q?ryib1XnKomS3tPPqjP49vqENLyMNykh+Wu7QODWZ?= 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: 4e1c89b2-0228-4ff9-1ab0-08db4593d038 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Apr 2023 13:48:55.8371 (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: uwzD5Q6RxLvmD7der+pAFdf0RiRFPnMLNf3Noro10noSjfG6gEoas1dgHV7Zy82ZjPZzZgTez1cck+EgbNL+Kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB6017 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 Zhiguang, Can you please keep the comments that explain why below 1MB memory resource should be added for QSP platform? Another question not related to your changes: why "AddMemoryRangeHob (BASE_1MB, LowerMemorySize);" is only called when PcdSmmSmramRequire is FALSE? Thanks, Ray > -----Original Message----- > From: Liu, Zhiguang > Sent: Tuesday, April 25, 2023 3:03 PM > To: devel@edk2.groups.io > Cc: Liu, Zhiguang ; Desimone, Nathaniel L > ; Ni, Ray > Subject: [PATCH 1/5] SimicsOpenBoardPkg: Build > gEfiSmmSmramMemoryGuid Hob in S3 path >=20 > gEfiSmmSmramMemoryGuid Hob is needed for SmmRelocation feature > even for S3 path. So in MemDetect.c, remove specical code path > for S3 about creating gEfiSmmSmramMemoryGuid Hob and adding some > memory descriptor, which does no harm in S3 path. >=20 > Cc: Nate DeSimone > Cc: Ray Ni > Signed-off-by: Zhiguang Liu > --- > .../SimicsOpenBoardPkg/SimicsPei/MemDetect.c | 107 +++++++----------- > 1 file changed, 42 insertions(+), 65 deletions(-) >=20 > diff --git a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c > b/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c > index 127afffc00..d80ac1d213 100644 > --- a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c > +++ b/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c > @@ -405,79 +405,56 @@ QemuInitializeRam ( > LowerMemorySize =3D GetSystemMemorySizeBelow4gb (); > UpperMemorySize =3D GetSystemMemorySizeAbove4gb (); >=20 > - if (mBootMode =3D=3D BOOT_ON_S3_RESUME) { > - // > - // Create the following memory HOB as an exception on the S3 boot pa= th. > - // > - // Normally we'd create memory HOBs only on the normal boot path. > However, > - // CpuMpPei specifically needs such a low-memory HOB on the S3 path = as > - // well, for "borrowing" a subset of it temporarily, for the AP star= tup > - // vector. > - // > - // CpuMpPei saves the original contents of the borrowed area in > permanent > - // PEI RAM, in a backup buffer allocated with the normal PEI service= s. > - // CpuMpPei restores the original contents ("returns" the borrowed a= rea) > at > - // End-of-PEI. End-of-PEI in turn is emitted by S3Resume2Pei before > - // transferring control to the OS's wakeup vector in the FACS. > - // > - // We expect any other PEIMs that "borrow" memory similarly to > CpuMpPei to > - // restore the original contents. Furthermore, we expect all such PE= IMs > - // (CpuMpPei included) to claim the borrowed areas by producing > memory > - // allocation HOBs, and to honor preexistent memory allocation HOBs > when > - // looking for an area to borrow. > - // > - AddMemoryRangeHob (0, BASE_512KB + BASE_128KB); > - } else { > - // > - // Create memory HOBs > - // > - AddMemoryRangeHob (0, BASE_512KB + BASE_128KB); > + // > + // Create memory HOBs > + // > + AddMemoryRangeHob (0, BASE_512KB + BASE_128KB); >=20 > - if (FeaturePcdGet (PcdSmmSmramRequire)) { > - UINT32 TsegSize; > + if (FeaturePcdGet (PcdSmmSmramRequire)) { > + UINT32 TsegSize; >=20 > - TsegSize =3D mX58TsegMbytes * SIZE_1MB; > - AddMemoryRangeHob (BASE_1MB, LowerMemorySize - TsegSize); > - AddReservedMemoryBaseSizeHob (LowerMemorySize - TsegSize, > TsegSize, > - TRUE); > + TsegSize =3D mX58TsegMbytes * SIZE_1MB; > + AddMemoryRangeHob (BASE_1MB, LowerMemorySize - TsegSize); > + AddReservedMemoryBaseSizeHob (LowerMemorySize - TsegSize, > TsegSize, > + TRUE); >=20 > - BufferSize =3D sizeof(EFI_SMRAM_HOB_DESCRIPTOR_BLOCK); > - SmramRanges =3D 1; > + BufferSize =3D sizeof(EFI_SMRAM_HOB_DESCRIPTOR_BLOCK); > + SmramRanges =3D 1; >=20 > - Hob.Raw =3D BuildGuidHob( > - &gEfiSmmSmramMemoryGuid, > - BufferSize > - ); > - ASSERT(Hob.Raw); > - > - SmramHobDescriptorBlock =3D (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK > *)(Hob.Raw); > - SmramHobDescriptorBlock->NumberOfSmmReservedRegions =3D > SmramRanges; > - > - SmramIndex =3D 0; > - for (Index =3D 0; Index < SmramRanges; Index++) { > - // > - // This is an SMRAM range, create an SMRAM descriptor > - // > - SmramHobDescriptorBlock->Descriptor[SmramIndex].PhysicalStart = =3D > LowerMemorySize - TsegSize; > - SmramHobDescriptorBlock->Descriptor[SmramIndex].CpuStart =3D > LowerMemorySize - TsegSize; > - SmramHobDescriptorBlock->Descriptor[SmramIndex].PhysicalSize =3D > TsegSize; > - SmramHobDescriptorBlock->Descriptor[SmramIndex].RegionState =3D > EFI_SMRAM_CLOSED | EFI_CACHEABLE; > - SmramIndex++; > - } > + Hob.Raw =3D BuildGuidHob( > + &gEfiSmmSmramMemoryGuid, > + BufferSize > + ); > + ASSERT(Hob.Raw); >=20 > - } else { > - AddMemoryRangeHob (BASE_1MB, LowerMemorySize); > - } > + SmramHobDescriptorBlock =3D (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK > *)(Hob.Raw); > + SmramHobDescriptorBlock->NumberOfSmmReservedRegions =3D > SmramRanges; >=20 > - // > - // If QEMU presents an E820 map, then create memory HOBs for > the >=3D4GB RAM > - // entries. Otherwise, create a single memory HOB with the flat >=3D= 4GB > - // memory size read from the CMOS. > - // > - if (UpperMemorySize !=3D 0) { > - AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); > + SmramIndex =3D 0; > + for (Index =3D 0; Index < SmramRanges; Index++) { > + // > + // This is an SMRAM range, create an SMRAM descriptor > + // > + SmramHobDescriptorBlock->Descriptor[SmramIndex].PhysicalStart =3D > LowerMemorySize - TsegSize; > + SmramHobDescriptorBlock->Descriptor[SmramIndex].CpuStart =3D > LowerMemorySize - TsegSize; > + SmramHobDescriptorBlock->Descriptor[SmramIndex].PhysicalSize =3D > TsegSize; > + SmramHobDescriptorBlock->Descriptor[SmramIndex].RegionState =3D > EFI_SMRAM_CLOSED | EFI_CACHEABLE; > + SmramIndex++; > } > + > + } else { > + AddMemoryRangeHob (BASE_1MB, LowerMemorySize); > } > + > + // > + // If QEMU presents an E820 map, then create memory HOBs for > the >=3D4GB RAM > + // entries. Otherwise, create a single memory HOB with the flat >=3D4G= B > + // memory size read from the CMOS. > + // > + if (UpperMemorySize !=3D 0) { > + AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); > + } > + > } >=20 > /** > -- > 2.31.1.windows.1