]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/cddl/dev/kinst/amd64/kinst_isa.h
libpcap: Update to 1.10.4
[FreeBSD/FreeBSD.git] / sys / cddl / dev / kinst / amd64 / kinst_isa.h
1 /*
2  * SPDX-License-Identifier: CDDL 1.0
3  *
4  * Copyright 2022 Christos Margiolis <christos@FreeBSD.org>
5  * Copyright 2022 Mark Johnston <markj@FreeBSD.org>
6  */
7
8 #ifndef _KINST_ISA_H_
9 #define _KINST_ISA_H_
10
11 #include <sys/types.h>
12
13 #define KINST_PATCHVAL          0xcc
14
15 /*
16  * Each trampoline is 32 bytes long and contains [instruction, jmp]. Since we
17  * have 2 instructions stored in the trampoline, and each of them can take up
18  * to 16 bytes, 32 bytes is enough to cover even the worst case scenario.
19  */
20 #define KINST_TRAMP_SIZE        32
21 #define KINST_TRAMPCHUNK_SIZE   PAGE_SIZE
22
23 /*
24  * Fill the trampolines with breakpoint instructions so that the kernel will
25  * crash cleanly if things somehow go wrong.
26  */
27 #define KINST_TRAMP_INIT(t, s)  memset((t), KINST_PATCHVAL, (s))
28
29 typedef uint8_t kinst_patchval_t;
30
31 struct kinst_probe_md {
32         int                     flags;
33         int                     instlen;        /* original instr len */
34         int                     tinstlen;       /* trampoline instr len */
35         uint8_t                 template[16];   /* copied into thread tramps */
36         int                     dispoff;        /* offset of rip displacement */
37
38         /* operands to "call" instruction branch target */
39         int                     reg1;
40         int                     reg2;
41         int                     scale;
42         int64_t                 disp;
43 };
44
45 #endif /* _KINST_ISA_H_ */