> From: Simon Glass <[email protected]>
> Date: Sun,  6 Apr 2025 10:12:47 +1200

Hi Simon,

> This removal should be the last thing done, so that U-Boot does no more
> memory allocations afterwards. Move it and add a comment.

I really don't see what problem this is solving.  If DMA is stopped
before device driver memory is freed there is no problem with
overwriting memory.  And if DMA isn't stopped, it may overwrite memory
as soon as the OS starts using it.

All you're doing here is causing a conflict with the change that
Heinrich is proposing.

> Note that the TCG2 log is updated after this call, but I cannot see any
> allocations there.
> 
> Reported-by: Christian Kohlschütter <[email protected]>
> 
> Signed-off-by: Simon Glass <[email protected]>
> ---
> 
>  lib/efi_loader/efi_boottime.c | 21 +++++++++++++--------
>  1 file changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index ffe43accd1e..e525662f82f 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -2250,14 +2250,6 @@ static efi_status_t EFIAPI 
> efi_exit_boot_services(efi_handle_t image_handle,
>                       list_del(&evt->link);
>       }
>  
> -     if (!efi_st_keep_devices) {
> -             bootm_disable_interrupts();
> -             if (IS_ENABLED(CONFIG_USB_DEVICE))
> -                     udc_disconnect();
> -             board_quiesce_devices();
> -             dm_remove_devices_active();
> -     }
> -
>       /* Patch out unsupported runtime function */
>       efi_runtime_detach();
>  
> @@ -2279,6 +2271,19 @@ static efi_status_t EFIAPI 
> efi_exit_boot_services(efi_handle_t image_handle,
>       /* Give the payload some time to boot */
>       efi_set_watchdog(0);
>       schedule();
> +
> +     /*
> +      * this should be the last thing done, to avoid memory allocations
> +      * between removing devices and the OS taking over
> +      */
> +     if (!efi_st_keep_devices) {
> +             bootm_disable_interrupts();
> +             if (IS_ENABLED(CONFIG_USB_DEVICE))
> +                     udc_disconnect();
> +             board_quiesce_devices();
> +             dm_remove_devices_active();
> +     }
> +
>  out:
>       if (IS_ENABLED(CONFIG_EFI_TCG2_PROTOCOL)) {
>               if (ret != EFI_SUCCESS)
> -- 
> 2.43.0
> 
> base-commit: bcfa94be955ef263d37918ef4b8f898ee8964c61
> branch: eth
> 

Reply via email to