hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/arch/x86/include/asm/insn.h
....@@ -1,27 +1,14 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 #ifndef _ASM_X86_INSN_H
23 #define _ASM_X86_INSN_H
34 /*
45 * x86 instruction analysis
56 *
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
- *
207 * Copyright (C) IBM Corporation, 2009
218 */
229
2310 /* insn_attr_t is defined in inat.h */
24
-#include <asm/inat.h>
11
+#include <asm/inat.h> /* __ignore_sync_check__ */
2512
2613 struct insn_field {
2714 union {
....@@ -58,6 +45,7 @@
5845 struct insn_field immediate2; /* for 64bit imm or seg16 */
5946 };
6047
48
+ int emulate_prefix_size;
6149 insn_attr_t attr;
6250 unsigned char opnd_bytes;
6351 unsigned char addr_bytes;
....@@ -99,13 +87,25 @@
9987 #define X86_VEX_M_MAX 0x1f /* VEX3.M Maximum value */
10088
10189 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)
109109
110110 /* Attribute will be determined after getting ModRM (for opcode groups) */
111111 static inline void insn_get_attribute(struct insn *insn)
....@@ -141,6 +141,11 @@
141141 return (insn->vex_prefix.nbytes == 4);
142142 }
143143
144
+static inline int insn_has_emulate_prefix(struct insn *insn)
145
+{
146
+ return !!insn->emulate_prefix_size;
147
+}
148
+
144149 /* Ensure this instruction is decoded completely */
145150 static inline int insn_complete(struct insn *insn)
146151 {