From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiong Wang Subject: [PATH bpf-next 01/13] bpf: encoding description and macros for JMP32 Date: Wed, 19 Dec 2018 17:44:08 -0500 Message-ID: <1545259460-13376-2-git-send-email-jiong.wang@netronome.com> References: <1545259460-13376-1-git-send-email-jiong.wang@netronome.com> Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, Jiong Wang To: ast@kernel.org, daniel@iogearbox.net Return-path: Received: from mail-wm1-f66.google.com ([209.85.128.66]:34051 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728170AbeLSWoh (ORCPT ); Wed, 19 Dec 2018 17:44:37 -0500 Received: by mail-wm1-f66.google.com with SMTP id y185so10572338wmd.1 for ; Wed, 19 Dec 2018 14:44:35 -0800 (PST) In-Reply-To: <1545259460-13376-1-git-send-email-jiong.wang@netronome.com> Sender: netdev-owner@vger.kernel.org List-ID: This patch update kernel BPF documents for JMP32 encoding. Two macros are added for JMP32 to easy programming. Signed-off-by: Jiong Wang --- Documentation/networking/filter.txt | 10 ++++++++++ include/uapi/linux/bpf.h | 4 ++++ tools/include/uapi/linux/bpf.h | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/Documentation/networking/filter.txt b/Documentation/networking/filter.txt index 2196b82..5f6fafa 100644 --- a/Documentation/networking/filter.txt +++ b/Documentation/networking/filter.txt @@ -939,6 +939,16 @@ in eBPF means function exit only. The eBPF program needs to store return value into register R0 before doing a BPF_EXIT. Class 6 in eBPF is currently unused and reserved for future use. +And BPF_JMP has sub-opcode. When BPF_SRC(code) == BPF_X, the encoding is at +insn->imm, starting from LSB. When BPF_SRC(code) == BPF_K, the encoding is at +insn->src_reg, starting from LSB as well. Only one bit is used for sub-opcode at +the moment, all other bits in imm and src_reg are still reserved and should be +zeroed. The BPF_JMP sub-opcode is: + + BPF_JMP_SUBOP_32BIT 0x1 + +It means jump insn use 32-bit sub-register when doing comparison. + For load and store instructions the 8-bit 'code' field is divided as: +--------+--------+-------------------+ diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index e7d57e89..f30d646 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -42,6 +42,10 @@ #define BPF_CALL 0x80 /* function call */ #define BPF_EXIT 0x90 /* function return */ +/* jmp has sub-opcode */ +#define BPF_JMP_SUBOP_MASK 0x1 +#define BPF_JMP_SUBOP_32BIT 0x1 + /* Register numbers */ enum { BPF_REG_0 = 0, diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index e7d57e89..f30d646 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -42,6 +42,10 @@ #define BPF_CALL 0x80 /* function call */ #define BPF_EXIT 0x90 /* function return */ +/* jmp has sub-opcode */ +#define BPF_JMP_SUBOP_MASK 0x1 +#define BPF_JMP_SUBOP_32BIT 0x1 + /* Register numbers */ enum { BPF_REG_0 = 0, -- 2.7.4