From 4449c81a85eef44b10532032207e8db5858c00ee Mon Sep 17 00:00:00 2001 From: David Faust Date: Wed, 26 Aug 2020 15:39:00 +0200 Subject: bpf: add xBPF ISA This patch adds support for xBPF, another ISA targetting the BPF virtual architecture. For now, the primary difference between eBPF and xBPF is that xBPF supports indirect calls through the 'call %reg' form of the call instruction. bfd/ * archures.c (bfd_mach_xbpf): Define. * bfd-in2.h: Regenerate. * cpu-bpf.c (bfd_xbpf_arch) New. (bfd_bpf_arch) Update next in list field to point to xbpf arch. cpu/ * bpf.cpu (arch bpf): Add xbpf mach and isas. (define-xbpf-isa) New pmacro. (all-isas) Add xbpfle,xbpfbe. (endian-isas): New pmacro. (mach xbpf): New. (model xbpf-def): Likewise. (h-gpr): Add xbpf mach. (f-dstle, f-srcle, dstle, srcle): Add xbpfle isa. (f-dstbe, f-srcbe, dstbe, srcbe): Add xbpfbe isa. (define-alu-insn-un): Use new endian-isas pmacro. (define-alu-insn-bin, define-alu-insn-mov): Likewise. (define-endian-insn, define-lddw): Likewise. (dlind, dxli, dxsi, dsti): Likewise. (define-cond-jump-insn, define-call-insn): Likewise. (define-atomic-insns): Likewise. gas/ * config/tc-bpf.c: Add option -mxbpf to select xbpf isa. * testsuite/gas/bpf/indcall-1.d: New file. * testsuite/gas/bpf/indcall-1.s: Likewise. * testsuite/gas/bpf/indcall-bad-1.l: Likewise. * testsuite/gas/bpf/indcall-bad-1.s: Likewise. * testsuite/gas/bpf/bpf.exp: Run new tests. opcodes/ * bpf-desc.c: Regenerate. * bpf-desc.h: Likewise. * bpf-opc.c: Likewise. * bpf-opc.h: Likewise. * disassemble.c (disassemble_init_for_target): Set bits for xBPF ISA when appropriate. --- opcodes/bpf-desc.c | 568 +++++++++++++++++++++++++++-------------------------- 1 file changed, 292 insertions(+), 276 deletions(-) (limited to 'opcodes/bpf-desc.c') diff --git a/opcodes/bpf-desc.c b/opcodes/bpf-desc.c index 6319f10..6914ce9 100644 --- a/opcodes/bpf-desc.c +++ b/opcodes/bpf-desc.c @@ -48,6 +48,7 @@ static const CGEN_ATTR_ENTRY MACH_attr[] ATTRIBUTE_UNUSED = { { "base", MACH_BASE }, { "bpf", MACH_BPF }, + { "xbpf", MACH_XBPF }, { "max", MACH_MAX }, { 0, 0 } }; @@ -56,6 +57,8 @@ static const CGEN_ATTR_ENTRY ISA_attr[] ATTRIBUTE_UNUSED = { { "ebpfle", ISA_EBPFLE }, { "ebpfbe", ISA_EBPFBE }, + { "xbpfle", ISA_XBPFLE }, + { "xbpfbe", ISA_XBPFBE }, { "max", ISA_MAX }, { 0, 0 } }; @@ -121,6 +124,8 @@ const CGEN_ATTR_TABLE bpf_cgen_insn_attr_table[] = static const CGEN_ISA bpf_cgen_isa_table[] = { { "ebpfle", 64, 64, 64, 128 }, { "ebpfbe", 64, 64, 64, 128 }, + { "xbpfle", 64, 64, 64, 128 }, + { "xbpfbe", 64, 64, 64, 128 }, { 0, 0, 0, 0, 0 } }; @@ -128,6 +133,7 @@ static const CGEN_ISA bpf_cgen_isa_table[] = { static const CGEN_MACH bpf_cgen_mach_table[] = { { "bpf", "bpf", MACH_BPF, 0 }, + { "xbpf", "xbpf", MACH_XBPF, 0 }, { 0, 0, 0, 0 } }; @@ -163,14 +169,14 @@ CGEN_KEYWORD bpf_cgen_opval_h_gpr = const CGEN_HW_ENTRY bpf_cgen_hw_table[] = { - { "h-memory", HW_H_MEMORY, CGEN_ASM_NONE, 0, { 0, { { { (1<