diff options
| author | Merlin Scholz <merlin@scholz.ruhr> | 2022-10-24 17:30:32 +0200 |
|---|---|---|
| committer | Merlin Scholz <merlin@scholz.ruhr> | 2022-10-24 17:30:32 +0200 |
| commit | 581d0d2125d0ef0541b12dc9ce81deb40aa4b79b (patch) | |
| tree | 00e59c26abe7f0b53d2c82a017118546134e1312 | |
| parent | 062b5ea39274e32d65f6369977a0b9142509e645 (diff) | |
First proper lockdoc hooks
| -rw-r--r-- | TODO | 1 | ||||
| -rw-r--r-- | sys/Makefile | 2 | ||||
| -rw-r--r-- | sys/arch/i386/conf/LOCKDOC | 2 | ||||
| -rw-r--r-- | sys/arch/i386/conf/files.i386 | 2 | ||||
| -rw-r--r-- | sys/arch/x86/include/cpufunc.h | 25 | ||||
| -rw-r--r-- | sys/lockdoc/log.c | 19 | ||||
| -rw-r--r-- | sys/sys/lockdoc.h | 1 |
7 files changed, 49 insertions, 3 deletions
@@ -1,3 +1,4 @@ +- Separate LOCKDEBUG from LOCKDOC kernel opt - SMP - IRQ - Implement all lock types diff --git a/sys/Makefile b/sys/Makefile index 3f1e18dc659..7eb25d75486 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -2,7 +2,7 @@ .include <bsd.own.mk> -SUBDIR= altq arch compat dev fs miscfs \ +SUBDIR= altq arch compat dev fs lockdoc miscfs \ net net80211 netatalk netbt netcan netipsec netinet netinet6 \ netmpls netsmb \ nfs opencrypto sys ufs uvm diff --git a/sys/arch/i386/conf/LOCKDOC b/sys/arch/i386/conf/LOCKDOC index 955fa29fec2..d7d2d0f7efe 100644 --- a/sys/arch/i386/conf/LOCKDOC +++ b/sys/arch/i386/conf/LOCKDOC @@ -22,7 +22,7 @@ include "arch/i386/conf/std.i386" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.1208.2.5 $" +#ident "LOCKDOC-$Revision: 1.1208.2.5 $" maxusers 64 # estimated number of users diff --git a/sys/arch/i386/conf/files.i386 b/sys/arch/i386/conf/files.i386 index 628d792929a..cabf5ab270b 100644 --- a/sys/arch/i386/conf/files.i386 +++ b/sys/arch/i386/conf/files.i386 @@ -48,7 +48,7 @@ defparam opt_beep.h BEEP_ONHALT_PITCH=1500 defparam opt_beep.h BEEP_ONHALT_PERIOD=250 -file lockdoc/log.c lockdebug +file lockdoc/log.c lockdebug # Multiboot support defflag opt_multiboot.h MULTIBOOT diff --git a/sys/arch/x86/include/cpufunc.h b/sys/arch/x86/include/cpufunc.h index 12e1f406ec9..c82058278b3 100644 --- a/sys/arch/x86/include/cpufunc.h +++ b/sys/arch/x86/include/cpufunc.h @@ -45,6 +45,7 @@ #ifdef _KERNEL #if defined(_KERNEL_OPT) #include "opt_xen.h" +#include "opt_lockdebug.h" #endif static inline void @@ -374,17 +375,41 @@ void xrstor(const union savefpu *, uint64_t); void x86_disable_intr(void); void x86_enable_intr(void); #else + +#ifdef LOCKDEBUG +#define x86_disable_intr() __x86_disable_intr(__FILE__, __LINE__, __func__) +void __x86_disable_intr(const char *file, int line, const char *func); + +static __inline void lockdoc_x86_disable_intr(void) +{ + __asm volatile ("cli" ::: "memory"); +} + +#else static inline void x86_disable_intr(void) { __asm volatile ("cli" ::: "memory"); } +#endif /* LOCKDEBUG */ +#ifdef LOCKDEBUG +#define x86_enable_intr() __x86_enable_intr(__FILE__, __LINE__, __func__) +void __x86_enable_intr(const char *file, int line, const char *func); + +static __inline void lockdoc_x86_enable_intr(void) +{ + __asm volatile ("sti" ::: "memory"); +} + +#else static inline void x86_enable_intr(void) { __asm volatile ("sti" ::: "memory"); } +#endif /* LOCKDEBUG */ + #endif /* XENPV */ /* Use read_psl, write_psl when saving and restoring interrupt state. */ diff --git a/sys/lockdoc/log.c b/sys/lockdoc/log.c index e2d49c76090..91d2a8d02cb 100644 --- a/sys/lockdoc/log.c +++ b/sys/lockdoc/log.c @@ -1,3 +1,22 @@ +#include <arch/x86/include/cpufunc.h> #include <sys/lockdoc.h> +#include "opt_lockdebug.h" + +#ifdef LOCKDEBUG + struct log_action la_buffer; + +void __x86_disable_intr(const char *file, int line, const char *func){ + // TODO Actually log things + lockdoc_x86_disable_intr(); + __asm __volatile("cli" : : : "memory"); +} + +void __x86_enable_intr(const char *file, int line, const char *func){ + // TODO Actually log things + lockdoc_x86_enable_intr(); + __asm __volatile ("sti" ::: "memory"); +} + +#endif /* LOCKDEBUG */
\ No newline at end of file diff --git a/sys/sys/lockdoc.h b/sys/sys/lockdoc.h index 45c1aa7faeb..e6b666540d5 100644 --- a/sys/sys/lockdoc.h +++ b/sys/sys/lockdoc.h @@ -2,6 +2,7 @@ #define __LOCKDOC_H__ #include <sys/types.h> +#include <sys/systm.h> #include <sys/lockdoc_event.h> #define DELIMITER "#" |
