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 087C3C43387 for ; Tue, 15 Jan 2019 08:35:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD31F2063F for ; Tue, 15 Jan 2019 08:35:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UUo7X7nX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728326AbfAOIfo (ORCPT ); Tue, 15 Jan 2019 03:35:44 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:34648 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbfAOIfo (ORCPT ); Tue, 15 Jan 2019 03:35:44 -0500 Received: by mail-lj1-f193.google.com with SMTP id u89-v6so1595541lje.1 for ; Tue, 15 Jan 2019 00:35:43 -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=54UCKXD55YHOKubS5JS59AxRACPcjYF8KFxR/pvfPzI=; b=UUo7X7nXPfMIid3V8x1AP+JC4SGOMvIAcMSm8O5K2VG2Tca+bKxtq4TQJ8Ero5bua5 TxLcVMeGwcnbwJd7+8oDF0j4AhqJrsekXZIszbUyGeeZgYiJq+fsChTiYWLwgZ9S6i0c PnyDOKxjmGQ1qos/URa1rJz/XnSfqJbsAeZQFJOdLc7JxD+B5MgDl5jo2AHkAKtYwna8 jirqhOc+DZ2Nzbgb6DdSjAVxzmaA7+y0jBlo57UFqUNVttslsaanAlIiS2GpOJrvUGCO NCaJT1OwfZmLAA9gLYMxBrtnInM5z2FEjp5b5FzUNvrK2cL64ebOt/n7bqjutDm3/0Rh /aHg== 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=54UCKXD55YHOKubS5JS59AxRACPcjYF8KFxR/pvfPzI=; b=jEG5hPLo1AiA6gEh12p+z8F17Kx7g3slkAsQx33khyY3vc/yXH6CvVNkh54VhgPDr1 AqmjWCl7TZQk7AXJZs9lo0X/KQgunseW/gNekiQyMqhsRl/VlQyToXlVMVFJegZ7+1y6 19qOP+IcHiVZi1Y4UNqDZ8z2u110TuKKTh9JktMs/vJdBLd9PjLHGQ5sY3mpBLOkgwgh aIVMlwqzsNgLl6mXNNB2MA9hIF0k9ekLc9UOFLKgK6otkG/QRKY6o6WQ7GGCCTBSgaAL 8Mimv8UV68nyz6RRQVQ4eCB37sxxNkitQWtxEAijgvPEmW9f1GiSvnWPDEstMx0hgnXc KyKA== X-Gm-Message-State: AJcUukeWJCLHdkReWqbAKToo7JHYyMKPivzRjux+LRPTr9MUNTAH0tiq K/qKL+pH69wRf1/Bhj0gW18= X-Google-Smtp-Source: ALg8bN5JSLwoATDB3fZMXpwQvqny651ZRVa+L8o6zDEpg8IlWloedmWoNdlNk/jqPKb9WaOSzYR4Dw== X-Received: by 2002:a2e:90ca:: with SMTP id o10-v6mr1877605ljg.134.1547541342295; Tue, 15 Jan 2019 00:35:42 -0800 (PST) Received: from btopel-mobl.ger.intel.com ([213.100.199.124]) by smtp.gmail.com with ESMTPSA id e14-v6sm453004ljb.31.2019.01.15.00.35.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 00:35:41 -0800 (PST) From: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= To: linux-riscv@lists.infradead.org Cc: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , daniel@iogearbox.net, palmer@sifive.com, davidlee@sifive.com, netdev@vger.kernel.org Subject: [RFC PATCH 0/3] RV64G eBPF JIT Date: Tue, 15 Jan 2019 09:35:15 +0100 Message-Id: <20190115083518.10149-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 Message-ID: <20190115083515.yfk46pzMYRe5vs9siJ7HrlTjipZOVJLJEkJvO332Ubs@z> Hi! I've been hacking on a RV64G eBPF JIT compiler, and would like some feedback. Codewise, it needs some refactoring. Currently there's a bit too much copy-and-paste going on, and I know some places where I could optimize the code generation a bit (mostly BPF_K type of instructions, dealing with immediates). >From a features perspective, two things are missing: * tail calls * "far-branches", i.e. conditional branches that reach beyond 13b. The test_bpf.ko (only tested on 4.20!) passes all tests. I've done all the tests on QEMU (version 3.1.50), so no real hardware. Some questions/observations: * I've added "HAVE_EFFICIENT_UNALIGNED_ACCESS" to arch/riscv/Kconfig. Is this assumption correct? * emit_imm() just relies on lui, adds and shifts. No fancy xori cost optimizations like GCC does. * Suggestions on how to implement the tail call, given that the prologue/epilogue has variable size. I will dig into the details of mips/arm64/x86. :-) Next steps (prior patch proper) is cleaning up the code, add tail calls, and making sure that bpftool disassembly works correctly. All input are welcome. This is my first RISC-V hack, so I sure there are a lot things to improve! Thanks, Björn Björn Töpel (3): riscv: set HAVE_EFFICIENT_UNALIGNED_ACCESS riscv: add build infra for JIT compiler bpf, riscv: added eBPF JIT for RV64G arch/riscv/Kconfig | 2 + arch/riscv/Makefile | 4 + arch/riscv/net/Makefile | 5 + arch/riscv/net/bpf_jit_comp.c | 1612 +++++++++++++++++++++++++++++++++ 4 files changed, 1623 insertions(+) create mode 100644 arch/riscv/net/Makefile create mode 100644 arch/riscv/net/bpf_jit_comp.c -- 2.19.1