@@ -24,7 +24,7 @@ use super::VmxExitInfo;
2424use super :: as_axerr;
2525use super :: definitions:: VmxExitReason ;
2626use super :: read_vmcs_revision_id;
27- use super :: structs:: { EPTP_LIST_SIZE , EPTPointer , EptpList , IOBitmap , MsrBitmap , VmxRegion } ;
27+ use super :: structs:: { EptpList , IOBitmap , MsrBitmap , VmxRegion } ;
2828use super :: vmcs:: {
2929 self , VmcsControl32 , VmcsControl64 , VmcsControlNW , VmcsGuest16 , VmcsGuest32 , VmcsGuest64 ,
3030 VmcsGuestNW , VmcsHost16 , VmcsHost32 , VmcsHost64 , VmcsHostNW , interrupt_exit_info,
@@ -755,11 +755,6 @@ impl<H: AxVCpuHal> VmxVcpu<H> {
755755 // Bit 0: EPTP switching
756756 VmcsControl64 :: VM_FUNCTION_CONTROLS . write ( 0b1 ) ?;
757757
758- assert ! (
759- self . eptp_list. entry_is_set( 0 ) ,
760- "The First EPTP list entry must be set as initial EPTP."
761- ) ;
762-
763758 VmcsControl64 :: EPTP_LIST_ADDR . write ( self . eptp_list . phys_addr ( ) . as_usize ( ) as _ ) ?;
764759
765760 // Pass-through exceptions (except #UD(6)), don't use I/O bitmap, set MSR bitmaps.
@@ -1369,7 +1364,6 @@ impl<H: AxVCpuHal> AxArchVCpu for VmxVcpu<H> {
13691364
13701365 fn set_ept_root ( & mut self , ept_root : HostPhysAddr ) -> AxResult {
13711366 self . ept_root = Some ( ept_root) ;
1372- self . append_eptp_list ( 0 , ept_root) ?;
13731367 Ok ( ( ) )
13741368 }
13751369
@@ -1383,10 +1377,6 @@ impl<H: AxVCpuHal> AxArchVCpu for VmxVcpu<H> {
13831377 }
13841378
13851379 fn run ( & mut self ) -> AxResult < AxVCpuExitReason > {
1386- if self . id == 3 {
1387- warn ! ( "Instance vcpu run {:#x?}" , self ) ;
1388- }
1389-
13901380 match self . inner_run ( ) {
13911381 Some ( exit_info) => Ok ( if exit_info. entry_failure {
13921382 match exit_info. exit_reason {
@@ -1399,6 +1389,7 @@ impl<H: AxVCpuHal> AxArchVCpu for VmxVcpu<H> {
13991389 } ;
14001390
14011391 warn ! ( "VMX entry failure: {:#x?}" , exit_info) ;
1392+ warn ! ( "VCpu {:#x?}" , self ) ;
14021393
14031394 AxVCpuExitReason :: FailEntry {
14041395 // Todo: get `hardware_entry_failure_reason` somehow.
@@ -1576,44 +1567,11 @@ impl<H: AxVCpuHal> AxVcpuAccessGuestState for VmxVcpu<H> {
15761567 self . guest_page_table_query ( gva) . ok ( )
15771568 }
15781569
1579- fn append_eptp_list ( & mut self , idx : usize , eptp : HostPhysAddr ) -> AxResult {
1580- if idx >= EPTP_LIST_SIZE {
1581- return ax_err ! ( InvalidInput ) ;
1582- }
1583-
1584- if self . eptp_list . entry_is_set ( idx) {
1585- return ax_err ! ( InvalidInput ) ;
1586- }
1587-
1588- self . eptp_list
1589- . set_entry ( idx, EPTPointer :: from_table_phys ( eptp) ) ;
1590- Ok ( ( ) )
1570+ fn current_ept_root ( & self ) -> HostPhysAddr {
1571+ vmcs:: get_ept_pointer ( )
15911572 }
15921573
1593- fn remove_eptp_list_entry ( & mut self , idx : usize ) -> AxResult {
1594- if idx >= EPTP_LIST_SIZE {
1595- return ax_err ! ( InvalidInput ) ;
1596- }
1597- if !self . eptp_list . entry_is_set ( idx) {
1598- return ax_err ! ( InvalidInput ) ;
1599- }
1600-
1601- self . eptp_list . remove_entry ( idx) ;
1602-
1603- Ok ( ( ) )
1604- }
1605-
1606- fn get_eptp_list_entry ( & self , idx : usize ) -> AxResult < HostPhysAddr > {
1607- if idx >= EPTP_LIST_SIZE {
1608- return ax_err ! ( InvalidInput ) ;
1609- }
1610- if !self . eptp_list . entry_is_set ( idx) {
1611- return ax_err ! ( InvalidInput ) ;
1612- }
1613- let entry = self . eptp_list . get_entry ( idx) ;
1614-
1615- Ok ( HostPhysAddr :: from_usize ( memory_addr:: align_down_4k (
1616- entry. bits ( ) as _ ,
1617- ) ) )
1574+ fn eptp_list_region ( & self ) -> HostPhysAddr {
1575+ self . eptp_list . phys_addr ( )
16181576 }
16191577}
0 commit comments