git: 9b091f12008f - main - kinst: simplify trampoline fill definitions

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Sat, 03 Jun 2023 17:05:19 UTC
The branch main has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=9b091f12008f060cd1c03b91b020f24187341d60

commit 9b091f12008f060cd1c03b91b020f24187341d60
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2023-06-03 17:04:57 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2023-06-03 17:04:57 +0000

    kinst: simplify trampoline fill definitions
    
    Centralize KINST_TRAMP_FILL_PATTERN and KINST_TRAMP_FILL_SIZE to reduce
    redefinitions, and use the architecture-dependent kinst_patchval_t as
    their size.
    
    Reviewed by:    markj
    Approved by:    markj (mentor)
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D40406
---
 sys/cddl/dev/kinst/amd64/kinst_isa.h | 6 ++----
 sys/cddl/dev/kinst/trampoline.c      | 5 ++++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/sys/cddl/dev/kinst/amd64/kinst_isa.h b/sys/cddl/dev/kinst/amd64/kinst_isa.h
index eb4f79c4c726..bd7d40f4bd06 100644
--- a/sys/cddl/dev/kinst/amd64/kinst_isa.h
+++ b/sys/cddl/dev/kinst/amd64/kinst_isa.h
@@ -17,10 +17,8 @@
  * have 2 instructions stored in the trampoline, and each of them can take up
  * to 16 bytes, 32 bytes is enough to cover even the worst case scenario.
  */
-#define	KINST_TRAMP_SIZE		32
-#define	KINST_TRAMPCHUNK_SIZE		PAGE_SIZE
-#define KINST_TRAMP_FILL_PATTERN	((uint8_t []){KINST_PATCHVAL})
-#define KINST_TRAMP_FILL_SIZE		sizeof(uint8_t)
+#define	KINST_TRAMP_SIZE	32
+#define	KINST_TRAMPCHUNK_SIZE	PAGE_SIZE
 
 typedef uint8_t kinst_patchval_t;
 
diff --git a/sys/cddl/dev/kinst/trampoline.c b/sys/cddl/dev/kinst/trampoline.c
index 75efd022fb20..5c8c27343201 100644
--- a/sys/cddl/dev/kinst/trampoline.c
+++ b/sys/cddl/dev/kinst/trampoline.c
@@ -28,7 +28,10 @@
 #include "kinst.h"
 #include "kinst_isa.h"
 
-#define KINST_TRAMPS_PER_CHUNK	(KINST_TRAMPCHUNK_SIZE / KINST_TRAMP_SIZE)
+#define KINST_TRAMP_FILL_PATTERN	((kinst_patchval_t []){KINST_PATCHVAL})
+#define KINST_TRAMP_FILL_SIZE		sizeof(kinst_patchval_t)
+
+#define KINST_TRAMPS_PER_CHUNK		(KINST_TRAMPCHUNK_SIZE / KINST_TRAMP_SIZE)
 
 struct trampchunk {
 	TAILQ_ENTRY(trampchunk) next;