diff options
author | Ian Moffett <ian@osmora.org> | 2025-05-31 01:56:21 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-05-31 01:56:21 -0400 |
commit | a1383ceb824076be78b23913b1a750c3a70a4f80 (patch) | |
tree | 692d226a19cb63fa7a270e056c1f058bd0701084 | |
parent | 396915ebad39c3b9e76211e91d859786d9695aa3 (diff) |
kernel/amd64: proc: Support kicking kernel threads
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/arch/amd64/amd64/proc_machdep.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/sys/arch/amd64/amd64/proc_machdep.c b/sys/arch/amd64/amd64/proc_machdep.c index f6b91f9..4fe8580 100644 --- a/sys/arch/amd64/amd64/proc_machdep.c +++ b/sys/arch/amd64/amd64/proc_machdep.c @@ -123,24 +123,37 @@ md_td_kick(struct proc *td) { struct trapframe *tfp; struct cpu_info *ci; + uint8_t rpl; + uint16_t ds = KERNEL_DS; tfp = &td->tf; + rpl = tfp->cs & 3; ci = this_cpu(); ci->curtd = td; + if (rpl == 3) { + td->flags &= ~PROC_KTD; + ds = USER_DS | 3; + } + __ASMV( - "push %0\n" + "mov %0, %%rax\n" "push %1\n" - "pushf\n" "push %2\n" "push %3\n" + "push %%rax\n" + "push %4\n" + "test $3, %%ax\n" + "jz 1f\n" "lfence\n" "swapgs\n" - "iretq" + "1:\n" + " iretq" : - : "i" (USER_DS | 3), + : "r" (tfp->cs), + "r" (ds), "r" (tfp->rsp), - "i" (USER_CS | 3), + "m" (tfp->rflags), "r" (tfp->rip) ); |