File tree Expand file tree Collapse file tree 4 files changed +13
-11
lines changed
src/hyperlight_host/src/hypervisor Expand file tree Collapse file tree 4 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ Hyperlight provides a mechanism to forcefully interrupt guest execution through
1010
1111### LinuxInterruptHandle State
1212
13- The ` LinuxInterruptHandle ` uses a packed atomic u64 to track execution state:
13+ The ` LinuxInterruptHandle ` uses a packed atomic u8 to track execution state:
1414
15- - ** state (AtomicU64 )** : Packs three bits:
15+ - ** state (AtomicU8 )** : Packs three bits:
1616 - ** Bit 2 (DEBUG_INTERRUPT_BIT)** : Set when debugger interrupt is requested (gdb feature only)
1717 - ** Bit 1 (RUNNING_BIT)** : Set when vCPU is actively running in guest mode
1818 - ** Bit 0 (CANCEL_BIT)** : Set when cancellation has been requested via ` kill() `
@@ -255,7 +255,7 @@ While the core cancellation mechanism follows the same conceptual model on Windo
255255
256256The ` WindowsInterruptHandle ` uses a simpler structure compared to Linux:
257257
258- - ** state (AtomicU64 )** : Packs three bits (RUNNING_BIT, CANCEL_BIT and DEBUG_INTERRUPT_BIT)
258+ - ** state (AtomicU8 )** : Packs three bits (RUNNING_BIT, CANCEL_BIT and DEBUG_INTERRUPT_BIT)
259259- ** partition_handle** : Windows Hyper-V partition handle for the VM
260260- ** dropped (AtomicBool)** : Set when the corresponding VM has been dropped
261261
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ extern crate mshv_bindings;
1818extern crate mshv_ioctls;
1919
2020use std:: fmt:: { Debug , Formatter } ;
21- use std:: sync:: atomic:: { AtomicBool , AtomicU64 } ;
21+ use std:: sync:: atomic:: { AtomicBool , AtomicU8 , AtomicU64 } ;
2222use std:: sync:: { Arc , Mutex } ;
2323
2424use log:: { LevelFilter , error} ;
@@ -375,7 +375,7 @@ impl HypervLinuxDriver {
375375 } ) ?;
376376
377377 let interrupt_handle: Arc < dyn InterruptHandleImpl > = Arc :: new ( LinuxInterruptHandle {
378- state : AtomicU64 :: new ( 0 ) ,
378+ state : AtomicU8 :: new ( 0 ) ,
379379 #[ cfg( all(
380380 target_arch = "x86_64" ,
381381 target_vendor = "unknown" ,
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ limitations under the License.
1515*/
1616
1717use std:: fmt:: Debug ;
18- use std:: sync:: atomic:: { AtomicBool , AtomicU64 } ;
18+ use std:: sync:: atomic:: { AtomicBool , AtomicU8 , AtomicU64 } ;
1919use std:: sync:: { Arc , Mutex } ;
2020
2121use kvm_bindings:: { kvm_fpu, kvm_regs, kvm_sregs, kvm_userspace_memory_region} ;
@@ -333,7 +333,7 @@ impl KVMDriver {
333333 let rsp_gp = GuestPtr :: try_from ( RawPtr :: from ( rsp) ) ?;
334334
335335 let interrupt_handle: Arc < dyn InterruptHandleImpl > = Arc :: new ( LinuxInterruptHandle {
336- state : AtomicU64 :: new ( 0 ) ,
336+ state : AtomicU8 :: new ( 0 ) ,
337337 #[ cfg( all(
338338 target_arch = "x86_64" ,
339339 target_vendor = "unknown" ,
Original file line number Diff line number Diff line change @@ -63,6 +63,8 @@ pub(crate) mod crashdump;
6363
6464use std:: fmt:: Debug ;
6565use std:: str:: FromStr ;
66+ #[ cfg( any( kvm, mshv3) ) ]
67+ use std:: sync:: atomic:: AtomicU8 ;
6668use std:: sync:: atomic:: { AtomicBool , AtomicU64 , Ordering } ;
6769use std:: sync:: { Arc , Mutex } ;
6870#[ cfg( any( kvm, mshv3) ) ]
@@ -588,7 +590,7 @@ pub(super) struct LinuxInterruptHandle {
588590 ///
589591 /// CANCEL_BIT persists across vcpu exits/re-entries within a single `VirtualCPU::run()` call
590592 /// (e.g., during host function calls), but is cleared at the start of each new `VirtualCPU::run()` call.
591- state : AtomicU64 ,
593+ state : AtomicU8 ,
592594
593595 /// Thread ID where the vcpu is running.
594596 ///
@@ -608,10 +610,10 @@ pub(super) struct LinuxInterruptHandle {
608610
609611#[ cfg( any( kvm, mshv3) ) ]
610612impl LinuxInterruptHandle {
611- const RUNNING_BIT : u64 = 1 << 1 ;
612- const CANCEL_BIT : u64 = 1 << 0 ;
613+ const RUNNING_BIT : u8 = 1 << 1 ;
614+ const CANCEL_BIT : u8 = 1 << 0 ;
613615 #[ cfg( gdb) ]
614- const DEBUG_INTERRUPT_BIT : u64 = 1 << 2 ;
616+ const DEBUG_INTERRUPT_BIT : u8 = 1 << 2 ;
615617
616618 /// Get the running, cancel and debug flags atomically.
617619 ///
You can’t perform that action at this time.
0 commit comments