2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20 #ifndef __VMX_LOWLEVEL_H__
21 #define __VMX_LOWLEVEL_H__
27 #define VMX_FAIL_INVALID 1
28 #define VMX_FAIL_VALID 2
31 #define VMWRITE_OP ".byte 0x0f,0x79,0xc1;" /* [eax],[ecx] */
32 #define VMREAD_OP ".byte 0x0f,0x78,0xc1;" /* [eax],[ecx] */
34 #define VMXON_OP ".byte 0xf3,0x0f,0xc7,0x30;" /* [eax] */
37 static int inline v3_enable_vmx(addr_t host_state) {
39 __asm__ __volatile__ (
43 : "a"(host_state), "0"(ret)
58 static int inline vmcs_write(addr_t vmcs_index, addr_t value) {
62 __asm__ __volatile__ (
64 "seteb %0;" // fail valid (ZF=1)
65 "setnaeb %1;" // fail invalid (CF=1)
66 : "=q"(ret_valid), "=q"(ret_invalid)
67 : "a"(vmcs_index), "c"(&value), "0"(ret_valid), "1"(ret_invalid)
72 return VMX_FAIL_VALID;
73 } else if (ret_invalid) {
74 return VMX_FAIL_INVALID;
82 static int inline vmcs_read(addr_t vmcs_index, void * dst, int len) {
87 __asm__ __volatile__ (
89 "seteb %0;" // fail valid (ZF=1)
90 "setnaeb %1;" // fail invalid (CF=1)
91 : "=q"(ret_valid), "=q"(ret_invalid), "=c"(val)
92 : "a"(vmcs_index), "0"(ret_valid), "1"(ret_invalid)
97 return VMX_FAIL_VALID;
98 } else if (ret_invalid) {
99 return VMX_FAIL_INVALID;