| .. | .. |
|---|
| 1 | 1 | // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) |
|---|
| 2 | | -/* |
|---|
| 3 | | - * Copyright (C) 2018 Netronome Systems, Inc. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This software is dual licensed under the GNU General License Version 2, |
|---|
| 6 | | - * June 1991 as shown in the file COPYING in the top-level directory of this |
|---|
| 7 | | - * source tree or the BSD 2-Clause License provided below. You have the |
|---|
| 8 | | - * option to license this software under the complete terms of either license. |
|---|
| 9 | | - * |
|---|
| 10 | | - * The BSD 2-Clause License: |
|---|
| 11 | | - * |
|---|
| 12 | | - * Redistribution and use in source and binary forms, with or |
|---|
| 13 | | - * without modification, are permitted provided that the following |
|---|
| 14 | | - * conditions are met: |
|---|
| 15 | | - * |
|---|
| 16 | | - * 1. Redistributions of source code must retain the above |
|---|
| 17 | | - * copyright notice, this list of conditions and the following |
|---|
| 18 | | - * disclaimer. |
|---|
| 19 | | - * |
|---|
| 20 | | - * 2. Redistributions in binary form must reproduce the above |
|---|
| 21 | | - * copyright notice, this list of conditions and the following |
|---|
| 22 | | - * disclaimer in the documentation and/or other materials |
|---|
| 23 | | - * provided with the distribution. |
|---|
| 24 | | - * |
|---|
| 25 | | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 26 | | - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 27 | | - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 28 | | - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|---|
| 29 | | - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 30 | | - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 31 | | - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 32 | | - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 33 | | - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 34 | | - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|---|
| 35 | | - * POSSIBILITY OF SUCH DAMAGE. |
|---|
| 36 | | - */ |
|---|
| 2 | +/* Copyright (C) 2018 Netronome Systems, Inc. */ |
|---|
| 37 | 3 | |
|---|
| 38 | 4 | #include <linux/list.h> |
|---|
| 39 | 5 | #include <stdlib.h> |
|---|
| .. | .. |
|---|
| 191 | 157 | return false; |
|---|
| 192 | 158 | } |
|---|
| 193 | 159 | |
|---|
| 160 | +static bool is_jmp_insn(__u8 code) |
|---|
| 161 | +{ |
|---|
| 162 | + return BPF_CLASS(code) == BPF_JMP || BPF_CLASS(code) == BPF_JMP32; |
|---|
| 163 | +} |
|---|
| 164 | + |
|---|
| 194 | 165 | static bool func_partition_bb_head(struct func_node *func) |
|---|
| 195 | 166 | { |
|---|
| 196 | 167 | struct bpf_insn *cur, *end; |
|---|
| .. | .. |
|---|
| 204 | 175 | return true; |
|---|
| 205 | 176 | |
|---|
| 206 | 177 | for (; cur <= end; cur++) { |
|---|
| 207 | | - if (BPF_CLASS(cur->code) == BPF_JMP) { |
|---|
| 208 | | - u8 opcode = BPF_OP(cur->code); |
|---|
| 178 | + if (is_jmp_insn(cur->code)) { |
|---|
| 179 | + __u8 opcode = BPF_OP(cur->code); |
|---|
| 209 | 180 | |
|---|
| 210 | 181 | if (opcode == BPF_EXIT || opcode == BPF_CALL) |
|---|
| 211 | 182 | continue; |
|---|
| .. | .. |
|---|
| 330 | 301 | e->src = bb; |
|---|
| 331 | 302 | |
|---|
| 332 | 303 | insn = bb->tail; |
|---|
| 333 | | - if (BPF_CLASS(insn->code) != BPF_JMP || |
|---|
| 304 | + if (!is_jmp_insn(insn->code) || |
|---|
| 334 | 305 | BPF_OP(insn->code) == BPF_EXIT) { |
|---|
| 335 | 306 | e->dst = bb_next(bb); |
|---|
| 336 | 307 | e->flags |= EDGE_FLAG_FALLTHROUGH; |
|---|