Repository navigation
Conversation
The host checked r8 for the TraceBatch marker on every exit, and nothing cleared it. The Halt after each flush re-read the same buffer, so every span in it was exported twice. Clear r8 in the guest after each OUT that carries a batch, and check for a batch on the host only on OUT exits. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
76d0f03 to
0c48193
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The user-visible trace_guest duplicate-span fix is missing a release note in the prerelease Fixed section of CHANGELOG.md.
1 open issue
What changed in this PR
This PR prevents duplicate guest spans by ensuring each trace batch is consumed once across Hyperlight’s guest-to-host tracing boundary.
Changes:
- Clear the trace marker after both guest trace-delivery paths.
- Restrict host trace-batch checks to OUT exits.
- Document the register protocol and exit handling.
| File | Description |
|---|---|
src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs |
Checks for trace batches only on OUT exits. |
src/hyperlight_guest/src/arch/amd64/exit.rs |
Clears r8 after sending piggybacked trace data. |
src/hyperlight_guest_tracing/src/state.rs |
Clears r8 after dedicated trace-batch sends. |
docs/hyperlight-metrics-logs-and-traces.md |
Describes OUT-only delivery and marker clearing. |
Review effort: Balanced
| }); | ||
| // The guest reports trace batches only on OUT exits. Other exits | ||
| // can hold stale registers and must not be checked. | ||
| if let Ok(VmExit::IoOut(..)) = &result { |
Benchmark ResultsMeasured commit: kvm / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
kvm / intel (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / intel (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / amd (Windows) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / intel (Windows) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
Reported by |
|
@dblnz maybe you could take a look at this one since you reviewed the old pr this replaces? |

The guest reports a trace batch by setting
r8to theTraceBatchmarker, with the buffer pointer inr9and its length inr10. Nothing clearedr8, and the host checked it on every exit. TheHaltafter each flush re-read the same buffer, so every span in it was exported twice (#1230).On
mainthis is hidden by accident. #1794 and #1891 added code between the last flush and the halt that happens to overwriter8. Any change there can bring the duplicates back.This PR makes the guest clear
r8after each OUT that carries a batch, and makes the host check for a batch only on OUT exits. Either half prevents the duplicates alone. Checked by counting exported spans before #1891 and on v0.12.0. No automated test, because CI does not build trace-enabled guests.Replaces #1619. Closes #1230