From: Chunxiao Diao, Daniel Zuo, Yuanbo Fan Date: Mon, 26 May 2014 21:23:04 +0000 (-0500) Subject: Convert shadow paging to use 32 PAE (Remove 32 Bit Restrictions) X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=d3d6d09894dba66f4e2361bb2f903139a2d83684 Convert shadow paging to use 32 PAE (Remove 32 Bit Restrictions) This changes shadow paging to use, at minimum, 32PAE shadow page tables. This makes it possible to place a guest using shadow paging anywhere in host physical memory instead of just the first 4 GB This patch removes the concept of "Shadow Safe" memory from Palacios, and it removes all places where it was used, most importantly, in the allocation of the guest itself. These patches must be used together. --- diff --git a/palacios/include/palacios/vmm.h b/palacios/include/palacios/vmm.h index 2b02058..78373bc 100644 --- a/palacios/include/palacios/vmm.h +++ b/palacios/include/palacios/vmm.h @@ -65,24 +65,6 @@ int v3_get_vcore(struct guest_info *); }) -// Use 32 bit constraints if the vm uses 32bit shadow paging at any point -// Should be used for shadow page tables and any physical memory -// mapped into the vm -#define V3_AllocShadowSafePages(vm,num_pages) \ - ({ \ - extern struct v3_os_hooks * os_hooks; \ - void * ptr = 0; \ - int c; int shadow=0; \ - for (c=0;c<(vm)->num_cores && !shadow;c++) { \ - shadow|=vm->cores[c].shdw_pg_mode==SHADOW_PAGING; \ - } \ - if ((os_hooks) && (os_hooks)->allocate_pages) { \ - ptr = (os_hooks)->allocate_pages(num_pages,PAGE_SIZE_4KB,-1,\ - shadow ? V3_ALLOC_PAGES_CONSTRAINT_4GB : 0); \ - } \ - ptr; \ - }) - #define V3_AllocAlignedPages(num_pages, align) \ ({ \ extern struct v3_os_hooks * os_hooks; \ diff --git a/palacios/src/devices/cga.c b/palacios/src/devices/cga.c index 0513b8c..36bec51 100644 --- a/palacios/src/devices/cga.c +++ b/palacios/src/devices/cga.c @@ -1252,7 +1252,7 @@ static int cga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { video_state->dev = dev; - video_state->framebuf_pa = (addr_t)V3_AllocShadowSafePages(vm,FRAMEBUF_SIZE / 4096); + video_state->framebuf_pa = (addr_t)V3_AllocPages(FRAMEBUF_SIZE / 4096); if (!video_state->framebuf_pa) { PrintError(vm, VCORE_NONE, "Cannot allocate frame buffer\n"); diff --git a/palacios/src/devices/cirrus_gfx_card.c b/palacios/src/devices/cirrus_gfx_card.c index 66f75b4..c6b7a43 100644 --- a/palacios/src/devices/cirrus_gfx_card.c +++ b/palacios/src/devices/cirrus_gfx_card.c @@ -442,7 +442,7 @@ static int cirrus_gfx_card_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg){ PrintDebug(info->vm_info, info, "video: init_device\n"); PrintDebug(info->vm_info, info, "Num Pages=%d\n", SIZE_OF_REGION / 4096); - video_state->video_memory_pa = (addr_t)V3_AllocShadowSafePages(vm, SIZE_OF_REGION / 4096); + video_state->video_memory_pa = (addr_t)V3_AllocPages(SIZE_OF_REGION / 4096); if (!video_state->video_memory_pa) { PrintError(info->vm_info, info, "Cannot allocate video memory\n"); V3_Free(video_state); diff --git a/palacios/src/devices/paragraph.c b/palacios/src/devices/paragraph.c index 32f07f1..36e44d8 100644 --- a/palacios/src/devices/paragraph.c +++ b/palacios/src/devices/paragraph.c @@ -452,7 +452,7 @@ static int paragraph_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) if (state->mode==MEM || state->mode==GCONS_MEM) { state->mem_size=MAXX*MAXY*MAXBPP; PrintDebug(vm, VCORE_NONE, "paragraph: allocating %llu bytes for local framebuffer\n", state->mem_size); - state->mem_paddr = V3_AllocShadowSafePages(vm,ceil_pages(state->mem_size)); + state->mem_paddr = V3_AllocPages(ceil_pages(state->mem_size)); if (!state->mem_paddr) { PrintError(state->vm, VCORE_NONE, "paragraph: Cannot allocate memory for framebuffer\n"); paragraph_free_internal(state); diff --git a/palacios/src/devices/swapbypass_cache.c b/palacios/src/devices/swapbypass_cache.c index 882d55f..bb5e9fe 100644 --- a/palacios/src/devices/swapbypass_cache.c +++ b/palacios/src/devices/swapbypass_cache.c @@ -296,7 +296,7 @@ static int swap_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { swap->active = 0; swap->hdr = (union swap_header *)swap; - swap->swap_base_addr = (addr_t)V3_AllocShadowSafePages(swap->capacity / 4096); + swap->swap_base_addr = (addr_t)V3_AllocPages(swap->capacity / 4096); if (!swap->swap_base_addr) { PrintError(vm, VCORE_NONE, "Cannot allocate swap space\n"); diff --git a/palacios/src/devices/swapbypass_cache2.c b/palacios/src/devices/swapbypass_cache2.c index 408d2b8..09d090b 100644 --- a/palacios/src/devices/swapbypass_cache2.c +++ b/palacios/src/devices/swapbypass_cache2.c @@ -578,7 +578,7 @@ static int connect_fn(struct v3_vm_info * vm, swap->active = 0; - swap->cache_base_addr = (addr_t)V3_AllocShadowSafePages(vm,swap->cache_size / 4096); + swap->cache_base_addr = (addr_t)V3_AllocPages(swap->cache_size / 4096); if (!swap->cache_base_addr) { PrintError(vm, VCORE_NONE, "Cannot allocate cache space\n"); diff --git a/palacios/src/devices/tmpdisk.c b/palacios/src/devices/tmpdisk.c index 1046b9b..eb49a64 100644 --- a/palacios/src/devices/tmpdisk.c +++ b/palacios/src/devices/tmpdisk.c @@ -120,7 +120,7 @@ static int blk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { blk->capacity = capacity; - blk->blk_base_addr = (addr_t)V3_AllocShadowSafePages(vm,blk->capacity / 4096); + blk->blk_base_addr = (addr_t)V3_AllocPages(blk->capacity / 4096); if (!blk->blk_base_addr) { PrintError(vm, VCORE_NONE, "Cannot allocate block space\n"); diff --git a/palacios/src/devices/vga.c b/palacios/src/devices/vga.c index 8d21fa7..037223e 100644 --- a/palacios/src/devices/vga.c +++ b/palacios/src/devices/vga.c @@ -2870,7 +2870,7 @@ static int vga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { for (i=0;ihost_addr = (addr_t)V3_AllocPagesExtended(block_pages, PAGE_SIZE_4KB, node_id, - will_use_shadow_paging(vm) ? - V3_ALLOC_PAGES_CONSTRAINT_4GB : 0 ); + 0); // no constraints if ((void *)region->host_addr == NULL) { PrintError(vm, VCORE_NONE, "Could not allocate guest memory\n"); diff --git a/palacios/src/palacios/vmm_mem_hook.c b/palacios/src/palacios/vmm_mem_hook.c index c30e51d..1d49294 100644 --- a/palacios/src/palacios/vmm_mem_hook.c +++ b/palacios/src/palacios/vmm_mem_hook.c @@ -58,7 +58,7 @@ int v3_init_mem_hooks(struct v3_vm_info * vm) { struct v3_mem_hooks * hooks = &(vm->mem_hooks); - temp = V3_AllocShadowSafePages(vm,vm->num_cores); + temp = V3_AllocPages(vm->num_cores); if (!temp) { PrintError(vm, VCORE_NONE, "Cannot allocate space for mem hooks\n"); @@ -67,7 +67,7 @@ int v3_init_mem_hooks(struct v3_vm_info * vm) { hooks->hook_hvas_1 = V3_VAddr(temp); - temp = V3_AllocShadowSafePages(vm,vm->num_cores); + temp = V3_AllocPages(vm->num_cores); if (!temp) { PrintError(vm, VCORE_NONE,"Cannot allocate space for mem hooks\n"); diff --git a/palacios/src/palacios/vmm_symspy.c b/palacios/src/palacios/vmm_symspy.c index 148cbcb..58f8aed 100644 --- a/palacios/src/palacios/vmm_symspy.c +++ b/palacios/src/palacios/vmm_symspy.c @@ -117,7 +117,7 @@ static int symspy_msr_write(struct guest_info * core, uint_t msr, struct v3_msr int v3_init_symspy_vm(struct v3_vm_info * vm, struct v3_symspy_global_state * state) { - state->global_page_pa = (addr_t)V3_AllocShadowSafePages(vm, 1); + state->global_page_pa = (addr_t)V3_AllocPages(1); if (!state->global_page_pa) { PrintError(vm, VCORE_NONE, "Cannot allocate page\n"); return -1; @@ -137,7 +137,7 @@ int v3_init_symspy_vm(struct v3_vm_info * vm, struct v3_symspy_global_state * st int v3_init_symspy_core(struct guest_info * core, struct v3_symspy_local_state * state) { - state->local_page_pa = (addr_t)V3_AllocShadowSafePages(core->vm_info, 1); + state->local_page_pa = (addr_t)V3_AllocPages(1); if (!state->local_page_pa) { PrintError(core->vm_info, core, "Cannot allocate page\n");