Sibling vCPUs keep running through a MAP_SHARED overlay

未关闭
#495 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c, go, macos

调研方向

Start in src/syscall/proc.c at vcpu_handle_canceled_exit (around lines 4593–4655) and trace its EL1 and signal-delivery returns against thread_fork_barrier_check. Review hvf_apply_file_overlay_quiesced and the normal worker exit path in src/runtime/forkipc.c to understand the impact. Reproduce with the Go 1.23 workload and GOMAXPROCS=4; done means siblings stay quiesced through the overlay and the reported crashes and hangs no longer reproduce.

由索引模型根据 Issue 内容生成。

描述

bug

thread_quiesce_siblings does not hold every sibling. The quiesce kicks each sibling with hv_vcpus_exit, but vcpu_handle_canceled_exit can return VCPU_RESUME before it reaches thread_fork_barrier_check (src/syscall/proc.c:4655). Two branches do this: the EL1 early return (:4593) and the signal-delivery branch (:4641). The kick is one-shot, and the quiesce raises no attention bit, so that sibling keeps running guest code. When the caller is hvf_apply_file_overlay_quiesced, which calls hv_vm_unmap on the segment, the sibling takes a stage-2 translation fault:

unexpected exception EC=0x20 syndrome=0x82000007 VA=0x83950 PA=0x83950
unexpected exception EC=0x20 syndrome=0x82000086 VA=0x83950 PA=0xfeff010950

The second form has S1PTW set and faults on the page-table pool.

When the faulting vCPU is a worker, its run loop stops, the thread goes through the normal exit path (src/runtime/forkipc.c:1160), and the 128 exit code is dropped. The process keeps running one thread short. A Go guest then hangs with every remaining thread in futex_wait. Linux would kill the thread group with SIGSEGV instead.

Reproduce: Go 1.23 telemetry mmaps its counter file MAP_SHARED, so any Go tool does this. On upstream main 170b5df, with golang:1.23-alpine through scripts/elfuse-oci.py, each iteration runs go env GOROOT and then gofmt -l over net, runtime and crypto and gofmt -d over fmt, with GOMAXPROCS=4:

  • with GODEBUG=schedtrace=10: 20 crash reports and 2 hangs in 59 iterations
  • without schedtrace: 0 in 400
  • with schedtrace after go telemetry off: 0 in 60

It is not clear why schedtrace raises the rate.

Calling thread_fork_barrier_check() at the top of vcpu_handle_canceled_exit, before the EL1 early return, gave 0 crashes in 120 iterations, and the make check unit suites pass with it. Moving the check above only the signal branch was not enough (4 crashes in 8 iterations). A kick to a vCPU that is outside hv_vcpu_run is held for the next run (checked: CANCELED within 0.002 ms), so the gap is in how the CANCELED exit is handled, not a lost kick.

主要语言
C
星标
287
派生
33
平均合并
2 天 17 小时
30 天内合并 PR
18

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sysprog21/elfuse 的其他 Issue

查看 sysprog21/elfuse 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。