Thomas Gleixner | 1ccea77 | 2019-05-19 15:51:43 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com> |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _ARCH_H |
| 7 | #define _ARCH_H |
| 8 | |
| 9 | #include <stdbool.h> |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 10 | #include <linux/list.h> |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 11 | #include "elf.h" |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 12 | #include "cfi.h" |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 13 | |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 14 | #define INSN_JUMP_CONDITIONAL 1 |
| 15 | #define INSN_JUMP_UNCONDITIONAL 2 |
| 16 | #define INSN_JUMP_DYNAMIC 3 |
| 17 | #define INSN_CALL 4 |
| 18 | #define INSN_CALL_DYNAMIC 5 |
| 19 | #define INSN_RETURN 6 |
| 20 | #define INSN_CONTEXT_SWITCH 7 |
| 21 | #define INSN_STACK 8 |
Josh Poimboeuf | 649ea4d | 2017-07-27 15:56:53 -0500 | [diff] [blame] | 22 | #define INSN_BUG 9 |
| 23 | #define INSN_NOP 10 |
Peter Zijlstra | ea24213 | 2019-02-25 12:50:09 +0100 | [diff] [blame] | 24 | #define INSN_STAC 11 |
| 25 | #define INSN_CLAC 12 |
Peter Zijlstra | 2f0f9e9 | 2019-02-25 11:10:55 +0100 | [diff] [blame] | 26 | #define INSN_STD 13 |
| 27 | #define INSN_CLD 14 |
| 28 | #define INSN_OTHER 15 |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 29 | #define INSN_LAST INSN_OTHER |
| 30 | |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 31 | enum op_dest_type { |
| 32 | OP_DEST_REG, |
| 33 | OP_DEST_REG_INDIRECT, |
| 34 | OP_DEST_MEM, |
| 35 | OP_DEST_PUSH, |
Peter Zijlstra | ea24213 | 2019-02-25 12:50:09 +0100 | [diff] [blame] | 36 | OP_DEST_PUSHF, |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 37 | OP_DEST_LEAVE, |
| 38 | }; |
| 39 | |
| 40 | struct op_dest { |
| 41 | enum op_dest_type type; |
| 42 | unsigned char reg; |
| 43 | int offset; |
| 44 | }; |
| 45 | |
| 46 | enum op_src_type { |
| 47 | OP_SRC_REG, |
| 48 | OP_SRC_REG_INDIRECT, |
| 49 | OP_SRC_CONST, |
| 50 | OP_SRC_POP, |
Peter Zijlstra | ea24213 | 2019-02-25 12:50:09 +0100 | [diff] [blame] | 51 | OP_SRC_POPF, |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 52 | OP_SRC_ADD, |
| 53 | OP_SRC_AND, |
| 54 | }; |
| 55 | |
| 56 | struct op_src { |
| 57 | enum op_src_type type; |
| 58 | unsigned char reg; |
| 59 | int offset; |
| 60 | }; |
| 61 | |
| 62 | struct stack_op { |
| 63 | struct op_dest dest; |
| 64 | struct op_src src; |
| 65 | }; |
| 66 | |
| 67 | void arch_initial_func_cfi_state(struct cfi_state *state); |
| 68 | |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 69 | int arch_decode_instruction(struct elf *elf, struct section *sec, |
| 70 | unsigned long offset, unsigned int maxlen, |
| 71 | unsigned int *len, unsigned char *type, |
Josh Poimboeuf | baa4146 | 2017-06-28 10:11:07 -0500 | [diff] [blame] | 72 | unsigned long *immediate, struct stack_op *op); |
| 73 | |
| 74 | bool arch_callee_saved_reg(unsigned char reg); |
Josh Poimboeuf | 442f04c | 2016-02-28 22:22:41 -0600 | [diff] [blame] | 75 | |
| 76 | #endif /* _ARCH_H */ |