.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | #ifndef _ASM_X86_INSN_H |
---|
2 | 3 | #define _ASM_X86_INSN_H |
---|
3 | 4 | /* |
---|
4 | 5 | * x86 instruction analysis |
---|
5 | 6 | * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
9 | | - * (at your option) any later version. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope that it will be useful, |
---|
12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | | - * GNU General Public License for more details. |
---|
15 | | - * |
---|
16 | | - * You should have received a copy of the GNU General Public License |
---|
17 | | - * along with this program; if not, write to the Free Software |
---|
18 | | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | | - * |
---|
20 | 7 | * Copyright (C) IBM Corporation, 2009 |
---|
21 | 8 | */ |
---|
22 | 9 | |
---|
23 | 10 | /* insn_attr_t is defined in inat.h */ |
---|
24 | | -#include <asm/inat.h> |
---|
| 11 | +#include <asm/inat.h> /* __ignore_sync_check__ */ |
---|
25 | 12 | |
---|
26 | 13 | struct insn_field { |
---|
27 | 14 | union { |
---|
.. | .. |
---|
58 | 45 | struct insn_field immediate2; /* for 64bit imm or seg16 */ |
---|
59 | 46 | }; |
---|
60 | 47 | |
---|
| 48 | + int emulate_prefix_size; |
---|
61 | 49 | insn_attr_t attr; |
---|
62 | 50 | unsigned char opnd_bytes; |
---|
63 | 51 | unsigned char addr_bytes; |
---|
.. | .. |
---|
99 | 87 | #define X86_VEX_M_MAX 0x1f /* VEX3.M Maximum value */ |
---|
100 | 88 | |
---|
101 | 89 | extern void insn_init(struct insn *insn, const void *kaddr, int buf_len, int x86_64); |
---|
102 | | -extern void insn_get_prefixes(struct insn *insn); |
---|
103 | | -extern void insn_get_opcode(struct insn *insn); |
---|
104 | | -extern void insn_get_modrm(struct insn *insn); |
---|
105 | | -extern void insn_get_sib(struct insn *insn); |
---|
106 | | -extern void insn_get_displacement(struct insn *insn); |
---|
107 | | -extern void insn_get_immediate(struct insn *insn); |
---|
108 | | -extern void insn_get_length(struct insn *insn); |
---|
| 90 | +extern int insn_get_prefixes(struct insn *insn); |
---|
| 91 | +extern int insn_get_opcode(struct insn *insn); |
---|
| 92 | +extern int insn_get_modrm(struct insn *insn); |
---|
| 93 | +extern int insn_get_sib(struct insn *insn); |
---|
| 94 | +extern int insn_get_displacement(struct insn *insn); |
---|
| 95 | +extern int insn_get_immediate(struct insn *insn); |
---|
| 96 | +extern int insn_get_length(struct insn *insn); |
---|
| 97 | + |
---|
| 98 | +enum insn_mode { |
---|
| 99 | + INSN_MODE_32, |
---|
| 100 | + INSN_MODE_64, |
---|
| 101 | + /* Mode is determined by the current kernel build. */ |
---|
| 102 | + INSN_MODE_KERN, |
---|
| 103 | + INSN_NUM_MODES, |
---|
| 104 | +}; |
---|
| 105 | + |
---|
| 106 | +extern int insn_decode(struct insn *insn, const void *kaddr, int buf_len, enum insn_mode m); |
---|
| 107 | + |
---|
| 108 | +#define insn_decode_kernel(_insn, _ptr) insn_decode((_insn), (_ptr), MAX_INSN_SIZE, INSN_MODE_KERN) |
---|
109 | 109 | |
---|
110 | 110 | /* Attribute will be determined after getting ModRM (for opcode groups) */ |
---|
111 | 111 | static inline void insn_get_attribute(struct insn *insn) |
---|
.. | .. |
---|
141 | 141 | return (insn->vex_prefix.nbytes == 4); |
---|
142 | 142 | } |
---|
143 | 143 | |
---|
| 144 | +static inline int insn_has_emulate_prefix(struct insn *insn) |
---|
| 145 | +{ |
---|
| 146 | + return !!insn->emulate_prefix_size; |
---|
| 147 | +} |
---|
| 148 | + |
---|
144 | 149 | /* Ensure this instruction is decoded completely */ |
---|
145 | 150 | static inline int insn_complete(struct insn *insn) |
---|
146 | 151 | { |
---|