xref: /freebsd/sys/cddl/dev/kinst/amd64/kinst_isa.h (revision ba3c1f5972d7b90feb6e6da47905ff2757e0fe57)
1 /*
2  * SPDX-License-Identifier: CDDL 1.0
3  *
4  * Copyright (c) 2022 Christos Margiolis <christos@FreeBSD.org>
5  * Copyright (c) 2022 Mark Johnston <markj@FreeBSD.org>
6  * Copyright (c) 2023 The FreeBSD Foundation
7  *
8  * Portions of this software were developed by Christos Margiolis
9  * <christos@FreeBSD.org> under sponsorship from the FreeBSD Foundation.
10  */
11 
12 #ifndef _KINST_ISA_H_
13 #define _KINST_ISA_H_
14 
15 #include <sys/types.h>
16 
17 #define KINST_PATCHVAL		0xcc
18 
19 /*
20  * Each trampoline is 32 bytes long and contains [instruction, jmp]. Since we
21  * have 2 instructions stored in the trampoline, and each of them can take up
22  * to 16 bytes, 32 bytes is enough to cover even the worst case scenario.
23  */
24 #define	KINST_TRAMP_SIZE	32
25 
26 typedef uint8_t kinst_patchval_t;
27 
28 struct kinst_probe_md {
29 	int	flags;
30 	int	instlen;	/* original instr len */
31 	int	tinstlen;	/* trampoline instr len */
32 	uint8_t	template[16];	/* copied into thread tramps */
33 	int	dispoff;	/* offset of rip displacement */
34 
35 	/* operands to "call" instruction branch target */
36 	int	reg1;
37 	int	reg2;
38 	int	scale;
39 	int64_t	disp;
40 };
41 
42 #endif /* _KINST_ISA_H_ */
43