Skip to content

Abstractions over debug registers (DR0-DR7) #284

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

Closed
mkroening opened this issue Jul 19, 2021 · 3 comments · Fixed by #286
Closed

Abstractions over debug registers (DR0-DR7) #284

mkroening opened this issue Jul 19, 2021 · 3 comments · Fixed by #286

Comments

@mkroening
Copy link
Member

Working on the GDB support for uhyve, I wrote abstractions for the debug registers (DR0-DR7) to be able to easily configure hardware breakpoints. See a work-in-progress and undocumented version here.

Would such abstractions be in scope of this project?

@josephlr
Copy link
Contributor

I would think so, it seems like configuring the debug registers could work similar to our configuration of the control registers, see x86_64::registers::control.

I think if we added a x86_64::registers::debug module with similar abstractions.

  • We could have a way to read/write the VirtAddr for Dr0/Dr1/Dr2/Dr3
    • similar to what we currently do for Cr2
    • These should probably have a common type or trait
  • We would have Dr6/D6Flags and Dr7/Dr7Flags
    • similar to what we do for Cr0 and Cr4
    • Dr6 might make more sense to just have read and clear methods
    • Dr7 should have read and write methods

@josephlr
Copy link
Contributor

In addition to the AMD/Intel manuals, it might also be useful to look at how Linux does things

@mkroening
Copy link
Member Author

mkroening commented Jul 21, 2021

Thanks for the quick reply! I'll prepare a PR soon. 👍

Regarding Dr7Flags: DR7 has fields (not flags, R/W and LEN), which are two bits long. Using bitflags! for those wouldn't work nicely, would it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants