X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_emulator.c;h=b5394900390673b1efb424f69749832dedb5d36f;hb=0899a5c74318e582f3d6ebec52cc744cdb727734;hp=8d81eceb32a606627046dc12d78dc9ef6f27f44f;hpb=56f8088296ee4116a4811a2f4f843edd80a7748d;p=palacios.git diff --git a/palacios/src/palacios/vmm_emulator.c b/palacios/src/palacios/vmm_emulator.c index 8d81ece..b539490 100644 --- a/palacios/src/palacios/vmm_emulator.c +++ b/palacios/src/palacios/vmm_emulator.c @@ -1,6 +1,21 @@ -/* (c) 2008, Jack Lange */ -/* (c) 2008, The V3VEE Project */ - +/* + * This file is part of the Palacios Virtual Machine Monitor developed + * by the V3VEE Project with funding from the United States National + * Science Foundation and the Department of Energy. + * + * The V3VEE Project is a joint project between Northwestern University + * and the University of New Mexico. You can find out more at + * http://www.v3vee.org + * + * Copyright (c) 2008, Jack Lange + * Copyright (c) 2008, The V3VEE Project + * All rights reserved. + * + * Author: Jack Lange + * + * This is free software. You are permitted to use, + * redistribute, and modify it as specified in the file "V3VEE_LICENSE". + */ #include #include @@ -18,7 +33,7 @@ static const char VMMCALL[3] = {0x0f, 0x01, 0xd9}; #endif -int init_emulator(struct guest_info * info) { +int v3_init_emulator(struct guest_info * info) { struct emulation_state * emulator = &(info->emulator); emulator->num_emulated_pages = 0; @@ -125,7 +140,7 @@ int v3_emulate_memory_read(struct guest_info * info, addr_t read_gva, int (*read)(addr_t read_addr, void * dst, uint_t length, void * priv_data), addr_t read_gpa, void * private_data) { struct basic_instr_info instr_info; - char instr[15]; + uchar_t instr[15]; int ret; struct emulated_page * data_page = V3_Malloc(sizeof(struct emulated_page)); addr_t data_addr_offset = PT32_PAGE_OFFSET(read_gva); @@ -139,6 +154,11 @@ int v3_emulate_memory_read(struct guest_info * info, addr_t read_gva, ret = read_guest_va_memory(info, get_addr_linear(info, info->rip, &(info->segments.cs)), 15, instr); } + if (ret == -1) { + PrintError("Could not read guest memory\n"); + return -1; + } + #ifdef DEBUG_EMULATOR PrintDebug("Instr (15 bytes) at %x:\n", instr); PrintTraceMemDump(instr, 15); @@ -168,7 +188,8 @@ int v3_emulate_memory_read(struct guest_info * info, addr_t read_gva, // Read the data directly onto the emulated page - if (read(read_gpa, (void *)(data_page->page_addr + data_addr_offset), instr_info.op_size, private_data) != instr_info.op_size) { + ret = read(read_gpa, (void *)(data_page->page_addr + data_addr_offset), instr_info.op_size, private_data); + if ((ret == -1) || ((uint_t)ret != instr_info.op_size)) { PrintError("Read error in emulator\n"); V3_FreePage((void *)(data_page->page_addr)); V3_Free(data_page); @@ -208,7 +229,7 @@ int v3_emulate_memory_write(struct guest_info * info, addr_t write_gva, addr_t write_gpa, void * private_data) { struct basic_instr_info instr_info; - char instr[15]; + uchar_t instr[15]; int ret; struct write_region * write_op = V3_Malloc(sizeof(struct write_region )); struct emulated_page * data_page = V3_Malloc(sizeof(struct emulated_page));