X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_shdw_pg_swapbypass.c;h=2330f6d667eb8a2c0e88df6d82123548aa89560a;hb=d662cc4cc19794e57b3a0126fd05d09456e22cdc;hp=282c6971b5b63c3b1693ff058a2137310afe637d;hpb=926e4e742c02e6f1255c8da243494c8bbddbf752;p=palacios-OLD.git diff --git a/palacios/src/palacios/vmm_shdw_pg_swapbypass.c b/palacios/src/palacios/vmm_shdw_pg_swapbypass.c index 282c697..2330f6d 100644 --- a/palacios/src/palacios/vmm_shdw_pg_swapbypass.c +++ b/palacios/src/palacios/vmm_shdw_pg_swapbypass.c @@ -18,7 +18,10 @@ */ #include +#include +#include +#include struct shadow_page_data { v3_reg_t cr3; @@ -28,37 +31,39 @@ struct shadow_page_data { }; -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); @@ -77,7 +82,7 @@ static struct shadow_page_data * create_new_shadow_pt(struct guest_info * info) (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); @@ -87,18 +92,34 @@ static struct shadow_page_data * create_new_shadow_pt(struct guest_info * info) -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: @@ -117,12 +138,12 @@ int vtlb_activate_shdw_pt(struct guest_info * core, void * priv_data) { 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: @@ -142,7 +163,7 @@ int vtlb_handle_pf(struct guest_info * core, addr_t fault_addr, pf_error_t err_c } -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: @@ -158,3 +179,20 @@ int vtlb_handle_invlpg(struct guest_info * core, addr_t vaddr, void * priv_data) 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);