From: Jack Lange Date: Fri, 27 Jul 2012 18:42:35 +0000 (-0400) Subject: enabled VMX exit hooks X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=3751dffc4cb29c0db743895f7b507862db1a675d;p=palacios.releases.git enabled VMX exit hooks --- diff --git a/palacios/include/palacios/vmx_exits.h b/palacios/include/palacios/vmx_exits.h new file mode 100644 index 0000000..8858f97 --- /dev/null +++ b/palacios/include/palacios/vmx_exits.h @@ -0,0 +1,34 @@ +/* + * 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) 2012, Jack Lange + * Copyright (c) 2012, 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_EXITS_H__ +#define __VMX_EXITS_H__ + + +#ifdef __V3VEE__ + +int v3_init_vmx_exits(struct v3_vm_info * vm); + + + +#endif + +#endif diff --git a/palacios/src/palacios/Makefile b/palacios/src/palacios/Makefile index 5cde6ea..6d14934 100644 --- a/palacios/src/palacios/Makefile +++ b/palacios/src/palacios/Makefile @@ -66,7 +66,8 @@ obj-$(V3_CONFIG_VMX) += vmx.o \ vmcs.o \ vmx_ctrl_regs.o \ vmx_assist.o \ - vmx_ept.o + vmx_ept.o \ + vmx_exits.o diff --git a/palacios/src/palacios/vm_guest.c b/palacios/src/palacios/vm_guest.c index d94d465..dc47a46 100644 --- a/palacios/src/palacios/vm_guest.c +++ b/palacios/src/palacios/vm_guest.c @@ -211,6 +211,7 @@ static int info_hcall(struct guest_info * core, uint_t hcall_id, void * priv_dat #include #include #include +#include #endif @@ -277,6 +278,7 @@ int v3_init_vm(struct v3_vm_info * vm) { case V3_VMX_EPT_UG_CPU: v3_init_vmx_io_map(vm); v3_init_vmx_msr_map(vm); + v3_init_vmx_exits(vm); break; #endif default: diff --git a/palacios/src/palacios/vmx_exits.c b/palacios/src/palacios/vmx_exits.c new file mode 100644 index 0000000..b3f5ad9 --- /dev/null +++ b/palacios/src/palacios/vmx_exits.c @@ -0,0 +1,78 @@ +/* + * 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) 2012, Jack Lange + * Copyright (c) 2012, 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". + */ + + +#include +#include +#include + + + +static int enable_exit(struct guest_info * core, v3_exit_type_t exit_type) { + vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA((vmcb_t *)(core->vmm_data)); + + switch (exit_type) { + + case V3_EXIT_RDTSC: + ctrl_area->instrs.RDTSC = 1; + break; + case V3_EXIT_RDTSCP: + ctrl_area->svm_instrs.RDTSCP = 1; + break; + + default: + PrintError("Unhandled Exit Type (%d)\n", exit_type); + return -1; + } + + return 0; +} + + +static int disable_exit(struct guest_info * core, v3_exit_type_t exit_type) { + vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA((vmcb_t *)(core->vmm_data)); + + switch (exit_type) { + + case V3_EXIT_RDTSC: + ctrl_area->instrs.RDTSC = 0; + break; + case V3_EXIT_RDTSCP: + ctrl_area->svm_instrs.RDTSCP = 0; + break; + + default: + PrintError("Unhandled Exit Type (%d)\n", exit_type); + return -1; + } + + return 0; + +} + + +int v3_init_vmx_exits(struct v3_vm_info * vm) { + + int ret = 0; + + ret |= v3_register_exit(vm, V3_EXIT_RDTSC, enable_exit, disable_exit); + ret |= v3_register_exit(vm, V3_EXIT_RDTSCP, enable_exit, disable_exit); + + return ret; +}