From e9d80241385d7407bf3f3c88d6dc26da442e8b5a Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sat, 17 Oct 2026 17:36:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(sched):=20=E5=8E=8B=E7=BC=A9=20=5Fdo=5Fswit?= =?UTF-8?q?ch=20=E6=B3=A8=E9=87=8A=EF=BC=8C=E8=A7=84=E9=81=BF=E5=86=85?= =?UTF-8?q?=E8=81=94=E6=B1=87=E7=BC=96=202047=20=E5=AD=97=E8=8A=82?= =?UTF-8?q?=E9=9D=99=E9=BB=98=E6=88=AA=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit llc 报 :55:13 invalid operand + 孤立 mov 的真因:ViperC 的 _asm_append_cstr 只写入 ASM_TEXT_BUF_SIZE-1=2047 字节且静默丢弃后续内容。_do_switch 的 asm 模板(含 CRLF)为 2245 字节,第 2047 字节正好落在 mov [rsi + 40], rcx 的 mov 之后 ⇒ 生成的汇编串以孤立 mov 结尾,popfq/pop/ret 全部丢失。压缩块内 4 条中文注释(模板降到 1894 字节),指令与 clobber 未动。附:sha1_map 第 57 行 3e23dc8764e4a4dd:sched/sched.vp 与报错哈希一致;全仓 16 个含 asm 的 .vp、189 个模板中仅此一处超过 2047 字节。 --- VKernel/Kernel/sched/sched.vp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/VKernel/Kernel/sched/sched.vp b/VKernel/Kernel/sched/sched.vp index d6b5758..558b111 100644 --- a/VKernel/Kernel/sched/sched.vp +++ b/VKernel/Kernel/sched/sched.vp @@ -336,10 +336,10 @@ def _do_switch(): push r14 push r15 pushfq - # 切栈前保存本线程 SSE/FPU 状态(rax 已压栈,可作暂存;fxsave 不动通用寄存器) + # 切栈前保存 FPU/ISR mov rax, [rip + _switch_old_fpu] fxsave [rax] - # 按线程保存 ISR scratch(被抢占的 ISR 会跨越其它线程的 ISR) + # 保存 ISR scratch lea rsi, [rip + _isr_scratch] mov eax, dword ptr [rip + _switch_old_tid] imul rax, rax, 48 @@ -361,10 +361,10 @@ def _do_switch(): mov [rax], rsp mov rax, [rip + _switch_new_rsp] mov rsp, [rax] - # 换栈后恢复切入线程的 SSE/FPU 状态(不动通用寄存器;此时 rax 属新栈的保存值) + # 换栈后恢复 FPU/ISR mov rax, [rip + _switch_new_fpu] fxrstor [rax] - # 恢复切入线程的 scratch(不在 ISR 中时内容无意义,覆盖无害) + # 恢复 ISR scratch lea rsi, [rip + _isr_scratch] mov eax, dword ptr [rip + _switch_new_tid] imul rax, rax, 48