From patchwork Tue Feb 5 12:41:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 10797439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20FE713B5 for ; Tue, 5 Feb 2019 12:42:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 107982AA00 for ; Tue, 5 Feb 2019 12:42:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0344E2BAD7; Tue, 5 Feb 2019 12:42:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 285732BA88 for ; Tue, 5 Feb 2019 12:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=DywfrDplph7oFTzx1yJrvu3hqsbZCj7Jhu+rI4UPklo=; b=qNEZqeR0hkZoQH 2dojjiyK6YdokB3XG32CdxvjNIN8cdRdIjQnWprk3lIen3EIYmOxhCNI/tkOohKHGL5MewtI7fepG v2TVse+sL5xtvgOYemMB2ujVFSi+3CmPw2y/wCAlhOwZt8QyFafIhbtzzesNcD/OQab7Ry0iJcaOJ PKowyAJpbjzQT3mlxvs8Hyu51/n9PUVgj+rgYvdaADToPox/og0Xlzre9+d4906fu+35o3PHas2Ai hYL/cnZp6qleHqnOfq1rbRyH50X4s+UzPCc1a56RcW3hEsB13cfbuAbGkT+bnhdkYr9IH2y9Xutf5 YAHvY3q/RV8S4uHnDNIw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr03c-0003cy-TZ; Tue, 05 Feb 2019 12:42:32 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gr035-0003CK-KL for linux-riscv@lists.infradead.org; Tue, 05 Feb 2019 12:42:24 +0000 Received: by mail-pg1-x544.google.com with SMTP id y4so1319502pgc.12 for ; Tue, 05 Feb 2019 04:41:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iI6y08ByJ9IYoe8KpyT+hq3Vy79jkLyUMrmYFIWNeSQ=; b=Hfg0rRmL7nf9hm/Uu5ZsMjVbNCT/G72rrgg+d92gOvIFB9/d0mFnXYPu/COIwG9sfa tr8IecV8ztg/CLHUgoOGWV6NF+x982dQwGmgJjDWgCPMLlu9BkUbnFXA62dZ8caVR3G1 zijeccw/aDz8hrhimYCtr1tGiyrE/bZ/gtOEgGFdg+XXSqkt5n8H75eeaRrVYRB/iHDs xZasmkcYagixt0/VurKHxhiSyjFRjuC2RD4EZ7Sv3R0Mf9xtnmxASwXQqtO95ZndqMND s3pkrpiTL15XXFpFkjW7gRW3MMy3/fMfB1jyLGLXw81EA2ykcwicKhRDCtMvpqFTrK4L VoFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iI6y08ByJ9IYoe8KpyT+hq3Vy79jkLyUMrmYFIWNeSQ=; b=SBXAsFxcnvrmBQrD+fchXOBl5l6lEVBZoEebQaBWmQe0UVmDtHjJq4Je6ni3EJRq0S HuyTNlr2+azCYDlAHCAXWW5cPzBBwKXqNm1t74P/TXDOFemhLjOxb+uwKq/4SGku6i7v 1bKNw1NPNrszWbWZnGYHIgRx99MNiNX8itI/GPsxG/gkSD+jHRTGZtNRn1aVkesUo3ug BuhHwCypQEAJwqxia00tu6kUbV+xShU3/YgI1PzkS+hswBG6HvSZ3JQJjG7/MJD1JKYr Vk9iaPb/oNqV5THo8hq5kYmHUyDwR9PIy9AjZEn85OQt9Pl02STnSXciKICrqIRKxdnJ S8iA== X-Gm-Message-State: AHQUAubEnmSYr46bWcHRS2n54jByt24+s3jzU3ru3f/TYRDYvicTJ3XI MjTLvC9PeLsmFAN1QUvQCaZzjAoIyzMAgA== X-Google-Smtp-Source: AHgI3IahRcgEqwgUaEzFighuDZ+KDbML+P/5o++d+GIxGiKewDg4Iwcfm2H+7+miMGmI+daj9Ll2cA== X-Received: by 2002:a62:c28e:: with SMTP id w14mr4809385pfk.115.1549370518341; Tue, 05 Feb 2019 04:41:58 -0800 (PST) Received: from btopel-mobl.ger.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.139.73]) by smtp.gmail.com with ESMTPSA id g6sm5116774pgq.18.2019.02.05.04.41.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Feb 2019 04:41:57 -0800 (PST) From: bjorn.topel@gmail.com To: linux-riscv@lists.infradead.org, daniel@iogearbox.net, ast@kernel.org, netdev@vger.kernel.org Subject: [PATCH bpf-next v2 0/4] Add RISC-V (RV64G) BPF JIT Date: Tue, 5 Feb 2019 13:41:21 +0100 Message-Id: <20190205124125.5553-1-bjorn.topel@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190205_044200_404037_D140216B X-CRM114-Status: GOOD ( 11.66 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hch@infradead.org, =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , palmer@sifive.com Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Björn Töpel Hi! This v2 series adds an RV64G BPF JIT to the kernel. At the moment the RISC-V Linux port does not support CONFIG_HAVE_KPROBES (Patrick Stählin sent out an RFC last year), which means that CONFIG_BPF_EVENTS is not supported. Thus, no tests involving BPF_PROG_TYPE_TRACEPOINT, BPF_PROG_TYPE_PERF_EVENT, BPF_PROG_TYPE_KPROBE and BPF_PROG_TYPE_RAW_TRACEPOINT passes. The implementation does not support "far branching" (>4KiB). Test results: # modprobe test_bpf test_bpf: Summary: 378 PASSED, 0 FAILED, [366/366 JIT'ed] # echo 1 > /proc/sys/kernel/unprivileged_bpf_disabled # ./test_verifier ... Summary: 761 PASSED, 507 SKIPPED, 2 FAILED Note that "test_verifier" was run with one build with CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y and one without, otherwise many of the the tests that require unaligned access were skipped. CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y: # echo 1 > /proc/sys/kernel/unprivileged_bpf_disabled # ./test_verifier | grep -c 'NOTE.*unknown align' 0 No CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS: # echo 1 > /proc/sys/kernel/unprivileged_bpf_disabled # ./test_verifier | grep -c 'NOTE.*unknown align' 59 The two failing test_verifier tests are: "ld_abs: vlan + abs, test 1" "ld_abs: jump around ld_abs" This is due to that "far branching" involved in those tests. All tests where done on QEMU emulator version 3.1.50 (v3.1.0-688-g8ae951fbc106). I'll test it on real hardware, when I get access to it. I'm routing this patch via bpf-next/netdev mailing list (after a conversation with Palmer at FOSDEM), mainly because the other JITs went that path. Again, thanks for all the comments! Cheers, Björn v1 -> v2: * Added JMP32 support. (Daniel) * Add RISC-V to Documentation/sysctl/net.txt. (Daniel) * Fixed seen_call() asymmetry. (Daniel) * Fixed broken bpf_flush_icache() range. (Daniel) * Added alignment annotations to some selftests. RFCv1 -> v1: * Cleaned up the Kconfig and net/Makefile. (Christoph) * Removed the entry-stub and squashed the build/config changes to be part of the JIT implementation. (Christoph) * Simplified the register tracking code. (Daniel) * Removed unused macros. (Daniel) * Added myself as maintainer and updated documentation. (Daniel) * Removed HAVE_EFFICIENT_UNALIGNED_ACCESS. (Christoph, Palmer) * Added tail-calls and cleaned up the code. Björn Töpel (4): bpf, riscv: add BPF JIT for RV64G MAINTAINERS: add RISC-V BPF JIT maintainer bpf, doc: add RISC-V JIT to BPF documentation selftests/bpf: add "any alignment" annotation for some tests Documentation/networking/filter.txt | 16 +- Documentation/sysctl/net.txt | 1 + MAINTAINERS | 6 + arch/riscv/Kconfig | 1 + arch/riscv/Makefile | 2 +- arch/riscv/net/Makefile | 1 + arch/riscv/net/bpf_jit_comp.c | 1602 +++++++++++++++++ .../selftests/bpf/verifier/ctx_sk_msg.c | 1 + .../testing/selftests/bpf/verifier/ctx_skb.c | 1 + tools/testing/selftests/bpf/verifier/jmp32.c | 22 + tools/testing/selftests/bpf/verifier/jset.c | 2 + .../selftests/bpf/verifier/spill_fill.c | 1 + .../selftests/bpf/verifier/spin_lock.c | 2 + .../selftests/bpf/verifier/value_ptr_arith.c | 4 + 14 files changed, 1654 insertions(+), 8 deletions(-) create mode 100644 arch/riscv/net/Makefile create mode 100644 arch/riscv/net/bpf_jit_comp.c