@@ -46,6 +46,7 @@ use thiserror::Error;
4646use x86_64_target:: HyperlightSandboxTarget ;
4747
4848use super :: InterruptHandle ;
49+ use crate :: hypervisor:: regs:: CommonRegisters ;
4950use crate :: mem:: layout:: SandboxMemoryLayout ;
5051use crate :: mem:: mgr:: SandboxMemoryManager ;
5152use crate :: mem:: shared_mem:: HostSharedMemory ;
@@ -88,29 +89,6 @@ impl From<GdbTargetError> for TargetError<GdbTargetError> {
8889 }
8990}
9091
91- /// Struct that contains the x86_64 core registers
92- #[ derive( Debug , Default ) ]
93- pub ( crate ) struct X86_64Regs {
94- pub ( crate ) rax : u64 ,
95- pub ( crate ) rbx : u64 ,
96- pub ( crate ) rcx : u64 ,
97- pub ( crate ) rdx : u64 ,
98- pub ( crate ) rsi : u64 ,
99- pub ( crate ) rdi : u64 ,
100- pub ( crate ) rbp : u64 ,
101- pub ( crate ) rsp : u64 ,
102- pub ( crate ) r8 : u64 ,
103- pub ( crate ) r9 : u64 ,
104- pub ( crate ) r10 : u64 ,
105- pub ( crate ) r11 : u64 ,
106- pub ( crate ) r12 : u64 ,
107- pub ( crate ) r13 : u64 ,
108- pub ( crate ) r14 : u64 ,
109- pub ( crate ) r15 : u64 ,
110- pub ( crate ) rip : u64 ,
111- pub ( crate ) rflags : u64 ,
112- }
113-
11492/// Defines the possible reasons for which a vCPU can be stopped when debugging
11593#[ derive( Debug ) ]
11694pub enum VcpuStopReason {
@@ -140,7 +118,7 @@ pub(crate) enum DebugMsg {
140118 RemoveSwBreakpoint ( u64 ) ,
141119 Step ,
142120 WriteAddr ( u64 , Vec < u8 > ) ,
143- WriteRegisters ( X86_64Regs ) ,
121+ WriteRegisters ( CommonRegisters ) ,
144122}
145123
146124/// Enumerates the possible responses that a hypervisor can provide to a debugger
@@ -155,7 +133,7 @@ pub(crate) enum DebugResponse {
155133 NotAllowed ,
156134 InterruptHandle ( Arc < dyn InterruptHandle > ) ,
157135 ReadAddr ( Vec < u8 > ) ,
158- ReadRegisters ( X86_64Regs ) ,
136+ ReadRegisters ( CommonRegisters ) ,
159137 RemoveHwBreakpoint ( bool ) ,
160138 RemoveSwBreakpoint ( bool ) ,
161139 Step ,
@@ -183,13 +161,13 @@ pub(super) trait GuestDebug {
183161 fn delete_sw_breakpoint_data ( & mut self , addr : & u64 ) -> Option < [ u8 ; 1 ] > ;
184162
185163 /// Read registers
186- fn read_regs ( & self , vcpu_fd : & Self :: Vcpu , regs : & mut X86_64Regs ) -> crate :: Result < ( ) > ;
164+ fn read_regs ( & self , vcpu_fd : & Self :: Vcpu , regs : & mut CommonRegisters ) -> crate :: Result < ( ) > ;
187165 /// Enables or disables stepping and sets the vCPU debug configuration
188166 fn set_single_step ( & mut self , vcpu_fd : & Self :: Vcpu , enable : bool ) -> crate :: Result < ( ) > ;
189167 /// Translates the guest address to physical address
190168 fn translate_gva ( & self , vcpu_fd : & Self :: Vcpu , gva : u64 ) -> crate :: Result < u64 > ;
191169 /// Write registers
192- fn write_regs ( & self , vcpu_fd : & Self :: Vcpu , regs : & X86_64Regs ) -> crate :: Result < ( ) > ;
170+ fn write_regs ( & self , vcpu_fd : & Self :: Vcpu , regs : & CommonRegisters ) -> crate :: Result < ( ) > ;
193171
194172 /// Adds hardware breakpoint
195173 fn add_hw_breakpoint ( & mut self , vcpu_fd : & Self :: Vcpu , addr : u64 ) -> crate :: Result < ( ) > {
@@ -449,7 +427,7 @@ mod tests {
449427 let res = gdb_conn. try_recv ( ) ;
450428 assert ! ( res. is_err( ) ) ;
451429
452- let res = hyp_conn. send ( DebugResponse :: ReadRegisters ( X86_64Regs :: default ( ) ) ) ;
430+ let res = hyp_conn. send ( DebugResponse :: ReadRegisters ( Default :: default ( ) ) ) ;
453431 assert ! ( res. is_ok( ) ) ;
454432
455433 let res = gdb_conn. recv ( ) ;
0 commit comments