David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _ARCH_H |
| 7 | #define _ARCH_H |
| 8 | |
| 9 | #include <stdbool.h> |
| 10 | #include <linux/list.h> |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 11 | #include "objtool.h" |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 12 | #include "cfi.h" |
| 13 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 14 | #ifdef INSN_USE_ORC |
| 15 | #include <asm/orc_types.h> |
| 16 | #endif |
| 17 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 18 | enum insn_type { |
| 19 | INSN_JUMP_CONDITIONAL, |
| 20 | INSN_JUMP_UNCONDITIONAL, |
| 21 | INSN_JUMP_DYNAMIC, |
| 22 | INSN_JUMP_DYNAMIC_CONDITIONAL, |
| 23 | INSN_CALL, |
| 24 | INSN_CALL_DYNAMIC, |
| 25 | INSN_RETURN, |
| 26 | INSN_CONTEXT_SWITCH, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 27 | INSN_BUG, |
| 28 | INSN_NOP, |
| 29 | INSN_STAC, |
| 30 | INSN_CLAC, |
| 31 | INSN_STD, |
| 32 | INSN_CLD, |
| 33 | INSN_OTHER, |
| 34 | }; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 35 | |
| 36 | enum op_dest_type { |
| 37 | OP_DEST_REG, |
| 38 | OP_DEST_REG_INDIRECT, |
| 39 | OP_DEST_MEM, |
| 40 | OP_DEST_PUSH, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 41 | OP_DEST_PUSHF, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 42 | OP_DEST_LEAVE, |
| 43 | }; |
| 44 | |
| 45 | struct op_dest { |
| 46 | enum op_dest_type type; |
| 47 | unsigned char reg; |
| 48 | int offset; |
| 49 | }; |
| 50 | |
| 51 | enum op_src_type { |
| 52 | OP_SRC_REG, |
| 53 | OP_SRC_REG_INDIRECT, |
| 54 | OP_SRC_CONST, |
| 55 | OP_SRC_POP, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 56 | OP_SRC_POPF, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 57 | OP_SRC_ADD, |
| 58 | OP_SRC_AND, |
| 59 | }; |
| 60 | |
| 61 | struct op_src { |
| 62 | enum op_src_type type; |
| 63 | unsigned char reg; |
| 64 | int offset; |
| 65 | }; |
| 66 | |
| 67 | struct stack_op { |
| 68 | struct op_dest dest; |
| 69 | struct op_src src; |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 70 | struct list_head list; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 71 | }; |
| 72 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 73 | struct instruction; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 74 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 75 | void arch_initial_func_cfi_state(struct cfi_init_state *state); |
| 76 | |
| 77 | int arch_decode_instruction(const struct elf *elf, const struct section *sec, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 78 | unsigned long offset, unsigned int maxlen, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 79 | unsigned int *len, enum insn_type *type, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 80 | unsigned long *immediate, |
| 81 | struct list_head *ops_list); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 82 | |
| 83 | bool arch_callee_saved_reg(unsigned char reg); |
| 84 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 85 | unsigned long arch_jump_destination(struct instruction *insn); |
| 86 | |
| 87 | unsigned long arch_dest_reloc_offset(int addend); |
| 88 | |
| 89 | const char *arch_nop_insn(int len); |
| 90 | |
| 91 | int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg); |
| 92 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 93 | #endif /* _ARCH_H */ |