Compare commits

..

No commits in common. "105ed79f8f0a89fbc4791e8ef7136c36a9b101a8" and "c6d91c89cdecf9b62d614595144217dbc179b1e0" have entirely different histories.

5 changed files with 7 additions and 24 deletions

View File

@ -15,7 +15,3 @@
# control characters, leading/trailing spaces, problematic characters and invalid UTF-8). Keep in mind that this restriction # control characters, leading/trailing spaces, problematic characters and invalid UTF-8). Keep in mind that this restriction
# is only enforced when creating files; existing files with such illegal filenames are parsed correctly and fully usable. # is only enforced when creating files; existing files with such illegal filenames are parsed correctly and fully usable.
# target_compile_definitions(moon PRIVATE MOON_DISABLE_FILENAME_RESTRICTIONS) # target_compile_definitions(moon PRIVATE MOON_DISABLE_FILENAME_RESTRICTIONS)
# Uncomment the line below to make the kernel also calculate stack traces for userspace addresses on program crashes.
# This can aid in debugging, but makes the kernel more unstable as stack tracing will access arbitrary userspace memory.
# target_compile_definitions(moon PRIVATE MOON_ENABLE_USERSPACE_STACK_TRACES)

View File

@ -326,10 +326,7 @@ namespace CPU
static void backtrace_impl(u64 base_pointer, void (*callback)(u64, void*), void* arg) static void backtrace_impl(u64 base_pointer, void (*callback)(u64, void*), void* arg)
{ {
StackFrame* current_frame = (StackFrame*)base_pointer; StackFrame* current_frame = (StackFrame*)base_pointer;
while (current_frame && while (current_frame && (u64)current_frame >= 0xFFFF'FFFF'8000'0000 &&
#ifndef MOON_ENABLE_USERSPACE_STACK_TRACES
(u64)current_frame >= 0xFFFF'FFFF'8000'0000 &&
#endif
MemoryManager::validate_access(current_frame, sizeof(*current_frame), MemoryManager::DEFAULT_ACCESS) && MemoryManager::validate_access(current_frame, sizeof(*current_frame), MemoryManager::DEFAULT_ACCESS) &&
current_frame->instruction) current_frame->instruction)
{ {

View File

@ -5,7 +5,6 @@
#include <bits/fixed-size-types.h> #include <bits/fixed-size-types.h>
#include <bits/platform.h> #include <bits/platform.h>
#include <bits/signal.h>
#ifndef _SETJMP_H #ifndef _SETJMP_H
#error "Never use bits/setjmp-types.h directly; include setjmp.h instead." #error "Never use bits/setjmp-types.h directly; include setjmp.h instead."
@ -13,13 +12,7 @@
#ifdef __libc_arch_x86_64 #ifdef __libc_arch_x86_64
typedef __u64_t jmp_buf[8]; typedef __u64_t jmp_buf[8];
typedef struct typedef __u64_t sigjmp_buf[8];
{
jmp_buf buf;
sigset_t set;
int saved;
} __sigjmp_buf_tag;
typedef __sigjmp_buf_tag sigjmp_buf[1];
#else #else
#error "Unsupported architecture." #error "Unsupported architecture."
#endif #endif

View File

@ -14,13 +14,13 @@ extern "C"
/* Saves the current execution state in env. */ /* Saves the current execution state in env. */
int setjmp(jmp_buf env); int setjmp(jmp_buf env);
/* Saves the current execution state (and optionally, the current signal mask) in env. */ /* Right now, does the exact same thing as setjmp() (savesigs is ignored), since signals are not implemented. */
int sigsetjmp(sigjmp_buf env, int savesigs); int sigsetjmp(sigjmp_buf env, int savesigs);
/* Restores the execution state saved in env by a setjmp() call. */ /* Restores the execution state saved in env by a setjmp() call. */
__noreturn void longjmp(jmp_buf env, int val); __noreturn void longjmp(jmp_buf env, int val);
/* Restores the execution state saved in env by a sigsetjmp() call. */ /* Right now, does the exact same as longjmp(), since signals are not implemented. */
__noreturn void siglongjmp(sigjmp_buf env, int val); __noreturn void siglongjmp(sigjmp_buf env, int val);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,17 +1,14 @@
#include <setjmp.h> #include <setjmp.h>
#include <signal.h>
extern "C" extern "C"
{ {
int sigsetjmp(sigjmp_buf env, int savesigs) int sigsetjmp(sigjmp_buf env, int)
{ {
if (savesigs) env->saved = 1, sigprocmask(0, nullptr, &env->set); return setjmp(env);
return setjmp(env->buf);
} }
__noreturn void siglongjmp(sigjmp_buf env, int val) __noreturn void siglongjmp(sigjmp_buf env, int val)
{ {
if (env->saved) sigprocmask(SIG_SETMASK, &env->set, nullptr); longjmp(env, val);
longjmp(env->buf, val);
} }
} }