From: Alexander Dahl <ada@thorsis.com>
To: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Cc: "Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Liya Huang" <1425075683@qq.com>,
"Adriano Cordova" <adrianox@gmail.com>,
"Tom Rini" <trini@konsulko.com>, "Simon Glass" <sjg@chromium.org>,
"Sughosh Ganu" <sughosh.ganu@linaro.org>,
"Vincent Stehlé" <vincent.stehle@arm.com>,
"Sam Protsenko" <semen.protsenko@linaro.org>,
"Janne Grunau" <j@jannau.net>,
u-boot@lists.denx.de
Subject: Re: [PATCH 2/3] lmb: move lmb_map_update_notify() to EFI
Date: Fri, 21 Feb 2025 09:38:08 +0100 [thread overview]
Message-ID: <20250221-evaluate-freefall-dccd46ec232c@thorsis.com> (raw)
In-Reply-To: <20250216111241.6846-3-heinrich.schuchardt@canonical.com>
Hei hei,
Am Sun, Feb 16, 2025 at 12:12:40PM +0100 schrieb Heinrich Schuchardt:
> When building with qemu_arm64_defconfig with CONFIG_CC_OPTIMIZE_FOR_DEBUG=y
> and CONFIG_EFI_LOADER an error undefined reference to efi_add_memory_map_pg
> occurs.
>
> Move the EFI dependent part of lmb_map_update_notify() to the EFI
> sub-system.
>
> Reported-by: Liya Huang <1425075683@qq.com>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> Acked-by: Liya Huang <1425075683@qq.com>
This seems to be the same underlying problem I reported back in January:
https://lore.kernel.org/u-boot/20250117-molecular-quicksand-e80bf947313e@thorsis.com/
FWIW, while your patch hit master, and the follow-up to my report did
not yet … you might be interested that master does not fail to build
the armv5 targets with CC_OPTIMIZE_FOR_DEBUG anymore.
Besides: keeping EFI code in the EFI subsystem seems the right
approach to me, too. ;-)
Thanks and Greets
Alex
> ---
> include/efi_loader.h | 15 +++++++++++++++
> lib/efi_loader/efi_memory.c | 27 +++++++++++++++++++++++++++
> lib/lmb.c | 31 +++----------------------------
> 3 files changed, 45 insertions(+), 28 deletions(-)
>
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index dcae6a731a0..db3d20fd753 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -1263,6 +1263,21 @@ efi_status_t efi_disk_get_device_name(const efi_handle_t handle, char *buf, int
> */
> void efi_add_known_memory(void);
>
> +/**
> + * efi_map_update_notify() - notify EFI of memory map changes
> + *
> + * @addr: start of memory area
> + * @size: size of memory area
> + * @op: type of change
> + * Return: 0 if change could be processed
> + */
> +#ifdef CONFIG_EFI_LOADER
> +int efi_map_update_notify(phys_addr_t addr, phys_size_t size,
> + enum lmb_map_op op);
> +#else
> +#define efi_map_update_notify(addr, size, op) (0)
> +#endif
> +
> /**
> * efi_load_option_dp_join() - join device-paths for load option
> *
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index 1212772471e..11d092dc289 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -865,3 +865,30 @@ int efi_memory_init(void)
>
> return 0;
> }
> +
> +int efi_map_update_notify(phys_addr_t addr, phys_size_t size,
> + enum lmb_map_op op)
> +{
> + u64 efi_addr;
> + u64 pages;
> + efi_status_t status;
> +
> + efi_addr = (uintptr_t)map_sysmem(addr, 0);
> + pages = efi_size_in_pages(size + (efi_addr & EFI_PAGE_MASK));
> + efi_addr &= ~EFI_PAGE_MASK;
> +
> + status = efi_add_memory_map_pg(efi_addr, pages,
> + op == LMB_MAP_OP_RESERVE ?
> + EFI_BOOT_SERVICES_DATA :
> + EFI_CONVENTIONAL_MEMORY,
> + false);
> + if (status != EFI_SUCCESS) {
> + log_err("LMB Map notify failure %lu\n",
> + status & ~EFI_ERROR_MASK);
> + return -1;
> + }
> + unmap_sysmem((void *)(uintptr_t)efi_addr);
> +
> + return 0;
> +}
> +
> diff --git a/lib/lmb.c b/lib/lmb.c
> index 7534a231c99..93fc1bea07c 100644
> --- a/lib/lmb.c
> +++ b/lib/lmb.c
> @@ -426,37 +426,12 @@ long io_lmb_free(struct lmb *io_lmb, phys_addr_t base, phys_size_t size)
>
> static struct lmb lmb;
>
> -static bool lmb_should_notify(u32 flags)
> -{
> - return !lmb.test && !(flags & LMB_NONOTIFY) &&
> - CONFIG_IS_ENABLED(EFI_LOADER);
> -}
> -
> static int lmb_map_update_notify(phys_addr_t addr, phys_size_t size,
> enum lmb_map_op op, u32 flags)
> {
> - u64 efi_addr;
> - u64 pages;
> - efi_status_t status;
> -
> - if (!lmb_should_notify(flags))
> - return 0;
> -
> - efi_addr = (uintptr_t)map_sysmem(addr, 0);
> - pages = efi_size_in_pages(size + (efi_addr & EFI_PAGE_MASK));
> - efi_addr &= ~EFI_PAGE_MASK;
> -
> - status = efi_add_memory_map_pg(efi_addr, pages,
> - op == LMB_MAP_OP_RESERVE ?
> - EFI_BOOT_SERVICES_DATA :
> - EFI_CONVENTIONAL_MEMORY,
> - false);
> - if (status != EFI_SUCCESS) {
> - log_err("%s: LMB Map notify failure %lu\n", __func__,
> - status & ~EFI_ERROR_MASK);
> - return -1;
> - }
> - unmap_sysmem((void *)(uintptr_t)efi_addr);
> + if (CONFIG_IS_ENABLED(EFI_LOADER) &&
> + !lmb.test && !(flags & LMB_NONOTIFY))
> + return efi_map_update_notify(addr, size, op);
>
> return 0;
> }
> --
> 2.47.1
>
next prev parent reply other threads:[~2025-02-21 8:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-16 11:12 [PATCH 0/3] lmb: move lmb_map_update_notify() to EFI Heinrich Schuchardt
2025-02-16 11:12 ` [PATCH 1/3] lmb: avoid superfluous value check in lmb_map_update_notify() Heinrich Schuchardt
2025-02-20 6:57 ` Ilias Apalodimas
2025-02-16 11:12 ` [PATCH 2/3] lmb: move lmb_map_update_notify() to EFI Heinrich Schuchardt
2025-02-17 9:55 ` Sughosh Ganu
2025-02-20 8:28 ` Heinrich Schuchardt
2025-02-20 8:48 ` Ilias Apalodimas
2025-02-21 8:38 ` Alexander Dahl [this message]
2025-02-16 11:12 ` [PATCH 3/3] efi_loader: make efi_add_memory_map_pg() static Heinrich Schuchardt
2025-02-18 7:03 ` Ilias Apalodimas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250221-evaluate-freefall-dccd46ec232c@thorsis.com \
--to=ada@thorsis.com \
--cc=1425075683@qq.com \
--cc=adrianox@gmail.com \
--cc=heinrich.schuchardt@canonical.com \
--cc=ilias.apalodimas@linaro.org \
--cc=j@jannau.net \
--cc=semen.protsenko@linaro.org \
--cc=sjg@chromium.org \
--cc=sughosh.ganu@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=vincent.stehle@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.