Message ID | 20240616173105.7430-4-heinrich.schuchardt@canonical.com |
---|---|
State | Accepted |
Commit | 5225060b892d96a6da48f539609fb060859e955f |
Delegated to: | Tom Rini |
Headers | show |
Series | cmd: avoid duplicate weak functions | expand |
On Sun, 16 Jun 2024 at 20:31, Heinrich Schuchardt <heinrich.schuchardt@canonical.com> wrote: > > If multiple weak implementations of a weak function exist, it is unclear > which one the linker should chose. cmd/cache.c already defines a weak > invalidate_icache_all(). > > We don't need a call to invalidate_icache_all() on x86. > ARM, RISC-V, and Sandbox provide an implementation. > > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> > --- > lib/efi_loader/efi_image_loader.c | 13 +++++++------ > lib/efi_loader/efi_runtime.c | 7 ++++++- > 2 files changed, 13 insertions(+), 7 deletions(-) > > diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c > index 60424360328..45dc5b6b244 100644 > --- a/lib/efi_loader/efi_image_loader.c > +++ b/lib/efi_loader/efi_image_loader.c > @@ -173,11 +173,6 @@ static efi_status_t efi_loader_relocate(const IMAGE_BASE_RELOCATION *rel, > return EFI_SUCCESS; > } > > -void __weak invalidate_icache_all(void) > -{ > - /* If the system doesn't support icache_all flush, cross our fingers */ > -} > - > /** > * efi_set_code_and_data_type() - determine the memory types to be used for code > * and data. > @@ -986,7 +981,13 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle, > /* Flush cache */ > flush_cache((ulong)efi_reloc, > ALIGN(virt_size, EFI_CACHELINE_SIZE)); > - invalidate_icache_all(); > + > + /* > + * If on x86 a write affects a prefetched instruction, > + * the prefetch queue is invalidated. > + */ > + if (!CONFIG_IS_ENABLED(X86)) > + invalidate_icache_all(); > > /* Populate the loaded image interface bits */ > loaded_image_info->image_base = efi_reloc; > diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c > index 011bcd04836..05369c47b01 100644 > --- a/lib/efi_loader/efi_runtime.c > +++ b/lib/efi_loader/efi_runtime.c > @@ -783,7 +783,12 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map) > lastoff = offset; > #endif > > - invalidate_icache_all(); > + /* > + * If on x86 a write affects a prefetched instruction, > + * the prefetch queue is invalidated. > + */ > + if (!CONFIG_IS_ENABLED(X86)) > + invalidate_icache_all(); > } > > /** > -- > 2.43.0 > Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
On Sun, Jun 16, 2024 at 07:31:05PM +0200, Heinrich Schuchardt wrote: > If multiple weak implementations of a weak function exist, it is unclear > which one the linker should chose. cmd/cache.c already defines a weak > invalidate_icache_all(). > > We don't need a call to invalidate_icache_all() on x86. > ARM, RISC-V, and Sandbox provide an implementation. > > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> > Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Tom Rini <trini@konsulko.com>
diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index 60424360328..45dc5b6b244 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -173,11 +173,6 @@ static efi_status_t efi_loader_relocate(const IMAGE_BASE_RELOCATION *rel, return EFI_SUCCESS; } -void __weak invalidate_icache_all(void) -{ - /* If the system doesn't support icache_all flush, cross our fingers */ -} - /** * efi_set_code_and_data_type() - determine the memory types to be used for code * and data. @@ -986,7 +981,13 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle, /* Flush cache */ flush_cache((ulong)efi_reloc, ALIGN(virt_size, EFI_CACHELINE_SIZE)); - invalidate_icache_all(); + + /* + * If on x86 a write affects a prefetched instruction, + * the prefetch queue is invalidated. + */ + if (!CONFIG_IS_ENABLED(X86)) + invalidate_icache_all(); /* Populate the loaded image interface bits */ loaded_image_info->image_base = efi_reloc; diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 011bcd04836..05369c47b01 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -783,7 +783,12 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map) lastoff = offset; #endif - invalidate_icache_all(); + /* + * If on x86 a write affects a prefetched instruction, + * the prefetch queue is invalidated. + */ + if (!CONFIG_IS_ENABLED(X86)) + invalidate_icache_all(); } /**
If multiple weak implementations of a weak function exist, it is unclear which one the linker should chose. cmd/cache.c already defines a weak invalidate_icache_all(). We don't need a call to invalidate_icache_all() on x86. ARM, RISC-V, and Sandbox provide an implementation. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> --- lib/efi_loader/efi_image_loader.c | 13 +++++++------ lib/efi_loader/efi_runtime.c | 7 ++++++- 2 files changed, 13 insertions(+), 7 deletions(-)