X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmx_lowlevel.asm;h=94f743254a11a1e84163c42efc4e877cbc5a2fe9;hp=1916b557917bcdb85ae282c8840e57dcc4c3b900;hb=3373500a962dba67f09d120d7db3c2ea1d4beee2;hpb=56f8088296ee4116a4811a2f4f843edd80a7748d diff --git a/palacios/src/palacios/vmx_lowlevel.asm b/palacios/src/palacios/vmx_lowlevel.asm index 1916b55..94f7432 100644 --- a/palacios/src/palacios/vmx_lowlevel.asm +++ b/palacios/src/palacios/vmx_lowlevel.asm @@ -1,8 +1,22 @@ ; -*- fundamental -*- - -;; (c) 2008, Jack Lange -;; (c) 2008, The V3VEE Project - +;; +;; This file is part of the Palacios Virtual Machine Monitor developed +;; by the V3VEE Project with funding from the United States National +;; Science Foundation and the Department of Energy. +;; +;; The V3VEE Project is a joint project between Northwestern University +;; and the University of New Mexico. You can find out more at +;; http://www.v3vee.org +;; +;; Copyright (c) 2008, Jack Lange +;; Copyright (c) 2008, The V3VEE Project +;; All rights reserved. +;; +;; Author: Jack Lange +;; +;; This is free software. You are permitted to use, +;; redistribute, and modify it as specified in the file "V3VEE_LICENSE". +;; %ifndef VMX_ASM %define VMX_ASM @@ -40,150 +54,6 @@ EXPORT SAFE_VM_LAUNCH EXPORT Init_VMCS_HostState EXPORT Init_VMCS_GuestState -; -; Enable_VMX - Turn on VMX -; -align 8 -Enable_VMX: - push ebp - mov ebp, esp - push ebx - mov ebx, cr4 - or ebx, dword 0x00002000 - mov cr4, ebx - mov ebx, cr0 - or ebx, dword 0x80000021 - mov cr0, ebx - vmxon [ebp+8] - pop ebx - pop ebp - mov eax, VMX_SUCCESS - jnc .return - mov eax, VMX_FAIL_INVALID -.return - ret - - -; -; VMREAD - read a value from a VMCS -; -align 8 -VMCS_READ: - push ebp - mov ebp, esp - push ecx - push ebx - - mov ecx, [ebp + 8] - mov ebx,[ebp + 12] -; lea ebx, ebp - vmread [ebx], ecx - - pop ebx - pop ecx - pop ebp - jz .error_code - jc .error - - mov eax, VMX_SUCCESS - jmp .return -.error - mov eax, VMX_FAIL_INVALID - jmp .return -.error_code - mov eax, VMX_FAIL_VALID -.return - ret - -; -; VMWRITE - write a value to a VMCS -align 8 -VMCS_WRITE: - push ebp - mov ebp, esp - push ebx - - mov eax, [ebp + 8] - mov ebx, [ebp + 12] - vmwrite eax, [ebx] - - pop ebx - pop ebp - jz .error_code - jc .error - - mov eax, VMX_SUCCESS - jmp .return -.error - mov eax, VMX_FAIL_INVALID - jmp .return -.error_code - mov eax, VMX_FAIL_VALID -.return - ret - -; -; VMCLEAR - Initializes a VMCS -; -align 8 -VMCS_CLEAR: - vmclear [esp+4] - jz .error_code - jc .error - - mov eax, VMX_SUCCESS - jmp .return -.error - mov eax, VMX_FAIL_INVALID - jmp .return -.error_code - mov eax, VMX_FAIL_VALID -.return - ret - - - -; -; VMCS_LOAD - load a VMCS -; -align 8 -VMCS_LOAD: - vmptrld [esp+4] - jz .error_code - jc .error - - mov eax, VMX_SUCCESS - jmp .return -.error - mov eax, VMX_FAIL_INVALID - jmp .return -.error_code - mov eax, VMX_FAIL_VALID -.return - ret - - - -; -; VMCS_STORE - Store a VMCS -; -align 8 -VMCS_STORE: - mov eax, [esp+4] - vmptrst [eax] - jz .error_code - jc .error - - mov eax, VMX_SUCCESS - jmp .return -.error - mov eax, VMX_FAIL_INVALID - jmp .return -.error_code - mov eax, VMX_FAIL_VALID -.return - ret - ; ; VMCS_LAUNCH @@ -741,7 +611,18 @@ InitHostSelectors: jz .error_code jc .error - mov ebx, VMCS_HOST_SS_SELECTOR + mov ebx, VMCS_HOST_SS_SELECTOR; + PrintDebug("VMX revision: 0x%p\n", (void*)vmxon_ptr); + + if (v3_enable_vmx(vmxon_ptr) == 0) { + PrintDebug("VMX Enabled\n"); + } else { + PrintError("VMX initialization failure\n"); + return; + } + + + mov eax, ss vmwrite ebx, eax jz .error_code