From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web09.1327.1623889983590176958 for ; Wed, 16 Jun 2021 17:33:04 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=AgmcMoAj; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: maurice.ma@intel.com) IronPort-SDR: 1/ZYym+qNNfXKcBW5l38LEZAxs3a7ZMOEqA64TfRydO6UI5e5zCu7Ka0Ao6ZrjGJaxxRy6r1hL Mzo2qFejAZnA== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="267426686" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="267426686" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 17:33:01 -0700 IronPort-SDR: bCZIlCS/H8Ta6Aj+Nomz21PfHwk9DprM+kYmjpC3PQbcIgEKavuUrLRZvdAesLKHEE7vYMRyiE n6D2GgQcIU2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="640190938" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga005.fm.intel.com with ESMTP; 16 Jun 2021 17:33:01 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 16 Jun 2021 17:33:00 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 16 Jun 2021 17:33:00 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) 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.2242.4 via Frontend Transport; Wed, 16 Jun 2021 17:33:00 -0700 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.47) 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.2242.4; Wed, 16 Jun 2021 17:32:59 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jEj69HkSIDTLrU3d3NM+Idcr3qM9zjNy40yo3h1Em0XOEwND22ponDtiaMTQ0ZDcFiUipV2h+n9WxtjNmnw2StU1z9VGwxiTZj6u5Qs94hl8shqRsuzfhrp8IZi1x2rw3Uqa9VwV5ks6ZgDDTnI6/0wYCo8WGrh5FYpuVfT6RQTF/jqTgE/Q9D+uDhi0r+EnscBG/S7EtuzO3nsG9E/dazYW3M1neeJG1jmcpi1zapQKr9Ll+gYTs+ighYdlqnwHoWcDT/VttbbR+lwLc+RCLArlkV5IyqfnbfTd6KebkVyZWXNPs2BSY4fTkssgf/T+iWLUuVNuHiVZSBgdQUNdEw== 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-SenderADCheck; bh=rS1Y5vX23O3/b1QfV/6ep5svCQs5JWbGgKVcAx1ifZ8=; b=Mgt+n8aFkn1NFPfFZMj1WD+bY279g2r2Rp/EvZtrbKLA1yCctVuWq6w0VzbhsI0m83oILXZ5+iQfPadgsW83D1TAvilsayt/rkqECZOvhimmDAVjafRxKD4GmgpNSRcaia1Th1tVetCy8awkiNQgm+IgbHQpJLgxhlRKGpexmu7arkTuE4XTQJw+XaN/YctP5m1e2wPMIJqZK90KeHYjioHVVDYYY36sJ4or6dUPV3txhqOjLR1NcljiZYMT3CuFvLM5hNK2wDZ4WTgZQYBBkar+U/ao+nz+JGX/ylumRSsc1nJtkLmyVcFtYSoyJpUd14JOOjW5VjRoDTh8x/ERjQ== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rS1Y5vX23O3/b1QfV/6ep5svCQs5JWbGgKVcAx1ifZ8=; b=AgmcMoAjQADZzQ4Kh3qXK6QTjAtzslFaBBIGgRFtAgjzOw1VwCi+WSmNwzoGx4e6wcJfWWTPZyb6ZjAQ/HUjnbNBl2vIhOjOrlRHibZyE5ZeLde4FVAsPKnd2rgrVRyq7g/nyV5TQynta4RYaxUgLhyTCUqWrytISrvfqOAdpDw= Received: from CO1PR11MB4945.namprd11.prod.outlook.com (2603:10b6:303:9c::8) by MWHPR1101MB2350.namprd11.prod.outlook.com (2603:10b6:300:75::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.22; Thu, 17 Jun 2021 00:32:58 +0000 Received: from CO1PR11MB4945.namprd11.prod.outlook.com ([fe80::74c3:dd4a:c4aa:6c8d]) by CO1PR11MB4945.namprd11.prod.outlook.com ([fe80::74c3:dd4a:c4aa:6c8d%5]) with mapi id 15.20.4219.026; Thu, 17 Jun 2021 00:32:58 +0000 From: "Ma, Maurice" To: Patrick Rudolph CC: "devel@edk2.groups.io" , "Dong, Guo" , "You, Benjamin" Subject: Re: [PATCH] UefiPayloadPkg/UefiPayloadEntry: Improve bootloader memrange parsing Thread-Topic: [PATCH] UefiPayloadPkg/UefiPayloadEntry: Improve bootloader memrange parsing Thread-Index: AQHXYemYBCNsyShcbkae8mwspl+3D6sXO+yg Date: Thu, 17 Jun 2021 00:32:58 +0000 Message-ID: References: <20210615132254.3364910-1-patrick.rudolph@9elements.com> In-Reply-To: <20210615132254.3364910-1-patrick.rudolph@9elements.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.5.1.3 dlp-reaction: no-action authentication-results: 9elements.com; dkim=none (message not signed) header.d=none;9elements.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [104.153.200.60] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: caf7d438-8994-407b-ee8a-08d9312774db x-ms-traffictypediagnostic: MWHPR1101MB2350: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: AGZpQQLYSso9viVWwG5uqErB82NzJUYgq1iSzxjgnWupWtWMsHUCtXU3ofrBiogZ/Vb6/5E6SO8RLU43tWlBA46YSWpMqDsn3nal/Ae2QIjcnSBTxbkqlZR0MLVJSFC5CP53Ltw6vmiV8RIsVSbEres4lhht2EaYlIrNAZIbM3KeJAusYMWmFJ6ywnQZV+zjUToS7tyQMbSZOzY7YZlZFNS6R7Su+YFtHLFEXMauTMJbiQyylnAbg+HcRquxdZ3RHcPcLcuOV3+NN9AQZT9POApcbFt1rVMaJYJrOaI0DNyjTMViToOUWwQr10FEcWii80otTriTe81iwvw5K77PmHywx+kr2ruwdcgD5hWNdNrqBFnM9pAWmc2VupFfYfmHxdL9YAAnNfyn5wfxJw2dj5LRvU2gsEdGlLvn5PPWce0f0gJcvHt1sKcaxMkdou3fqMtIwWb6n7eabBHVHts4WIq11ffkFur15X4+jSVBMpo0gl/BNP77vGnudO7iAieG5/PdGruztrZ1Rbletxfbi0bmUHNcQuBEMGVNCHBgv/iNXUVGQzNaj7xiPSKgcuum/oHBMs8SrSrSH2cKq8sv49NIXfkNtvtIlml/QHQEkjQ= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR11MB4945.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(346002)(396003)(136003)(376002)(39850400004)(8676002)(4326008)(33656002)(316002)(107886003)(30864003)(55016002)(52536014)(9686003)(7696005)(122000001)(38100700002)(54906003)(5660300002)(8936002)(2906002)(66556008)(6916009)(71200400001)(66476007)(186003)(76116006)(66946007)(64756008)(66446008)(26005)(83380400001)(6506007)(53546011)(478600001)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?BTfINXVTDUartAf7jp2l1fzPKOWTVT1f0MsGmmvakdd0FW6PMXW/C8vMOzxn?= =?us-ascii?Q?7BKVxgIVwXwW7NuxPHUPT4ua+87O38rtAVRGzJif0p/7JdBPGb3bXtUzPP7K?= =?us-ascii?Q?KlOEc8d8pIcTZO3d6ex5vLYCjsSIW4a5S32vZCT92VlkZEckRpqzYxlHR8CY?= =?us-ascii?Q?6N9h0jqAe+Zp5TTQxW3WPWKu1Tgc5G0xRO5WDV4Q35LN5bhjhu8Uci7eNhIi?= =?us-ascii?Q?V4uRJrGz2w514W6TyeV76zD+5E/YcDRouyj/386MmL/g+jMxUFHIORr+n2/s?= =?us-ascii?Q?zMi2QSejRwinaQ/2hT5lEiL0qwX1x2toOFc71oyPH09K6GM6J/xXofKSq35I?= =?us-ascii?Q?8/f8RILJRE9FZ7l4M2bEGJFqBObCQTO5NNIdD050Hsoz6p1keYOn0U5N84E+?= =?us-ascii?Q?kBpixQw60BlEaDkSNr1eccgZfiOHPy8quj8xYMMWRpVfXkag0B3UDeXCiUPf?= =?us-ascii?Q?47Kv/X6HEBMfvXFi+QtG/RIt3PDvzFdko9Pw/m2qX+5cbW1+LW6jdoBL3YAM?= =?us-ascii?Q?fM9lk4BacjISTPKqaVCjOWzlrzjA7V2D/sq8224oVYZMZXqxbiFR3s4Mueck?= =?us-ascii?Q?ZlJrVI8XeSwBE9lpyhl3Rqtds1Sj2FuqfOaQ0c8HHfr3KrMJ5VAV7Bx1E9ja?= =?us-ascii?Q?KZDS9CSqy3uqlIoioJ3JxbqVTx3azWpyK9TtzdFbKg8SxGXx29hRz35rhB5e?= =?us-ascii?Q?x2NHNXIMlSX6ODef9XDqV/u190z7csrt/69u70rYFm+/mjzc8MBApgP5SpPL?= =?us-ascii?Q?/6wPCOEYt8wU08bzwZc9YUdZX7qBAXQrD+4qSDnaddCGL6qR2IqBkconIGuR?= =?us-ascii?Q?KBoWO55mZYFS/hDpj2tFLHuqr7kA9MsiR5ShKLKOnjtn86n7y1P4v5U9p2/X?= =?us-ascii?Q?w1qIDOCebKjneF2EMZzRHWe5MgWY3ELwss6kEHqIOP2C43BZiFSkPBIlcJNu?= =?us-ascii?Q?IL8klsdWNEAB1zOx2nLrPHHKpmFFX34mD+OumEvu5+LZ3TMAv3o8VSwrCpFG?= =?us-ascii?Q?y0hsYdopMr3REmgZy9GzRMBIxbO3iqEQYVjVbncB/iIrnse2emYgcB1mqc7+?= =?us-ascii?Q?MmxeLDfEEObiafRUrX2Ul3oAEYtHMZVvbh5mZ13MMtSxvW+kwXptFcb5+X20?= =?us-ascii?Q?HpNGYBbN09LxyDPfn99+d4UvRW8aYa2PV2HtAmNlJJR554eQM+K1dUxs15qV?= =?us-ascii?Q?81N0IFVRPHXfJhe0fQBbakdI6vVfXsUrno6sqcGMKE+qdEtpZiu9j7Ijv5Qp?= =?us-ascii?Q?TQc652v6ssPzKj/5Ah7JJ9tpqpN3EzBpeAPX77xEBBqwr+6HVye9H9sZ9mq/?= =?us-ascii?Q?+gZdazZUDbEhxualWzpyfR3y?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4945.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: caf7d438-8994-407b-ee8a-08d9312774db X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jun 2021 00:32:58.2716 (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: kGnnXodP1L6ymO09vFiBbh/YkyDVQPNQkrlMWZF1x1SCg3fqxBIhjZIgJE5jbiCUqMC4JxaI7JZLFh0OePhlrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2350 Return-Path: maurice.ma@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, Rudolph, Thank you for submitting the patch. In general the approach looks good to= me.=20 Here I have several minor comments on your patch as listed below: 1. For global variable in module, could we add "m" prefix ? EX: Change = "TopOfLowerUsableDram" to "mTopOfLowerUsableDram" ? 2. Please rename "MemInfoCallbackMMIO" to "MemInfoCallbackMmio" to follow = naming convention. 3. Maybe we can add parentheses for some condition expressions to make it = easier to read. EX: Change:=20 (MemoryMapEntry->Base < 0x100000000ULL && MemoryMapEntry->Base = >=3D TopOfLowerUsableDram) To: ((MemoryMapEntry->Base < 0x100000000ULL) && (MemoryMapEntry->Ba= se >=3D TopOfLowerUsableDram)) 4. If we use "EFI_STATUS" for function status, then function return type s= hould match that. =20 EX: Use "EFI_SUCCESS" instead of "RETURN_SUCCESS ". 5. I think the new FindToludCallback() function will find the correct TOLU= D if ACPI NVS memory region is below ACPI RECLAIM memory. =20 However, if it is the other way around, the TOLUD calculation might be= incorrect. Should we consider both cases? For example, given the memory map below, your patch will get TOLUM = =3D 0x1EB6C000. But the actual TOLUM should be 0x20000000. Base Length = E820 Type MEM: 0000000000000000 00000000000A0000 1 MEM: 00000000000A0000 0000000000060000 2 MEM: 0000000000100000 000000001EA00000 1 MEM: 000000001EB00000 0000000000004000 2 MEM: 000000001EB04000 0000000000068000 3 (ACPI Reclaim) MEM: 000000001EB6C000 0000000000008000 4 (ACPI NVS) MEM: 000000001EB74000 000000000038C000 2 MEM: 000000001EF00000 0000000000100000 2 MEM: 000000001F000000 0000000001000000 2 Thanks Maurice > -----Original Message----- > From: Patrick Rudolph > Sent: Tuesday, June 15, 2021 6:23 > To: devel@edk2.groups.io > Cc: Ma, Maurice ; Dong, Guo > ; You, Benjamin > Subject: [PATCH] UefiPayloadPkg/UefiPayloadEntry: Improve bootloader > memrange parsing >=20 > Currently several DXE crash due to invalid memory resource settings. > coreboot and slimbootloader provide an e820 compatible memory map, > which doesn't work well with EDK2 as the e820 spec is missing MMIO region= s. > In e820 'reserved' could either mean "DRAM used by boot firmware" or > "MMIO in use and not detectable by OS". >=20 > Guess Top of lower usable DRAM (TOLUD) by walking memory ranges and > then mark everything reserved below TOLUD as DRAM and everything > reserved above TOLUD as MMIO. >=20 > This fixes several assertions seen in PciHostBridgeDxe. >=20 > Signed-off-by: Patrick Rudolph > --- > .../UefiPayloadEntry/UefiPayloadEntry.c | 187 +++++++++++++++++- > .../UefiPayloadEntry/UefiPayloadEntry.h | 10 + > 2 files changed, 194 insertions(+), 3 deletions(-) >=20 > diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c > b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c > index 805f5448d9..d20e1a0862 100644 > --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c > +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c > @@ -7,10 +7,162 @@ > #include "UefiPayloadEntry.h" +STATIC UINT32 TopOfLowerUsableDram =3D > 0;+ /** Callback function to build resource descriptor HOB This fu= nction > build a HOB based on the memory map entry info.+ It creates only > EFI_RESOURCE_MEMORY_MAPPED_IO and > EFI_RESOURCE_MEMORY_RESERVED+ resources.++ @param > MemoryMapEntry Memory map entry info got from bootloader.+ > @param Params A pointer to ACPI_BOARD_INFO.++ @retval > RETURN_SUCCESS Successfully build a HOB.+ @retval > EFI_INVALID_PARAMETER Invalid parameter > provided.+**/+EFI_STATUS+MemInfoCallbackMMIO (+ IN > MEMROY_MAP_ENTRY *MemoryMapEntry,+ IN VOID > *Params+ )+{+ EFI_PHYSICAL_ADDRESS Base;+ EFI_RESOURCE_TYPE > Type;+ UINT64 Size;+ EFI_RESOURCE_ATTRIBUTE_TYPE > Attribue;+ ACPI_BOARD_INFO *AcpiBoardInfo;++ AcpiBoardInfo= =3D > (ACPI_BOARD_INFO *)Params;+ if (AcpiBoardInfo =3D=3D NULL) {+ return > EFI_INVALID_PARAMETER;+ }++ //+ // Skip types already handled in > MemInfoCallback+ //+ if (MemoryMapEntry->Type =3D=3D E820_RAM || > MemoryMapEntry->Type =3D=3D E820_ACPI) {+ return RETURN_SUCCESS;+ }++ > if (MemoryMapEntry->Base =3D=3D AcpiBoardInfo->PcieBaseAddress) {+ //+ > // MMCONF is always MMIO+ //+ Type =3D > EFI_RESOURCE_MEMORY_MAPPED_IO;+ } else if (MemoryMapEntry->Base > < TopOfLowerUsableDram) {+ //+ // It's in DRAM and thus must be > reserved+ //+ Type =3D EFI_RESOURCE_MEMORY_RESERVED;+ } else if > (MemoryMapEntry->Base < 0x100000000ULL &&+ MemoryMapEntry- > >Base >=3D TopOfLowerUsableDram) {+ //+ // It's not in DRAM, must b= e > MMIO+ //+ Type =3D EFI_RESOURCE_MEMORY_MAPPED_IO;+ } else {+ > Type =3D EFI_RESOURCE_MEMORY_RESERVED;+ }++ Base =3D > MemoryMapEntry->Base;+ Size =3D MemoryMapEntry->Size;++ Attribue =3D > EFI_RESOURCE_ATTRIBUTE_PRESENT |+ > EFI_RESOURCE_ATTRIBUTE_INITIALIZED |+ > EFI_RESOURCE_ATTRIBUTE_TESTED |+ > EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |+ > EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |+ > EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |+ > EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE;++ > BuildResourceDescriptorHob (Type, Attribue, (EFI_PHYSICAL_ADDRESS)Base, > Size);+ DEBUG ((DEBUG_INFO , "buildhob: base =3D 0x%lx, size =3D 0x%lx, = type =3D > 0x%x\n", Base, Size, Type));++ if (MemoryMapEntry->Type =3D=3D E820_NVS)= {+ > BuildMemoryAllocationHob (Base, Size, EfiACPIMemoryNVS);+ } else if > (MemoryMapEntry->Type =3D=3D E820_UNUSABLE ||+ MemoryMapEntry- > >Type =3D=3D E820_DISABLED) {+ BuildMemoryAllocationHob (Base, Size, > EfiUnusableMemory);+ } else if (MemoryMapEntry->Type =3D=3D E820_PMEM) > {+ BuildMemoryAllocationHob (Base, Size, EfiPersistentMemory);+ }++ > return RETURN_SUCCESS;+}+++/**+ Callback function to find TOLUD (Top > of Lower Usable DRAM)++ Estimate where TOLUD (Top of Lower Usable > DRAM) resides. The exact position+ would require platform specific code= .++ > @param MemoryMapEntry Memory map entry info got from > bootloader.+ @param Params Not used for now.++ @retval > RETURN_SUCCESS Successfully updated > TopOfLowerUsableDram.+**/+EFI_STATUS+FindToludCallback (+ IN > MEMROY_MAP_ENTRY *MemoryMapEntry,+ IN VOID > *Params+ )+{+ //+ // This code assumes that the memory map on this x86 > machine below 4GiB is continous+ // until TOLUD. In addition it assumes = that > the bootloader provided memory tables have+ // no "holes" and thus the > first memory range not covered by e820 marks the end of+ // usable DRAM. > In addition it's assumed that every reserved memory region touching+ // > usable RAM is also covering DRAM, everything else that is marked reserved > thus must be+ // MMIO not detectable by bootloader/OS+ //++ //+ // Sk= ip > memory types not RAM or reserved+ //+ if (MemoryMapEntry->Type =3D=3D > E820_NVS || MemoryMapEntry->Type =3D=3D E820_UNUSABLE ||+ > MemoryMapEntry->Type =3D=3D E820_DISABLED || MemoryMapEntry->Type =3D=3D > E820_PMEM) {+ return RETURN_SUCCESS;+ }++ //+ // Skip resources > above 4GiB+ //+ if (MemoryMapEntry->Base >=3D 0x100000000ULL) {+ > return RETURN_SUCCESS;+ }++ if ((MemoryMapEntry->Type =3D=3D E820_RAM) > ||+ (MemoryMapEntry->Type =3D=3D E820_ACPI)) {+ //+ // It's usab= le DRAM. > Update TOLUD.+ //+ if (TopOfLowerUsableDram < (MemoryMapEntry- > >Base + MemoryMapEntry->Size)) {+ TopOfLowerUsableDram =3D > MemoryMapEntry->Base + MemoryMapEntry->Size;+ }+ } else {+ //+ = // > It might be reserved DRAM or MMIO.+ //+ // If it touches usable DRA= M at > Base assume it's DRAM as well,+ // as it could be bootloader installed= tables, > TSEG, GTT, ...+ //+ if (TopOfLowerUsableDram =3D=3D MemoryMapEntry- > >Base) {+ TopOfLowerUsableDram =3D MemoryMapEntry->Base + > MemoryMapEntry->Size;+ }+ }++ return RETURN_SUCCESS;+}+++/**+ > Callback function to build resource descriptor HOB++ This function buil= d a > HOB based on the memory map entry info.+ Only add > EFI_RESOURCE_SYSTEM_MEMORY. @param MemoryMapEntry > Memory map entry info got from bootloader. @param Params = Not > used for now.@@ -28,7 +180,15 @@ MemInfoCallback ( > UINT64 Size; EFI_RESOURCE_ATTRIBUTE_TYPE Attr= ibue; - Type > =3D (MemoryMapEntry->Type =3D=3D 1) ? EFI_RESOURCE_SYSTEM_MEMORY : > EFI_RESOURCE_MEMORY_RESERVED;+ //+ // Skip everything not known to > be usable DRAM.+ // It will be added later.+ //+ if (MemoryMapEntry- > >Type !=3D E820_RAM && MemoryMapEntry->Type !=3D E820_ACPI) {+ return > RETURN_SUCCESS;+ }++ Type =3D EFI_RESOURCE_SYSTEM_MEMORY; Base > =3D MemoryMapEntry->Base; Size =3D MemoryMapEntry->Size; @@ -40,7 > +200,7 @@ MemInfoCallback ( > EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | > EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE; - if (Base >=3D > BASE_4GB ) {+ if (Base >=3D BASE_4GB) { // Remove tested attribute t= o > avoid DXE core to dispatch driver to memory above 4GB Attribue &=3D > ~EFI_RESOURCE_ATTRIBUTE_TESTED; }@@ -48,6 +208,10 @@ > MemInfoCallback ( > BuildResourceDescriptorHob (Type, Attribue, > (EFI_PHYSICAL_ADDRESS)Base, Size); DEBUG ((DEBUG_INFO , "buildhob: > base =3D 0x%lx, size =3D 0x%lx, type =3D 0x%x\n", Base, Size, Type)); + = if > (MemoryMapEntry->Type =3D=3D E820_ACPI) {+ BuildMemoryAllocationHob > (Base, Size, EfiACPIReclaimMemory);+ }+ return RETURN_SUCCESS; } @@ - > 236,7 +400,16 @@ BuildHobFromBl ( > EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *NewGfxDeviceInfo; //- // Parse > memory info and build memory HOBs+ // First find TOLUD+ //+ Status =3D > ParseMemoryInfo (FindToludCallback, NULL);+ if (EFI_ERROR(Status)) {+ > return Status;+ }+ DEBUG ((DEBUG_INFO , "Assuming TOLUD =3D 0x%x\n", > TopOfLowerUsableDram));++ //+ // Parse memory info and build memory > HOBs for Usable RAM // Status =3D ParseMemoryInfo (MemInfoCallback, > NULL); if (EFI_ERROR(Status)) {@@ -289,6 +462,14 @@ BuildHobFromBl ( > DEBUG ((DEBUG_INFO, "Create acpi board info guid hob\n")); } + //= + // > Parse memory info and build memory HOBs for reserved DRAM and MMIO+ > //+ Status =3D ParseMemoryInfo (MemInfoCallbackMMIO, &AcpiBoardInfo);+ > if (EFI_ERROR(Status)) {+ return Status;+ }+ // // Parse platform= specific > information. //diff --git > a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h > b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h > index 2c84d6ed53..35ea23d202 100644 > --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h > +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h > @@ -38,6 +38,16 @@ > #define GET_OCCUPIED_SIZE(ActualSize, Alignment) \ ((ActualSize) + > (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))) > ++#define E820_RAM 1+#define E820_RESERVED 2+#define E820_ACPI > 3+#define E820_NVS 4+#define E820_UNUSABLE 5+#define > E820_DISABLED 6+#define E820_PMEM 7+#define E820_UNDEFINED 8+ > /** Auto-generated function that calls the library constructors for all= of the > module's dependent libraries.-- > 2.30.2