@@ -47,7 +47,9 @@ pub enum VcpuExit<'a> {
47
47
/// Corresponds to KVM_EXIT_HYPERCALL.
48
48
Hypercall ,
49
49
/// Corresponds to KVM_EXIT_DEBUG.
50
- Debug ,
50
+ ///
51
+ /// Provides architecture specific information for the debug event.
52
+ Debug ( kvm_debug_exit_arch ) ,
51
53
/// Corresponds to KVM_EXIT_HLT.
52
54
Hlt ,
53
55
/// Corresponds to KVM_EXIT_IRQ_WINDOW_OPEN.
@@ -1278,7 +1280,12 @@ impl VcpuFd {
1278
1280
}
1279
1281
}
1280
1282
KVM_EXIT_HYPERCALL => Ok ( VcpuExit :: Hypercall ) ,
1281
- KVM_EXIT_DEBUG => Ok ( VcpuExit :: Debug ) ,
1283
+ KVM_EXIT_DEBUG => {
1284
+ // Safe because the exit_reason (which comes from the kernel) told us which
1285
+ // union field to use.
1286
+ let debug = unsafe { run. __bindgen_anon_1 . debug } ;
1287
+ Ok ( VcpuExit :: Debug ( debug. arch ) )
1288
+ }
1282
1289
KVM_EXIT_HLT => Ok ( VcpuExit :: Hlt ) ,
1283
1290
KVM_EXIT_MMIO => {
1284
1291
// Safe because the exit_reason (which comes from the kernel) told us which
@@ -1932,7 +1939,7 @@ mod tests {
1932
1939
assert_eq ! ( data. len( ) , 1 ) ;
1933
1940
assert_eq ! ( data[ 0 ] , 0 ) ;
1934
1941
}
1935
- VcpuExit :: Debug => {
1942
+ VcpuExit :: Debug ( debug ) => {
1936
1943
if instr_idx == expected_rips. len ( ) - 1 {
1937
1944
// Disabling debugging/single-stepping
1938
1945
debug_struct. control = 0 ;
@@ -1942,6 +1949,13 @@ mod tests {
1942
1949
}
1943
1950
let vcpu_regs = vcpu_fd. get_regs ( ) . unwrap ( ) ;
1944
1951
assert_eq ! ( vcpu_regs. rip, expected_rips[ instr_idx] ) ;
1952
+ assert_eq ! ( debug. exception, 1 ) ;
1953
+ assert_eq ! ( debug. pc, expected_rips[ instr_idx] ) ;
1954
+ // Check first 15 bits of DR6
1955
+ let mask = ( 1 << 16 ) - 1 ;
1956
+ assert_eq ! ( debug. dr6 & mask, 0b100111111110000 ) ;
1957
+ // Bit 10 in DR7 is always 1
1958
+ assert_eq ! ( debug. dr7, 1 << 10 ) ;
1945
1959
instr_idx += 1 ;
1946
1960
}
1947
1961
VcpuExit :: Hlt => {
0 commit comments