From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E767BC54EBD for ; Mon, 9 Jan 2023 07:19:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C7E2285609; Mon, 9 Jan 2023 08:19:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="NzQMoi7R"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6E5AF85548; Mon, 9 Jan 2023 08:19:10 +0100 (CET) Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6285E8560F for ; Mon, 9 Jan 2023 08:19:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x629.google.com with SMTP id ud5so17801932ejc.4 for ; Sun, 08 Jan 2023 23:19:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=N9r4tCahVEicQGiysaQwLMX1u7asRGf5PN7eG5+orG0=; b=NzQMoi7Rylg7rdPFmJ8VJATSYQPNNFrkw9mC6awC3HY6zJngS+71mIUwB0B+VAOj+3 2wIfTeGmnzilcbBxE3urBrNQ8smPrhL5fxUYIVEVk5RCHyDFr1nbvAGzaoavIPv4sW2N UN3OZLWet14iEeRxycZ0gxwewaOG8yfw6V3LOGwcq3JGreyZcgpMFTnFkwvQmwI4h6X7 WWvnVt6p9FPaagD7lXfEJWT0t/Kvqzz7XOP7tKq+9D90PVr6HnM8tUPEf1nw/L3HI8aN yoeeWwFRhK1LPxJWQkcxaetNSDWOzh0Kwa70J5PTuVjAxnQjbKWlHnQwGKTRKI6m4dpv vrAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=N9r4tCahVEicQGiysaQwLMX1u7asRGf5PN7eG5+orG0=; b=l4XOIB7v4PE9xsnVMDtWgqVdc7XhO0JoT7poQiAh7Zovg5w3bvL87/877qQ12zWMJt gb28CYy7MlrcPJDnP4K0c9bvBzm8f00GOjiavpnXRU3vzR3urrHJTrngJxbsPAwmMXAP 8gMWGtqCeU3mvqqF00Qm0OXRhMnNazaFef1FFprdnvtUmzXeak1BryEyiLi01SpPl87X MUjkB5muKJUN1XebBbm1hR8y51teXmRlq6kdx6QlgEcRW3PX7TfLsbLBheTl51bt34yL IpCQBi/LVdH/5uRTPTWdSBDUFaP/V3MaDnocdHQDi5Sf3+XmuYOC0g4WZAkZLbb/lcBk spEw== X-Gm-Message-State: AFqh2krZFzmHaLz4mvvroX73xvitfyoELyKwM7umAjfja0hdCQTJSz60 3Zo7GXro5LjL06PcIPe5IiPd+w== X-Google-Smtp-Source: AMrXdXsh0aJZIOLHqu0l+TQVZOnJlJ67Wz3QhaOPG6zoX8XCOxAOySfmZw/5aqkA3X6nppXh5TIcqg== X-Received: by 2002:a17:906:5e41:b0:84d:465e:49b7 with SMTP id b1-20020a1709065e4100b0084d465e49b7mr2159349eju.63.1673248743654; Sun, 08 Jan 2023 23:19:03 -0800 (PST) Received: from hades (ppp079167090036.access.hol.gr. [79.167.90.36]) by smtp.gmail.com with ESMTPSA id lb25-20020a170907785900b007c00323cc23sm3392668ejc.27.2023.01.08.23.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 23:19:03 -0800 (PST) Date: Mon, 9 Jan 2023 09:19:00 +0200 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: Tom Rini , Liviu Dudau , Simon Glass , Stefan Roese , Patrick Delaunay , Jaehoon Chung , Michal Simek , Patrice Chotard , Ashok Reddy Soma , u-boot@lists.denx.de Subject: Re: [PATCH v2 3/3] lmb: consider EFI memory map Message-ID: References: <20230105202536.190392-1-heinrich.schuchardt@canonical.com> <20230105202536.190392-4-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230105202536.190392-4-heinrich.schuchardt@canonical.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Thu, Jan 05, 2023 at 09:25:36PM +0100, Heinrich Schuchardt wrote: > Add reservations for all EFI memory areas that are not > EFI_CONVENTIONAL_MEMORY. > > Signed-off-by: Heinrich Schuchardt > --- > v2: > use efi_get_memory_map_alloc() > --- > lib/lmb.c | 36 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) > > diff --git a/lib/lmb.c b/lib/lmb.c > index c599608fa3..ec790760db 100644 > --- a/lib/lmb.c > +++ b/lib/lmb.c > @@ -7,7 +7,9 @@ > */ > > #include > +#include > #include > +#include > #include > #include > #include > @@ -153,6 +155,37 @@ void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align) > } > } > > +/** > + * efi_lmb_reserve() - add reservations for EFI memory > + * > + * Add reservations for all EFI memory areas that are not > + * EFI_CONVENTIONAL_MEMORY. > + * > + * @lmb: lmb environment > + * Return: 0 on success, 1 on failure > + */ > +static __maybe_unused int efi_lmb_reserve(struct lmb *lmb) > +{ > + struct efi_mem_desc *memmap = NULL, *map; > + efi_uintn_t i, map_size = 0; > + efi_status_t ret; > + > + ret = efi_get_memory_map_alloc(&map_size, &memmap); > + if (ret != EFI_SUCCESS) > + return 1; > + > + for (i = 0, map = memmap; i < map_size / sizeof(*map); ++map, ++i) { > + if (map->type != EFI_CONVENTIONAL_MEMORY) > + lmb_reserve(lmb, > + map_to_sysmem((void *)(uintptr_t) > + map->physical_start), > + map->num_pages * EFI_PAGE_SIZE); > + } > + efi_free_pool(memmap); > + > + return 0; > +} > + > static void lmb_reserve_common(struct lmb *lmb, void *fdt_blob) > { > arch_lmb_reserve(lmb); > @@ -160,6 +193,9 @@ static void lmb_reserve_common(struct lmb *lmb, void *fdt_blob) > > if (CONFIG_IS_ENABLED(OF_LIBFDT) && fdt_blob) > boot_fdt_add_mem_rsv_regions(lmb, fdt_blob); > + > + if (CONFIG_IS_ENABLED(EFI_LOADER)) > + efi_lmb_reserve(lmb); > } > > /* Initialize the struct, add memory and call arch/board reserve functions */ > -- > 2.37.2 > Reviewed-by: Ilias Apalodimas