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