X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvm_guest_mem.c;h=f3ab42714886f205b3b6ac658abb65a93c0719ec;hb=1831ffe56d9eeb2bde9b5584227dcaf958dad70d;hp=33cb5b2a398df8734be45bd92d7389f1ce045385;hpb=a109eb919a162bd7de58d62020801bc2e633be50;p=palacios.git diff --git a/palacios/src/palacios/vm_guest_mem.c b/palacios/src/palacios/vm_guest_mem.c index 33cb5b2..f3ab427 100644 --- a/palacios/src/palacios/vm_guest_mem.c +++ b/palacios/src/palacios/vm_guest_mem.c @@ -43,6 +43,7 @@ int host_pa_to_host_va(addr_t host_pa, addr_t * host_va) { int guest_pa_to_host_pa(struct guest_info * guest_info, addr_t guest_pa, addr_t * host_pa) { // we use the shadow map here... if (lookup_shadow_map_addr(&(guest_info->mem_map), guest_pa, host_pa) != HOST_REGION_PHYSICAL_MEMORY) { + PrintDebug("Could not find address in shadow map (addr=%x)\n", guest_pa); return -1; } @@ -283,7 +284,7 @@ int read_guest_va_memory(struct guest_info * guest_info, addr_t guest_va, int co int bytes_read = 0; while (count > 0) { - int dist_to_pg_edge = (PAGE_OFFSET(cursor) + PAGE_SIZE) - cursor; + int dist_to_pg_edge = (PAGE_ADDR(cursor) + PAGE_SIZE) - cursor; int bytes_to_copy = (dist_to_pg_edge > count) ? count : dist_to_pg_edge; addr_t host_addr; @@ -314,7 +315,7 @@ int read_guest_pa_memory(struct guest_info * guest_info, addr_t guest_pa, int co int bytes_read = 0; while (count > 0) { - int dist_to_pg_edge = (PAGE_OFFSET(cursor) + PAGE_SIZE) - cursor; + int dist_to_pg_edge = (PAGE_ADDR(cursor) + PAGE_SIZE) - cursor; int bytes_to_copy = (dist_to_pg_edge > count) ? count : dist_to_pg_edge; addr_t host_addr; @@ -322,11 +323,19 @@ int read_guest_pa_memory(struct guest_info * guest_info, addr_t guest_pa, int co return bytes_read; } + + /* + PrintDebug("Trying to read %d bytes\n", bytes_to_copy); + PrintDebug("Dist to page edge=%d\n", dist_to_pg_edge); + PrintDebug("PAGE_ADDR=0x%x\n", PAGE_ADDR(cursor)); + PrintDebug("guest_pa=0x%x\n", guest_pa); + */ + memcpy(dest + bytes_read, (void*)host_addr, bytes_to_copy); bytes_read += bytes_to_copy; count -= bytes_to_copy; - cursor += bytes_to_copy; + cursor += bytes_to_copy; } return bytes_read; @@ -343,7 +352,7 @@ int write_guest_pa_memory(struct guest_info * guest_info, addr_t guest_pa, int c int bytes_written = 0; while (count > 0) { - int dist_to_pg_edge = (PAGE_OFFSET(cursor) + PAGE_SIZE) - cursor; + int dist_to_pg_edge = (PAGE_ADDR(cursor) + PAGE_SIZE) - cursor; int bytes_to_copy = (dist_to_pg_edge > count) ? count : dist_to_pg_edge; addr_t host_addr; @@ -351,8 +360,9 @@ int write_guest_pa_memory(struct guest_info * guest_info, addr_t guest_pa, int c return bytes_written; } + memcpy((void*)host_addr, src + bytes_written, bytes_to_copy); - + bytes_written += bytes_to_copy; count -= bytes_to_copy; cursor += bytes_to_copy;