[PATCH] Revert "powerpc: Switch to relative jump labels"
Greg Kurz
groug at kaod.org
Fri May 28 20:34:35 AEST 2021
On Fri, 28 May 2021 04:29:43 +0300
Roman Bolshakov <r.bolshakov at yadro.com> wrote:
> This reverts commit b0b3b2c78ec075cec4721986a95abbbac8c3da4f.
>
> Otherwise, direct kernel boot with initramfs no longer works in QEMU.
> It's broken in some bizarre way because a valid initramfs is not
> recognized anymore:
>
> Found initrd at 0xc000000001f70000:0xc000000003d61d64
> rootfs image is not initramfs (XZ-compressed data is corrupt); looks like an initrd
>
> The issue is observed on v5.13-rc3 if the kernel is built with
> defconfig, GCC 7.5.0 and GNU ld 2.32.0.
>
> Cc: Christophe Leroy <christophe.leroy at csgroup.eu>
> Reported-by: Anastasia Kovaleva <a.kovaleva at yadro.com>
> Signed-off-by: Roman Bolshakov <r.bolshakov at yadro.com>
> ---
I'm observing the very same issue and reverting the offending commit
fixes it indeed. Until someone has investigated the root cause, this
looks like a reasonable bug fix to me.
Reviewed-by: Greg Kurz <groug at kaod.org>
and
Tested-by: Greg Kurz <groug at kaod.org>
> arch/powerpc/Kconfig | 1 -
> arch/powerpc/include/asm/jump_label.h | 21 +++++++++++++++------
> arch/powerpc/kernel/jump_label.c | 4 ++--
> 3 files changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 088dd2afcfe4..59e0d55ee01d 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -189,7 +189,6 @@ config PPC
> select HAVE_ARCH_HUGE_VMALLOC if HAVE_ARCH_HUGE_VMAP
> select HAVE_ARCH_HUGE_VMAP if PPC_BOOK3S_64 && PPC_RADIX_MMU
> select HAVE_ARCH_JUMP_LABEL
> - select HAVE_ARCH_JUMP_LABEL_RELATIVE
> select HAVE_ARCH_KASAN if PPC32 && PPC_PAGE_SHIFT <= 14
> select HAVE_ARCH_KASAN_VMALLOC if PPC32 && PPC_PAGE_SHIFT <= 14
> select HAVE_ARCH_KFENCE if PPC32
> diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
> index 2d5c6bec2b4f..09297ec9fa52 100644
> --- a/arch/powerpc/include/asm/jump_label.h
> +++ b/arch/powerpc/include/asm/jump_label.h
> @@ -20,8 +20,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran
> asm_volatile_goto("1:\n\t"
> "nop # arch_static_branch\n\t"
> ".pushsection __jump_table, \"aw\"\n\t"
> - ".long 1b - ., %l[l_yes] - .\n\t"
> - JUMP_ENTRY_TYPE "%c0 - .\n\t"
> + JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t"
> ".popsection \n\t"
> : : "i" (&((char *)key)[branch]) : : l_yes);
>
> @@ -35,8 +34,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
> asm_volatile_goto("1:\n\t"
> "b %l[l_yes] # arch_static_branch_jump\n\t"
> ".pushsection __jump_table, \"aw\"\n\t"
> - ".long 1b - ., %l[l_yes] - .\n\t"
> - JUMP_ENTRY_TYPE "%c0 - .\n\t"
> + JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t"
> ".popsection \n\t"
> : : "i" (&((char *)key)[branch]) : : l_yes);
>
> @@ -45,12 +43,23 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
> return true;
> }
>
> +#ifdef CONFIG_PPC64
> +typedef u64 jump_label_t;
> +#else
> +typedef u32 jump_label_t;
> +#endif
> +
> +struct jump_entry {
> + jump_label_t code;
> + jump_label_t target;
> + jump_label_t key;
> +};
> +
> #else
> #define ARCH_STATIC_BRANCH(LABEL, KEY) \
> 1098: nop; \
> .pushsection __jump_table, "aw"; \
> - .long 1098b - ., LABEL - .; \
> - FTR_ENTRY_LONG KEY; \
> + FTR_ENTRY_LONG 1098b, LABEL, KEY; \
> .popsection
> #endif
>
> diff --git a/arch/powerpc/kernel/jump_label.c b/arch/powerpc/kernel/jump_label.c
> index ce87dc5ea23c..144858027fa3 100644
> --- a/arch/powerpc/kernel/jump_label.c
> +++ b/arch/powerpc/kernel/jump_label.c
> @@ -11,10 +11,10 @@
> void arch_jump_label_transform(struct jump_entry *entry,
> enum jump_label_type type)
> {
> - struct ppc_inst *addr = (struct ppc_inst *)jump_entry_code(entry);
> + struct ppc_inst *addr = (struct ppc_inst *)(unsigned long)entry->code;
>
> if (type == JUMP_LABEL_JMP)
> - patch_branch(addr, jump_entry_target(entry), 0);
> + patch_branch(addr, entry->target, 0);
> else
> patch_instruction(addr, ppc_inst(PPC_INST_NOP));
> }
More information about the Linuxppc-dev
mailing list