Skip to content

Gdb support for mshv guests #327

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

Merged
merged 18 commits into from
Mar 27, 2025
Merged

Conversation

dblnz
Copy link
Contributor

@dblnz dblnz commented Mar 5, 2025

This PR address the #220 issue.
Additionally, the first 7 commits refactor the existing guest debugging code and moves code from kvm.rs to a new file that is to contain the hypervisor specific debugging functionality.

@dblnz dblnz added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Mar 5, 2025
@dblnz dblnz force-pushed the gdb-support-mshv branch from e82833e to 0119675 Compare March 5, 2025 16:49
@ludfjig
Copy link
Contributor

ludfjig commented Mar 5, 2025

This looks great! I noticed the how-to-debug-a-hyperlgiht-guest.md only mentions KVM guests, so we might want to update that doc. Additionally we have a debugging-hyperlgiht.md doc that has no mention of gdb debugging at all. Perhaps we could add a link from that doc to how-to-debug-a-hyperlight-guest.md

@dblnz
Copy link
Contributor Author

dblnz commented Mar 5, 2025

This looks great! I noticed the how-to-debug-a-hyperlgiht-guest.md only mentions KVM guests, so we might want to update that doc. Additionally we have a debugging-hyperlgiht.md doc that has no mention of gdb debugging at all. Perhaps we could add a link from that doc to how-to-debug-a-hyperlight-guest.md

Thanks, I forgot about the documentation.
I'll add another commit that addresses the documentation

ludfjig
ludfjig previously approved these changes Mar 7, 2025
Copy link
Contributor

@ludfjig ludfjig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! It would be good if @syntactically could review as well

@dblnz dblnz force-pushed the gdb-support-mshv branch 2 times, most recently from 4df565e to ebdbe13 Compare March 12, 2025 14:00
@dblnz dblnz requested a review from syntactically March 13, 2025 10:08
ludfjig
ludfjig previously approved these changes Mar 14, 2025
simongdavies
simongdavies previously approved these changes Mar 17, 2025
Copy link
Contributor

@simongdavies simongdavies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor questions/suggestions but otherwise this LGTM

dblnz added 17 commits March 19, 2025 23:50
- this is done in preparation of accomodating support for other hypervisors
which means some of the functionality whould be common.
- moving the debug code to a separate file can enable us to
group common behavior in traits

Signed-off-by: Doru Blânzeanu <[email protected]>
- also add a trait that contains all the needed methods for interacting
with a vCPU

Signed-off-by: Doru Blânzeanu <[email protected]>
… file

- add trait to define common behavior to be used by other hypervisors
  later

Signed-off-by: Doru Blânzeanu <[email protected]>
- it can be done using the generic way to add hw breakpoints
- also remove the entry point breakpoint after the vCPU stops to
avoid hanging there

Signed-off-by: Doru Blânzeanu <[email protected]>
- verify the debug registers that report what kind of exception was triggered
- in case there is an unknown reason, report it as a SwBp so that the gdb
client can inspect what happened

Signed-off-by: Doru Blânzeanu <[email protected]>
- use checked_sub to avoid issues from addresses that could cause
underflow

Signed-off-by: Doru Blânzeanu <[email protected]>
- change gdb commands in test to be usable with older gdb versions
- change Justfile to provide mshv3 feature
- change gdb test to invoke cargo test with correct features for mshv

Signed-off-by: Doru Blânzeanu <[email protected]>
Copy link
Contributor

@danbugs danbugs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM–great work, Doru!

Copy link
Contributor

@syntactically syntactically left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Great work, especially given how little documentation there is for the HV interfaces, @dblnz !

@dblnz dblnz merged commit 54ffc0d into hyperlight-dev:main Mar 27, 2025
24 checks passed
@dblnz dblnz deleted the gdb-support-mshv branch March 27, 2025 15:19
@dblnz dblnz mentioned this pull request May 2, 2025
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.

5 participants