@@ -31,7 +31,7 @@ use event_loop::event_loop_thread;
3131use gdbstub:: conn:: ConnectionExt ;
3232use gdbstub:: stub:: GdbStub ;
3333use gdbstub:: target:: TargetError ;
34- use hyperlight_common:: mem :: PAGE_SIZE ;
34+ use hyperlight_common:: PAGE_SIZE ;
3535#[ cfg( kvm) ]
3636pub ( crate ) use kvm_debug:: KvmDebug ;
3737#[ cfg( mshv) ]
@@ -40,7 +40,7 @@ use thiserror::Error;
4040use x86_64_target:: HyperlightSandboxTarget ;
4141
4242use crate :: hypervisor:: handlers:: DbgMemAccessHandlerCaller ;
43- use crate :: mem :: layout :: SandboxMemoryLayout ;
43+ use crate :: sandbox :: sandbox_builder :: BASE_ADDRESS ;
4444use crate :: { new_error, HyperlightError } ;
4545
4646/// Software Breakpoint size in memory
@@ -252,14 +252,16 @@ pub(crate) trait GuestDebug {
252252
253253 let read_len = std:: cmp:: min (
254254 data. len ( ) ,
255- ( PAGE_SIZE - ( gpa & ( PAGE_SIZE - 1 ) ) ) . try_into ( ) . unwrap ( ) ,
255+ ( PAGE_SIZE as u64 - ( gpa & ( PAGE_SIZE as u64 - 1 ) ) )
256+ . try_into ( )
257+ . unwrap ( ) ,
256258 ) ;
257259 let offset = ( gpa as usize )
258- . checked_sub ( SandboxMemoryLayout :: BASE_ADDRESS )
260+ . checked_sub ( BASE_ADDRESS )
259261 . ok_or_else ( || {
260262 log:: warn!(
261263 "gva=0x{:#X} causes subtract with underflow: \" gpa - BASE_ADDRESS={:#X}-{:#X}\" " ,
262- gva, gpa, SandboxMemoryLayout :: BASE_ADDRESS ) ;
264+ gva, gpa, BASE_ADDRESS ) ;
263265 HyperlightError :: TranslateGuestAddress ( gva)
264266 } ) ?;
265267
@@ -324,14 +326,16 @@ pub(crate) trait GuestDebug {
324326
325327 let write_len = std:: cmp:: min (
326328 data. len ( ) ,
327- ( PAGE_SIZE - ( gpa & ( PAGE_SIZE - 1 ) ) ) . try_into ( ) . unwrap ( ) ,
329+ ( PAGE_SIZE as u64 - ( gpa & ( PAGE_SIZE as u64 - 1 ) ) )
330+ . try_into ( )
331+ . unwrap ( ) ,
328332 ) ;
329333 let offset = ( gpa as usize )
330- . checked_sub ( SandboxMemoryLayout :: BASE_ADDRESS )
334+ . checked_sub ( BASE_ADDRESS )
331335 . ok_or_else ( || {
332336 log:: warn!(
333337 "gva=0x{:#X} causes subtract with underflow: \" gpa - BASE_ADDRESS={:#X}-{:#X}\" " ,
334- gva, gpa, SandboxMemoryLayout :: BASE_ADDRESS ) ;
338+ gva, gpa, BASE_ADDRESS ) ;
335339 HyperlightError :: TranslateGuestAddress ( gva)
336340 } ) ?;
337341
0 commit comments