[RFC PATCH 0/4] consolidate PowerPC instruction encoding macros

Balamuruhan S bala24 at linux.ibm.com
Fri Mar 20 19:18:33 AEDT 2020


ppc-opcode.h have base instruction encoding wrapped with stringify_in_c()
for raw encoding to have compatibility. But there are redundant macros for
base instruction encodings in bpf, instruction emulation test infrastructure
and powerpc selftests.

Currently PPC_INST_* macros are used for encoding instruction opcode and PPC_*
for raw instuction encoding, this rfc patchset introduces PPC_ENCODE_* macros
for base instruction encoding and reuse it from elsewhere. With this change we
can avoid redundant macro definitions in multiple files and start adding new
instructions in ppc-opcode.h in future.

TODO:
----
We can still improve further by moving all the instruction encoding
from bpf_jit.h to ppc-opcode.h and reuse them from bpf source. It can be
implemented based on the thoughts and feedback on this RFC.

This patchset is based on mpe's merge branch of linuxppc tree with a
fix patch on top of it,
https://patchwork.ozlabs.org/patch/1252760/

Thanks to Naveen and Sandipan on overall suggestions/improvements.

Tested it by compiling vmlinux with and without the changes and the
objdump of them remains to be same,

# diff vmlinux_objdump vmlinux_rfc_objdump 
2c2
< vmlinux:     file format elf64-powerpcle
---
> vmlinux_rfc:     file format elf64-powerpcle


I would request for your review and suggestions to make it better.

Balamuruhan S (4):
  powerpc ppc-opcode: consolidate PowerPC instruction macros
  powerpc selftest: reuse ppc-opcode macros to avoid redundancy
  powerpc ppc-opcode: move ppc instuction encoding from
    test_emulate_step
  powerpc kvm_asm: rename PPC_LD and PPC_STD macros to avoid
    redefinition

 arch/powerpc/include/asm/kvm_asm.h            |   8 +-
 arch/powerpc/include/asm/ppc-opcode.h         | 364 ++++++++++++------
 arch/powerpc/kvm/booke_interrupts.S           |   8 +-
 arch/powerpc/kvm/bookehv_interrupts.S         |  28 +-
 arch/powerpc/lib/test_emulate_step.c          | 155 +++-----
 arch/powerpc/net/bpf_jit.h                    |   8 -
 arch/powerpc/net/bpf_jit32.h                  |  10 +-
 arch/powerpc/net/bpf_jit64.h                  |   4 +-
 arch/powerpc/net/bpf_jit_comp.c               |   2 +-
 arch/powerpc/net/bpf_jit_comp64.c             |  14 +-
 .../selftests/powerpc/stringloops/Makefile    |  15 +-
 .../powerpc/stringloops/asm/asm-const.h       |   1 +
 .../powerpc/stringloops/asm/ppc-opcode.h      |  36 +-
 13 files changed, 361 insertions(+), 292 deletions(-)
 create mode 120000 tools/testing/selftests/powerpc/stringloops/asm/asm-const.h
 mode change 100644 => 120000 tools/testing/selftests/powerpc/stringloops/asm/ppc-opcode.h


base-commit: 8a445cbcb9f5090cb07ec6cbb89a8a1fc99a0ff7
prerequisite-patch-id: c271d8516dd39526e848dfa95ae38c9205002d2c
-- 
2.24.1



More information about the Linuxppc-dev mailing list