github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/host/trial_exec.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 "vmm_dbg.h" 17 #include "trial_exec.h" 18 #include "file_codes.h" 19 #define VMM_DEADLOOP() VMM_DEADLOOP_LOG(TRIAL_EXEC_C) 20 #define VMM_ASSERT(__condition) VMM_ASSERT_LOG(TRIAL_EXEC_C, __condition) 21 #ifdef JLMDEBUG 22 #include "jlmdebug.h" 23 #endif 24 25 static TRIAL_DATA *trial_data[VMM_MAX_CPU_SUPPORTED]; // max phys. CPUs supported 26 27 28 void trial_execution_push(TRIAL_DATA *p_trial_data, SETJMP_BUFFER *p_env) 29 { 30 CPU_ID cpu_id = hw_cpu_id(); 31 32 VMM_ASSERT(cpu_id < NELEMENTS(trial_data)); 33 34 p_trial_data->saved_env = p_env; 35 p_trial_data->error_code = 0; 36 p_trial_data->fault_vector = 0; 37 p_trial_data->prev = trial_data[cpu_id]; 38 trial_data[cpu_id] = p_trial_data; 39 } 40 41 42 TRIAL_DATA *trial_execution_pop(void) 43 { 44 TRIAL_DATA *p_last_trial; 45 CPU_ID cpu_id = hw_cpu_id(); 46 47 VMM_ASSERT(cpu_id < NELEMENTS(trial_data)); 48 49 if (NULL != trial_data[cpu_id]) { 50 p_last_trial = trial_data[cpu_id]; 51 trial_data[cpu_id] = trial_data[cpu_id]->prev; 52 } 53 else { 54 VMM_LOG(mask_anonymous, level_trace,"Error. Attempt to Pop Empty Trial Stack\n"); 55 p_last_trial = NULL; 56 } 57 58 return p_last_trial; 59 } 60 61 62 TRIAL_DATA * trial_execution_get_last(void) 63 { 64 CPU_ID cpu_id = hw_cpu_id(); 65 VMM_ASSERT(cpu_id < NELEMENTS(trial_data)); 66 return trial_data[cpu_id]; 67 } 68