github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/vmexit/vmexit_ept.c (about) 1 /* 2 * Copyright (c) 2013 Intel Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * Unless required by applicable law or agreed to in writing, software 9 * distributed under the License is distributed on an "AS IS" BASIS, 10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 * See the License for the specific language governing permissions and 12 * limitations under the License. 13 */ 14 15 #include "vmm_defs.h" 16 #include "guest_cpu.h" 17 #include "vmm_events_data.h" 18 #include "vmcs_api.h" 19 #include "hw_utils.h" 20 #include "emulator_if.h" 21 #include "vmm_callback.h" 22 #include "file_codes.h" 23 #define VMM_DEADLOOP() VMM_DEADLOOP_LOG(VMEXIT_EPT_C) 24 #define VMM_ASSERT(__condition) VMM_ASSERT_LOG(VMEXIT_EPT_C, __condition) 25 #ifdef JLMDEBUG 26 #include "jlmdebug.h" 27 #endif 28 29 #pragma warning (push) 30 #pragma warning (disable : 4100) // disable non-referenced formal parameters 31 VMEXIT_HANDLING_STATUS vmexit_mtf(GUEST_CPU_HANDLE gcpu) 32 { 33 if (!report_uvmm_event(UVMM_EVENT_MTF_VMEXIT, (VMM_IDENTIFICATION_DATA)gcpu, 34 (const GUEST_VCPU*)guest_vcpu(gcpu), NULL)) { 35 VMM_LOG(mask_uvmm, level_trace, "Report MTF VMExit failed.\n"); 36 } 37 return VMEXIT_HANDLED; 38 } 39 #pragma warning (pop) 40 41 BOOLEAN ept_violation_vmexit(GUEST_CPU_HANDLE gcpu, void *pv); 42 43 44 VMEXIT_HANDLING_STATUS vmexit_ept_violation(GUEST_CPU_HANDLE gcpu) 45 { 46 EVENT_GCPU_EPT_VIOLATION_DATA data; 47 VMCS_OBJECT* vmcs = gcpu_get_vmcs(gcpu); 48 49 50 //vmm_memset(&data, 0, sizeof(data)); 51 data.qualification.Uint64 = vmcs_read(vmcs, VMCS_EXIT_INFO_QUALIFICATION); 52 data.guest_linear_address = vmcs_read(vmcs, VMCS_EXIT_INFO_GUEST_LINEAR_ADDRESS); 53 data.guest_physical_address = vmcs_read(vmcs, VMCS_EXIT_INFO_GUEST_PHYSICAL_ADDRESS); 54 data.processed = FALSE; 55 56 ept_violation_vmexit( gcpu, &data ); 57 58 if (!data.processed) { 59 VMM_LOG(mask_anonymous, level_trace,"Unsupported ept violation in \n"); 60 PRINT_GCPU_IDENTITY(gcpu); 61 VMM_LOG(mask_anonymous, level_trace," Running %s emulator\n", emulator_is_running_as_guest() ? "inside" : "outside"); 62 //vmexit_handler_default(gcpu); 63 VMM_DEADLOOP(); 64 } 65 return VMEXIT_HANDLED; 66 } 67 68 VMEXIT_HANDLING_STATUS vmexit_ept_misconfiguration(GUEST_CPU_HANDLE gcpu) 69 { 70 EVENT_GCPU_EPT_MISCONFIGURATION_DATA data; 71 VMCS_OBJECT* vmcs = gcpu_get_vmcs(gcpu); 72 data.guest_physical_address = vmcs_read(vmcs, VMCS_EXIT_INFO_GUEST_PHYSICAL_ADDRESS); 73 data.processed = FALSE; 74 75 event_raise( EVENT_GCPU_EPT_MISCONFIGURATION, gcpu, &data ); 76 77 VMM_ASSERT(data.processed); 78 79 if ( ! data.processed) { 80 VMM_LOG(mask_anonymous, level_trace,"Unsupported ept misconfiguration in \n"); 81 PRINT_GCPU_IDENTITY(gcpu); 82 VMM_LOG(mask_anonymous, level_trace," Running %s emulator\n", emulator_is_running_as_guest() ? "inside" : "outside"); 83 //vmexit_handler_default(gcpu); 84 VMM_DEADLOOP(); 85 } 86 return VMEXIT_HANDLED; 87 } 88