blob: d0969a9328c2d85484ac8c86135fbf3a0c64550d [file] [log] [blame]
Thomas Gleixner1ccea772019-05-19 15:51:43 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Josh Poimboeuf442f04c2016-02-28 22:22:41 -06002/*
3 * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com>
Josh Poimboeuf442f04c2016-02-28 22:22:41 -06004 */
5
6#ifndef _ARCH_H
7#define _ARCH_H
8
9#include <stdbool.h>
Josh Poimboeufbaa41462017-06-28 10:11:07 -050010#include <linux/list.h>
Matt Helsley0decf1f2020-05-19 13:55:33 -070011#include "objtool.h"
Josh Poimboeufbaa41462017-06-28 10:11:07 -050012#include "cfi.h"
Josh Poimboeuf442f04c2016-02-28 22:22:41 -060013
Matt Helsley0decf1f2020-05-19 13:55:33 -070014#include <asm/orc_types.h>
15
Josh Poimboeuf9fe7b762019-07-17 20:36:56 -050016enum insn_type {
17 INSN_JUMP_CONDITIONAL,
18 INSN_JUMP_UNCONDITIONAL,
19 INSN_JUMP_DYNAMIC,
Josh Poimboeufb68b9902019-07-17 20:36:57 -050020 INSN_JUMP_DYNAMIC_CONDITIONAL,
Josh Poimboeuf9fe7b762019-07-17 20:36:56 -050021 INSN_CALL,
22 INSN_CALL_DYNAMIC,
23 INSN_RETURN,
24 INSN_CONTEXT_SWITCH,
Josh Poimboeuf9fe7b762019-07-17 20:36:56 -050025 INSN_BUG,
26 INSN_NOP,
27 INSN_STAC,
28 INSN_CLAC,
29 INSN_STD,
30 INSN_CLD,
31 INSN_OTHER,
32};
Josh Poimboeuf442f04c2016-02-28 22:22:41 -060033
Josh Poimboeufbaa41462017-06-28 10:11:07 -050034enum op_dest_type {
35 OP_DEST_REG,
36 OP_DEST_REG_INDIRECT,
37 OP_DEST_MEM,
38 OP_DEST_PUSH,
Peter Zijlstraea242132019-02-25 12:50:09 +010039 OP_DEST_PUSHF,
Josh Poimboeufbaa41462017-06-28 10:11:07 -050040 OP_DEST_LEAVE,
41};
42
43struct op_dest {
44 enum op_dest_type type;
45 unsigned char reg;
46 int offset;
47};
48
49enum op_src_type {
50 OP_SRC_REG,
51 OP_SRC_REG_INDIRECT,
52 OP_SRC_CONST,
53 OP_SRC_POP,
Peter Zijlstraea242132019-02-25 12:50:09 +010054 OP_SRC_POPF,
Josh Poimboeufbaa41462017-06-28 10:11:07 -050055 OP_SRC_ADD,
56 OP_SRC_AND,
57};
58
59struct op_src {
60 enum op_src_type type;
61 unsigned char reg;
62 int offset;
63};
64
65struct stack_op {
66 struct op_dest dest;
67 struct op_src src;
Julien Thierry65ea47d2020-03-27 15:28:47 +000068 struct list_head list;
Josh Poimboeufbaa41462017-06-28 10:11:07 -050069};
70
Raphael Gaultbfb08f22020-03-27 15:28:45 +000071struct instruction;
72
Peter Zijlstraa3608f52020-03-25 15:34:50 +010073void arch_initial_func_cfi_state(struct cfi_init_state *state);
Josh Poimboeufbaa41462017-06-28 10:11:07 -050074
Ingo Molnar0c98be82020-04-22 12:32:05 +020075int arch_decode_instruction(const struct elf *elf, const struct section *sec,
Josh Poimboeuf442f04c2016-02-28 22:22:41 -060076 unsigned long offset, unsigned int maxlen,
Josh Poimboeuf9fe7b762019-07-17 20:36:56 -050077 unsigned int *len, enum insn_type *type,
Julien Thierry65ea47d2020-03-27 15:28:47 +000078 unsigned long *immediate,
79 struct list_head *ops_list);
Josh Poimboeufbaa41462017-06-28 10:11:07 -050080
81bool arch_callee_saved_reg(unsigned char reg);
Josh Poimboeuf442f04c2016-02-28 22:22:41 -060082
Raphael Gaultbfb08f22020-03-27 15:28:45 +000083unsigned long arch_jump_destination(struct instruction *insn);
84
Matt Helsleyf1974222020-05-29 14:01:13 -070085unsigned long arch_dest_reloc_offset(int addend);
Raphael Gaultbfb08f22020-03-27 15:28:45 +000086
Josh Poimboeuf442f04c2016-02-28 22:22:41 -060087#endif /* _ARCH_H */