20
20
21
21
pub struct Vm {
22
22
/// The VMCS (Virtual Machine Control Structure) for the VM.
23
- pub vmcs_region : Vmcs ,
23
+ pub vmcs_region : Box < Vmcs > ,
24
24
25
25
/// The guest's descriptor tables.
26
26
pub guest_descriptor : Descriptors ,
@@ -45,7 +45,7 @@ impl Vm {
45
45
pub fn new ( guest_registers : & GuestRegisters , shared_data : & mut SharedData ) -> Self {
46
46
log:: debug!( "Creating VM" ) ;
47
47
48
- let vmcs = Vmcs :: default ( ) ;
48
+ let vmcs_region = Box :: new ( Vmcs :: default ( ) ) ;
49
49
let guest_descriptor_table = Descriptors :: new_from_current ( ) ;
50
50
let host_descriptor_table = Descriptors :: new_for_host ( ) ;
51
51
let mut host_paging = unsafe { Box :: < PageTables > :: new_zeroed ( ) . assume_init ( ) } ;
@@ -57,7 +57,7 @@ impl Vm {
57
57
log:: debug!( "VM created" ) ;
58
58
59
59
Self {
60
- vmcs_region : vmcs ,
60
+ vmcs_region,
61
61
host_paging,
62
62
host_descriptor : host_descriptor_table,
63
63
guest_descriptor : guest_descriptor_table,
@@ -72,11 +72,11 @@ impl Vm {
72
72
self . vmcs_region . revision_id . set_bit ( 31 , false ) ;
73
73
74
74
// Clear the VMCS region.
75
- vmclear ( & mut self . vmcs_region as * mut _ as _ ) ;
75
+ vmclear ( self . vmcs_region . as_ref ( ) as * const _ as _ ) ;
76
76
log:: trace!( "VMCLEAR successful!" ) ;
77
77
78
78
// Load current VMCS pointer.
79
- vmptrld ( & mut self . vmcs_region as * mut _ as _ ) ;
79
+ vmptrld ( self . vmcs_region . as_ref ( ) as * const _ as _ ) ;
80
80
log:: trace!( "VMPTRLD successful!" ) ;
81
81
82
82
self . setup_vmcs ( ) ?;
0 commit comments