summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMerlin Scholz <merlin@scholz.ruhr>2022-10-17 22:44:37 +0200
committerMerlin Scholz <merlin@scholz.ruhr>2022-10-17 22:44:37 +0200
commit43541eb4960ae12af3a65f0fa389a5c8c13f67ab (patch)
treeb73c41be3562e3d0c973947a4253da27940f8c92
parent1df0d21d448db8d42144dbf29f840ea4751fcc7e (diff)
Continue implementation
-rw-r--r--.gitignore1
-rw-r--r--TODO4
-rw-r--r--sys/kern/kern_rwlock.c3
-rw-r--r--sys/sys/lockdoc.h41
-rw-r--r--sys/sys/lockdoc_event.h11
5 files changed, 59 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 76b6f3ba2fa..41d4b849aa6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
/obj/**
/.idea/**
+/.vscode/** \ No newline at end of file
diff --git a/TODO b/TODO
new file mode 100644
index 00000000000..a0ab1197c06
--- /dev/null
+++ b/TODO
@@ -0,0 +1,4 @@
+- SMP
+- IRQ
+- Implement all lock types
+- Memory access \ No newline at end of file
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
index fbdbcdad870..cf9924728ea 100644
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -53,6 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.54 2019/05/09 05:00:31 ozaki-r Exp
#include <sys/atomic.h>
#include <sys/lock.h>
#include <sys/pserialize.h>
+#include <sys/lockdoc.h>
#include <dev/lockstat.h>
@@ -570,6 +571,8 @@ rw_vector_tryenter(krwlock_t *rw, const krw_t op)
RW_DASSERT(rw, (op != RW_READER && RW_OWNER(rw) == curthread) ||
(op == RW_READER && RW_COUNT(rw) != 0));
+
+ log_lock(P_WRITE, rw, __FILE__, __LINE__, LOCK_NONE);
return 1;
}
diff --git a/sys/sys/lockdoc.h b/sys/sys/lockdoc.h
index ee9ffdb8820..b101b05bd4a 100644
--- a/sys/sys/lockdoc.h
+++ b/sys/sys/lockdoc.h
@@ -24,8 +24,47 @@ static inline void log_memory(int alloc, const char *datatype, const void *ptr,
}
-static inline void log_lock(int lock_op, const kmutex_t* ptr, const char *file, int line, int irq_sync) {
+static inline void log_lock(int lock_op, const void* ptr, const char *file, int line, int irq_sync) {
+
memset(&la_buffer,0,sizeof(la_buffer));
+
+ // TODO fail shows 0x016c instead of 0x6c
+ // action
+ la_buffer.action = LOCKDOC_LOCK_OP;
+
+ // operation
+ la_buffer.lock_op = lock_op;
+
+ // pointer
+ la_buffer.ptr = (unsigned long)ptr;
+
+ // size only relevant for memory access
+
+ // TODO type
+ //strncpy(la_buffer.type, ,LOG_CHAR_BUFFER_LEN);
+ la_buffer.type[LOG_CHAR_BUFFER_LEN - 1] = '\0';
+
+ // TODO lock_member
+ strncpy(la_buffer.lock_member,"dummy",LOG_CHAR_BUFFER_LEN);
+ la_buffer.lock_member[LOG_CHAR_BUFFER_LEN - 1] = '\0';
+
+
+ // file
+ strncpy(la_buffer.file,file,LOG_CHAR_BUFFER_LEN);
+ la_buffer.file[LOG_CHAR_BUFFER_LEN - 1] = '\0';
+
+
+ // line
+ la_buffer.line = line;
+
+ // TODO function
+ strncpy(la_buffer.function,"dummy",LOG_CHAR_BUFFER_LEN);
+ la_buffer.function[LOG_CHAR_BUFFER_LEN - 1] = '\0';
+
+ // TODO preempt_count
+ // TODO irq_sync
+ // TODO flags
+
outb_(PING_CHAR,IO_PORT_LOG);
}
#else
diff --git a/sys/sys/lockdoc_event.h b/sys/sys/lockdoc_event.h
index 5dc402cf435..6addbe5b3ab 100644
--- a/sys/sys/lockdoc_event.h
+++ b/sys/sys/lockdoc_event.h
@@ -24,6 +24,17 @@
* has to be copied to the according fail experiment
* as well as to convert!
*/
+enum LOCKDOC_OP {
+ LOCKDOC_ALLOC = 'a',
+ LOCKDOC_FREE = 'f',
+ LOCKDOC_LOCK_OP = 'l',
+ LOCKDOC_CURRENT_TASK = 't',
+ LOCKDOC_PREEMPT_COUNT = 'p',
+ LOCKDOC_PID_OFFSET = 'o',
+ LOCKDOC_KERNEL_VERSION = 'v',
+ LOCKDOC_READ = 'r',
+ LOCKDOC_WRITE = 'w'
+};
enum LOCK_OP {
P_READ = 0,