[PATCH v2 3/6] powerpc/module: Optimise nearby branches in ELF V2 ABI stub

Benjamin Gray bgray at linux.ibm.com
Tue Sep 27 13:12:18 AEST 2022


On Mon, 2022-09-26 at 14:49 +0000, Christophe Leroy wrote:
> > +       /* Replace indirect branch sequence with direct branch
> > where possible */
> > +       if (!create_branch(&direct, jump_seq_addr, addr, 0))
> > +               if (patch_instruction(jump_seq_addr, direct))
> 
> Why not use patch_branch() ?

I didn't think of it at the time. To get the same abort-if-patch-failed
semantics then the following should work

  int err;
  ...

  /* Replace indirect branch sequence with direct branch where 
   * possible 
   */
  err = patch_branch(&entry->jump[PPC64_STUB_MTCTR_OFFSET], addr, 0);
  if (err && err != -ERANGE)
      return 0;
> 


More information about the Linuxppc-dev mailing list