80 while (sym[len] !=
'\0')
91 if (name == 0 || sym == 0)
97 ret = bfelf_loader_resolve_symbol(&
g_loader, name, sym);
100 ALERT(
"Failed to find: %s\n", name);
111 void *entry_point = 0;
127 ALERT(
"%s failed\n", sym);
160 for (s = 0; s < bfelf_file_get_num_load_instrs(&module->
file); s++)
166 ret = bfelf_file_get_load_instr(&module->
file, s, &instr);
177 if ((instr->
perm & bfpf_x) != 0)
200 for (s = 0; s < bfelf_file_get_num_load_instrs(&module->
file); s++)
209 ret = bfelf_file_get_load_instr(&module->
file, s, &instr);
281 ALERT(
"common_fini: failed to stop vmm\n");
288 ALERT(
"common_fini: failed to unload vmm\n");
298 ALERT(
"common_fini: failed to reset\n");
316 if (file == 0 || fsize == 0)
330 ret = bfelf_file_init(file, fsize, &module->
file);
334 module->
size = (uint64_t)bfelf_file_get_total_size(&module->
file);
336 if (module->
exec == 0)
344 DEBUG(
" addr = %p\n", (
void *)module->
exec);
345 DEBUG(
" size = %p\n", (
void *)module->
size);
361 int64_t ignore_ret = 0;
393 for (i = 0; (module =
get_module(i)) != 0; i++)
400 ret = bfelf_loader_relocate(&
g_loader);
408 for (i = 0; (module =
get_module(i)) != 0; i++)
412 ret = bfelf_file_get_section_info(&module->
file, &info);
420 for (i = 0; (module =
get_module(i)) != 0; i++)
428 uint64_t tlss = (uint64_t)
g_tls;
469 ret = bfelf_file_get_section_info(&module->
file, &info);
494 int64_t ignore_ret = 0;
495 int64_t caller_affinity = 0;
513 if (caller_affinity < 0)
516 ret =
execute_symbol(
"start_vmm", (uint64_t)cpuid, 0, (uint64_t)cpuid);
547 int64_t caller_affinity = 0;
565 if (caller_affinity < 0)
572 ret =
execute_symbol(
"stop_vmm", (uint64_t)cpuid, 0, (uint64_t)cpuid);
602 ret =
execute_symbol(
"get_drr", (uint64_t)vcpuid, (uint64_t)drr, 0);
613 int64_t caller_affinity = 0;
614 int64_t signed_cpuid = (int64_t)cpuid;
631 if (signed_cpuid >= 0)
634 if (caller_affinity < 0)
643 if (signed_cpuid >= 0)
constexpr const auto cpuid
#define ENTRY_ERROR_VMM_START_FAILED
#define MEMORY_MANAGER_SUCCESS
int64_t common_vmm_status(void)
int64_t load_elf_file(struct module_t *module)
int64_t(* execute_entry_t)(uint64_t stack, void *func, uint64_t arg1, uint64_t arg2)
int64_t common_dump_vmm(struct debug_ring_resources_t **drr, uint64_t vcpuid)
execute_entry_t execute_entry
int64_t common_reset(void)
int64_t common_fini(void)
#define BF_ERROR_VMM_INVALID_STATE
#define BF_ERROR_MAX_MODULES_REACHED
int64_t execute_symbol(const char *sym, uint64_t arg1, uint64_t arg2, uint64_t cpuid)
debug_ring_resources_t * drr
constexpr const auto size
#define THREAD_LOCAL_STORAGE_SIZE
auto index(const T virt, const F from)
int64_t common_vmcall(struct vmcall_registers_t *regs, uint64_t cpuid)
uint64_t symbol_length(const char *sym)
int64_t common_stop_vmm(void)
int64_t common_start_vmm(void)
struct module_t * get_module(int64_t index)
struct bfelf_loader_t g_loader
constexpr page_table_x64::integer_pointer virt
int64_t common_add_module(const char *file, uint64_t fsize)
int64_t add_md_to_memory_manager(struct module_t *module)
int64_t common_load_vmm(void)
#define BF_ERROR_OUT_OF_MEMORY
#define BF_ERROR_NO_MODULES_ADDED
constexpr const auto name
#define ENTRY_ERROR_VMM_STOP_FAILED
struct module_t g_modules[MAX_NUM_MODULES]
int64_t add_raw_md_to_memory_manager(uint64_t virt, uint64_t type)
int64_t common_init(void)
#define BF_ERROR_INVALID_ARG
int64_t common_unload_vmm(void)
int64_t resolve_symbol(const char *name, void **sym)
#define BF_ERROR_VMM_CORRUPTED
int64_t g_num_cpus_started
#define VMCALL_MAGIC_NUMBER