*/
#include <palacios/vmm_shadow_paging.h>
+#include <palacios/vmm_ctrl_regs.h>
+#include <palacios/vm_guest.h>
+#include <palacios/vm_guest_mem.h>
struct shadow_page_data {
v3_reg_t cr3;
};
-struct vtlb_state {
+struct swapbypass_local_state {
struct list_head page_list;
};
-static struct shadow_page_data * create_new_shadow_pt(struct guest_info * info);
+static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core);
-#include "vmm_shdw_pg_tlb_32.h"
-#include "vmm_shdw_pg_tlb_32pae.h"
-#include "vmm_shdw_pg_tlb_64.h"
+#include "vmm_shdw_pg_swapbypass_32.h"
+#include "vmm_shdw_pg_swapbypass_32pae.h"
+#include "vmm_shdw_pg_swapbypass_64.h"
-static struct shadow_page_data * create_new_shadow_pt(struct guest_info * info) {
- struct shadow_page_state * state = &(info->shdw_pg_state);
- v3_reg_t cur_cr3 = info->ctrl_regs.cr3;
+static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core) {
+ struct v3_shdw_pg_state * state = &(core->shdw_pg_state);
+ struct swapbypass_local_state * impl_state = (struct swapbypass_local_state *)(state->local_impl_data);
+ v3_reg_t cur_cr3 = core->ctrl_regs.cr3;
struct shadow_page_data * page_tail = NULL;
addr_t shdw_page = 0;
- if (!list_empty(&(state->page_list))) {
- page_tail = list_tail_entry(&(state->page_list), struct shadow_page_data, page_list_node);
-
+ if (!list_empty(&(impl_state->page_list))) {
+ page_tail = list_tail_entry(&(impl_state->page_list), struct shadow_page_data, page_list_node);
+
+
if (page_tail->cr3 != cur_cr3) {
PrintDebug("Reusing old shadow Page: %p (cur_CR3=%p)(page_cr3=%p) \n",
(void *)(addr_t)page_tail->page_pa,
(void *)(addr_t)cur_cr3,
(void *)(addr_t)(page_tail->cr3));
- list_move(&(page_tail->page_list_node), &(state->page_list));
+ list_move(&(page_tail->page_list_node), &(impl_state->page_list));
memset(V3_VAddr((void *)(page_tail->page_pa)), 0, PAGE_SIZE_4KB);
(void *)(addr_t)cur_cr3);
page_tail->cr3 = cur_cr3;
- list_add(&(page_tail->page_list_node), &(state->page_list));
+ list_add(&(page_tail->page_list_node), &(impl_state->page_list));
shdw_page = (addr_t)V3_VAddr((void *)(page_tail->page_pa));
memset((void *)shdw_page, 0, PAGE_SIZE_4KB);
-static int vtlb_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg, void ** priv_data) {
- struct vtlb_state * state = V3_Malloc(sizeof(struct vtlb_state));
+static int sb_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
+
+ V3_Print("SWAPBYPASS initialization\n");
+ return 0;
+}
+
+static int sb_deinit(struct v3_vm_info * vm) {
+ return -1;
+}
+
+static int sb_local_init(struct guest_info * core) {
+ struct v3_shdw_pg_state * state = &(core->shdw_pg_state);
+ struct swapbypass_local_state * swapbypass_state = NULL;
+
+ V3_Print("SWAPBYPASS local initialization\n");
+
+
+ swapbypass_state = (struct swapbypass_local_state *)V3_Malloc(sizeof(struct swapbypass_local_state));
- INIT_LIST_HEAD(&(state->page_list));
+ INIT_LIST_HEAD(&(swapbypass_state->page_list));
- *priv_data = state;
+ state->local_impl_data = swapbypass_state;
return 0;
}
-int vtlb_activate_shdw_pt(struct guest_info * core, void * priv_data) {
+static int sb_activate_shdw_pt(struct guest_info * core) {
switch (v3_get_vm_cpu_mode(core)) {
case PROTECTED:
return 0;
}
-int vtlb_invalidate_shdw_pt(struct guest_info * core, void * priv_data) {
- return vtlb_activate_shdw_pt(core, priv_data);
+static int sb_invalidate_shdw_pt(struct guest_info * core) {
+ return sb_activate_shdw_pt(core);
}
-int vtlb_handle_pf(struct guest_info * core, addr_t fault_addr, pf_error_t err_code, void * priv_data) {
+static int sb_handle_pf(struct guest_info * core, addr_t fault_addr, pf_error_t error_code) {
switch (v3_get_vm_cpu_mode(core)) {
case PROTECTED:
}
-int vtlb_handle_invlpg(struct guest_info * core, addr_t vaddr, void * priv_data) {
+static int sb_handle_invlpg(struct guest_info * core, addr_t vaddr) {
switch (v3_get_vm_cpu_mode(core)) {
case PROTECTED:
return -1;
}
}
+
+static struct v3_shdw_pg_impl sb_impl = {
+ .name = "SWAPBYPASS",
+ .init = sb_init,
+ .deinit = sb_deinit,
+ .local_init = sb_local_init,
+ .handle_pagefault = sb_handle_pf,
+ .handle_invlpg = sb_handle_invlpg,
+ .activate_shdw_pt = sb_activate_shdw_pt,
+ .invalidate_shdw_pt = sb_invalidate_shdw_pt
+};
+
+
+
+
+
+register_shdw_pg_impl(&sb_impl);