summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2017-05-11 09:36:51 +0000
committerkib <kib@FreeBSD.org>2017-05-11 09:36:51 +0000
commitdad5ccf4808854af8f6af32ab4f15dca00dae42b (patch)
treea629fb54970edd47e6efaae5913abafa5a662a1c /sys/kern
parenta3bbb52744f6222d95f7329383f674e7c4472ab5 (diff)
downloadFreeBSD-src-dad5ccf4808854af8f6af32ab4f15dca00dae42b.zip
FreeBSD-src-dad5ccf4808854af8f6af32ab4f15dca00dae42b.tar.gz
MFC r317523:
Add asserts to verify stability of struct proc and struct thread layouts.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_thread.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index df33821..6a42950 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -64,6 +64,57 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_domain.h>
#include <sys/eventhandler.h>
+/*
+ * Asserts below verify the stability of struct thread and struct proc
+ * layout, as exposed by KBI to modules. On head, the KBI is allowed
+ * to drift, change to the structures must be accompanied by the
+ * assert update.
+ *
+ * On the stable branches after KBI freeze, conditions must not be
+ * violated. Typically new fields are moved to the end of the
+ * structures.
+ */
+#ifdef __amd64__
+_Static_assert(offsetof(struct thread, td_flags) == 0xe4,
+ "struct thread KBI td_flags");
+_Static_assert(offsetof(struct thread, td_pflags) == 0xec,
+ "struct thread KBI td_pflags");
+_Static_assert(offsetof(struct thread, td_frame) == 0x418,
+ "struct thread KBI td_frame");
+_Static_assert(offsetof(struct thread, td_emuldata) == 0x4c0,
+ "struct thread KBI td_emuldata");
+_Static_assert(offsetof(struct proc, p_flag) == 0xb0,
+ "struct proc KBI p_flag");
+_Static_assert(offsetof(struct proc, p_pid) == 0xbc,
+ "struct proc KBI p_pid");
+_Static_assert(offsetof(struct proc, p_filemon) == 0x3d0,
+ "struct proc KBI p_filemon");
+_Static_assert(offsetof(struct proc, p_comm) == 0x3e0,
+ "struct proc KBI p_comm");
+_Static_assert(offsetof(struct proc, p_emuldata) == 0x4b0,
+ "struct proc KBI p_emuldata");
+#endif
+#ifdef __i386__
+_Static_assert(offsetof(struct thread, td_flags) == 0x8c,
+ "struct thread KBI td_flags");
+_Static_assert(offsetof(struct thread, td_pflags) == 0x94,
+ "struct thread KBI td_pflags");
+_Static_assert(offsetof(struct thread, td_frame) == 0x2c0,
+ "struct thread KBI td_frame");
+_Static_assert(offsetof(struct thread, td_emuldata) == 0x30c,
+ "struct thread KBI td_emuldata");
+_Static_assert(offsetof(struct proc, p_flag) == 0x68,
+ "struct proc KBI p_flag");
+_Static_assert(offsetof(struct proc, p_pid) == 0x74,
+ "struct proc KBI p_pid");
+_Static_assert(offsetof(struct proc, p_filemon) == 0x278,
+ "struct proc KBI p_filemon");
+_Static_assert(offsetof(struct proc, p_comm) == 0x284,
+ "struct proc KBI p_comm");
+_Static_assert(offsetof(struct proc, p_emuldata) == 0x304,
+ "struct proc KBI p_emuldata");
+#endif
+
SDT_PROVIDER_DECLARE(proc);
SDT_PROBE_DEFINE(proc, , , lwp__exit);
OpenPOWER on IntegriCloud