From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E5DCC282CB for ; Tue, 5 Feb 2019 12:42:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 258DF2083B for ; Tue, 5 Feb 2019 12:42:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hfg0rRmL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729071AbfBEMmA (ORCPT ); Tue, 5 Feb 2019 07:42:00 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40184 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726065AbfBEMl7 (ORCPT ); Tue, 5 Feb 2019 07:41:59 -0500 Received: by mail-pg1-f196.google.com with SMTP id z10so1332065pgp.7 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=d5PULuYZk1lZho2g/v/K4McJ1XbJqy3etsfTxR+7+tdQZ2nd1iGrHiWoeBCXEuMeUx dwjzVxkCflv5LY5Co9X6/ewSM4ViICECgsKAHh5gg2DfLh8mer5hg1ct4AJyu4exToQE ts7ELZ3++a4L8fj+Mg0oiHMfRpzriuvGaM4P8/u9q0XPEfTmWvhFEPGJeGMfzdfmL46m ijua550cXLYjDlPTxkkO2bpkZunYUnVmq+pqNqY9IY5hFPd8l4nL2foNgIZKeFFi/oRE JiAGOZ2JLADMGbk4DIygikadvP/zXB1TjcbULTou92JeFNzRDpohf2tXryeD9LrXaV4X 5HSA== X-Gm-Message-State: AHQUAubl3TwoEJ2+lBSMYeWR6bS1uoFpmDuAzbV3vcOX+yzX3QEahE4g 6ym+3HqI6WN/VEpMzPtIVrh7zzm1OzSehQ== 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 Cc: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , palmer@sifive.com, hch@infradead.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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 -- 2.19.1