{"id":2218883,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2218883/?format=json","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.0/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260402001410.3736815-6-rs@ti.com>","date":"2026-04-02T00:14:09","name":"[5/6] efi_memory: backfill EFI_CONVENTIONAL_MEMORY","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"bb367577376c5a82019e821076882fd66919a1db","submitter":{"id":88727,"url":"http://patchwork.ozlabs.org/api/1.0/people/88727/?format=json","name":"Randolph Sapp","email":"rs@ti.com"},"delegate":{"id":68728,"url":"http://patchwork.ozlabs.org/api/1.0/users/68728/?format=json","username":"xypron","first_name":"Heinrich","last_name":"Schuchardt","email":"xypron.glpk@gmx.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20260402001410.3736815-6-rs@ti.com/mbox/","series":[{"id":498412,"url":"http://patchwork.ozlabs.org/api/1.0/series/498412/?format=json","date":"2026-04-02T00:14:04","name":"various memory related fixups","version":1,"mbox":"http://patchwork.ozlabs.org/series/498412/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2218883/checks/","tags":{},"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=ti.com header.i=@ti.com header.a=rsa-sha256\n header.s=selector1 header.b=iglIHacq;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=pass (p=quarantine dis=none) header.from=ti.com","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=ti.com header.i=@ti.com header.b=\"iglIHacq\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=quarantine dis=none) header.from=ti.com","phobos.denx.de; spf=pass smtp.mailfrom=rs@ti.com"],"Received":["from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fmMn02zxsz1yCs\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 02 Apr 2026 11:15:00 +1100 (AEDT)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 052DC80517;\n\tThu,  2 Apr 2026 02:14:37 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id C209983D8A; Thu,  2 Apr 2026 02:14:32 +0200 (CEST)","from BYAPR05CU005.outbound.protection.outlook.com\n (mail-westusazlp170100001.outbound.protection.outlook.com\n [IPv6:2a01:111:f403:c000::1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id D7A6284011\n for <u-boot@lists.denx.de>; Thu,  2 Apr 2026 02:14:28 +0200 (CEST)","from DS7PR03CA0248.namprd03.prod.outlook.com (2603:10b6:5:3b3::13)\n by DS0PR10MB7174.namprd10.prod.outlook.com (2603:10b6:8:df::11) with\n Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.15; Thu, 2 Apr\n 2026 00:14:24 +0000","from DS1PEPF00017096.namprd05.prod.outlook.com\n (2603:10b6:5:3b3:cafe::35) by DS7PR03CA0248.outlook.office365.com\n (2603:10b6:5:3b3::13) with Microsoft SMTP Server (version=TLS1_3,\n cipher=TLS_AES_256_GCM_SHA384) id 15.20.9745.30 via Frontend Transport; Thu,\n 2 Apr 2026 00:14:24 +0000","from lewvzet201.ext.ti.com (198.47.23.195) by\n DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft\n SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.20.9769.17 via Frontend Transport; Thu, 2 Apr 2026 00:14:24 +0000","from DLEE210.ent.ti.com (157.170.170.112) by lewvzet201.ext.ti.com\n (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 1 Apr\n 2026 19:14:21 -0500","from DLEE211.ent.ti.com (157.170.170.113) by DLEE210.ent.ti.com\n (157.170.170.112) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 1 Apr\n 2026 19:14:21 -0500","from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE211.ent.ti.com\n (157.170.170.113) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend\n Transport; Wed, 1 Apr 2026 19:14:21 -0500","from rs-desk.dhcp.ti.com (rs-desk.dhcp.ti.com [128.247.81.39])\n by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 6320EKsF1004385;\n Wed, 1 Apr 2026 19:14:21 -0500"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-1.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,\n DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,\n RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,T_SPF_PERMERROR autolearn=no\n autolearn_force=no version=3.4.2","ARC-Seal":"i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n b=ZNSMr2PfqHNdzg7B+kkNsu++6jeA9ttcWvKIf7kVawOhdcusUHspavt8tiV15G9IrkSeL04bNomgosbq42jNCH5huufwik/b2p3HApCZ461VmiQzYCaM2nIoVMm1imJUjJEigJ3X1XcJ0dnkOhSiB7LRrVkbdfhsnTwa+D3nZ2PhFfuynVy4edTQV8MTS5u3Qzpe3bImDSzx4msgu5WqODd5tlbxduDPP9AYxPONPrgs6XJdo+YRWiV46X4t3ThJGRpszB3OHwQPFZKkDaxXICiSGROe37bwNWemnq1hjb8K13Y3MSt0GKEjNv04ysEDMvClyUpGursqQnjC4NEHdQ==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector10001;\n 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;\n bh=gPc6DMG5Yu+scxWkuVOP/T+FezA3X9fPYltU6uS3Bqg=;\n b=IiAk8HbOfxK24Fjp9oIZ3z5IbJh/IHmzZl4oY48qIQ5WLLUcItr9xMyP8fAlVO8HZvCAQlzuEUXX7CvSpLzdC0RcNJYKwKh/ybAI8d6GvTPeO88TJ8pio99c2N0TCXMy2YqRu47PZ0mh2tqd/vObhw2l+520UL2lSXyFvlChgtFPrrREY4xOfau0FsKmtyvxUGD9fe+A5R6Sogz1BZekyLkVZz9dAnb8wsk6G0v9irQETiEZAMEvaTlokx6/qSuV0apBdwuKlTdWlmkjE6n6+B3gVmxH4L1dG/ZvEeiYeN6m0TXbNel60uAD83DKzVL76sEJFjlUzFpj+f68U1mtmA==","ARC-Authentication-Results":"i=1; mx.microsoft.com 1; spf=pass (sender ip is\n 198.47.23.195) smtp.rcpttodomain=lists.denx.de smtp.mailfrom=ti.com;\n dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com;\n dkim=none (message not signed); arc=none (0)","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=gPc6DMG5Yu+scxWkuVOP/T+FezA3X9fPYltU6uS3Bqg=;\n b=iglIHacqk2dOOTi00ai360Wxr+iRYpCIrF/BQxGZ0isZ2tN3ITbUN1cSkc25yggBxudesln+WungAZyBEEMABvIZP/xHrjjBkckVLR43RXwQ2MW67l027AjGmtCS7Uuy75vVW0jti0pxeCQ5vaIomQof6JIxxVNopWRCvzJivxQ=","X-MS-Exchange-Authentication-Results":"spf=pass (sender IP is 198.47.23.195)\n smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;\n dmarc=pass\n action=none header.from=ti.com;","Received-SPF":"Pass (protection.outlook.com: domain of ti.com designates\n 198.47.23.195 as permitted sender) receiver=protection.outlook.com;\n client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C","From":"<rs@ti.com>","To":"<robertcnelson@gmail.com>, <ayush@beagleboard.org>,\n <Erik.Welsh@octavosystems.com>, <anshuld@ti.com>, <bb@ti.com>,\n <trini@konsulko.com>, <afd@ti.com>, <xypron.glpk@gmx.de>,\n <ilias.apalodimas@linaro.org>","CC":"<u-boot@lists.denx.de>","Subject":"[PATCH 5/6] efi_memory: backfill EFI_CONVENTIONAL_MEMORY","Date":"Wed, 1 Apr 2026 19:14:09 -0500","Message-ID":"<20260402001410.3736815-6-rs@ti.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260402001410.3736815-1-rs@ti.com>","References":"<20260402001410.3736815-1-rs@ti.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain","X-C2ProcessedOrg":"333ef613-75bf-4e12-a4b1-8e3623f5dcea","X-EOPAttributedMessage":"0","X-MS-PublicTrafficType":"Email","X-MS-TrafficTypeDiagnostic":"DS1PEPF00017096:EE_|DS0PR10MB7174:EE_","X-MS-Office365-Filtering-Correlation-Id":"bcf69ec6-6b10-44bf-0c60-08de904ccbe6","X-MS-Exchange-SenderADCheck":"1","X-MS-Exchange-AntiSpam-Relay":"0","X-Microsoft-Antispam":"BCL:0;\n ARA:13230040|376014|82310400026|1800799024|36860700016|22082099003|18002099003|56012099003;","X-Microsoft-Antispam-Message-Info":"\n ROQ6VBlahYWvSZC1AyYpyGfNcX2FKquQCFOuxUZsAAmbmeTXxZayIq+gC+Px8p9nwaOwQImz94oFIRM+9tk+OSCO+L2iHygS5Esj1BWvxBQvTXRglvvOBkWBQTXC1WKXLbpT2uIrArumdh6riXAOxGo5KigpdNOHHsHqLOU0QUTF//J48jIQs8mhLTaUY+oOabDdN0SxNHJ4sV7+WzJ2pCMprZBkzNmcNGIrT/0zuYLiVvou87uqwS1Y8l1ANUz/6MlYaxKB9yMx1/OJEfcMzuD57hqVD5m3rWnqQPDjKHCjporM93W7ST62XubHSKO+DUv0r3AaLWfVwuWdHWDVRNyVgAfjKJHASSfErcamgqvO6LWchoMVkpmFfqIuwcf9EvMTx734nHIdYprbaJQDTF8ZhR7T1x8eRwjanRE4uqAwnGqId0og6RzUt7jNkhY1cGm5k02WaLiaT+06b3ih2I1X0l0FBSzLHrIvwlp4Ytprd41hiGiOIlbXJpyx1RJLZua7YOGr96e6AUY/cHSf4iJqG0vqKDvwxcZCoOAGLZMbVwEWGV+HmhZcqmQdXrfDhcJPam2ZWSoG5y+X2Qj002H6pp9nIZDX+TgzE6XP4q5Sa2x4G9Mton22LIPIpqiJ+IBc0WU2QSCchetHTUD/UG0hqLqKAmAZuIMSclTsgn/FUPipU2lA51a73eIw4ujdeq6KcjFfwRWe1HrsroryiHG7ASnhjpfmYxLGtjPvPNq4rFg0yEJk0k+fCZS2OYCWU/ZcPeTwggxAgkO4PFtyIQ==","X-Forefront-Antispam-Report":"CIP:198.47.23.195; CTRY:US; LANG:en; SCL:1; SRV:;\n IPV:NLI; SFV:NSPM; H:lewvzet201.ext.ti.com; PTR:InfoDomainNonexistent;\n CAT:NONE;\n SFS:(13230040)(376014)(82310400026)(1800799024)(36860700016)(22082099003)(18002099003)(56012099003);\n DIR:OUT; SFP:1101;","X-MS-Exchange-AntiSpam-MessageData-ChunkCount":"1","X-MS-Exchange-AntiSpam-MessageData-0":"\n 8j3AdpG0DrafrLXZD/k2Hd8c+WdHsytw+FettolQlx2v4pOI1a8e6DPQNFae88tIwKlTbpsPHRGZdg31NcGcIxWY4dGE4ntmO2CLT2/3aMVtBIFRtOf2cNFHYZyyBSdax3tZ6i3FCaMHJm4tzwhbC0Npx/anl2WGDdR7h7r5LWT+X4inM4c4i/khu2lCUwaX7UtiPY15fDHmaNnwBZuZC6zI8SYimIZ01AN5Qwy9ocTeZq+Xz1yIjzyiYMEEHifuz5FyT7QIf9KpGU+aoUi+sw8G1VNSQHYNh3c6c5Q57MdA/mcMRAlkp3krmQMU0KwRu7a5C5Qnjr08uvSTnHXKfg1n4kIEXtx2GTiJA8rCd8FMQW6e/DG+JPJtuShUaYcfzufKxYWXQRwmnn79eZTuTd4qE2JctVeu8WyF0q0o4mEobQEhT3qmNxHIrrBh07Lw","X-OriginatorOrg":"ti.com","X-MS-Exchange-CrossTenant-OriginalArrivalTime":"02 Apr 2026 00:14:24.4994 (UTC)","X-MS-Exchange-CrossTenant-Network-Message-Id":"\n bcf69ec6-6b10-44bf-0c60-08de904ccbe6","X-MS-Exchange-CrossTenant-Id":"e5b49634-450b-4709-8abb-1e2b19b982b7","X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp":"\n TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7; Ip=[198.47.23.195];\n Helo=[lewvzet201.ext.ti.com]","X-MS-Exchange-CrossTenant-AuthSource":"\n DS1PEPF00017096.namprd05.prod.outlook.com","X-MS-Exchange-CrossTenant-AuthAs":"Anonymous","X-MS-Exchange-CrossTenant-FromEntityHeader":"HybridOnPrem","X-MS-Exchange-Transport-CrossTenantHeadersStamped":"DS0PR10MB7174","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"From: Randolph Sapp <rs@ti.com>\n\nBackfill any fragmented EFI_CONVENTIONAL_MEMORY when LMB allocations\nstart to fail. This may be a low memory environment, or maybe LMB is\nrunning up against a tricky reserved region.\n\nSigned-off-by: Randolph Sapp <rs@ti.com>\n---\n lib/efi_loader/efi_memory.c | 35 +++++++++++++++++++++++++++++++++--\n 1 file changed, 33 insertions(+), 2 deletions(-)","diff":"diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\nindex 882366a9f8a..f07cc39b157 100644\n--- a/lib/efi_loader/efi_memory.c\n+++ b/lib/efi_loader/efi_memory.c\n@@ -441,6 +441,27 @@ static efi_status_t efi_check_allocated(u64 addr, bool must_be_allocated)\n \treturn EFI_NOT_FOUND;\n }\n \n+/**\n+ * efi_get_conventional_start - find the highest conventional region start\n+ *                              address with at least the specified number of\n+ *                              pages\n+ *\n+ * @pages:                      number of pages required to be in that carveout\n+ * Return:                      starting address of the give carveout\n+ */\n+static u64 efi_get_conventional_start(u64 pages)\n+{\n+\tstruct efi_mem_list *item;\n+\n+\tlist_for_each_entry(item, &efi_mem, link) {\n+\t\tif (item->desc.type != EFI_CONVENTIONAL_MEMORY)\n+\t\t\tcontinue;\n+\t\tif (item->desc.num_pages >= pages)\n+\t\t\treturn item->desc.physical_start;\n+\t}\n+\treturn 0;\n+}\n+\n /**\n  * efi_allocate_pages - allocate memory pages\n  *\n@@ -507,10 +528,20 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type,\n \t/* Reserve that map in our memory maps */\n \tret = efi_update_memory_map(efi_addr, pages, memory_type, true, false);\n \tif (ret != EFI_SUCCESS) {\n-\t\t/* Map would overlap, bail out */\n+\t\t/* Map would overlap, try something else */\n \t\tlmb_free(addr, (u64)pages << EFI_PAGE_SHIFT, flags);\n \t\tunmap_sysmem((void *)(uintptr_t)efi_addr);\n-\t\treturn  EFI_OUT_OF_RESOURCES;\n+\n+\t\t/* See if there is any EFI_CONVENTIONAL_MEMORY allocations */\n+\t\tif (type != EFI_ALLOCATE_ADDRESS) {\n+\t\t\t*memory = efi_get_conventional_start(pages);\n+\t\t\tif (*memory != 0)\n+\t\t\t\treturn efi_allocate_pages(EFI_ALLOCATE_ADDRESS,\n+\t\t\t\t\t\t\t  memory_type, pages,\n+\t\t\t\t\t\t\t  memory);\n+\t\t}\n+\n+\t\treturn EFI_OUT_OF_RESOURCES;\n \t}\n \n \t*memory = efi_addr;\n","prefixes":["5/6"]}