From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 9C7E11B525 for ; Fri, 23 Nov 2018 11:30:45 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0FF9C86641; Fri, 23 Nov 2018 10:30:45 +0000 (UTC) Received: from ktraynor.remote.csb (unknown [10.36.118.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9C2A18A72; Fri, 23 Nov 2018 10:30:43 +0000 (UTC) From: Kevin Traynor To: Konstantin Ananyev Cc: dpdk stable Date: Fri, 23 Nov 2018 10:27:05 +0000 Message-Id: <20181123102713.17309-61-ktraynor@redhat.com> In-Reply-To: <20181123102713.17309-1-ktraynor@redhat.com> References: <20181123102713.17309-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 23 Nov 2018 10:30:45 +0000 (UTC) Subject: [dpdk-stable] patch 'bpf: fix x86 JIT for immediate loads' has been queued to stable release 18.08.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2018 10:30:46 -0000 Hi, FYI, your patch has been queued to stable release 18.08.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/29/18. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. If the code is different (ie: not only metadata diffs), due for example to a change in context or macro names, please double check it. Thanks. Kevin Traynor --- >>From 7e5b6aa6cc75c0129cc23cd1778c8d743fafbf81 Mon Sep 17 00:00:00 2001 From: Konstantin Ananyev Date: Thu, 8 Nov 2018 12:36:43 +0000 Subject: [PATCH] bpf: fix x86 JIT for immediate loads [ upstream commit 95df7307a77de5d28b4c81151a8dcc100be8172c ] x86 jit can generate invalid code for (BPF_LD | BPF_IMM | EBPF_DW) instructions, when immediate value is bigger then INT32_MAX. Fixes: cc752e43e079 ("bpf: add JIT compilation for x86_64 ISA") Signed-off-by: Konstantin Ananyev --- lib/librte_bpf/bpf_jit_x86.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/librte_bpf/bpf_jit_x86.c b/lib/librte_bpf/bpf_jit_x86.c index 68ea389f2..f70cd6be5 100644 --- a/lib/librte_bpf/bpf_jit_x86.c +++ b/lib/librte_bpf/bpf_jit_x86.c @@ -209,4 +209,17 @@ emit_sib(struct bpf_jit_state *st, uint32_t scale, uint32_t idx, uint32_t base) } +/* + * emit OPCODE+REGIDX byte + */ +static void +emit_opcode(struct bpf_jit_state *st, uint8_t ops, uint32_t reg) +{ + uint8_t v; + + v = ops | (reg & 7); + emit_bytes(st, &v, sizeof(v)); +} + + /* * emit xchg %, % @@ -473,17 +486,16 @@ emit_ld_imm64(struct bpf_jit_state *st, uint32_t dreg, uint32_t imm0, uint32_t imm1) { + uint32_t op; + const uint8_t ops = 0xB8; - if (imm1 == 0) { - emit_mov_imm(st, EBPF_ALU64 | EBPF_MOV | BPF_K, dreg, imm0); - return; - } + op = (imm1 == 0) ? BPF_ALU : EBPF_ALU64; - emit_rex(st, EBPF_ALU64, 0, dreg); - emit_bytes(st, &ops, sizeof(ops)); - emit_modregrm(st, MOD_DIRECT, 0, dreg); + emit_rex(st, op, 0, dreg); + emit_opcode(st, ops, dreg); emit_imm(st, imm0, sizeof(imm0)); - emit_imm(st, imm1, sizeof(imm1)); + if (imm1 != 0) + emit_imm(st, imm1, sizeof(imm1)); } -- 2.19.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2018-11-23 10:22:55.825256066 +0000 +++ 0061-bpf-fix-x86-JIT-for-immediate-loads.patch 2018-11-23 10:22:54.000000000 +0000 @@ -1,13 +1,14 @@ -From 95df7307a77de5d28b4c81151a8dcc100be8172c Mon Sep 17 00:00:00 2001 +From 7e5b6aa6cc75c0129cc23cd1778c8d743fafbf81 Mon Sep 17 00:00:00 2001 From: Konstantin Ananyev Date: Thu, 8 Nov 2018 12:36:43 +0000 Subject: [PATCH] bpf: fix x86 JIT for immediate loads +[ upstream commit 95df7307a77de5d28b4c81151a8dcc100be8172c ] + x86 jit can generate invalid code for (BPF_LD | BPF_IMM | EBPF_DW) instructions, when immediate value is bigger then INT32_MAX. Fixes: cc752e43e079 ("bpf: add JIT compilation for x86_64 ISA") -Cc: stable@dpdk.org Signed-off-by: Konstantin Ananyev ---