Skip to content

[WIP] Enable guest tracing #695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft

Conversation

dblnz
Copy link
Contributor

@dblnz dblnz commented Jul 7, 2025

Description

This PR update the work @syntactically has done in #103 to latest main and extends it to support tracing the guest for performance.

How it works

It defines a TraceBuffer in the guest that holds TraceRecords. These records are sent to the host using an Out instruction and providing the pointer to an array of TraceRecords. The host accesses the guest memory, reads these records and writes them to the trace file.

TODO

  • For now, the timestamp of the traces is not calculated correctly. It needs to be calculated relative to the start of the guest and base of on the invariant TSC frequency.
  • Check the features introduced in the crates to ensure consistency
  • Expand dump_trace functionality to visualize the traces

syntactically and others added 8 commits July 7, 2025 18:15
In the future, the outb handler will need to take a Hypervisor
instance in order to be able to access register and memory state of
the VM, so it doesn't make sense for these interfaces to be more
public than the `Hypervisor` trait.  Nobody outside of Hyperlight
seems to use these at the moment, so it's probably simplest to
restrict these to `pub(crate)`.

Signed-off-by: Lucy Menon <[email protected]>
This adds (unused) support for creating trace files for sandboxes and
passing them around to relevant sandbox event handler code. This will
be used for collecting debug trace and profiling information.

Signed-off-by: Lucy Menon <[email protected]>
Signed-off-by: Doru Blânzeanu <[email protected]>
This will be useful in the near future, when it will allow
transforming the exe_info into unwind information without an extra
copy.

Signed-off-by: Lucy Menon <[email protected]>
This adds a new interface which tracing code can use to request the
values of registers from the hypervisor supervising a sandbox.

Signed-off-by: Lucy Menon <[email protected]>
This allows for producing profiles of memory usage.

Signed-off-by: Lucy Menon <[email protected]>
@dblnz dblnz added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Jul 7, 2025
dblnz added 4 commits July 7, 2025 19:47
- Adds `hyperlight-guest-tracing` and `hyperlight-guest-tracing-macro` for
guests to be able to submit traces on functions or as statements.
- Adds handling of `OutBAction::TraceRecord` in host, that will be handled later
- The `hyperlight-guest-tracing` defines a Trace buffer that caches the traces
until it is full at which time it sends them to the host by calling outb
"

Signed-off-by: Doru Blânzeanu <[email protected]>
- Supports only list_frames for now

Signed-off-by: Doru Blânzeanu <[email protected]>
Signed-off-by: Doru Blânzeanu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants