summaryrefslogtreecommitdiff
path: root/src/kernel/syscalls.c
diff options
context:
space:
mode:
authordzwdz2024-08-02 01:20:40 +0200
committerdzwdz2024-08-02 01:20:40 +0200
commite818cab3f1fc4a3d4d0b8e2c9424fb2e7b1dff70 (patch)
tree5d59d2e0ea74253f5b265cdd542b74daca6dce5a /src/kernel/syscalls.c
parent1890868af4b8cf2593a4b0831e2fc69a44ec680b (diff)
*: use a generic UserRegs type everywhere I'm storing registers
mostly inspired by Plan 9's Ureg, probably obvious from the name
Diffstat (limited to 'src/kernel/syscalls.c')
-rw-r--r--src/kernel/syscalls.c33
1 files changed, 1 insertions, 32 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index 42f548e..e94f886 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -488,43 +488,12 @@ long _sys_duplex(hid_t from, hid_t to, int flags) {
}
void _sys_intr_return(struct intr_data __user *intr, int flags) {
- CpuRegs *r = &proc_cur->regs;
struct intr_data d;
if (flags != 0 || pcpy_from(proc_cur, &d, intr, sizeof(d)) < sizeof(d)) {
proc_kill(proc_cur, EFAULT);
proc_switch_any(); /* doesn't return */
}
- r->r15 = d.r15;
- r->r14 = d.r14;
- r->r13 = d.r13;
- r->r12 = d.r12;
- r->r11 = d.r11;
- r->r10 = d.r10;
- r->r9 = d.r9;
- r->r8 = d.r8;
- r->rdi = d.rdi;
- r->rsi = d.rsi;
- r->rbp = d.rbp;
- r->rsp = d.rsp;
- r->rbx = d.rbx;
- r->rdx = d.rdx;
- r->rcx = d.rcx;
- r->rax = d.rax;
- r->rip = d.rip;
- /* preserved flags: (see intel vol 1 3.4.3.)
- * 1<<0 = CF, carry flag
- * 1<<2 = PF, parity flag
- * 1<<4 = AC, auxilary carry
- * 1<<6 = ZF, zero flag
- * 1<<7 = SF, sign flag
- * 1<<11 = OF, overflow flag
- * 1<<10 = DF, direction flag
- */
- static_assert(
- ((1<<0) | (1<<2) | (1<<4) | (1<<6) | (1<<7) | (1<<10) | (1<<11))
- == 0xCD5
- );
- r->flags = (d.flags & 0xCD5) | (r->flags & ~0xCD5);
+ regs_safecopy(&proc_cur->regs, &d.reg);
}
long _sys_execbuf(void __user *ubuf, size_t len) {