-
Notifications
You must be signed in to change notification settings - Fork 142
Add ability to debug additional registers via gdb #817
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
base: main
Are you sure you want to change the base?
Add ability to debug additional registers via gdb #817
Conversation
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for improving the debugging experience. I left some small comments here and there.
@@ -193,6 +194,31 @@ impl GuestDebug for KvmDebug { | |||
regs.rip = vcpu_regs.rip; | |||
regs.rflags = vcpu_regs.rflags; | |||
|
|||
// Read XMM registers from FPU state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Read XMM registers from FPU state | |
// Read XMM registers from FPU state |
match vcpu_fd.get_xsave() { | ||
Ok(xsave) => { | ||
regs.mxcsr = xsave.region[6]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -16,6 +16,7 @@ limitations under the License. | |||
|
|||
use std::collections::HashMap; | |||
|
|||
use gdbstub_arch::msp430::reg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not needed, right?
@@ -258,6 +270,8 @@ impl GuestDebug for MshvDebug { | |||
|
|||
rip: regs.rip, | |||
rflags: regs.rflags, | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -258,6 +270,8 @@ impl GuestDebug for MshvDebug { | |||
|
|||
rip: regs.rip, | |||
rflags: regs.rflags, | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -591,6 +591,9 @@ impl Hypervisor for KVMDriver { | |||
mxcsr: MXCSR_DEFAULT, | |||
..Default::default() // zero out the rest | |||
}; | |||
|
|||
// note kvm set_fpu doesn't actually set or read the mxcsr value | |||
// https://elixir.bootlin.com/linux/v6.16/source/arch/x86/kvm/x86.c#L12229 | |||
self.vcpu_fd.set_fpu(&fpu)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How could we change the code to set/read the mxcsr value?
This pull request adds support for reading and writing XMM and MXCSR registers in the GDB debug interface for all supported hypervisors (KVM, MSHV, and WHVP). It introduces new fields to the register structures to hold these values and implements the necessary logic to fetch and store them using each hypervisor's API.
Register structure updates:
xmm: [u128; 16]
andmxcsr: u32
fields to theX86_64Regs
struct to store XMM registers and MXCSR control state.Todo: