From: Jack Lange Date: Sun, 26 Oct 2008 01:18:07 +0000 (-0500) Subject: fixed format string issues due to printf attribute checks X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=03a41b18bdb6ce4bf666f18acdaf302e2360efdc fixed format string issues due to printf attribute checks --- diff --git a/palacios/include/palacios/vmm.h b/palacios/include/palacios/vmm.h index f7a612d..3b57710 100644 --- a/palacios/include/palacios/vmm.h +++ b/palacios/include/palacios/vmm.h @@ -211,12 +211,12 @@ struct guest_info; /* This will contain function pointers that provide OS services */ struct v3_os_hooks { - void (*print_info)(const char * format, ...); - // __attribute__ ((format (printf, 1, 2))); - void (*print_debug)(const char * format, ...); - // __attribute__ ((format (printf, 1, 2))); - void (*print_trace)(const char * format, ...); - // __attribute__ ((format (printf, 1, 2))); + void (*print_info)(const char * format, ...) + __attribute__ ((format (printf, 1, 2))); + void (*print_debug)(const char * format, ...) + __attribute__ ((format (printf, 1, 2))); + void (*print_trace)(const char * format, ...) + __attribute__ ((format (printf, 1, 2))); void *(*allocate_pages)(int numPages); void (*free_page)(void * page); diff --git a/palacios/include/palacios/vmm_decoder.h b/palacios/include/palacios/vmm_decoder.h index 6b8715e..c9636d3 100644 --- a/palacios/include/palacios/vmm_decoder.h +++ b/palacios/include/palacios/vmm_decoder.h @@ -242,9 +242,12 @@ static inline v3_reg_t get_gpr_mask(struct guest_info * info) { break; case PROTECTED: return 0xffffffff; + case LONG: + case LONG_32_COMPAT: + case LONG_16_COMPAT: default: - V3_ASSERT(0); - return 0; + PrintError("Unsupported Address Mode\n"); + return -1; } } @@ -260,9 +263,16 @@ static inline addr_t get_addr_linear(struct guest_info * info, addr_t addr, stru case PROTECTED: return addr + seg->base; break; + + case LONG: + // In long mode the segment bases are disregarded (forced to 0), unless using + // FS or GS, then the base addresses are added + return addr + seg->base; + case LONG_32_COMPAT: + case LONG_16_COMPAT: default: - V3_ASSERT(0); - return 0; + PrintError("Unsupported Address Mode\n"); + return -1; } } diff --git a/palacios/src/palacios/svm_handler.c b/palacios/src/palacios/svm_handler.c index 23546e2..798177e 100644 --- a/palacios/src/palacios/svm_handler.c +++ b/palacios/src/palacios/svm_handler.c @@ -417,7 +417,7 @@ int v3_handle_svm_exit(struct guest_info * info) { #ifdef DEBUG_INTERRUPTS PrintDebug("Injecting Interrupt %d (EIP=%p)\n", guest_ctrl->guest_ctrl.V_INTR_VECTOR, - (void *)info->rip); + (void *)(addr_t)info->rip); #endif v3_injecting_intr(info, irq, EXTERNAL_IRQ); @@ -446,7 +446,7 @@ int v3_handle_svm_exit(struct guest_info * info) { #ifdef DEBUG_INTERRUPTS PrintDebug("Injecting Interrupt %d (EIP=%p)\n", guest_ctrl->EVENTINJ.vector, - (void *)info->rip); + (void *)(addr_t)info->rip); #endif v3_injecting_intr(info, excp, EXCEPTION); break; diff --git a/palacios/src/palacios/svm_io.c b/palacios/src/palacios/svm_io.c index d4af89f..04b488b 100644 --- a/palacios/src/palacios/svm_io.c +++ b/palacios/src/palacios/svm_io.c @@ -171,7 +171,7 @@ int v3_handle_svm_io_ins(struct guest_info * info) { mask = get_gpr_mask(info); PrintDebug("INS io_info invalid address size, mask=0x%p, io_info=0x%p\n", - (void *)mask, (void *)(io_info)); + (void *)(addr_t)mask, (void *)(addr_t)(io_info)); // PrintDebug("INS Aborted... Check implementation\n"); //return -1; } @@ -311,7 +311,7 @@ int v3_handle_svm_io_outs(struct guest_info * info) { mask = get_gpr_mask(info); PrintDebug("OUTS io_info invalid address size, mask=0%p, io_info=0x%p\n", - (void *)mask, (void *)io_info); + (void *)(addr_t)mask, (void *)(addr_t)io_info); // PrintDebug("INS Aborted... Check implementation\n"); //return -1; // should never happen diff --git a/palacios/src/palacios/vmm_ctrl_regs.c b/palacios/src/palacios/vmm_ctrl_regs.c index f56c5a6..e2ab2bc 100644 --- a/palacios/src/palacios/vmm_ctrl_regs.c +++ b/palacios/src/palacios/vmm_ctrl_regs.c @@ -280,7 +280,7 @@ int v3_handle_cr3_write(struct guest_info * info) { shadow_pt = v3_create_new_shadow_pt32(); shadow_cr3->pdt_base_addr = (addr_t)V3_PAddr((void *)(addr_t)PD32_BASE_ADDR(shadow_pt)); - PrintDebug( "Created new shadow page table %p\n", shadow_cr3->pdt_base_addr ); + PrintDebug( "Created new shadow page table %p\n", (void *)(addr_t)shadow_cr3->pdt_base_addr ); //PrintDebugPageTables( (pde32_t *)CR3_TO_PDE32(*(uint_t*)shadow_cr3) ); diff --git a/palacios/src/palacios/vmm_dev_mgr.c b/palacios/src/palacios/vmm_dev_mgr.c index a49e25d..c1e1fdb 100644 --- a/palacios/src/palacios/vmm_dev_mgr.c +++ b/palacios/src/palacios/vmm_dev_mgr.c @@ -300,7 +300,9 @@ void PrintDebugDevIO(struct vm_device * dev) { PrintDebug("IO Hooks(%d) for Device: %s\n", dev->num_io_hooks, dev->name); list_for_each_entry(hook, &(dev->io_hooks), dev_list) { - PrintDebug("\tPort: 0x%x (read=0x%x), (write=0x%x)\n", hook->port, hook->read, hook->write); + PrintDebug("\tPort: 0x%x (read=0x%p), (write=0x%p)\n", hook->port, + (void *)(addr_t)(hook->read), + (void *)(addr_t)(hook->write)); } return; diff --git a/palacios/src/palacios/vmm_emulator.c b/palacios/src/palacios/vmm_emulator.c index db53ca8..1760a8f 100644 --- a/palacios/src/palacios/vmm_emulator.c +++ b/palacios/src/palacios/vmm_emulator.c @@ -160,7 +160,7 @@ int v3_emulate_memory_read(struct guest_info * info, addr_t read_gva, } #ifdef DEBUG_EMULATOR - PrintDebug("Instr (15 bytes) at %x:\n", instr); + PrintDebug("Instr (15 bytes) at %p:\n", (void *)(addr_t)instr); PrintTraceMemDump(instr, 15); #endif @@ -237,7 +237,7 @@ int v3_emulate_memory_write(struct guest_info * info, addr_t write_gva, pte32_t saved_pte; int i; - PrintDebug("Emulating Write for instruction at 0x%x\n",info->rip); + PrintDebug("Emulating Write for instruction at 0x%p\n", (void *)(addr_t)(info->rip)); if (info->mem_mode == PHYSICAL_MEM) { ret = read_guest_pa_memory(info, get_addr_linear(info, info->rip, &(info->segments.cs)), 15, instr); @@ -348,7 +348,7 @@ int v3_emulation_exit_handler(struct guest_info * info) { list_for_each_entry_safe(empg, p_empg, &(info->emulator.emulated_pages), page_list) { pte32_t empte32_t; - PrintDebug("wiping page %x\n", empg->va); + PrintDebug("wiping page %p\n", (void *)(addr_t)(empg->va)); v3_replace_shdw_page32(info, empg->va, &dummy_pte, &empte32_t); V3_FreePage((void *)(V3_PAddr((void *)(empg->page_addr)))); @@ -360,7 +360,7 @@ int v3_emulation_exit_handler(struct guest_info * info) { list_for_each_entry_safe(svpg, p_svpg, &(info->emulator.saved_pages), page_list) { - PrintDebug("Setting Saved page %x back\n", svpg->va); + PrintDebug("Setting Saved page %p back\n", (void *)(addr_t)(svpg->va)); v3_replace_shdw_page32(info, empg->va, &(svpg->pte), &dummy_pte); list_del(&(svpg->page_list)); @@ -373,7 +373,7 @@ int v3_emulation_exit_handler(struct guest_info * info) { //info->rip += info->emulator.instr_length; - PrintDebug("Returning to rip: 0x%x\n", info->rip); + PrintDebug("Returning to rip: 0x%p\n", (void *)(addr_t)(info->rip)); info->emulator.instr_length = 0; diff --git a/palacios/src/palacios/vmm_shadow_paging.c b/palacios/src/palacios/vmm_shadow_paging.c index 1f8e7a2..97dac47 100644 --- a/palacios/src/palacios/vmm_shadow_paging.c +++ b/palacios/src/palacios/vmm_shadow_paging.c @@ -512,7 +512,7 @@ static int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr return 0; } - PrintDebug("Returning end of PDE function (rip=%p)\n", (void *)(info->rip)); + PrintDebug("Returning end of PDE function (rip=%p)\n", (void *)(addr_t)(info->rip)); return 0; }