From: Huacai Chen <chenhuacai@kernel.org>
To: WANG Rui <r@hev.cc>
Cc: Ard Biesheuvel <ardb@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
WANG Xuerui <kernel@xen0n.name>,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
loongarch@lists.linux.dev
Subject: Re: [PATCH 2/2] efi/libstub: Synchronize instruction cache after kernel relocation
Date: Mon, 27 Apr 2026 16:09:25 +0800 [thread overview]
Message-ID: <CAAhV-H7zGFjzBTCLMZvE+etd2J9Te1+9Xr9GwtjvBSXgGYfQEw@mail.gmail.com> (raw)
In-Reply-To: <20260427034451.717817-3-r@hev.cc>
On Mon, Apr 27, 2026 at 11:45 AM WANG Rui <r@hev.cc> wrote:
>
> The relocated kernel image is copied to its new location using memcpy().
> On architectures with separate instruction and data caches, the copied
> instructions may remain stale in the instruction cache, leading to the
> execution of outdated contents.
>
> Call efi_cache_sync_image() after the relocation copy to ensure the
> instruction cache is synchronized with the updated memory contents before
> control is transferred to the relocated kernel.
>
> Signed-off-by: WANG Rui <r@hev.cc>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
> drivers/firmware/efi/libstub/relocate.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/firmware/efi/libstub/relocate.c b/drivers/firmware/efi/libstub/relocate.c
> index d4264bfb6dc1..913b425d089d 100644
> --- a/drivers/firmware/efi/libstub/relocate.c
> +++ b/drivers/firmware/efi/libstub/relocate.c
> @@ -158,6 +158,7 @@ efi_status_t efi_relocate_kernel(unsigned long *image_addr,
> * have been allocated by UEFI, so we can safely use memcpy.
> */
> memcpy((void *)new_addr, (void *)cur_image_addr, image_size);
> + efi_cache_sync_image(new_addr, image_size);
>
> /* Return the new address of the relocated image. */
> *image_addr = new_addr;
> --
> 2.54.0
>
prev parent reply other threads:[~2026-04-27 8:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 3:44 [PATCH 0/2] efi/libstub: Ensure instruction cache coherency after kernel relocation WANG Rui
2026-04-27 3:44 ` [PATCH 1/2] efi/loongarch: Implement efi_cache_sync_image WANG Rui
2026-04-27 8:09 ` Huacai Chen
2026-04-27 3:44 ` [PATCH 2/2] efi/libstub: Synchronize instruction cache after kernel relocation WANG Rui
2026-04-27 8:09 ` Huacai Chen [this message]
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=CAAhV-H7zGFjzBTCLMZvE+etd2J9Te1+9Xr9GwtjvBSXgGYfQEw@mail.gmail.com \
--to=chenhuacai@kernel.org \
--cc=ardb@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=kernel@xen0n.name \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=r@hev.cc \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).