aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/setup_32.c
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@c-s.fr>2017-08-23 16:54:38 +0200
committerMichael Ellerman <mpe@ellerman.id.au>2017-09-01 16:42:46 +1000
commitad1b0122bdc96cbcfcfbc9ef59f9bf3658802a72 (patch)
tree49b31cc88d2728f2f75c3292a1ea4250b48f2695 /arch/powerpc/kernel/setup_32.c
parentpowerpc/32: optimise memset() (diff)
downloadlinux-dev-ad1b0122bdc96cbcfcfbc9ef59f9bf3658802a72.tar.xz
linux-dev-ad1b0122bdc96cbcfcfbc9ef59f9bf3658802a72.zip
powerpc/32: remove a NOP from memset()
memset() is patched after initialisation to activate the optimised part which uses cache instructions. Today we have a 'b 2f' to skip the optimised patch, which then gets replaced by a NOP, implying a useless cycle consumption. As we have a 'bne 2f' just before, we could use that instruction for the live patching, hence removing the need to have a dedicated 'b 2f' to be replaced by a NOP. This patch changes the 'bne 2f' by a 'b 2f'. During init, that 'b 2f' is then replaced by 'bne 2f' Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/kernel/setup_32.c')
-rw-r--r--arch/powerpc/kernel/setup_32.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 2f88f6cf1a42..51ebc01fff52 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -98,6 +98,9 @@ extern unsigned int memset_nocache_branch; /* Insn to be replaced by NOP */
notrace void __init machine_init(u64 dt_ptr)
{
+ unsigned int *addr = &memset_nocache_branch;
+ unsigned long insn;
+
/* Configure static keys first, now that we're relocated. */
setup_feature_keys();
@@ -105,7 +108,9 @@ notrace void __init machine_init(u64 dt_ptr)
udbg_early_init();
patch_instruction((unsigned int *)&memcpy, PPC_INST_NOP);
- patch_instruction(&memset_nocache_branch, PPC_INST_NOP);
+
+ insn = create_cond_branch(addr, branch_target(addr), 0x820000);
+ patch_instruction(addr, insn); /* replace b by bne cr0 */
/* Do some early initialization based on the flat device tree */
early_init_devtree(__va(dt_ptr));