From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by sourceware.org (Postfix) with ESMTPS id C74FB3857008 for ; Fri, 10 Jul 2020 12:25:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C74FB3857008 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06ACLqWo004834 for ; Fri, 10 Jul 2020 12:25:37 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 325y0aq5gv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 10 Jul 2020 12:25:36 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06ACHLVk021418 for ; Fri, 10 Jul 2020 12:25:36 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 325k3jsur5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 10 Jul 2020 12:25:36 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06ACPZ5f016569 for ; Fri, 10 Jul 2020 12:25:35 GMT Received: from termi.localdomain (/10.175.56.150) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 10 Jul 2020 05:25:34 -0700 From: "Jose E. Marchesi" To: gdb-patches@sourceware.org Subject: [PATCH V4 0/3] eBPF support Date: Fri, 10 Jul 2020 14:25:27 +0200 Message-Id: <20200710122530.32541-1-jose.marchesi@oracle.com> X-Mailer: git-send-email 2.25.0.2.g232378479e MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9677 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 mlxlogscore=981 bulkscore=0 spamscore=0 mlxscore=0 adultscore=0 suspectscore=15 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007100089 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9677 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 malwarescore=0 bulkscore=0 phishscore=0 adultscore=0 suspectscore=15 mlxlogscore=987 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007100089 X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jul 2020 12:25:41 -0000 [Changes from V3: - Rebased to today's master. - Change eBPF instances to BPF. - Use fprintf_unfiltered instead of bpf_debug. - Remove bpf_debug. - Remove unneedded bpf_unwind_pc. - Added missing top-level comments to bpf-tdep.c. - Turn ebpf_debug_flag into 'set debug bpf'. - Turn XXX comments into more useful comments, or assertions. - Do not use pointers as bools, compare them to NULL instead. - Regenerate with non-Debian autoconf to avoid spurious changes. - Several minor cosmetic changes.] Hi good peoples! This patch series adds support for the eBPF virtual architecture to GDB [1]. The first patch contains the basic bits to GDB in order to support the bpf-unknown-none target. Breakpointing and instruction single-stepping works, but the debugging support in eBPF is still very minimal. This is mainly due to the many limitations imposed by the architecture (disjoint stack, maximum stack size, etc). We are working to overcome these limitations, by introducing a variant called xbpf, already supported in GCC with the -mxbpf option, whose purpose is to ease debugging and to be used in other contexts different than the Linux kernel, less restrictive. The second patch adds a basic CGEN-based instruction simulator for eBPF. It can run many eBPF programs and works well with GDB. A testsuite covering the supported instructions is also included. We will be expanding it in order to emulate the several kernel contexts in which eBPF programs can run, so eBPF developers can use GDB to debug their programs without having to load them in a running kernel. Currently the only kernel helper implemented in the simulator is printk, which is used by the tests. We of course commit to maintain and evolve this stuff :) [1] Support for eBPF has been already added to both binutils and GCC. Jose E. Marchesi (3): gdb: support for eBPF sim: eBPF simulator sim: generated files for the eBPF simulator gdb/ChangeLog | 10 + gdb/Makefile.in | 3 + gdb/bpf-tdep.c | 349 + gdb/bpf-tdep.h | 45 + gdb/configure.tgt | 6 + gdb/doc/ChangeLog | 6 + gdb/doc/gdb.texinfo | 21 + sim/ChangeLog | 42 + sim/MAINTAINERS | 1 + sim/bpf/Makefile.in | 205 + sim/bpf/aclocal.m4 | 119 + sim/bpf/arch.c | 35 + sim/bpf/arch.h | 50 + sim/bpf/bpf-helpers.c | 175 + sim/bpf/bpf-helpers.def | 194 + sim/bpf/bpf-helpers.h | 31 + sim/bpf/bpf-sim.h | 31 + sim/bpf/bpf.c | 327 + sim/bpf/config.in | 248 + sim/bpf/configure | 15942 ++++++++++++++++++++++++++ sim/bpf/configure.ac | 13 + sim/bpf/cpu.c | 69 + sim/bpf/cpu.h | 81 + sim/bpf/cpuall.h | 65 + sim/bpf/decode-be.c | 1129 ++ sim/bpf/decode-be.h | 94 + sim/bpf/decode-le.c | 1129 ++ sim/bpf/decode-le.h | 94 + sim/bpf/decode.h | 37 + sim/bpf/defs-be.h | 383 + sim/bpf/defs-le.h | 383 + sim/bpf/eng.h | 24 + sim/bpf/mloop.in | 165 + sim/bpf/sem-be.c | 3207 ++++++ sim/bpf/sem-le.c | 3207 ++++++ sim/bpf/sim-if.c | 216 + sim/bpf/sim-main.h | 51 + sim/bpf/traps.c | 33 + sim/configure | 8 + sim/configure.tgt | 3 + sim/testsuite/ChangeLog | 17 + sim/testsuite/configure | 9 +- sim/testsuite/sim/bpf/allinsn.exp | 26 + sim/testsuite/sim/bpf/alu.s | 109 + sim/testsuite/sim/bpf/alu32.s | 99 + sim/testsuite/sim/bpf/endbe.s | 46 + sim/testsuite/sim/bpf/endle.s | 43 + sim/testsuite/sim/bpf/jmp.s | 120 + sim/testsuite/sim/bpf/jmp32.s | 120 + sim/testsuite/sim/bpf/ldabs.s | 87 + sim/testsuite/sim/bpf/mem.s | 56 + sim/testsuite/sim/bpf/mov.s | 54 + sim/testsuite/sim/bpf/testutils.inc | 38 + sim/testsuite/sim/bpf/xadd.s | 44 + 54 files changed, 29096 insertions(+), 3 deletions(-) create mode 100644 gdb/bpf-tdep.c create mode 100644 gdb/bpf-tdep.h create mode 100644 sim/bpf/Makefile.in create mode 100644 sim/bpf/aclocal.m4 create mode 100644 sim/bpf/arch.c create mode 100644 sim/bpf/arch.h create mode 100644 sim/bpf/bpf-helpers.c create mode 100644 sim/bpf/bpf-helpers.def create mode 100644 sim/bpf/bpf-helpers.h create mode 100644 sim/bpf/bpf-sim.h create mode 100644 sim/bpf/bpf.c create mode 100644 sim/bpf/config.in create mode 100755 sim/bpf/configure create mode 100644 sim/bpf/configure.ac create mode 100644 sim/bpf/cpu.c create mode 100644 sim/bpf/cpu.h create mode 100644 sim/bpf/cpuall.h create mode 100644 sim/bpf/decode-be.c create mode 100644 sim/bpf/decode-be.h create mode 100644 sim/bpf/decode-le.c create mode 100644 sim/bpf/decode-le.h create mode 100644 sim/bpf/decode.h create mode 100644 sim/bpf/defs-be.h create mode 100644 sim/bpf/defs-le.h create mode 100644 sim/bpf/eng.h create mode 100644 sim/bpf/mloop.in create mode 100644 sim/bpf/sem-be.c create mode 100644 sim/bpf/sem-le.c create mode 100644 sim/bpf/sim-if.c create mode 100644 sim/bpf/sim-main.h create mode 100644 sim/bpf/traps.c create mode 100644 sim/testsuite/sim/bpf/allinsn.exp create mode 100644 sim/testsuite/sim/bpf/alu.s create mode 100644 sim/testsuite/sim/bpf/alu32.s create mode 100644 sim/testsuite/sim/bpf/endbe.s create mode 100644 sim/testsuite/sim/bpf/endle.s create mode 100644 sim/testsuite/sim/bpf/jmp.s create mode 100644 sim/testsuite/sim/bpf/jmp32.s create mode 100644 sim/testsuite/sim/bpf/ldabs.s create mode 100644 sim/testsuite/sim/bpf/mem.s create mode 100644 sim/testsuite/sim/bpf/mov.s create mode 100644 sim/testsuite/sim/bpf/testutils.inc create mode 100644 sim/testsuite/sim/bpf/xadd.s -- 2.25.0.2.g232378479e