-#ifdef CONFIG_SHADOW_PAGING_TELEMETRY
+#ifdef V3_CONFIG_SHADOW_PAGING_TELEMETRY
#include <palacios/vmm_telemetry.h>
#endif
-#ifdef CONFIG_SYMBIOTIC_SWAP
+#ifdef V3_CONFIG_SYMBIOTIC_SWAP
#include <palacios/vmm_sym_swap.h>
#endif
-#ifndef CONFIG_DEBUG_SHADOW_PAGING
+#ifndef V3_CONFIG_DEBUG_SHADOW_PAGING
#undef PrintDebug
#define PrintDebug(fmt, args...)
#endif
+static const char default_strategy[] = "VTLB";
+
static struct hashtable * master_shdw_pg_table = NULL;
return 0;
}
+int V3_deinit_shdw_paging() {
+ v3_free_htable(master_shdw_pg_table, 0, 0);
+ return 0;
+}
+
/***
***/
-#ifdef CONFIG_SHADOW_PAGING_TELEMETRY
+#ifdef V3_CONFIG_SHADOW_PAGING_TELEMETRY
static void telemetry_cb(struct v3_vm_info * vm, void * private_data, char * hdr) {
int i = 0;
for (i = 0; i < vm->num_cores; i++) {
}
-#ifdef CONFIG_SHADOW_PAGING_TELEMETRY
+#ifdef V3_CONFIG_SHADOW_PAGING_TELEMETRY
v3_add_telemetry_cb(core->vm_info, telemetry_cb, NULL);
#endif
}
+int v3_deinit_shdw_pg_state(struct guest_info * core) {
+ struct v3_shdw_pg_impl * impl = core->vm_info->shdw_impl.current_impl;
+
+ if (impl->local_deinit(core) == -1) {
+ PrintError("Error deinitializing shadow paging state\n");
+ return -1;
+ }
+
+
+ return 0;
+}
+
+
int v3_init_shdw_impl(struct v3_vm_info * vm) {
struct v3_shdw_impl_state * impl_state = &(vm->shdw_impl);
struct v3_shdw_pg_impl * impl = NULL;
PrintDebug("Checking if shadow paging requested.\n");
- if (pg_mode && (strcasecmp(pg_mode, "nested") == 0)) {
+ if ((pg_mode != NULL) && (strcasecmp(pg_mode, "nested") == 0)) {
PrintDebug("Nested paging specified - not initializing shadow paging.\n");
return 0;
}
+
+ if (pg_strat == NULL) {
+ pg_strat = (char *)default_strategy;
+ }
V3_Print("Initialization of Shadow Paging implementation\n");
return -1;
}
-
+ return 0;
+}
+
+int v3_deinit_shdw_impl(struct v3_vm_info * vm) {
+ struct v3_shdw_pg_impl * impl = vm->shdw_impl.current_impl;
+ if (impl->deinit(vm) == -1) {
+ PrintError("Error deinitializing shadow paging implementation\n");
+ return -1;
+ }
return 0;
}
int v3_inject_guest_pf(struct guest_info * core, addr_t fault_addr, pf_error_t error_code) {
core->ctrl_regs.cr2 = fault_addr;
-#ifdef CONFIG_SHADOW_PAGING_TELEMETRY
+#ifdef V3_CONFIG_SHADOW_PAGING_TELEMETRY
core->shdw_pg_state.guest_faults++;
#endif