@@ -2,14 +2,14 @@ use alloc::collections::VecDeque;
2
2
use alloc:: vec:: Vec ;
3
3
use core:: fmt:: { Debug , Formatter , Result } ;
4
4
use core:: { arch:: naked_asm, mem:: size_of} ;
5
- use x86_64:: VirtAddr ;
6
5
7
6
use bit_field:: BitField ;
8
7
use raw_cpuid:: CpuId ;
9
8
use x86:: bits64:: vmx;
10
9
use x86:: controlregs:: Xcr0 ;
11
10
use x86:: dtables:: { self , DescriptorTablePointer } ;
12
11
use x86:: segmentation:: SegmentSelector ;
12
+ use x86_64:: VirtAddr ;
13
13
use x86_64:: registers:: control:: { Cr0 , Cr0Flags , Cr3 , Cr4 , Cr4Flags , EferFlags } ;
14
14
15
15
use page_table_entry:: x86_64:: X64PTE ;
@@ -27,7 +27,8 @@ use super::read_vmcs_revision_id;
27
27
use super :: structs:: { EptpList , IOBitmap , MsrBitmap , VmxRegion } ;
28
28
use super :: vmcs:: {
29
29
self , VmcsControl32 , VmcsControl64 , VmcsControlNW , VmcsGuest16 , VmcsGuest32 , VmcsGuest64 ,
30
- VmcsGuestNW , VmcsHost16 , VmcsHost32 , VmcsHost64 , VmcsHostNW , interrupt_exit_info,
30
+ VmcsGuestNW , VmcsHost16 , VmcsHost32 , VmcsHost64 , VmcsHostNW , exit_qualification,
31
+ interrupt_exit_info,
31
32
} ;
32
33
use crate :: LinuxContext ;
33
34
use crate :: page_table:: GuestPageTable64 ;
@@ -363,7 +364,7 @@ impl<H: AxVCpuHal> VmxVcpu<H> {
363
364
364
365
pub fn decode_instruction ( & self , rip : GuestVirtAddr , instr_len : usize ) -> AxResult {
365
366
use alloc:: string:: String ;
366
- use iced_x86:: { Decoder , DecoderOptions , Formatter , IntelFormatter , MasmFormatter } ;
367
+ use iced_x86:: { Decoder , DecoderOptions , Formatter , IntelFormatter } ;
367
368
368
369
let bytes = self . read_guest_memory ( rip, instr_len) ?;
369
370
let mut decoder = Decoder :: with_ip (
@@ -373,21 +374,11 @@ impl<H: AxVCpuHal> VmxVcpu<H> {
373
374
DecoderOptions :: NONE ,
374
375
) ;
375
376
let instr = decoder. decode ( ) ;
376
-
377
- debug ! ( "Decoded instruction: {:#x?}" , instr) ;
378
-
379
377
let mut output = String :: new ( ) ;
380
378
let mut formattor = IntelFormatter :: new ( ) ;
381
379
formattor. format ( & instr, & mut output) ;
382
380
383
- debug ! ( "Decoded instruction Intel formatter: {}" , output) ;
384
-
385
- let mut output = String :: new ( ) ;
386
- let mut formattor = MasmFormatter :: new ( ) ;
387
- formattor. format ( & instr, & mut output) ;
388
-
389
- debug ! ( "Decoded instruction MasmFormatter: {}" , output) ;
390
-
381
+ debug ! ( "Decoded instruction @Intel formatter: {}" , output) ;
391
382
Ok ( ( ) )
392
383
}
393
384
}
@@ -546,11 +537,6 @@ impl<H: AxVCpuHal> VmxVcpu<H> {
546
537
} } ;
547
538
}
548
539
549
- debug ! (
550
- "setup_vmcs_guest_from_ctx: CS access rights: {:?}" ,
551
- linux. cs. access_rights
552
- ) ;
553
-
554
540
set_guest_segment ! ( linux. es, ES ) ;
555
541
set_guest_segment ! ( linux. cs, CS ) ;
556
542
set_guest_segment ! ( linux. ss, SS ) ;
@@ -1356,7 +1342,7 @@ impl<H: AxVCpuHal> AxArchVCpu for VmxVcpu<H> {
1356
1342
}
1357
1343
1358
1344
fn load_context ( & self , config : & mut Self :: HostContext ) -> AxResult {
1359
- info ! ( "Loading context {:#x?}" , self ) ;
1345
+ // info!("Loading context {:#x?}", self);
1360
1346
1361
1347
self . load_vmcs_guest ( config) ?;
1362
1348
Ok ( ( ) )
@@ -1393,7 +1379,10 @@ impl<H: AxVCpuHal> AxArchVCpu for VmxVcpu<H> {
1393
1379
}
1394
1380
} ;
1395
1381
1382
+ let exit_qualification = exit_qualification ( ) ?;
1383
+
1396
1384
warn ! ( "VMX entry failure: {:#x?}" , exit_info) ;
1385
+ warn ! ( "Exit qualification: {:#x?}" , exit_qualification) ;
1397
1386
warn ! ( "VCpu {:#x?}" , self ) ;
1398
1387
1399
1388
AxVCpuExitReason :: FailEntry {
@@ -1461,13 +1450,8 @@ impl<H: AxVCpuHal> AxArchVCpu for VmxVcpu<H> {
1461
1450
}
1462
1451
}
1463
1452
}
1464
- VmxExitReason :: EPT_VIOLATION | VmxExitReason :: TRIPLE_FAULT => {
1453
+ VmxExitReason :: EPT_VIOLATION => {
1465
1454
let ept_info = self . nested_page_fault_info ( ) ?;
1466
-
1467
- warn ! ( "VMX EPT-Exit: {:#x?} of {:#x?}" , ept_info, exit_info) ;
1468
-
1469
- warn ! ( "Vcpu {:#x?}" , self ) ;
1470
-
1471
1455
self . decode_instruction (
1472
1456
GuestVirtAddr :: from_usize ( exit_info. guest_rip ) ,
1473
1457
exit_info. exit_instruction_length as _ ,
@@ -1478,6 +1462,11 @@ impl<H: AxVCpuHal> AxArchVCpu for VmxVcpu<H> {
1478
1462
access_flags : ept_info. access_flags ,
1479
1463
}
1480
1464
}
1465
+ VmxExitReason :: TRIPLE_FAULT => {
1466
+ error ! ( "VMX triple fault: {:#x?}" , exit_info) ;
1467
+ error ! ( "VCpu {:#x?}" , self ) ;
1468
+ AxVCpuExitReason :: Halt
1469
+ }
1481
1470
_ => {
1482
1471
warn ! ( "VMX unsupported VM-Exit: {:#x?}" , exit_info) ;
1483
1472
warn ! ( "VCpu {:#x?}" , self ) ;
0 commit comments