From 5958c43275236bf5508c2e1582b245c60e1b83fd Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 27 May 2024 09:17:28 -0400 Subject: kernel: syslog: Serialize kprintf() Signed-off-by: Ian Moffett --- sys/kern/kern_syslog.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sys') diff --git a/sys/kern/kern_syslog.c b/sys/kern/kern_syslog.c index f52c05f..86877e0 100644 --- a/sys/kern/kern_syslog.c +++ b/sys/kern/kern_syslog.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,7 @@ __STATIC_ASSERT(KMSG_BUF_SHIFT <= 16, "Log buffer shift too large!\n"); static char kmsg_buf[KMSG_BUF_SIZE]; static size_t kmsg_buf_idx = 0; static struct proc_entry *kmsg_proc; +static struct spinlock lock = {0}; struct vcons_screen g_syslog_screen = {0}; bool g_syslog_use_tty = true; @@ -92,6 +94,9 @@ syslog_write(const char *s, size_t len) tty_flush(&g_root_tty); } +/* + * XXX: Not serialized + */ void vkprintf(const char *fmt, va_list *ap) { @@ -111,6 +116,8 @@ kprintf(const char *fmt, ...) const char *fmt_p = fmt; struct timer tmr = {0}; + spinlock_acquire(&lock); + /* * If the first char is OMIT_TIMESTAMP, then we won't * print out the timestamp. @@ -139,6 +146,8 @@ kprintf(const char *fmt, ...) va_start(ap, fmt); vkprintf(fmt_p, &ap); va_end(ap); + + spinlock_release(&lock); } void -- cgit v1.2.3