Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. proc VMexec    
  2.    
  3.     ; проверить VMX_SUPPORT
  4.     mov rax, [VMX_SUPPORT]
  5.     and eax, BASE_TRUE
  6.     jnz @F
  7.    
  8.     ; pin-based
  9.     ; 0 - external-interrupt
  10.     ; 3 - NMI
  11.     ; 5 - virtual NMI
  12.     ; 6 - activate vmx-preemption timer
  13.    
  14.         mov ecx, IA32_VMX_PINBASED_CLTS
  15.     jmp VMexec1
  16.    
  17.     @@:
  18.         invoke DrawStringPos, 500, 50, addr basic_msr55
  19.        
  20.         mov ecx, IA32_VMX_TRUE_PINBASED_CLTS
  21.     VMexec1:
  22.         rdmsr
  23.         and eax, edx
  24.         mov dword [vm_mem.ctrl_vmx_pin], eax
  25.    
  26.    
  27.     ; проверить VMX_SUPPORT
  28.     mov rax, [VMX_SUPPORT]
  29.     and eax, BASE_TRUE
  30.     jnz @F
  31.  
  32.     ; proc-based
  33.     ; 2 - interrupt-window      21 - tpr shadow
  34.     ; 3 - tsc offset            22 - nmi-window
  35.     ; 7 - hlt                   23 - mov dr
  36.     ; 9 - invplg                24 - unconditional i/o
  37.     ; 10 - mwait                25 - use i/o bitmaps
  38.     ; 11 - rdpmc                27 - monitor trap flag
  39.     ; 12 - rdtsc                28 - use msr bitmaps
  40.     ; 15 - cr3-load             29 - monitor
  41.     ; 16 - cr3-store            30 - pause
  42.     ; 19 - cr8-load             31 - activate secondary controls
  43.     ; 20 - cr8-store
  44.    
  45.         mov ecx, IA32_VMX_PROCBASED_CLTS
  46.         jmp VMexec2
  47.     @@:
  48.         mov ecx, IA32_VMX_TRUE_PROCBASED_CLTS
  49.    
  50.     VMexec2:
  51.         rdmsr
  52.    
  53.     and eax, edx
  54.     ;; проверка secondary proc
  55.     bts edx, 31
  56.     jnc @F
  57.        
  58.         or eax, 1 shl 31
  59.     @@:
  60.         mov [vm_mem.ctrl_vmx_cpu], eax
  61.    
  62.    
  63.     bts edx, 31
  64.     jnc @F
  65.         invoke DrawStringPos, 20, 65, addr szSecondProcSupp
  66.         invoke VMexecSecondProc
  67.    
  68.     @@:
  69.    
  70.     ;; exception bitmap
  71.     ;; page-fault error-code mask
  72.     ;; page-fault error-code match
  73.     ;; cr3-target count
  74.     ;; tpr threshold
  75.    
  76.     ;; ple_gap
  77.     ;; ple_window
  78.    
  79.     ;; i/o bitmap a
  80.     ;; i/o bitmap b
  81.     ;; msr bitmap
  82.    
  83.     ;; executive-vmsc
  84.    
  85.     ;; tsc offset
  86.    
  87.     ;; virtual-apic addr
  88.    
  89.     ;; eptp
  90.     ;; 2:0 0-uncache, 6 - write-back
  91.     ;; 5:3 равно значение page-walk минус единица (page-walk - 1)
  92.    
  93.     ;; проверка EPTP
  94.     mov rax, [VMX_SUPPORT]
  95.     and eax, EPTP_TRUE
  96.     jz @F
  97.    
  98.         mov [vm_mem.ctrl_eptp_f], 60000h+11000b
  99.     @@:
  100.    
  101.     ret
  102. endp
  103.  
  104.  
  105. proc VMexecSecondProc
  106.     push rbx
  107.     ; 0 - virtualize apic
  108.     ; 1 - enable ept
  109.     ; 2 - descriptor table
  110.     ; 3 - enable rdtscp
  111.     ; 4 - virtualize x2apic
  112.     ; 5 - enable vpid
  113.     ; 6 - wbinvd
  114.     ; 7 - unrestricted guest
  115.     ; 10 - pause-loop
  116.    
  117.     mov ecx, IA32_VMX_PROCBASED_CLTS2       ;48bh
  118.     rdmsr
  119.    
  120.     mov ebx, edx   
  121.     and edx, 2
  122.     jz @F
  123.         invoke DrawStringPos, 20, 80, addr eptsupp
  124.         or [VMX_SUPPORT], 10b
  125.     @@:
  126.    
  127.     mov edx, ebx
  128.     and edx, 80h
  129.     jz @F
  130.         invoke DrawStringPos, 20, 95, addr szUnrestrict
  131.         or [VMX_SUPPORT], 100b
  132.     @@:
  133.    
  134.     mov edx, ebx
  135.     and edx, 20h
  136.     jz @F
  137.         invoke DrawStringPos, 20, 110, addr vpidsupp
  138.     @@:
  139.    
  140.     mov edx, ebx
  141.     and edx, 82h        ; 1 и 7 бит
  142.     or eax, edx
  143.     mov [vm_mem.ctrl_second_vmx_cpu], eax
  144.    
  145.     pop rbx
  146.     ret
  147. endp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement