[PATCH 1/1] efi_loader: stop network in EXIT_BOOT_SERVICES
Christian Kohlschütter
christian at kohlschutter.com
Sat Apr 5 22:45:11 CEST 2025
On 5. Apr 2025, at 13:00, Ilias Apalodimas <ilias.apalodimas at linaro.org> wrote:
>
> On Sat, Apr 5, 2025, 08:58 Heinrich Schuchardt <heinrich.schuchardt at canonical.com> wrote:
> It has been reported that memory corruption can occurred because network
> packages where received after EXIT_BOOT_SERVICES. See the thread
> starting at [1].
>
> We try to remove all drivers when EXIT_BOOT_SERVICES is called. But
>
> * Some network drivers don't call their own stop method when removed.
> * Some network drivers don't have a remove method.
> * Some devices have CONFIG_DM_DEVICE_REMOVE=n.
>
> Let's call eth_halt() in EXIT_BOOT_SERVICES explicitly.
>
> Thanks Heinrich
>
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
>
> [1]
> https://lore.kernel.org/all/C101B675-EEE6-44CB-8A44-83F72182FBD6@kohlschutter.com/
>
> Cc: Michael Brown <mcb30 at ipxe.org>
> Reported-by: Christian Kohlschütter <christian at kohlschutter.com>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
> lib/efi_loader/efi_boottime.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index 5164cb15986..eaa6464fa39 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -15,6 +15,7 @@
> #include <irq_func.h>
> #include <log.h>
> #include <malloc.h>
> +#include <net-common.h>
> #include <pe.h>
> #include <time.h>
> #include <u-boot/crc.h>
> @@ -2235,6 +2236,8 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
> bootm_disable_interrupts();
> if (IS_ENABLED(CONFIG_USB_DEVICE))
> udc_disconnect();
> + if (IS_ENABLED(CONFIG_DM_ETH))
> + eth_halt();
> board_quiesce_devices();
> dm_remove_devices_active();
> }
> --
> 2.48.1
>
Works beautifully, and is not specific to any affected board. Very nice.
Tested-by: Christian Kohlschütter <christian at kohlschutter.com <mailto:christian at kohlschutter.com>>
Thanks a lot!
Christian
More information about the U-Boot
mailing list