diff mbox series

[v1,03/13] arm64: Downgrade flush_icache_range to invalidate

Message ID 20210511144252.3779113-4-tabba@google.com (mailing list archive)
State New, archived
Headers show
Series Tidy up cache.S | expand

Commit Message

Fuad Tabba May 11, 2021, 2:42 p.m. UTC
Since __flush_dcache_area is called right before,
invalidate_icache_range is sufficient in this case.

No functional change intended.

Reported-by: Catalin Marinas <catalin.marinas@arm.com>
Reported-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/linux-arch/20200511110014.lb9PEahJ4hVOYrbwIb_qUHXyNy9KQzNFdb_I3YlzY6A@z/
Signed-off-by: Fuad Tabba <tabba@google.com>
---
 arch/arm64/kernel/machine_kexec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Ard Biesheuvel May 11, 2021, 2:53 p.m. UTC | #1
On Tue, 11 May 2021 at 16:43, Fuad Tabba <tabba@google.com> wrote:
>
> Since __flush_dcache_area is called right before,
> invalidate_icache_range is sufficient in this case.
>
> No functional change intended.
>
> Reported-by: Catalin Marinas <catalin.marinas@arm.com>
> Reported-by: Will Deacon <will@kernel.org>
> Link: https://lore.kernel.org/linux-arch/20200511110014.lb9PEahJ4hVOYrbwIb_qUHXyNy9KQzNFdb_I3YlzY6A@z/
> Signed-off-by: Fuad Tabba <tabba@google.com>
> ---
>  arch/arm64/kernel/machine_kexec.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c
> index 90a335c74442..001ffbfc645b 100644
> --- a/arch/arm64/kernel/machine_kexec.c
> +++ b/arch/arm64/kernel/machine_kexec.c
> @@ -70,8 +70,9 @@ int machine_kexec_post_load(struct kimage *kimage)
>
>         /* Flush the reloc_code in preparation for its execution. */
>         __flush_dcache_area(reloc_code, arm64_relocate_new_kernel_size);
> -       flush_icache_range((uintptr_t)reloc_code, (uintptr_t)reloc_code +
> -                          arm64_relocate_new_kernel_size);
> +       invalidate_icache_range((uintptr_t)reloc_code,
> +                               (uintptr_t)reloc_code +
> +                                       arm64_relocate_new_kernel_size);
>

So this is a clean to the PoC followed by a I-cache invalidate to the
PoU, right? Perhaps we could improve the comment while at it (avoid
'flush', and mention that the code needs to be cleaned to the PoC and
invalidated from the I-cache for execution with the MMU off and
I-cache on)


>         return 0;
>  }
> --
> 2.31.1.607.g51e8a6a459-goog
>
Fuad Tabba May 12, 2021, 9:45 a.m. UTC | #2
Hi Ard,

> > diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c
> > index 90a335c74442..001ffbfc645b 100644
> > --- a/arch/arm64/kernel/machine_kexec.c
> > +++ b/arch/arm64/kernel/machine_kexec.c
> > @@ -70,8 +70,9 @@ int machine_kexec_post_load(struct kimage *kimage)
> >
> >         /* Flush the reloc_code in preparation for its execution. */
> >         __flush_dcache_area(reloc_code, arm64_relocate_new_kernel_size);
> > -       flush_icache_range((uintptr_t)reloc_code, (uintptr_t)reloc_code +
> > -                          arm64_relocate_new_kernel_size);
> > +       invalidate_icache_range((uintptr_t)reloc_code,
> > +                               (uintptr_t)reloc_code +
> > +                                       arm64_relocate_new_kernel_size);
> >
>
> So this is a clean to the PoC followed by a I-cache invalidate to the
> PoU, right? Perhaps we could improve the comment while at it (avoid
> 'flush', and mention that the code needs to be cleaned to the PoC and
> invalidated from the I-cache for execution with the MMU off and
> I-cache on)

Yes it is. The renaming I do later on in the series clarifies this,
but the comment should be fixed to match. I'll do that in v2.

Thanks,
/fuad

>
> >         return 0;
> >  }
> > --
> > 2.31.1.607.g51e8a6a459-goog
> >
diff mbox series

Patch

diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c
index 90a335c74442..001ffbfc645b 100644
--- a/arch/arm64/kernel/machine_kexec.c
+++ b/arch/arm64/kernel/machine_kexec.c
@@ -70,8 +70,9 @@  int machine_kexec_post_load(struct kimage *kimage)
 
 	/* Flush the reloc_code in preparation for its execution. */
 	__flush_dcache_area(reloc_code, arm64_relocate_new_kernel_size);
-	flush_icache_range((uintptr_t)reloc_code, (uintptr_t)reloc_code +
-			   arm64_relocate_new_kernel_size);
+	invalidate_icache_range((uintptr_t)reloc_code,
+				(uintptr_t)reloc_code +
+					arm64_relocate_new_kernel_size);
 
 	return 0;
 }