summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/debug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Syscalls/debug.cpp')
-rw-r--r--Kernel/Syscalls/debug.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/Kernel/Syscalls/debug.cpp b/Kernel/Syscalls/debug.cpp
index bd22e8b4c2..8bafe6399d 100644
--- a/Kernel/Syscalls/debug.cpp
+++ b/Kernel/Syscalls/debug.cpp
@@ -27,6 +27,7 @@
#include <Kernel/IO.h>
#include <Kernel/KSyms.h>
#include <Kernel/Process.h>
+#include <Kernel/UserOrKernelBuffer.h>
namespace Kernel {
@@ -44,13 +45,20 @@ int Process::sys$dbgputch(u8 ch)
int Process::sys$dbgputstr(Userspace<const u8*> characters, int length)
{
- if (!length)
+ if (length <= 0)
return 0;
- if (!validate_read(characters, length))
- return -EFAULT;
+
SmapDisabler disabler;
- for (int i = 0; i < length; ++i)
- IO::out8(0xe9, characters.unsafe_userspace_ptr()[i]);
+ auto buffer = UserOrKernelBuffer::for_user_buffer(characters, length);
+ if (!buffer.has_value())
+ return -EFAULT;
+ ssize_t nread = buffer.value().read_buffered<1024>(length, [&](const u8* buffer, size_t buffer_size) {
+ for (size_t i = 0; i < buffer_size; ++i)
+ IO::out8(0xe9, buffer[i]);
+ return (ssize_t)buffer_size;
+ });
+ if (nread < 0)
+ return (int)nread;
return 0;
}