diff --git a/sys/cddl/dev/kinst/amd64/kinst_isa.h b/sys/cddl/dev/kinst/amd64/kinst_isa.h --- a/sys/cddl/dev/kinst/amd64/kinst_isa.h +++ b/sys/cddl/dev/kinst/amd64/kinst_isa.h @@ -20,12 +20,6 @@ #define KINST_TRAMP_SIZE 32 #define KINST_TRAMPCHUNK_SIZE PAGE_SIZE -/* - * Fill the trampolines with breakpoint instructions so that the kernel will - * crash cleanly if things somehow go wrong. - */ -#define KINST_TRAMP_INIT(t, s) memset((t), KINST_PATCHVAL, (s)) - typedef uint8_t kinst_patchval_t; struct kinst_probe_md { diff --git a/sys/cddl/dev/kinst/trampoline.c b/sys/cddl/dev/kinst/trampoline.c --- a/sys/cddl/dev/kinst/trampoline.c +++ b/sys/cddl/dev/kinst/trampoline.c @@ -29,8 +29,17 @@ #include "kinst_isa.h" /* - * We can have 4KB/32B = 128 trampolines per chunk. + * Fill the trampolines with breakpoint instructions so that the kernel will + * crash cleanly if things somehow go wrong. */ +#define KINST_TRAMP_INIT(t, s) do { \ + int _i, _v; \ + \ + _v = KINST_PATCHVAL; \ + for (_i = 0; _i < (s); _i += sizeof(kinst_patchval_t)) \ + memcpy(&((uint8_t *)(t))[_i], &_v, sizeof(kinst_patchval_t)); \ +} while (0) + #define KINST_TRAMPS_PER_CHUNK (KINST_TRAMPCHUNK_SIZE / KINST_TRAMP_SIZE) struct trampchunk {