Compare commits

..

2 Commits

Author SHA1 Message Date
marv7000 947d8931a4 fix shitty attributes 2026-10-06 00:24:08 +02:00
marv7000 685f911431 change errno to error to avoid confusion 2026-10-06 00:20:35 +02:00
7 changed files with 14 additions and 21 deletions
+3 -3
View File
@@ -12,21 +12,21 @@ struct syscall_ret arch_archctl(uintptr_t op, uintptr_t arg) {
switch (op) { switch (op) {
case __ARCHCTL_SET_FSBASE: case __ARCHCTL_SET_FSBASE:
if (!arch_mem_addr_is_user(arg)) { if (!arch_mem_addr_is_user(arg)) {
ret.errno = EINVAL; ret.error = EINVAL;
return ret; return ret;
} }
asm_wrmsr(MSR_FS_BASE, arg); asm_wrmsr(MSR_FS_BASE, arg);
return ret; return ret;
case __ARCHCTL_SET_GSBASE: case __ARCHCTL_SET_GSBASE:
if (!arch_mem_addr_is_user(arg)) { if (!arch_mem_addr_is_user(arg)) {
ret.errno = EINVAL; ret.error = EINVAL;
return ret; return ret;
} }
// Update the inactive GSBASE MSR, not ours. // Update the inactive GSBASE MSR, not ours.
asm_wrmsr(MSR_KERNEL_GS_BASE, arg); asm_wrmsr(MSR_KERNEL_GS_BASE, arg);
return ret; return ret;
default: default:
ret.errno = EINVAL; ret.error = EINVAL;
return ret; return ret;
} }
} }
+2 -10
View File
@@ -14,18 +14,10 @@
#define __format(like, ...) gnu::format(like, __VA_ARGS__) #define __format(like, ...) gnu::format(like, __VA_ARGS__)
#define __always_inline gnu::always_inline #define __always_inline gnu::always_inline
#define __visibility gnu::visibility #define __visibility gnu::visibility
#define __pure gnu::pure
// TODO: Workaround for clang which doesn't have these C23 standard attributes yet.
#if !__has_c_attribute(unsequenced)
#define unsequenced gnu::const
#endif
#if !__has_c_attribute(reproducible)
#define reproducible gnu::pure
#endif
// Only clang has these hints, GCC would throw a warning here. // Only clang has these hints, GCC would throw a warning here.
// clang::noderef also don't support the C23 attribute format. // clang::noderef also doesn't support the C23 attribute format.
#ifdef __clang__ #ifdef __clang__
#define __user __attribute__((noderef, address_space(1))) #define __user __attribute__((noderef, address_space(1)))
#define __phys __attribute__((noderef, address_space(2))) #define __phys __attribute__((noderef, address_space(2)))
+1 -1
View File
@@ -4,7 +4,7 @@
struct syscall_ret { struct syscall_ret {
uintptr_t value; uintptr_t value;
int errno; int error;
}; };
struct syscall { struct syscall {
+1 -1
View File
@@ -1,5 +1,5 @@
#ifndef SYSCALL_DECLARE #ifndef SYSCALL_DECLARE
#define SYSCALL_DECLARE(number, name, num_args) extern void sys_##name(...); #define SYSCALL_DECLARE(number, name, num_args)
#endif #endif
SYSCALL_DECLARE(0, exit, 1) SYSCALL_DECLARE(0, exit, 1)
+2 -1
View File
@@ -8,6 +8,7 @@
#include <bits/sched.h> #include <bits/sched.h>
// Declare all syscalls. // Declare all syscalls.
#define SYSCALL_DECLARE(number, name, num_args) extern void sys_##name(...);
#include <zinnia/syscall_list.inc> #include <zinnia/syscall_list.inc>
#undef SYSCALL_DECLARE #undef SYSCALL_DECLARE
@@ -43,5 +44,5 @@ void syscall_dispatch(struct arch_context* ctx) {
} }
ctx->ARCH_CTX_RET0 = ret.value; ctx->ARCH_CTX_RET0 = ret.value;
ctx->ARCH_CTX_RET1 = ret.errno; ctx->ARCH_CTX_RET1 = ret.error;
} }
+1 -1
View File
@@ -4,7 +4,7 @@
struct syscall_ret sys_exit(int err) { struct syscall_ret sys_exit(int err) {
struct syscall_ret ret = {}; struct syscall_ret ret = {};
ret.errno = ENOSYS; ret.error = ENOSYS;
panic("sys::exit() not implemented!\n"); panic("sys::exit() not implemented!\n");
+4 -4
View File
@@ -20,7 +20,7 @@ struct syscall_ret sys_setuname(const __user struct __utsname* ptr) {
struct syscall_ret ret = {}; struct syscall_ret ret = {};
if (!ptr) { if (!ptr) {
ret.errno = EINVAL; ret.error = EINVAL;
return ret; return ret;
} }
@@ -28,7 +28,7 @@ struct syscall_ret sys_setuname(const __user struct __utsname* ptr) {
struct __utsname read_buf; struct __utsname read_buf;
if (!usercopy_read(&read_buf, ptr, sizeof(read_buf))) { if (!usercopy_read(&read_buf, ptr, sizeof(read_buf))) {
ret.errno = EFAULT; ret.error = EFAULT;
return ret; return ret;
} }
@@ -50,7 +50,7 @@ struct syscall_ret sys_getuname(__user struct __utsname* ptr) {
struct syscall_ret ret = {}; struct syscall_ret ret = {};
if (!ptr) { if (!ptr) {
ret.errno = EINVAL; ret.error = EINVAL;
return ret; return ret;
} }
@@ -59,7 +59,7 @@ struct syscall_ret sys_getuname(__user struct __utsname* ptr) {
spin_unlock(&uname_lock); spin_unlock(&uname_lock);
if (!usercopy_write(ptr, &write_buf, sizeof(write_buf))) if (!usercopy_write(ptr, &write_buf, sizeof(write_buf)))
ret.errno = EFAULT; ret.error = EFAULT;
return ret; return ret;
} }