;*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
; Written and compiled with FASMW v1.67.3
; 2006-08-25 HyperVista
; Thanks to vid and locdelassembly for their help and guidance
;
; The purpose of this simple program is to determine
; if the box on which it is run supports Intel's VT-x
; virtualization.
;
; This program uses CPUID to determine if the CPU is Intel
; and if so, it determines if it supports Intel's VT-x
; extensions.  First, we use CPUID with 00H in EAX in order
; to retrieve the vendor identification string and then we
; test that string.  Next we use CPUID with 01H in EAX to
; retrieve the Extended Feature information returned in ECX.
; If Bit 5 in CL is set it indicates that the processor
; supports VT-x.
;
; While this program only prints a message indicating the
; processor does or doesn't support Intel's VT-x, this routine
; can be used to determine if VT-x is supported as a first
; step in a VMM or hypervisor installation program or as a
; portion of a survey tool.
;
;*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

org 100h

jmp start

; Print Routine
print:
	mov ah,9h
	int 21h
	ret

print_wait:
	call print
	xor ax,ax   ; pause screen until user hits any key
	int 16h
	jmp exit

; Message Text
no_msg db 'Genuine Intel, but no VT-x support!  Press any key to continue....', 13, 10, '$'
yes_msg db 'Genuine Intel and VT-x IS supported!  Please press any key to continue....', 13, 10, '$'
not_intel db 'Non-Intel Processor.  VT-x in NOT supported.  Please press any key to continue....', 13, 10, '$'

start:
	;  Check to see if the processor is Intel
	mov ax,00h
	CPUID
	cmp ebx,'Genu'	  ; partial Intel signature placed in EBX
	jz Is_Intel	  ; if not an Intel chip, we're done
	mov dx,not_intel
	call print_wait

	Is_Intel:
	; Check to see if VT-x is supported
	   mov ax,01h
	   CPUID
	   and cl,20h	    ; ECX bit 5 bit mask test
	   jnz VTX_Supported
	   mov dx,no_msg
	   call print_wait

       ; VTX supported - we only print message now
       ; This is where we will launch VMM or hypervisor later
       VTX_Supported:
	    mov dx,yes_msg
	    call print_wait

	; Program End
	exit:
	   mov ax,4C00h   ; hand back control to the OS
	   int 21h
