From: Peter Dinda Date: Sat, 29 Dec 2012 18:59:47 +0000 (-0600) Subject: Context-based output infrastructure (V3_Print, etc) and modifications to use it X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=acaadd79c597c8d5180fbfbec79c01fef3dff003;p=palacios.releases.git Context-based output infrastructure (V3_Print, etc) and modifications to use it This commit is huge, but the vast majority of it is basically trivial changes in how V3_Print, PrintDebug, PrintError, V3_ASSERT, and Vnet_Print are invoked throughout our codebase. All compiles, with all debug and features enabled. Functionality testing doesn't show problems. These functions now include a context: the VM and the vcore. There are Several cases: V3_Print(vm, vcore, ...) => VM-specific, and vcore-specific V3_Print(vm, VCORE_NONE,...) => VM-specific, but not core specific V3_Print(VM_NONE, VCORE_NONE),...) => non-specific PrintDebug now prefaces data with DEBUG: PrintError now prefaces data with ERROR: Telementry prefaces with telem.# (as before) The print OS hook has been modified so that it is called with: print(void *host_priv_data_from_create, // NULL = non-specific int vcore_number, // -1 = non-specific ...) The linux implementation now uses this functionality to decorate its output in an enhanced way: palacios (pcore num): ... palacios (pcore num vm name): ... palacios (pcore num vm name vcore num):... The new userspace tool v3_info filters and formats dmesg or /proc/kmsg output in numerous ways so that you can, for example, focus on the debugging output of a specfic core on a specific VM. Run without arguments for help. Other minor compilation fixes for ancient code. --- diff --git a/linux_module/iface-graphics-console.c b/linux_module/iface-graphics-console.c index ec965fd..d47819c 100644 --- a/linux_module/iface-graphics-console.c +++ b/linux_module/iface-graphics-console.c @@ -254,7 +254,7 @@ static int palacios_graphics_console_key(struct v3_guest * guest, struct palacios_graphics_console *cons, uint8_t scancode) { - struct v3_keyboard_event e; + struct v3_keyboard_event e; e.status = 0; e.scan_code = scancode; @@ -271,11 +271,12 @@ static int palacios_graphics_console_mouse(struct v3_guest * guest, struct palacios_graphics_console *cons, uint8_t x, uint8_t y, uint8_t buttons) { + /* struct v3_mouse_event e; e.data[0]=x; e.data[1]=y; e.data[2]=buttons; // These three are completely wrong, of course - ignoring mouse for now - + */ // mouse delivery is broken, so don't do it. // v3_deliver_mouse_event(guest->v3_ctx,&e); diff --git a/linux_module/mcheck.c b/linux_module/mcheck.c index e357e94..9cdc04b 100644 --- a/linux_module/mcheck.c +++ b/linux_module/mcheck.c @@ -8,7 +8,7 @@ #include #include -#include +//#include #include "palacios.h" #include "vm.h" @@ -17,6 +17,12 @@ #define SCRUBBER_MCE 0x1 #define V3_VM_INJECT_SCRUBBER_MCE (10224+20) +/* Missing the vmm_mcheck.h header file */ + +struct v3_vm_info; + +int v3_mcheck_inject_scrubber_mce(struct v3_vm_info *info, int cpu, uint64_t dst); + static int inject_mce(struct v3_guest * guest, unsigned int cmd, unsigned long arg, void * priv_data) { diff --git a/linux_module/palacios-stubs.c b/linux_module/palacios-stubs.c index 5bf69a1..92b3767 100644 --- a/linux_module/palacios-stubs.c +++ b/linux_module/palacios-stubs.c @@ -87,7 +87,7 @@ static int init_print_buffers(void) /** * Prints a message to the console. */ -void palacios_print(const char *fmt, ...) { +void palacios_print_scoped(void * vm, int vcore, const char *fmt, ...) { #if V3_PRINTK_OLD_STYLE_OUTPUT @@ -104,6 +104,7 @@ void palacios_print(const char *fmt, ...) { va_list ap; char *buf; unsigned int cpu = palacios_get_cpu(); + struct v3_guest *guest = (struct v3_guest *)vm; buf = print_buffer[cpu]; @@ -132,8 +133,25 @@ void palacios_print(const char *fmt, ...) { } #endif - printk(KERN_INFO "palacios (pcore %u): %s",cpu,buf); - + if (guest) { + if (vcore>=0) { + printk(KERN_INFO "palacios (pcore %u vm %s vcore %u): %s", + cpu, + guest->name, + vcore, + buf); + } else { + printk(KERN_INFO "palacios (pcore %u vm %s): %s", + cpu, + guest->name, + buf); + } + } else { + printk(KERN_INFO "palacios (pcore %u): %s", + cpu, + buf); + } + return; #endif @@ -141,7 +159,6 @@ void palacios_print(const char *fmt, ...) { } - /* * Allocates a contiguous region of pages of the requested size. * Returns the physical address of the first page in the region. @@ -663,7 +680,7 @@ palacios_mutex_unlock_irqrestore(void *mutex, void *flags) * Structure used by the Palacios hypervisor to interface with the host kernel. */ static struct v3_os_hooks palacios_os_hooks = { - .print = palacios_print, + .print = palacios_print_scoped, .allocate_pages = palacios_allocate_pages, .free_pages = palacios_free_pages, .malloc = palacios_alloc, diff --git a/linux_module/palacios-vnet.c b/linux_module/palacios-vnet.c index c1111ef..bdc88a1 100644 --- a/linux_module/palacios-vnet.c +++ b/linux_module/palacios-vnet.c @@ -140,8 +140,6 @@ host_del_timer(void * vnet_timer){ - - static struct vnet_host_hooks vnet_host_hooks = { .timer_create = host_create_timer, .timer_del = host_del_timer, @@ -164,7 +162,7 @@ static struct vnet_host_hooks vnet_host_hooks = { .mutex_lock_irqsave = palacios_mutex_lock_irqsave, .mutex_unlock_irqrestore = palacios_mutex_unlock_irqrestore, - .print = palacios_print, + .print = palacios_print_scoped, .allocate_pages = palacios_allocate_pages, .free_pages = palacios_free_pages, .malloc = palacios_alloc, diff --git a/linux_module/palacios.h b/linux_module/palacios.h index b80663a..a172adb 100644 --- a/linux_module/palacios.h +++ b/linux_module/palacios.h @@ -123,7 +123,8 @@ struct proc_dir_entry *palacios_get_procdir(void); // Selected exported stubs, for use in other palacios components, like vnet // The idea is that everything uses the same stubs -void palacios_print(const char *fmt, ...); +void palacios_print_scoped(void *vm, int vcore, const char *fmt, ...); +#define palacios_print(...) palacios_print_scoped(0,-1, __VA_ARGS__) void *palacios_allocate_pages(int num_pages, unsigned int alignment); void palacios_free_pages(void *page_addr, int num_pages); void *palacios_alloc(unsigned int size); diff --git a/linux_usr/v3_info b/linux_usr/v3_info new file mode 100755 index 0000000..e1b3969 --- /dev/null +++ b/linux_usr/v3_info @@ -0,0 +1,120 @@ +#!/usr/bin/perl -w + +use Getopt::Long; + +$debug=0; +$error=0; +$telemetry=0; +$skipunnamed=0; +$skipgeneral=0; +$targetvcore=-1; +$format=0; +$any=0; +$stream=0; + +&GetOptions("skipunnamed"=>\$skipunnamed, + "skipgeneral"=>\$skipgeneral, + "debug"=>\$debug, + "error"=>\$error, + "telemetry"=>\$telemetry, + "format"=>\$format, + "stream"=>\$stream, + "vcore=i"=>\$targetvcore); + + +$#ARGV==0 or die "v3_info [--skipunnamed] [--skipgeneral] [--debug] [--error]\n". + " [--telemetry] [--vcore=num] [--format] [--stream] vmname|_\n\n". + "Filter palacios output in dmesg\n". + "given a vmname, the default is to show the general output\n". + "for that vm, plus any general output from palacios.\n". + "the vm name \"_\" means VMs of any name.\n\n". + " --skipunnamed : do not show non-VM specific output\n". + " --skipgeneral : do not show general output (V3_Print)\n". + " --debug : show debug output (PrintDebug)\n". + " --error : show error output (PrintError)\n". + " --telemetry : show telemetry output\n". + " --vcore=num : show only output for specified vcore\n". + " --stream : attempt to stream from /proc/kmsg\n". + " --format : reformat output into a convenient form\n\n"; + + + + +$vmname = shift; +if ($vmname eq "_") { + $any=1; +} else { + $any=0; +} + +if ($stream) { + open(DMESG, "cat /proc/kmsg |"); +} else { + open(DMESG,"dmesg |"); +} + +while ($line = ) { + $origline=$line; + $timestamp=-1; + $pcore=-1; + $vm="NONE"; + $vcore=-1; + + if ($line =~ /^\[(.*)\]\s+(.*)$/) { + $timestamp = $1; + $line = $2; + } + + + if ($line =~/^palacios\s+\(pcore\s+(\d+)\)\:\s+(.*)/) { + # Unnamed output + next if $skipunnamed; + next if ($targetvcore!=-1); + $pcore=$1; + $line=$2; + } elsif ($line =~/^palacios\s+\(pcore\s+(\d+)\s+vm\s+(\S+)\s+vcore\s+(\d+)\):\s+(.*)$/) { + # core-specific output + $pcore=$1; + $vm=$2; + $vcore=$3; + $line=$4; + next if (!$any && !($vm eq $vmname)); + next if ($targetvcore!=-1 && $vcore!=$targetvcore); + } elsif ($line =~ /^palacios\s+\(pcore\s+(\d+)\s+vm\s+(\S+)\):\s+(.*)$/) { + $pcore=$1; + $vm=$2; + $line=$3; + next if (!$any & !($vm eq $vmname)); + next if ($targetvcore!=-1); + } else { + next; + } + + if ($line =~ /^DEBUG:\s+.*$/) { + next if !$debug; + } elsif ($line =~ /^ERROR:\s+.*$/) { + next if !$error; + } elsif ($line =~ /^telem\.\d+\>.*$/) { + next if !$telemetry; + } else { + next if $skipgeneral; + } + + if ($format) { + if ($timestamp!=-1) { + print "$timestamp\t"; + } + print "$pcore\t"; + print "$vm\t"; + if ($vcore==-1) { + print "NONE\t"; + } else { + print "$vcore\t"; + } + print $line,"\n"; + } else { + print $origline; + } +} + +close(DMESG); diff --git a/palacios/include/palacios/vmm.h b/palacios/include/palacios/vmm.h index 667c9b4..8e6c6de 100644 --- a/palacios/include/palacios/vmm.h +++ b/palacios/include/palacios/vmm.h @@ -21,16 +21,11 @@ #define __VMM_H__ -/*#include */ - -struct guest_info; #ifdef __V3VEE__ #include #include - -//#include #include @@ -38,32 +33,24 @@ struct guest_info; /* utility definitions */ +#define VM_NONE ((struct v3_vm_info *)0) +#define VCORE_NONE ((struct guest_info *)0) -#define V3_Print(fmt, args...) \ - do { \ - extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->print) { \ - (os_hooks)->print((fmt), ##args); \ - } \ - } while (0) +void *v3_get_host_vm(struct v3_vm_info *); +int v3_get_vcore(struct guest_info *); +#define V3_Print(vm, vcore, fmt, args...) \ + do { \ + extern struct v3_os_hooks * os_hooks; \ + if ((os_hooks) && (os_hooks)->print) { \ + (os_hooks)->print(v3_get_host_vm(vm), v3_get_vcore(vcore), (fmt), ##args); \ + } \ + } while (0) -#define PrintDebug(fmt, args...) \ - do { \ - extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->print) { \ - (os_hooks)->print((fmt), ##args); \ - } \ - } while (0) +#define PrintDebug(vm, vcore, fmt, args...) V3_Print(vm, vcore, "DEBUG: " fmt, ##args) -#define PrintError(fmt, args...) \ - do { \ - extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->print) { \ - (os_hooks)->print("%s(%d): " fmt, __FILE__, __LINE__, ##args); \ - } \ - } while (0) +#define PrintError(vm, vcore, fmt, args...) V3_Print(vm, vcore, "ERROR at %s(%d): " fmt, __FILE__, __LINE__, ##args) @@ -126,7 +113,7 @@ struct guest_info; if ((os_hooks) && (os_hooks)->malloc) { \ var = (os_hooks)->malloc(size); \ } \ - if (!var) PrintError("MALLOC FAILURE. Memory LEAK!!\n"); \ + if (!var) PrintError(VM_NONE,VCORE_NONE,"MALLOC FAILURE. Memory LEAK!!\n"); \ var; \ }) @@ -228,11 +215,11 @@ struct guest_info; /* ** */ -#define V3_ASSERT(x) \ +#define V3_ASSERT(vm, vcore, x) \ do { \ extern struct v3_os_hooks * os_hooks; \ if (!(x)) { \ - PrintDebug("Failed assertion in %s: %s at %s, line %d, RA=%lx\n", \ + PrintDebug(vm, vcore, "Failed assertion in %s: %s at %s, line %d, RA=%lx\n", \ __func__, #x, __FILE__, __LINE__, \ (ulong_t) __builtin_return_address(0)); \ while(1){ \ @@ -305,8 +292,12 @@ struct v3_vm_info; /* This will contain function pointers that provide OS services */ struct v3_os_hooks { - void (*print)(const char * format, ...) - __attribute__ ((format (printf, 1, 2))); + // the vm pointer is the host os's "priv_data" from v3_create_vm + // if vm is null, this is a general palacios printout + // if vm is not null, and vcore is negative, this is a general print form the vm + // if vm is not null, and vcore is non-negative, this is a print from a specific vcore + void (*print)(void *vm, int vcore, const char * format, ...) + __attribute__ ((format (printf, 3, 4))); void *(*allocate_pages)(int num_pages, unsigned int alignment); void (*free_pages)(void * page, int num_pages); diff --git a/palacios/include/palacios/vmm_checkpoint.h b/palacios/include/palacios/vmm_checkpoint.h index a861026..3b1a06e 100644 --- a/palacios/include/palacios/vmm_checkpoint.h +++ b/palacios/include/palacios/vmm_checkpoint.h @@ -104,7 +104,7 @@ failout: - PrintError("Failed to save device\n"); + PrintError(info->vm_info, info, "Failed to save device\n"); return -1; } diff --git a/palacios/include/palacios/vmm_decoder.h b/palacios/include/palacios/vmm_decoder.h index b1e87c2..c2686d9 100644 --- a/palacios/include/palacios/vmm_decoder.h +++ b/palacios/include/palacios/vmm_decoder.h @@ -195,7 +195,7 @@ static inline v3_reg_t get_gpr_mask(struct guest_info * info) { case LONG: return 0xffffffffffffffffLL; default: - PrintError("Unsupported Address Mode\n"); + PrintError(info->vm_info, info, "Unsupported Address Mode\n"); return -1; } } @@ -228,7 +228,7 @@ static inline addr_t get_addr_linear(struct guest_info * info, addr_t addr, stru } case LONG_16_COMPAT: default: - PrintError("Unsupported CPU Mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info,"Unsupported CPU Mode: %d\n", info->cpu_mode); return -1; } } diff --git a/palacios/include/palacios/vmm_dev_mgr.h b/palacios/include/palacios/vmm_dev_mgr.h index 556725e..e5e13d9 100644 --- a/palacios/include/palacios/vmm_dev_mgr.h +++ b/palacios/include/palacios/vmm_dev_mgr.h @@ -28,7 +28,6 @@ #include #include #include -#include #ifdef V3_CONFIG_CHECKPOINT #include diff --git a/palacios/include/palacios/vmm_ethernet.h b/palacios/include/palacios/vmm_ethernet.h index b141a59..f43ba43 100644 --- a/palacios/include/palacios/vmm_ethernet.h +++ b/palacios/include/palacios/vmm_ethernet.h @@ -53,27 +53,24 @@ struct nic_statistics { #include -#define V3_Net_Print(level, fmt, args...) \ +#define V3_Net_Print(level, fmt, args...) \ do { \ if(level <= net_debug) { \ - extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->print) { \ - (os_hooks)->print((fmt), ##args); \ - } \ + V3_Print(VM_NONE, VCORE_NONE, fmt, ##args); \ } \ } while (0) static inline int is_multicast_ethaddr(const uint8_t * addr) { - V3_ASSERT(ETH_ALEN == 6); + V3_ASSERT(VM_NONE, VCORE_NONE, ETH_ALEN == 6); return (0x01 & addr[0]); } static inline int is_broadcast_ethaddr(const uint8_t * addr) { - V3_ASSERT(ETH_ALEN == 6); + V3_ASSERT(VM_NONE, VCORE_NONE, ETH_ALEN == 6); return (addr[0] & addr[1] & addr[2] & addr[3] & addr[4] & addr[5]) == 0xff; } @@ -84,7 +81,7 @@ static inline int compare_ethaddr(const uint8_t * addr1, const uint8_t * addr2) const uint16_t *a = (const uint16_t *) addr1; const uint16_t *b = (const uint16_t *) addr2; - V3_ASSERT(ETH_ALEN == 6); + V3_ASSERT(VM_NONE, VCORE_NONE, ETH_ALEN == 6); return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0; } @@ -94,7 +91,7 @@ static inline int compare_ether_hdr(const uint8_t * hdr1, const uint8_t * hdr2) uint32_t *a32 = (uint32_t *)(hdr1 + 2); uint32_t *b32 = (uint32_t *)(hdr2 + 2); - V3_ASSERT(ETHERNET_HEADER_LEN == 14); + V3_ASSERT(VM_NONE, VCORE_NONE, ETHERNET_HEADER_LEN == 14); return (*(uint16_t *)hdr1 ^ *(uint16_t *)hdr2) | (a32[0] ^ b32[0]) | (a32[1] ^ b32[1]) | (a32[2] ^ b32[2]); diff --git a/palacios/include/palacios/vmm_events.h b/palacios/include/palacios/vmm_events.h index 296fe81..afc1194 100644 --- a/palacios/include/palacios/vmm_events.h +++ b/palacios/include/palacios/vmm_events.h @@ -82,7 +82,7 @@ static void inline v3_dispatch_event(struct guest_info * core, struct v3_notifier * tmp_notifier = NULL; if (event_type >= V3_EVENT_INVALID) { - PrintError("Tried to dispatch illegal event (%d)\n", event_type); + PrintError(info->vm_info, info, "Tried to dispatch illegal event (%d)\n", event_type); return; } diff --git a/palacios/include/palacios/vmm_instr_decoder.h b/palacios/include/palacios/vmm_instr_decoder.h index ce494e7..6e9785e 100644 --- a/palacios/include/palacios/vmm_instr_decoder.h +++ b/palacios/include/palacios/vmm_instr_decoder.h @@ -151,7 +151,7 @@ static int get_addr_width(struct guest_info * info, struct x86_instr * instr) { return (instr->prefixes.addr_size) ? 4 : 2; } default: - PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info, "Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } } @@ -276,13 +276,13 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, return (instr->prefixes.op_size) ? 4 : 2; } default: - PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info, "Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } case INVLPG: switch (v3_get_vm_cpu_mode(info)) { case REAL: - PrintError("Invalid instruction given operating mode (%d)\n", form); + PrintError(info->vm_info, info, "Invalid instruction given operating mode (%d)\n", form); return 0; case PROTECTED: case PROTECTED_PAE: @@ -291,7 +291,7 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, case LONG: return 8; default: - PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info, "Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } @@ -307,7 +307,7 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, case LONG: return 8; default: - PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info, "Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } @@ -326,14 +326,14 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, case LONG: return 8; default: - PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info, "Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } case MOV_SR2: case MOV_2SR: default: - PrintError("Unsupported instruction form %d\n", form); + PrintError(info->vm_info, info, "Unsupported instruction form %d\n", form); return -1; } @@ -437,7 +437,7 @@ static inline int decode_gpr(struct guest_info * core, reg->operand = (addr_t)&(gprs->r15); break; default: - PrintError("Invalid Reg Code (%d)\n", reg_code); + PrintError(core->vm_info, core, "Invalid Reg Code (%d)\n", reg_code); reg->operand = 0; return -1; } @@ -454,7 +454,7 @@ static inline int decode_cr(struct guest_info * core, struct v3_ctrl_regs * crs = &(core->ctrl_regs); -// PrintDebug("\t Ctrl regs %d\n", reg_code); +// PrintDebug(core->vm_info, core, "\t Ctrl regs %d\n", reg_code); switch (reg_code) { case 0: @@ -471,7 +471,7 @@ static inline int decode_cr(struct guest_info * core, break; default: reg->operand = 0; - PrintError("Invalid Reg Code (%d)\n", reg_code); + PrintError(core->vm_info, core, "Invalid Reg Code (%d)\n", reg_code); return -1; } @@ -510,14 +510,14 @@ static int decode_rm_operand16(struct guest_info * core, modrm_mode_t mod_mode = 0; uint8_t * instr_cursor = modrm_instr; - // PrintDebug("ModRM mod=%d\n", modrm->mod); + // PrintDebug(core->vm_info, core, "ModRM mod=%d\n", modrm->mod); *reg_code = modrm->reg; instr_cursor += 1; if (modrm->mod == 3) { - //PrintDebug("first operand = Register (RM=%d)\n",modrm->rm); + //PrintDebug(core->vm_info, core, "first operand = Register (RM=%d)\n",modrm->rm); operand->type = REG_OPERAND; decode_gpr(core, modrm->rm, operand); @@ -534,7 +534,7 @@ static int decode_rm_operand16(struct guest_info * core, } else if (modrm->mod == 2) { mod_mode = DISP16; } else { - PrintError("Instruction format error: Invalid mod_rm mode (%d)\n", modrm->mod); + PrintError(core->vm_info, core, "Instruction format error: Invalid mod_rm mode (%d)\n", modrm->mod); v3_print_instr(instr); return -1; } @@ -627,7 +627,7 @@ static int decode_rm_operand32(struct guest_info * core, if (modrm->mod == 3) { operand->type = REG_OPERAND; - // PrintDebug("first operand = Register (RM=%d)\n",modrm->rm); + // PrintDebug(core->vm_info, core, "first operand = Register (RM=%d)\n",modrm->rm); decode_gpr(core, modrm->rm, operand); @@ -643,7 +643,7 @@ static int decode_rm_operand32(struct guest_info * core, } else if (modrm->mod == 2) { mod_mode = DISP32; } else { - PrintError("Instruction format error: Invalid mod_rm mode (%d)\n", modrm->mod); + PrintError(core->vm_info, core, "Instruction format error: Invalid mod_rm mode (%d)\n", modrm->mod); v3_print_instr(instr); return -1; } @@ -806,7 +806,7 @@ int decode_rm_operand64(struct guest_info * core, uint8_t * modrm_instr, rm_val |= (instr->prefixes.rex_rm << 3); operand->type = REG_OPERAND; - // PrintDebug("first operand = Register (RM=%d)\n",modrm->rm); + // PrintDebug(core->vm_info, core, "first operand = Register (RM=%d)\n",modrm->rm); decode_gpr(core, rm_val, operand); } else { @@ -823,7 +823,7 @@ int decode_rm_operand64(struct guest_info * core, uint8_t * modrm_instr, } else if (modrm->mod == 2) { mod_mode = DISP32; } else { - PrintError("Instruction format error: Invalid mod_rm mode (%d)\n", modrm->mod); + PrintError(core->vm_info, core, "Instruction format error: Invalid mod_rm mode (%d)\n", modrm->mod); v3_print_instr(instr); return -1; } @@ -1075,7 +1075,7 @@ static int decode_rm_operand(struct guest_info * core, case LONG_32_COMPAT: return decode_rm_operand32(core, instr_ptr, instr, operand, reg_code); default: - PrintError("Invalid CPU_MODE (%d)\n", mode); + PrintError(core->vm_info, core, "Invalid CPU_MODE (%d)\n", mode); return -1; } } diff --git a/palacios/include/vnet/vnet_host.h b/palacios/include/vnet/vnet_host.h index 5ace729..6347fed 100644 --- a/palacios/include/vnet/vnet_host.h +++ b/palacios/include/vnet/vnet_host.h @@ -58,8 +58,8 @@ struct vnet_host_hooks { /* duplicate part from os_hooks */ void (*yield_cpu)(void); - void (*print)(const char * format, ...) - __attribute__ ((format (printf, 1, 2))); + void (*print)(void *vm , int core, const char * format, ...) + __attribute__ ((format (printf, 3, 4))); void *(*allocate_pages)(int num_pages, unsigned int alignment); void (*free_pages)(void * page, int num_pages); @@ -217,17 +217,17 @@ static inline void vnet_reset_timer(struct vnet_timer * timer, if(level <= net_debug) { \ extern struct vnet_host_hooks * host_hooks; \ if ((host_hooks) && (host_hooks)->print) { \ - (host_hooks)->print((fmt), ##args); \ + (host_hooks)->print(0, -1, (fmt), ##args); \ } \ } \ } while (0) -#define Vnet_Debug(fmt, args...) \ +#define Vnet_Debug(fmt, args...) \ do { \ extern struct vnet_host_hooks * host_hooks; \ if ((host_hooks) && (host_hooks)->print) { \ - (host_hooks)->print((fmt), ##args); \ + (host_hooks)->print(0, -1, (fmt), ##args); \ } \ } while (0) diff --git a/palacios/src/devices/8237_dma.c b/palacios/src/devices/8237_dma.c index 0467c63..adb5b4b 100644 --- a/palacios/src/devices/8237_dma.c +++ b/palacios/src/devices/8237_dma.c @@ -46,7 +46,7 @@ struct vm_device * v3_create_dma() { dma = (struct dma_state *)V3_Malloc(sizeof(struct dma_state)); if (!dma) { - PrintError("Cannot allocate\n"); + PrintError(info->vm_info, info, "Cannot allocate\n"); return NULL; } diff --git a/palacios/src/devices/8254.c b/palacios/src/devices/8254.c index 58b66b6..8ea7d61 100644 --- a/palacios/src/devices/8254.c +++ b/palacios/src/devices/8254.c @@ -133,7 +133,7 @@ static int handle_crystal_tics(struct pit * pit, struct channel * ch, uint_t osc uint_t channel_cycles = 0; uint_t output_changed = 0; - // PrintDebug("8254 PIT (channel %d): %d crystal tics\n", + // PrintDebug(info->vm_info, info, "8254 PIT (channel %d): %d crystal tics\n", // ch - pit->ch0, oscillations); if (ch->run_state == PENDING) { oscillations--; @@ -149,9 +149,9 @@ static int handle_crystal_tics(struct pit * pit, struct channel * ch, uint_t osc } /* - PrintDebug("8254 PIT: Channel Run State = %d, counter=", ch->run_state); + PrintDebug(VM_NONE, VCORE_NONE, "8254 PIT: Channel Run State = %d, counter=", ch->run_state); PrintTraceLL(ch->counter); - PrintDebug("\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\n"); */ if (ch->op_mode == SQR_WAVE) { oscillations *= 2; @@ -159,7 +159,7 @@ static int handle_crystal_tics(struct pit * pit, struct channel * ch, uint_t osc if (ch->counter > oscillations) { ch->counter -= oscillations; - //PrintDebug("8254 PIT: Counter at %u after %u oscillations.\n", + //PrintDebug(VM_NONE, VCORE_NONE, "8254 PIT: Counter at %u after %u oscillations.\n", // (unsigned int)ch->counter, oscillations); return output_changed; } else { @@ -188,12 +188,12 @@ static int handle_crystal_tics(struct pit * pit, struct channel * ch, uint_t osc oscillations = oscillations % reload_val; ch->counter = reload_val - oscillations; - // PrintDebug("8254 PIT: Counter reset to %u.\n", + // PrintDebug(VM_NONE, VCORE_NONE, "8254 PIT: Counter reset to %u.\n", // (unsigned int)ch->counter); } - //PrintDebug("8254 PIT: Channel %ld (mode = %u) Cycles: %d\n", + //PrintDebug(VM_NONE, VCORE_NONE, "8254 PIT: Channel %ld (mode = %u) Cycles: %d\n", //(ch - &pit->ch_0), ch->op_mode, channel_cycles); switch (ch->op_mode) { @@ -203,7 +203,7 @@ static int handle_crystal_tics(struct pit * pit, struct channel * ch, uint_t osc ch->output_pin = 1; output_changed = 1; } else { - // PrintDebug("8254: Output not changed in TERM_CNT mode.\n"); + // PrintDebug(VM_NONE, VCORE_NONE, "8254: Output not changed in TERM_CNT mode.\n"); } } break; @@ -213,7 +213,7 @@ static int handle_crystal_tics(struct pit * pit, struct channel * ch, uint_t osc ch->output_pin = 1; output_changed = 1; } else { - // PrintDebug("8254: Output not changed in ONE_SHOT mode.\n"); + // PrintDebug(VM_NONE, VCORE_NONE, "8254: Output not changed in ONE_SHOT mode.\n"); } } break; @@ -242,7 +242,7 @@ static int handle_crystal_tics(struct pit * pit, struct channel * ch, uint_t osc } break; case HW_STROBE: - PrintError("Hardware strobe not implemented\n"); + PrintError(VM_NONE, VCORE_NONE, "Hardware strobe not implemented\n"); return -1; break; default: @@ -263,17 +263,17 @@ static void pit_update_timer(struct guest_info * info, ullong_t cpu_cycles, ullo /* - PrintDebug("updating cpu_cycles="); + PrintDebug(info->vm_info, info, "updating cpu_cycles="); PrintTraceLL(cpu_cycles); - PrintDebug("\n"); + PrintDebug(info->vm_info, info, "\n"); - PrintDebug("pit_counter="); + PrintDebug(info->vm_info, info, "pit_counter="); PrintTraceLL(state->pit_counter); - PrintDebug("\n"); + PrintDebug(info->vm_info, info, "\n"); - PrintDebug("pit_reload="); + PrintDebug(info->vm_info, info, "pit_reload="); PrintTraceLL(state->pit_reload); - PrintDebug("\n"); + PrintDebug(info->vm_info, info, "\n"); */ if (state->pit_counter > cpu_cycles) { @@ -289,7 +289,7 @@ static void pit_update_timer(struct guest_info * info, ullong_t cpu_cycles, ullo if (cpu_cycles > state->pit_reload) { // how many full oscillations - //PrintError("cpu_cycles = %p, reload = %p...\n", + //PrintError(info->vm_info, info, "cpu_cycles = %p, reload = %p...\n", // (void *)(addr_t)cpu_cycles, // (void *)(addr_t)state->pit_reload); @@ -315,11 +315,11 @@ static void pit_update_timer(struct guest_info * info, ullong_t cpu_cycles, ullo state->pit_counter = state->pit_reload - cpu_cycles; if (oscillations) { - // PrintDebug("8254 PIT: Handling %d crystal tics\n", oscillations); + // PrintDebug(info->vm_info, info, "8254 PIT: Handling %d crystal tics\n", oscillations); if (handle_crystal_tics(state, &(state->ch_0), oscillations) == 1) { // raise interrupt - PrintDebug("8254 PIT: Injecting Timer interrupt to guest (run_state = %d)\n", + PrintDebug(info->vm_info, info, "8254 PIT: Injecting Timer interrupt to guest (run_state = %d)\n", state->ch_0.run_state); v3_raise_irq(info->vm_info, 0); } @@ -352,8 +352,8 @@ static int handle_channel_write(struct channel * ch, char val) { ch->access_state = WAITING_LOBYTE; } - PrintDebug("8254 PIT: updated channel counter: %d\n", ch->reload_value); - PrintDebug("8254 PIT: Channel Run State=%d\n", ch->run_state); + PrintDebug(VM_NONE, VCORE_NONE, "8254 PIT: updated channel counter: %d\n", ch->reload_value); + PrintDebug(VM_NONE, VCORE_NONE, "8254 PIT: Channel Run State=%d\n", ch->run_state); break; } case WAITING_LOBYTE: @@ -366,11 +366,11 @@ static int handle_channel_write(struct channel * ch, char val) { ch->run_state = PENDING; } - PrintDebug("8254 PIT: updated channel counter: %d\n", ch->reload_value); - PrintDebug("8254 PIT: Channel Run State=%d\n", ch->run_state); + PrintDebug(VM_NONE, VCORE_NONE, "8254 PIT: updated channel counter: %d\n", ch->reload_value); + PrintDebug(VM_NONE, VCORE_NONE, "8254 PIT: Channel Run State=%d\n", ch->run_state); break; default: - PrintError("Invalid Access state\n"); + PrintError(VM_NONE, VCORE_NONE, "Invalid Access state\n"); return -1; } @@ -392,7 +392,7 @@ static int handle_channel_write(struct channel * ch, char val) { ch->output_pin = 1; break; default: - PrintError("Invalid OP_MODE: %d\n", ch->op_mode); + PrintError(VM_NONE, VCORE_NONE, "Invalid OP_MODE: %d\n", ch->op_mode); return -1; break; } @@ -445,7 +445,7 @@ static int handle_speaker_write(uint8_t *speaker, struct channel * ch, char val) static int handle_channel_cmd(struct channel * ch, struct pit_cmd_word cmd) { if (cmd.op_mode != ch->op_mode) { - PrintDebug("8254 PIT: Changing channel from op mode %d to op mode %d.\n", + PrintDebug(VM_NONE, VCORE_NONE, "8254 PIT: Changing channel from op mode %d to op mode %d.\n", ch->op_mode, cmd.op_mode); } @@ -454,7 +454,7 @@ static int handle_channel_cmd(struct channel * ch, struct pit_cmd_word cmd) { } if (cmd.access_mode != ch->access_mode) { - PrintDebug("8254 PIT: Changing channel from access mode %d to access mode %d.\n", + PrintDebug(VM_NONE, VCORE_NONE, "8254 PIT: Changing channel from access mode %d to access mode %d.\n", ch->access_mode, cmd.access_mode); } ch->access_mode = cmd.access_mode; @@ -493,7 +493,7 @@ static int handle_channel_cmd(struct channel * ch, struct pit_cmd_word cmd) { ch->output_pin = 1; break; default: - PrintError("Invalid OP_MODE: %d\n", cmd.op_mode); + PrintError(VM_NONE, VCORE_NONE, "Invalid OP_MODE: %d\n", cmd.op_mode); return -1; } @@ -509,39 +509,39 @@ static int pit_read_channel(struct guest_info * core, ushort_t port, void * dst, char * val = (char *)dst; if (length != 1) { - PrintError("8254 PIT: Invalid Read Write length \n"); + PrintError(core->vm_info, core, "8254 PIT: Invalid Read Write length \n"); return -1; } - PrintDebug("8254 PIT: Read of PIT Channel %d\n", port - CHANNEL0_PORT); + PrintDebug(core->vm_info, core, "8254 PIT: Read of PIT Channel %d\n", port - CHANNEL0_PORT); switch (port) { case CHANNEL0_PORT: if (handle_channel_read(&(state->ch_0), val) == -1) { - PrintError("CHANNEL0 read error\n"); + PrintError(core->vm_info, core, "CHANNEL0 read error\n"); return -1; } break; case CHANNEL1_PORT: if (handle_channel_read(&(state->ch_1), val) == -1) { - PrintError("CHANNEL1 read error\n"); + PrintError(core->vm_info, core, "CHANNEL1 read error\n"); return -1; } break; case CHANNEL2_PORT: if (handle_channel_read(&(state->ch_2), val) == -1) { - PrintError("CHANNEL2 read error\n"); + PrintError(core->vm_info, core, "CHANNEL2 read error\n"); return -1; } break; case SPEAKER_PORT: if (handle_speaker_read(&state->speaker, &(state->ch_2), val) == -1) { - PrintError("SPEAKER read error\n"); + PrintError(core->vm_info, core, "SPEAKER read error\n"); return -1; } break; default: - PrintError("8254 PIT: Read from invalid port (%d)\n", port); + PrintError(core->vm_info, core, "8254 PIT: Read from invalid port (%d)\n", port); return -1; } @@ -555,40 +555,40 @@ static int pit_write_channel(struct guest_info * core, ushort_t port, void * src char val = *(char *)src; if (length != 1) { - PrintError("8254 PIT: Invalid Write Length\n"); + PrintError(core->vm_info, core, "8254 PIT: Invalid Write Length\n"); return -1; } - PrintDebug("8254 PIT: Write to PIT Channel %d (%x)\n", port - CHANNEL0_PORT, *(char*)src); + PrintDebug(core->vm_info, core, "8254 PIT: Write to PIT Channel %d (%x)\n", port - CHANNEL0_PORT, *(char*)src); switch (port) { case CHANNEL0_PORT: if (handle_channel_write(&(state->ch_0), val) == -1) { - PrintError("CHANNEL0 write error\n"); + PrintError(core->vm_info, core, "CHANNEL0 write error\n"); return -1; } break; case CHANNEL1_PORT: if (handle_channel_write(&(state->ch_1), val) == -1) { - PrintError("CHANNEL1 write error\n"); + PrintError(core->vm_info, core, "CHANNEL1 write error\n"); return -1; } break; case CHANNEL2_PORT: if (handle_channel_write(&(state->ch_2), val) == -1) { - PrintError("CHANNEL2 write error\n"); + PrintError(core->vm_info, core, "CHANNEL2 write error\n"); return -1; } break; case SPEAKER_PORT: if (handle_speaker_write(&state->speaker, &(state->ch_2), val) == -1) { - PrintError("SPEAKER write error\n"); + PrintError(core->vm_info, core, "SPEAKER write error\n"); return -1; } break; default: - PrintError("8254 PIT: Write to invalid port (%d)\n", port); + PrintError(core->vm_info, core, "8254 PIT: Write to invalid port (%d)\n", port); return -1; } @@ -602,35 +602,35 @@ static int pit_write_command(struct guest_info * core, ushort_t port, void * src struct pit * state = (struct pit *)priv_data; struct pit_cmd_word * cmd = (struct pit_cmd_word *)src; - PrintDebug("8254 PIT: Write to PIT Command port\n"); - PrintDebug("8254 PIT: Writing to channel %d (access_mode = %d, op_mode = %d)\n", cmd->channel, cmd->access_mode, cmd->op_mode); + PrintDebug(core->vm_info, core, "8254 PIT: Write to PIT Command port\n"); + PrintDebug(core->vm_info, core, "8254 PIT: Writing to channel %d (access_mode = %d, op_mode = %d)\n", cmd->channel, cmd->access_mode, cmd->op_mode); if (length != 1) { - PrintError("8254 PIT: Write of Invalid length to command port\n"); + PrintError(core->vm_info, core, "8254 PIT: Write of Invalid length to command port\n"); return -1; } switch (cmd->channel) { case 0: if (handle_channel_cmd(&(state->ch_0), *cmd) == -1) { - PrintError("CHANNEL0 command error\n"); + PrintError(core->vm_info, core, "CHANNEL0 command error\n"); return -1; } break; case 1: if (handle_channel_cmd(&(state->ch_1), *cmd) == -1) { - PrintError("CHANNEL1 command error\n"); + PrintError(core->vm_info, core, "CHANNEL1 command error\n"); return -1; } break; case 2: if (handle_channel_cmd(&(state->ch_2), *cmd) == -1) { - PrintError("CHANNEL2 command error\n"); + PrintError(core->vm_info, core, "CHANNEL2 command error\n"); return -1; } break; case 3: // Read Back command - PrintError("Read back command not implemented\n"); + PrintError(core->vm_info, core, "Read back command not implemented\n"); return -1; break; default: @@ -737,7 +737,7 @@ static int pit_save(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; savefailout: - PrintError("Failed to save pit\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to save pit\n"); return -1; } @@ -788,7 +788,7 @@ static int pit_load(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; loadfailout: - PrintError("Failed to load pit\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to load pit\n"); return -1; } #endif @@ -819,7 +819,7 @@ static int pit_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { pit_state = (struct pit *)V3_Malloc(sizeof(struct pit)); if (!pit_state) { - PrintError("Cannot allocate in init\n"); + PrintError(info->vm_info, info, "Cannot allocate in init\n"); return -1; } @@ -829,7 +829,7 @@ static int pit_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { dev = v3_add_device(vm, dev_id, &dev_ops, pit_state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(info->vm_info, info, "Could not attach device %s\n", dev_id); V3_Free(pit_state); return -1; } @@ -841,15 +841,15 @@ static int pit_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { ret |= v3_dev_hook_io(dev, SPEAKER_PORT, &pit_read_channel, &pit_write_channel); if (ret != 0) { - PrintError("8254 PIT: Failed to hook IO ports\n"); + PrintError(info->vm_info, info, "8254 PIT: Failed to hook IO ports\n"); v3_remove_device(dev); return -1; } #ifdef V3_CONFIG_DEBUG_PIT - PrintDebug("8254 PIT: OSC_HZ=%d, reload_val=", OSC_HZ); + PrintDebug(info->vm_info, info, "8254 PIT: OSC_HZ=%d, reload_val=", OSC_HZ); //PrintTrace(reload_val); - PrintDebug("\n"); + PrintDebug(info->vm_info, info, "\n"); #endif @@ -873,9 +873,9 @@ static int pit_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { init_channel(&(pit_state->ch_2)); #ifdef V3_CONFIG_DEBUG_PIT - PrintDebug("8254 PIT: CPU MHZ=%d -- pit count=", cpu_khz / 1000); + PrintDebug(info->vm_info, info, "8254 PIT: CPU MHZ=%d -- pit count=", cpu_khz / 1000); //PrintTraceLL(pit_state->pit_counter); - PrintDebug("\n"); + PrintDebug(info->vm_info, info, "\n"); #endif return 0; diff --git a/palacios/src/devices/8259a.c b/palacios/src/devices/8259a.c index 0eaa40e..bf3a139 100644 --- a/palacios/src/devices/8259a.c +++ b/palacios/src/devices/8259a.c @@ -173,31 +173,31 @@ struct pic_internal { static void DumpPICState(struct pic_internal *p) { - PrintDebug("8259 PIC: master_state=0x%x\n",p->master_state); - PrintDebug("8259 PIC: master_irr=0x%x\n",p->master_irr); - PrintDebug("8259 PIC: master_isr=0x%x\n",p->master_isr); - PrintDebug("8259 PIC: master_imr=0x%x\n",p->master_imr); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: master_state=0x%x\n",p->master_state); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: master_irr=0x%x\n",p->master_irr); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: master_isr=0x%x\n",p->master_isr); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: master_imr=0x%x\n",p->master_imr); - PrintDebug("8259 PIC: master_ocw2=0x%x\n",p->master_ocw2); - PrintDebug("8259 PIC: master_ocw3=0x%x\n",p->master_ocw3); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: master_ocw2=0x%x\n",p->master_ocw2); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: master_ocw3=0x%x\n",p->master_ocw3); - PrintDebug("8259 PIC: master_icw1=0x%x\n",p->master_icw1); - PrintDebug("8259 PIC: master_icw2=0x%x\n",p->master_icw2); - PrintDebug("8259 PIC: master_icw3=0x%x\n",p->master_icw3); - PrintDebug("8259 PIC: master_icw4=0x%x\n",p->master_icw4); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: master_icw1=0x%x\n",p->master_icw1); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: master_icw2=0x%x\n",p->master_icw2); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: master_icw3=0x%x\n",p->master_icw3); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: master_icw4=0x%x\n",p->master_icw4); - PrintDebug("8259 PIC: slave_state=0x%x\n",p->slave_state); - PrintDebug("8259 PIC: slave_irr=0x%x\n",p->slave_irr); - PrintDebug("8259 PIC: slave_isr=0x%x\n",p->slave_isr); - PrintDebug("8259 PIC: slave_imr=0x%x\n",p->slave_imr); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: slave_state=0x%x\n",p->slave_state); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: slave_irr=0x%x\n",p->slave_irr); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: slave_isr=0x%x\n",p->slave_isr); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: slave_imr=0x%x\n",p->slave_imr); - PrintDebug("8259 PIC: slave_ocw2=0x%x\n",p->slave_ocw2); - PrintDebug("8259 PIC: slave_ocw3=0x%x\n",p->slave_ocw3); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: slave_ocw2=0x%x\n",p->slave_ocw2); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: slave_ocw3=0x%x\n",p->slave_ocw3); - PrintDebug("8259 PIC: slave_icw1=0x%x\n",p->slave_icw1); - PrintDebug("8259 PIC: slave_icw2=0x%x\n",p->slave_icw2); - PrintDebug("8259 PIC: slave_icw3=0x%x\n",p->slave_icw3); - PrintDebug("8259 PIC: slave_icw4=0x%x\n",p->slave_icw4); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: slave_icw1=0x%x\n",p->slave_icw1); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: slave_icw2=0x%x\n",p->slave_icw2); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: slave_icw3=0x%x\n",p->slave_icw3); + PrintDebug(VM_NONE, VCORE_NONE, "8259 PIC: slave_icw4=0x%x\n",p->slave_icw4); } @@ -211,14 +211,14 @@ static int pic_raise_intr(struct v3_vm_info * vm, void * private_data, struct v3 state->master_irr |= 0x04; } - PrintDebug("8259 PIC: Raising irq %d in the PIC\n", irq_num); + PrintDebug(vm, VCORE_NONE, "8259 PIC: Raising irq %d in the PIC\n", irq_num); if (irq_num <= 7) { state->master_irr |= 0x01 << irq_num; } else if ((irq_num > 7) && (irq_num < 16)) { state->slave_irr |= 0x01 << (irq_num - 8); } else { - PrintDebug("8259 PIC: Invalid IRQ raised (%d)\n", irq_num); + PrintDebug(vm, VCORE_NONE, "8259 PIC: Invalid IRQ raised (%d)\n", irq_num); return -1; } @@ -239,18 +239,18 @@ static int pic_lower_intr(struct v3_vm_info * vm, void * private_data, struct v3 uint8_t irq_num = irq->irq; - PrintDebug("[pic_lower_intr] IRQ line %d now low\n", irq_num); + PrintDebug(vm, VCORE_NONE, "[pic_lower_intr] IRQ line %d now low\n", irq_num); if (irq_num <= 7) { state->master_irr &= ~(1 << irq_num); if ((state->master_irr & ~(state->master_imr)) == 0) { - PrintDebug("\t\tFIXME: Master maybe should do sth\n"); + PrintDebug(vm, VCORE_NONE, "\t\tFIXME: Master maybe should do sth\n"); } } else if ((irq_num > 7) && (irq_num < 16)) { state->slave_irr &= ~(1 << (irq_num - 8)); if ((state->slave_irr & (~(state->slave_imr))) == 0) { - PrintDebug("\t\tFIXME: Slave maybe should do sth\n"); + PrintDebug(vm, VCORE_NONE, "\t\tFIXME: Slave maybe should do sth\n"); } } return 0; @@ -274,8 +274,8 @@ static int pic_get_intr_number(struct guest_info * info, void * private_data) { int i = 0; int irq = -1; - PrintDebug("8259 PIC: getnum: master_irr: 0x%x master_imr: 0x%x\n", state->master_irr, state->master_imr); - PrintDebug("8259 PIC: getnum: slave_irr: 0x%x slave_imr: 0x%x\n", state->slave_irr, state->slave_imr); + PrintDebug(info->vm_info, info, "8259 PIC: getnum: master_irr: 0x%x master_imr: 0x%x\n", state->master_irr, state->master_imr); + PrintDebug(info->vm_info, info, "8259 PIC: getnum: slave_irr: 0x%x slave_imr: 0x%x\n", state->slave_irr, state->slave_imr); for (i = 0; i < 16; i++) { if (i <= 7) { @@ -283,7 +283,7 @@ static int pic_get_intr_number(struct guest_info * info, void * private_data) { //state->master_isr |= (0x1 << i); // reset the irr //state->master_irr &= ~(0x1 << i); - PrintDebug("8259 PIC: IRQ: %d, master_icw2: %x\n", i, state->master_icw2); + PrintDebug(info->vm_info, info, "8259 PIC: IRQ: %d, master_icw2: %x\n", i, state->master_icw2); irq = i + state->master_icw2; break; } @@ -291,7 +291,7 @@ static int pic_get_intr_number(struct guest_info * info, void * private_data) { if (((state->slave_irr & ~(state->slave_imr)) >> (i - 8)) & 0x01) { //state->slave_isr |= (0x1 << (i - 8)); //state->slave_irr &= ~(0x1 << (i - 8)); - PrintDebug("8259 PIC: IRQ: %d, slave_icw2: %x\n", i, state->slave_icw2); + PrintDebug(info->vm_info, info, "8259 PIC: IRQ: %d, slave_icw2: %x\n", i, state->slave_icw2); irq = (i - 8) + state->slave_icw2; break; } @@ -307,7 +307,7 @@ static int pic_get_intr_number(struct guest_info * info, void * private_data) { if (i == 16) { return -1; } else { - PrintDebug("8259 PIC: get num is returning %d\n",irq); + PrintDebug(info->vm_info, info, "8259 PIC: get num is returning %d\n",irq); return irq; } } @@ -324,7 +324,7 @@ static int pic_begin_irq(struct guest_info * info, void * private_data, int irq) irq &= 0x7; irq += 8; } else { - // PrintError("8259 PIC: Could not find IRQ (0x%x) to Begin\n",irq); + // PrintError(info->vm_info, info, "8259 PIC: Could not find IRQ (0x%x) to Begin\n",irq); return -1; } @@ -337,7 +337,7 @@ static int pic_begin_irq(struct guest_info * info, void * private_data, int irq) state->master_irr &= ~(0x1 << irq); } } else { - PrintDebug("8259 PIC: (master) Ignoring begin_irq for %d since I don't own it\n", irq); + PrintDebug(info->vm_info, info, "8259 PIC: (master) Ignoring begin_irq for %d since I don't own it\n", irq); } } else { @@ -349,7 +349,7 @@ static int pic_begin_irq(struct guest_info * info, void * private_data, int irq) state->slave_irr &= ~(0x1 << (irq - 8)); } } else { - PrintDebug("8259 PIC: (slave) Ignoring begin_irq for %d since I don't own it\n", irq); + PrintDebug(info->vm_info, info, "8259 PIC: (slave) Ignoring begin_irq for %d since I don't own it\n", irq); } } @@ -383,7 +383,7 @@ static int read_master_port1(struct guest_info * core, ushort_t port, void * dst struct pic_internal * state = (struct pic_internal *)priv_data; if (length != 1) { - PrintError("8259 PIC: Invalid Read length (rd_Master1)\n"); + PrintError(core->vm_info, core, "8259 PIC: Invalid Read length (rd_Master1)\n"); return -1; } @@ -402,7 +402,7 @@ static int read_master_port2(struct guest_info * core, ushort_t port, void * dst struct pic_internal * state = (struct pic_internal *)priv_data; if (length != 1) { - PrintError("8259 PIC: Invalid Read length (rd_Master2)\n"); + PrintError(core->vm_info, core, "8259 PIC: Invalid Read length (rd_Master2)\n"); return -1; } @@ -416,7 +416,7 @@ static int read_slave_port1(struct guest_info * core, ushort_t port, void * dst, struct pic_internal * state = (struct pic_internal *)priv_data; if (length != 1) { - PrintError("8259 PIC: Invalid Read length (rd_Slave1)\n"); + PrintError(core->vm_info, core, "8259 PIC: Invalid Read length (rd_Slave1)\n"); return -1; } @@ -435,7 +435,7 @@ static int read_slave_port2(struct guest_info * core, ushort_t port, void * dst, struct pic_internal * state = (struct pic_internal *)priv_data; if (length != 1) { - PrintError("8259 PIC: Invalid Read length (rd_Slave2)\n"); + PrintError(core->vm_info, core, "8259 PIC: Invalid Read length (rd_Slave2)\n"); return -1; } @@ -449,10 +449,10 @@ static int write_master_port1(struct guest_info * core, ushort_t port, void * sr struct pic_internal * state = (struct pic_internal *)priv_data; uint8_t cw = *(uint8_t *)src; - PrintDebug("8259 PIC: Write master port 1 with 0x%x\n",cw); + PrintDebug(core->vm_info, core, "8259 PIC: Write master port 1 with 0x%x\n",cw); if (length != 1) { - PrintError("8259 PIC: Invalid Write length (wr_Master1)\n"); + PrintError(core->vm_info, core, "8259 PIC: Invalid Write length (wr_Master1)\n"); return -1; } @@ -460,7 +460,7 @@ static int write_master_port1(struct guest_info * core, ushort_t port, void * sr if (IS_ICW1(cw)) { - PrintDebug("8259 PIC: Setting ICW1 = %x (wr_Master1)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Setting ICW1 = %x (wr_Master1)\n", cw); state->master_icw1 = cw; state->master_state = ICW2; @@ -470,7 +470,7 @@ static int write_master_port1(struct guest_info * core, ushort_t port, void * sr // handle the EOI here struct ocw2 * cw2 = (struct ocw2*)&cw; - PrintDebug("8259 PIC: Handling OCW2 = %x (wr_Master1)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Handling OCW2 = %x (wr_Master1)\n", cw); if ((cw2->EOI) && (!cw2->R) && (cw2->SL)) { // specific EOI; @@ -487,42 +487,42 @@ static int write_master_port1(struct guest_info * core, ushort_t port, void * sr } else if ((cw2->EOI) & (!cw2->R) && (!cw2->SL)) { int i; // Non-specific EOI - PrintDebug("8259 PIC: Pre ISR = %x (wr_Master1)\n", state->master_isr); + PrintDebug(core->vm_info, core, "8259 PIC: Pre ISR = %x (wr_Master1)\n", state->master_isr); for (i = 0; i < 8; i++) { if (state->master_isr & (0x01 << i)) { state->master_isr &= ~(0x01 << i); break; } } - PrintDebug("8259 PIC: Post ISR = %x (wr_Master1)\n", state->master_isr); + PrintDebug(core->vm_info, core, "8259 PIC: Post ISR = %x (wr_Master1)\n", state->master_isr); } else if (!(cw2->EOI) && (cw2->R) && (cw2->SL)) { - PrintDebug("8259 PIC: Ignoring set-priority, priorities not implemented (level=%d, wr_Master1)\n", cw2->level); + PrintDebug(core->vm_info, core, "8259 PIC: Ignoring set-priority, priorities not implemented (level=%d, wr_Master1)\n", cw2->level); } else if (!(cw2->EOI) && !(cw2->R) && (cw2->SL)) { - PrintDebug("8259 PIC: Ignoring no-op (level=%d, wr_Master1)\n", cw2->level); + PrintDebug(core->vm_info, core, "8259 PIC: Ignoring no-op (level=%d, wr_Master1)\n", cw2->level); } else { - PrintError("8259 PIC: Command not handled, or in error (wr_Master1)\n"); + PrintError(core->vm_info, core, "8259 PIC: Command not handled, or in error (wr_Master1)\n"); return -1; } if (cw2->EOI) { if (pic_get_intr_number(core, state) != -1) { - PrintError("Interrupt pending after EOI\n"); + PrintError(core->vm_info, core, "Interrupt pending after EOI\n"); } } state->master_ocw2 = cw; } else if (IS_OCW3(cw)) { - PrintDebug("8259 PIC: Handling OCW3 = %x (wr_Master1)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Handling OCW3 = %x (wr_Master1)\n", cw); state->master_ocw3 = cw; } else { - PrintError("8259 PIC: Invalid OCW to PIC (wr_Master1)\n"); - PrintError("8259 PIC: CW=%x\n", cw); + PrintError(core->vm_info, core, "8259 PIC: Invalid OCW to PIC (wr_Master1)\n"); + PrintError(core->vm_info, core, "8259 PIC: CW=%x\n", cw); return -1; } } else { - PrintError("8259 PIC: Invalid PIC State (wr_Master1)\n"); - PrintError("8259 PIC: CW=%x\n", cw); + PrintError(core->vm_info, core, "8259 PIC: Invalid PIC State (wr_Master1)\n"); + PrintError(core->vm_info, core, "8259 PIC: CW=%x\n", cw); return -1; } @@ -533,10 +533,10 @@ static int write_master_port2(struct guest_info * core, ushort_t port, void * sr struct pic_internal * state = (struct pic_internal *)priv_data; uint8_t cw = *(uint8_t *)src; - PrintDebug("8259 PIC: Write master port 2 with 0x%x\n",cw); + PrintDebug(core->vm_info, core, "8259 PIC: Write master port 2 with 0x%x\n",cw); if (length != 1) { - PrintError("8259 PIC: Invalid Write length (wr_Master2)\n"); + PrintError(core->vm_info, core, "8259 PIC: Invalid Write length (wr_Master2)\n"); return -1; } @@ -545,7 +545,7 @@ static int write_master_port2(struct guest_info * core, ushort_t port, void * sr if (state->master_state == ICW2) { struct icw1 * cw1 = (struct icw1 *)&(state->master_icw1); - PrintDebug("8259 PIC: Setting ICW2 = %x (wr_Master2)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Setting ICW2 = %x (wr_Master2)\n", cw); state->master_icw2 = cw; @@ -563,7 +563,7 @@ static int write_master_port2(struct guest_info * core, ushort_t port, void * sr } else if (state->master_state == ICW3) { struct icw1 * cw1 = (struct icw1 *)&(state->master_icw1); - PrintDebug("8259 PIC: Setting ICW3 = %x (wr_Master2)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Setting ICW3 = %x (wr_Master2)\n", cw); state->master_icw3 = cw; @@ -574,15 +574,15 @@ static int write_master_port2(struct guest_info * core, ushort_t port, void * sr } } else if (state->master_state == ICW4) { - PrintDebug("8259 PIC: Setting ICW4 = %x (wr_Master2)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Setting ICW4 = %x (wr_Master2)\n", cw); state->master_icw4 = cw; state->master_state = READY; } else if ((state->master_state == ICW1) || (state->master_state == READY)) { - PrintDebug("8259 PIC: Setting IMR = %x (wr_Master2)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Setting IMR = %x (wr_Master2)\n", cw); state->master_imr = cw; } else { // error - PrintError("8259 PIC: Invalid master PIC State (wr_Master2) (state=%d)\n", + PrintError(core->vm_info, core, "8259 PIC: Invalid master PIC State (wr_Master2) (state=%d)\n", state->master_state); return -1; } @@ -594,18 +594,18 @@ static int write_slave_port1(struct guest_info * core, ushort_t port, void * src struct pic_internal * state = (struct pic_internal *)priv_data; uint8_t cw = *(uint8_t *)src; - PrintDebug("8259 PIC: Write slave port 1 with 0x%x\n",cw); + PrintDebug(core->vm_info, core, "8259 PIC: Write slave port 1 with 0x%x\n",cw); if (length != 1) { // error - PrintError("8259 PIC: Invalid Write length (wr_Slave1)\n"); + PrintError(core->vm_info, core, "8259 PIC: Invalid Write length (wr_Slave1)\n"); return -1; } v3_clear_pending_intr(core); if (IS_ICW1(cw)) { - PrintDebug("8259 PIC: Setting ICW1 = %x (wr_Slave1)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Setting ICW1 = %x (wr_Slave1)\n", cw); state->slave_icw1 = cw; state->slave_state = ICW2; } else if (state->slave_state == READY) { @@ -613,7 +613,7 @@ static int write_slave_port1(struct guest_info * core, ushort_t port, void * src // handle the EOI here struct ocw2 * cw2 = (struct ocw2 *)&cw; - PrintDebug("8259 PIC: Setting OCW2 = %x (wr_Slave1)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Setting OCW2 = %x (wr_Slave1)\n", cw); if ((cw2->EOI) && (!cw2->R) && (cw2->SL)) { // specific EOI; @@ -621,22 +621,22 @@ static int write_slave_port1(struct guest_info * core, ushort_t port, void * src } else if ((cw2->EOI) & (!cw2->R) && (!cw2->SL)) { int i; // Non-specific EOI - PrintDebug("8259 PIC: Pre ISR = %x (wr_Slave1)\n", state->slave_isr); + PrintDebug(core->vm_info, core, "8259 PIC: Pre ISR = %x (wr_Slave1)\n", state->slave_isr); for (i = 0; i < 8; i++) { if (state->slave_isr & (0x01 << i)) { state->slave_isr &= ~(0x01 << i); break; } } - PrintDebug("8259 PIC: Post ISR = %x (wr_Slave1)\n", state->slave_isr); + PrintDebug(core->vm_info, core, "8259 PIC: Post ISR = %x (wr_Slave1)\n", state->slave_isr); } else { - PrintError("8259 PIC: Command not handled or invalid (wr_Slave1)\n"); + PrintError(core->vm_info, core, "8259 PIC: Command not handled or invalid (wr_Slave1)\n"); return -1; } if (cw2->EOI) { if (pic_get_intr_number(core, state) != -1) { - PrintError("Interrupt pending after EOI\n"); + PrintError(core->vm_info, core, "Interrupt pending after EOI\n"); } } @@ -645,14 +645,14 @@ static int write_slave_port1(struct guest_info * core, ushort_t port, void * src state->slave_ocw2 = cw; } else if (IS_OCW3(cw)) { // Basically sets the IRR/ISR read flag - PrintDebug("8259 PIC: Setting OCW3 = %x (wr_Slave1)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Setting OCW3 = %x (wr_Slave1)\n", cw); state->slave_ocw3 = cw; } else { - PrintError("8259 PIC: Invalid command work (wr_Slave1)\n"); + PrintError(core->vm_info, core, "8259 PIC: Invalid command work (wr_Slave1)\n"); return -1; } } else { - PrintError("8259 PIC: Invalid State writing (wr_Slave1)\n"); + PrintError(core->vm_info, core, "8259 PIC: Invalid State writing (wr_Slave1)\n"); return -1; } @@ -663,10 +663,10 @@ static int write_slave_port2(struct guest_info * core, ushort_t port, void * src struct pic_internal * state = (struct pic_internal *)priv_data; uint8_t cw = *(uint8_t *)src; - PrintDebug("8259 PIC: Write slave port 2 with 0x%x\n",cw); + PrintDebug(core->vm_info, core, "8259 PIC: Write slave port 2 with 0x%x\n",cw); if (length != 1) { - PrintError("8259 PIC: Invalid write length (wr_Slave2)\n"); + PrintError(core->vm_info, core, "8259 PIC: Invalid write length (wr_Slave2)\n"); return -1; } @@ -676,7 +676,7 @@ static int write_slave_port2(struct guest_info * core, ushort_t port, void * src if (state->slave_state == ICW2) { struct icw1 * cw1 = (struct icw1 *)&(state->master_icw1); - PrintDebug("8259 PIC: Setting ICW2 = %x (wr_Slave2)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Setting ICW2 = %x (wr_Slave2)\n", cw); state->slave_icw2 = cw; @@ -691,7 +691,7 @@ static int write_slave_port2(struct guest_info * core, ushort_t port, void * src } else if (state->slave_state == ICW3) { struct icw1 * cw1 = (struct icw1 *)&(state->master_icw1); - PrintDebug("8259 PIC: Setting ICW3 = %x (wr_Slave2)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Setting ICW3 = %x (wr_Slave2)\n", cw); state->slave_icw3 = cw; @@ -702,14 +702,14 @@ static int write_slave_port2(struct guest_info * core, ushort_t port, void * src } } else if (state->slave_state == ICW4) { - PrintDebug("8259 PIC: Setting ICW4 = %x (wr_Slave2)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Setting ICW4 = %x (wr_Slave2)\n", cw); state->slave_icw4 = cw; state->slave_state = READY; } else if ((state->slave_state == ICW1) || (state->slave_state == READY)) { - PrintDebug("8259 PIC: Setting IMR = %x (wr_Slave2)\n", cw); + PrintDebug(core->vm_info, core, "8259 PIC: Setting IMR = %x (wr_Slave2)\n", cw); state->slave_imr = cw; } else { - PrintError("8259 PIC: Invalid State at write (wr_Slave2)\n"); + PrintError(core->vm_info, core, "8259 PIC: Invalid State at write (wr_Slave2)\n"); return -1; } @@ -723,7 +723,7 @@ static int read_elcr_port(struct guest_info * core, ushort_t port, void * dst, u struct pic_internal * state = (struct pic_internal *)priv_data; if (length != 1) { - PrintError("ELCR read of invalid length %d\n", length); + PrintError(core->vm_info, core, "ELCR read of invalid length %d\n", length); return -1; } @@ -733,7 +733,7 @@ static int read_elcr_port(struct guest_info * core, ushort_t port, void * dst, u } else if (port == ELCR2_PORT) { *(uint8_t *)dst = state->slave_elcr; } else { - PrintError("Invalid port %x\n", port); + PrintError(core->vm_info, core, "Invalid port %x\n", port); return -1; } @@ -745,7 +745,7 @@ static int write_elcr_port(struct guest_info * core, ushort_t port, void * src, struct pic_internal * state = (struct pic_internal *)priv_data; if (length != 1) { - PrintError("ELCR read of invalid length %d\n", length); + PrintError(core->vm_info, core, "ELCR read of invalid length %d\n", length); return -1; } @@ -755,7 +755,7 @@ static int write_elcr_port(struct guest_info * core, ushort_t port, void * src, } else if (port == ELCR2_PORT) { state->slave_elcr = (*(uint8_t *)src) & state->slave_elcr_mask; } else { - PrintError("Invalid port %x\n", port); + PrintError(core->vm_info, core, "Invalid port %x\n", port); return -1; } @@ -815,7 +815,7 @@ static int pic_save(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; savefailout: - PrintError("Failed to save PIC\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to save PIC\n"); return -1; } @@ -860,7 +860,7 @@ static int pic_load(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; loadfailout: - PrintError("Failed to load PIC\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to load PIC\n"); return -1; } @@ -891,14 +891,14 @@ static int pic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { state = (struct pic_internal *)V3_Malloc(sizeof(struct pic_internal)); if (!state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, state); if (dev == NULL) { - PrintError("Could not add device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not add device %s\n", dev_id); V3_Free(state); return -1; } @@ -946,7 +946,7 @@ static int pic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { ret |= v3_dev_hook_io(dev, ELCR2_PORT, &read_elcr_port, &write_elcr_port); if (ret != 0) { - PrintError("Error hooking io ports\n"); + PrintError(vm, VCORE_NONE, "Error hooking io ports\n"); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/apic.c b/palacios/src/devices/apic.c index 5233038..b6c2416 100644 --- a/palacios/src/devices/apic.c +++ b/palacios/src/devices/apic.c @@ -298,9 +298,9 @@ static void init_apic_state(struct apic_state * apic, uint32_t id) { // same base address regardless of ap or main apic->base_addr_msr.value |= ((uint64_t)DEFAULT_BASE_ADDR); - PrintDebug("apic %u: (init_apic_state): msr=0x%llx\n",id, apic->base_addr_msr.value); + PrintDebug(VM_NONE, VCORE_NONE, "apic %u: (init_apic_state): msr=0x%llx\n",id, apic->base_addr_msr.value); - PrintDebug("apic %u: (init_apic_state): Sizeof Interrupt Request Register %d, should be 32\n", + PrintDebug(VM_NONE, VCORE_NONE, "apic %u: (init_apic_state): Sizeof Interrupt Request Register %d, should be 32\n", id, (uint_t)sizeof(apic->int_req_reg)); memset(apic->int_req_reg, 0, sizeof(apic->int_req_reg)); @@ -360,7 +360,7 @@ static int read_apic_msr(struct guest_info * core, uint_t msr, v3_msr_t * dst, v struct apic_dev_state * apic_dev = (struct apic_dev_state *)priv_data; struct apic_state * apic = &(apic_dev->apics[core->vcpu_id]); - PrintDebug("apic %u: core %u: MSR read\n", apic->lapic_id.val, core->vcpu_id); + PrintDebug(core->vm_info, core, "apic %u: core %u: MSR read\n", apic->lapic_id.val, core->vcpu_id); dst->value = apic->base_addr; @@ -374,11 +374,11 @@ static int write_apic_msr(struct guest_info * core, uint_t msr, v3_msr_t src, vo struct v3_mem_region * old_reg = v3_get_mem_region(core->vm_info, core->vcpu_id, apic->base_addr); - PrintDebug("apic %u: core %u: MSR write\n", apic->lapic_id.val, core->vcpu_id); + PrintDebug(core->vm_info, core, "apic %u: core %u: MSR write\n", apic->lapic_id.val, core->vcpu_id); if (old_reg == NULL) { // uh oh... - PrintError("apic %u: core %u: APIC Base address region does not exit...\n", + PrintError(core->vm_info, core, "apic %u: core %u: APIC Base address region does not exit...\n", apic->lapic_id.val, core->vcpu_id); return -1; } @@ -392,7 +392,7 @@ static int write_apic_msr(struct guest_info * core, uint_t msr, v3_msr_t src, vo if (v3_hook_full_mem(core->vm_info, core->vcpu_id, apic->base_addr, apic->base_addr + PAGE_SIZE_4KB, apic_read, apic_write, apic_dev) == -1) { - PrintError("apic %u: core %u: Could not hook new APIC Base address\n", + PrintError(core->vm_info, core, "apic %u: core %u: Could not hook new APIC Base address\n", apic->lapic_id.val, core->vcpu_id); return -1; @@ -417,10 +417,10 @@ static int activate_apic_irq(struct apic_state * apic, uint32_t irq_num, uint8_t flag = 0x1 << minor_offset; - PrintDebug("apic %u: core %d: Raising APIC IRQ %d\n", apic->lapic_id.val, apic->core->vcpu_id, irq_num); + PrintDebug(VM_NONE, VCORE_NONE, "apic %u: core %d: Raising APIC IRQ %d\n", apic->lapic_id.val, apic->core->vcpu_id, irq_num); if (*req_location & flag) { - PrintDebug("Interrupt %d coallescing\n", irq_num); + PrintDebug(VM_NONE, VCORE_NONE, "Interrupt %d coallescing\n", irq_num); return 0; } @@ -431,7 +431,7 @@ static int activate_apic_irq(struct apic_state * apic, uint32_t irq_num, return 1; } else { - PrintDebug("apic %u: core %d: Interrupt not enabled... %.2x\n", + PrintDebug(VM_NONE, VCORE_NONE, "apic %u: core %d: Interrupt not enabled... %.2x\n", apic->lapic_id.val, apic->core->vcpu_id, *en_location); } @@ -447,7 +447,7 @@ static int add_apic_irq_entry(struct apic_state * apic, uint32_t irq_num, struct irq_queue_entry * entry = NULL; if (irq_num <= 15) { - PrintError("core %d: Attempting to raise an invalid interrupt: %d\n", + PrintError(VM_NONE, VCORE_NONE, "core %d: Attempting to raise an invalid interrupt: %d\n", apic->core->vcpu_id, irq_num); return -1; } @@ -455,7 +455,7 @@ static int add_apic_irq_entry(struct apic_state * apic, uint32_t irq_num, entry = V3_Malloc(sizeof(struct irq_queue_entry)); if (entry == NULL) { - PrintError("Could not allocate irq queue entry\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not allocate irq queue entry\n"); return -1; } @@ -580,7 +580,7 @@ static uint32_t get_apic_tpr(struct apic_state *apic) static void set_apic_tpr(struct apic_state *apic, uint32_t val) { - PrintDebug("Set apic_tpr to 0x%x from apic reg path\n",val); + PrintDebug(VM_NONE, VCORE_NONE, "Set apic_tpr to 0x%x from apic reg path\n",val); apic->core->ctrl_regs.apic_tpr = (uint64_t) val; // see comment in vmm_ctrl_regs.c for how this works } @@ -642,7 +642,7 @@ static int apic_do_eoi(struct guest_info * core, struct apic_state * apic) { uint8_t flag = 0x1 << minor_offset; uint8_t * svc_location = apic->int_svc_reg + major_offset; - PrintDebug("apic %u: core ?: Received APIC EOI for IRQ %d\n", apic->lapic_id.val,isr_irq); + PrintDebug(core->vm_info, core, "apic %u: core ?: Received APIC EOI for IRQ %d\n", apic->lapic_id.val,isr_irq); *svc_location &= ~flag; @@ -654,7 +654,7 @@ static int apic_do_eoi(struct guest_info * core, struct apic_state * apic) { if ((isr_irq == 238) || (isr_irq == 239)) { - PrintDebug("apic %u: core ?: Acking IRQ %d\n", apic->lapic_id.val,isr_irq); + PrintDebug(core->vm_info, core, "apic %u: core ?: Acking IRQ %d\n", apic->lapic_id.val,isr_irq); } if (isr_irq == 238) { @@ -662,7 +662,7 @@ static int apic_do_eoi(struct guest_info * core, struct apic_state * apic) { } #endif } else { - //PrintError("apic %u: core ?: Spurious EOI...\n",apic->lapic_id.val); + //PrintError(core->vm_info, core, "apic %u: core ?: Spurious EOI...\n",apic->lapic_id.val); } return 0; @@ -707,21 +707,21 @@ static int activate_internal_irq(struct apic_state * apic, apic_irq_type_t int_t masked = apic->err_vec_tbl.mask; break; default: - PrintError("apic %u: core ?: Invalid APIC interrupt type\n", apic->lapic_id.val); + PrintError(VM_NONE, VCORE_NONE, "apic %u: core ?: Invalid APIC interrupt type\n", apic->lapic_id.val); return -1; } // interrupt is masked, don't send if (masked == 1) { - PrintDebug("apic %u: core ?: Inerrupt is masked\n", apic->lapic_id.val); + PrintDebug(VM_NONE, VCORE_NONE, "apic %u: core ?: Inerrupt is masked\n", apic->lapic_id.val); return 0; } if (del_mode == IPI_FIXED) { - //PrintDebug("Activating internal APIC IRQ %d\n", vec_num); + //PrintDebug(VM_NONE, VCORE_NONE, "Activating internal APIC IRQ %d\n", vec_num); return add_apic_irq_entry(apic, vec_num, NULL, NULL); } else { - PrintError("apic %u: core ?: Unhandled Delivery Mode\n", apic->lapic_id.val); + PrintError(VM_NONE, VCORE_NONE, "apic %u: core ?: Unhandled Delivery Mode\n", apic->lapic_id.val); return -1; } } @@ -744,11 +744,11 @@ static inline int should_deliver_cluster_ipi(struct apic_dev_state * apic_dev, if (ret == 1) { - PrintDebug("apic %u core %u: accepting clustered IRQ (mda 0x%x == log_dst 0x%x)\n", + PrintDebug(VM_NONE, VCORE_NONE, "apic %u core %u: accepting clustered IRQ (mda 0x%x == log_dst 0x%x)\n", dst_apic->lapic_id.val, dst_core->vcpu_id, mda, dst_apic->log_dst.dst_log_id); } else { - PrintDebug("apic %u core %u: rejecting clustered IRQ (mda 0x%x != log_dst 0x%x)\n", + PrintDebug(VM_NONE, VCORE_NONE, "apic %u core %u: rejecting clustered IRQ (mda 0x%x != log_dst 0x%x)\n", dst_apic->lapic_id.val, dst_core->vcpu_id, mda, dst_apic->log_dst.dst_log_id); } @@ -772,11 +772,11 @@ static inline int should_deliver_flat_ipi(struct apic_dev_state * apic_dev, if (ret == 1) { - PrintDebug("apic %u core %u: accepting flat IRQ (mda 0x%x == log_dst 0x%x)\n", + PrintDebug(VM_NONE, VCORE_NONE, "apic %u core %u: accepting flat IRQ (mda 0x%x == log_dst 0x%x)\n", dst_apic->lapic_id.val, dst_core->vcpu_id, mda, dst_apic->log_dst.dst_log_id); } else { - PrintDebug("apic %u core %u: rejecting flat IRQ (mda 0x%x != log_dst 0x%x)\n", + PrintDebug(VM_NONE, VCORE_NONE, "apic %u core %u: rejecting flat IRQ (mda 0x%x != log_dst 0x%x)\n", dst_apic->lapic_id.val, dst_core->vcpu_id, mda, dst_apic->log_dst.dst_log_id); } @@ -820,7 +820,7 @@ static int should_deliver_ipi(struct apic_dev_state * apic_dev, if (ret == -1) { - PrintError("apic %u core %u: invalid destination format register value 0x%x for logical mode delivery.\n", + PrintError(VM_NONE, VCORE_NONE, "apic %u core %u: invalid destination format register value 0x%x for logical mode delivery.\n", dst_apic->lapic_id.val, dst_core->vcpu_id, dst_apic->dst_fmt.model); } @@ -846,12 +846,12 @@ static int deliver_ipi(struct apic_state * src_apic, // lowest priority - // caller needs to have decided which apic to deliver to! - PrintDebug("delivering IRQ %d to core %u\n", ipi->vector, dst_core->vcpu_id); + PrintDebug(VM_NONE, VCORE_NONE, "delivering IRQ %d to core %u\n", ipi->vector, dst_core->vcpu_id); add_apic_irq_entry(dst_apic, ipi->vector, ipi->ack, ipi->private_data); if (dst_apic != src_apic) { - PrintDebug(" non-local core with new interrupt, forcing it to exit now\n"); + PrintDebug(VM_NONE, VCORE_NONE, " non-local core with new interrupt, forcing it to exit now\n"); v3_interrupt_cpu(dst_core->vm_info, dst_core->pcpu_id, 0); } @@ -859,13 +859,13 @@ static int deliver_ipi(struct apic_state * src_apic, } case IPI_INIT: { - PrintDebug(" INIT delivery to core %u\n", dst_core->vcpu_id); + PrintDebug(VM_NONE, VCORE_NONE, " INIT delivery to core %u\n", dst_core->vcpu_id); // TODO: any APIC reset on dest core (shouldn't be needed, but not sure...) // Sanity check if (dst_apic->ipi_state != INIT_ST) { - PrintError(" Warning: core %u is not in INIT state (mode = %d), ignored (assuming this is the deassert)\n", + PrintError(VM_NONE, VCORE_NONE, " Warning: core %u is not in INIT state (mode = %d), ignored (assuming this is the deassert)\n", dst_core->vcpu_id, dst_apic->ipi_state); // Only a warning, since INIT INIT SIPI is common break; @@ -880,7 +880,7 @@ static int deliver_ipi(struct apic_state * src_apic, // in both cases, it will quickly notice this transition // in particular, we should not need to force an exit here - PrintDebug(" INIT delivery done\n"); + PrintDebug(VM_NONE, VCORE_NONE, " INIT delivery done\n"); break; } @@ -888,14 +888,14 @@ static int deliver_ipi(struct apic_state * src_apic, // Sanity check if (dst_apic->ipi_state != SIPI) { - PrintError(" core %u is not in SIPI state (mode = %d), ignored!\n", + PrintError(VM_NONE, VCORE_NONE, " core %u is not in SIPI state (mode = %d), ignored!\n", dst_core->vcpu_id, dst_apic->ipi_state); break; } v3_reset_vm_core(dst_core, ipi->vector); - PrintDebug(" SIPI delivery (0x%x -> 0x%x:0x0) to core %u\n", + PrintDebug(VM_NONE, VCORE_NONE, " SIPI delivery (0x%x -> 0x%x:0x0) to core %u\n", ipi->vector, dst_core->segments.cs.selector, dst_core->vcpu_id); // Maybe need to adjust the APIC? @@ -905,7 +905,7 @@ static int deliver_ipi(struct apic_state * src_apic, // As with INIT, we should not need to do anything else - PrintDebug(" SIPI delivery done\n"); + PrintDebug(VM_NONE, VCORE_NONE, " SIPI delivery done\n"); break; } @@ -922,7 +922,7 @@ static int deliver_ipi(struct apic_state * src_apic, case IPI_RES1: // reserved case IPI_NMI: default: - PrintError("IPI %d delivery is unsupported\n", ipi->mode); + PrintError(VM_NONE, VCORE_NONE, "IPI %d delivery is unsupported\n", ipi->mode); return -1; } @@ -963,7 +963,7 @@ static int route_ipi(struct apic_dev_state * apic_dev, struct apic_state * dest_apic = NULL; - PrintDebug("apic: IPI %s %u from apic %p to %s %s %u\n", + PrintDebug(VM_NONE, VCORE_NONE, "apic: IPI %s %u from apic %p to %s %s %u\n", deliverymode_str[ipi->mode], ipi->vector, src_apic, @@ -980,17 +980,17 @@ static int route_ipi(struct apic_dev_state * apic_dev, dest_apic = find_physical_apic(apic_dev, ipi->dst); if (dest_apic == NULL) { - PrintError("apic: Attempted send to unregistered apic id=%u\n", ipi->dst); + PrintError(VM_NONE, VCORE_NONE, "apic: Attempted send to unregistered apic id=%u\n", ipi->dst); return -1; } if (deliver_ipi(src_apic, dest_apic, ipi) == -1) { - PrintError("apic: Could not deliver IPI\n"); + PrintError(VM_NONE, VCORE_NONE, "apic: Could not deliver IPI\n"); return -1; } - PrintDebug("apic: done\n"); + PrintDebug(VM_NONE, VCORE_NONE, "apic: done\n"); } else if (ipi->logical == APIC_DEST_LOGICAL) { @@ -1012,12 +1012,12 @@ static int route_ipi(struct apic_dev_state * apic_dev, if (del_flag == -1) { - PrintError("apic: Error checking delivery mode\n"); + PrintError(VM_NONE, VCORE_NONE, "apic: Error checking delivery mode\n"); return -1; } else if (del_flag == 1) { if (deliver_ipi(src_apic, dest_apic, ipi) == -1) { - PrintError("apic: Error: Could not deliver IPI\n"); + PrintError(VM_NONE, VCORE_NONE, "apic: Error: Could not deliver IPI\n"); return -1; } } @@ -1038,7 +1038,7 @@ static int route_ipi(struct apic_dev_state * apic_dev, del_flag = should_deliver_ipi(apic_dev, dest_apic->core, dest_apic, mda); if (del_flag == -1) { - PrintError("apic: Error checking delivery mode\n"); + PrintError(VM_NONE, VCORE_NONE, "apic: Error checking delivery mode\n"); return -1; } else if (del_flag == 1) { @@ -1065,13 +1065,13 @@ static int route_ipi(struct apic_dev_state * apic_dev, // now we will deliver to the best one if it exists if (!cur_best_apic) { - PrintDebug("apic: lowest priority deliver, but no destinations!\n"); + PrintDebug(VM_NONE, VCORE_NONE, "apic: lowest priority deliver, but no destinations!\n"); } else { if (deliver_ipi(src_apic, cur_best_apic, ipi) == -1) { - PrintError("apic: Error: Could not deliver IPI\n"); + PrintError(VM_NONE, VCORE_NONE, "apic: Error: Could not deliver IPI\n"); return -1; } - //V3_Print("apic: logical, lowest priority delivery to apic %u\n",cur_best_apic->lapic_id.val); + //V3_Print(VM_NONE, VCORE_NONE, "apic: logical, lowest priority delivery to apic %u\n",cur_best_apic->lapic_id.val); } } } @@ -1081,7 +1081,7 @@ static int route_ipi(struct apic_dev_state * apic_dev, case APIC_SHORTHAND_SELF: // self if (src_apic == NULL) { /* this is not an apic, but it's trying to send to itself??? */ - PrintError("apic: Sending IPI to self from generic IPI sender\n"); + PrintError(VM_NONE, VCORE_NONE, "apic: Sending IPI to self from generic IPI sender\n"); break; } @@ -1089,14 +1089,14 @@ static int route_ipi(struct apic_dev_state * apic_dev, if (ipi->logical == APIC_DEST_PHYSICAL) { /* physical delivery */ if (deliver_ipi(src_apic, src_apic, ipi) == -1) { - PrintError("apic: Could not deliver IPI to self (physical)\n"); + PrintError(VM_NONE, VCORE_NONE, "apic: Could not deliver IPI to self (physical)\n"); return -1; } } else if (ipi->logical == APIC_DEST_LOGICAL) { /* logical delivery */ - PrintError("apic: use of logical delivery in self (untested)\n"); + PrintError(VM_NONE, VCORE_NONE, "apic: use of logical delivery in self (untested)\n"); if (deliver_ipi(src_apic, src_apic, ipi) == -1) { - PrintError("apic: Could not deliver IPI to self (logical)\n"); + PrintError(VM_NONE, VCORE_NONE, "apic: Could not deliver IPI to self (logical)\n"); return -1; } } @@ -1114,7 +1114,7 @@ static int route_ipi(struct apic_dev_state * apic_dev, if ((dest_apic != src_apic) || (ipi->dst_shorthand == APIC_SHORTHAND_ALL)) { if (deliver_ipi(src_apic, dest_apic, ipi) == -1) { - PrintError("apic: Error: Could not deliver IPI\n"); + PrintError(VM_NONE, VCORE_NONE, "apic: Error: Could not deliver IPI\n"); return -1; } } @@ -1123,7 +1123,7 @@ static int route_ipi(struct apic_dev_state * apic_dev, break; } default: - PrintError("apic: Error routing IPI, invalid Mode (%d)\n", ipi->dst_shorthand); + PrintError(VM_NONE, VCORE_NONE, "apic: Error routing IPI, invalid Mode (%d)\n", ipi->dst_shorthand); return -1; } @@ -1140,11 +1140,11 @@ static int apic_read(struct guest_info * core, addr_t guest_addr, void * dst, ui uint32_t val = 0; - PrintDebug("apic %u: core %u: at %p: Read apic address space (%p)\n", + PrintDebug(core->vm_info, core, "apic %u: core %u: at %p: Read apic address space (%p)\n", apic->lapic_id.val, core->vcpu_id, apic, (void *)guest_addr); if (msr->apic_enable == 0) { - PrintError("apic %u: core %u: Read from APIC address space with disabled APIC, apic msr=0x%llx\n", + PrintError(core->vm_info, core, "apic %u: core %u: Read from APIC address space with disabled APIC, apic msr=0x%llx\n", apic->lapic_id.val, core->vcpu_id, apic->base_addr_msr.value); return -1; } @@ -1152,7 +1152,7 @@ static int apic_read(struct guest_info * core, addr_t guest_addr, void * dst, ui /* Because "May not be supported" doesn't matter to Linux developers... */ /* if (length != 4) { */ - /* PrintError("Invalid apic read length (%d)\n", length); */ + /* PrintError(core->vm_info, core, "Invalid apic read length (%d)\n", length); */ /* return -1; */ /* } */ @@ -1160,7 +1160,7 @@ static int apic_read(struct guest_info * core, addr_t guest_addr, void * dst, ui case EOI_OFFSET: // Well, only an idiot would read from a architectural write only register // Oh, Hello Linux. - // PrintError("Attempting to read from write only register\n"); + // PrintError(core->vm_info, core, "Attempting to read from write only register\n"); // return -1; break; @@ -1357,7 +1357,7 @@ static int apic_read(struct guest_info * core, addr_t guest_addr, void * dst, ui case SEOI_OFFSET: default: - PrintError("apic %u: core %u: Read from Unhandled APIC Register: %x (getting zero)\n", + PrintError(core->vm_info, core, "apic %u: core %u: Read from Unhandled APIC Register: %x (getting zero)\n", apic->lapic_id.val, core->vcpu_id, (uint32_t)reg_addr); return -1; } @@ -1380,12 +1380,12 @@ static int apic_read(struct guest_info * core, addr_t guest_addr, void * dst, ui *val_ptr = val; } else { - PrintError("apic %u: core %u: Invalid apic read length (%d)\n", + PrintError(core->vm_info, core, "apic %u: core %u: Invalid apic read length (%d)\n", apic->lapic_id.val, core->vcpu_id, length); return -1; } - PrintDebug("apic %u: core %u: Read finished (val=%x)\n", + PrintDebug(core->vm_info, core, "apic %u: core %u: Read finished (val=%x)\n", apic->lapic_id.val, core->vcpu_id, *(uint32_t *)dst); return length; @@ -1403,21 +1403,21 @@ static int apic_write(struct guest_info * core, addr_t guest_addr, void * src, u uint32_t op_val = *(uint32_t *)src; addr_t flags = 0; - PrintDebug("apic %u: core %u: at %p and priv_data is at %p\n", + PrintDebug(core->vm_info, core, "apic %u: core %u: at %p and priv_data is at %p\n", apic->lapic_id.val, core->vcpu_id, apic, priv_data); - PrintDebug("apic %u: core %u: write to address space (%p) (val=%x)\n", + PrintDebug(core->vm_info, core, "apic %u: core %u: write to address space (%p) (val=%x)\n", apic->lapic_id.val, core->vcpu_id, (void *)guest_addr, *(uint32_t *)src); if (msr->apic_enable == 0) { - PrintError("apic %u: core %u: Write to APIC address space with disabled APIC, apic msr=0x%llx\n", + PrintError(core->vm_info, core, "apic %u: core %u: Write to APIC address space with disabled APIC, apic msr=0x%llx\n", apic->lapic_id.val, core->vcpu_id, apic->base_addr_msr.value); return -1; } if (length != 4) { - PrintError("apic %u: core %u: Invalid apic write length (%d)\n", + PrintError(core->vm_info, core, "apic %u: core %u: Invalid apic write length (%d)\n", apic->lapic_id.val, length, core->vcpu_id); return -1; } @@ -1453,14 +1453,14 @@ static int apic_write(struct guest_info * core, addr_t guest_addr, void * src, u case PPR_OFFSET: case EXT_APIC_FEATURE_OFFSET: - PrintError("apic %u: core %u: Attempting to write to read only register %p (error)\n", + PrintError(core->vm_info, core, "apic %u: core %u: Attempting to write to read only register %p (error)\n", apic->lapic_id.val, core->vcpu_id, (void *)reg_addr); break; // Data registers case APIC_ID_OFFSET: - //V3_Print("apic %u: core %u: my id is being changed to %u\n", + //V3_Print(core->vm_info, core, "apic %u: core %u: my id is being changed to %u\n", // apic->lapic_id.val, core->vcpu_id, op_val); apic->lapic_id.val = op_val; @@ -1469,7 +1469,7 @@ static int apic_write(struct guest_info * core, addr_t guest_addr, void * src, u set_apic_tpr(apic,op_val); break; case LDR_OFFSET: - PrintDebug("apic %u: core %u: setting log_dst.val to 0x%x\n", + PrintDebug(core->vm_info, core, "apic %u: core %u: setting log_dst.val to 0x%x\n", apic->lapic_id.val, core->vcpu_id, op_val); flags = v3_lock_irqsave(apic_dev->state_lock); apic->log_dst.val = op_val; @@ -1512,7 +1512,7 @@ static int apic_write(struct guest_info * core, addr_t guest_addr, void * src, u apic->tmr_cur_cnt = op_val; break; case TMR_DIV_CFG_OFFSET: - PrintDebug("apic %u: core %u: setting tmr_div_cfg to 0x%x\n", + PrintDebug(core->vm_info, core, "apic %u: core %u: setting tmr_div_cfg to 0x%x\n", apic->lapic_id.val, core->vcpu_id, op_val); apic->tmr_div_cfg.val = op_val; break; @@ -1582,12 +1582,12 @@ static int apic_write(struct guest_info * core, addr_t guest_addr, void * src, u tmp_ipi.private_data = NULL; - // V3_Print("apic %u: core %u: sending cmd 0x%llx to apic %u\n", + // V3_Print(core->vm_info, core, "apic %u: core %u: sending cmd 0x%llx to apic %u\n", // apic->lapic_id.val, core->vcpu_id, // apic->int_cmd.val, apic->int_cmd.dst); if (route_ipi(apic_dev, apic, &tmp_ipi) == -1) { - PrintError("IPI Routing failure\n"); + PrintError(core->vm_info, core, "IPI Routing failure\n"); return -1; } @@ -1595,20 +1595,20 @@ static int apic_write(struct guest_info * core, addr_t guest_addr, void * src, u } case INT_CMD_HI_OFFSET: { apic->int_cmd.hi = op_val; - //V3_Print("apic %u: core %u: writing command high=0x%x\n", apic->lapic_id.val, core->vcpu_id,apic->int_cmd.hi); + //V3_Print(core->vm_info, core, "apic %u: core %u: writing command high=0x%x\n", apic->lapic_id.val, core->vcpu_id,apic->int_cmd.hi); break; } // Unhandled Registers case EXT_APIC_CMD_OFFSET: case SEOI_OFFSET: default: - PrintError("apic %u: core %u: Write to Unhandled APIC Register: %x (ignored)\n", + PrintError(core->vm_info, core, "apic %u: core %u: Write to Unhandled APIC Register: %x (ignored)\n", apic->lapic_id.val, core->vcpu_id, (uint32_t)reg_addr); return -1; } - PrintDebug("apic %u: core %u: Write finished\n", apic->lapic_id.val, core->vcpu_id); + PrintDebug(core->vm_info, core, "apic %u: core %u: Write finished\n", apic->lapic_id.val, core->vcpu_id); return length; @@ -1632,7 +1632,7 @@ static int apic_intr_pending(struct guest_info * core, void * private_data) { req_irq = get_highest_irr(apic); svc_irq = get_highest_isr(apic); - // PrintDebug("apic %u: core %u: req_irq=%d, svc_irq=%d\n",apic->lapic_id.val,info->vcpu_id,req_irq,svc_irq); + // PrintDebug(core->vm_info, core, "apic %u: core %u: req_irq=%d, svc_irq=%d\n",apic->lapic_id.val,info->vcpu_id,req_irq,svc_irq); if ((req_irq >= 0) && @@ -1717,7 +1717,7 @@ static int apic_begin_irq(struct guest_info * core, void * private_data, int irq *req_location &= ~flag; } else { // do nothing... - //PrintDebug("apic %u: core %u: begin irq for %d ignored since I don't own it\n", + //PrintDebug(core->vm_info, core, "apic %u: core %u: begin irq for %d ignored since I don't own it\n", // apic->lapic_id.val, core->vcpu_id, irq); } @@ -1732,18 +1732,18 @@ static void apic_inject_timer_intr(struct guest_info *core, struct apic_dev_state * apic_dev = (struct apic_dev_state *)(priv_data); struct apic_state * apic = &(apic_dev->apics[core->vcpu_id]); // raise irq - PrintDebug("apic %u: core %u: Raising APIC Timer interrupt (periodic=%d) (icnt=%d)\n", + PrintDebug(core->vm_info, core, "apic %u: core %u: Raising APIC Timer interrupt (periodic=%d) (icnt=%d)\n", apic->lapic_id.val, core->vcpu_id, apic->tmr_vec_tbl.tmr_mode, apic->tmr_init_cnt); if (apic_intr_pending(core, priv_data)) { - PrintDebug("apic %u: core %u: Overriding pending IRQ %d\n", + PrintDebug(core->vm_info, core, "apic %u: core %u: Overriding pending IRQ %d\n", apic->lapic_id.val, core->vcpu_id, apic_get_intr_number(core, priv_data)); } if (activate_internal_irq(apic, APIC_TMR_INT) == -1) { - PrintError("apic %u: core %u: Could not raise Timer interrupt\n", + PrintError(core->vm_info, core, "apic %u: core %u: Could not raise Timer interrupt\n", apic->lapic_id.val, core->vcpu_id); } @@ -1776,7 +1776,7 @@ static void apic_update_time(struct guest_info * core, if ((apic->tmr_init_cnt == 0) || ( (apic->tmr_vec_tbl.tmr_mode == APIC_TMR_ONESHOT) && (apic->tmr_cur_cnt == 0))) { - //PrintDebug("apic %u: core %u: APIC timer not yet initialized\n",apic->lapic_id.val,info->vcpu_id); + //PrintDebug(core->vm_info, core, "apic %u: core %u: APIC timer not yet initialized\n",apic->lapic_id.val,info->vcpu_id); return; } @@ -1807,19 +1807,19 @@ static void apic_update_time(struct guest_info * core, shift_num = 7; break; default: - PrintError("apic %u: core %u: Invalid Timer Divider configuration\n", + PrintError(core->vm_info, core, "apic %u: core %u: Invalid Timer Divider configuration\n", apic->lapic_id.val, core->vcpu_id); return; } tmr_ticks = cpu_cycles >> shift_num; - // PrintDebug("Timer Ticks: %p\n", (void *)tmr_ticks); + // PrintDebug(core->vm_info, core, "Timer Ticks: %p\n", (void *)tmr_ticks); if (tmr_ticks < apic->tmr_cur_cnt) { apic->tmr_cur_cnt -= tmr_ticks; #ifdef V3_CONFIG_APIC_ENQUEUE_MISSED_TMR_IRQS if (apic->missed_ints && !apic_intr_pending(core, priv_data)) { - PrintDebug("apic %u: core %u: Injecting queued APIC timer interrupt.\n", + PrintDebug(core->vm_info, core, "apic %u: core %u: Injecting queued APIC timer interrupt.\n", apic->lapic_id.val, core->vcpu_id); apic_inject_timer_intr(core, priv_data); apic->missed_ints--; @@ -1980,7 +1980,7 @@ static int apic_save(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; savefailout: - PrintError("Failed to save apic\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to save apic\n"); return -1; } @@ -2080,7 +2080,7 @@ static int apic_load(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; loadfailout: - PrintError("Failed to load apic\n"); + PrintError(VM_NONE,VCORE_NONE, "Failed to load apic\n"); return -1; } @@ -2102,14 +2102,14 @@ static int apic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct apic_dev_state * apic_dev = NULL; int i = 0; - PrintDebug("apic: creating an APIC for each core\n"); + PrintDebug(vm, VCORE_NONE, "apic: creating an APIC for each core\n"); apic_dev = (struct apic_dev_state *)V3_Malloc(sizeof(struct apic_dev_state) + sizeof(struct apic_state) * vm->num_cores); if (!apic_dev) { - PrintError("Failed to allocate space for APIC\n"); + PrintError(vm, VCORE_NONE, "Failed to allocate space for APIC\n"); return -1; } @@ -2119,7 +2119,7 @@ static int apic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, apic_dev); if (dev == NULL) { - PrintError("apic: Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "apic: Could not attach device %s\n", dev_id); V3_Free(apic_dev); return -1; } @@ -2138,26 +2138,26 @@ static int apic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { apic->timer = v3_add_timer(core, &timer_ops, apic_dev); if (apic->timer == NULL) { - PrintError("APIC: Failed to attach timer to core %d\n", i); + PrintError(vm, VCORE_NONE,"APIC: Failed to attach timer to core %d\n", i); v3_remove_device(dev); return -1; } v3_hook_full_mem(vm, core->vcpu_id, apic->base_addr, apic->base_addr + PAGE_SIZE_4KB, apic_read, apic_write, apic_dev); - PrintDebug("apic %u: (setup device): done, my id is %u\n", i, apic->lapic_id.val); + PrintDebug(vm, VCORE_NONE, "apic %u: (setup device): done, my id is %u\n", i, apic->lapic_id.val); } #ifdef V3_CONFIG_DEBUG_APIC for (i = 0; i < vm->num_cores; i++) { struct apic_state * apic = &(apic_dev->apics[i]); - PrintDebug("apic: sanity check: apic %u (at %p) has id %u and msr value %llx and core at %p\n", + PrintDebug(vm, VCORE_NONE, "apic: sanity check: apic %u (at %p) has id %u and msr value %llx and core at %p\n", i, apic, apic->lapic_id.val, apic->base_addr_msr.value,apic->core); } #endif - PrintDebug("apic: priv_data is at %p\n", apic_dev); + PrintDebug(vm, VCORE_NONE, "apic: priv_data is at %p\n", apic_dev); v3_hook_msr(vm, BASE_ADDR_MSR, read_apic_msr, write_apic_msr, apic_dev); diff --git a/palacios/src/devices/ata.h b/palacios/src/devices/ata.h index 7eb901c..49637c1 100644 --- a/palacios/src/devices/ata.h +++ b/palacios/src/devices/ata.h @@ -114,12 +114,12 @@ static int ata_read(struct ide_internal * ide, struct ide_channel * channel, uin drive->hd_state.accessed = 1; } - PrintDebug("Reading Drive LBA=%d (count=%d)\n", (uint32_t)(drive->current_lba), sect_cnt); + PrintDebug(VM_NONE, VCORE_NONE,"Reading Drive LBA=%d (count=%d)\n", (uint32_t)(drive->current_lba), sect_cnt); int ret = drive->ops->read(dst, drive->current_lba * HD_SECTOR_SIZE, sect_cnt * HD_SECTOR_SIZE, drive->private_data); if (ret == -1) { - PrintError("IDE: Error reading HD block (LBA=%p)\n", (void *)(addr_t)(drive->current_lba)); + PrintError(VM_NONE, VCORE_NONE,"IDE: Error reading HD block (LBA=%p)\n", (void *)(addr_t)(drive->current_lba)); return -1; } @@ -130,12 +130,12 @@ static int ata_read(struct ide_internal * ide, struct ide_channel * channel, uin static int ata_write(struct ide_internal * ide, struct ide_channel * channel, uint8_t * src, uint_t sect_cnt) { struct ide_drive * drive = get_selected_drive(channel); - PrintDebug("Writing Drive LBA=%d (count=%d)\n", (uint32_t)(drive->current_lba), sect_cnt); + PrintDebug(VM_NONE, VCORE_NONE,"Writing Drive LBA=%d (count=%d)\n", (uint32_t)(drive->current_lba), sect_cnt); int ret = drive->ops->write(src, drive->current_lba * HD_SECTOR_SIZE, sect_cnt * HD_SECTOR_SIZE, drive->private_data); if (ret == -1) { - PrintError("IDE: Error writing HD block (LBA=%p)\n", (void *)(addr_t)(drive->current_lba)); + PrintError(VM_NONE, VCORE_NONE,"IDE: Error writing HD block (LBA=%p)\n", (void *)(addr_t)(drive->current_lba)); return -1; } @@ -169,7 +169,7 @@ static int ata_get_lba(struct ide_internal * ide, struct ide_channel * channel, if ((lba_addr.addr + sect_cnt) > drive->ops->get_capacity(drive->private_data) / HD_SECTOR_SIZE) { - PrintError("IDE: request size exceeds disk capacity (lba=%d) (sect_cnt=%d) (ReadEnd=%d) (capacity=%p)\n", + PrintError(VM_NONE, VCORE_NONE,"IDE: request size exceeds disk capacity (lba=%d) (sect_cnt=%d) (ReadEnd=%d) (capacity=%p)\n", lba_addr.addr, sect_cnt, lba_addr.addr + (sect_cnt * HD_SECTOR_SIZE), (void *)(addr_t)(drive->ops->get_capacity(drive->private_data))); @@ -194,7 +194,7 @@ static int ata_read_sectors(struct ide_internal * ide, struct ide_channel * cha if (ata_read(ide, channel, drive->data_buf, 1) == -1) { - PrintError("Could not read disk sector\n"); + PrintError(VM_NONE, VCORE_NONE,"Could not read disk sector\n"); return -1; } @@ -214,7 +214,7 @@ static int ata_read_sectors(struct ide_internal * ide, struct ide_channel * cha ide_raise_irq(ide, channel); - PrintDebug("Returning from read sectors\n"); + PrintDebug(VM_NONE, VCORE_NONE,"Returning from read sectors\n"); return 0; } @@ -226,7 +226,7 @@ static int ata_read_sectors_ext(struct ide_internal * ide, struct ide_channel * // The if the sector count == 0 then read 256 sectors (cast up to handle that value) //uint32_t sector_count = (drive->sector_count == 0) ? 256 : drive->sector_count; - PrintError("Extended Sector read not implemented\n"); + PrintError(VM_NONE, VCORE_NONE, "Extended Sector read not implemented\n"); return -1; } diff --git a/palacios/src/devices/atapi.h b/palacios/src/devices/atapi.h index b41e9df..029229b 100644 --- a/palacios/src/devices/atapi.h +++ b/palacios/src/devices/atapi.h @@ -33,7 +33,7 @@ static int atapi_update_req_len(struct ide_internal * ide, struct ide_channel * //PrintDebug("\tUpdating request length (pre=%d)\n", drive->req_len); if (drive->req_len == 0) { - PrintError("ATAPI Error: request of length 0\n"); + PrintError(VM_NONE,VCORE_NONE, "ATAPI Error: request of length 0\n"); return -1; } @@ -137,7 +137,7 @@ static int atapi_read_chunk(struct ide_internal * ide, struct ide_channel * chan ATAPI_BLOCK_SIZE, drive->private_data); if (ret == -1) { - PrintError("IDE: Error reading CD block (LBA=%p)\n", (void *)(addr_t)(drive->current_lba)); + PrintError(VM_NONE,VCORE_NONE, "IDE: Error reading CD block (LBA=%p)\n", (void *)(addr_t)(drive->current_lba)); return -1; } @@ -159,7 +159,7 @@ static int atapi_update_data_buf(struct ide_internal * ide, struct ide_channel * return atapi_read_chunk(ide, channel); default: - PrintError("Unhandled ATAPI command in update buffer %x\n", drive->cd_state.atapi_cmd); + PrintError(VM_NONE,VCORE_NONE, "Unhandled ATAPI command in update buffer %x\n", drive->cd_state.atapi_cmd); return -1; } @@ -174,7 +174,7 @@ static int atapi_read10(struct guest_info * core, uint32_t lba = be_to_le_32(cmd->lba); uint16_t xfer_len = be_to_le_16(cmd->xfer_len); - PrintDebug("READ10: XferLen=%d ; LBA=%x \n", xfer_len, lba ); + PrintDebug(core->vm_info, core, "READ10: XferLen=%d ; LBA=%x \n", xfer_len, lba ); /* Check if cd is ready * if not: atapi_cmd_error(... ATAPI_SEN_NOT_RDY, ASC_MEDIA_NOT_PRESENT) @@ -186,7 +186,7 @@ static int atapi_read10(struct guest_info * core, } if ((lba + xfer_len) > (drive->ops->get_capacity(drive->private_data) / ATAPI_BLOCK_SIZE)) { - PrintError("IDE: xfer len exceeded capacity (lba=%d) (xfer_len=%d) (ReadEnd=%d) (capacity=%d)\n", + PrintError(core->vm_info, core, "IDE: xfer len exceeded capacity (lba=%d) (xfer_len=%d) (ReadEnd=%d) (capacity=%d)\n", lba, xfer_len, lba + xfer_len, (uint32_t)drive->ops->get_capacity(drive->private_data)); atapi_cmd_error(ide, channel, ATAPI_SEN_ILL_REQ, ASC_LOG_BLK_OOR); @@ -194,7 +194,7 @@ static int atapi_read10(struct guest_info * core, return 0; } - // PrintDebug("Reading %d blocks from LBA 0x%x\n", xfer_len, lba); + // PrintDebug(core->vm_info, core, "Reading %d blocks from LBA 0x%x\n", xfer_len, lba); drive->current_lba = lba; // Update the request length value in the cylinder registers @@ -205,7 +205,7 @@ static int atapi_read10(struct guest_info * core, if (channel->dma_status.active == 1) { if (dma_read(core, ide, channel) == -1) { - PrintError("Error in DMA read for CD Read10 command\n"); + PrintError(core->vm_info, core, "Error in DMA read for CD Read10 command\n"); return -1; } } @@ -213,7 +213,7 @@ static int atapi_read10(struct guest_info * core, } if (atapi_read_chunk(ide, channel) == -1) { - PrintError("IDE: Could not read initial chunk from CD\n"); + PrintError(core->vm_info, core, "IDE: Could not read initial chunk from CD\n"); return -1; } @@ -221,7 +221,7 @@ static int atapi_read10(struct guest_info * core, // This is weird... The host sets this value to say what it would like to transfer, // if it is larger than the correct size, the device shrinks it to the correct size if (atapi_update_req_len(ide, channel, ATAPI_BLOCK_SIZE) == -1) { - PrintError("Could not update initial request length\n"); + PrintError(core->vm_info, core, "Could not update initial request length\n"); return -1; } @@ -270,7 +270,7 @@ static int atapi_get_config(struct ide_internal * ide, struct ide_channel * chan xfer_len = alloc_len; } - V3_Print("ATAPI Get config: xfer_len=%d\b", xfer_len); + V3_Print(VM_NONE, VCORE_NONE, "ATAPI Get config: xfer_len=%d\b", xfer_len); atapi_setup_cmd_resp(ide, channel, xfer_len); @@ -303,7 +303,7 @@ static int atapi_read_toc(struct ide_internal * ide, struct ide_channel * channe atapi_setup_cmd_resp(ide, channel, xfer_len); } else { - PrintError("Unhandled Format (%d)\n", cmd->format); + PrintError(VM_NONE, VCORE_NONE, "Unhandled Format (%d)\n", cmd->format); return -1; } @@ -317,8 +317,8 @@ static int atapi_mode_sense_cur_values(struct ide_internal * ide, struct ide_cha struct atapi_mode_sense_hdr * hdr = (struct atapi_mode_sense_hdr *)(drive->data_buf); uint_t resp_len = sizeof(struct atapi_mode_sense_hdr); uint16_t alloc_len = be_to_le_16(sense_cmd->alloc_len); - PrintDebug("Page Code: %x\n", sense_cmd->page_code); - PrintDebug("Alloc len: %d\n", alloc_len); + PrintDebug(VM_NONE, VCORE_NONE,"Page Code: %x\n", sense_cmd->page_code); + PrintDebug(VM_NONE, VCORE_NONE,"Alloc len: %d\n", alloc_len); switch (sense_cmd->page_code) { @@ -332,7 +332,7 @@ static int atapi_mode_sense_cur_values(struct ide_internal * ide, struct ide_cha resp_len += sizeof(struct atapi_error_recovery); - PrintError("mode sense (error recovery) resp_len=%d\n", resp_len); + PrintError(VM_NONE, VCORE_NONE,"mode sense (error recovery) resp_len=%d\n", resp_len); hdr->mode_data_len = le_to_be_16(resp_len - 2); @@ -345,7 +345,7 @@ static int atapi_mode_sense_cur_values(struct ide_internal * ide, struct ide_cha - PrintError("mode sense (caps/mechs v2) resp_len=%d\n", resp_len); + PrintError(VM_NONE, VCORE_NONE, "mode sense (caps/mechs v2) resp_len=%d\n", resp_len); *((uint16_t *)buf) = le_to_be_16(28 + 6); buf[2] = 0x70; @@ -394,7 +394,7 @@ static int atapi_mode_sense_cur_values(struct ide_internal * ide, struct ide_cha hdr->mode_data_len = le_to_be_16(resp_len - 2); - PrintError("mode sense (caps/mechs v2) resp_len=%d\n", resp_len); + PrintError(VM_NONE, VCORE_NONE, "mode sense (caps/mechs v2) resp_len=%d\n", resp_len); caps->page_code = 0x2a; caps->page_len = 0x12; @@ -424,7 +424,7 @@ static int atapi_mode_sense_cur_values(struct ide_internal * ide, struct ide_cha case 0x0e: case 0x3f: default: - PrintError("ATAPI: Mode sense Page Code not supported (%x)\n", sense_cmd->page_code); + PrintError(VM_NONE, VCORE_NONE, "ATAPI: Mode sense Page Code not supported (%x)\n", sense_cmd->page_code); atapi_cmd_error(ide, channel, ATAPI_SEN_ILL_REQ, ASC_INV_CMD_FIELD); ide_raise_irq(ide, channel); return 0; @@ -435,7 +435,7 @@ static int atapi_mode_sense_cur_values(struct ide_internal * ide, struct ide_cha // memset(hdr, 0, sizeof(struct atapi_mode_sense_hdr)); // hdr->media_type_code = 0x70; - PrintDebug("resp_len=%d\n", resp_len); + PrintDebug(VM_NONE, VCORE_NONE, "resp_len=%d\n", resp_len); drive->transfer_length = (resp_len > alloc_len) ? alloc_len : resp_len; drive->transfer_index = 0; @@ -458,7 +458,7 @@ static int atapi_mode_sense(struct ide_internal * ide, struct ide_channel * chan case 0x02: // default values case 0x03: // saved values default: - PrintError("ATAPI: Mode sense mode not supported (%x)\n", sense_cmd->page_ctrl); + PrintError(VM_NONE, VCORE_NONE, "ATAPI: Mode sense mode not supported (%x)\n", sense_cmd->page_ctrl); return -1; } return 0; @@ -537,7 +537,7 @@ static int atapi_handle_packet(struct guest_info * core, struct ide_internal * i struct ide_drive * drive = get_selected_drive(channel); uint8_t cmd = drive->data_buf[0]; - PrintDebug("IDE: ATAPI Command %x\n", cmd); + PrintDebug(core->vm_info, core, "IDE: ATAPI Command %x\n", cmd); drive->cd_state.atapi_cmd = cmd; @@ -550,7 +550,7 @@ static int atapi_handle_packet(struct guest_info * core, struct ide_internal * i */ break; case 0x03: // request sense - PrintError("IDE: Requesting Sense (0x3)\n"); + PrintError(core->vm_info, core, "IDE: Requesting Sense (0x3)\n"); atapi_req_sense(ide, channel); break; @@ -560,14 +560,14 @@ static int atapi_handle_packet(struct guest_info * core, struct ide_internal * i case 0x28: // read(10) if (atapi_read10(core, ide, channel) == -1) { - PrintError("IDE: Error in ATAPI read (%x)\n", cmd); + PrintError(core->vm_info, core, "IDE: Error in ATAPI read (%x)\n", cmd); return -1; } break; case 0x5a: // mode sense if (atapi_mode_sense(ide, channel) == -1) { - PrintError("IDE: Error in ATAPI mode sense (%x)\n", cmd); + PrintError(core->vm_info, core, "IDE: Error in ATAPI mode sense (%x)\n", cmd); return -1; } break; @@ -575,7 +575,7 @@ static int atapi_handle_packet(struct guest_info * core, struct ide_internal * i case 0x25: // read cdrom capacity if (atapi_get_capacity(ide, channel) == -1) { - PrintError("IDE: Error getting CDROM capacity (%x)\n", cmd); + PrintError(core->vm_info, core, "IDE: Error getting CDROM capacity (%x)\n", cmd); return -1; } break; @@ -583,14 +583,14 @@ static int atapi_handle_packet(struct guest_info * core, struct ide_internal * i case 0x43: // read TOC if (atapi_read_toc(ide, channel) == -1) { - PrintError("IDE: Error getting CDROM TOC (%x)\n", cmd); + PrintError(core->vm_info, core, "IDE: Error getting CDROM TOC (%x)\n", cmd); return -1; } break; case 0x46: // get configuration if (atapi_get_config(ide, channel) == -1) { - PrintError("IDE: Error getting CDROM Configuration (%x)\n", cmd); + PrintError(core->vm_info, core, "IDE: Error getting CDROM Configuration (%x)\n", cmd); return -1; } break; @@ -599,21 +599,21 @@ static int atapi_handle_packet(struct guest_info * core, struct ide_internal * i case 0x4a: // Get Status/event case 0x51: // read disk info // no-op to keep the Linux CD-ROM driver happy - PrintDebug("Error: Read disk info no-op to keep the Linux CD-ROM driver happy\n"); + PrintDebug(core->vm_info, core, "Error: Read disk info no-op to keep the Linux CD-ROM driver happy\n"); atapi_cmd_error(ide, channel, ATAPI_SEN_ILL_REQ, ASC_INV_CMD_FIELD); ide_raise_irq(ide, channel); break; case 0x12: // inquiry if (atapi_inquiry(ide, channel) == -1) { - PrintError("IDE: Error in ATAPI inquiry (%x)\n", cmd); + PrintError(core->vm_info, core, "IDE: Error in ATAPI inquiry (%x)\n", cmd); return -1; } break; case 0xbd: // mechanism status if (atapi_mech_status(ide, channel) == -1) { - PrintError("IDE: error in ATAPI Mechanism status query (%x)\n", cmd); + PrintError(core->vm_info, core, "IDE: error in ATAPI Mechanism status query (%x)\n", cmd); return -1; } break; @@ -647,7 +647,7 @@ static int atapi_handle_packet(struct guest_info * core, struct ide_internal * i case 0x4e: // stop play/scan default: - PrintError("Unhandled ATAPI command %x\n", cmd); + PrintError(core->vm_info, core, "Unhandled ATAPI command %x\n", cmd); atapi_cmd_error(ide, channel, ATAPI_SEN_ILL_REQ, ASC_INV_CMD_FIELD); ide_raise_irq(ide, channel); return -1; diff --git a/palacios/src/devices/bochs_debug.c b/palacios/src/devices/bochs_debug.c index 339999d..8daa49c 100644 --- a/palacios/src/devices/bochs_debug.c +++ b/palacios/src/devices/bochs_debug.c @@ -22,6 +22,7 @@ #include #include #include +#include #define BUF_SIZE 1024 @@ -50,7 +51,7 @@ static int handle_info_write(struct guest_info * core, ushort_t port, void * src state->info_buf[state->info_offset++] = *(char*)src; if ((*(char*)src == 0xa) || (state->info_offset == (BUF_SIZE - 1))) { - PrintDebug("BOCHSINFO>%s", state->info_buf); + PrintDebug(core->vm_info, core, "BOCHSINFO>%s", state->info_buf); memset(state->info_buf, 0, BUF_SIZE); state->info_offset = 0; } @@ -65,7 +66,7 @@ static int handle_debug_write(struct guest_info * core, ushort_t port, void * sr state->debug_buf[state->debug_offset++] = *(char*)src; if ((*(char*)src == 0xa) || (state->debug_offset == (BUF_SIZE - 1))) { - PrintDebug("BOCHSDEBUG>%s", state->debug_buf); + PrintDebug(core->vm_info, core, "BOCHSDEBUG>%s", state->debug_buf); memset(state->debug_buf, 0, BUF_SIZE); state->debug_offset = 0; } @@ -80,7 +81,7 @@ static int handle_console_write(struct guest_info * core, ushort_t port, void * state->cons_buf[state->cons_offset++] = *(char *)src; if ((*(char *)src == 0xa) || (state->cons_offset == (BUF_SIZE - 1))) { - V3_Print("BOCHSCONSOLE>%s", state->cons_buf); + V3_Print(core->vm_info, core, "BOCHSCONSOLE>%s", state->cons_buf); memset(state->cons_buf, 0, BUF_SIZE); state->cons_offset = 0; } @@ -93,16 +94,16 @@ static int handle_gen_write(struct guest_info * core, ushort_t port, void * src, switch (length) { case 1: - PrintDebug(">0x%.2x\n", *(uchar_t*)src); + PrintDebug(core->vm_info, core, ">0x%.2x\n", *(uchar_t*)src); break; case 2: - PrintDebug(">0x%.4x\n", *(ushort_t*)src); + PrintDebug(core->vm_info, core, ">0x%.4x\n", *(ushort_t*)src); break; case 4: - PrintDebug(">0x%.8x\n", *(uint_t*)src); + PrintDebug(core->vm_info, core, ">0x%.8x\n", *(uint_t*)src); break; default: - PrintError("Invalid length in handle_gen_write\n"); + PrintError(core->vm_info, core, "Invalid length in handle_gen_write\n"); return -1; break; } @@ -138,15 +139,15 @@ static int debug_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { state = (struct debug_state *)V3_Malloc(sizeof(struct debug_state)); if (state == NULL) { - PrintError("Could not allocate bochs debug state\n"); + PrintError(vm, VCORE_NONE, "Could not allocate bochs debug state\n"); return -1; } - PrintDebug("Creating Bochs Debug Device\n"); + PrintDebug(vm, VCORE_NONE, "Creating Bochs Debug Device\n"); struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(state); return -1; } @@ -166,7 +167,7 @@ static int debug_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { ret |= v3_dev_hook_io(dev, BOCHS_CONSOLE_PORT, NULL, &handle_console_write); if (ret != 0) { - PrintError("Could not hook Bochs Debug IO Ports\n"); + PrintError(vm, VCORE_NONE, "Could not hook Bochs Debug IO Ports\n"); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/cga.c b/palacios/src/devices/cga.c index 60baa54..d79e577 100644 --- a/palacios/src/devices/cga.c +++ b/palacios/src/devices/cga.c @@ -227,7 +227,7 @@ struct video_internal { static void refresh_screen(struct video_internal * state) { uint_t screen_size; - PrintDebug("Screen config: framebuf=0x%x-0x%x, gres=%dx%d, tres=%dx%d, %s mode\n", + PrintDebug(VM_NONE, VCORE_NONE, "Screen config: framebuf=0x%x-0x%x, gres=%dx%d, tres=%dx%d, %s mode\n", (unsigned) state->activefb_addr, (unsigned) state->activefb_addr + state->activefb_len, state->hres, @@ -242,14 +242,14 @@ static void refresh_screen(struct video_internal * state) { if (state->reschanged) { /* resolution change message will trigger update */ state->reschanged = 0; - PrintDebug("Video: set_text_resolution(%d, %d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Video: set_text_resolution(%d, %d)\n", state->hchars, state->vchars); if (state->ops && state->ops->set_text_resolution) { state->ops->set_text_resolution(state->hchars, state->vchars, state->private_data); } } else { /* send update for full buffer */ - PrintDebug("Video: update_screen(0, 0, %d * %d * %d)\n", state->vchars, state->hchars, BYTES_PER_COL); + PrintDebug(VM_NONE, VCORE_NONE, "Video: update_screen(0, 0, %d * %d * %d)\n", state->vchars, state->hchars, BYTES_PER_COL); screen_size = state->vchars * state->hchars * BYTES_PER_COL; if (state->ops) { state->ops->update_screen(0, 0, screen_size, state->private_data); @@ -280,7 +280,7 @@ static void registers_updated(struct video_internal * state) { state->activefb_addr = activefb_addr; state->activefb_len = activefb_len; state->dirty = 1; - PrintVerbose("Video: need refresh (activefb=0x%x-0x%x)\n", + PrintVerbose(VM_NONE, VCORE_NONE, "Video: need refresh (activefb=0x%x-0x%x)\n", activefb_addr, activefb_addr + activefb_len); } @@ -288,7 +288,7 @@ static void registers_updated(struct video_internal * state) { if (state->graphmode != misc->gm) { state->graphmode = misc->gm; state->dirty = 1; - PrintVerbose("Video: need refresh (graphmode=%d)\n", state->graphmode); + PrintVerbose(VM_NONE, VCORE_NONE, "Video: need refresh (graphmode=%d)\n", state->graphmode); } /* graphics resolution */ @@ -296,7 +296,7 @@ static void registers_updated(struct video_internal * state) { vres = (state->misc_outp_reg.vsp) ? 480 : 400; } else { if (!state->misc_outp_reg.vsp) { - PrintError("Video: reserved value in misc_outp_reg (0x%x)\n", + PrintError(VM_NONE, VCORE_NONE, "Video: reserved value in misc_outp_reg (0x%x)\n", *(uint8_t *) &state->misc_outp_reg); } vres = 350; @@ -307,14 +307,14 @@ static void registers_updated(struct video_internal * state) { if (state->vres != vres) { state->vres = vres; state->reschanged = 1; - PrintVerbose("Video: need refresh (vres=%d)\n", vres); + PrintVerbose(VM_NONE, VCORE_NONE, "Video: need refresh (vres=%d)\n", vres); } switch (state->misc_outp_reg.cs) { case 0: hres = 640; break; case 1: hres = 720; break; default: - PrintError("Video: reserved value in misc_outp_reg (0x%x)\n", + PrintError(VM_NONE, VCORE_NONE, "Video: reserved value in misc_outp_reg (0x%x)\n", *(uint8_t *) &state->misc_outp_reg); hres = 640; break; @@ -325,7 +325,7 @@ static void registers_updated(struct video_internal * state) { if (state->hres != hres) { state->hres = hres; state->reschanged = 1; - PrintVerbose("Video: need refresh (hres=%d)\n", hres); + PrintVerbose(VM_NONE, VCORE_NONE, "Video: need refresh (hres=%d)\n", hres); } /* text resolution */ @@ -341,7 +341,7 @@ static void registers_updated(struct video_internal * state) { state->hchars = hchars; state->vchars = vchars; state->reschanged = 1; - PrintVerbose("Video: need refresh (hchars=%d, vchars=%d)\n", hchars, vchars); + PrintVerbose(VM_NONE, VCORE_NONE, "Video: need refresh (hchars=%d, vchars=%d)\n", hchars, vchars); } /* resolution change implies refresh needed */ @@ -391,19 +391,19 @@ static void registers_initialize(struct video_internal * state) { state->misc_outp_reg.hsp = 1; /* sequencer registers */ - V3_ASSERT(sizeof(seq_defaults) == sizeof(state->seq_data_regs)); + V3_ASSERT(VM_NONE, VCORE_NONE, sizeof(seq_defaults) == sizeof(state->seq_data_regs)); memcpy(state->seq_data_regs, seq_defaults, sizeof(state->seq_data_regs)); /* CRT controller registers */ - V3_ASSERT(sizeof(crtc_defaults) == sizeof(state->crtc_data_regs)); + V3_ASSERT(VM_NONE, VCORE_NONE, sizeof(crtc_defaults) == sizeof(state->crtc_data_regs)); memcpy(state->crtc_data_regs, crtc_defaults, sizeof(state->crtc_data_regs)); /* graphics controller registers */ - V3_ASSERT(sizeof(graphc_defaults) == sizeof(state->graphc_data_regs)); + V3_ASSERT(VM_NONE, VCORE_NONE, sizeof(graphc_defaults) == sizeof(state->graphc_data_regs)); memcpy(state->graphc_data_regs, graphc_defaults, sizeof(state->graphc_data_regs)); /* attribute controller registers */ - V3_ASSERT(sizeof(attrc_defaults) == sizeof(state->attrc_data_regs)); + V3_ASSERT(VM_NONE, VCORE_NONE, sizeof(attrc_defaults) == sizeof(state->attrc_data_regs)); memcpy(state->attrc_data_regs, attrc_defaults, sizeof(state->attrc_data_regs)); /* initialize auxilary fields */ @@ -470,10 +470,10 @@ static int video_write_mem(struct guest_info * core, addr_t guest_addr, void * d uint_t length_adjusted, screen_pos, x, y; addr_t framebuf_offset, framebuf_offset_screen, screen_offset; - V3_ASSERT(guest_addr >= START_ADDR); - V3_ASSERT(guest_addr < END_ADDR); + V3_ASSERT(core->vm_info, core, guest_addr >= START_ADDR); + V3_ASSERT(core->vm_info, core, guest_addr < END_ADDR); - PrintVerbose("Video: write(%p, 0x%lx, %d)\n", + PrintVerbose(core->vm_info, core, "Video: write(%p, 0x%lx, %d)\n", (void *)guest_addr, get_value(state->framebuf + (guest_addr - START_ADDR), length), length); @@ -526,7 +526,7 @@ static int video_write_mem(struct guest_info * core, addr_t guest_addr, void * d x = screen_pos % state->hchars; y = screen_pos / state->hchars; if (y >= state->vchars) return length; - PrintVerbose("Video: update_screen(%d, %d, %d)\n", x, y, length_adjusted); + PrintVerbose(core->vm_info, core, "Video: update_screen(%d, %d, %d)\n", x, y, length_adjusted); state->ops->update_screen(x, y, length_adjusted, state->private_data); return length; @@ -538,17 +538,17 @@ static void debug_port(struct video_internal * video_state, const char *function /* report any unexpected guest behaviour, it may explain failures */ if (portrange != 0x3c0 && portrange != video_state->iorange) { - PrintError("Video %s: got bad port 0x%x\n", function, port); + PrintError(VM_NONE, VCORE_NONE, "Video %s: got bad port 0x%x\n", function, port); } if (!video_state->passthrough && length > maxlength) { - PrintError("Video %s: got bad length %d\n", function, length); + PrintError(VM_NONE, VCORE_NONE, "Video %s: got bad length %d\n", function, length); } - V3_ASSERT(length >= 1); + V3_ASSERT(VM_NONE, VCORE_NONE, length >= 1); } static void handle_port_read(struct video_internal * video_state, const char *function, uint16_t port, void *dest, uint_t length, uint_t maxlength) { - PrintVerbose("Video %s: in%c(0x%x): 0x%lx\n", function, opsize_char(length), port, get_value(dest, length)); + PrintVerbose(VM_NONE, VCORE_NONE, "Video %s: in%c(0x%x): 0x%lx\n", function, opsize_char(length), port, get_value(dest, length)); debug_port(video_state, function, port, length, maxlength); if (video_state->passthrough) { @@ -557,7 +557,7 @@ static void handle_port_read(struct video_internal * video_state, const char *fu } static void handle_port_write(struct video_internal * video_state, const char *function, uint16_t port, const void *src, uint_t length, uint_t maxlength) { - PrintVerbose("Video %s: out%c(0x%x, 0x%lx)\n", function, opsize_char(length), port, get_value(src, length)); + PrintVerbose(VM_NONE, VCORE_NONE, "Video %s: out%c(0x%x, 0x%lx)\n", function, opsize_char(length), port, get_value(src, length)); debug_port(video_state, function, port, length, maxlength); if (video_state->passthrough) { @@ -569,7 +569,7 @@ static int notimpl_port_read(struct video_internal * video_state, const char *fu memset(dest, 0xff, length); handle_port_read(video_state, function, port, dest, length, 1); if (!video_state->passthrough) { - PrintError("Video %s: not implemented\n", function); + PrintError(VM_NONE, VCORE_NONE, "Video %s: not implemented\n", function); } return length; } @@ -577,7 +577,7 @@ static int notimpl_port_read(struct video_internal * video_state, const char *fu static int notimpl_port_write(struct video_internal * video_state, const char *function, uint16_t port, const void *src, uint_t length) { handle_port_write(video_state, function, port, src, length, 1); if (!video_state->passthrough) { - PrintError("Video %s: not implemented\n", function); + PrintError(VM_NONE, VCORE_NONE, "Video %s: not implemented\n", function); } return length; } @@ -596,7 +596,7 @@ static int misc_outp_write(struct guest_info * core, uint16_t port, void * src, struct video_internal * video_state = priv_data; handle_port_write(video_state, __FUNCTION__, port, src, length, 1); - PrintDebug("Video: misc_outp=0x%x\n", *(uint8_t *) src); + PrintDebug(core->vm_info, core, "Video: misc_outp=0x%x\n", *(uint8_t *) src); video_state->misc_outp_reg = *(struct misc_outp_reg *) src; registers_updated(video_state); @@ -642,7 +642,7 @@ static int seq_data_read(struct guest_info * core, uint16_t port, void * dest, u if (index < SEQ_REG_COUNT) { *(uint8_t *) dest = video_state->seq_data_regs[index]; } else { - PrintError("Video %s: index %d out of range\n", __FUNCTION__, video_state->seq_index_reg); + PrintError(core->vm_info, core, "Video %s: index %d out of range\n", __FUNCTION__, video_state->seq_index_reg); *(uint8_t *) dest = 0; } @@ -657,11 +657,11 @@ static int seq_data_write(struct guest_info * core, uint16_t port, void * src, u handle_port_write(video_state, __FUNCTION__, port, src, length, 1); if (index < SEQ_REG_COUNT) { - PrintDebug("Video: seq[%d]=0x%x\n", index, val); + PrintDebug(core->vm_info, core, "Video: seq[%d]=0x%x\n", index, val); video_state->seq_data_regs[index] = val; registers_updated(video_state); } else { - PrintError("Video %s: index %d out of range\n", __FUNCTION__, video_state->seq_index_reg); + PrintError(core->vm_info, core, "Video %s: index %d out of range\n", __FUNCTION__, video_state->seq_index_reg); } return length; @@ -708,7 +708,7 @@ static int crtc_data_write(struct guest_info * core, uint16_t port, void * src, handle_port_write(video_state, __FUNCTION__, port, src, length, 1); if (length != 1) { - PrintError("Invalid write length for port 0x%x\n", port); + PrintError(core->vm_info, core, "Invalid write length for port 0x%x\n", port); return -1; } @@ -734,7 +734,7 @@ static int crtc_data_write(struct guest_info * core, uint16_t port, void * src, diff = (screen_offset - video_state->screen_offset) / video_state->hchars; refresh = 0; } - PrintVerbose("Video: screen_offset=%d, video_state->screen_offset=%d, video_state->hchars=%d, diff=%d, refresh=%d\n", + PrintVerbose(core->vm_info, core, "Video: screen_offset=%d, video_state->screen_offset=%d, video_state->hchars=%d, diff=%d, refresh=%d\n", screen_offset, video_state->screen_offset, video_state->hchars, diff, refresh); // Update the true offset value @@ -743,9 +743,9 @@ static int crtc_data_write(struct guest_info * core, uint16_t port, void * src, if (refresh || video_state->dirty) { refresh_screen(video_state); } else if (diff && video_state->ops) { - PrintVerbose("Video: scroll(%d)\n", diff); + PrintVerbose(core->vm_info, core, "Video: scroll(%d)\n", diff); if (video_state->ops->scroll(diff, video_state->private_data) == -1) { - PrintError("Error sending scroll event\n"); + PrintError(core->vm_info, core, "Error sending scroll event\n"); return -1; } } @@ -761,17 +761,17 @@ static int crtc_data_write(struct guest_info * core, uint16_t port, void * src, ((uint16_t) video_state->crtc_data_regs[CRTC_REGIDX_CURSOR_LOC_LOW]); x = video_state->cursor_offset % video_state->hchars; y = (video_state->cursor_offset - video_state->screen_offset) / video_state->hchars; - PrintVerbose("Video: video_state->cursor_offset=%d, x=%d, y=%d\n", + PrintVerbose(core->vm_info, core, "Video: video_state->cursor_offset=%d, x=%d, y=%d\n", video_state->cursor_offset, x, y); if (video_state->dirty) { refresh_screen(video_state); } - PrintVerbose("Video: set cursor(%d, %d)\n", x, y); + PrintVerbose(core->vm_info, core, "Video: set cursor(%d, %d)\n", x, y); if (video_state->ops) { if (video_state->ops->update_cursor(x, y, video_state->private_data) == -1) { - PrintError("Error updating cursor\n"); + PrintError(core->vm_info, core, "Error updating cursor\n"); return -1; } } @@ -779,7 +779,7 @@ static int crtc_data_write(struct guest_info * core, uint16_t port, void * src, break; } default: - PrintDebug("Video: crtc[%d]=0x%x\n", index, val); + PrintDebug(core->vm_info, core, "Video: crtc[%d]=0x%x\n", index, val); break; } @@ -804,7 +804,7 @@ static int crtc_index_write(struct guest_info * core, uint16_t port, void * src, handle_port_write(video_state, __FUNCTION__, port, src, length, 2); if (length > 2) { - PrintError("Invalid write length for crtc index register port: %d (0x%x)\n", + PrintError(core->vm_info, core, "Invalid write length for crtc index register port: %d (0x%x)\n", port, port); return -1; } @@ -834,7 +834,7 @@ static int graphc_data_read(struct guest_info * core, uint16_t port, void * dest if (index < GRAPHC_REG_COUNT) { *(uint8_t *) dest = video_state->graphc_data_regs[index]; } else { - PrintError("Video %s: index %d out of range\n", __FUNCTION__, video_state->graphc_index_reg); + PrintError(core->vm_info, core, "Video %s: index %d out of range\n", __FUNCTION__, video_state->graphc_index_reg); *(uint8_t *) dest = 0; } @@ -849,11 +849,11 @@ static int graphc_data_write(struct guest_info * core, uint16_t port, void * src handle_port_write(video_state, __FUNCTION__, port, src, length, 1); if (index < GRAPHC_REG_COUNT) { - PrintDebug("Video: graphc[%d]=0x%x\n", index, val); + PrintDebug(core->vm_info, core, "Video: graphc[%d]=0x%x\n", index, val); video_state->graphc_data_regs[index] = val; registers_updated(video_state); } else { - PrintError("Video %s: index %d out of range\n", __FUNCTION__, video_state->graphc_index_reg); + PrintError(core->vm_info, core, "Video %s: index %d out of range\n", __FUNCTION__, video_state->graphc_index_reg); } return length; @@ -891,7 +891,7 @@ static int attrc_data_read(struct guest_info * core, uint16_t port, void * dest, if (index < ATTRC_REG_COUNT) { *(uint8_t *) dest = video_state->attrc_data_regs[index]; } else { - PrintError("Video %s: index %d out of range\n", __FUNCTION__, video_state->attrc_index_reg); + PrintError(core->vm_info, core, "Video %s: index %d out of range\n", __FUNCTION__, video_state->attrc_index_reg); *(uint8_t *) dest = 0; } @@ -906,10 +906,10 @@ static int attrc_data_write(struct guest_info * core, uint16_t port, void * src, handle_port_write(video_state, __FUNCTION__, port, src, length, 1); if (index < ATTRC_REG_COUNT) { - PrintDebug("Video: attrc[%d]=0x%x\n", index, val); + PrintDebug(core->vm_info, core, "Video: attrc[%d]=0x%x\n", index, val); video_state->attrc_data_regs[index] = val; } else { - PrintError("Video %s: index %d out of range\n", __FUNCTION__, video_state->attrc_index_reg); + PrintError(core->vm_info, core, "Video %s: index %d out of range\n", __FUNCTION__, video_state->attrc_index_reg); } return length; @@ -989,7 +989,7 @@ static int dac_data_read(struct guest_info * core, uint16_t port, void * dest, u /* update palette */ index = (unsigned) video_state->dac_indexr_reg * DAC_COLOR_COUNT + video_state->dac_indexr_color; - V3_ASSERT(index < DAC_REG_COUNT); + V3_ASSERT(core->vm_info, core, index < DAC_REG_COUNT); *(uint8_t *) dest = video_state->dac_data_regs[index]; /* move on to next entry/color */ @@ -1010,7 +1010,7 @@ static int dac_data_write(struct guest_info * core, uint16_t port, void * src, u /* update palette */ index = (unsigned) video_state->dac_indexw_reg * DAC_COLOR_COUNT + video_state->dac_indexw_color; - V3_ASSERT(index < DAC_REG_COUNT); + V3_ASSERT(core->vm_info, core, index < DAC_REG_COUNT); video_state->dac_data_regs[index] = *(uint8_t *) src; /* move on to next entry/color */ @@ -1070,12 +1070,12 @@ int v3_cons_get_fb_text(struct video_internal * state, uint8_t * dst, uint_t off uint_t framebuf_offset, len1, len2; uint_t screen_byte_offset = state->screen_offset * BYTES_PER_COL; - PrintVerbose("Video: getfb o=%d l=%d so=%d aa=0x%x al=0x%x hc=%d vc=%d\n", + PrintVerbose(VM_NONE, VCORE_NONE, "Video: getfb o=%d l=%d so=%d aa=0x%x al=0x%x hc=%d vc=%d\n", offset, length, state->screen_offset, (unsigned) state->activefb_addr, (unsigned) state->activefb_len, state->hchars, state->vchars); - V3_ASSERT(state->activefb_addr >= START_ADDR); - V3_ASSERT(state->activefb_addr + state->activefb_len <= END_ADDR); + V3_ASSERT(VM_NONE, VCORE_NONE, state->activefb_addr >= START_ADDR); + V3_ASSERT(VM_NONE, VCORE_NONE, state->activefb_addr + state->activefb_len <= END_ADDR); /* Copy memory with wrapping (should be configurable, but where else to get the data?) */ framebuf = state->framebuf + (state->activefb_addr - START_ADDR); @@ -1102,7 +1102,7 @@ int v3_cons_get_fb(struct vm_device * frontend_dev, uint8_t * dst, uint_t offset static int cga_free(struct video_internal * video_state) { if (video_state->framebuf_pa) { - PrintError("Freeing framebuffer PA %p\n", (void *)(video_state->framebuf_pa)); + PrintError(VM_NONE, VCORE_NONE, "Freeing framebuffer PA %p\n", (void *)(video_state->framebuf_pa)); V3_FreePages((void *)(video_state->framebuf_pa), (FRAMEBUF_SIZE / 4096)); } @@ -1158,7 +1158,7 @@ static int cga_save(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; savefailout: - PrintError("Failed to save CGA\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to save CGA\n"); return -1; } @@ -1208,7 +1208,7 @@ static int cga_load(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; loadfailout: - PrintError("Failed to load cga\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to load cga\n"); return -1; } @@ -1231,12 +1231,12 @@ static int cga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { char * passthrough_str = v3_cfg_val(cfg, "passthrough"); int ret = 0; - PrintDebug("video: init_device\n"); + PrintDebug(vm, VCORE_NONE, "video: init_device\n"); video_state = (struct video_internal *)V3_Malloc(sizeof(struct video_internal)); if (!video_state) { - PrintError("Cannot allocate space for CGA state\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate space for CGA state\n"); return -1; } @@ -1245,7 +1245,7 @@ static int cga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, video_state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(video_state); return -1; } @@ -1255,7 +1255,7 @@ static int cga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { video_state->framebuf_pa = (addr_t)V3_AllocPages(FRAMEBUF_SIZE / 4096); if (!video_state->framebuf_pa) { - PrintError("Cannot allocate frame buffer\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate frame buffer\n"); V3_Free(video_state); return -1; } @@ -1264,7 +1264,7 @@ static int cga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { memset(video_state->framebuf, 0, FRAMEBUF_SIZE); - PrintDebug("PA of array: %p\n", (void *)(video_state->framebuf_pa)); + PrintDebug(vm, VCORE_NONE, "PA of array: %p\n", (void *)(video_state->framebuf_pa)); if ((passthrough_str != NULL) && (strcasecmp(passthrough_str, "enable") == 0)) {; @@ -1273,16 +1273,16 @@ static int cga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { if (video_state->passthrough) { - PrintDebug("Enabling CGA Passthrough\n"); + PrintDebug(vm, VCORE_NONE, "Enabling CGA Passthrough\n"); if (v3_hook_write_mem(vm, V3_MEM_CORE_ANY, START_ADDR, END_ADDR, START_ADDR, &video_write_mem, dev) == -1) { - PrintError("\n\nVideo Hook failed.\n\n"); + PrintError(vm, VCORE_NONE, "\n\nVideo Hook failed.\n\n"); return -1; } } else { if (v3_hook_write_mem(vm, V3_MEM_CORE_ANY, START_ADDR, END_ADDR, video_state->framebuf_pa, &video_write_mem, dev) == -1) { - PrintError("\n\nVideo Hook failed.\n\n"); + PrintError(vm, VCORE_NONE, "\n\nVideo Hook failed.\n\n"); return -1; } } @@ -1322,7 +1322,7 @@ static int cga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { ret |= v3_dev_hook_io(dev, 0x3c6, &dac_pelmask_read, &dac_pelmask_write); if (ret != 0) { - PrintError("Error allocating VGA IO ports\n"); + PrintError(vm, VCORE_NONE, "Error allocating VGA IO ports\n"); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/char_stream.c b/palacios/src/devices/char_stream.c index 2bde181..445a0ac 100644 --- a/palacios/src/devices/char_stream.c +++ b/palacios/src/devices/char_stream.c @@ -75,7 +75,7 @@ static int stream_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { state = (struct stream_state *)V3_Malloc(sizeof(struct stream_state)); if (state == NULL) { - PrintError("Could not allocate stream backend device\n"); + PrintError(vm, VCORE_NONE, "Could not allocate stream backend device\n"); return -1; } @@ -84,7 +84,7 @@ static int stream_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, state); if (dev == NULL) { - PrintError("Could not allocate device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not allocate device %s\n", dev_id); V3_Free(state); return -1; } @@ -93,7 +93,7 @@ static int stream_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { state->stream = v3_stream_open(vm, stream_name, stream_input, state); if (state->stream == NULL) { - PrintError("Could not open stream %s\n", stream_name); + PrintError(vm, VCORE_NONE, "Could not open stream %s\n", stream_name); v3_remove_device(dev); return -1; } @@ -104,7 +104,7 @@ static int stream_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { if (v3_dev_connect_char(vm, v3_cfg_val(frontend_cfg, "tag"), &(state->char_ops), frontend_cfg, state, &(state->push_fn_arg)) == -1) { - PrintError("Could not connect %s to frontend %s\n", + PrintError(vm, VCORE_NONE, "Could not connect %s to frontend %s\n", dev_id, v3_cfg_val(frontend_cfg, "tag")); v3_remove_device(dev); return -1; diff --git a/palacios/src/devices/cirrus_gfx_card.c b/palacios/src/devices/cirrus_gfx_card.c index 663f03b..c6b7a43 100644 --- a/palacios/src/devices/cirrus_gfx_card.c +++ b/palacios/src/devices/cirrus_gfx_card.c @@ -121,14 +121,14 @@ static int video_write_mem(struct guest_info * core, addr_t guest_addr, void * d // int i = 0; /* - PrintDebug("\n\nInside Video Write Memory.\n\n"); - PrintDebug("Guest address: %p length = %d\n", (void *)guest_addr, length); + PrintDebug(info->vm_info, info, "\n\nInside Video Write Memory.\n\n"); + PrintDebug(info->vm_info, info, "Guest address: %p length = %d\n", (void *)guest_addr, length); - PrintDebug("Write offset: 0x%x\n", (uint_t)write_offset); - PrintDebug("Video_Memory: "); + PrintDebug(info->vm_info, info, "Write offset: 0x%x\n", (uint_t)write_offset); + PrintDebug(info->vm_info, info, "Video_Memory: "); for (i = 0; i < length; i += 2) { - PrintDebug("%c", ((char *)(V3_VAddr((void *)guest_addr)))[i]); + PrintDebug(info->vm_info, info, "%c", ((char *)(V3_VAddr((void *)guest_addr)))[i]); } */ #if PASSTHROUGH @@ -137,16 +137,16 @@ static int video_write_mem(struct guest_info * core, addr_t guest_addr, void * d /* if (send_update(data->client_fd, data->video_memory + difference, write_offset-difference, data->start_addr_offset, length) == -1) { - PrintError("Error sending update to client\n"); + PrintError(info->vm_info, info, "Error sending update to client\n"); return -1; } */ - // PrintDebug(" Done.\n"); + // PrintDebug(info->vm_info, info, " Done.\n"); return length; } static int video_read_port(struct guest_info * dev, uint16_t port, void * dest, uint_t length, void * priv_data ) { - PrintDebug("Video: Read port 0x%x\n",port); + PrintDebug(info->vm_info, info, "Video: Read port 0x%x\n",port); video_do_in(port, dest, length); return length; } @@ -160,24 +160,24 @@ static int video_read_port_generic(struct guest_info * dev, uint16_t port, void static int video_write_port(struct guest_info * dev, uint16_t port, void * dest, uint_t length, void * priv_data) { - PrintDebug("Video: write port 0x%x...Wrote: ", port); + PrintDebug(info->vm_info, info, "Video: write port 0x%x...Wrote: ", port); uint_t i; for(i = 0; i < length; i++){ - PrintDebug("%x", ((uint8_t*)dest)[i]); + PrintDebug(info->vm_info, info, "%x", ((uint8_t*)dest)[i]); } - PrintDebug("...Done\n"); + PrintDebug(info->vm_info, info, "...Done\n"); video_do_out(port, dest, length); return length; } static int video_write_port_store(struct guest_info * dev, uint16_t port, void * dest, uint_t length, void * priv_data) { - PrintDebug("Entering video_write_port_store...port 0x%x\n", port); + PrintDebug(info->vm_info, info, "Entering video_write_port_store...port 0x%x\n", port); uint_t i; for(i = 0; i < length; i++){ - PrintDebug("%x", ((uint8_t*)dest)[i]); + PrintDebug(info->vm_info, info, "%x", ((uint8_t*)dest)[i]); } - PrintDebug("...Done\n"); + PrintDebug(info->vm_info, info, "...Done\n"); struct video_internal * video_state = (struct video_internal *)priv_data; @@ -193,13 +193,13 @@ static int video_write_port_3D5(struct guest_info * dev, uint16_t port, void * d uint8_t new_start = 0; uint_t index = 0; - PrintDebug("Video: write port 0x%x...Wrote: ", port); + PrintDebug(info->vm_info, info, "Video: write port 0x%x...Wrote: ", port); { uint_t i = 0; for (i = 0; i < length; i++){ - PrintDebug("%x", ((uint8_t*)dest)[i]); + PrintDebug(info->vm_info, info, "%x", ((uint8_t*)dest)[i]); } - PrintDebug("...Done\n"); + PrintDebug(info->vm_info, info, "...Done\n"); } video_state->ports[port - PORT_OFFSET] = 0; @@ -229,7 +229,7 @@ static int video_write_port_3D5(struct guest_info * dev, uint16_t port, void * d diff = video_state->start_addr_offset - video_state->old_start_addr_offset; diff /= 80; - PrintDebug("Scroll lines = %d\n", diff); + PrintDebug(info->vm_info, info, "Scroll lines = %d\n", diff); // send_scroll(video_state->client_fd, diff, video_state->video_memory); @@ -248,7 +248,7 @@ static int video_write_port_3D5(struct guest_info * dev, uint16_t port, void * d x = ((video_state->cursor_addr) % 80) + 1; y = (((video_state->cursor_addr) / 80) - ((video_state->start_addr_offset / 80))) + 1; - PrintDebug("New Cursor Location; X=%d Y=%d\n", x, y); + PrintDebug(info->vm_info, info, "New Cursor Location; X=%d Y=%d\n", x, y); // send_cursor_update(video_state->client_fd, x, y); break; @@ -268,13 +268,13 @@ static int video_write_port_3C5(struct guest_info * dev, uint16_t port, void * d uint_t index = 0; - PrintDebug("Entering write_port_3C5....port 0x%x\n", port); + PrintDebug(info->vm_info, info, "Entering write_port_3C5....port 0x%x\n", port); { uint_t i = 0; for(i = 0; i < length; i++){ - PrintDebug("%x", ((uint8_t*)dest)[i]); + PrintDebug(info->vm_info, info, "%x", ((uint8_t*)dest)[i]); } - PrintDebug("...Done\n"); + PrintDebug(info->vm_info, info, "...Done\n"); } video_state->ports[port - PORT_OFFSET] = 0; @@ -291,14 +291,14 @@ static int video_write_port_3C5(struct guest_info * dev, uint16_t port, void * d static int video_write_port_3CF(struct guest_info * dev, uint16_t port, void * dest, uint_t length, void * priv_data) { struct video_internal * video_state = (struct video_internal *)priv_data; - PrintDebug("Entering write_port_3CF....port 0x%x\n", port); + PrintDebug(info->vm_info, info, "Entering write_port_3CF....port 0x%x\n", port); { uint_t i = 0; for(i = 0; i < length; i++){ - PrintDebug("%x", ((uint8_t*)dest)[i]); + PrintDebug(info->vm_info, info, "%x", ((uint8_t*)dest)[i]); } - PrintDebug("...Done\n"); + PrintDebug(info->vm_info, info, "...Done\n"); } video_state->ports[port - PORT_OFFSET] = 0; @@ -338,7 +338,7 @@ static int video_write_port_3D4(struct guest_info * dev, uint16_t port, void * d x = ((video_state->cursor_addr) % 80) + 1; y = (((video_state->cursor_addr) / 80) - ((video_state->start_addr_offset / 80))) + 1; - PrintDebug("New Cursor Location; X=%d Y=%d\n", x, y); + PrintDebug(info->vm_info, info, "New Cursor Location; X=%d Y=%d\n", x, y); // send_cursor_update(video_state->client_fd, x, y); } @@ -358,7 +358,7 @@ static int video_write_port_3D4(struct guest_info * dev, uint16_t port, void * d diff = video_state->start_addr_offset - video_state->old_start_addr_offset; diff /= 80; - PrintDebug("Scroll lines = %d\n", diff); + PrintDebug(info->vm_info, info, "Scroll lines = %d\n", diff); // send_scroll(video_state->client_fd, diff, video_state->video_memory+0x18000); } @@ -372,22 +372,22 @@ static int video_write_port_3D4(struct guest_info * dev, uint16_t port, void * d } static int video_write_mem_region(struct guest_info * core, addr_t guest_addr, void * dest, uint_t length, void * priv_data) {; - PrintDebug("Video write mem region guest_addr: 0x%p, src: 0x%p, length: %d, Value?= %x\n", (void *)guest_addr, dest, length, *((uint32_t *)V3_VAddr((void *)guest_addr))); + PrintDebug(info->vm_info, info, "Video write mem region guest_addr: 0x%p, src: 0x%p, length: %d, Value?= %x\n", (void *)guest_addr, dest, length, *((uint32_t *)V3_VAddr((void *)guest_addr))); return length; } static int video_read_mem_region(struct guest_info * core, addr_t guest_addr, void * dest, uint_t length, void * priv_data){ - PrintDebug("Video: Within video_read_mem_region\n"); + PrintDebug(info->vm_info, info, "Video: Within video_read_mem_region\n"); return length; } static int video_write_io_region(struct guest_info * core, addr_t guest_addr, void * dest, uint_t length, void * priv_data){ - PrintDebug("Video: Within video_write_io_region\n"); + PrintDebug(info->vm_info, info, "Video: Within video_write_io_region\n"); return length; } static int video_read_io_region(struct guest_info * core, addr_t guest_addr, void * dest, uint_t length, void * priv_data){ - PrintDebug("Video: Within video_read_io_region\n"); + PrintDebug(info->vm_info, info, "Video: Within video_read_io_region\n"); return length; } @@ -398,17 +398,17 @@ static int cirrus_gfx_card_free(struct vm_device * dev) { /* static int cirrus_gfx_card_reset_device(struct vm_device * dev) { - PrintDebug("Video: reset device\n"); + PrintDebug(info->vm_info, info, "Video: reset device\n"); return 0; } static int cirrus_gfx_card_start_device(struct vm_device * dev) { - PrintDebug("Video: start device\n"); + PrintDebug(info->vm_info, info, "Video: start device\n"); return 0; } static int cirrus_gfx_card_stop_device(struct vm_device * dev) { - PrintDebug("Video: stop device\n"); + PrintDebug(info->vm_info, info, "Video: stop device\n"); return 0; } */ @@ -427,24 +427,24 @@ static int cirrus_gfx_card_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg){ if (!video_state) { - PrintError("Cannot allocate state in cirrus gfx\n"); + PrintError(info->vm_info, info, "Cannot allocate state in cirrus gfx\n"); return -1; } struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, video_state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(info->vm_info, info, "Could not attach device %s\n", dev_id); V3_Free(video_state) return -1; } - PrintDebug("video: init_device\n"); - PrintDebug("Num Pages=%d\n", SIZE_OF_REGION / 4096); + 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_AllocPages(SIZE_OF_REGION / 4096); if (!video_state->video_memory_pa) { - PrintError("Cannot allocate video memory\n"); + PrintError(info->vm_info, info, "Cannot allocate video memory\n"); V3_Free(video_state); return -1; } @@ -500,31 +500,31 @@ static int cirrus_gfx_card_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg){ v3_dev_hook_io(dev, 0x3df, &video_read_port, &video_write_port); - PrintDebug("PA of array: %p\n", (void *)video_state->video_memory_pa); + PrintDebug(info->vm_info, info, "PA of array: %p\n", (void *)video_state->video_memory_pa); #if PASSTHROUGH if (v3_hook_write_mem(vm, V3_MEM_CORE_ANY, START_ADDR, END_ADDR, START_ADDR, &video_write_mem, dev) == -1){ - PrintDebug("\n\nVideo Hook failed.\n\n"); + PrintDebug(info->vm_info, info, "\n\nVideo Hook failed.\n\n"); } #else if (v3_hook_write_mem(vm, V3_MEM_CORE_ANY, START_ADDR, END_ADDR, video_memory_pa, &video_write_mem, dev) == -1){ - PrintDebug("\n\nVideo Hook failed.\n\n"); + PrintDebug(info->vm_info, info, "\n\nVideo Hook failed.\n\n"); } #endif - PrintDebug("Video: Getting client connection\n"); + PrintDebug(info->vm_info, info, "Video: Getting client connection\n"); //video_state->client_fd = get_client_connection(vm); - PrintDebug("Video: Client connection established\n"); + PrintDebug(info->vm_info, info, "Video: Client connection established\n"); video_state->screen_bottom = 25; video_state->pci_bus = pci_bus; if (video_state->pci_bus == NULL) { - PrintError("Could not find PCI device\n"); + PrintError(info->vm_info, info, "Could not find PCI device\n"); return -1; } else { struct v3_pci_bar bars[6]; @@ -556,10 +556,10 @@ static int cirrus_gfx_card_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg){ NULL, NULL, dev); if (pci_dev == NULL) { - PrintError("Failed to register VIDEO %d with PCI\n", i); + PrintError(info->vm_info, info, "Failed to register VIDEO %d with PCI\n", i); return -1; } else{ - PrintDebug("Registering PCI_VIDEO succeeded\n"); + PrintDebug(info->vm_info, info, "Registering PCI_VIDEO succeeded\n"); } //Need to set some pci_dev->config_header.vendor_id type variables @@ -588,7 +588,7 @@ static int cirrus_gfx_card_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg){ video_state->pci_dev = pci_dev; } - PrintDebug("Video: init complete\n"); + PrintDebug(info->vm_info, info, "Video: init complete\n"); return 0; } diff --git a/palacios/src/devices/curses_cons.c b/palacios/src/devices/curses_cons.c index af66d77..8824447 100644 --- a/palacios/src/devices/curses_cons.c +++ b/palacios/src/devices/curses_cons.c @@ -63,7 +63,7 @@ static int cursor_update(uint_t x, uint_t y, void *private_data) struct cons_state *state = (struct cons_state *) dev->private_data; uint_t offset; - PrintDebug("cursor_update(%d, %d, %p)\n", x, y, private_data); + PrintDebug(VM_NONE, VCORE_NONE, "cursor_update(%d, %d, %p)\n", x, y, private_data); /* avoid out-of-range coordinates */ if (x < 0) x = 0; @@ -74,13 +74,13 @@ static int cursor_update(uint_t x, uint_t y, void *private_data) /* adjust cursor */ if (v3_console_set_cursor(state->cons, x, y) < 0) { - PrintError("set cursor (0x%p, %d, %d) failed\n", state->cons, x, y); + PrintError(VM_NONE, VCORE_NONE, "set cursor (0x%p, %d, %d) failed\n", state->cons, x, y); return -1; } /* done with console update */ if (v3_console_update(state->cons) < 0) { - PrintError("console update (0x%p) failed\n", state->cons); + PrintError(VM_NONE, VCORE_NONE, "console update (0x%p) failed\n", state->cons); return -1; } @@ -96,11 +96,11 @@ static int screen_update(uint_t x, uint_t y, uint_t length, void * private_data) uint_t cur_y = y; if (length > (state->rows * state->cols * BYTES_PER_COL)) { - PrintError("Screen update larger than curses framebuffer\n"); + PrintError(VM_NONE, VCORE_NONE, "Screen update larger than curses framebuffer\n"); return 0; } - PrintDebug("screen_update(%d, %d, %d, %p)\n", x, y, length, private_data); + PrintDebug(VM_NONE, VCORE_NONE, "screen_update(%d, %d, %d, %p)\n", x, y, length, private_data); /* grab frame buffer */ v3_cons_get_fb(state->frontend_dev, state->framebuf, offset, length); @@ -115,7 +115,7 @@ static int screen_update(uint_t x, uint_t y, uint_t length, void * private_data) /* update current character */ if (v3_console_set_char(state->cons, cur_x, cur_y, col[0], col[1]) < 0) { - PrintError("set cursor (0x%p, %d, %d, %d, %d) failed\n", + PrintError(VM_NONE, VCORE_NONE, "set cursor (0x%p, %d, %d, %d, %d) failed\n", state->cons, cur_x, cur_y, col[1], col[0]); return -1; } @@ -128,7 +128,7 @@ static int screen_update(uint_t x, uint_t y, uint_t length, void * private_data) /* done with console update */ if (v3_console_update(state->cons) < 0) { - PrintError("console update(0x%p) failed\n", state->cons); + PrintError(VM_NONE, VCORE_NONE, "console update(0x%p) failed\n", state->cons); return -1; } @@ -139,7 +139,7 @@ static int scroll(int rows, void * private_data) { struct vm_device *dev = (struct vm_device *)private_data; struct cons_state *state = (struct cons_state *)dev->private_data; - PrintDebug("scroll(%d, %p)\n", rows, private_data); + PrintDebug(VM_NONE, VCORE_NONE, "scroll(%d, %p)\n", rows, private_data); if (rows < 0) { /* simply update the screen */ @@ -149,13 +149,13 @@ static int scroll(int rows, void * private_data) { if (rows > 0) { /* scroll requested number of lines*/ if (v3_console_scroll(state->cons, rows) < 0) { - PrintError("console scroll (0x%p, %u) failed\n", state->cons, rows); + PrintError(VM_NONE, VCORE_NONE, "console scroll (0x%p, %u) failed\n", state->cons, rows); return -1; } /* done with console update */ if (v3_console_update(state->cons) < 0) { - PrintError("console update (0x%p) failed\n", state->cons); + PrintError(VM_NONE, VCORE_NONE, "console update (0x%p) failed\n", state->cons); return -1; } } @@ -167,17 +167,17 @@ static int set_text_resolution(int cols, int rows, void * private_data) { struct vm_device *dev = (struct vm_device *)private_data; struct cons_state *state = (struct cons_state *)dev->private_data; - PrintDebug("set_text_resolution(%d, %d, %p)\n", cols, rows, private_data); + PrintDebug(VM_NONE, VCORE_NONE, "set_text_resolution(%d, %d, %p)\n", cols, rows, private_data); /* store resolution for internal use */ - V3_ASSERT(cols >= 1); - V3_ASSERT(rows >= 1); + V3_ASSERT(VM_NONE, VCORE_NONE, cols >= 1); + V3_ASSERT(VM_NONE, VCORE_NONE, rows >= 1); state->cols = cols; state->rows = rows; /* set notification regarding resolution change */ if (v3_console_set_text_resolution(state->cons, cols, rows) < 0) { - PrintError("console set_text_resolution (0x%p, %u, %u) failed\n", state->cons, cols, rows); + PrintError(VM_NONE, VCORE_NONE, "console set_text_resolution (0x%p, %u, %u) failed\n", state->cons, cols, rows); return -1; } @@ -223,19 +223,19 @@ static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) /* read configuration */ frontend_cfg = v3_cfg_subtree(cfg, "frontend"); if (!frontend_cfg) { - PrintError("No frontend specification for curses console.\n"); + PrintError(vm, VCORE_NONE, "No frontend specification for curses console.\n"); return -1; } frontend_tag = v3_cfg_val(frontend_cfg, "tag"); if (!frontend_tag) { - PrintError("No frontend device tag specified for curses console.\n"); + PrintError(vm, VCORE_NONE, "No frontend device tag specified for curses console.\n"); return -1; } frontend = v3_find_dev(vm, frontend_tag); if (!frontend) { - PrintError("Could not find frontend device %s for curses console.\n", + PrintError(vm, VCORE_NONE, "Could not find frontend device %s for curses console.\n", frontend_tag); return -1; } @@ -244,7 +244,7 @@ static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) state = (struct cons_state *)V3_Malloc(sizeof(struct cons_state)); if (!state) { - PrintError("Cannot allocate curses state\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate curses state\n"); V3_Free(state); return -1; } @@ -255,7 +255,7 @@ static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) state->framebuf = V3_Malloc(state->cols * state->rows * BYTES_PER_COL); if (!state->framebuf) { - PrintError("Cannot allocate frame buffer\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate frame buffer\n"); V3_Free(state); return -1; } @@ -264,7 +264,7 @@ static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) state->cons = v3_console_open(vm, state->cols, state->rows); if (!state->cons) { - PrintError("Could not open console\n"); + PrintError(vm, VCORE_NONE, "Could not open console\n"); V3_Free(state->framebuf); V3_Free(state); return -1; @@ -274,7 +274,7 @@ static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(state->framebuf); V3_Free(state); return -1; diff --git a/palacios/src/devices/disk_model.c b/palacios/src/devices/disk_model.c index 74d40a1..2c192f9 100644 --- a/palacios/src/devices/disk_model.c +++ b/palacios/src/devices/disk_model.c @@ -92,7 +92,7 @@ static int connect_fn(struct v3_vm_info * vm, struct disk_state * model = (struct disk_state *)V3_Malloc(sizeof(struct disk_state)); if (!model) { - PrintError("Cannot allocate\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate\n"); return -1; } @@ -102,7 +102,7 @@ static int connect_fn(struct v3_vm_info * vm, if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"), &blk_ops, frontend_cfg, model) == -1) { - PrintError("Could not connect to frontend %s\n", + PrintError(vm, VCORE_NONE, "Could not connect to frontend %s\n", v3_cfg_val(frontend_cfg, "tag")); return -1; } @@ -117,12 +117,12 @@ static int model_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, NULL); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); return -1; } if (v3_dev_add_blk_frontend(vm, dev_id, connect_fn, NULL) == -1) { - PrintError("Could not register %s as block frontend\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not register %s as block frontend\n", dev_id); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/filedisk.c b/palacios/src/devices/filedisk.c index aae7ae6..15f4f6a 100644 --- a/palacios/src/devices/filedisk.c +++ b/palacios/src/devices/filedisk.c @@ -39,13 +39,13 @@ struct disk_state { static int write_all(v3_file_t fd, char * buf, uint64_t offset, uint64_t length) { uint64_t bytes_written = 0; - PrintDebug("Writing %llu bytes\n", length - bytes_written); + PrintDebug(VM_NONE, VCORE_NONE, "Writing %llu bytes\n", length - bytes_written); while (bytes_written < length) { int tmp_bytes = v3_file_write(fd, buf + bytes_written, length - bytes_written, offset + bytes_written); - PrintDebug("Wrote %d bytes\n", tmp_bytes); + PrintDebug(VM_NONE, VCORE_NONE, "Wrote %d bytes\n", tmp_bytes); if (tmp_bytes <= 0 ) { - PrintError("Write failed\n"); + PrintError(VM_NONE, VCORE_NONE, "Write failed\n"); return -1; } @@ -59,13 +59,13 @@ static int write_all(v3_file_t fd, char * buf, uint64_t offset, uint64_t length) static int read_all(v3_file_t fd, char * buf, uint64_t offset, uint64_t length) { uint64_t bytes_read = 0; - PrintDebug("Reading %llu bytes\n", length - bytes_read); + PrintDebug(VM_NONE, VCORE_NONE, "Reading %llu bytes\n", length - bytes_read); while (bytes_read < length) { int tmp_bytes = v3_file_read(fd, buf + bytes_read, length - bytes_read, offset + bytes_read); - PrintDebug("Read %d bytes\n", tmp_bytes); + PrintDebug(VM_NONE, VCORE_NONE, "Read %d bytes\n", tmp_bytes); if (tmp_bytes <= 0) { - PrintError("Read failed\n"); + PrintError(VM_NONE, VCORE_NONE, "Read failed\n"); return -1; } @@ -78,10 +78,10 @@ static int read_all(v3_file_t fd, char * buf, uint64_t offset, uint64_t length) static int read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data) { struct disk_state * disk = (struct disk_state *)private_data; - PrintDebug("Reading %llu bytes from %p to %p\n", num_bytes, (uint8_t *)(disk->disk_image + lba), buf); + PrintDebug(VM_NONE, VCORE_NONE, "Reading %llu bytes from %llu to 0x%p\n", num_bytes, lba, buf); if (lba + num_bytes > disk->capacity) { - PrintError("Out of bounds read: lba=%llu, num_bytes=%llu, capacity=%llu\n", + PrintError(VM_NONE, VCORE_NONE, "Out of bounds read: lba=%llu, num_bytes=%llu, capacity=%llu\n", lba, num_bytes, disk->capacity); return -1; } @@ -93,10 +93,10 @@ static int read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_ static int write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data) { struct disk_state * disk = (struct disk_state *)private_data; - PrintDebug("Writing %llu bytes from %p to %p\n", num_bytes, buf, (uint8_t *)(disk->disk_image + lba)); + PrintDebug(VM_NONE, VCORE_NONE, "Writing %llu bytes from 0x%p to %llu\n", num_bytes, buf, lba); if (lba + num_bytes > disk->capacity) { - PrintError("Out of bounds read: lba=%llu, num_bytes=%llu, capacity=%llu\n", + PrintError(VM_NONE, VCORE_NONE, "Out of bounds read: lba=%llu, num_bytes=%llu, capacity=%llu\n", lba, num_bytes, disk->capacity); return -1; } @@ -109,7 +109,7 @@ static int write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private static uint64_t get_capacity(void * private_data) { struct disk_state * disk = (struct disk_state *)private_data; - PrintDebug("Querying FILEDISK capacity %llu\n", disk->capacity); + PrintDebug(VM_NONE, VCORE_NONE, "Querying FILEDISK capacity %llu\n", disk->capacity); return disk->capacity; } @@ -153,14 +153,14 @@ static int disk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { } if (path == NULL) { - PrintError("Missing path (%s) for %s\n", path, dev_id); + PrintError(vm, VCORE_NONE, "Missing path (%s) for %s\n", path, dev_id); return -1; } disk = (struct disk_state *)V3_Malloc(sizeof(struct disk_state)); if (disk == NULL) { - PrintError("Could not allocate disk\n"); + PrintError(vm, VCORE_NONE, "Could not allocate disk\n"); return -1; } @@ -169,7 +169,7 @@ static int disk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, disk); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(disk); return -1; } @@ -178,21 +178,21 @@ static int disk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { disk->fd = v3_file_open(vm, path, flags); if (disk->fd == NULL) { - PrintError("Could not open file disk:%s\n", path); + PrintError(vm, VCORE_NONE, "Could not open file disk:%s\n", path); v3_remove_device(dev); return -1; } disk->capacity = v3_file_size(disk->fd); - V3_Print("Registering FILEDISK %s (path=%s, fd=%lu, size=%llu, writeable=%d)\n", + V3_Print(vm, VCORE_NONE, "Registering FILEDISK %s (path=%s, fd=%lu, size=%llu, writeable=%d)\n", dev_id, path, (addr_t)disk->fd, disk->capacity, flags & FILE_OPEN_MODE_WRITE); if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"), &blk_ops, frontend_cfg, disk) == -1) { - PrintError("Could not connect %s to frontend %s\n", + PrintError(vm, VCORE_NONE, "Could not connect %s to frontend %s\n", dev_id, v3_cfg_val(frontend_cfg, "tag")); v3_remove_device(dev); return -1; diff --git a/palacios/src/devices/generic.c b/palacios/src/devices/generic.c index 9c9b290..5e17d2f 100644 --- a/palacios/src/devices/generic.c +++ b/palacios/src/devices/generic.c @@ -98,7 +98,7 @@ static int generic_write_port_passthrough(struct guest_info * core, break; #endif default: - PrintError("generic (%s): unknown forwarding type\n", state->name); + PrintError(core->vm_info, core, "generic (%s): unknown forwarding type\n", state->name); return -1; break; } @@ -113,22 +113,22 @@ static int generic_write_port_print_and_passthrough(struct guest_info * core, ui struct generic_internal *state = (struct generic_internal *) priv_data; #endif - PrintDebug("generic (%s): writing 0x%x bytes to port 0x%x using %s ...", state->name, + PrintDebug(core->vm_info, core, "generic (%s): writing 0x%x bytes to port 0x%x using %s ...", state->name, length, port, state->forward_type == GENERIC_PHYSICAL ? "physical" : state->forward_type == GENERIC_HOST ? "host" : "UNKNOWN"); - PrintDebug("generic (%s): writing 0x", state->name); + PrintDebug(core->vm_info, core, "generic (%s): writing 0x", state->name); for (i = 0; i < length; i++) { - PrintDebug("%x", ((uint8_t *)src)[i]); + PrintDebug(core->vm_info, core, "%x", ((uint8_t *)src)[i]); } - PrintDebug(" to port 0x%x ... ", port); + PrintDebug(core->vm_info, core, " to port 0x%x ... ", port); rc=generic_write_port_passthrough(core,port,src,length,priv_data); - PrintDebug(" done\n"); + PrintDebug(core->vm_info, core, " done\n"); return rc; } @@ -170,7 +170,7 @@ static int generic_read_port_passthrough(struct guest_info * core, break; #endif default: - PrintError("generic (%s): unknown forwarding type\n", state->name); + PrintError(core->vm_info, core, "generic (%s): unknown forwarding type\n", state->name); return -1; break; } @@ -187,20 +187,20 @@ static int generic_read_port_print_and_passthrough(struct guest_info * core, uin struct generic_internal *state = (struct generic_internal *) priv_data; #endif - PrintDebug("generic (%s): reading 0x%x bytes from port 0x%x using %s ...", state->name, length, port, + PrintDebug(core->vm_info, core, "generic (%s): reading 0x%x bytes from port 0x%x using %s ...", state->name, length, port, state->forward_type == GENERIC_PHYSICAL ? "physical" : state->forward_type == GENERIC_HOST ? "host" : "UNKNOWN"); rc=generic_read_port_passthrough(core,port,src,length,priv_data); - PrintDebug(" done ... read 0x"); + PrintDebug(core->vm_info, core, " done ... read 0x"); for (i = 0; i < rc; i++) { - PrintDebug("%x", ((uint8_t *)src)[i]); + PrintDebug(core->vm_info, core, "%x", ((uint8_t *)src)[i]); } - PrintDebug("\n"); + PrintDebug(core->vm_info, core, "\n"); return rc; } @@ -221,13 +221,13 @@ static int generic_read_port_print_and_ignore(struct guest_info * core, uint16_t struct generic_internal *state = (struct generic_internal *) priv_data; #endif - PrintDebug("generic (%s): reading 0x%x bytes from port 0x%x using %s ...", state->name, length, port, + PrintDebug(core->vm_info, core, "generic (%s): reading 0x%x bytes from port 0x%x using %s ...", state->name, length, port, state->forward_type == GENERIC_PHYSICAL ? "physical" : state->forward_type == GENERIC_HOST ? "host" : "UNKNOWN"); memset((uint8_t *)src, 0, length); - PrintDebug(" ignored (return zeroed buffer)\n"); + PrintDebug(core->vm_info, core, " ignored (return zeroed buffer)\n"); return length; } @@ -246,18 +246,18 @@ static int generic_write_port_print_and_ignore(struct guest_info * core, uint16_ struct generic_internal *state = (struct generic_internal *) priv_data; #endif - PrintDebug("generic (%s): writing 0x%x bytes to port 0x%x using %s ", state->name, length, port, + PrintDebug(core->vm_info, core, "generic (%s): writing 0x%x bytes to port 0x%x using %s ", state->name, length, port, state->forward_type == GENERIC_PHYSICAL ? "physical" : state->forward_type == GENERIC_HOST ? "host" : "UNKNOWN"); memset((uint8_t *)src, 0, length); - PrintDebug(" ignored - data was: 0x"); + PrintDebug(core->vm_info, core, " ignored - data was: 0x"); for (i = 0; i < length; i++) { - PrintDebug("%x", ((uint8_t *)src)[i]); + PrintDebug(core->vm_info, core, "%x", ((uint8_t *)src)[i]); } - PrintDebug("\n"); + PrintDebug(core->vm_info, core, "\n"); return length; } @@ -288,7 +288,7 @@ static int generic_write_mem_passthrough(struct guest_info * core, break; #endif default: - PrintError("generic (%s): unknown forwarding type\n", state->name); + PrintError(core->vm_info, core, "generic (%s): unknown forwarding type\n", state->name); return -1; break; } @@ -305,14 +305,14 @@ static int generic_write_mem_print_and_passthrough(struct guest_info * core, struct generic_internal *state = (struct generic_internal *) dev->private_data; #endif - PrintDebug("generic (%s): writing %u bytes to GPA 0x%p via %s ... ", state->name, + PrintDebug(core->vm_info, core, "generic (%s): writing %u bytes to GPA 0x%p via %s ... ", state->name, len,(void*)gpa, state->forward_type == GENERIC_PHYSICAL ? "physical" : state->forward_type == GENERIC_HOST ? "host" : "UNKNOWN"); int rc = generic_write_mem_passthrough(core,gpa,src,len,priv); - PrintDebug("done\n"); + PrintDebug(core->vm_info, core, "done\n"); return rc; } @@ -337,7 +337,7 @@ static int generic_write_mem_print_and_ignore(struct guest_info * core, struct generic_internal *state = (struct generic_internal *) dev->private_data; #endif - PrintDebug("generic (%s): ignoring write of %u bytes to GPA 0x%p via %s", state->name, + PrintDebug(core->vm_info, core, "generic (%s): ignoring write of %u bytes to GPA 0x%p via %s", state->name, len,(void*)gpa, state->forward_type == GENERIC_PHYSICAL ? "physical" : state->forward_type == GENERIC_HOST ? "host" : "UNKNOWN"); @@ -369,7 +369,7 @@ static int generic_read_mem_passthrough(struct guest_info * core, break; #endif default: - PrintError("generic (%s): unknown forwarding type\n", state->name); + PrintError(core->vm_info, core, "generic (%s): unknown forwarding type\n", state->name); break; } @@ -387,14 +387,14 @@ static int generic_read_mem_print_and_passthrough(struct guest_info * core, struct generic_internal *state = (struct generic_internal *) dev->private_data; #endif - PrintDebug("generic (%s): attempting to read %u bytes from GPA 0x%p via %s ... ", state->name, + PrintDebug(core->vm_info, core, "generic (%s): attempting to read %u bytes from GPA 0x%p via %s ... ", state->name, len,(void*)gpa, state->forward_type == GENERIC_PHYSICAL ? "physical" : state->forward_type == GENERIC_HOST ? "host" : "UNKNOWN"); int rc = generic_read_mem_passthrough(core,gpa,dst,len,priv); - PrintDebug("done - read %d bytes\n", rc); + PrintDebug(core->vm_info, core, "done - read %d bytes\n", rc); return rc; } @@ -410,14 +410,14 @@ static int generic_read_mem_ignore(struct guest_info * core, struct generic_internal *state = (struct generic_internal *) dev->private_data; #endif - PrintDebug("generic (%s): ignoring attempt to read %u bytes from GPA 0x%p via %s ... ", state->name, + PrintDebug(core->vm_info, core, "generic (%s): ignoring attempt to read %u bytes from GPA 0x%p via %s ... ", state->name, len,(void*)gpa, state->forward_type == GENERIC_PHYSICAL ? "physical" : state->forward_type == GENERIC_HOST ? "host" : "UNKNOWN"); memset((uint8_t *)dst, 0, len); - PrintDebug("returning zeros\n"); + PrintDebug(core->vm_info, core, "returning zeros\n"); return len; } @@ -437,7 +437,7 @@ static int generic_read_mem_print_and_ignore(struct guest_info * core, static int generic_free(struct generic_internal * state) { int i; - PrintDebug("generic (%s): deinit_device\n", state->name); + PrintDebug(VM_NONE,VCORE_NONE, "generic (%s): deinit_device\n", state->name); #ifdef V3_CONFIG_HOST_DEVICE if (state->host_dev) { @@ -450,7 +450,7 @@ static int generic_free(struct generic_internal * state) { // We need to handle unhooking memory regions for (i=0;inum_mem_hooks;i++) { if (v3_unhook_mem(state->dev->vm,V3_MEM_CORE_ANY,state->mem_hook[i])<0) { - PrintError("generic (%s): unable to unhook memory starting at 0x%p\n", state->name,(void*)(state->mem_hook[i])); + PrintError(VM_NONE,VCORE_NONE , "generic (%s): unable to unhook memory starting at 0x%p\n", state->name,(void*)(state->mem_hook[i])); return -1; } } @@ -475,7 +475,7 @@ static int add_port_range(struct vm_device * dev, uint_t start, uint_t end, gene struct generic_internal *state = (struct generic_internal *) dev->private_data; - PrintDebug("generic (%s): adding port range 0x%x to 0x%x as %s\n", state->name, + PrintDebug(VM_NONE, VCORE_NONE, "generic (%s): adding port range 0x%x to 0x%x as %s\n", state->name, start, end, (mode == GENERIC_PRINT_AND_PASSTHROUGH) ? "print-and-passthrough" : (mode == GENERIC_PRINT_AND_IGNORE) ? "print-and-ignore" : @@ -488,7 +488,7 @@ static int add_port_range(struct vm_device * dev, uint_t start, uint_t end, gene if (v3_dev_hook_io(dev, i, &generic_read_port_print_and_passthrough, &generic_write_port_print_and_passthrough) == -1) { - PrintError("generic (%s): can't hook port 0x%x (already hooked?)\n", state->name, i); + PrintError(VM_NONE, VCORE_NONE, "generic (%s): can't hook port 0x%x (already hooked?)\n", state->name, i); return -1; } break; @@ -497,7 +497,7 @@ static int add_port_range(struct vm_device * dev, uint_t start, uint_t end, gene if (v3_dev_hook_io(dev, i, &generic_read_port_print_and_ignore, &generic_write_port_print_and_ignore) == -1) { - PrintError("generic (%s): can't hook port 0x%x (already hooked?)\n", state->name, i); + PrintError(VM_NONE, VCORE_NONE, "generic (%s): can't hook port 0x%x (already hooked?)\n", state->name, i); return -1; } break; @@ -505,7 +505,7 @@ static int add_port_range(struct vm_device * dev, uint_t start, uint_t end, gene if (v3_dev_hook_io(dev, i, &generic_read_port_passthrough, &generic_write_port_passthrough) == -1) { - PrintError("generic (%s): can't hook port 0x%x (already hooked?)\n", state->name, i); + PrintError(VM_NONE, VCORE_NONE, "generic (%s): can't hook port 0x%x (already hooked?)\n", state->name, i); return -1; } break; @@ -513,12 +513,12 @@ static int add_port_range(struct vm_device * dev, uint_t start, uint_t end, gene if (v3_dev_hook_io(dev, i, &generic_read_port_ignore, &generic_write_port_ignore) == -1) { - PrintError("generic (%s): can't hook port 0x%x (already hooked?)\n", state->name, i); + PrintError(VM_NONE, VCORE_NONE, "generic (%s): can't hook port 0x%x (already hooked?)\n", state->name, i); return -1; } break; default: - PrintError("generic (%s): huh?\n", state->name); + PrintError(VM_NONE, VCORE_NONE, "generic (%s): huh?\n", state->name); break; } } @@ -531,7 +531,7 @@ static int add_mem_range(struct vm_device * dev, addr_t start, addr_t end, gener struct generic_internal *state = (struct generic_internal *) dev->private_data; - PrintDebug("generic (%s): adding memory range 0x%p to 0x%p as %s\n", state->name, + PrintDebug(VM_NONE, VCORE_NONE, "generic (%s): adding memory range 0x%p to 0x%p as %s\n", state->name, (void*)start, (void*)end, (mode == GENERIC_PRINT_AND_PASSTHROUGH) ? "print-and-passthrough" : (mode == GENERIC_PRINT_AND_IGNORE) ? "print-and-ignore" : @@ -543,7 +543,7 @@ static int add_mem_range(struct vm_device * dev, addr_t start, addr_t end, gener if (v3_hook_full_mem(dev->vm, V3_MEM_CORE_ANY, start, end+1, &generic_read_mem_print_and_passthrough, &generic_write_mem_print_and_passthrough, dev) == -1) { - PrintError("generic (%s): can't hook memory region 0x%p to 0x%p\n", state->name,(void*)start,(void*)end); + PrintError(VM_NONE, VCORE_NONE, "generic (%s): can't hook memory region 0x%p to 0x%p\n", state->name,(void*)start,(void*)end); return -1; } break; @@ -552,7 +552,7 @@ static int add_mem_range(struct vm_device * dev, addr_t start, addr_t end, gener if (v3_hook_full_mem(dev->vm, V3_MEM_CORE_ANY, start, end+1, &generic_read_mem_print_and_ignore, &generic_write_mem_print_and_ignore, dev) == -1) { - PrintError("generic (%s): can't hook memory region 0x%p to 0x%p\n", state->name,(void*)start,(void*)end); + PrintError(VM_NONE, VCORE_NONE, "generic (%s): can't hook memory region 0x%p to 0x%p\n", state->name,(void*)start,(void*)end); return -1; } break; @@ -561,7 +561,7 @@ static int add_mem_range(struct vm_device * dev, addr_t start, addr_t end, gener if (v3_hook_full_mem(dev->vm, V3_MEM_CORE_ANY, start, end+1, &generic_read_mem_passthrough, &generic_write_mem_passthrough, dev) == -1) { - PrintError("generic (%s): can't hook memory region 0x%p to 0x%p\n", state->name,(void*)start,(void*)end); + PrintError(VM_NONE, VCORE_NONE, "generic (%s): can't hook memory region 0x%p to 0x%p\n", state->name,(void*)start,(void*)end); return -1; } break; @@ -570,12 +570,12 @@ static int add_mem_range(struct vm_device * dev, addr_t start, addr_t end, gener if (v3_hook_full_mem(dev->vm, V3_MEM_CORE_ANY, start, end+1, &generic_read_mem_ignore, &generic_write_mem_ignore, dev) == -1) { - PrintError("generic (%s): can't hook memory region 0x%p to 0x%p\n", state->name,(void*)start,(void*)end); + PrintError(VM_NONE, VCORE_NONE, "generic (%s): can't hook memory region 0x%p to 0x%p\n", state->name,(void*)start,(void*)end); return -1; } break; default: - PrintError("generic (%s): huh?\n",state->name); + PrintError(VM_NONE, VCORE_NONE, "generic (%s): huh?\n",state->name); break; } @@ -595,26 +595,25 @@ static int osdebug_hcall(struct guest_info *core, uint_t hcall_id, void * priv_d addr_t msg_gpa = core->vm_regs.rbx; int buf_is_va = core->vm_regs.rdx; int i; - uint8_t c; - - PrintDebug("generic (%s): handling hypercall (len=%d) as sequence of port writes\n", + uint8_t c; + PrintDebug(core->vm_info, core, "generic (%s): handling hypercall (len=%d) as sequence of port writes\n", state->name, msg_len); for (i=0;iname); + PrintError(core->vm_info, core, "generic (%s): could not read debug message\n",state->name); return -1; } } else { if (v3_read_gpa_memory(core, msg_gpa+i, 1, &c) != 1) { - PrintError("generic (%s): Could not read debug message\n",state->name); + PrintError(core->vm_info, core, "generic (%s): Could not read debug message\n",state->name); return -1; } } if (generic_write_port_print_and_passthrough(core,0xc0c0,&c,1,priv_data)!=1) { - PrintError("generic (%s): write port passthrough failed\n",state->name); + PrintError(core->vm_info, core, "generic (%s): write port passthrough failed\n",state->name); return -1; } } @@ -673,7 +672,7 @@ static int generic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { state = (struct generic_internal *)V3_Malloc(sizeof(struct generic_internal)); if (state == NULL) { - PrintError("generic (%s): could not allocate generic state\n",dev_id); + PrintError(vm, VCORE_NONE, "generic (%s): could not allocate generic state\n",dev_id); return -1; } @@ -689,12 +688,12 @@ static int generic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { #ifdef V3_CONFIG_HOST_DEVICE state->forward_type=GENERIC_HOST; #else - PrintError("generic (%s): cannot configure host device since host device support is not built in\n", state->name); + PrintError(vm, VCORE_NONE, "generic (%s): cannot configure host device since host device support is not built in\n", state->name); V3_Free(state); return -1; #endif } else { - PrintError("generic (%s): unknown forwarding type \"%s\"\n", state->name, forward); + PrintError(vm, VCORE_NONE, "generic (%s): unknown forwarding type \"%s\"\n", state->name, forward); V3_Free(state); return -1; } @@ -703,7 +702,7 @@ static int generic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, state); if (dev == NULL) { - PrintError("generic: could not attach device %s\n", state->name); + PrintError(vm, VCORE_NONE, "generic: could not attach device %s\n", state->name); V3_Free(state); return -1; } @@ -714,23 +713,23 @@ static int generic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { #ifdef V3_CONFIG_HOST_DEVICE if (state->forward_type==GENERIC_HOST) { if (!host_dev) { - PrintError("generic (%s): host forwarding requested, but no host device given\n", state->name); + PrintError(vm, VCORE_NONE, "generic (%s): host forwarding requested, but no host device given\n", state->name); v3_remove_device(dev); return -1; } else { state->host_dev = v3_host_dev_open(host_dev,V3_BUS_CLASS_DIRECT,dev,vm); if (!(state->host_dev)) { - PrintError("generic (%s): unable to open host device \"%s\"\n", state->name,host_dev); + PrintError(vm, VCORE_NONE, "generic (%s): unable to open host device \"%s\"\n", state->name,host_dev); v3_remove_device(dev); return -1; } else { - PrintDebug("generic (%s): successfully attached host device \"%s\"\n", state->name,host_dev); + PrintDebug(vm, VCORE_NONE, "generic (%s): successfully attached host device \"%s\"\n", state->name,host_dev); } } } #endif - PrintDebug("generic (%s): init_device\n", state->name); + PrintDebug(vm, VCORE_NONE, "generic (%s): init_device\n", state->name); // scan port list.... while (port_cfg) { @@ -747,14 +746,14 @@ static int generic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { } else if (strcasecmp(mode_str, "ignore") == 0) { mode = GENERIC_IGNORE; } else { - PrintError("generic (%s): invalid mode %s in adding ports\n", state->name, mode_str); + PrintError(vm, VCORE_NONE, "generic (%s): invalid mode %s in adding ports\n", state->name, mode_str); v3_remove_device(dev); return -1; } if (add_port_range(dev, start, end, mode) == -1) { - PrintError("generic (%s): could not add port range 0x%x to 0x%x\n", state->name, start, end); + PrintError(vm, VCORE_NONE, "generic (%s): could not add port range 0x%x to 0x%x\n", state->name, start, end); v3_remove_device(dev); return -1; } @@ -778,19 +777,19 @@ static int generic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { } else if (strcasecmp(mode_str, "ignore") == 0) { mode = GENERIC_IGNORE; } else { - PrintError("generic (%s): invalid mode %s for adding memory\n", state->name, mode_str); + PrintError(vm, VCORE_NONE, "generic (%s): invalid mode %s for adding memory\n", state->name, mode_str); v3_remove_device(dev); return -1; } if (state->num_mem_hooks>=MAX_MEM_HOOKS) { - PrintError("generic (%s): cannot add another memory hook (increase MAX_MEM_HOOKS)\n", state->name); + PrintError(vm, VCORE_NONE, "generic (%s): cannot add another memory hook (increase MAX_MEM_HOOKS)\n", state->name); v3_remove_device(dev); return -1; } if (add_mem_range(dev, start, end, mode) == -1) { - PrintError("generic (%s): could not add memory range 0x%p to 0x%p\n", state->name, (void*)start, (void*)end); + PrintError(vm, VCORE_NONE, "generic (%s): could not add memory range 0x%p to 0x%p\n", state->name, (void*)start, (void*)end); v3_remove_device(dev); return -1; } @@ -804,12 +803,12 @@ static int generic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { #if 1 // hack for os debug testing if (strcasecmp(state->name,"os debug")==0) { - PrintDebug("generic (%s): adding hypercall for os debug device\n", state->name); + PrintDebug(vm, VCORE_NONE, "generic (%s): adding hypercall for os debug device\n", state->name); v3_register_hypercall(vm,0xc0c0,osdebug_hcall,state); } #endif - PrintDebug("generic (%s): initialization complete\n", state->name); + PrintDebug(vm, VCORE_NONE, "generic (%s): initialization complete\n", state->name); return 0; } diff --git a/palacios/src/devices/host_pci.c b/palacios/src/devices/host_pci.c index 8db3c3a..b12d3a0 100644 --- a/palacios/src/devices/host_pci.c +++ b/palacios/src/devices/host_pci.c @@ -78,7 +78,7 @@ static int pci_exp_rom_init(struct vm_device * dev, struct host_pci_state * stat - PrintDebug("Adding 32 bit PCI mem region: start=%p, end=%p\n", + PrintDebug(info->vm_info, info, "Adding 32 bit PCI mem region: start=%p, end=%p\n", (void *)(addr_t)hrom->addr, (void *)(addr_t)(hrom->addr + hrom->size)); @@ -94,7 +94,7 @@ static int pci_exp_rom_init(struct vm_device * dev, struct host_pci_state * stat memcpy(&(state->virt_exp_rom), hrom, sizeof(struct v3_host_pci_bar)); - PrintDebug("phys exp_rom: addr=%p, size=%u\n", + PrintDebug(info->vm_info, info, "phys exp_rom: addr=%p, size=%u\n", (void *)(addr_t)hrom->addr, hrom->size); @@ -121,7 +121,7 @@ static int pt_io_read(struct guest_info * core, uint16_t port, void * dst, uint_ } else if (length == 4) { *(uint32_t *)dst = v3_indw(pbar->addr + port_offset); } else { - PrintError("Invalid PCI passthrough IO Redirection size read\n"); + PrintError(core->vm_info, core, "Invalid PCI passthrough IO Redirection size read\n"); return -1; } @@ -140,7 +140,7 @@ static int pt_io_write(struct guest_info * core, uint16_t port, void * src, uint } else if (length == 4) { v3_outdw(pbar->addr + port_offset, *(uint32_t *)src); } else { - PrintError("Invalid PCI passthrough IO Redirection size write\n"); + PrintError(core->vm_info, core, "Invalid PCI passthrough IO Redirection size write\n"); return -1; } @@ -215,7 +215,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { // unhook old ports for (i = 0; i < vbar->size; i++) { if (v3_unhook_io_port(dev->vm, vbar->addr + i) == -1) { - PrintError("Could not unhook previously hooked port.... %d (0x%x)\n", + PrintError(VM_NONE, VCORE_NONE, "Could not unhook previously hooked port.... %d (0x%x)\n", (uint32_t)vbar->addr + i, (uint32_t)vbar->addr + i); return -1; } @@ -227,7 +227,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { // udpate source version *src = PCI_IO_BAR_VAL(vbar->addr); - PrintDebug("Rehooking passthrough IO ports starting at %d (0x%x)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Rehooking passthrough IO ports starting at %d (0x%x)\n", (uint32_t)vbar->addr, (uint32_t)vbar->addr); if (vbar->addr == hbar->addr) { @@ -247,7 +247,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { if (old_reg == NULL) { // uh oh... - PrintError("Could not find PCI Passthrough memory redirection region (addr=0x%x)\n", (uint32_t)vbar->addr); + PrintError(VM_NONE, VCORE_NONE, "Could not find PCI Passthrough memory redirection region (addr=0x%x)\n", (uint32_t)vbar->addr); return -1; } @@ -259,7 +259,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { // Set reserved bits *src = PCI_MEM32_BAR_VAL(vbar->addr, hbar->prefetchable); - PrintDebug("Adding pci Passthrough remapping: start=0x%x, size=%d, end=0x%x (hpa=%p)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Adding pci Passthrough remapping: start=0x%x, size=%d, end=0x%x (hpa=%p)\n", (uint32_t)vbar->addr, vbar->size, (uint32_t)vbar->addr + vbar->size, (void *)hbar->addr); v3_add_shadow_mem(dev->vm, V3_MEM_CORE_ANY, @@ -281,7 +281,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { if (old_reg == NULL) { // uh oh... - PrintError("Could not find PCI Passthrough memory redirection region (addr=%p)\n", + PrintError(VM_NONE, VCORE_NONE, "Could not find PCI Passthrough memory redirection region (addr=%p)\n", (void *)(addr_t)vbar->addr); return -1; } @@ -295,14 +295,14 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { // src does not change, because there are no reserved bits - PrintDebug("Adding pci Passthrough remapping: start=%p, size=%p, end=%p\n", + PrintDebug(VM_NONE, VCORE_NONE, "Adding pci Passthrough remapping: start=%p, size=%p, end=%p\n", (void *)(addr_t)vbar->addr, (void *)(addr_t)vbar->size, (void *)(addr_t)(vbar->addr + vbar->size)); if (v3_add_shadow_mem(dev->vm, V3_MEM_CORE_ANY, vbar->addr, vbar->addr + vbar->size - 1, hbar->addr) == -1) { - PrintDebug("Fail to insert shadow region (%p, %p) -> %p\n", + PrintDebug(VM_NONE, VCORE_NONE, "Fail to insert shadow region (%p, %p) -> %p\n", (void *)(addr_t)vbar->addr, (void *)(addr_t)(vbar->addr + vbar->size - 1), (void *)(addr_t)hbar->addr); @@ -310,7 +310,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { } } else { - PrintError("Unhandled Pasthrough PCI Bar type %d\n", vbar->type); + PrintError(VM_NONE, VCORE_NONE, "Unhandled Pasthrough PCI Bar type %d\n", vbar->type); return -1; } @@ -323,7 +323,7 @@ static int pt_config_write(struct pci_device * pci_dev, uint32_t reg_num, void * struct vm_device * dev = (struct vm_device *)private_data; struct host_pci_state * state = (struct host_pci_state *)dev->private_data; -// V3_Print("Writing host PCI config space update\n"); +// V3_Print(VM_NONE, VCORE_NONE, "Writing host PCI config space update\n"); // We will mask all operations to the config header itself, // and only allow direct access to the device specific config space @@ -340,7 +340,7 @@ static int pt_config_read(struct pci_device * pci_dev, uint32_t reg_num, void * struct vm_device * dev = (struct vm_device *)private_data; struct host_pci_state * state = (struct host_pci_state *)dev->private_data; - // V3_Print("Reading host PCI config space update\n"); + // V3_Print(VM_NONE, VCORE_NONE, "Reading host PCI config space update\n"); return v3_host_pci_config_read(state->host_dev, reg_num, dst, length); } @@ -360,9 +360,9 @@ static int pt_exp_rom_write(struct pci_device * pci_dev, uint32_t * src, void * struct v3_host_pci_bar * hrom = &(state->host_dev->exp_rom); struct v3_host_pci_bar * vrom = &(state->virt_exp_rom); - PrintDebug("exp_rom update: src=0x%x\n", *src); - PrintDebug("vrom is size=%u, addr=0x%x\n", vrom->size, (uint32_t)vrom->addr); - PrintDebug("hrom is size=%u, addr=0x%x\n", hrom->size, (uint32_t)hrom->addr); + PrintDebug(VM_NONE, VCORE_NONE, "exp_rom update: src=0x%x\n", *src); + PrintDebug(VM_NONE, VCORE_NONE, "vrom is size=%u, addr=0x%x\n", vrom->size, (uint32_t)vrom->addr); + PrintDebug(VM_NONE, VCORE_NONE, "hrom is size=%u, addr=0x%x\n", hrom->size, (uint32_t)hrom->addr); if (hrom->exp_rom_enabled) { // only remove old mapping if present, I.E. if the rom was enabled previously @@ -371,7 +371,7 @@ static int pt_exp_rom_write(struct pci_device * pci_dev, uint32_t * src, void * if (old_reg == NULL) { // uh oh... - PrintError("Could not find PCI Passthrough exp_rom_base redirection region (addr=0x%x)\n", (uint32_t)vrom->addr); + PrintError(VM_NONE, VCORE_NONE, "Could not find PCI Passthrough exp_rom_base redirection region (addr=0x%x)\n", (uint32_t)vrom->addr); return -1; } @@ -384,15 +384,15 @@ static int pt_exp_rom_write(struct pci_device * pci_dev, uint32_t * src, void * // Set flags in actual register value *src = PCI_EXP_ROM_VAL(vrom->addr, (*src & 0x00000001)); - PrintDebug("Cooked src=0x%x\n", *src); + PrintDebug(VM_NONE, VCORE_NONE, "Cooked src=0x%x\n", *src); - PrintDebug("Adding pci Passthrough exp_rom_base remapping: start=0x%x, size=%u, end=0x%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "Adding pci Passthrough exp_rom_base remapping: start=0x%x, size=%u, end=0x%x\n", (uint32_t)vrom->addr, vrom->size, (uint32_t)vrom->addr + vrom->size); if (v3_add_shadow_mem(dev->vm, V3_MEM_CORE_ANY, vrom->addr, vrom->addr + vrom->size - 1, hrom->addr) == -1) { - PrintError("Failed to remap pci exp_rom: start=0x%x, size=%u, end=0x%x\n", + PrintError(VM_NONE, VCORE_NONE, "Failed to remap pci exp_rom: start=0x%x, size=%u, end=0x%x\n", (uint32_t)vrom->addr, vrom->size, (uint32_t)vrom->addr + vrom->size); return -1; } @@ -406,7 +406,7 @@ static int pt_cmd_update(struct pci_device * pci, pci_cmd_t cmd, uint64_t arg, v struct vm_device * dev = (struct vm_device *)(priv_data); struct host_pci_state * state = (struct host_pci_state *)dev->private_data; - V3_Print("Host PCI Device: CMD update (%d)(arg=%llu)\n", cmd, arg); + V3_Print(VM_NONE, VCORE_NONE, "Host PCI Device: CMD update (%d)(arg=%llu)\n", cmd, arg); v3_host_pci_cmd_update(state->host_dev, cmd, arg); @@ -455,7 +455,7 @@ static int setup_virt_pci_dev(struct v3_vm_info * vm_info, struct vm_device * de #ifdef V3_CONFIG_SYMBIOTIC v3_sym_map_pci_passthrough(vm_info, pci_dev->bus_num, pci_dev->dev_num, pci_dev->fn_num); #else - PrintError("ERROR Symbiotic Passthrough is not enabled\n"); + PrintError(VM_NONE, VCORE_NONE, "ERROR Symbiotic Passthrough is not enabled\n"); return -1; #endif } @@ -473,7 +473,7 @@ static int irq_ack(struct guest_info * core, uint32_t irq, void * private_data) struct host_pci_state * state = (struct host_pci_state *)private_data; - // V3_Print("Acking IRQ %d\n", irq); + // V3_Print(core->vm_info, core, "Acking IRQ %d\n", irq); v3_host_pci_ack_irq(state->host_dev, irq); return 0; @@ -489,7 +489,7 @@ static int irq_handler(void * private_data, uint32_t vec_index) { vec.private_data = state; - // V3_Print("Raising host PCI IRQ %d\n", vec_index); + // V3_Print(VM_NONE, VCORE_NONE, "Raising host PCI IRQ %d\n", vec_index); if (state->pci_dev->irq_type == IRQ_NONE) { return 0; @@ -513,7 +513,7 @@ static int host_pci_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { memset(state, 0, sizeof(struct host_pci_state)); if (!pci) { - PrintError("PCI bus not specified in config file\n"); + PrintError(vm, VCORE_NONE, "PCI bus not specified in config file\n"); return -1; } @@ -524,7 +524,7 @@ static int host_pci_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { dev = v3_add_device(vm, dev_id, &dev_ops, state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(state); return -1; } @@ -532,7 +532,7 @@ static int host_pci_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { state->host_dev = v3_host_pci_get_dev(vm, url, state); if (state->host_dev == NULL) { - PrintError("Could not connect to host pci device (%s)\n", url); + PrintError(vm, VCORE_NONE, "Could not connect to host pci device (%s)\n", url); return -1; } @@ -540,7 +540,7 @@ static int host_pci_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { state->host_dev->irq_handler = irq_handler; if (setup_virt_pci_dev(vm, dev) == -1) { - PrintError("Could not setup virtual host PCI device\n"); + PrintError(vm, VCORE_NONE, "Could not setup virtual host PCI device\n"); return -1; } diff --git a/palacios/src/devices/i440fx.c b/palacios/src/devices/i440fx.c index 800633f..a68e275 100644 --- a/palacios/src/devices/i440fx.c +++ b/palacios/src/devices/i440fx.c @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -32,12 +33,12 @@ struct i440_state { static int io_read(struct guest_info * core, ushort_t port, void * dst, uint_t length, void * priv_data) { - PrintError("Unhandled read on port %x\n", port); + PrintError(core->vm_info, core, "Unhandled read on port %x\n", port); return -1; } static int io_write(struct guest_info * core, ushort_t port, void * src, uint_t length, void * priv_data) { - PrintError("Unhandled write on port %x\n", port); + PrintError(core->vm_info, core, "Unhandled write on port %x\n", port); return -1; } @@ -72,14 +73,14 @@ static int i440_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { int ret = 0; if (!pci) { - PrintError("could not find PCI Device\n"); + PrintError(vm, VCORE_NONE, "could not find PCI Device\n"); return -1; } state = (struct i440_state *)V3_Malloc(sizeof(struct i440_state)); if (!state) { - PrintError("Cannot allocate state\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate state\n"); return -1; } @@ -88,7 +89,7 @@ static int i440_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(state); return -1; } @@ -100,7 +101,7 @@ static int i440_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { /* if (ret != 0) { - PrintError("Error hooking i440FX io ports\n"); + PrintError(vm, VCORE_NONE, "Error hooking i440FX io ports\n"); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/ide.c b/palacios/src/devices/ide.c index 7f266ff..e0da650 100644 --- a/palacios/src/devices/ide.c +++ b/palacios/src/devices/ide.c @@ -292,7 +292,7 @@ static inline int is_lba_enabled(struct ide_channel * channel) { static void ide_raise_irq(struct ide_internal * ide, struct ide_channel * channel) { if (channel->ctrl_reg.irq_disable == 0) { - //PrintError("Raising IDE Interrupt %d\n", channel->irq); + //PrintError(info->vm_info, info, "Raising IDE Interrupt %d\n", channel->irq); channel->dma_status.int_gen = 1; v3_raise_irq(ide->vm, channel->irq); @@ -304,7 +304,7 @@ static void drive_reset(struct ide_drive * drive) { drive->sector_count = 0x01; drive->sector_num = 0x01; - PrintDebug("Resetting drive %s\n", drive->model); + PrintDebug(VM_NONE,VCORE_NONE, "Resetting drive %s\n", drive->model); if (drive->drive_type == BLOCK_CDROM) { drive->cylinder = 0xeb14; @@ -371,7 +371,7 @@ static void print_prd_table(struct ide_internal * ide, struct ide_channel * chan struct ide_dma_prd prd_entry; int index = 0; - V3_Print("Dumping PRD table\n"); + V3_Print(VM_NONE, VCORE_NONE,"Dumping PRD table\n"); while (1) { uint32_t prd_entry_addr = channel->dma_prd_addr + (sizeof(struct ide_dma_prd) * index); @@ -380,11 +380,11 @@ static void print_prd_table(struct ide_internal * ide, struct ide_channel * chan ret = v3_read_gpa_memory(&(ide->vm->cores[0]), prd_entry_addr, sizeof(struct ide_dma_prd), (void *)&prd_entry); if (ret != sizeof(struct ide_dma_prd)) { - PrintError("Could not read PRD\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not read PRD\n"); return; } - V3_Print("\tPRD Addr: %x, PRD Len: %d, EOT: %d\n", + V3_Print(VM_NONE, VCORE_NONE,"\tPRD Addr: %x, PRD Len: %d, EOT: %d\n", prd_entry.base_addr, (prd_entry.size == 0) ? 0x10000 : prd_entry.size, prd_entry.end_of_table); @@ -414,7 +414,7 @@ static int dma_read(struct guest_info * core, struct ide_internal * ide, struct print_prd_table(ide, channel); #endif - PrintDebug("DMA read for %d bytes\n", bytes_left); + PrintDebug(core->vm_info, core, "DMA read for %d bytes\n", bytes_left); // Loop through the disk data while (bytes_left > 0) { @@ -423,16 +423,16 @@ static int dma_read(struct guest_info * core, struct ide_internal * ide, struct uint_t prd_offset = 0; int ret; - PrintDebug("PRD table address = %x\n", channel->dma_prd_addr); + PrintDebug(core->vm_info, core, "PRD table address = %x\n", channel->dma_prd_addr); ret = v3_read_gpa_memory(core, prd_entry_addr, sizeof(struct ide_dma_prd), (void *)&prd_entry); if (ret != sizeof(struct ide_dma_prd)) { - PrintError("Could not read PRD\n"); + PrintError(core->vm_info, core, "Could not read PRD\n"); return -1; } - PrintDebug("PRD Addr: %x, PRD Len: %d, EOT: %d\n", + PrintDebug(core->vm_info, core, "PRD Addr: %x, PRD Len: %d, EOT: %d\n", prd_entry.base_addr, prd_entry.size, prd_entry.end_of_table); // loop through the PRD data.... @@ -453,7 +453,7 @@ static int dma_read(struct guest_info * core, struct ide_internal * ide, struct if (ata_read(ide, channel, drive->data_buf, 1) == -1) { - PrintError("Failed to read next disk sector\n"); + PrintError(core->vm_info, core, "Failed to read next disk sector\n"); return -1; } } else if (drive->drive_type == BLOCK_CDROM) { @@ -461,23 +461,23 @@ static int dma_read(struct guest_info * core, struct ide_internal * ide, struct bytes_to_write = (prd_bytes_left > ATAPI_BLOCK_SIZE) ? ATAPI_BLOCK_SIZE : prd_bytes_left; if (atapi_read_chunk(ide, channel) == -1) { - PrintError("Failed to read next disk sector\n"); + PrintError(core->vm_info, core, "Failed to read next disk sector\n"); return -1; } } else { /* - PrintError("How does this work (ATAPI CMD=%x)???\n", drive->cd_state.atapi_cmd); + PrintError(core->vm_info, core, "How does this work (ATAPI CMD=%x)???\n", drive->cd_state.atapi_cmd); return -1; */ int cmd_ret = 0; - //V3_Print("DMA of command packet\n"); + //V3_Print(core->vm_info, core, "DMA of command packet\n"); bytes_to_write = (prd_bytes_left > bytes_left) ? bytes_left : prd_bytes_left; prd_bytes_left = bytes_to_write; - // V3_Print("Writing ATAPI cmd OP DMA (cmd=%x) (len=%d)\n", drive->cd_state.atapi_cmd, prd_bytes_left); + // V3_Print(core->vm_info, core, "Writing ATAPI cmd OP DMA (cmd=%x) (len=%d)\n", drive->cd_state.atapi_cmd, prd_bytes_left); cmd_ret = v3_write_gpa_memory(core, prd_entry.base_addr + prd_offset, bytes_to_write, drive->data_buf); @@ -503,7 +503,7 @@ static int dma_read(struct guest_info * core, struct ide_internal * ide, struct } } - PrintDebug("Writing DMA data to guest Memory ptr=%p, len=%d\n", + PrintDebug(core->vm_info, core, "Writing DMA data to guest Memory ptr=%p, len=%d\n", (void *)(addr_t)(prd_entry.base_addr + prd_offset), bytes_to_write); drive->current_lba++; @@ -511,11 +511,11 @@ static int dma_read(struct guest_info * core, struct ide_internal * ide, struct ret = v3_write_gpa_memory(core, prd_entry.base_addr + prd_offset, bytes_to_write, drive->data_buf); if (ret != bytes_to_write) { - PrintError("Failed to copy data into guest memory... (ret=%d)\n", ret); + PrintError(core->vm_info, core, "Failed to copy data into guest memory... (ret=%d)\n", ret); return -1; } - PrintDebug("\t DMA ret=%d, (prd_bytes_left=%d) (bytes_left=%d)\n", ret, prd_bytes_left, bytes_left); + PrintDebug(core->vm_info, core, "\t DMA ret=%d, (prd_bytes_left=%d) (bytes_left=%d)\n", ret, prd_bytes_left, bytes_left); drive->transfer_index += ret; prd_bytes_left -= ret; @@ -527,14 +527,14 @@ static int dma_read(struct guest_info * core, struct ide_internal * ide, struct if (drive->drive_type == BLOCK_DISK) { if (drive->transfer_index % HD_SECTOR_SIZE) { - PrintError("We currently don't handle sectors that span PRD descriptors\n"); + PrintError(core->vm_info, core, "We currently don't handle sectors that span PRD descriptors\n"); return -1; } } else if (drive->drive_type == BLOCK_CDROM) { if (atapi_cmd_is_data_op(drive->cd_state.atapi_cmd)) { if (drive->transfer_index % ATAPI_BLOCK_SIZE) { - PrintError("We currently don't handle ATAPI BLOCKS that span PRD descriptors\n"); - PrintError("transfer_index=%d, transfer_length=%d\n", + PrintError(core->vm_info, core, "We currently don't handle ATAPI BLOCKS that span PRD descriptors\n"); + PrintError(core->vm_info, core, "transfer_index=%d, transfer_length=%d\n", drive->transfer_index, drive->transfer_length); return -1; } @@ -543,7 +543,7 @@ static int dma_read(struct guest_info * core, struct ide_internal * ide, struct if ((prd_entry.end_of_table == 1) && (bytes_left > 0)) { - PrintError("DMA table not large enough for data transfer...\n"); + PrintError(core->vm_info, core, "DMA table not large enough for data transfer...\n"); return -1; } } @@ -583,7 +583,7 @@ static int dma_write(struct guest_info * core, struct ide_internal * ide, struct uint_t bytes_left = drive->transfer_length; - PrintDebug("DMA write from %d bytes\n", bytes_left); + PrintDebug(core->vm_info, core, "DMA write from %d bytes\n", bytes_left); // Loop through disk data while (bytes_left > 0) { @@ -592,16 +592,16 @@ static int dma_write(struct guest_info * core, struct ide_internal * ide, struct uint_t prd_offset = 0; int ret; - PrintDebug("PRD Table address = %x\n", channel->dma_prd_addr); + PrintDebug(core->vm_info, core, "PRD Table address = %x\n", channel->dma_prd_addr); ret = v3_read_gpa_memory(core, prd_entry_addr, sizeof(struct ide_dma_prd), (void *)&prd_entry); if (ret != sizeof(struct ide_dma_prd)) { - PrintError("Could not read PRD\n"); + PrintError(core->vm_info, core, "Could not read PRD\n"); return -1; } - PrintDebug("PRD Addr: %x, PRD Len: %d, EOT: %d\n", + PrintDebug(core->vm_info, core, "PRD Addr: %x, PRD Len: %d, EOT: %d\n", prd_entry.base_addr, prd_entry.size, prd_entry.end_of_table); @@ -622,15 +622,15 @@ static int dma_write(struct guest_info * core, struct ide_internal * ide, struct ret = v3_read_gpa_memory(core, prd_entry.base_addr + prd_offset, bytes_to_write, drive->data_buf); if (ret != bytes_to_write) { - PrintError("Faild to copy data from guest memory... (ret=%d)\n", ret); + PrintError(core->vm_info, core, "Faild to copy data from guest memory... (ret=%d)\n", ret); return -1; } - PrintDebug("\t DMA ret=%d (prd_bytes_left=%d) (bytes_left=%d)\n", ret, prd_bytes_left, bytes_left); + PrintDebug(core->vm_info, core, "\t DMA ret=%d (prd_bytes_left=%d) (bytes_left=%d)\n", ret, prd_bytes_left, bytes_left); if (ata_write(ide, channel, drive->data_buf, 1) == -1) { - PrintError("Failed to write data to disk\n"); + PrintError(core->vm_info, core, "Failed to write data to disk\n"); return -1; } @@ -645,15 +645,15 @@ static int dma_write(struct guest_info * core, struct ide_internal * ide, struct channel->dma_tbl_index++; if (drive->transfer_index % HD_SECTOR_SIZE) { - PrintError("We currently don't handle sectors that span PRD descriptors\n"); + PrintError(core->vm_info, core, "We currently don't handle sectors that span PRD descriptors\n"); return -1; } if ((prd_entry.end_of_table == 1) && (bytes_left > 0)) { - PrintError("DMA table not large enough for data transfer...\n"); - PrintError("\t(bytes_left=%u) (transfer_length=%u)...\n", + PrintError(core->vm_info, core, "DMA table not large enough for data transfer...\n"); + PrintError(core->vm_info, core, "\t(bytes_left=%u) (transfer_length=%u)...\n", bytes_left, drive->transfer_length); - PrintError("PRD Addr: %x, PRD Len: %d, EOT: %d\n", + PrintError(core->vm_info, core, "PRD Addr: %x, PRD Len: %d, EOT: %d\n", prd_entry.base_addr, prd_entry.size, prd_entry.end_of_table); print_prd_table(ide, channel); @@ -694,7 +694,7 @@ static int write_dma_port(struct guest_info * core, ushort_t port, void * src, u uint_t channel_flag = (port & DMA_CHANNEL_FLAG) >> 3; struct ide_channel * channel = &(ide->channels[channel_flag]); - PrintDebug("IDE: Writing DMA Port %x (%s) (val=%x) (len=%d) (channel=%d)\n", + PrintDebug(core->vm_info, core, "IDE: Writing DMA Port %x (%s) (val=%x) (len=%d) (channel=%d)\n", port, dma_port_to_str(port_offset), *(uint32_t *)src, length, channel_flag); switch (port_offset) { @@ -709,13 +709,13 @@ static int write_dma_port(struct guest_info * core, ushort_t port, void * src, u if (channel->dma_cmd.read == 1) { // DMA Read if (dma_read(core, ide, channel) == -1) { - PrintError("Failed DMA Read\n"); + PrintError(core->vm_info, core, "Failed DMA Read\n"); return -1; } } else { // DMA write if (dma_write(core, ide, channel) == -1) { - PrintError("Failed DMA Write\n"); + PrintError(core->vm_info, core, "Failed DMA Write\n"); return -1; } } @@ -729,7 +729,7 @@ static int write_dma_port(struct guest_info * core, ushort_t port, void * src, u uint8_t val = *(uint8_t *)src; if (length != 1) { - PrintError("Invalid read length for DMA status port\n"); + PrintError(core->vm_info, core, "Invalid read length for DMA status port\n"); return -1; } @@ -749,7 +749,7 @@ static int write_dma_port(struct guest_info * core, ushort_t port, void * src, u int i = 0; if (addr_index + length > 4) { - PrintError("DMA Port space overrun port=%x len=%d\n", port_offset, length); + PrintError(core->vm_info, core, "DMA Port space overrun port=%x len=%d\n", port_offset, length); return -1; } @@ -757,12 +757,12 @@ static int write_dma_port(struct guest_info * core, ushort_t port, void * src, u addr_buf[addr_index + i] = *((uint8_t *)src + i); } - PrintDebug("Writing PRD Port %x (val=%x)\n", port_offset, channel->dma_prd_addr); + PrintDebug(core->vm_info, core, "Writing PRD Port %x (val=%x)\n", port_offset, channel->dma_prd_addr); break; } default: - PrintError("IDE: Invalid DMA Port (%d) (%s)\n", port, dma_port_to_str(port_offset)); + PrintError(core->vm_info, core, "IDE: Invalid DMA Port (%d) (%s)\n", port, dma_port_to_str(port_offset)); break; } @@ -776,16 +776,16 @@ static int read_dma_port(struct guest_info * core, uint16_t port, void * dst, ui uint_t channel_flag = (port & DMA_CHANNEL_FLAG) >> 3; struct ide_channel * channel = &(ide->channels[channel_flag]); - PrintDebug("Reading DMA port %d (%x) (channel=%d)\n", port, port, channel_flag); + PrintDebug(core->vm_info, core, "Reading DMA port %d (%x) (channel=%d)\n", port, port, channel_flag); if (port_offset + length > 16) { - PrintError("DMA Port Read: Port overrun (port_offset=%d, length=%d)\n", port_offset, length); + PrintError(core->vm_info, core, "DMA Port Read: Port overrun (port_offset=%d, length=%d)\n", port_offset, length); return -1; } memcpy(dst, channel->dma_ports + port_offset, length); - PrintDebug("\tval=%x (len=%d)\n", *(uint32_t *)dst, length); + PrintDebug(core->vm_info, core, "\tval=%x (len=%d)\n", *(uint32_t *)dst, length); return length; } @@ -798,11 +798,11 @@ static int write_cmd_port(struct guest_info * core, ushort_t port, void * src, u struct ide_drive * drive = get_selected_drive(channel); if (length != 1) { - PrintError("Invalid Write Length on IDE command Port %x\n", port); + PrintError(core->vm_info, core, "Invalid Write Length on IDE command Port %x\n", port); return -1; } - PrintDebug("IDE: Writing Command Port %x (%s) (val=%x)\n", port, io_port_to_str(port), *(uint8_t *)src); + PrintDebug(core->vm_info, core, "IDE: Writing Command Port %x (%s) (val=%x)\n", port, io_port_to_str(port), *(uint8_t *)src); channel->cmd_reg = *(uint8_t *)src; @@ -863,7 +863,7 @@ static int write_cmd_port(struct guest_info * core, ushort_t port, void * src, u drive->hd_state.cur_sector_num = 1; if (ata_read_sectors(ide, channel) == -1) { - PrintError("Error reading sectors\n"); + PrintError(core->vm_info, core, "Error reading sectors\n"); return -1; } break; @@ -872,7 +872,7 @@ static int write_cmd_port(struct guest_info * core, ushort_t port, void * src, u drive->hd_state.cur_sector_num = 1; if (ata_read_sectors_ext(ide, channel) == -1) { - PrintError("Error reading extended sectors\n"); + PrintError(core->vm_info, core, "Error reading extended sectors\n"); return -1; } break; @@ -894,7 +894,7 @@ static int write_cmd_port(struct guest_info * core, ushort_t port, void * src, u if (channel->dma_status.active == 1) { // DMA Read if (dma_read(core, ide, channel) == -1) { - PrintError("Failed DMA Read\n"); + PrintError(core->vm_info, core, "Failed DMA Read\n"); return -1; } } @@ -917,7 +917,7 @@ static int write_cmd_port(struct guest_info * core, ushort_t port, void * src, u if (channel->dma_status.active == 1) { // DMA Write if (dma_write(core, ide, channel) == -1) { - PrintError("Failed DMA Write\n"); + PrintError(core->vm_info, core, "Failed DMA Write\n"); return -1; } } @@ -1007,7 +1007,7 @@ static int write_cmd_port(struct guest_info * core, ushort_t port, void * src, u case 0xc4: // read multiple sectors drive->hd_state.cur_sector_num = drive->hd_state.mult_sector_num; default: - PrintError("Unimplemented IDE command (%x)\n", channel->cmd_reg); + PrintError(core->vm_info, core, "Unimplemented IDE command (%x)\n", channel->cmd_reg); return -1; } @@ -1020,7 +1020,7 @@ static int write_data_port(struct guest_info * core, ushort_t port, void * src, struct ide_channel * channel = get_selected_channel(ide, port); struct ide_drive * drive = get_selected_drive(channel); - // PrintDebug("IDE: Writing Data Port %x (val=%x, len=%d)\n", + // PrintDebug(core->vm_info, core, "IDE: Writing Data Port %x (val=%x, len=%d)\n", // port, *(uint32_t *)src, length); memcpy(drive->data_buf + drive->transfer_index, src, length); @@ -1030,17 +1030,17 @@ static int write_data_port(struct guest_info * core, ushort_t port, void * src, if (drive->transfer_index >= drive->transfer_length) { switch (channel->cmd_reg) { case 0x30: // Write Sectors - PrintError("Writing Data not yet implemented\n"); + PrintError(core->vm_info, core, "Writing Data not yet implemented\n"); return -1; case 0xa0: // ATAPI packet command if (atapi_handle_packet(core, ide, channel) == -1) { - PrintError("Error handling ATAPI packet\n"); + PrintError(core->vm_info, core, "Error handling ATAPI packet\n"); return -1; } break; default: - PrintError("Unhandld IDE Command %x\n", channel->cmd_reg); + PrintError(core->vm_info, core, "Unhandld IDE Command %x\n", channel->cmd_reg); return -1; } } @@ -1056,7 +1056,7 @@ static int read_hd_data(uint8_t * dst, uint_t length, struct ide_internal * ide, if (drive->transfer_index >= drive->transfer_length) { - PrintError("Buffer overrun... (xfer_len=%d) (cur_idx=%x) (post_idx=%d)\n", + PrintError(VM_NONE, VCORE_NONE, "Buffer overrun... (xfer_len=%d) (cur_idx=%x) (post_idx=%d)\n", drive->transfer_length, drive->transfer_index, drive->transfer_index + length); return -1; @@ -1067,13 +1067,13 @@ static int read_hd_data(uint8_t * dst, uint_t length, struct ide_internal * ide, drive->current_lba++; if (ata_read(ide, channel, drive->data_buf, 1) == -1) { - PrintError("Could not read next disk sector\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not read next disk sector\n"); return -1; } } /* - PrintDebug("Reading HD Data (Val=%x), (len=%d) (offset=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Reading HD Data (Val=%x), (len=%d) (offset=%d)\n", *(uint32_t *)(drive->data_buf + data_offset), length, data_offset); */ @@ -1092,12 +1092,12 @@ static int read_hd_data(uint8_t * dst, uint_t length, struct ide_internal * ide, (drive->transfer_index == drive->transfer_length)) { if (drive->transfer_index < drive->transfer_length) { // An increment is complete, but there is still more data to be transferred... - PrintDebug("Integral Complete, still transferring more sectors\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Integral Complete, still transferring more sectors\n"); channel->status.data_req = 1; drive->irq_flags.c_d = 0; } else { - PrintDebug("Final Sector Transferred\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Final Sector Transferred\n"); // This was the final read of the request channel->status.data_req = 0; @@ -1125,14 +1125,14 @@ static int read_cd_data(uint8_t * dst, uint_t length, struct ide_internal * ide, // int req_offset = drive->transfer_index % drive->req_len; if (drive->cd_state.atapi_cmd != 0x28) { - PrintDebug("IDE: Reading CD Data (len=%d) (req_len=%d)\n", length, drive->req_len); - PrintDebug("IDE: transfer len=%d, transfer idx=%d\n", drive->transfer_length, drive->transfer_index); + PrintDebug(VM_NONE, VCORE_NONE, "IDE: Reading CD Data (len=%d) (req_len=%d)\n", length, drive->req_len); + PrintDebug(VM_NONE, VCORE_NONE, "IDE: transfer len=%d, transfer idx=%d\n", drive->transfer_length, drive->transfer_index); } if (drive->transfer_index >= drive->transfer_length) { - PrintError("Buffer Overrun... (xfer_len=%d) (cur_idx=%d) (post_idx=%d)\n", + PrintError(VM_NONE, VCORE_NONE, "Buffer Overrun... (xfer_len=%d) (cur_idx=%d) (post_idx=%d)\n", drive->transfer_length, drive->transfer_index, drive->transfer_index + length); return -1; @@ -1141,7 +1141,7 @@ static int read_cd_data(uint8_t * dst, uint_t length, struct ide_internal * ide, if ((data_offset == 0) && (drive->transfer_index > 0)) { if (atapi_update_data_buf(ide, channel) == -1) { - PrintError("Could not update CDROM data buffer\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not update CDROM data buffer\n"); return -1; } } @@ -1162,7 +1162,7 @@ static int read_cd_data(uint8_t * dst, uint_t length, struct ide_internal * ide, // Update the request length in the cylinder regs if (atapi_update_req_len(ide, channel, drive->transfer_length - drive->transfer_index) == -1) { - PrintError("Could not update request length after completed increment\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not update request length after completed increment\n"); return -1; } } else { @@ -1213,7 +1213,7 @@ static int ide_read_data_port(struct guest_info * core, ushort_t port, void * ds struct ide_channel * channel = get_selected_channel(ide, port); struct ide_drive * drive = get_selected_drive(channel); - // PrintDebug("IDE: Reading Data Port %x (len=%d)\n", port, length); + // PrintDebug(core->vm_info, core, "IDE: Reading Data Port %x (len=%d)\n", port, length); if ((channel->cmd_reg == 0xec) || (channel->cmd_reg == 0xa1)) { @@ -1222,12 +1222,12 @@ static int ide_read_data_port(struct guest_info * core, ushort_t port, void * ds if (drive->drive_type == BLOCK_CDROM) { if (read_cd_data((uint8_t *)dst, length, ide, channel) == -1) { - PrintError("IDE: Could not read CD Data (atapi cmd=%x)\n", drive->cd_state.atapi_cmd); + PrintError(core->vm_info, core, "IDE: Could not read CD Data (atapi cmd=%x)\n", drive->cd_state.atapi_cmd); return -1; } } else if (drive->drive_type == BLOCK_DISK) { if (read_hd_data((uint8_t *)dst, length, ide, channel) == -1) { - PrintError("IDE: Could not read HD Data\n"); + PrintError(core->vm_info, core, "IDE: Could not read HD Data\n"); return -1; } } else { @@ -1243,11 +1243,11 @@ static int write_port_std(struct guest_info * core, ushort_t port, void * src, u struct ide_drive * drive = get_selected_drive(channel); if (length != 1) { - PrintError("Invalid Write length on IDE port %x\n", port); + PrintError(core->vm_info, core, "Invalid Write length on IDE port %x\n", port); return -1; } - PrintDebug("IDE: Writing Standard Port %x (%s) (val=%x)\n", port, io_port_to_str(port), *(uint8_t *)src); + PrintDebug(core->vm_info, core, "IDE: Writing Standard Port %x (%s) (val=%x)\n", port, io_port_to_str(port), *(uint8_t *)src); switch (port) { // reset and interrupt enable @@ -1305,7 +1305,7 @@ static int write_port_std(struct guest_info * core, ushort_t port, void * src, u // Selecting a non-present device is a no-no if (drive->drive_type == BLOCK_NONE) { - PrintDebug("Attempting to select a non-present drive\n"); + PrintDebug(core->vm_info, core, "Attempting to select a non-present drive\n"); channel->error_reg.abort = 1; channel->status.error = 1; } else { @@ -1322,7 +1322,7 @@ static int write_port_std(struct guest_info * core, ushort_t port, void * src, u break; } default: - PrintError("IDE: Write to unknown Port %x\n", port); + PrintError(core->vm_info, core, "IDE: Write to unknown Port %x\n", port); return -1; } return length; @@ -1335,11 +1335,11 @@ static int read_port_std(struct guest_info * core, ushort_t port, void * dst, ui struct ide_drive * drive = get_selected_drive(channel); if (length != 1) { - PrintError("Invalid Read length on IDE port %x\n", port); + PrintError(core->vm_info, core, "Invalid Read length on IDE port %x\n", port); return -1; } - PrintDebug("IDE: Reading Standard Port %x (%s)\n", port, io_port_to_str(port)); + PrintDebug(core->vm_info, core, "IDE: Reading Standard Port %x (%s)\n", port, io_port_to_str(port)); if ((port == PRI_ADDR_REG_PORT) || (port == SEC_ADDR_REG_PORT)) { @@ -1404,11 +1404,11 @@ static int read_port_std(struct guest_info * core, ushort_t port, void * dst, ui break; default: - PrintError("Invalid Port: %x\n", port); + PrintError(core->vm_info, core, "Invalid Port: %x\n", port); return -1; } - PrintDebug("\tVal=%x\n", *(uint8_t *)dst); + PrintDebug(core->vm_info, core, "\tVal=%x\n", *(uint8_t *)dst); return length; } @@ -1460,11 +1460,11 @@ static void init_channel(struct ide_channel * channel) { static int pci_config_update(struct pci_device * pci_dev, uint32_t reg_num, void * src, uint_t length, void * private_data) { - PrintDebug("PCI Config Update\n"); + PrintDebug(VM_NONE, VCORE_NONE, "PCI Config Update\n"); /* struct ide_internal * ide = (struct ide_internal *)(private_data); - PrintDebug("\t\tInterupt register (Dev=%s), irq=%d\n", ide->ide_pci->name, ide->ide_pci->config_header.intr_line); + PrintDebug(VM_NONE, VCORE_NONE, info, "\t\tInterupt register (Dev=%s), irq=%d\n", ide->ide_pci->name, ide->ide_pci->config_header.intr_line); */ return 0; @@ -1515,7 +1515,7 @@ static int ide_save_extended(struct v3_chkpt *chkpt, char *id, void * private_da ctx=v3_chkpt_open_ctx(chkpt,id); if (!ctx) { - PrintError("Failed to open context for save\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to open context for save\n"); goto savefailout; } @@ -1532,7 +1532,7 @@ static int ide_save_extended(struct v3_chkpt *chkpt, char *id, void * private_da ctx = v3_chkpt_open_ctx(chkpt, buf); if (!ctx) { - PrintError("Unable to open context to save channel %d\n",ch_num); + PrintError(VM_NONE, VCORE_NONE, "Unable to open context to save channel %d\n",ch_num); goto savefailout; } @@ -1557,7 +1557,7 @@ static int ide_save_extended(struct v3_chkpt *chkpt, char *id, void * private_da ctx = v3_chkpt_open_ctx(chkpt, buf); if (!ctx) { - PrintError("Unable to open context to save drive %d\n",drive_num); + PrintError(VM_NONE, VCORE_NONE, "Unable to open context to save drive %d\n",drive_num); goto savefailout; } @@ -1586,7 +1586,7 @@ static int ide_save_extended(struct v3_chkpt *chkpt, char *id, void * private_da } else if (drive->drive_type == BLOCK_NONE) { // no drive connected, so no data } else { - PrintError("Invalid drive type %d\n",drive->drive_type); + PrintError(VM_NONE, VCORE_NONE, "Invalid drive type %d\n",drive->drive_type); goto savefailout; } @@ -1598,7 +1598,7 @@ static int ide_save_extended(struct v3_chkpt *chkpt, char *id, void * private_da return 0; savefailout: - PrintError("Failed to save IDE\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to save IDE\n"); if (ctx) {v3_chkpt_close_ctx(ctx); } return -1; } @@ -1615,7 +1615,7 @@ static int ide_load_extended(struct v3_chkpt *chkpt, char *id, void * private_da ctx=v3_chkpt_open_ctx(chkpt,id); if (!ctx) { - PrintError("Failed to open context for load\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to open context for load\n"); goto loadfailout; } @@ -1632,7 +1632,7 @@ static int ide_load_extended(struct v3_chkpt *chkpt, char *id, void * private_da ctx = v3_chkpt_open_ctx(chkpt, buf); if (!ctx) { - PrintError("Unable to open context to load channel %d\n",ch_num); + PrintError(VM_NONE, VCORE_NONE, "Unable to open context to load channel %d\n",ch_num); goto loadfailout; } @@ -1657,7 +1657,7 @@ static int ide_load_extended(struct v3_chkpt *chkpt, char *id, void * private_da ctx = v3_chkpt_open_ctx(chkpt, buf); if (!ctx) { - PrintError("Unable to open context to load drive %d\n",drive_num); + PrintError(VM_NONE, VCORE_NONE, "Unable to open context to load drive %d\n",drive_num); goto loadfailout; } @@ -1686,7 +1686,7 @@ static int ide_load_extended(struct v3_chkpt *chkpt, char *id, void * private_da } else if (drive->drive_type == BLOCK_NONE) { // no drive connected, so no data } else { - PrintError("Invalid drive type %d\n",drive->drive_type); + PrintError(VM_NONE, VCORE_NONE, "Invalid drive type %d\n",drive->drive_type); goto loadfailout; } } @@ -1695,7 +1695,7 @@ static int ide_load_extended(struct v3_chkpt *chkpt, char *id, void * private_da return 0; loadfailout: - PrintError("Failed to load IDE\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to load IDE\n"); if (ctx) {v3_chkpt_close_ctx(ctx); } return -1; @@ -1735,7 +1735,7 @@ static int connect_fn(struct v3_vm_info * vm, if ((!type_str) || (!drive_str) || (!bus_str)) { - PrintError("Incomplete IDE Configuration\n"); + PrintError(vm, VCORE_NONE, "Incomplete IDE Configuration\n"); return -1; } @@ -1746,7 +1746,7 @@ static int connect_fn(struct v3_vm_info * vm, drive = &(channel->drives[drive_num]); if (drive->drive_type != BLOCK_NONE) { - PrintError("Device slot (bus=%d, drive=%d) already occupied\n", bus_num, drive_num); + PrintError(vm, VCORE_NONE, "Device slot (bus=%d, drive=%d) already occupied\n", bus_num, drive_num); return -1; } @@ -1771,7 +1771,7 @@ static int connect_fn(struct v3_vm_info * vm, drive->num_heads = 16; drive->num_cylinders = (ops->get_capacity(private_data) / HD_SECTOR_SIZE) / (drive->num_sectors * drive->num_heads); } else { - PrintError("invalid IDE drive type\n"); + PrintError(vm, VCORE_NONE, "invalid IDE drive type\n"); return -1; } @@ -1795,12 +1795,12 @@ static int ide_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { char * dev_id = v3_cfg_val(cfg, "ID"); int ret = 0; - PrintDebug("IDE: Initializing IDE\n"); + PrintDebug(vm, VCORE_NONE, "IDE: Initializing IDE\n"); ide = (struct ide_internal *)V3_Malloc(sizeof(struct ide_internal)); if (ide == NULL) { - PrintError("Error allocating IDE state\n"); + PrintError(vm, VCORE_NONE, "Error allocating IDE state\n"); return -1; } @@ -1813,7 +1813,7 @@ static int ide_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * southbridge = v3_find_dev(vm, v3_cfg_val(cfg, "controller")); if (!southbridge) { - PrintError("Could not find southbridge\n"); + PrintError(vm, VCORE_NONE, "Could not find southbridge\n"); V3_Free(ide); return -1; } @@ -1821,23 +1821,23 @@ static int ide_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { ide->southbridge = (struct v3_southbridge *)(southbridge->private_data); } - PrintDebug("IDE: Creating IDE bus x 2\n"); + PrintDebug(vm, VCORE_NONE, "IDE: Creating IDE bus x 2\n"); struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, ide); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(ide); return -1; } if (init_ide_state(ide) == -1) { - PrintError("Failed to initialize IDE state\n"); + PrintError(vm, VCORE_NONE, "Failed to initialize IDE state\n"); v3_remove_device(dev); return -1; } - PrintDebug("Connecting to IDE IO ports\n"); + PrintDebug(vm, VCORE_NONE, "Connecting to IDE IO ports\n"); ret |= v3_dev_hook_io(dev, PRI_DATA_PORT, &ide_read_data_port, &write_data_port); @@ -1889,7 +1889,7 @@ static int ide_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { if (ret != 0) { - PrintError("Error hooking IDE IO port\n"); + PrintError(vm, VCORE_NONE, "Error hooking IDE IO port\n"); v3_remove_device(dev); return -1; } @@ -1902,7 +1902,7 @@ static int ide_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct pci_device * pci_dev = NULL; int i; - PrintDebug("Connecting IDE to PCI bus\n"); + PrintDebug(vm, VCORE_NONE, "Connecting IDE to PCI bus\n"); for (i = 0; i < 6; i++) { bars[i].type = PCI_BAR_NONE; @@ -1922,7 +1922,7 @@ static int ide_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { pci_config_update, NULL, NULL, NULL, ide); if (pci_dev == NULL) { - PrintError("Failed to register IDE BUS %d with PCI\n", i); + PrintError(vm, VCORE_NONE, "Failed to register IDE BUS %d with PCI\n", i); v3_remove_device(dev); return -1; } @@ -1950,13 +1950,13 @@ static int ide_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { } if (v3_dev_add_blk_frontend(vm, dev_id, connect_fn, (void *)ide) == -1) { - PrintError("Could not register %s as frontend\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not register %s as frontend\n", dev_id); v3_remove_device(dev); return -1; } - PrintDebug("IDE Initialized\n"); + PrintDebug(vm, VCORE_NONE, "IDE Initialized\n"); return 0; } diff --git a/palacios/src/devices/io_apic.c b/palacios/src/devices/io_apic.c index 56cb35d..a3c14b6 100644 --- a/palacios/src/devices/io_apic.c +++ b/palacios/src/devices/io_apic.c @@ -170,7 +170,7 @@ static int ioapic_read(struct guest_info * core, addr_t guest_addr, void * dst, uint32_t reg_tgt = guest_addr - ioapic->base_addr; uint32_t * op_val = (uint32_t *)dst; - PrintDebug("ioapic %u: IOAPIC Read at %p\n", ioapic->ioapic_id.id, (void *)guest_addr); + PrintDebug(core->vm_info, core, "ioapic %u: IOAPIC Read at %p\n", ioapic->ioapic_id.id, (void *)guest_addr); if (reg_tgt == 0x00) { *op_val = ioapic->index_reg; @@ -191,7 +191,7 @@ static int ioapic_read(struct guest_info * core, addr_t guest_addr, void * dst, uint_t hi_val = (ioapic->index_reg - IOAPIC_REDIR_BASE_REG) & 1; if (redir_index > 0x3f) { - PrintError("ioapic %u: Invalid redirection table entry %x\n", ioapic->ioapic_id.id, (uint32_t)redir_index); + PrintError(core->vm_info, core, "ioapic %u: Invalid redirection table entry %x\n", ioapic->ioapic_id.id, (uint32_t)redir_index); return -1; } @@ -204,7 +204,7 @@ static int ioapic_read(struct guest_info * core, addr_t guest_addr, void * dst, } } - PrintDebug("ioapic %u: IOAPIC Read at %p gave value 0x%x\n", ioapic->ioapic_id.id, (void *)guest_addr, *op_val); + PrintDebug(core->vm_info, core, "ioapic %u: IOAPIC Read at %p gave value 0x%x\n", ioapic->ioapic_id.id, (void *)guest_addr, *op_val); return length; } @@ -215,10 +215,10 @@ static int ioapic_write(struct guest_info * core, addr_t guest_addr, void * src, uint32_t reg_tgt = guest_addr - ioapic->base_addr; uint32_t op_val = *(uint32_t *)src; - PrintDebug("ioapic %u: IOAPIC Write at %p (val = %d)\n", ioapic->ioapic_id.id, (void *)guest_addr, *(uint32_t *)src); + PrintDebug(core->vm_info, core, "ioapic %u: IOAPIC Write at %p (val = %d)\n", ioapic->ioapic_id.id, (void *)guest_addr, *(uint32_t *)src); if (reg_tgt == 0x00) { - PrintDebug("ioapic %u: Setting ioapic index register to 0x%x.\n", ioapic->ioapic_id.id, op_val); + PrintDebug(core->vm_info, core, "ioapic %u: Setting ioapic index register to 0x%x.\n", ioapic->ioapic_id.id, op_val); ioapic->index_reg = op_val; } else if (reg_tgt == 0x10) { // IOWIN register @@ -229,7 +229,7 @@ static int ioapic_write(struct guest_info * core, addr_t guest_addr, void * src, break; case IOAPIC_VER_REG: // GPF/PageFault/Ignore? - PrintError("ioapic %u: Writing to read only IOAPIC register\n", ioapic->ioapic_id.id); + PrintError(core->vm_info, core, "ioapic %u: Writing to read only IOAPIC register\n", ioapic->ioapic_id.id); return -1; case IOAPIC_ARB_REG: ioapic->ioapic_arb_id.val = op_val; @@ -239,18 +239,18 @@ static int ioapic_write(struct guest_info * core, addr_t guest_addr, void * src, uint_t redir_index = (ioapic->index_reg - IOAPIC_REDIR_BASE_REG) >> 1; uint_t hi_val = (ioapic->index_reg - IOAPIC_REDIR_BASE_REG) & 1; - PrintDebug("ioapic %u: Writing value 0x%x to redirection entry %u (%s)\n", + PrintDebug(core->vm_info, core, "ioapic %u: Writing value 0x%x to redirection entry %u (%s)\n", ioapic->ioapic_id.id, op_val, redir_index, hi_val ? "hi" : "low"); if (redir_index > 0x3f) { - PrintError("ioapic %u: Invalid redirection table entry %x\n", ioapic->ioapic_id.id, (uint32_t)redir_index); + PrintError(core->vm_info, core, "ioapic %u: Invalid redirection table entry %x\n", ioapic->ioapic_id.id, (uint32_t)redir_index); return -1; } if (hi_val) { - PrintDebug("ioapic %u: Writing to hi of pin %d\n", ioapic->ioapic_id.id, redir_index); + PrintDebug(core->vm_info, core, "ioapic %u: Writing to hi of pin %d\n", ioapic->ioapic_id.id, redir_index); ioapic->redir_tbl[redir_index].hi = op_val; } else { - PrintDebug("ioapic %u: Writing to lo of pin %d\n", ioapic->ioapic_id.id, redir_index); + PrintDebug(core->vm_info, core, "ioapic %u: Writing to lo of pin %d\n", ioapic->ioapic_id.id, redir_index); op_val &= REDIR_LO_MASK; ioapic->redir_tbl[redir_index].lo &= ~REDIR_LO_MASK; ioapic->redir_tbl[redir_index].lo |= op_val; @@ -280,7 +280,7 @@ static int ioapic_raise_irq(struct v3_vm_info * vm, void * private_data, struct } if (irq_num > 24) { - PrintDebug("ioapic %u: IRQ out of range of IO APIC\n", ioapic->ioapic_id.id); + PrintDebug(vm, VCORE_NONE, "ioapic %u: IRQ out of range of IO APIC\n", ioapic->ioapic_id.id); return -1; } @@ -289,7 +289,7 @@ static int ioapic_raise_irq(struct v3_vm_info * vm, void * private_data, struct if (irq_entry->mask == 0) { struct v3_gen_ipi ipi; - PrintDebug("ioapic %u: IOAPIC Signaling APIC to raise INTR %d\n", + PrintDebug(vm, VCORE_NONE, "ioapic %u: IOAPIC Signaling APIC to raise INTR %d\n", ioapic->ioapic_id.id, irq_entry->vec); @@ -303,11 +303,11 @@ static int ioapic_raise_irq(struct v3_vm_info * vm, void * private_data, struct ipi.ack = irq->ack; ipi.private_data = irq->private_data; - PrintDebug("ioapic %u: IPI: vector 0x%x, mode 0x%x, logical 0x%x, trigger 0x%x, dst 0x%x, shorthand 0x%x\n", + PrintDebug(vm, VCORE_NONE, "ioapic %u: IPI: vector 0x%x, mode 0x%x, logical 0x%x, trigger 0x%x, dst 0x%x, shorthand 0x%x\n", ioapic->ioapic_id.id, ipi.vector, ipi.mode, ipi.logical, ipi.trigger_mode, ipi.dst, ipi.dst_shorthand); // Need to add destination argument here... if (v3_apic_send_ipi(vm, &ipi, ioapic->apic_dev_data) == -1) { - PrintError("Error sending IPI to apic %d\n", ipi.dst); + PrintError(vm, VCORE_NONE, "Error sending IPI to apic %d\n", ipi.dst); return -1; } } @@ -354,7 +354,7 @@ static int io_apic_save(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; savefailout: - PrintError("ioapic save failed\n"); + PrintError(VM_NONE, VCORE_NONE, "ioapic save failed\n"); return -1; } @@ -371,7 +371,7 @@ static int io_apic_load(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; loadfailout: - PrintError("ioapic load failed\n"); + PrintError(VM_NONE, VCORE_NONE, "ioapic load failed\n"); return -1; } @@ -394,12 +394,12 @@ static int ioapic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { char * dev_id = v3_cfg_val(cfg, "ID"); - PrintDebug("ioapic: Creating IO APIC\n"); + PrintDebug(vm, VCORE_NONE, "ioapic: Creating IO APIC\n"); struct io_apic_state * ioapic = (struct io_apic_state *)V3_Malloc(sizeof(struct io_apic_state)); if (!ioapic) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -408,7 +408,7 @@ static int ioapic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, ioapic); if (dev == NULL) { - PrintError("ioapic: Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "ioapic: Could not attach device %s\n", dev_id); V3_Free(ioapic); return -1; } diff --git a/palacios/src/devices/keyboard.c b/palacios/src/devices/keyboard.c index 84833dc..cbdad8c 100644 --- a/palacios/src/devices/keyboard.c +++ b/palacios/src/devices/keyboard.c @@ -246,7 +246,7 @@ static int update_kb_irq(struct keyboard_internal * state) { state->status.mouse_buf_full = 1; } - PrintDebug("keyboard: interrupt 0x%d\n", irq_num); + PrintDebug(VM_NONE, VCORE_NONE, "keyboard: interrupt 0x%d\n", irq_num); if (irq_num) { // Global output buffer flag (for both Keyboard and mouse) @@ -310,13 +310,13 @@ static int pull_from_output_queue(struct keyboard_internal * state, uint8_t * va if (state->kbd_queue.count > 0) { q = &(state->kbd_queue); - PrintDebug("Reading from Keyboard Queue\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Reading from Keyboard Queue\n"); } else if (state->mouse_queue.count > 0) { q = &(state->mouse_queue); - PrintDebug("Reading from Mouse Queue\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Reading from Mouse Queue\n"); } else { uint8_t idx = state->kbd_queue.start - 1; - PrintDebug("No Data in any queue\n"); + PrintDebug(VM_NONE, VCORE_NONE, "No Data in any queue\n"); *value = state->kbd_queue.queue[idx]; return 0; } @@ -332,8 +332,8 @@ static int pull_from_output_queue(struct keyboard_internal * state, uint8_t * va q->count--; - PrintDebug("Read from Queue: %x\n", *value); - PrintDebug("QStart=%d, QEnd=%d\n", q->start, q->end); + PrintDebug(VM_NONE, VCORE_NONE, "Read from Queue: %x\n", *value); + PrintDebug(VM_NONE, VCORE_NONE, "QStart=%d, QEnd=%d\n", q->start, q->end); update_kb_irq(state); @@ -351,7 +351,7 @@ static int key_event_handler(struct v3_vm_info * vm, void * private_data) { struct keyboard_internal * state = (struct keyboard_internal *)private_data; - PrintDebug("keyboard: injected status 0x%x, and scancode 0x%x\n", evt->status, evt->scan_code); + PrintDebug(vm, VCORE_NONE, "keyboard: injected status 0x%x, and scancode 0x%x\n", evt->status, evt->scan_code); if (evt->scan_code == 0x44) { // F10 debug dump int i = 0; @@ -363,7 +363,7 @@ static int key_event_handler(struct v3_vm_info * vm, #ifdef V3_CONFIG_SYMCALL else if (evt->scan_code == 0x43) { // F9 Sym test struct guest_info * core = &(vm->cores[0]); - PrintDebug("Testing sym call\n"); + PrintDebug(vm, VCORE_NONE, "Testing sym call\n"); sym_arg_t a0 = 0x1111; sym_arg_t a1 = 0x2222; sym_arg_t a2 = 0x3333; @@ -372,15 +372,15 @@ static int key_event_handler(struct v3_vm_info * vm, uint64_t call_start = 0; uint64_t call_end = 0; - V3_Print("Exits before symcall: %d\n", (uint32_t)core->num_exits); + V3_Print(vm, VCORE_NONE, "Exits before symcall: %d\n", (uint32_t)core->num_exits); rdtscll(call_start); v3_sym_call5(core, SYMCALL_TEST, &a0, &a1, &a2, &a3, &a4); rdtscll(call_end); - V3_Print("Symcall latency = %d cycles (%d exits)\n", (uint32_t)(call_end - call_start), (uint32_t)core->num_exits); + V3_Print(vm, VCORE_NONE, "Symcall latency = %d cycles (%d exits)\n", (uint32_t)(call_end - call_start), (uint32_t)core->num_exits); - V3_Print("Symcall Test Returned arg0=%x, arg1=%x, arg2=%x, arg3=%x, arg4=%x\n", + V3_Print(vm, VCORE_NONE, "Symcall Test Returned arg0=%x, arg1=%x, arg2=%x, arg3=%x, arg4=%x\n", (uint32_t)a0, (uint32_t)a1, (uint32_t)a2, (uint32_t)a3, (uint32_t)a4); } @@ -388,7 +388,7 @@ static int key_event_handler(struct v3_vm_info * vm, else if (evt->scan_code == 0x42) { // F8 debug toggle extern int v3_dbg_enable; - PrintDebug("Toggling Debugging\n"); + PrintDebug(vm, VCORE_NONE, "Toggling Debugging\n"); v3_dbg_enable ^= 1; } @@ -425,7 +425,7 @@ static int mouse_event_handler(struct v3_vm_info * vm, struct keyboard_internal * kbd = (struct keyboard_internal *)private_data; int ret = 0; - PrintDebug("keyboard: injected mouse packet 0x %x %x %x\n", + PrintDebug(vm, VCORE_NONE, "keyboard: injected mouse packet 0x %x %x %x\n", evt->data[0], evt->data[1], evt->data[2]); addr_t irq_state = v3_lock_irqsave(kbd->kb_lock); @@ -440,7 +440,7 @@ static int mouse_event_handler(struct v3_vm_info * vm, } break; default: - PrintError("Invalid mouse state\n"); + PrintError(vm, VCORE_NONE, "Invalid mouse state\n"); ret = -1; break; } @@ -477,7 +477,7 @@ static int mouse_write_output(struct keyboard_internal * kbd, uint8_t data) { /* case 0xfe: //resend */ /* PushToOutputQueue(kbd, 0xfa, OVERWRITE, DATA, MOUSE) ; */ -/* PrintDebug(" mouse resend begins "); */ +/* PrintDebug(VM_NONE, VCORE_NONE, " mouse resend begins "); */ /* kbd->mouse_done_after_ack = 0; */ /* kbd->mouse_needs_ack = 0; */ /* kbd->mouse_state = STREAM1; */ @@ -486,55 +486,55 @@ static int mouse_write_output(struct keyboard_internal * kbd, uint8_t data) { case 0xf6: // set defaults push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; - PrintDebug(" mouse set defaults "); + PrintDebug(VM_NONE, VCORE_NONE, " mouse set defaults "); break; case 0xf5: // disable data reporting push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; - PrintDebug(" mouse disable data reporting "); + PrintDebug(VM_NONE, VCORE_NONE, " mouse disable data reporting "); break; case 0xf4: // enable data reporting push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; - PrintDebug(" mouse enable data reporting "); + PrintDebug(VM_NONE, VCORE_NONE, " mouse enable data reporting "); break; case 0xf3: // set sample rate push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; kbd->mouse_state = SAMPLE; - PrintDebug(" mouse set sample rate begins "); + PrintDebug(VM_NONE, VCORE_NONE, " mouse set sample rate begins "); break; case 0xf2: // get device id push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; push_to_output_queue(kbd, 0x0, DATA, MOUSE); - PrintDebug(" mouse get device id begins "); + PrintDebug(VM_NONE, VCORE_NONE, " mouse get device id begins "); break; case 0xf0: // set remote mode push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; - PrintDebug(" mouse set remote mode "); + PrintDebug(VM_NONE, VCORE_NONE, " mouse set remote mode "); break; case 0xee: // set wrap mode push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; - PrintError(" mouse set wrap mode (ignored) "); + PrintError(VM_NONE, VCORE_NONE, " mouse set wrap mode (ignored) "); break; case 0xec: // reset wrap mode push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; - PrintError(" mouse reset wrap mode (ignored) "); + PrintError(VM_NONE, VCORE_NONE, " mouse reset wrap mode (ignored) "); break; case 0xeb: // read data push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; - PrintError(" mouse switch to wrap mode (ignored) "); + PrintError(VM_NONE, VCORE_NONE, " mouse switch to wrap mode (ignored) "); break; case 0xea: // set stream mode push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; - PrintDebug(" mouse set stream mode "); + PrintDebug(VM_NONE, VCORE_NONE, " mouse set stream mode "); break; case 0xe9: // status request @@ -542,27 +542,27 @@ static int mouse_write_output(struct keyboard_internal * kbd, uint8_t data) { push_to_output_queue(kbd, 0x00, DATA, MOUSE); push_to_output_queue(kbd, 0x00, DATA, MOUSE); push_to_output_queue(kbd, 0x00, DATA, MOUSE); - PrintDebug(" mouse status request begins "); + PrintDebug(VM_NONE, VCORE_NONE, " mouse status request begins "); break; case 0xe8: // set resolution push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; - PrintDebug(" mouse set resolution begins "); + PrintDebug(VM_NONE, VCORE_NONE, " mouse set resolution begins "); kbd->mouse_state = SET_RES; break; case 0xe7: // set scaling 2:1 push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; - PrintDebug(" mouse set scaling 2:1 "); + PrintDebug(VM_NONE, VCORE_NONE, " mouse set scaling 2:1 "); break; case 0xe6: // set scaling 1:1 push_to_output_queue(kbd, MOUSE_ACK, DATA, MOUSE) ; - PrintDebug(" mouse set scaling 1:1 "); + PrintDebug(VM_NONE, VCORE_NONE, " mouse set scaling 1:1 "); break; default: - PrintDebug(" receiving unknown mouse command (0x%x) in acceptable kbd ", data); + PrintDebug(VM_NONE, VCORE_NONE, " receiving unknown mouse command (0x%x) in acceptable kbd ", data); break; } @@ -570,7 +570,7 @@ static int mouse_write_output(struct keyboard_internal * kbd, uint8_t data) { case SAMPLE: case SET_RES: default: - PrintDebug(" receiving mouse output in unhandled kbd (0x%x) ", kbd->mouse_state); + PrintDebug(VM_NONE, VCORE_NONE, " receiving mouse output in unhandled kbd (0x%x) ", kbd->mouse_state); return -1; } @@ -583,10 +583,10 @@ static int mouse_write_output(struct keyboard_internal * kbd, uint8_t data) { static int keyboard_write_delay(struct guest_info *core, ushort_t port, void * src, uint_t length, void * priv_data) { if (length == 1) { - PrintDebug("keyboard: write of 0x%x to 80h\n", *((uint8_t*)src)); + PrintDebug(core->vm_info, core, "keyboard: write of 0x%x to 80h\n", *((uint8_t*)src)); return 1; } else { - PrintDebug("keyboard: write of >1 byte to 80h\n", *((uint8_t*)src)); + PrintDebug(core->vm_info, core, "keyboard: write of >1 byte to 80h\n", *((uint8_t*)src)); return length; } } @@ -596,11 +596,11 @@ static int keyboard_read_delay(struct guest_info * core, ushort_t port, void * d if (length == 1) { *(uint8_t *)dest = v3_inb(port); - PrintDebug("keyboard: read of 0x%x from 80h\n", *((uint8_t*)dest)); + PrintDebug(core->vm_info, core, "keyboard: read of 0x%x from 80h\n", *((uint8_t*)dest)); return 1; } else { - PrintDebug("keyboard: read of >1 byte from 80h\n"); + PrintDebug(core->vm_info, core, "keyboard: read of >1 byte from 80h\n"); return length; } @@ -617,7 +617,7 @@ static int keyboard_write_command(struct guest_info * core, ushort_t port, void // Should always be single byte write if (length != 1) { - PrintError("keyboard: write of >1 bytes (%d) to 64h\n", length); + PrintError(core->vm_info, core, "keyboard: write of >1 bytes (%d) to 64h\n", length); return -1; } @@ -625,132 +625,132 @@ static int keyboard_write_command(struct guest_info * core, ushort_t port, void addr_t irq_state = v3_lock_irqsave(kbd->kb_lock); if (kbd->state != NORMAL) { - PrintDebug("keyboard: warning - receiving command on 64h but state != NORMAL\n"); + PrintDebug(core->vm_info, core, "keyboard: warning - receiving command on 64h but state != NORMAL\n"); } - PrintDebug("keyboard: command 0x%x on 64h\n", cmd); + PrintDebug(core->vm_info, core, "keyboard: command 0x%x on 64h\n", cmd); switch (cmd) { case 0x20: // READ COMMAND BYTE (returned in 60h) push_to_output_queue(kbd, kbd->cmd.val, COMMAND, KEYBOARD); - PrintDebug("keyboard: command byte 0x%x returned\n", kbd->cmd.val); + PrintDebug(core->vm_info, core, "keyboard: command byte 0x%x returned\n", kbd->cmd.val); break; case 0x60: // WRITE COMMAND BYTE (read from 60h) kbd->state = WRITING_CMD_BYTE; // we need to make sure we send the next 0x60 byte appropriately - PrintDebug("keyboard: prepare to write command byte\n"); + PrintDebug(core->vm_info, core, "keyboard: prepare to write command byte\n"); break; // case 0x90-9f - write to output port (?) case 0xa1: // Get version number push_to_output_queue(kbd, 0x00, COMMAND, KEYBOARD); - PrintDebug("keyboard: version number 0x0 returned\n"); + PrintDebug(core->vm_info, core, "keyboard: version number 0x0 returned\n"); break; case 0xa4: // is password installed? send result to 0x60 // we don't support passwords push_to_output_queue(kbd, 0xf1, COMMAND, KEYBOARD); - PrintDebug("keyboard: password not installed\n"); + PrintDebug(core->vm_info, core, "keyboard: password not installed\n"); break; case 0xa5: // new password will arrive on 0x60 kbd->state = TRANSMIT_PASSWD; - PrintDebug("keyboard: pepare to transmit password\n"); + PrintDebug(core->vm_info, core, "keyboard: pepare to transmit password\n"); break; case 0xa6: // check passwd; // since we do not support passwords, we will simply ignore this // the implication is that any password check immediately succeeds // with a blank password - PrintDebug("keyboard: password check succeeded\n"); + PrintDebug(core->vm_info, core, "keyboard: password check succeeded\n"); break; case 0xa7: // disable mouse kbd->cmd.mouse_disable = 1; - PrintDebug("keyboard: mouse disabled\n"); + PrintDebug(core->vm_info, core, "keyboard: mouse disabled\n"); break; case 0xa8: // enable mouse kbd->cmd.mouse_disable = 0; - PrintDebug("keyboard: mouse enabled\n"); + PrintDebug(core->vm_info, core, "keyboard: mouse enabled\n"); break; case 0xa9: // mouse interface test (always succeeds) push_to_output_queue(kbd, 0x00, COMMAND, KEYBOARD); - PrintDebug("keyboard: mouse interface test succeeded\n"); + PrintDebug(core->vm_info, core, "keyboard: mouse interface test succeeded\n"); break; case 0xaa: // controller self test (always succeeds) push_to_output_queue(kbd, 0x55, COMMAND, KEYBOARD); - PrintDebug("keyboard: controller self test succeeded\n"); + PrintDebug(core->vm_info, core, "keyboard: controller self test succeeded\n"); break; case 0xab: // keyboard interface test (always succeeds) push_to_output_queue(kbd, 0, COMMAND, KEYBOARD); - PrintDebug("keyboard: keyboard interface test succeeded\n"); + PrintDebug(core->vm_info, core, "keyboard: keyboard interface test succeeded\n"); break; case 0xad: // disable keyboard kbd->cmd.disable = 1; - PrintDebug("keyboard: keyboard disabled\n"); + PrintDebug(core->vm_info, core, "keyboard: keyboard disabled\n"); break; case 0xae: // enable keyboard kbd->cmd.disable = 0; - PrintDebug("keyboard: keyboard enabled\n"); + PrintDebug(core->vm_info, core, "keyboard: keyboard enabled\n"); break; case 0xaf: // get version push_to_output_queue(kbd, 0x00, COMMAND, KEYBOARD); - PrintDebug("keyboard: version 0 returned \n"); + PrintDebug(core->vm_info, core, "keyboard: version 0 returned \n"); break; case 0xd0: // return microcontroller output on 60h push_to_output_queue(kbd, kbd->output_byte, COMMAND, KEYBOARD); - PrintDebug("keyboard: output byte 0x%x returned\n", kbd->output_byte); + PrintDebug(core->vm_info, core, "keyboard: output byte 0x%x returned\n", kbd->output_byte); break; case 0xd1: // request to write next byte on 60h to the microcontroller output port kbd->state = WRITING_OUTPUT_PORT; - PrintDebug("keyboard: prepare to write output byte\n"); + PrintDebug(core->vm_info, core, "keyboard: prepare to write output byte\n"); break; case 0xd2: // write keyboard buffer (inject key) kbd->state = INJECTING_KEY; - PrintDebug("keyboard: prepare to inject key\n"); + PrintDebug(core->vm_info, core, "keyboard: prepare to inject key\n"); break; case 0xd3: // write mouse buffer (inject mouse) kbd->state = INJECTING_MOUSE; - PrintDebug("keyboard: prepare to inject mouse\n"); + PrintDebug(core->vm_info, core, "keyboard: prepare to inject mouse\n"); break; case 0xd4: // write mouse device (command to mouse?) kbd->state = IN_MOUSE; - PrintDebug("keyboard: prepare to inject mouse command\n"); + PrintDebug(core->vm_info, core, "keyboard: prepare to inject mouse command\n"); break; case 0xc0: // read input port push_to_output_queue(kbd, kbd->input_byte, COMMAND, KEYBOARD); - PrintDebug("keyboard: input byte 0x%x returned\n", kbd->input_byte); + PrintDebug(core->vm_info, core, "keyboard: input byte 0x%x returned\n", kbd->input_byte); break; case 0xc1: //copy input port lsn to status msn kbd->status.val &= 0x0f; kbd->status.val |= (kbd->input_byte & 0xf) << 4; - PrintDebug("keyboard: copied input byte low 4 bits to status reg hi 4 bits\n"); + PrintDebug(core->vm_info, core, "keyboard: copied input byte low 4 bits to status reg hi 4 bits\n"); break; case 0xc2: // copy input port msn to status msn kbd->status.val &= 0x0f; kbd->status.val |= (kbd->input_byte & 0xf0); - PrintDebug("keyboard: copied input byte hi 4 bits to status reg hi 4 bits\n"); + PrintDebug(core->vm_info, core, "keyboard: copied input byte hi 4 bits to status reg hi 4 bits\n"); break; case 0xe0: // read test port push_to_output_queue(kbd, kbd->output_byte >> 6, COMMAND, KEYBOARD); - PrintDebug("keyboard: read 0x%x from test port\n", kbd->output_byte >> 6); + PrintDebug(core->vm_info, core, "keyboard: read 0x%x from test port\n", kbd->output_byte >> 6); break; @@ -770,12 +770,12 @@ static int keyboard_write_command(struct guest_info * core, ushort_t port, void case 0xfd: case 0xfe: case 0xff: - PrintDebug("keyboard: ignoring pulse of 0x%x (low=pulsed) on output port\n", (cmd & 0xf)); + PrintDebug(core->vm_info, core, "keyboard: ignoring pulse of 0x%x (low=pulsed) on output port\n", (cmd & 0xf)); break; // case ac diagonstic - returns 16 bytes from keyboard microcontroler on 60h default: - PrintDebug("keyboard: ignoring command (unimplemented)\n"); + PrintDebug(core->vm_info, core, "keyboard: ignoring command (unimplemented)\n"); break; } @@ -788,11 +788,11 @@ static int keyboard_read_status(struct guest_info * core, ushort_t port, void * struct keyboard_internal * kbd = priv_data; if (length != 1) { - PrintError("keyboard: >1 byte read for status (64h)\n"); + PrintError(core->vm_info, core, "keyboard: >1 byte read for status (64h)\n"); return -1; } - PrintDebug("keyboard: read status (64h): "); + PrintDebug(core->vm_info, core, "keyboard: read status (64h): "); addr_t irq_state = v3_lock_irqsave(kbd->kb_lock); @@ -800,7 +800,7 @@ static int keyboard_read_status(struct guest_info * core, ushort_t port, void * v3_unlock_irqrestore(kbd->kb_lock, irq_state); - PrintDebug("0x%x\n", *(uint8_t *)dest); + PrintDebug(core->vm_info, core, "0x%x\n", *(uint8_t *)dest); return length; } @@ -810,13 +810,13 @@ static int keyboard_write_output(struct guest_info * core, ushort_t port, void * int ret = length; if (length != 1) { - PrintError("keyboard: write of 60h with >1 byte\n"); + PrintError(core->vm_info, core, "keyboard: write of 60h with >1 byte\n"); return -1; } uint8_t data = *(uint8_t *)src; - PrintDebug("keyboard: output 0x%x on 60h\n", data); + PrintDebug(core->vm_info, core, "keyboard: output 0x%x on 60h\n", data); addr_t irq_state = v3_lock_irqsave(kbd->kb_lock); @@ -824,55 +824,55 @@ static int keyboard_write_output(struct guest_info * core, ushort_t port, void * case WRITING_CMD_BYTE: kbd->cmd.val = data; kbd->state = NORMAL; - PrintDebug("keyboard: wrote new command byte 0x%x\n", kbd->cmd.val); + PrintDebug(core->vm_info, core, "keyboard: wrote new command byte 0x%x\n", kbd->cmd.val); break; case WRITING_OUTPUT_PORT: kbd->output_byte = data; kbd->state = NORMAL; - PrintDebug("keyboard: wrote new output byte 0x%x\n", kbd->output_byte); + PrintDebug(core->vm_info, core, "keyboard: wrote new output byte 0x%x\n", kbd->output_byte); break; case INJECTING_KEY: push_to_output_queue(kbd, data, COMMAND, KEYBOARD); // probably should be a call to deliver_key_to_vmm() kbd->state = NORMAL; - PrintDebug("keyboard: injected key 0x%x\n", data); + PrintDebug(core->vm_info, core, "keyboard: injected key 0x%x\n", data); break; case INJECTING_MOUSE: push_to_output_queue(kbd, data, DATA, MOUSE); - // PrintDebug("keyboard: ignoring injected mouse event 0x%x\n", data); - PrintDebug("keyboard: injected mouse event 0x%x\n", data); + // PrintDebug(core->vm_info, core, "keyboard: ignoring injected mouse event 0x%x\n", data); + PrintDebug(core->vm_info, core, "keyboard: injected mouse event 0x%x\n", data); kbd->state = NORMAL; break; case IN_MOUSE: - PrintDebug("keyboard: mouse action: "); + PrintDebug(core->vm_info, core, "keyboard: mouse action: "); if (mouse_write_output(kbd, data)) { kbd->state = NORMAL; } - PrintDebug("\n"); + PrintDebug(core->vm_info, core, "\n"); break; case TRANSMIT_PASSWD: if (data) { //ignore passwd - PrintDebug("keyboard: ignoring password character 0x%x\n",data); + PrintDebug(core->vm_info, core, "keyboard: ignoring password character 0x%x\n",data); } else { // end of password kbd->state = NORMAL; - PrintDebug("keyboard: done with password\n"); + PrintDebug(core->vm_info, core, "keyboard: done with password\n"); } break; case SET_LEDS: - PrintDebug("Keyboard: LEDs being set...\n"); + PrintDebug(core->vm_info, core, "Keyboard: LEDs being set...\n"); push_to_output_queue(kbd, 0xfa, COMMAND, KEYBOARD); kbd->state = NORMAL; break; case SET_RATE: - PrintDebug("Keyboard: Rate being set...\n"); + PrintDebug(core->vm_info, core, "Keyboard: Rate being set...\n"); push_to_output_queue(kbd, 0xfa, COMMAND, KEYBOARD); kbd->state = NORMAL; break; @@ -880,14 +880,14 @@ static int keyboard_write_output(struct guest_info * core, ushort_t port, void * case GETSET_SCANCODES: switch (data) { case 0: - PrintDebug("Keyboard: scancode set being read\n"); + PrintDebug(core->vm_info, core, "Keyboard: scancode set being read\n"); push_to_output_queue(kbd, 0x45 - 2 * kbd->scancode_set, COMMAND, KEYBOARD); break; case 1: - PrintError("keyboard: unsupported scancode set %d selected\n", data); + PrintError(core->vm_info, core, "keyboard: unsupported scancode set %d selected\n", data); return -1; case 2: - PrintDebug("Keyboard: scancode set being set to %d\n", data); + PrintDebug(core->vm_info, core, "Keyboard: scancode set being set to %d\n", data); kbd->scancode_set = data; push_to_output_queue(kbd, 0xfa, COMMAND, KEYBOARD); break; @@ -895,10 +895,10 @@ static int keyboard_write_output(struct guest_info * core, ushort_t port, void * /* OpenBSD wants scancode set 3, but falls back to 2 if a * subsequent read reveals that the request was ignored */ - PrintError("keyboard: ignoring request for scancode set %d\n", data); + PrintError(core->vm_info, core, "keyboard: ignoring request for scancode set %d\n", data); break; default: - PrintError("keyboard: unknown scancode set %d selected\n", data); + PrintError(core->vm_info, core, "keyboard: unknown scancode set %d selected\n", data); ret = -1; break; @@ -918,7 +918,7 @@ static int keyboard_write_output(struct guest_info * core, ushort_t port, void * case 0xff: // reset push_to_output_queue(kbd, 0xfa, COMMAND, KEYBOARD); // ack push_to_output_queue(kbd, 0xaa, COMMAND, KEYBOARD); - PrintDebug("keyboard: reset complete and acked\n"); + PrintDebug(core->vm_info, core, "keyboard: reset complete and acked\n"); break; case 0xf5: // disable scanning @@ -926,7 +926,7 @@ static int keyboard_write_output(struct guest_info * core, ushort_t port, void * // ack push_to_output_queue(kbd, 0xfa, COMMAND, KEYBOARD); // should do something here... PAD - PrintDebug("keyboard: %s scanning done and acked\n", (data == 0xf5) ? "disable" : "enable"); + PrintDebug(core->vm_info, core, "keyboard: %s scanning done and acked\n", (data == 0xf5) ? "disable" : "enable"); break; case 0xf3: @@ -938,7 +938,7 @@ static int keyboard_write_output(struct guest_info * core, ushort_t port, void * push_to_output_queue(kbd, 0xfa, COMMAND, KEYBOARD); push_to_output_queue(kbd, 0xab, COMMAND, KEYBOARD); push_to_output_queue(kbd, 0x83, COMMAND, KEYBOARD); - PrintDebug("Keyboard: Requesting Keyboard ID\n"); + PrintDebug(core->vm_info, core, "Keyboard: Requesting Keyboard ID\n"); break; case 0xed: // enable keyboard LEDs @@ -973,12 +973,12 @@ static int keyboard_write_output(struct guest_info * core, ushort_t port, void * case 0xf8: // set all make/break case 0xf7: // set all typemaktic - PrintError("keyboard: unhandled known command 0x%x on output buffer (60h)\n", data); + PrintError(core->vm_info, core, "keyboard: unhandled known command 0x%x on output buffer (60h)\n", data); ret = -1; break; default: - PrintError("keyboard: unhandled unknown command 0x%x on output buffer (60h)\n", data); + PrintError(core->vm_info, core, "keyboard: unhandled unknown command 0x%x on output buffer (60h)\n", data); kbd->status.out_buf_full = 1; ret = -1; break; @@ -996,7 +996,7 @@ static int keyboard_read_input(struct guest_info * core, ushort_t port, void * d struct keyboard_internal * kbd = priv_data; if (length != 1) { - PrintError("keyboard: unknown size read from input (60h)\n"); + PrintError(core->vm_info, core, "keyboard: unknown size read from input (60h)\n"); return -1; } @@ -1006,7 +1006,7 @@ static int keyboard_read_input(struct guest_info * core, ushort_t port, void * d v3_unlock_irqrestore(kbd->kb_lock, irq_state); - PrintDebug("keyboard: read from input (60h): 0x%x\n", *(uint8_t *)dest); + PrintDebug(core->vm_info, core, "keyboard: read from input (60h): 0x%x\n", *(uint8_t *)dest); return length; } @@ -1067,7 +1067,7 @@ static int keyboard_reset_device(struct keyboard_internal * kbd) { kbd->input_byte = INPUT_RAM; // we have some // also display=color, jumper 0, keyboard enabled - PrintDebug("keyboard: reset device\n"); + PrintDebug(VM_NONE, VCORE_NONE, "keyboard: reset device\n"); return 0; @@ -1090,7 +1090,7 @@ static int keyboard_save(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; savefailout: - PrintError("Failed to save keyboard\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to save keyboard\n"); return -1; } @@ -1113,7 +1113,7 @@ static int keyboard_load(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; loadfailout: - PrintError("Failed to load keyboard\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to load keyboard\n"); return -1; } @@ -1136,12 +1136,12 @@ static int keyboard_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { char * dev_id = v3_cfg_val(cfg, "ID"); int ret = 0; - PrintDebug("keyboard: init_device\n"); + PrintDebug(vm, VCORE_NONE, "keyboard: init_device\n"); kbd = (struct keyboard_internal *)V3_Malloc(sizeof(struct keyboard_internal)); if (!kbd) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -1152,7 +1152,7 @@ static int keyboard_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, kbd); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(kbd); return -1; } @@ -1168,7 +1168,7 @@ static int keyboard_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { ret |= v3_dev_hook_io(dev, KEYBOARD_60H, &keyboard_read_input, &keyboard_write_output); if (ret != 0) { - PrintError("Error hooking keyboard IO ports\n"); + PrintError(vm, VCORE_NONE, "Error hooking keyboard IO ports\n"); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/lnx_virtio_balloon.c b/palacios/src/devices/lnx_virtio_balloon.c index f6608d2..653bc5e 100644 --- a/palacios/src/devices/lnx_virtio_balloon.c +++ b/palacios/src/devices/lnx_virtio_balloon.c @@ -119,7 +119,7 @@ static int get_desc_count(struct virtio_queue * q, int index) { static int handle_kick(struct guest_info * core, struct virtio_balloon_state * virtio) { struct virtio_queue * q = virtio->cur_queue; - PrintDebug("VIRTIO BALLOON KICK: cur_index=%d (mod=%d), avail_index=%d\n", + PrintDebug(core->vm_info, core, "VIRTIO BALLOON KICK: cur_index=%d (mod=%d), avail_index=%d\n", q->cur_avail_idx, q->cur_avail_idx % QUEUE_SIZE, q->avail->index); while (q->cur_avail_idx < q->avail->index) { @@ -130,32 +130,32 @@ static int handle_kick(struct guest_info * core, struct virtio_balloon_state * v uint32_t req_len = 0; - PrintDebug("Descriptor Count=%d, index=%d\n", desc_cnt, q->cur_avail_idx % QUEUE_SIZE); + PrintDebug(core->vm_info, core, "Descriptor Count=%d, index=%d\n", desc_cnt, q->cur_avail_idx % QUEUE_SIZE); for (i = 0; i < desc_cnt; i++) { addr_t page_addr; tmp_desc = &(q->desc[desc_idx]); - PrintDebug("Header Descriptor (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", + PrintDebug(core->vm_info, core, "Header Descriptor (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", tmp_desc, (void *)(addr_t)(tmp_desc->addr_gpa), tmp_desc->length, tmp_desc->flags, tmp_desc->next); if (v3_gpa_to_hva(core, tmp_desc->addr_gpa, (addr_t *)&(page_addr)) == -1) { - PrintError("Could not translate block header address\n"); + PrintError(core->vm_info, core, "Could not translate block header address\n"); return -1; } /* if (handle_balloon_op(virtio, tmp_desc, buf_desc, status_desc) == -1) { - PrintError("Error handling balloon operation\n"); + PrintError(core->vm_info, core, "Error handling balloon operation\n"); return -1; } */ - PrintDebug("Guest Balloon Currently Ignored\n"); - PrintDebug("\t Requested=%d, Allocated=%d\n", + PrintDebug(core->vm_info, core, "Guest Balloon Currently Ignored\n"); + PrintDebug(core->vm_info, core, "\t Requested=%d, Allocated=%d\n", virtio->balloon_cfg.requested_pages, virtio->balloon_cfg.allocated_pages); @@ -171,7 +171,7 @@ static int handle_kick(struct guest_info * core, struct virtio_balloon_state * v } if (!(q->avail->flags & VIRTIO_NO_IRQ_FLAG)) { - PrintDebug("Raising IRQ %d\n", virtio->pci_dev->config_header.intr_line); + PrintDebug(core->vm_info, core, "Raising IRQ %d\n", virtio->pci_dev->config_header.intr_line); v3_pci_raise_irq(virtio->pci_bus, virtio->pci_dev, 0); virtio->virtio_cfg.pci_isr = VIRTIO_ISR_ACTIVE; } @@ -184,7 +184,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, int port_idx = port % virtio->io_range_size; - PrintDebug("VIRTIO BALLOON Write for port %d (index=%d) len=%d, value=%x\n", + PrintDebug(core->vm_info, core, "VIRTIO BALLOON Write for port %d (index=%d) len=%d, value=%x\n", port, port_idx, length, *(uint32_t *)src); @@ -192,7 +192,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, switch (port_idx) { case GUEST_FEATURES_PORT: if (length != 4) { - PrintError("Illegal write length for guest features\n"); + PrintError(core->vm_info, core, "Illegal write length for guest features\n"); return -1; } @@ -217,32 +217,32 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, virtio->cur_queue->ring_used_addr = (virtio->cur_queue->ring_used_addr + 0xfff) & ~0xfff; if (v3_gpa_to_hva(core, virtio->cur_queue->ring_desc_addr, (addr_t *)&(virtio->cur_queue->desc)) == -1) { - PrintError("Could not translate ring descriptor address\n"); + PrintError(core->vm_info, core, "Could not translate ring descriptor address\n"); return -1; } if (v3_gpa_to_hva(core, virtio->cur_queue->ring_avail_addr, (addr_t *)&(virtio->cur_queue->avail)) == -1) { - PrintError("Could not translate ring available address\n"); + PrintError(core->vm_info, core, "Could not translate ring available address\n"); return -1; } if (v3_gpa_to_hva(core, virtio->cur_queue->ring_used_addr, (addr_t *)&(virtio->cur_queue->used)) == -1) { - PrintError("Could not translate ring used address\n"); + PrintError(core->vm_info, core, "Could not translate ring used address\n"); return -1; } - PrintDebug("RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", + PrintDebug(core->vm_info, core, "RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", (void *)(virtio->cur_queue->ring_desc_addr), (void *)(virtio->cur_queue->ring_avail_addr), (void *)(virtio->cur_queue->ring_used_addr)); - PrintDebug("RingDesc=%p, Avail=%p, Used=%p\n", + PrintDebug(core->vm_info, core, "RingDesc=%p, Avail=%p, Used=%p\n", virtio->cur_queue->desc, virtio->cur_queue->avail, virtio->cur_queue->used); } else { - PrintError("Illegal write length for page frame number\n"); + PrintError(core->vm_info, core, "Illegal write length for page frame number\n"); return -1; } break; @@ -250,7 +250,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, virtio->virtio_cfg.vring_queue_selector = *(uint16_t *)src; if (virtio->virtio_cfg.vring_queue_selector > 1) { - PrintError("Virtio Balloon device only uses 2 queue, selected %d\n", + PrintError(core->vm_info, core, "Virtio Balloon device only uses 2 queue, selected %d\n", virtio->virtio_cfg.vring_queue_selector); return -1; } @@ -259,9 +259,9 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, break; case VRING_Q_NOTIFY_PORT: - PrintDebug("Handling Kick\n"); + PrintDebug(core->vm_info, core, "Handling Kick\n"); if (handle_kick(core, virtio) == -1) { - PrintError("Could not handle Balloon Notification\n"); + PrintError(core->vm_info, core, "Could not handle Balloon Notification\n"); return -1; } break; @@ -269,7 +269,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, virtio->virtio_cfg.status = *(uint8_t *)src; if (virtio->virtio_cfg.status == 0) { - PrintDebug("Resetting device\n"); + PrintDebug(core->vm_info, core, "Resetting device\n"); virtio_reset(virtio); } @@ -292,13 +292,13 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u int port_idx = port % virtio->io_range_size; - PrintDebug("VIRTIO BALLOON Read for port %d (index =%d), length=%d\n", + PrintDebug(core->vm_info, core, "VIRTIO BALLOON Read for port %d (index =%d), length=%d\n", port, port_idx, length); switch (port_idx) { case HOST_FEATURES_PORT: if (length != 4) { - PrintError("Illegal read length for host features\n"); + PrintError(core->vm_info, core, "Illegal read length for host features\n"); return -1; } @@ -307,7 +307,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u break; case VRING_PG_NUM_PORT: if (length != 4) { - PrintError("Illegal read length for page frame number\n"); + PrintError(core->vm_info, core, "Illegal read length for page frame number\n"); return -1; } @@ -316,7 +316,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u break; case VRING_SIZE_PORT: if (length != 2) { - PrintError("Illegal read length for vring size\n"); + PrintError(core->vm_info, core, "Illegal read length for vring size\n"); return -1; } @@ -326,7 +326,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u case VIRTIO_STATUS_PORT: if (length != 1) { - PrintError("Illegal read length for status\n"); + PrintError(core->vm_info, core, "Illegal read length for status\n"); return -1; } @@ -348,7 +348,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u memcpy(dst, cfg_ptr + cfg_offset, length); } else { - PrintError("Read of Unhandled Virtio Read\n"); + PrintError(core->vm_info, core, "Read of Unhandled Virtio Read\n"); return -1; } @@ -377,7 +377,7 @@ static struct v3_device_ops dev_ops = { static int set_size(struct virtio_balloon_state * virtio, addr_t size) { virtio->balloon_cfg.requested_pages = size / PAGE_SIZE; // number of pages - PrintDebug("Requesting %d pages\n", virtio->balloon_cfg.requested_pages); + PrintDebug(VM_NONE, VCORE_NONE, "Requesting %d pages\n", virtio->balloon_cfg.requested_pages); v3_pci_raise_irq(virtio->pci_bus, virtio->pci_dev, 0); virtio->virtio_cfg.pci_isr = VIRTIO_ISR_ACTIVE | VIRTIO_ISR_CFG_CHANGED; @@ -416,10 +416,10 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct pci_device * pci_dev = NULL; char * dev_id = v3_cfg_val(cfg, "ID"); - PrintDebug("Initializing VIRTIO Balloon device\n"); + PrintDebug(vm, VCORE_NONE, "Initializing VIRTIO Balloon device\n"); if (pci_bus == NULL) { - PrintError("VirtIO devices require a PCI Bus"); + PrintError(vm, VCORE_NONE, "VirtIO devices require a PCI Bus"); return -1; } @@ -427,7 +427,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { virtio_state = (struct virtio_balloon_state *)V3_Malloc(sizeof(struct virtio_balloon_state)); if (!virtio_state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -437,7 +437,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, virtio_state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(virtio_state); return -1; } @@ -485,7 +485,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { NULL, NULL, NULL, NULL, virtio_state); if (!pci_dev) { - PrintError("Could not register PCI Device\n"); + PrintError(vm, VCORE_NONE, "Could not register PCI Device\n"); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/lnx_virtio_blk.c b/palacios/src/devices/lnx_virtio_blk.c index a8dba1c..476b284 100644 --- a/palacios/src/devices/lnx_virtio_blk.c +++ b/palacios/src/devices/lnx_virtio_blk.c @@ -125,7 +125,7 @@ static int blk_reset(struct virtio_blk_state * virtio) { static int handle_read_op(struct virtio_blk_state * blk_state, uint8_t * buf, uint64_t * sector, uint64_t len) { int ret = -1; - PrintDebug("Reading Disk\n"); + PrintDebug(info->vm_info, info, "Reading Disk\n"); ret = blk_state->ops->read(buf, (*sector) * SECTOR_SIZE, len, (void *)(blk_state->backend_data)); *sector += (len / SECTOR_SIZE); @@ -136,7 +136,7 @@ static int handle_read_op(struct virtio_blk_state * blk_state, uint8_t * buf, ui static int handle_write_op(struct virtio_blk_state * blk_state, uint8_t * buf, uint64_t * sector, uint64_t len) { int ret = -1; - PrintDebug("Writing Disk\n"); + PrintDebug(info->vm_info, info, "Writing Disk\n"); ret = blk_state->ops->write(buf, (*sector) * SECTOR_SIZE, len, (void *)(blk_state->backend_data)); *sector += (len / SECTOR_SIZE); @@ -151,13 +151,13 @@ static int handle_block_op(struct guest_info * core, struct virtio_blk_state * b struct vring_desc * buf_desc, uint8_t * status) { uint8_t * buf = NULL; - PrintDebug("Handling Block op\n"); + PrintDebug(core->vm_info, core, "Handling Block op\n"); if (v3_gpa_to_hva(core, buf_desc->addr_gpa, (addr_t *)&(buf)) == -1) { - PrintError("Could not translate buffer address\n"); + PrintError(core->vm_info, core, "Could not translate buffer address\n"); return -1; } - PrintDebug("Sector=%p Length=%d\n", (void *)(addr_t)(hdr->sector), buf_desc->length); + PrintDebug(core->vm_info, core, "Sector=%p Length=%d\n", (void *)(addr_t)(hdr->sector), buf_desc->length); if (hdr->type == BLK_IN_REQ) { if (handle_read_op(blk_state, buf, &(hdr->sector), buf_desc->length) == -1) { @@ -174,12 +174,12 @@ static int handle_block_op(struct guest_info * core, struct virtio_blk_state * b *status = BLK_STATUS_OK; } } else if (hdr->type == BLK_SCSI_CMD) { - PrintError("VIRTIO: SCSI Command Not supported!!!\n"); + PrintError(core->vm_info, core, "VIRTIO: SCSI Command Not supported!!!\n"); *status = BLK_STATUS_NOT_SUPPORTED; return -1; } - PrintDebug("Returning Status: %d\n", *status); + PrintDebug(core->vm_info, core, "Returning Status: %d\n", *status); return 0; } @@ -201,7 +201,7 @@ static int get_desc_count(struct virtio_queue * q, int index) { static int handle_kick(struct guest_info * core, struct virtio_blk_state * blk_state) { struct virtio_queue * q = &(blk_state->queue); - PrintDebug("VIRTIO KICK: cur_index=%d (mod=%d), avail_index=%d\n", + PrintDebug(core->vm_info, core, "VIRTIO KICK: cur_index=%d (mod=%d), avail_index=%d\n", q->cur_avail_idx, q->cur_avail_idx % QUEUE_SIZE, q->avail->index); while (q->cur_avail_idx != q->avail->index) { @@ -217,28 +217,28 @@ static int handle_kick(struct guest_info * core, struct virtio_blk_state * blk_s uint8_t status = BLK_STATUS_OK; uint32_t req_len = 0; - PrintDebug("Descriptor Count=%d, index=%d\n", desc_cnt, q->cur_avail_idx % QUEUE_SIZE); + PrintDebug(core->vm_info, core, "Descriptor Count=%d, index=%d\n", desc_cnt, q->cur_avail_idx % QUEUE_SIZE); if (desc_cnt < 3) { - PrintError("Block operations must include at least 3 descriptors\n"); + PrintError(core->vm_info, core, "Block operations must include at least 3 descriptors\n"); return -1; } hdr_desc = &(q->desc[desc_idx]); - PrintDebug("Header Descriptor (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", hdr_desc, + PrintDebug(core->vm_info, core, "Header Descriptor (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", hdr_desc, (void *)(hdr_desc->addr_gpa), hdr_desc->length, hdr_desc->flags, hdr_desc->next); if (v3_gpa_to_hva(core, hdr_desc->addr_gpa, &(hdr_addr)) == -1) { - PrintError("Could not translate block header address\n"); + PrintError(core->vm_info, core, "Could not translate block header address\n"); return -1; } // We copy the block op header out because we are going to modify its contents memcpy(&hdr, (void *)hdr_addr, sizeof(struct blk_op_hdr)); - PrintDebug("Blk Op Hdr (ptr=%p) type=%d, sector=%p\n", (void *)hdr_addr, hdr.type, (void *)hdr.sector); + PrintDebug(core->vm_info, core, "Blk Op Hdr (ptr=%p) type=%d, sector=%p\n", (void *)hdr_addr, hdr.type, (void *)hdr.sector); desc_idx = hdr_desc->next; @@ -247,11 +247,11 @@ static int handle_kick(struct guest_info * core, struct virtio_blk_state * blk_s buf_desc = &(q->desc[desc_idx]); - PrintDebug("Buffer Descriptor (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", buf_desc, + PrintDebug(core->vm_info, core, "Buffer Descriptor (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", buf_desc, (void *)(buf_desc->addr_gpa), buf_desc->length, buf_desc->flags, buf_desc->next); if (handle_block_op(core, blk_state, &hdr, buf_desc, &tmp_status) == -1) { - PrintError("Error handling block operation\n"); + PrintError(core->vm_info, core, "Error handling block operation\n"); return -1; } @@ -265,11 +265,11 @@ static int handle_kick(struct guest_info * core, struct virtio_blk_state * blk_s status_desc = &(q->desc[desc_idx]); - PrintDebug("Status Descriptor (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", status_desc, + PrintDebug(core->vm_info, core, "Status Descriptor (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", status_desc, (void *)(status_desc->addr_gpa), status_desc->length, status_desc->flags, status_desc->next); if (v3_gpa_to_hva(core, status_desc->addr_gpa, (addr_t *)&(status_ptr)) == -1) { - PrintError("Could not translate status address\n"); + PrintError(core->vm_info, core, "Could not translate status address\n"); return -1; } @@ -284,7 +284,7 @@ static int handle_kick(struct guest_info * core, struct virtio_blk_state * blk_s } if (!(q->avail->flags & VIRTIO_NO_IRQ_FLAG)) { - PrintDebug("Raising IRQ %d\n", blk_state->pci_dev->config_header.intr_line); + PrintDebug(core->vm_info, core, "Raising IRQ %d\n", blk_state->pci_dev->config_header.intr_line); v3_pci_raise_irq(blk_state->virtio_dev->pci_bus, blk_state->pci_dev, 0); blk_state->virtio_cfg.pci_isr = 1; } @@ -297,7 +297,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, int port_idx = port % blk_state->io_range_size; - PrintDebug("VIRTIO BLOCK Write for port %d (index=%d) len=%d, value=%x\n", + PrintDebug(core->vm_info, core, "VIRTIO BLOCK Write for port %d (index=%d) len=%d, value=%x\n", port, port_idx, length, *(uint32_t *)src); @@ -305,12 +305,12 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, switch (port_idx) { case GUEST_FEATURES_PORT: if (length != 4) { - PrintError("Illegal write length for guest features\n"); + PrintError(core->vm_info, core, "Illegal write length for guest features\n"); return -1; } blk_state->virtio_cfg.guest_features = *(uint32_t *)src; - PrintDebug("Setting Guest Features to %x\n", blk_state->virtio_cfg.guest_features); + PrintDebug(core->vm_info, core, "Setting Guest Features to %x\n", blk_state->virtio_cfg.guest_features); break; case VRING_PG_NUM_PORT: @@ -331,32 +331,32 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, blk_state->queue.ring_used_addr = (blk_state->queue.ring_used_addr + 0xfff) & ~0xfff; if (v3_gpa_to_hva(core, blk_state->queue.ring_desc_addr, (addr_t *)&(blk_state->queue.desc)) == -1) { - PrintError("Could not translate ring descriptor address\n"); + PrintError(core->vm_info, core, "Could not translate ring descriptor address\n"); return -1; } if (v3_gpa_to_hva(core, blk_state->queue.ring_avail_addr, (addr_t *)&(blk_state->queue.avail)) == -1) { - PrintError("Could not translate ring available address\n"); + PrintError(core->vm_info, core, "Could not translate ring available address\n"); return -1; } if (v3_gpa_to_hva(core, blk_state->queue.ring_used_addr, (addr_t *)&(blk_state->queue.used)) == -1) { - PrintError("Could not translate ring used address\n"); + PrintError(core->vm_info, core, "Could not translate ring used address\n"); return -1; } - PrintDebug("RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", + PrintDebug(core->vm_info, core, "RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", (void *)(blk_state->queue.ring_desc_addr), (void *)(blk_state->queue.ring_avail_addr), (void *)(blk_state->queue.ring_used_addr)); - PrintDebug("RingDesc=%p, Avail=%p, Used=%p\n", + PrintDebug(core->vm_info, core, "RingDesc=%p, Avail=%p, Used=%p\n", blk_state->queue.desc, blk_state->queue.avail, blk_state->queue.used); } else { - PrintError("Illegal write length for page frame number\n"); + PrintError(core->vm_info, core, "Illegal write length for page frame number\n"); return -1; } break; @@ -364,16 +364,16 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, blk_state->virtio_cfg.vring_queue_selector = *(uint16_t *)src; if (blk_state->virtio_cfg.vring_queue_selector != 0) { - PrintError("Virtio Block device only uses 1 queue, selected %d\n", + PrintError(core->vm_info, core, "Virtio Block device only uses 1 queue, selected %d\n", blk_state->virtio_cfg.vring_queue_selector); return -1; } break; case VRING_Q_NOTIFY_PORT: - PrintDebug("Handling Kick\n"); + PrintDebug(core->vm_info, core, "Handling Kick\n"); if (handle_kick(core, blk_state) == -1) { - PrintError("Could not handle Block Notification\n"); + PrintError(core->vm_info, core, "Could not handle Block Notification\n"); return -1; } break; @@ -381,7 +381,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, blk_state->virtio_cfg.status = *(uint8_t *)src; if (blk_state->virtio_cfg.status == 0) { - PrintDebug("Resetting device\n"); + PrintDebug(core->vm_info, core, "Resetting device\n"); blk_reset(blk_state); } @@ -404,7 +404,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u int port_idx = port % blk_state->io_range_size; - PrintDebug("VIRTIO BLOCK Read for port %d (index =%d), length=%d\n", + PrintDebug(core->vm_info, core, "VIRTIO BLOCK Read for port %d (index =%d), length=%d\n", port, port_idx, length); @@ -414,7 +414,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u case HOST_FEATURES_PORT + 2: case HOST_FEATURES_PORT + 3: if (port_idx + length > HOST_FEATURES_PORT + 4) { - PrintError("Illegal read length for host features (len=%d)\n", length); + PrintError(core->vm_info, core, "Illegal read length for host features (len=%d)\n", length); return -1; } @@ -425,7 +425,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u case VRING_PG_NUM_PORT + 2: case VRING_PG_NUM_PORT + 3: if (port_idx + length > VRING_PG_NUM_PORT + 4) { - PrintError("Illegal read length for vring pg num (len=%d)\n", length); + PrintError(core->vm_info, core, "Illegal read length for vring pg num (len=%d)\n", length); return -1; } @@ -434,7 +434,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u case VRING_SIZE_PORT: case VRING_SIZE_PORT + 1: if (length > 2) { - PrintError("Illegal read length for vring size (len=%d)\n", length); + PrintError(core->vm_info, core, "Illegal read length for vring size (len=%d)\n", length); return -1; } @@ -444,7 +444,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u case VIRTIO_STATUS_PORT: if (length != 1) { - PrintError("Illegal read length for status (len=%d)\n", length); + PrintError(core->vm_info, core, "Illegal read length for status (len=%d)\n", length); return -1; } @@ -466,7 +466,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u memcpy(dst, cfg_ptr + cfg_offset, length); } else { - PrintError("Read of Unhandled Virtio Read\n"); + PrintError(core->vm_info, core, "Read of Unhandled Virtio Read\n"); return -1; } @@ -535,7 +535,7 @@ static int register_dev(struct virtio_dev_state * virtio, struct virtio_blk_stat bars[i].type = PCI_BAR_NONE; } - PrintDebug("Virtio-BLK io_range_size = %d\n", blk_state->io_range_size); + PrintDebug(VM_NONE, VCORE_NONE, "Virtio-BLK io_range_size = %d\n", blk_state->io_range_size); bars[0].type = PCI_BAR_IO; bars[0].default_base_port = -1; @@ -551,7 +551,7 @@ static int register_dev(struct virtio_dev_state * virtio, struct virtio_blk_stat NULL, NULL, NULL, NULL, blk_state); if (!pci_dev) { - PrintError("Could not register PCI Device\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not register PCI Device\n"); return -1; } @@ -604,7 +604,7 @@ static int connect_fn(struct v3_vm_info * vm, struct virtio_blk_state * blk_state = (struct virtio_blk_state *)V3_Malloc(sizeof(struct virtio_blk_state)); if (!blk_state) { - PrintError("Cannot allocate in connect\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in connect\n"); return -1; } @@ -618,7 +618,7 @@ static int connect_fn(struct v3_vm_info * vm, blk_state->block_cfg.capacity = ops->get_capacity(private_data) / SECTOR_SIZE; - PrintDebug("Virtio Capacity = %d -- 0x%p\n", (int)(blk_state->block_cfg.capacity), + PrintDebug(vm, VCORE_NONE, "Virtio Capacity = %d -- 0x%p\n", (int)(blk_state->block_cfg.capacity), (void *)(addr_t)(blk_state->block_cfg.capacity)); return 0; @@ -630,10 +630,10 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct virtio_dev_state * virtio_state = NULL; char * dev_id = v3_cfg_val(cfg, "ID"); - PrintDebug("Initializing VIRTIO Block device\n"); + PrintDebug(vm, VCORE_NONE, "Initializing VIRTIO Block device\n"); if (pci_bus == NULL) { - PrintError("VirtIO devices require a PCI Bus"); + PrintError(vm, VCORE_NONE, "VirtIO devices require a PCI Bus"); return -1; } @@ -641,7 +641,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { virtio_state = (struct virtio_dev_state *)V3_Malloc(sizeof(struct virtio_dev_state)); if (!virtio_state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -654,13 +654,13 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, virtio_state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(virtio_state); return -1; } if (v3_dev_add_blk_frontend(vm, dev_id, connect_fn, (void *)virtio_state) == -1) { - PrintError("Could not register %s as block frontend\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not register %s as block frontend\n", dev_id); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/lnx_virtio_console.c b/palacios/src/devices/lnx_virtio_console.c index 0c0f4bc..e3087a7 100644 --- a/palacios/src/devices/lnx_virtio_console.c +++ b/palacios/src/devices/lnx_virtio_console.c @@ -102,7 +102,7 @@ static int get_desc_count(struct virtio_queue * q, int index) { static int handle_kick(struct guest_info * core, struct virtio_console_state * virtio) { struct virtio_queue * q = virtio->cur_queue; - PrintDebug("VIRTIO CONSOLE KICK: cur_index=%d (mod=%d), avail_index=%d\n", + PrintDebug(core->vm_info, core, "VIRTIO CONSOLE KICK: cur_index=%d (mod=%d), avail_index=%d\n", q->cur_avail_idx, q->cur_avail_idx % QUEUE_SIZE, q->avail->index); while (q->cur_avail_idx < q->avail->index) { @@ -113,26 +113,26 @@ static int handle_kick(struct guest_info * core, struct virtio_console_state * v uint32_t req_len = 0; - PrintDebug("Descriptor Count=%d, index=%d\n", desc_cnt, q->cur_avail_idx % QUEUE_SIZE); + PrintDebug(core->vm_info, core, "Descriptor Count=%d, index=%d\n", desc_cnt, q->cur_avail_idx % QUEUE_SIZE); for (i = 0; i < desc_cnt; i++) { addr_t page_addr; tmp_desc = &(q->desc[desc_idx]); - PrintDebug("Console output (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", + PrintDebug(core->vm_info, core, "Console output (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", tmp_desc, (void *)(addr_t)(tmp_desc->addr_gpa), tmp_desc->length, tmp_desc->flags, tmp_desc->next); if (v3_gpa_to_hva(core, tmp_desc->addr_gpa, (addr_t *)&(page_addr)) == -1) { - PrintError("Could not translate block header address\n"); + PrintError(core->vm_info, core, "Could not translate block header address\n"); return -1; } virtio->ops->output((uint8_t *)page_addr, tmp_desc->length, virtio->backend_data); - PrintDebug("Guest Console Currently Ignored\n"); + PrintDebug(core->vm_info, core, "Guest Console Currently Ignored\n"); req_len += tmp_desc->length; desc_idx = tmp_desc->next; @@ -146,7 +146,7 @@ static int handle_kick(struct guest_info * core, struct virtio_console_state * v } if (!(q->avail->flags & VIRTIO_NO_IRQ_FLAG)) { - PrintDebug("Raising IRQ %d\n", virtio->pci_dev->config_header.intr_line); + PrintDebug(core->vm_info, core, "Raising IRQ %d\n", virtio->pci_dev->config_header.intr_line); v3_pci_raise_irq(virtio->pci_bus, virtio->pci_dev, 0); virtio->virtio_cfg.pci_isr = VIRTIO_ISR_ACTIVE; } @@ -160,7 +160,7 @@ static uint64_t virtio_input(struct v3_vm_info * vm, uint8_t * buf, uint64_t len struct virtio_queue * q = &(cons_state->queue[0]); int xfer_len = 0; - PrintDebug("VIRTIO CONSOLE Handle Input: cur_index=%d (mod=%d), avail_index=%d\n", + PrintDebug(vm, VCORE_NONE, "VIRTIO CONSOLE Handle Input: cur_index=%d (mod=%d), avail_index=%d\n", q->cur_avail_idx, q->cur_avail_idx % QUEUE_SIZE, q->avail->index); @@ -173,7 +173,7 @@ static uint64_t virtio_input(struct v3_vm_info * vm, uint8_t * buf, uint64_t len input_desc = &(q->desc[input_idx]); if (v3_gpa_to_hva(&(cons_state->vm->cores[0]), input_desc->addr_gpa, (addr_t *)&(input_buf)) == -1) { - PrintError("Could not translate receive buffer address\n"); + PrintError(vm, VCORE_NONE, "Could not translate receive buffer address\n"); return 0; } @@ -207,7 +207,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, int port_idx = port % virtio->io_range_size; - PrintDebug("VIRTIO CONSOLE Write for port %d (index=%d) len=%d, value=%x\n", + PrintDebug(core->vm_info, core, "VIRTIO CONSOLE Write for port %d (index=%d) len=%d, value=%x\n", port, port_idx, length, *(uint32_t *)src); @@ -215,7 +215,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, switch (port_idx) { case GUEST_FEATURES_PORT: if (length != 4) { - PrintError("Illegal write length for guest features\n"); + PrintError(core->vm_info, core, "Illegal write length for guest features\n"); return -1; } @@ -240,32 +240,32 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, virtio->cur_queue->ring_used_addr = (virtio->cur_queue->ring_used_addr + 0xfff) & ~0xfff; if (v3_gpa_to_hva(core, virtio->cur_queue->ring_desc_addr, (addr_t *)&(virtio->cur_queue->desc)) == -1) { - PrintError("Could not translate ring descriptor address\n"); + PrintError(core->vm_info, core, "Could not translate ring descriptor address\n"); return -1; } if (v3_gpa_to_hva(core, virtio->cur_queue->ring_avail_addr, (addr_t *)&(virtio->cur_queue->avail)) == -1) { - PrintError("Could not translate ring available address\n"); + PrintError(core->vm_info, core, "Could not translate ring available address\n"); return -1; } if (v3_gpa_to_hva(core, virtio->cur_queue->ring_used_addr, (addr_t *)&(virtio->cur_queue->used)) == -1) { - PrintError("Could not translate ring used address\n"); + PrintError(core->vm_info, core, "Could not translate ring used address\n"); return -1; } - PrintDebug("RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", + PrintDebug(core->vm_info, core, "RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", (void *)(virtio->cur_queue->ring_desc_addr), (void *)(virtio->cur_queue->ring_avail_addr), (void *)(virtio->cur_queue->ring_used_addr)); - PrintDebug("RingDesc=%p, Avail=%p, Used=%p\n", + PrintDebug(core->vm_info, core, "RingDesc=%p, Avail=%p, Used=%p\n", virtio->cur_queue->desc, virtio->cur_queue->avail, virtio->cur_queue->used); } else { - PrintError("Illegal write length for page frame number\n"); + PrintError(core->vm_info, core, "Illegal write length for page frame number\n"); return -1; } break; @@ -273,7 +273,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, virtio->virtio_cfg.vring_queue_selector = *(uint16_t *)src; if (virtio->virtio_cfg.vring_queue_selector > 1) { - PrintError("Virtio Console device only uses 2 queue, selected %d\n", + PrintError(core->vm_info, core, "Virtio Console device only uses 2 queue, selected %d\n", virtio->virtio_cfg.vring_queue_selector); return -1; } @@ -282,9 +282,9 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, break; case VRING_Q_NOTIFY_PORT: - PrintDebug("Handling Kick\n"); + PrintDebug(core->vm_info, core, "Handling Kick\n"); if (handle_kick(core, virtio) == -1) { - PrintError("Could not handle Console Notification\n"); + PrintError(core->vm_info, core, "Could not handle Console Notification\n"); return -1; } break; @@ -292,7 +292,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, virtio->virtio_cfg.status = *(uint8_t *)src; if (virtio->virtio_cfg.status == 0) { - PrintDebug("Resetting device\n"); + PrintDebug(core->vm_info, core, "Resetting device\n"); virtio_reset(virtio); } @@ -315,13 +315,13 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u int port_idx = port % virtio->io_range_size; - PrintDebug("VIRTIO CONSOLE Read for port %d (index =%d), length=%d\n", + PrintDebug(core->vm_info, core, "VIRTIO CONSOLE Read for port %d (index =%d), length=%d\n", port, port_idx, length); switch (port_idx) { case HOST_FEATURES_PORT: if (length != 4) { - PrintError("Illegal read length for host features\n"); + PrintError(core->vm_info, core, "Illegal read length for host features\n"); return -1; } @@ -330,7 +330,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u break; case VRING_PG_NUM_PORT: if (length != 4) { - PrintError("Illegal read length for page frame number\n"); + PrintError(core->vm_info, core, "Illegal read length for page frame number\n"); return -1; } @@ -339,7 +339,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u break; case VRING_SIZE_PORT: if (length != 2) { - PrintError("Illegal read length for vring size\n"); + PrintError(core->vm_info, core, "Illegal read length for vring size\n"); return -1; } @@ -349,7 +349,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u case VIRTIO_STATUS_PORT: if (length != 1) { - PrintError("Illegal read length for status\n"); + PrintError(core->vm_info, core, "Illegal read length for status\n"); return -1; } @@ -371,7 +371,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u memcpy(dst, cfg_ptr + cfg_offset, length); } else { - PrintError("Read of Unhandled Virtio Read\n"); + PrintError(core->vm_info, core, "Read of Unhandled Virtio Read\n"); return -1; } @@ -425,10 +425,10 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct pci_device * pci_dev = NULL; char * dev_id = v3_cfg_val(cfg, "ID"); - PrintDebug("Initializing VIRTIO Console device\n"); + PrintDebug(vm, VCORE_NONE, "Initializing VIRTIO Console device\n"); if (pci_bus == NULL) { - PrintError("VirtIO devices require a PCI Bus"); + PrintError(vm, VCORE_NONE, "VirtIO devices require a PCI Bus"); return -1; } @@ -436,7 +436,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { virtio_state = (struct virtio_console_state *)V3_Malloc(sizeof(struct virtio_console_state)); if (!virtio_state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -451,7 +451,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, virtio_state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(virtio_state); return -1; } @@ -498,7 +498,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { NULL, NULL, NULL, NULL, virtio_state); if (!pci_dev) { - PrintError("Could not register PCI Device\n"); + PrintError(vm, VCORE_NONE, "Could not register PCI Device\n"); v3_remove_device(dev); return -1; } @@ -525,7 +525,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { virtio_reset(virtio_state); if (v3_dev_add_char_frontend(vm, dev_id, connect_fn, (void *)virtio_state) == -1) { - PrintError("Could not register %s as frontend\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not register %s as frontend\n", dev_id); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/lnx_virtio_nic.c b/palacios/src/devices/lnx_virtio_nic.c index 2f5c2b8..da3dd9d 100644 --- a/palacios/src/devices/lnx_virtio_nic.c +++ b/palacios/src/devices/lnx_virtio_nic.c @@ -187,7 +187,7 @@ static int virtio_init_state(struct virtio_net_state * virtio) if ((v3_lock_init(&(virtio->rx_lock)) == -1) || (v3_lock_init(&(virtio->tx_lock)) == -1)){ - PrintError("Virtio NIC: Failure to init locks for net_state\n"); + PrintError(VM_NONE, VCORE_NONE, "Virtio NIC: Failure to init locks for net_state\n"); } return 0; @@ -209,7 +209,7 @@ static int tx_one_pkt(struct guest_info * core, uint32_t len = buf_desc->length; if (v3_gpa_to_hva(core, buf_desc->addr_gpa, (addr_t *)&(buf)) == -1) { - PrintDebug("Could not translate buffer address\n"); + PrintDebug(core->vm_info, core, "Could not translate buffer address\n"); return -1; } @@ -241,7 +241,7 @@ static inline int copy_data_to_desc(struct guest_info * core, uint8_t * desc_buf = NULL; if (v3_gpa_to_hva(core, desc->addr_gpa, (addr_t *)&(desc_buf)) == -1) { - PrintDebug("Could not translate buffer address\n"); + PrintDebug(core->vm_info, core, "Could not translate buffer address\n"); return -1; } len = (desc->length < (buf_len+dst_offset))?(desc->length - dst_offset):buf_len; @@ -310,7 +310,7 @@ static int handle_pkt_tx(struct guest_info * core, desc_cnt = get_desc_count(q, desc_idx); if(desc_cnt != 2){ - PrintError("VNIC: merged rx buffer not supported, desc_cnt %d\n", desc_cnt); + PrintError(core->vm_info, core, "VNIC: merged rx buffer not supported, desc_cnt %d\n", desc_cnt); } hdr_desc = &(q->desc[desc_idx]); @@ -324,10 +324,10 @@ static int handle_pkt_tx(struct guest_info * core, /* here we assumed that one ethernet pkt is not splitted into multiple buffer */ buf_desc = &(q->desc[desc_idx]); if (tx_one_pkt(core, virtio_state, buf_desc) == -1) { - PrintError("Virtio NIC: Fails to send packet\n"); + PrintError(core->vm_info, core, "Virtio NIC: Fails to send packet\n"); } } else { - PrintError("Could not translate block header address\n"); + PrintError(core->vm_info, core, "Could not translate block header address\n"); } flags = v3_lock_irqsave(virtio_state->tx_lock); @@ -368,26 +368,26 @@ static int virtio_setup_queue(struct guest_info *core, // round up to next page boundary. queue->ring_used_addr = (queue->ring_used_addr + 0xfff) & ~0xfff; if (v3_gpa_to_hva(core, queue->ring_desc_addr, (addr_t *)&(queue->desc)) == -1) { - PrintError("Could not translate ring descriptor address\n"); + PrintError(core->vm_info, core, "Could not translate ring descriptor address\n"); return -1; } if (v3_gpa_to_hva(core, queue->ring_avail_addr, (addr_t *)&(queue->avail)) == -1) { - PrintError("Could not translate ring available address\n"); + PrintError(core->vm_info, core, "Could not translate ring available address\n"); return -1; } if (v3_gpa_to_hva(core, queue->ring_used_addr, (addr_t *)&(queue->used)) == -1) { - PrintError("Could not translate ring used address\n"); + PrintError(core->vm_info, core, "Could not translate ring used address\n"); return -1; } - PrintDebug("RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", + PrintDebug(core->vm_info, core, "RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", (void *)(queue->ring_desc_addr), (void *)(queue->ring_avail_addr), (void *)(queue->ring_used_addr)); - PrintDebug("RingDesc=%p, Avail=%p, Used=%p\n", + PrintDebug(core->vm_info, core, "RingDesc=%p, Avail=%p, Used=%p\n", queue->desc, queue->avail, queue->used); return 0; @@ -400,14 +400,14 @@ static int virtio_io_write(struct guest_info *core, struct virtio_net_state * virtio = (struct virtio_net_state *)private_data; int port_idx = port % virtio->io_range_size; - PrintDebug("VIRTIO NIC %p Write for port %d (index=%d) len=%d, value=%x\n", + PrintDebug(core->vm_info, core, "VIRTIO NIC %p Write for port %d (index=%d) len=%d, value=%x\n", private_data, port, port_idx, length, *(uint32_t *)src); switch (port_idx) { case GUEST_FEATURES_PORT: if (length != 4) { - PrintError("Illegal write length for guest features\n"); + PrintError(core->vm_info, core, "Illegal write length for guest features\n"); return -1; } virtio->virtio_cfg.guest_features = *(uint32_t *)src; @@ -415,7 +415,7 @@ static int virtio_io_write(struct guest_info *core, case VRING_PG_NUM_PORT: if (length != 4) { - PrintError("Illegal write length for page frame number\n"); + PrintError(core->vm_info, core, "Illegal write length for page frame number\n"); return -1; } addr_t pfn = *(uint32_t *)src; @@ -449,7 +449,7 @@ static int virtio_io_write(struct guest_info *core, case VRING_Q_SEL_PORT: virtio->virtio_cfg.vring_queue_selector = *(uint16_t *)src; if (virtio->virtio_cfg.vring_queue_selector > 2) { - PrintError("Virtio NIC: wrong queue idx: %d\n", + PrintError(core->vm_info, core, "Virtio NIC: wrong queue idx: %d\n", virtio->virtio_cfg.vring_queue_selector); return -1; } @@ -463,14 +463,14 @@ static int virtio_io_write(struct guest_info *core, virtio->stats.tx_interrupts ++; } else if (queue_idx == 1){ if (handle_pkt_tx(core, virtio, 0) < 0) { - PrintError("Virtio NIC: Error to handle packet TX\n"); + PrintError(core->vm_info, core, "Virtio NIC: Error to handle packet TX\n"); return -1; } virtio->stats.tx_interrupts ++; } else if (queue_idx == 2){ /* ctrl */ } else { - PrintError("Virtio NIC: Wrong queue index %d\n", queue_idx); + PrintError(core->vm_info, core, "Virtio NIC: Wrong queue index %d\n", queue_idx); } break; } @@ -502,13 +502,13 @@ static int virtio_io_read(struct guest_info *core, int port_idx = port % virtio->io_range_size; uint16_t queue_idx = virtio->virtio_cfg.vring_queue_selector; - PrintDebug("Virtio NIC %p: Read for port 0x%x (index =%d), length=%d\n", + PrintDebug(core->vm_info, core, "Virtio NIC %p: Read for port 0x%x (index =%d), length=%d\n", private_data, port, port_idx, length); switch (port_idx) { case HOST_FEATURES_PORT: if (length != 4) { - PrintError("Virtio NIC: Illegal read length for host features\n"); + PrintError(core->vm_info, core, "Virtio NIC: Illegal read length for host features\n"); //return -1; } *(uint32_t *)dst = virtio->virtio_cfg.host_features; @@ -516,7 +516,7 @@ static int virtio_io_read(struct guest_info *core, case VRING_PG_NUM_PORT: if (length != 4) { - PrintError("Virtio NIC: Illegal read length for page frame number\n"); + PrintError(core->vm_info, core, "Virtio NIC: Illegal read length for page frame number\n"); return -1; } switch (queue_idx) { @@ -536,7 +536,7 @@ static int virtio_io_read(struct guest_info *core, case VRING_SIZE_PORT: if (length != 2) { - PrintError("Virtio NIC: Illegal read length for vring size\n"); + PrintError(core->vm_info, core, "Virtio NIC: Illegal read length for vring size\n"); return -1; } switch (queue_idx) { @@ -556,7 +556,7 @@ static int virtio_io_read(struct guest_info *core, case VIRTIO_STATUS_PORT: if (length != 1) { - PrintError("Virtio NIC: Illegal read length for status\n"); + PrintError(core->vm_info, core, "Virtio NIC: Illegal read length for status\n"); return -1; } *(uint8_t *)dst = virtio->virtio_cfg.status; @@ -574,7 +574,7 @@ static int virtio_io_read(struct guest_info *core, break; default: - PrintError("Virtio NIC: Read of Unhandled Virtio Read:%d\n", + PrintError(core->vm_info, core, "Virtio NIC: Read of Unhandled Virtio Read:%d\n", port_idx); return -1; } @@ -802,7 +802,7 @@ static int register_dev(struct virtio_dev_state * virtio, bars[i].type = PCI_BAR_NONE; } - PrintDebug("Virtio NIC: io_range_size = %d\n", + PrintDebug(VM_NONE, VCORE_NONE, "Virtio NIC: io_range_size = %d\n", net_state->io_range_size); bars[0].type = PCI_BAR_IO; @@ -818,11 +818,11 @@ static int register_dev(struct virtio_dev_state * virtio, NULL, NULL, NULL, NULL, net_state); if (!pci_dev) { - PrintError("Virtio NIC: Could not register PCI Device\n"); + PrintError(VM_NONE, VCORE_NONE, "Virtio NIC: Could not register PCI Device\n"); return -1; } - PrintDebug("Virtio NIC: registered to PCI bus\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Virtio NIC: registered to PCI bus\n"); pci_dev->config_header.vendor_id = VIRTIO_VENDOR_ID; pci_dev->config_header.subsystem_vendor_id = VIRTIO_SUBVENDOR_ID; @@ -842,7 +842,7 @@ static int register_dev(struct virtio_dev_state * virtio, virtio_init_state(net_state); - V3_Print("Virtio NIC: Registered Intr Line %d\n", pci_dev->config_header.intr_line); + V3_Print(VM_NONE, VCORE_NONE, "Virtio NIC: Registered Intr Line %d\n", pci_dev->config_header.intr_line); /* Add backend to list of devices */ list_add(&(net_state->dev_link), &(virtio->dev_list)); @@ -888,24 +888,24 @@ static void virtio_nic_timer(struct guest_info * core, net_state->rx_pkts = net_state->stats.rx_pkts; if(tx_count > ub_tx_count && net_state->tx_notify == 1) { - PrintDebug("Virtio NIC: Switch TX to VMM driven mode\n"); + PrintDebug(core->vm_info, core, "Virtio NIC: Switch TX to VMM driven mode\n"); disable_cb(&(net_state->tx_vq)); net_state->tx_notify = 0; } if(tx_count < lb_tx_count && net_state->tx_notify == 0) { - PrintDebug("Virtio NIC: Switch TX to Guest driven mode\n"); + PrintDebug(core->vm_info, core, "Virtio NIC: Switch TX to Guest driven mode\n"); enable_cb(&(net_state->tx_vq)); net_state->tx_notify = 1; } if(rx_count > ub_rx_count && net_state->rx_notify == 1) { - PrintDebug("Virtio NIC: Switch RX to VMM None notify mode\n"); + PrintDebug(core->vm_info, core, "Virtio NIC: Switch RX to VMM None notify mode\n"); net_state->rx_notify = 0; } if(rx_count < lb_rx_count && net_state->rx_notify == 0) { - V3_Print("Virtio NIC: Switch RX to VMM notify mode\n"); + V3_Print(core->vm_info, core, "Virtio NIC: Switch RX to VMM notify mode\n"); net_state->rx_notify = 1; } @@ -914,7 +914,7 @@ static void virtio_nic_timer(struct guest_info * core, profile_ms += period_us/1000; if(profile_ms > 20000){ - PrintDebug("Virtio NIC: TX: Pkt: %lld, Bytes: %lld\n\t\tRX Pkt: %lld. Bytes: %lld\n\t\tDropped: tx %lld, rx %lld\nInterrupts: tx %d, rx %d\nTotal Exit: %lld\n", + PrintDebug(core->vm_info, core, "Virtio NIC: TX: Pkt: %lld, Bytes: %lld\n\t\tRX Pkt: %lld. Bytes: %lld\n\t\tDropped: tx %lld, rx %lld\nInterrupts: tx %d, rx %d\nTotal Exit: %lld\n", net_state->stats.tx_pkts, net_state->stats.tx_bytes, net_state->stats.rx_pkts, net_state->stats.rx_bytes, net_state->stats.tx_dropped, net_state->stats.rx_dropped, @@ -937,7 +937,7 @@ static int connect_fn(struct v3_vm_info * info, struct virtio_net_state * net_state = (struct virtio_net_state *)V3_Malloc(sizeof(struct virtio_net_state)); if (!net_state) { - PrintError("Cannot allocate in connect\n"); + PrintError(info, VCORE_NONE, "Cannot allocate in connect\n"); return -1; } @@ -951,17 +951,17 @@ static int connect_fn(struct v3_vm_info * info, switch (virtio->model) { case GUEST_DRIVEN: - V3_Print("Virtio NIC: Guest-driven operation\n"); + V3_Print(info, VCORE_NONE, "Virtio NIC: Guest-driven operation\n"); net_state->tx_notify = 1; net_state->rx_notify = 1; break; case VMM_DRIVEN: - V3_Print("Virtio NIC: VMM-driven operation\n"); + V3_Print(info, VCORE_NONE, "Virtio NIC: VMM-driven operation\n"); net_state->tx_notify = 0; net_state->rx_notify = 0; break; case ADAPTIVE: { - V3_Print("Virtio NIC: Adaptive operation (begins in guest-driven mode)\n"); + V3_Print(info, VCORE_NONE, "Virtio NIC: Adaptive operation (begins in guest-driven mode)\n"); net_state->tx_notify = 1; net_state->rx_notify = 1; @@ -971,7 +971,7 @@ static int connect_fn(struct v3_vm_info * info, break; default: - V3_Print("Virtio NIC: Unknown model, using GUEST_DRIVEN\n"); + V3_Print(info, VCORE_NONE, "Virtio NIC: Unknown model, using GUEST_DRIVEN\n"); net_state->tx_notify = 1; net_state->rx_notify = 1; break; @@ -986,7 +986,7 @@ static int connect_fn(struct v3_vm_info * info, ops->config.fnt_mac = V3_Malloc(ETH_ALEN); if (!ops->config.fnt_mac) { - PrintError("Cannot allocate in connect\n"); + PrintError(info, VCORE_NONE, "Cannot allocate in connect\n"); // should unregister here return -1; } @@ -1010,43 +1010,43 @@ static int setup_perf_model(struct virtio_dev_state *virtio_state, v3_cfg_tree_t // overrides if (mode) { if (!strcasecmp(mode,"guest-driven")) { - V3_Print("Virtio NIC: Setting static GUEST_DRIVEN mode of operation (latency optimized)\n"); + V3_Print(VM_NONE, VCORE_NONE, "Virtio NIC: Setting static GUEST_DRIVEN mode of operation (latency optimized)\n"); virtio_state->model=GUEST_DRIVEN; } else if (!strcasecmp(mode, "vmm-driven")) { - V3_Print("Virtio NIC: Setting static VMM_DRIVEN mode of operation (throughput optimized)\n"); + V3_Print(VM_NONE, VCORE_NONE, "Virtio NIC: Setting static VMM_DRIVEN mode of operation (throughput optimized)\n"); virtio_state->model=VMM_DRIVEN; } else if (!strcasecmp(mode, "adaptive")) { char *s; - V3_Print("Virtio NIC: Setting dynamic ADAPTIVE mode of operation\n"); + V3_Print(VM_NONE, VCORE_NONE, "Virtio NIC: Setting dynamic ADAPTIVE mode of operation\n"); virtio_state->model=ADAPTIVE; if (!(s=v3_cfg_val(t,"upper"))) { - V3_Print("Virtio NIC: No upper bound given, using default\n"); + V3_Print(VM_NONE, VCORE_NONE, "Virtio NIC: No upper bound given, using default\n"); } else { virtio_state->upper_thresh_pps = atoi(s); } if (!(s=v3_cfg_val(t,"lower"))) { - V3_Print("Virtio NIC: No lower bound given, using default\n"); + V3_Print(VM_NONE, VCORE_NONE, "Virtio NIC: No lower bound given, using default\n"); } else { virtio_state->lower_thresh_pps = atoi(s); } if (!(s=v3_cfg_val(t,"period"))) { - V3_Print("Virtio NIC: No period given, using default\n"); + V3_Print(VM_NONE, VCORE_NONE, "Virtio NIC: No period given, using default\n"); } else { virtio_state->period_us = atoi(s); } - V3_Print("Virtio NIC: lower_thresh_pps=%llu, upper_thresh_pps=%llu, period_us=%llu\n", + V3_Print(VM_NONE, VCORE_NONE, "Virtio NIC: lower_thresh_pps=%llu, upper_thresh_pps=%llu, period_us=%llu\n", virtio_state->lower_thresh_pps, virtio_state->upper_thresh_pps, virtio_state->period_us); } else { - PrintError("Virtio NIC: Unknown mode of operation '%s', using default (guest-driven)\n",mode); + PrintError(VM_NONE, VCORE_NONE, "Virtio NIC: Unknown mode of operation '%s', using default (guest-driven)\n",mode); virtio_state->model=GUEST_DRIVEN; } } else { - V3_Print("Virtio NIC: No model given, using default (guest-driven)\n"); + V3_Print(VM_NONE, VCORE_NONE, "Virtio NIC: No model given, using default (guest-driven)\n"); } return 0; @@ -1068,14 +1068,14 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { v3_cfg_tree_t *model = v3_cfg_subtree(cfg,"model"); if (pci_bus == NULL) { - PrintError("Virtio NIC: Virtio device require a PCI Bus"); + PrintError(vm, VCORE_NONE, "Virtio NIC: Virtio device require a PCI Bus"); return -1; } virtio_state = (struct virtio_dev_state *)V3_Malloc(sizeof(struct virtio_dev_state)); if (!virtio_state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -1087,18 +1087,18 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { if (mac) { if (!str2mac(mac, virtio_state->mac)) { - PrintDebug("Virtio NIC: Mac specified %s\n", mac); + PrintDebug(vm, VCORE_NONE, "Virtio NIC: Mac specified %s\n", mac); } else { - PrintError("Virtio NIC: Mac specified is incorrect, picking a randoom mac\n"); + PrintError(vm, VCORE_NONE, "Virtio NIC: Mac specified is incorrect, picking a randoom mac\n"); random_ethaddr(virtio_state->mac); } } else { - PrintDebug("Virtio NIC: no mac specified, so picking a random mac\n"); + PrintDebug(vm, VCORE_NONE, "Virtio NIC: no mac specified, so picking a random mac\n"); random_ethaddr(virtio_state->mac); } if (setup_perf_model(virtio_state,model)<0) { - PrintError("Cannnot setup performance model\n"); + PrintError(vm, VCORE_NONE, "Cannnot setup performance model\n"); V3_Free(virtio_state); return -1; } @@ -1106,13 +1106,13 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, virtio_state); if (dev == NULL) { - PrintError("Virtio NIC: Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Virtio NIC: Could not attach device %s\n", dev_id); V3_Free(virtio_state); return -1; } if (v3_dev_add_net_frontend(vm, dev_id, connect_fn, (void *)virtio_state) == -1) { - PrintError("Virtio NIC: Could not register %s as net frontend\n", dev_id); + PrintError(vm, VCORE_NONE, "Virtio NIC: Could not register %s as net frontend\n", dev_id); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/lnx_virtio_sym.c b/palacios/src/devices/lnx_virtio_sym.c index 33758ef..3fbeffe 100644 --- a/palacios/src/devices/lnx_virtio_sym.c +++ b/palacios/src/devices/lnx_virtio_sym.c @@ -96,7 +96,7 @@ static int handle_kick(struct guest_info * core, struct virtio_sym_state * sym_s return -1; - PrintDebug("VIRTIO Symbiotic KICK: cur_index=%d (mod=%d), avail_index=%d\n", + PrintDebug(core->vm_info, core, "VIRTIO Symbiotic KICK: cur_index=%d (mod=%d), avail_index=%d\n", q->cur_avail_idx, q->cur_avail_idx % QUEUE_SIZE, q->avail->index); while (q->cur_avail_idx < q->avail->index) { @@ -107,31 +107,31 @@ static int handle_kick(struct guest_info * core, struct virtio_sym_state * sym_s uint32_t req_len = 0; - PrintDebug("Descriptor Count=%d, index=%d\n", desc_cnt, q->cur_avail_idx % QUEUE_SIZE); + PrintDebug(core->vm_info, core, "Descriptor Count=%d, index=%d\n", desc_cnt, q->cur_avail_idx % QUEUE_SIZE); for (i = 0; i < desc_cnt; i++) { addr_t page_addr; tmp_desc = &(q->desc[desc_idx]); - PrintDebug("Header Descriptor (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", + PrintDebug(core->vm_info, core, "Header Descriptor (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", tmp_desc, (void *)(addr_t)(tmp_desc->addr_gpa), tmp_desc->length, tmp_desc->flags, tmp_desc->next); if (v3_gpa_to_hva(core, tmp_desc->addr_gpa, (addr_t *)&(page_addr)) == -1) { - PrintError("Could not translate block header address\n"); + PrintError(core->vm_info, core, "Could not translate block header address\n"); return -1; } /* if (handle_sym_op(dev, tmp_desc, buf_desc, status_desc) == -1) { - PrintError("Error handling symbiotic operation\n"); + PrintError(core->vm_info, core, "Error handling symbiotic operation\n"); return -1; } */ - PrintDebug("Symbiotic Device Currently Ignored\n"); + PrintDebug(core->vm_info, core, "Symbiotic Device Currently Ignored\n"); req_len += tmp_desc->length; @@ -146,7 +146,7 @@ static int handle_kick(struct guest_info * core, struct virtio_sym_state * sym_s } if (!(q->avail->flags & VIRTIO_NO_IRQ_FLAG)) { - PrintDebug("Raising IRQ %d\n", sym_state->pci_dev->config_header.intr_line); + PrintDebug(core->vm_info, core, "Raising IRQ %d\n", sym_state->pci_dev->config_header.intr_line); v3_pci_raise_irq(sym_state->pci_bus, sym_state->pci_dev, 0); sym_state->virtio_cfg.pci_isr = VIRTIO_ISR_ACTIVE; } @@ -161,7 +161,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, /* - PrintDebug("VIRTIO SYMBIOTIC Write for port %d (index=%d) len=%d, value=%x\n", + PrintDebug(core->vm_info, core, "VIRTIO SYMBIOTIC Write for port %d (index=%d) len=%d, value=%x\n", port, port_idx, length, *(uint32_t *)src); */ @@ -169,7 +169,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, switch (port_idx) { case GUEST_FEATURES_PORT: if (length != 4) { - PrintError("Illegal write length for guest features\n"); + PrintError(core->vm_info, core, "Illegal write length for guest features\n"); return -1; } @@ -194,32 +194,32 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, sym_state->cur_queue->ring_used_addr = (sym_state->cur_queue->ring_used_addr + 0xfff) & ~0xfff; if (v3_gpa_to_hva(core, sym_state->cur_queue->ring_desc_addr, (addr_t *)&(sym_state->cur_queue->desc)) == -1) { - PrintError("Could not translate ring descriptor address\n"); + PrintError(core->vm_info, core, "Could not translate ring descriptor address\n"); return -1; } if (v3_gpa_to_hva(core, sym_state->cur_queue->ring_avail_addr, (addr_t *)&(sym_state->cur_queue->avail)) == -1) { - PrintError("Could not translate ring available address\n"); + PrintError(core->vm_info, core, "Could not translate ring available address\n"); return -1; } if (v3_gpa_to_hva(core, sym_state->cur_queue->ring_used_addr, (addr_t *)&(sym_state->cur_queue->used)) == -1) { - PrintError("Could not translate ring used address\n"); + PrintError(core->vm_info, core, "Could not translate ring used address\n"); return -1; } - PrintDebug("RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", + PrintDebug(core->vm_info, core, "RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", (void *)(sym_state->cur_queue->ring_desc_addr), (void *)(sym_state->cur_queue->ring_avail_addr), (void *)(sym_state->cur_queue->ring_used_addr)); - PrintDebug("RingDesc=%p, Avail=%p, Used=%p\n", + PrintDebug(core->vm_info, core, "RingDesc=%p, Avail=%p, Used=%p\n", sym_state->cur_queue->desc, sym_state->cur_queue->avail, sym_state->cur_queue->used); } else { - PrintError("Illegal write length for page frame number\n"); + PrintError(core->vm_info, core, "Illegal write length for page frame number\n"); return -1; } break; @@ -227,7 +227,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, sym_state->virtio_cfg.vring_queue_selector = *(uint16_t *)src; if (sym_state->virtio_cfg.vring_queue_selector > 0) { - PrintError("Virtio Symbiotic device has not qeueues. Selected %d\n", + PrintError(core->vm_info, core, "Virtio Symbiotic device has not qeueues. Selected %d\n", sym_state->virtio_cfg.vring_queue_selector); return -1; } @@ -236,9 +236,9 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, break; case VRING_Q_NOTIFY_PORT: - PrintDebug("Handling Kick\n"); + PrintDebug(core->vm_info, core, "Handling Kick\n"); if (handle_kick(core, sym_state) == -1) { - PrintError("Could not handle Symbiotic Notification\n"); + PrintError(core->vm_info, core, "Could not handle Symbiotic Notification\n"); return -1; } break; @@ -246,7 +246,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, sym_state->virtio_cfg.status = *(uint8_t *)src; if (sym_state->virtio_cfg.status == 0) { - PrintDebug("Resetting device\n"); + PrintDebug(core->vm_info, core, "Resetting device\n"); virtio_reset(sym_state); } @@ -270,13 +270,13 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u int port_idx = port % sym_state->io_range_size; /* - PrintDebug("VIRTIO SYMBIOTIC Read for port %d (index =%d), length=%d\n", + PrintDebug(core->vm_info, core, "VIRTIO SYMBIOTIC Read for port %d (index =%d), length=%d\n", port, port_idx, length); */ switch (port_idx) { case HOST_FEATURES_PORT: if (length != 4) { - PrintError("Illegal read length for host features\n"); + PrintError(core->vm_info, core, "Illegal read length for host features\n"); return -1; } @@ -285,7 +285,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u break; case VRING_PG_NUM_PORT: if (length != 4) { - PrintError("Illegal read length for page frame number\n"); + PrintError(core->vm_info, core, "Illegal read length for page frame number\n"); return -1; } @@ -294,7 +294,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u break; case VRING_SIZE_PORT: if (length != 2) { - PrintError("Illegal read length for vring size\n"); + PrintError(core->vm_info, core, "Illegal read length for vring size\n"); return -1; } @@ -304,7 +304,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u case VIRTIO_STATUS_PORT: if (length != 1) { - PrintError("Illegal read length for status\n"); + PrintError(core->vm_info, core, "Illegal read length for status\n"); return -1; } @@ -326,7 +326,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u memcpy(dst, cfg_ptr + cfg_offset, length); } else { - PrintError("Read of Unhandled Virtio Read\n"); + PrintError(core->vm_info, core, "Read of Unhandled Virtio Read\n"); return -1; } @@ -360,10 +360,10 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct pci_device * pci_dev = NULL; char * dev_id = v3_cfg_val(cfg, "ID"); - PrintDebug("Initializing VIRTIO Symbiotic device\n"); + PrintDebug(vm, VCORE_NONE, "Initializing VIRTIO Symbiotic device\n"); if (pci_bus == NULL) { - PrintError("VirtIO devices require a PCI Bus"); + PrintError(vm, VCORE_NONE, "VirtIO devices require a PCI Bus"); return -1; } @@ -371,7 +371,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { virtio_state = (struct virtio_sym_state *)V3_Malloc(sizeof(struct virtio_sym_state)); if (!virtio_state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -381,7 +381,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, virtio_state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(virtio_state); return -1; } @@ -429,7 +429,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { NULL, NULL, NULL, NULL, virtio_state); if (!pci_dev) { - PrintError("Could not register PCI Device\n"); + PrintError(vm, VCORE_NONE, "Could not register PCI Device\n"); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/lnx_virtio_symmod.c b/palacios/src/devices/lnx_virtio_symmod.c index f579f27..d9d9673 100644 --- a/palacios/src/devices/lnx_virtio_symmod.c +++ b/palacios/src/devices/lnx_virtio_symmod.c @@ -138,7 +138,7 @@ static int get_desc_count(struct virtio_queue * q, int index) { static int handle_xfer_kick(struct guest_info * core, struct virtio_sym_state * sym_state) { struct virtio_queue * q = sym_state->cur_queue; - PrintDebug("SYMMOD: VIRTIO SYMMOD Kick on loader queue\n"); + PrintDebug(core->vm_info, core, "SYMMOD: VIRTIO SYMMOD Kick on loader queue\n"); while (q->cur_avail_idx != q->avail->index) { struct vring_desc * cmd_desc = NULL; @@ -154,7 +154,7 @@ static int handle_xfer_kick(struct guest_info * core, struct virtio_sym_state * cmd_desc = &(q->desc[desc_idx]); if (v3_gpa_to_hva(core, cmd_desc->addr_gpa, (addr_t *)&cmd) == -1) { - PrintError("Could not translate SYMMOD header address\n"); + PrintError(core->vm_info, core, "Could not translate SYMMOD header address\n"); return -1; } @@ -168,17 +168,17 @@ static int handle_xfer_kick(struct guest_info * core, struct virtio_sym_state * uint32_t offset = 0; - PrintDebug("Descriptor Count=%d, index=%d\n", desc_cnt, q->cur_avail_idx % QUEUE_SIZE); + PrintDebug(core->vm_info, core, "Descriptor Count=%d, index=%d\n", desc_cnt, q->cur_avail_idx % QUEUE_SIZE); if (desc_cnt < 3) { - PrintError("Symmod loads must include at least 3 descriptors (cnt=%d)\n", desc_cnt); + PrintError(core->vm_info, core, "Symmod loads must include at least 3 descriptors (cnt=%d)\n", desc_cnt); return -1; } name_desc = &(q->desc[desc_idx]); if (v3_gpa_to_hva(core, name_desc->addr_gpa, (addr_t *)&name) == -1) { - PrintError("Could not translate SYMMOD header address\n"); + PrintError(core->vm_info, core, "Could not translate SYMMOD header address\n"); return -1; } @@ -193,16 +193,16 @@ static int handle_xfer_kick(struct guest_info * core, struct virtio_sym_state * buf_desc = &(q->desc[desc_idx]); if (v3_gpa_to_hva(core, buf_desc->addr_gpa, (addr_t *)&(buf)) == -1) { - PrintError("Could not translate buffer address\n"); + PrintError(core->vm_info, core, "Could not translate buffer address\n"); return -1; } memcpy(buf, capsule->start_addr + offset, buf_desc->length); - PrintDebug("Copying module to virtio buffers: SRC=%p, DST=%p, len=%d\n", + PrintDebug(core->vm_info, core, "Copying module to virtio buffers: SRC=%p, DST=%p, len=%d\n", (void *)(capsule->start_addr + offset), (void *)buf, buf_desc->length); if (tmp_status != 0) { - PrintError("Error loading module segment\n"); + PrintError(core->vm_info, core, "Error loading module segment\n"); status = tmp_status; } @@ -212,21 +212,21 @@ static int handle_xfer_kick(struct guest_info * core, struct virtio_sym_state * desc_idx = buf_desc->next; } } else { - PrintError("Invalid SYMMOD Loader command\n"); + PrintError(core->vm_info, core, "Invalid SYMMOD Loader command\n"); return -1; } status_desc = &(q->desc[desc_idx]); if (v3_gpa_to_hva(core, status_desc->addr_gpa, (addr_t *)&status_ptr) == -1) { - PrintError("SYMMOD Error could not translate status address\n"); + PrintError(core->vm_info, core, "SYMMOD Error could not translate status address\n"); return -1; } xfer_len += status_desc->length; *status_ptr = status; - PrintDebug("Transferred %d bytes (xfer_len)\n", xfer_len); + PrintDebug(core->vm_info, core, "Transferred %d bytes (xfer_len)\n", xfer_len); q->used->ring[q->used->index % QUEUE_SIZE].id = q->avail->ring[q->cur_avail_idx % QUEUE_SIZE]; q->used->ring[q->used->index % QUEUE_SIZE].length = xfer_len; // set to total inbound xfer length @@ -237,7 +237,7 @@ static int handle_xfer_kick(struct guest_info * core, struct virtio_sym_state * if (!(q->avail->flags & VIRTIO_NO_IRQ_FLAG)) { - PrintDebug("Raising IRQ %d\n", sym_state->pci_dev->config_header.intr_line); + PrintDebug(core->vm_info, core, "Raising IRQ %d\n", sym_state->pci_dev->config_header.intr_line); v3_pci_raise_irq(sym_state->pci_bus, sym_state->pci_dev, 0); sym_state->virtio_cfg.pci_isr = 1; } @@ -254,7 +254,7 @@ static int handle_notification_kick(struct guest_info * core, struct virtio_sym_ struct virtio_queue * q = &(sym_state->queue[NOTIFY_QUEUE]); struct hashtable_iter * capsule_iter = NULL; - PrintDebug("SYMMOD: VIRTIO SYMMOD Kick on notification queue\n"); + PrintDebug(core->vm_info, core, "SYMMOD: VIRTIO SYMMOD Kick on notification queue\n"); capsule_iter = v3_create_htable_iter(sym_state->symmod_state->capsule_table); @@ -268,7 +268,7 @@ static int handle_notification_kick(struct guest_info * core, struct virtio_sym_ capsule = (struct v3_sym_capsule *)v3_htable_get_iter_value(capsule_iter); - PrintDebug("SYMMOD: Advertising Capsule %s\n", capsule->name); + PrintDebug(core->vm_info, core, "SYMMOD: Advertising Capsule %s\n", capsule->name); if (capsule->type != V3_SYMMOD_LNX) { continue; @@ -277,14 +277,14 @@ static int handle_notification_kick(struct guest_info * core, struct virtio_sym_ if (q->cur_avail_idx == q->avail->index) { - PrintError("Notification Queue Too SMALL\n"); + PrintError(core->vm_info, core, "Notification Queue Too SMALL\n"); return -1; } hdr_desc = &(q->desc[desc_idx]); if (v3_gpa_to_hva(core, hdr_desc->addr_gpa, (addr_t *)&hdr) == -1) { - PrintError("Could not translate SYMMOD header address\n"); + PrintError(core->vm_info, core, "Could not translate SYMMOD header address\n"); return -1; } @@ -306,7 +306,7 @@ static int handle_notification_kick(struct guest_info * core, struct virtio_sym_ if (!(q->avail->flags & VIRTIO_NO_IRQ_FLAG)) { - PrintDebug("Raising IRQ %d\n", sym_state->pci_dev->config_header.intr_line); + PrintDebug(core->vm_info, core, "Raising IRQ %d\n", sym_state->pci_dev->config_header.intr_line); v3_pci_raise_irq(sym_state->pci_bus, sym_state->pci_dev, 0); sym_state->virtio_cfg.pci_isr = 1; } @@ -321,15 +321,15 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, int port_idx = port % sym_state->io_range_size; - PrintDebug("SYMMOD: VIRTIO SYMMOD Write for port %d len=%d, value=%x\n", + PrintDebug(core->vm_info, core, "SYMMOD: VIRTIO SYMMOD Write for port %d len=%d, value=%x\n", port, length, *(uint32_t *)src); - PrintDebug("SYMMOD: port idx=%d\n", port_idx); + PrintDebug(core->vm_info, core, "SYMMOD: port idx=%d\n", port_idx); switch (port_idx) { case GUEST_FEATURES_PORT: if (length != 4) { - PrintError("Illegal write length for guest features\n"); + PrintError(core->vm_info, core, "Illegal write length for guest features\n"); return -1; } @@ -353,32 +353,32 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, sym_state->cur_queue->ring_used_addr = (sym_state->cur_queue->ring_used_addr + 0xfff) & ~0xfff; if (v3_gpa_to_hva(core, sym_state->cur_queue->ring_desc_addr, (addr_t *)&(sym_state->cur_queue->desc)) == -1) { - PrintError("Could not translate ring descriptor address\n"); + PrintError(core->vm_info, core, "Could not translate ring descriptor address\n"); return -1; } if (v3_gpa_to_hva(core, sym_state->cur_queue->ring_avail_addr, (addr_t *)&(sym_state->cur_queue->avail)) == -1) { - PrintError("Could not translate ring available address\n"); + PrintError(core->vm_info, core, "Could not translate ring available address\n"); return -1; } if (v3_gpa_to_hva(core, sym_state->cur_queue->ring_used_addr, (addr_t *)&(sym_state->cur_queue->used)) == -1) { - PrintError("Could not translate ring used address\n"); + PrintError(core->vm_info, core, "Could not translate ring used address\n"); return -1; } - PrintDebug("SYMMOD: RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", + PrintDebug(core->vm_info, core, "SYMMOD: RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", (void *)(sym_state->cur_queue->ring_desc_addr), (void *)(sym_state->cur_queue->ring_avail_addr), (void *)(sym_state->cur_queue->ring_used_addr)); - PrintDebug("SYMMOD: RingDesc=%p, Avail=%p, Used=%p\n", + PrintDebug(core->vm_info, core, "SYMMOD: RingDesc=%p, Avail=%p, Used=%p\n", sym_state->cur_queue->desc, sym_state->cur_queue->avail, sym_state->cur_queue->used); } else { - PrintError("Illegal write length for page frame number\n"); + PrintError(core->vm_info, core, "Illegal write length for page frame number\n"); return -1; } break; @@ -386,7 +386,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, sym_state->virtio_cfg.vring_queue_selector = *(uint16_t *)src; if (sym_state->virtio_cfg.vring_queue_selector > NUM_QUEUES) { - PrintError("Virtio Symbiotic device has no qeueues. Selected %d\n", + PrintError(core->vm_info, core, "Virtio Symbiotic device has no qeueues. Selected %d\n", sym_state->virtio_cfg.vring_queue_selector); return -1; } @@ -397,11 +397,11 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, case VRING_Q_NOTIFY_PORT: { uint16_t queue_idx = *(uint16_t *)src; - PrintDebug("SYMMOD: Handling Kick\n"); + PrintDebug(core->vm_info, core, "SYMMOD: Handling Kick\n"); if (queue_idx == 0) { if (handle_notification_kick(core, sym_state) == -1) { - PrintError("Could not handle Notification Kick\n"); + PrintError(core->vm_info, core, "Could not handle Notification Kick\n"); return -1; } @@ -409,11 +409,11 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, } else if (queue_idx == 1) { if (handle_xfer_kick(core, sym_state) == -1) { - PrintError("Could not handle Symbiotic Notification\n"); + PrintError(core->vm_info, core, "Could not handle Symbiotic Notification\n"); return -1; } } else { - PrintError("Kick on invalid queue (%d)\n", queue_idx); + PrintError(core->vm_info, core, "Kick on invalid queue (%d)\n", queue_idx); return -1; } @@ -423,7 +423,7 @@ static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, sym_state->virtio_cfg.status = *(uint8_t *)src; if (sym_state->virtio_cfg.status == 0) { - PrintDebug("SYMMOD: Resetting device\n"); + PrintDebug(core->vm_info, core, "SYMMOD: Resetting device\n"); virtio_reset(sym_state); } @@ -447,13 +447,13 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u int port_idx = port % sym_state->io_range_size; /* - PrintDebug("SYMMOD: VIRTIO SYMBIOTIC Read for port %d (index =%d), length=%d\n", + PrintDebug(core->vm_info, core, "SYMMOD: VIRTIO SYMBIOTIC Read for port %d (index =%d), length=%d\n", port, port_idx, length); */ switch (port_idx) { case HOST_FEATURES_PORT: if (length != 4) { - PrintError("Illegal read length for host features\n"); + PrintError(core->vm_info, core, "Illegal read length for host features\n"); return -1; } @@ -462,7 +462,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u break; case VRING_PG_NUM_PORT: if (length != 4) { - PrintError("Illegal read length for page frame number\n"); + PrintError(core->vm_info, core, "Illegal read length for page frame number\n"); return -1; } @@ -471,7 +471,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u break; case VRING_SIZE_PORT: if (length != 2) { - PrintError("Illegal read length for vring size\n"); + PrintError(core->vm_info, core, "Illegal read length for vring size\n"); return -1; } @@ -481,7 +481,7 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u case VIRTIO_STATUS_PORT: if (length != 1) { - PrintError("Illegal read length for status\n"); + PrintError(core->vm_info, core, "Illegal read length for status\n"); return -1; } @@ -502,10 +502,10 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u memcpy(dst, cfg_ptr + cfg_offset, length); - V3_Print("Reading SymConfig at idx %d (val=%x)\n", cfg_offset, *(uint32_t *)cfg_ptr); + V3_Print(core->vm_info, core, "Reading SymConfig at idx %d (val=%x)\n", cfg_offset, *(uint32_t *)cfg_ptr); } else { - PrintError("Read of Unhandled Virtio Read\n"); + PrintError(core->vm_info, core, "Read of Unhandled Virtio Read\n"); return -1; } @@ -525,15 +525,15 @@ static int virtio_load_capsule(struct v3_vm_info * vm, struct v3_sym_capsule * m if (strlen(mod->name) >= 32) { - PrintError("Capsule name is too long... (%d bytes) limit is 32\n", (uint32_t)strlen(mod->name)); + PrintError(vm, VCORE_NONE, "Capsule name is too long... (%d bytes) limit is 32\n", (uint32_t)strlen(mod->name)); return -1; } - PrintDebug("SYMMOD: VIRTIO SYMMOD Loader: Loading Capsule (size=%d)\n", mod->size); + PrintDebug(vm, VCORE_NONE, "SYMMOD: VIRTIO SYMMOD Loader: Loading Capsule (size=%d)\n", mod->size); //queue is not set yet if (q->ring_avail_addr == 0) { - PrintError("Queue is not set\n"); + PrintError(vm, VCORE_NONE, "Queue is not set\n"); return -1; } @@ -543,17 +543,17 @@ static int virtio_load_capsule(struct v3_vm_info * vm, struct v3_sym_capsule * m struct symmod_hdr * notifier = NULL; struct vring_desc * notifier_desc = NULL; - PrintDebug("SYMMOD: Descriptor index=%d\n", q->cur_avail_idx % q->queue_size); + PrintDebug(vm, VCORE_NONE, "SYMMOD: Descriptor index=%d\n", q->cur_avail_idx % q->queue_size); notifier_desc = &(q->desc[notifier_idx]); - PrintDebug("SYMMOD: Notifier Descriptor (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", + PrintDebug(vm, VCORE_NONE, "SYMMOD: Notifier Descriptor (ptr=%p) gpa=%p, len=%d, flags=%x, next=%d\n", notifier_desc, (void *)(addr_t)(notifier_desc->addr_gpa), notifier_desc->length, notifier_desc->flags, notifier_desc->next); if (v3_gpa_to_hva(&(vm->cores[0]), notifier_desc->addr_gpa, (addr_t *)&(notifier)) == -1) { - PrintError("Could not translate receive buffer address\n"); + PrintError(vm, VCORE_NONE, "Could not translate receive buffer address\n"); return -1; } @@ -578,7 +578,7 @@ static int virtio_load_capsule(struct v3_vm_info * vm, struct v3_sym_capsule * m } if (!(q->avail->flags & VIRTIO_NO_IRQ_FLAG)) { - PrintDebug("SYMMOD: Raising IRQ %d\n", virtio->pci_dev->config_header.intr_line); + PrintDebug(vm, VCORE_NONE, "SYMMOD: Raising IRQ %d\n", virtio->pci_dev->config_header.intr_line); v3_pci_raise_irq(virtio->pci_bus, virtio->pci_dev, 0); virtio->virtio_cfg.pci_isr = 0x1; } @@ -614,17 +614,17 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct pci_device * pci_dev = NULL; char * dev_id = v3_cfg_val(cfg, "ID"); - PrintDebug("SYMMOD: Initializing VIRTIO Symbiotic Module device\n"); + PrintDebug(vm, VCORE_NONE, "SYMMOD: Initializing VIRTIO Symbiotic Module device\n"); if (pci_bus == NULL) { - PrintError("VirtIO devices require a PCI Bus"); + PrintError(vm, VCORE_NONE, "VirtIO devices require a PCI Bus"); return -1; } virtio_state = (struct virtio_sym_state *)V3_Malloc(sizeof(struct virtio_sym_state)); if (!virtio_state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -639,7 +639,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, virtio_state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(virtio_state); return -1; } @@ -686,7 +686,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { NULL, NULL, NULL, NULL, virtio_state); if (!pci_dev) { - PrintError("Could not register PCI Device\n"); + PrintError(vm, VCORE_NONE, "Could not register PCI Device\n"); v3_remove_device(dev); return -1; } @@ -712,7 +712,7 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { } - V3_Print("SYMMOD: %d available sym modules\n", virtio_state->sym_cfg.avail_mods); + V3_Print(vm, VCORE_NONE, "SYMMOD: %d available sym modules\n", virtio_state->sym_cfg.avail_mods); virtio_reset(virtio_state); diff --git a/palacios/src/devices/lnx_virtio_vnet.c b/palacios/src/devices/lnx_virtio_vnet.c index f7795f5..eb889ed 100644 --- a/palacios/src/devices/lnx_virtio_vnet.c +++ b/palacios/src/devices/lnx_virtio_vnet.c @@ -126,7 +126,7 @@ static int handle_cmd_kick(struct guest_info * core, struct virtio_vnet_state * vnet_state) { struct virtio_queue * q = &(vnet_state->queue[0]); - PrintDebug("VNET Bridge: Handling command queue\n"); + PrintDebug(core->vm_info, core, "VNET Bridge: Handling command queue\n"); while (q->cur_avail_idx != q->avail->index) { struct vring_desc * hdr_desc = NULL; @@ -140,17 +140,17 @@ static int handle_cmd_kick(struct guest_info * core, uint8_t * status_ptr = NULL; uint8_t status = 0; - PrintDebug("VNET Bridge: CMD: Descriptor Count=%d, index=%d, desc_idx=%d\n", desc_cnt, q->cur_avail_idx % QUEUE_SIZE, desc_idx); + PrintDebug(core->vm_info, core, "VNET Bridge: CMD: Descriptor Count=%d, index=%d, desc_idx=%d\n", desc_cnt, q->cur_avail_idx % QUEUE_SIZE, desc_idx); if (desc_cnt < 3) { - PrintError("VNET Bridge cmd must include at least 3 descriptors (cnt=%d)\n", desc_cnt); + PrintError(core->vm_info, core, "VNET Bridge cmd must include at least 3 descriptors (cnt=%d)\n", desc_cnt); return -1; } hdr_desc = &(q->desc[desc_idx]); if (v3_gpa_to_hva(core, hdr_desc->addr_gpa, (addr_t *)&hdr) == -1) { - PrintError("Could not translate VirtioVNET header address\n"); + PrintError(core->vm_info, core, "Could not translate VirtioVNET header address\n"); return -1; } @@ -164,18 +164,18 @@ static int handle_cmd_kick(struct guest_info * core, buf_desc = &(q->desc[desc_idx]); if (v3_gpa_to_hva(core, buf_desc->addr_gpa, (addr_t *)&(route)) == -1) { - PrintError("Could not translate route address\n"); + PrintError(core->vm_info, core, "Could not translate route address\n"); return -1; } tmp_status = v3_vnet_add_route(*route); if (tmp_status != 0) { - PrintError("Error adding VNET ROUTE\n"); + PrintError(core->vm_info, core, "Error adding VNET ROUTE\n"); status = tmp_status; } - PrintDebug("VNET Route Added\n"); + PrintDebug(core->vm_info, core, "VNET Route Added\n"); xfer_len += buf_desc->length; desc_idx = buf_desc->next; @@ -186,14 +186,14 @@ static int handle_cmd_kick(struct guest_info * core, status_desc = &(q->desc[desc_idx]); if (v3_gpa_to_hva(core, status_desc->addr_gpa, (addr_t *)&status_ptr) == -1) { - PrintError("VirtioVNET Error could not translate status address\n"); + PrintError(core->vm_info, core, "VirtioVNET Error could not translate status address\n"); return -1; } xfer_len += status_desc->length; *status_ptr = status; - PrintDebug("Transferred %d bytes (xfer_len)\n", xfer_len); + PrintDebug(core->vm_info, core, "Transferred %d bytes (xfer_len)\n", xfer_len); q->used->ring[q->used->index % QUEUE_SIZE].id = q->avail->ring[q->cur_avail_idx % QUEUE_SIZE]; q->used->ring[q->used->index % QUEUE_SIZE].length = xfer_len; // set to total inbound xfer length @@ -203,7 +203,7 @@ static int handle_cmd_kick(struct guest_info * core, if (!(q->avail->flags & VIRTIO_NO_IRQ_FLAG)) { - PrintDebug("Raising IRQ %d\n", vnet_state->pci_dev->config_header.intr_line); + PrintDebug(core->vm_info, core, "Raising IRQ %d\n", vnet_state->pci_dev->config_header.intr_line); v3_pci_raise_irq(vnet_state->pci_bus, vnet_state->pci_dev, 0); vnet_state->virtio_cfg.pci_isr = 1; } @@ -224,7 +224,7 @@ static int vnet_pkt_input_cb(struct v3_vm_info * vm, flags = v3_lock_irqsave(vnet_state->lock); if (q->ring_avail_addr == 0) { - PrintError("Queue is not set\n"); + PrintError(vm, VCORE_NONE, "Queue is not set\n"); goto exit; } @@ -237,11 +237,11 @@ static int vnet_pkt_input_cb(struct v3_vm_info * vm, pkt_desc = &(q->desc[pkt_idx]); if (v3_gpa_to_hva(&(vm->cores[0]), pkt_desc->addr_gpa, (addr_t *)&(virtio_pkt)) == -1) { - PrintError("Could not translate buffer address\n"); + PrintError(vm, VCORE_NONE, "Could not translate buffer address\n"); goto exit; } - PrintDebug("VNET Bridge: RX: pkt sent to guest pkt size: %d, dst link: %d\n", pkt->size, pkt->dst_id); + PrintDebug(vm, VCORE_NONE, "VNET Bridge: RX: pkt sent to guest pkt size: %d, dst link: %d\n", pkt->size, pkt->dst_id); // Fill in dst packet buffer virtio_pkt->link_id = pkt->dst_id; @@ -260,7 +260,7 @@ static int vnet_pkt_input_cb(struct v3_vm_info * vm, if (!(q->avail->flags & VIRTIO_NO_IRQ_FLAG)) { v3_pci_raise_irq(vnet_state->pci_bus, vnet_state->pci_dev, 0); vnet_state->virtio_cfg.pci_isr = 0x1; - PrintDebug("Raising IRQ %d\n", vnet_state->pci_dev->config_header.intr_line); + PrintDebug(vm, VCORE_NONE, "Raising IRQ %d\n", vnet_state->pci_dev->config_header.intr_line); } ret_val = 0; @@ -290,11 +290,11 @@ static int do_tx_pkts(struct guest_info * core, pkt_desc = &(q->desc[desc_idx]); if (v3_gpa_to_hva(core, pkt_desc->addr_gpa, (addr_t *)&(virtio_pkt)) == -1) { - PrintError("Could not translate buffer address\n"); + PrintError(core->vm_info, core, "Could not translate buffer address\n"); return -1; } - //PrintDebug("VNET Bridge: TX: on cpu %d pkt size: %d, dst link: %d\n", cpu, virtio_pkt->pkt_size, virtio_pkt->link_id); + //PrintDebug(core->vm_info, core, "VNET Bridge: TX: on cpu %d pkt size: %d, dst link: %d\n", cpu, virtio_pkt->pkt_size, virtio_pkt->link_id); struct v3_vnet_pkt pkt; pkt.size = virtio_pkt->pkt_size; @@ -347,14 +347,14 @@ static int vnet_virtio_io_write(struct guest_info * core, struct virtio_vnet_state * vnet_state = (struct virtio_vnet_state *)private_data; int port_idx = port % vnet_state->io_range_size; - PrintDebug("VNET Bridge: VIRTIO VNET Write for port %d len=%d, value=%x\n", + PrintDebug(core->vm_info, core, "VNET Bridge: VIRTIO VNET Write for port %d len=%d, value=%x\n", port, length, *(uint32_t *)src); vnet_state->total_exit ++; switch (port_idx) { case GUEST_FEATURES_PORT: if (length != 4) { - PrintError("Illegal write length for guest features\n"); + PrintError(core->vm_info, core, "Illegal write length for guest features\n"); return -1; } vnet_state->virtio_cfg.guest_features = *(uint32_t *)src; @@ -377,26 +377,26 @@ static int vnet_virtio_io_write(struct guest_info * core, vnet_state->cur_queue->ring_used_addr = (vnet_state->cur_queue->ring_used_addr + 0xfff) & ~0xfff; if (v3_gpa_to_hva(core, vnet_state->cur_queue->ring_desc_addr, (addr_t *)&(vnet_state->cur_queue->desc)) == -1) { - PrintError("Could not translate ring descriptor address\n"); + PrintError(core->vm_info, core, "Could not translate ring descriptor address\n"); return -1; } if (v3_gpa_to_hva(core, vnet_state->cur_queue->ring_avail_addr, (addr_t *)&(vnet_state->cur_queue->avail)) == -1) { - PrintError("Could not translate ring available address\n"); + PrintError(core->vm_info, core, "Could not translate ring available address\n"); return -1; } if (v3_gpa_to_hva(core, vnet_state->cur_queue->ring_used_addr, (addr_t *)&(vnet_state->cur_queue->used)) == -1) { - PrintError("Could not translate ring used address\n"); + PrintError(core->vm_info, core, "Could not translate ring used address\n"); return -1; } - PrintDebug("VNET Bridge: RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", + PrintDebug(core->vm_info, core, "VNET Bridge: RingDesc_addr=%p, Avail_addr=%p, Used_addr=%p\n", (void *)(vnet_state->cur_queue->ring_desc_addr), (void *)(vnet_state->cur_queue->ring_avail_addr), (void *)(vnet_state->cur_queue->ring_used_addr)); - PrintDebug("VNET Bridge: RingDesc=%p, Avail=%p, Used=%p\n", + PrintDebug(core->vm_info, core, "VNET Bridge: RingDesc=%p, Avail=%p, Used=%p\n", vnet_state->cur_queue->desc, vnet_state->cur_queue->avail, vnet_state->cur_queue->used); if(vnet_state->queue[RECV_QUEUE].avail != NULL){ @@ -410,7 +410,7 @@ static int vnet_virtio_io_write(struct guest_info * core, vnet_state->queue[XMIT_QUEUE].used->flags |= VRING_NO_NOTIFY_FLAG; } } else { - PrintError("Illegal write length for page frame number\n"); + PrintError(core->vm_info, core, "Illegal write length for page frame number\n"); return -1; } break; @@ -418,7 +418,7 @@ static int vnet_virtio_io_write(struct guest_info * core, vnet_state->virtio_cfg.vring_queue_selector = *(uint16_t *)src; if (vnet_state->virtio_cfg.vring_queue_selector > NUM_QUEUES) { - PrintError("VNET Bridge device has no qeueues. Selected %d\n", + PrintError(core->vm_info, core, "VNET Bridge device has no qeueues. Selected %d\n", vnet_state->virtio_cfg.vring_queue_selector); return -1; } @@ -429,27 +429,27 @@ static int vnet_virtio_io_write(struct guest_info * core, case VRING_Q_NOTIFY_PORT: { uint16_t queue_idx = *(uint16_t *)src; - PrintDebug("VNET Bridge: Handling Kick\n"); + PrintDebug(core->vm_info, core, "VNET Bridge: Handling Kick\n"); if (queue_idx == 0) { if (handle_cmd_kick(core, vnet_state) == -1) { - PrintError("Could not handle Virtio VNET Control command\n"); + PrintError(core->vm_info, core, "Could not handle Virtio VNET Control command\n"); return -1; } } else if (queue_idx == 1) { if (do_tx_pkts(core, vnet_state) == -1){ - PrintError("Could not handle Virtio VNET TX\n"); + PrintError(core->vm_info, core, "Could not handle Virtio VNET TX\n"); return -1; } - PrintError("Notify on TX\n"); + PrintError(core->vm_info, core, "Notify on TX\n"); } else if (queue_idx == 2) { if (handle_rx_queue_kick(core, vnet_state) == -1){ - PrintError("Could not handle Virtio RX buffer refills Kick\n"); + PrintError(core->vm_info, core, "Could not handle Virtio RX buffer refills Kick\n"); return -1; } vnet_state->rx_exit ++; } else { - PrintError("VNET Bridge: Kick on invalid queue (%d)\n", queue_idx); + PrintError(core->vm_info, core, "VNET Bridge: Kick on invalid queue (%d)\n", queue_idx); return -1; } @@ -459,7 +459,7 @@ static int vnet_virtio_io_write(struct guest_info * core, vnet_state->virtio_cfg.status = *(uint8_t *)src; if (vnet_state->virtio_cfg.status == 0) { - PrintDebug("VNET Bridge: Resetting device\n"); + PrintDebug(core->vm_info, core, "VNET Bridge: Resetting device\n"); virtio_reset(vnet_state); } @@ -487,7 +487,7 @@ static int vnet_virtio_io_read(struct guest_info * core, switch (port_idx) { case HOST_FEATURES_PORT: if (length != 4) { - PrintError("Illegal read length for host features\n"); + PrintError(core->vm_info, core, "Illegal read length for host features\n"); return -1; } @@ -496,7 +496,7 @@ static int vnet_virtio_io_read(struct guest_info * core, break; case VRING_PG_NUM_PORT: if (length != 4) { - PrintError("Illegal read length for page frame number\n"); + PrintError(core->vm_info, core, "Illegal read length for page frame number\n"); return -1; } @@ -505,7 +505,7 @@ static int vnet_virtio_io_read(struct guest_info * core, break; case VRING_SIZE_PORT: if (length != 2) { - PrintError("Illegal read length for vring size\n"); + PrintError(core->vm_info, core, "Illegal read length for vring size\n"); return -1; } @@ -515,7 +515,7 @@ static int vnet_virtio_io_read(struct guest_info * core, case VIRTIO_STATUS_PORT: if (length != 1) { - PrintError("Illegal read length for status\n"); + PrintError(core->vm_info, core, "Illegal read length for status\n"); return -1; } @@ -537,7 +537,7 @@ static int vnet_virtio_io_read(struct guest_info * core, memcpy(dst, cfg_ptr + cfg_offset, length); } else { - PrintError("Read of Unhandled Virtio Read\n"); + PrintError(core->vm_info, core, "Read of Unhandled Virtio Read\n"); return -1; } @@ -567,17 +567,17 @@ static int dev_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct pci_device * pci_dev = NULL; char * name = v3_cfg_val(cfg, "name"); - PrintDebug("VNET Bridge: Initializing VNET Bridge Control device: %s\n", name); + PrintDebug(vm, VCORE_NONE, "VNET Bridge: Initializing VNET Bridge Control device: %s\n", name); if (pci_bus == NULL) { - PrintError("VNET Bridge device require a PCI Bus"); + PrintError(vm, VCORE_NONE, "VNET Bridge device require a PCI Bus"); return -1; } vnet_state = (struct virtio_vnet_state *)V3_Malloc(sizeof(struct virtio_vnet_state)); if (!vnet_state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -588,7 +588,7 @@ static int dev_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, name, &dev_ops, vnet_state); if (dev == NULL) { - PrintError("Could not attach device %s\n", name); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", name); V3_Free(vnet_state); return -1; } @@ -632,7 +632,7 @@ static int dev_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { NULL, NULL, NULL, NULL, vnet_state); if (!pci_dev) { - PrintError("Could not register PCI Device\n"); + PrintError(vm, VCORE_NONE, "Could not register PCI Device\n"); v3_remove_device(dev); return -1; } @@ -657,7 +657,7 @@ static int dev_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { brg_ops.input = vnet_pkt_input_cb; brg_ops.poll = vnet_virtio_poll; - V3_Print("Registering Virtio device as vnet bridge\n"); + V3_Print(vm, VCORE_NONE, "Registering Virtio device as vnet bridge\n"); v3_vnet_add_bridge(vm, &brg_ops, CTL_VM_BRIDGE, (void *)vnet_state); diff --git a/palacios/src/devices/mptable.c b/palacios/src/devices/mptable.c index 2dbb8ac..c4cdc42 100644 --- a/palacios/src/devices/mptable.c +++ b/palacios/src/devices/mptable.c @@ -466,7 +466,7 @@ static int write_mptable(void * target, uint32_t numcores, int have_ioapic, int cur += sizeof(struct mp_table_io_interrupt_assignment); - //V3_Print("PCI0, slot %d, irq %d maps to irq %d\n",slot,intr,dst_irq); + //V3_Print(VM_NONE, VCORE_NONE, "PCI0, slot %d, irq %d maps to irq %d\n",slot,intr,dst_irq); } } } @@ -475,7 +475,7 @@ static int write_mptable(void * target, uint32_t numcores, int have_ioapic, int header->base_table_length = (cur - (uint8_t *)header); - V3_Print("MPtable size: %u\n",header->base_table_length); + V3_Print(VM_NONE, VCORE_NONE, "MPtable size: %u\n",header->base_table_length); // checksum calculation header->checksum = 0; @@ -519,53 +519,53 @@ static int mptable_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { int have_ioapic = find_first_peer_device_of_class(cfg,"ioapic")!=NULL; if (!have_apic) { - PrintError("Attempt to instantiate MPTABLE but machine has no apics!\n"); + PrintError(vm, VCORE_NONE, "Attempt to instantiate MPTABLE but machine has no apics!\n"); return -1; } if (!have_ioapic) { - PrintError("Attempt to instantiate MPTABLE without ioapic - will try, but this won't end well\n"); + PrintError(vm, VCORE_NONE, "Attempt to instantiate MPTABLE without ioapic - will try, but this won't end well\n"); } if (have_pci && (!have_piix3 || !have_ioapic)) { - PrintError("Attempt to instantiate MPTABLE with a PCI Bus, but without either a piix3 or an ioapic\n"); + PrintError(vm, VCORE_NONE, "Attempt to instantiate MPTABLE with a PCI Bus, but without either a piix3 or an ioapic\n"); return -1; } if (v3_gpa_to_hva(&(vm->cores[0]), BIOS_MP_TABLE_DEFAULT_LOCATION, (addr_t *)&target) == -1) { - PrintError("Cannot inject mptable due to unmapped bios!\n"); + PrintError(vm, VCORE_NONE, "Cannot inject mptable due to unmapped bios!\n"); return -1; } if (!check_for_cookie(target)) { - PrintError("Cookie mismatch in writing mptable, aborting (probably wrong guest BIOS).\n"); + PrintError(vm, VCORE_NONE, "Cookie mismatch in writing mptable, aborting (probably wrong guest BIOS).\n"); return -1; } if (vm->num_cores > 32) { - PrintError("No support for >32 cores in writing MP table, aborting.\n"); + PrintError(vm, VCORE_NONE, "No support for >32 cores in writing MP table, aborting.\n"); return -1; } - V3_Print("Constructing mptable for %u cores at %p\n", vm->num_cores, target); + V3_Print(vm, VCORE_NONE, "Constructing mptable for %u cores at %p\n", vm->num_cores, target); if (write_pointer(target, BIOS_MP_TABLE_DEFAULT_LOCATION + sizeof(struct mp_floating_pointer)) == -1) { - PrintError("Unable to write mptable floating pointer, aborting.\n"); + PrintError(vm, VCORE_NONE, "Unable to write mptable floating pointer, aborting.\n"); return -1; } if (!check_pointer(target)) { - PrintError("Failed to inject mptable floating pointer correctly --- checksum fails\n"); + PrintError(vm, VCORE_NONE, "Failed to inject mptable floating pointer correctly --- checksum fails\n"); return -1; } if (write_mptable(target + sizeof(struct mp_floating_pointer), vm->num_cores, have_ioapic, have_pci)) { - PrintError("Cannot inject mptable configuration header and entries\n"); + PrintError(vm, VCORE_NONE, "Cannot inject mptable configuration header and entries\n"); return -1; } if (!check_table(target + sizeof(struct mp_floating_pointer))) { - PrintError("Failed to inject mptable configuration header and entries correctly --- checksum fails\n"); + PrintError(vm, VCORE_NONE, "Failed to inject mptable configuration header and entries correctly --- checksum fails\n"); return -1; } diff --git a/palacios/src/devices/ne2k.c b/palacios/src/devices/ne2k.c index 420bc79..413ec24 100644 --- a/palacios/src/devices/ne2k.c +++ b/palacios/src/devices/ne2k.c @@ -339,7 +339,7 @@ static int ne2k_update_irq(struct ne2k_state * nic_state) { nic_state->statistics.rx_interrupts ++; - PrintDebug("NE2000: Raise IRQ\n"); + PrintDebug(VM_NONE, VCORE_NONE, "NE2000: Raise IRQ\n"); } return 0; @@ -348,7 +348,7 @@ static int ne2k_update_irq(struct ne2k_state * nic_state) { static int tx_one_pkt(struct ne2k_state * nic_state, uchar_t *pkt, uint32_t length) { #ifdef V3_CONFIG_DEBUG_NE2K - PrintDebug("NE2000: Send Packet:\n"); + PrintDebug(VM_NONE, VCORE_NONE, "NE2000: Send Packet:\n"); v3_hexdump(pkt, length, NULL, 0); #endif @@ -408,7 +408,7 @@ static int rx_one_pkt(struct ne2k_state * nic_state, const uchar_t * pkt, uint3 } if (ne2k_rxbuf_full(regs)) { - PrintError("Ne2k: received buffer overflow\n"); + PrintError(VM_NONE, VCORE_NONE, "Ne2k: received buffer overflow\n"); return -1; } @@ -485,7 +485,7 @@ static int ne2k_rx(uint8_t * buf, uint32_t size, void * private_data){ struct ne2k_state * nic_state = (struct ne2k_state *)private_data; #ifdef V3_CONFIG_DEBUG_NE2K - PrintDebug("\nNe2k: Packet Received:\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\nNe2k: Packet Received:\n"); v3_hexdump(buf, size, NULL, 0); #endif @@ -604,14 +604,14 @@ static int ne2k_data_read(struct guest_info * core, val = mem_readl(nic_state, addr); break; default: - PrintError("ne2k_data_read error: invalid length %d\n", length); + PrintError(VM_NONE, VCORE_NONE, "ne2k_data_read error: invalid length %d\n", length); val = 0x0; } dma_update(nic_state, length); memcpy(dst, &val, length); - PrintDebug("NE2000 read: port:0x%x (%u bytes): 0x%x", port & 0x1f, length, val); + PrintDebug(VM_NONE, VCORE_NONE, "NE2000 read: port:0x%x (%u bytes): 0x%x", port & 0x1f, length, val); return length; } @@ -644,12 +644,12 @@ static int ne2k_data_write(struct guest_info * core, mem_writel(nic_state, addr, val); break; default: - PrintError("NE2000 port write error: invalid length %d\n", length); + PrintError(VM_NONE, VCORE_NONE, "NE2000 port write error: invalid length %d\n", length); } dma_update(nic_state, length); - PrintDebug("NE2000: Write port:0x%x (%u bytes): 0x%x\n", port & 0x1f, length, val); + PrintDebug(VM_NONE, VCORE_NONE, "NE2000: Write port:0x%x (%u bytes): 0x%x\n", port & 0x1f, length, val); return length; } @@ -675,7 +675,7 @@ static void ne2k_init_state(struct ne2k_state * nic_state) { static int reset_device(struct ne2k_state * nic_state) { ne2k_init_state(nic_state); - PrintDebug("NE2000: Reset device\n"); + PrintDebug(VM_NONE, VCORE_NONE, "NE2000: Reset device\n"); return 0; } @@ -714,7 +714,7 @@ static int ne2k_cmd_write(struct guest_info * core, struct ne2k_registers * regs = (struct ne2k_registers *)&(nic_state->context); if (length != 1) { - PrintError("Invalid write length to NE2000 Command register\n"); + PrintError(core->vm_info, core, "Invalid write length to NE2000 Command register\n"); return -1; } @@ -763,13 +763,13 @@ static int ne2k_cmd_read(struct guest_info * core, struct ne2k_state * nic_state = (struct ne2k_state *)private_data; if (length != 1) { - PrintError("Invalid read length to NE2000 Command register\n"); + PrintError(core->vm_info, core, "Invalid read length to NE2000 Command register\n"); return -1; } *(uint8_t *)dst = nic_state->context.cmd.val; - PrintDebug("ne2k_read: port:0x%x val: 0x%x\n", port, *(uint8_t *)dst); + PrintDebug(core->vm_info, core, "ne2k_read: port:0x%x val: 0x%x\n", port, *(uint8_t *)dst); return length; } @@ -784,13 +784,13 @@ static int ne2k_std_write(struct guest_info * core, uint8_t page = regs->cmd.pg_sel; if (length != 1){ - PrintError("NE2000 port write error: length %d port 0x%xnot equal to 1\n", length, port); + PrintError(core->vm_info, core, "NE2000 port write error: length %d port 0x%xnot equal to 1\n", length, port); return -1; } uint8_t val = *(uint8_t *)src; - PrintDebug("NE2000: write port:0x%x val: 0x%x\n", port, (uint8_t)val); + PrintDebug(core->vm_info, core, "NE2000: write port:0x%x val: 0x%x\n", port, (uint8_t)val); if (page == 0) { switch (idx) { @@ -843,7 +843,7 @@ static int ne2k_std_write(struct guest_info * core, break; default: - PrintError("NE2000 port write error: invalid port:0x%x\n", port); + PrintError(core->vm_info, core, "NE2000 port write error: invalid port:0x%x\n", port); return -1; } } else if (page == 1) { @@ -859,7 +859,7 @@ static int ne2k_std_write(struct guest_info * core, break; default: - PrintError("NE2000 write port error: invalid port:0x%x\n", port); + PrintError(core->vm_info, core, "NE2000 write port error: invalid port:0x%x\n", port); return -1; } } else if (page == 2) { @@ -884,11 +884,11 @@ static int ne2k_std_write(struct guest_info * core, break; default: - PrintError("NE2000 write port error: invalid port:0x%x\n", port); + PrintError(core->vm_info, core, "NE2000 write port error: invalid port:0x%x\n", port); return -1; } } else { - PrintError("NE2000: Invalid Register Page Value\n"); + PrintError(core->vm_info, core, "NE2000: Invalid Register Page Value\n"); return -1; } @@ -908,7 +908,7 @@ static int ne2k_std_read(struct guest_info * core, uint8_t page = regs->cmd.pg_sel; if (length > 1) { - PrintError("ne2k_read error: length %d\n", length); + PrintError(core->vm_info, core, "ne2k_read error: length %d\n", length); return length; } @@ -956,7 +956,7 @@ static int ne2k_std_read(struct guest_info * core, break; default: - PrintError("NE2000 port read error: invalid port:0x%x\n", port); + PrintError(core->vm_info, core, "NE2000 port read error: invalid port:0x%x\n", port); return -1; } } else if (page == 1) { @@ -972,7 +972,7 @@ static int ne2k_std_read(struct guest_info * core, break; default: - PrintError("ne2k_read error: invalid port:0x%x\n", port); + PrintError(core->vm_info, core, "ne2k_read error: invalid port:0x%x\n", port); return -1; } } else if (page == 2) { @@ -1011,15 +1011,15 @@ static int ne2k_std_read(struct guest_info * core, *(uint8_t *)dst = regs->imr.val; break; default: - PrintError("NE2000 port read error: invalid port:0x%x\n", port); + PrintError(core->vm_info, core, "NE2000 port read error: invalid port:0x%x\n", port); return -1; } } else { - PrintError("NE2000 port read: Invalid Register Page Value\n"); + PrintError(core->vm_info, core, "NE2000 port read: Invalid Register Page Value\n"); return -1; } - PrintDebug("NE2000 port read: port:0x%x val: 0x%x\n", port, *(uint8_t *)dst); + PrintDebug(core->vm_info, core, "NE2000 port read: port:0x%x val: 0x%x\n", port, *(uint8_t *)dst); return length; } @@ -1049,7 +1049,7 @@ static int ne2k_pci_write(struct guest_info * core, break; default: - PrintError("NE2000 port write error: invalid port:0x%x\n", port); + PrintError(core->vm_info, core, "NE2000 port write error: invalid port:0x%x\n", port); return -1; } @@ -1079,7 +1079,7 @@ static int ne2k_pci_read(struct guest_info * core, break; default: - PrintError("NE2000 port read error: invalid port:0x%x\n", port); + PrintError(core->vm_info, core, "NE2000 port read error: invalid port:0x%x\n", port); return -1; } @@ -1093,7 +1093,7 @@ static int pci_config_update(struct pci_device * pci_dev, void * src, uint_t length, void * private_data) { - PrintDebug("PCI Config Update\n"); + PrintDebug(VM_NONE, VCORE_NONE, "PCI Config Update\n"); /* Do we need this? */ @@ -1109,7 +1109,7 @@ static int register_dev(struct ne2k_state * nic_state) struct v3_pci_bar bars[6]; struct pci_device * pci_dev = NULL; - PrintDebug("NE2000: PCI Enabled\n"); + PrintDebug(VM_NONE, VCORE_NONE, "NE2000: PCI Enabled\n"); for (i = 0; i < 6; i++) { bars[i].type = PCI_BAR_NONE; @@ -1129,7 +1129,7 @@ static int register_dev(struct ne2k_state * nic_state) if (pci_dev == NULL) { - PrintError("NE2000: Could not register PCI Device\n"); + PrintError(VM_NONE, VCORE_NONE, "NE2000: Could not register PCI Device\n"); return -1; } @@ -1146,7 +1146,7 @@ static int register_dev(struct ne2k_state * nic_state) nic_state->pci_dev = pci_dev; }else { - PrintDebug("NE2000: Not attached to PCI\n"); + PrintDebug(VM_NONE, VCORE_NONE, "NE2000: Not attached to PCI\n"); v3_dev_hook_io(nic_state->dev, NIC_REG_BASE_PORT , &ne2k_cmd_read, &ne2k_cmd_write); @@ -1220,7 +1220,7 @@ static int ne2k_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { nic_state = (struct ne2k_state *)V3_Malloc(sizeof(struct ne2k_state)); if (!nic_state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -1230,16 +1230,16 @@ static int ne2k_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { nic_state->vm = vm; if (macstr != NULL && !str2mac(macstr, nic_state->mac)) { - PrintDebug("NE2000: Mac specified %s\n", macstr); + PrintDebug(vm, VCORE_NONE, "NE2000: Mac specified %s\n", macstr); }else { - PrintDebug("NE2000: MAC not specified\n"); + PrintDebug(vm, VCORE_NONE, "NE2000: MAC not specified\n"); random_ethaddr(nic_state->mac); } struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, nic_state); if (dev == NULL) { - PrintError("NE2000: Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "NE2000: Could not attach device %s\n", dev_id); V3_Free(nic_state); return -1; } @@ -1247,7 +1247,7 @@ static int ne2k_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { nic_state->dev = dev; if (v3_dev_add_net_frontend(vm, dev_id, connect_fn, (void *)nic_state) == -1) { - PrintError("NE2000: Could not register %s as net frontend\n", dev_id); + PrintError(vm, VCORE_NONE, "NE2000: Could not register %s as net frontend\n", dev_id); v3_remove_device(dev); V3_Free(nic_state); return -1; diff --git a/palacios/src/devices/netdisk.c b/palacios/src/devices/netdisk.c index 2c89937..403d9d5 100644 --- a/palacios/src/devices/netdisk.c +++ b/palacios/src/devices/netdisk.c @@ -53,13 +53,13 @@ struct disk_state { static int send_all(v3_sock_t socket, char * buf, int length) { int bytes_sent = 0; - PrintDebug("Sending %d bytes\n", length - bytes_sent); + PrintDebug(VM_NONE, VCORE_NONE, "Sending %d bytes\n", length - bytes_sent); while (bytes_sent < length) { int tmp_bytes = v3_socket_send(socket, buf + bytes_sent, length - bytes_sent); - PrintDebug("Sent %d bytes\n", tmp_bytes); + PrintDebug(VM_NONE, VCORE_NONE, "Sent %d bytes\n", tmp_bytes); if (tmp_bytes == 0) { - PrintError("Connection Closed unexpectedly\n"); + PrintError(VM_NONE, VCORE_NONE, "Connection Closed unexpectedly\n"); return -1; } @@ -73,13 +73,13 @@ static int send_all(v3_sock_t socket, char * buf, int length) { static int recv_all(v3_sock_t socket, char * buf, int length) { int bytes_read = 0; - PrintDebug("Reading %d bytes\n", length - bytes_read); + PrintDebug(VM_NONE, VCORE_NONE, "Reading %d bytes\n", length - bytes_read); while (bytes_read < length) { int tmp_bytes = v3_socket_recv(socket, buf + bytes_read, length - bytes_read); - PrintDebug("Received %d bytes\n", tmp_bytes); + PrintDebug(VM_NONE, VCORE_NONE, "Received %d bytes\n", tmp_bytes); if (tmp_bytes == 0) { - PrintError("Connection Closed unexpectedly\n"); + PrintError(VM_NONE, VCORE_NONE, "Connection Closed unexpectedly\n"); return -1; } @@ -102,46 +102,46 @@ static int read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_ nbd_cmd[0] = NBD_READ_CMD; if (send_all(disk->socket, nbd_cmd, 4) == -1) { - PrintError("Error sending read command\n"); + PrintError(VM_NONE, VCORE_NONE, "Error sending read command\n"); return -1; } if (send_all(disk->socket, (char *)&offset, 8) == -1) { - PrintError("Error sending read offset\n"); + PrintError(VM_NONE, VCORE_NONE, "Error sending read offset\n"); return -1; } if (send_all(disk->socket, (char *)&length, 4) == -1) { - PrintError("Error sending read length\n"); + PrintError(VM_NONE, VCORE_NONE, "Error sending read length\n"); return -1; } if (recv_all(disk->socket, (char *)&status, 1) == -1) { - PrintError("Error receiving status\n"); + PrintError(VM_NONE, VCORE_NONE, "Error receiving status\n"); return -1; } if (status != NBD_STATUS_OK) { - PrintError("NBD Error....\n"); + PrintError(VM_NONE, VCORE_NONE, "NBD Error....\n"); return -1; } - PrintDebug("Reading Data Ret Length\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Reading Data Ret Length\n"); if (recv_all(disk->socket, (char *)&ret_len, 4) == -1) { - PrintError("Error receiving Return read length\n"); + PrintError(VM_NONE, VCORE_NONE, "Error receiving Return read length\n"); return -1; } if (ret_len != length) { - PrintError("Read length mismatch (req=%llu) (result=%u)\n", length, ret_len); + PrintError(VM_NONE, VCORE_NONE, "Read length mismatch (req=%llu) (result=%u)\n", length, ret_len); return -1; } - PrintDebug("Reading Data (%d bytes)\n", ret_len); + PrintDebug(VM_NONE, VCORE_NONE, "Reading Data (%d bytes)\n", ret_len); if (recv_all(disk->socket, (char *)buf, ret_len) == -1) { - PrintError("Read Data Error\n"); + PrintError(VM_NONE, VCORE_NONE, "Read Data Error\n"); return -1; } @@ -159,34 +159,34 @@ static int write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private nbd_cmd[0] = NBD_WRITE_CMD; if (send_all(disk->socket, nbd_cmd, 4) == -1) { - PrintError("Error sending write command\n"); + PrintError(VM_NONE, VCORE_NONE, "Error sending write command\n"); return -1; } if (send_all(disk->socket, (char *)&offset, 8) == -1) { - PrintError("Error sending write offset\n"); + PrintError(VM_NONE, VCORE_NONE, "Error sending write offset\n"); return -1; } if (send_all(disk->socket, (char *)&length, 4) == -1) { - PrintError("Error sending write length\n"); + PrintError(VM_NONE, VCORE_NONE, "Error sending write length\n"); return -1; } - PrintDebug("Writing Data (%d bytes)\n", length); + PrintDebug(VM_NONE, VCORE_NONE, "Writing Data (%d bytes)\n", length); if (send_all(disk->socket, (char *)buf, length) == -1) { - PrintError("Write Data Error\n"); + PrintError(VM_NONE, VCORE_NONE, "Write Data Error\n"); return -1; } if (recv_all(disk->socket, (char *)&status, 1) == -1) { - PrintError("Error receiving status\n"); + PrintError(VM_NONE, VCORE_NONE, "Error receiving status\n"); return -1; } if (status != NBD_STATUS_OK) { - PrintError("NBD Error....\n"); + PrintError(VM_NONE, VCORE_NONE, "NBD Error....\n"); return -1; } @@ -226,16 +226,16 @@ static struct v3_device_ops dev_ops = { static int socket_init(struct disk_state * disk) { char header[64]; - PrintDebug("Intializing Net Disk\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Intializing Net Disk\n"); disk->socket = v3_create_tcp_socket(disk->vm); - PrintDebug("DISK socket: %p\n", disk->socket); - PrintDebug("Connecting to: %s:%d\n", v3_inet_ntoa(disk->ip_addr), disk->port); + PrintDebug(VM_NONE, VCORE_NONE, "DISK socket: %p\n", disk->socket); + PrintDebug(VM_NONE, VCORE_NONE, "Connecting to: %s:%d\n", v3_inet_ntoa(disk->ip_addr), disk->port); v3_connect_to_ip(disk->socket, v3_ntohl(disk->ip_addr), disk->port); - PrintDebug("Connected to NBD server\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Connected to NBD server\n"); //snprintf(header, 64, "V3_NBD_1 %s\n", cd->disk_name); strcpy(header, "V3_NBD_1 "); @@ -244,7 +244,7 @@ static int socket_init(struct disk_state * disk) { if (send_all(disk->socket, header, strlen(header)) == -1) { - PrintError("Error connecting to Network Block Device: %s\n", disk->disk_name); + PrintError(VM_NONE, VCORE_NONE, "Error connecting to Network Block Device: %s\n", disk->disk_name); return -1; } @@ -255,16 +255,16 @@ static int socket_init(struct disk_state * disk) { nbd_cmd[0] = NBD_CAPACITY_CMD; if (send_all(disk->socket, nbd_cmd, 4) == -1) { - PrintError("Error sending capacity command\n"); + PrintError(VM_NONE, VCORE_NONE, "Error sending capacity command\n"); return -1; } if (recv_all(disk->socket, (char *)&(disk->capacity), 8) == -1) { - PrintError("Error Receiving Capacity\n"); + PrintError(VM_NONE, VCORE_NONE, "Error Receiving Capacity\n"); return -1; } - PrintDebug("Capacity: %p\n", (void *)(addr_t)disk->capacity); + PrintDebug(VM_NONE, VCORE_NONE, "Capacity: %p\n", (void *)(addr_t)disk->capacity); } @@ -277,7 +277,7 @@ static int disk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct disk_state * disk = (struct disk_state *)V3_Malloc(sizeof(struct disk_state)); if (!disk) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -288,7 +288,7 @@ static int disk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { v3_cfg_tree_t * frontend_cfg = v3_cfg_subtree(cfg, "frontend"); - PrintDebug("Registering Net disk at %s:%s disk=%s\n", ip_str, port_str, disk_tag); + PrintDebug(vm, VCORE_NONE, "Registering Net disk at %s:%s disk=%s\n", ip_str, port_str, disk_tag); strncpy(disk->disk_name, disk_tag, sizeof(disk->disk_name)); disk->ip_addr = v3_inet_addr(ip_str); @@ -298,27 +298,27 @@ static int disk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, disk); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(disk); return -1; } if (socket_init(disk) == -1) { - PrintError("could not initialize network connection\n"); + PrintError(vm, VCORE_NONE, "could not initialize network connection\n"); v3_remove_device(dev); return -1; } - PrintDebug("Registering Disk\n"); + PrintDebug(vm, VCORE_NONE, "Registering Disk\n"); if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"), &blk_ops, frontend_cfg, disk) == -1) { - PrintError("Could not connect %s to frontend\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not connect %s to frontend\n", dev_id); v3_remove_device(dev); return -1; } - PrintDebug("intialization done\n"); + PrintDebug(vm, VCORE_NONE, "intialization done\n"); return 0; } diff --git a/palacios/src/devices/nic_bridge.c b/palacios/src/devices/nic_bridge.c index 0a5bc8e..34fb174 100644 --- a/palacios/src/devices/nic_bridge.c +++ b/palacios/src/devices/nic_bridge.c @@ -42,7 +42,7 @@ static int bridge_send(uint8_t * buf, uint32_t len, #ifdef V3_CONFIG_DEBUG_NIC_BRIDGE { - PrintDebug("NIC Bridge: send pkt size: %d\n", len); + PrintDebug(VM_NONE, VCORE_NONE, "NIC Bridge: send pkt size: %d\n", len); v3_hexdump(buf, len, NULL, 0); } #endif @@ -55,7 +55,7 @@ static int packet_input(struct v3_packet * packet_state, uint8_t * pkt, uint32_t #ifdef V3_CONFIG_DEBUG_NIC_BRIDGE { - PrintDebug("NIC Bridge: recv pkt size: %d\n", size); + PrintDebug(VM_NONE, VCORE_NONE, "NIC Bridge: recv pkt size: %d\n", size); v3_hexdump(pkt, size, NULL, 0); } #endif @@ -96,7 +96,7 @@ static int nic_bridge_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { bridge = (struct nic_bridge_state *)V3_Malloc(sizeof(struct nic_bridge_state)); if (!bridge) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -105,7 +105,7 @@ static int nic_bridge_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, bridge); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(bridge); return -1; } @@ -115,13 +115,13 @@ static int nic_bridge_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { if (v3_dev_connect_net(vm, v3_cfg_val(frontend_cfg, "tag"), &(bridge->net_ops), frontend_cfg, bridge) == -1) { - PrintError("Could not connect %s to frontend %s\n", + PrintError(vm, VCORE_NONE, "Could not connect %s to frontend %s\n", dev_id, v3_cfg_val(frontend_cfg, "tag")); v3_remove_device(dev); return -1; } - PrintDebug("NIC-Bridge: Connect %s to frontend %s\n", + PrintDebug(vm, VCORE_NONE, "NIC-Bridge: Connect %s to frontend %s\n", dev_id, v3_cfg_val(frontend_cfg, "tag")); bridge->packet_state = v3_packet_connect(vm, host_nic, @@ -130,7 +130,7 @@ static int nic_bridge_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { (void *)bridge); if(bridge->packet_state == NULL){ - PrintError("NIC-Bridge: Error to connect to host ethernet device\n"); + PrintError(vm, VCORE_NONE, "NIC-Bridge: Error to connect to host ethernet device\n"); return -1; } diff --git a/palacios/src/devices/nvram.c b/palacios/src/devices/nvram.c index 8c8830b..912b5f5 100644 --- a/palacios/src/devices/nvram.c +++ b/palacios/src/devices/nvram.c @@ -302,7 +302,7 @@ static void update_time(struct nvram_internal * data, uint64_t period_us) { uint8_t nextday = 0; uint32_t periodic_period; - PrintDebug("nvram: update_time by %llu microseocnds\n",period_us); + PrintDebug(VM_NONE, VCORE_NONE, "nvram: update_time by %llu microseocnds\n",period_us); // We will set these flags on exit statc->irq = 0; @@ -320,7 +320,7 @@ static void update_time(struct nvram_internal * data, uint64_t period_us) { carry = add_to(sec, &carry, bcd); if (carry) { - PrintError("nvram: somehow managed to get a carry in second update\n"); + PrintError(VM_NONE, VCORE_NONE, "nvram: somehow managed to get a carry in second update\n"); } if ( (bcd && (*sec == 0x60)) || @@ -331,7 +331,7 @@ static void update_time(struct nvram_internal * data, uint64_t period_us) { carry = 1; carry = add_to(min, &carry, bcd); if (carry) { - PrintError("nvram: somehow managed to get a carry in minute update\n"); + PrintError(VM_NONE, VCORE_NONE, "nvram: somehow managed to get a carry in minute update\n"); } if ( (bcd && (*min == 0x60)) || @@ -352,7 +352,7 @@ static void update_time(struct nvram_internal * data, uint64_t period_us) { carry = 1; carry = add_to(&hour24, &carry, bcd); if (carry) { - PrintError("nvram: somehow managed to get a carry in hour update\n"); + PrintError(VM_NONE, VCORE_NONE, "nvram: somehow managed to get a carry in hour update\n"); } if ( (bcd && (hour24 == 0x24)) || @@ -432,7 +432,7 @@ static void update_time(struct nvram_internal * data, uint64_t period_us) { if (statb->ai) { if ((*sec == *seca) && (*min == *mina) && (*hour == *houra)) { statc->af = 1; - PrintDebug("nvram: interrupt on alarm\n"); + PrintDebug(VM_NONE, VCORE_NONE, "nvram: interrupt on alarm\n"); } } } @@ -442,22 +442,22 @@ static void update_time(struct nvram_internal * data, uint64_t period_us) { if (data->pus >= periodic_period) { statc->pf = 1; data->pus -= periodic_period; - PrintDebug("nvram: interrupt on periodic\n"); + PrintDebug(VM_NONE, VCORE_NONE, "nvram: interrupt on periodic\n"); } } if (statb->ui) { statc->uf = 1; - PrintDebug("nvram: interrupt on update\n"); + PrintDebug(VM_NONE, VCORE_NONE, "nvram: interrupt on update\n"); } statc->irq = (statc->pf || statc->af || statc->uf); - PrintDebug("nvram: time is now: YMDHMS: 0x%x:0x%x:0x%x:0x%x:0x%x,0x%x bcd=%d\n", *year, *month, *monthday, *hour, *min, *sec,bcd); + PrintDebug(VM_NONE, VCORE_NONE, "nvram: time is now: YMDHMS: 0x%x:0x%x:0x%x:0x%x:0x%x,0x%x bcd=%d\n", *year, *month, *monthday, *hour, *min, *sec,bcd); // Interrupt associated VM, if needed if (statc->irq) { - PrintDebug("nvram: injecting interrupt\n"); + PrintDebug(VM_NONE, VCORE_NONE, "nvram: injecting interrupt\n"); v3_raise_irq(data->vm, NVRAM_RTC_IRQ); } } @@ -720,7 +720,7 @@ static int nvram_write_reg_port(struct guest_info * core, uint16_t port, data->thereg = reg & 0x7f; //discard NMI bit if it's there - PrintDebug("nvram: Writing To NVRAM reg: 0x%x (NMI_disable=%d)\n", data->thereg,reg>>7); + PrintDebug(core->vm_info, core, "nvram: Writing To NVRAM reg: 0x%x (NMI_disable=%d)\n", data->thereg,reg>>7); return 1; } @@ -733,11 +733,11 @@ static int nvram_read_data_port(struct guest_info * core, uint16_t port, addr_t irq_state = v3_lock_irqsave(data->nvram_lock); if (get_memory(data, data->thereg, (uint8_t *)dst) == -1) { - PrintError("nvram: Register %d (0x%x) Not set - POSSIBLE BUG IN MACHINE INIT - CONTINUING\n", data->thereg, data->thereg); + PrintError(core->vm_info, core, "nvram: Register %d (0x%x) Not set - POSSIBLE BUG IN MACHINE INIT - CONTINUING\n", data->thereg, data->thereg); } - PrintDebug("nvram: nvram_read_data_port(0x%x) = 0x%x\n", data->thereg, *(uint8_t *)dst); + PrintDebug(core->vm_info, core, "nvram: nvram_read_data_port(0x%x) = 0x%x\n", data->thereg, *(uint8_t *)dst); // hack if (data->thereg == NVRAM_REG_STAT_A) { @@ -761,7 +761,7 @@ static int nvram_write_data_port(struct guest_info * core, uint16_t port, v3_unlock_irqrestore(data->nvram_lock, irq_state); - PrintDebug("nvram: nvram_write_data_port(0x%x) = 0x%x\n", + PrintDebug(core->vm_info, core, "nvram: nvram_write_data_port(0x%x) = 0x%x\n", data->thereg, data->mem_state[data->thereg]); return 1; @@ -805,19 +805,19 @@ static int nvram_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { int ret = 0; if (!ide) { - PrintError("nvram: Could not find IDE device\n"); + PrintError(vm, VCORE_NONE, "nvram: Could not find IDE device\n"); return -1; } - PrintDebug("nvram: init_device\n"); + PrintDebug(vm, VCORE_NONE, "nvram: init_device\n"); nvram_state = (struct nvram_internal *)V3_Malloc(sizeof(struct nvram_internal) + 1000); if (!nvram_state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } - PrintDebug("nvram: internal at %p\n", (void *)nvram_state); + PrintDebug(vm, VCORE_NONE, "nvram: internal at %p\n", (void *)nvram_state); nvram_state->ide = ide; nvram_state->vm = vm; @@ -825,7 +825,7 @@ static int nvram_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, nvram_state); if (dev == NULL) { - PrintError("nvram: Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "nvram: Could not attach device %s\n", dev_id); V3_Free(nvram_state); return -1; } @@ -837,7 +837,7 @@ static int nvram_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { ret |= v3_dev_hook_io(dev, NVRAM_DATA_PORT, &nvram_read_data_port, &nvram_write_data_port); if (ret != 0) { - PrintError("nvram: Error hooking NVRAM IO ports\n"); + PrintError(vm, VCORE_NONE, "nvram: Error hooking NVRAM IO ports\n"); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/os_debug.c b/palacios/src/devices/os_debug.c index a2fbee0..f27dca3 100644 --- a/palacios/src/devices/os_debug.c +++ b/palacios/src/devices/os_debug.c @@ -41,7 +41,7 @@ static int handle_gen_write(struct guest_info * core, ushort_t port, void * src, state->debug_buf[state->debug_offset++] = *(char*)src; if ((*(char*)src == 0xa) || (state->debug_offset == (BUF_SIZE - 1))) { - PrintDebug("VM_CONSOLE>%s", state->debug_buf); + PrintDebug(core->vm_info, core, "VM_CONSOLE>%s", state->debug_buf); memset(state->debug_buf, 0, BUF_SIZE); state->debug_offset = 0; } @@ -60,7 +60,7 @@ static int handle_hb_write(struct guest_info * core, ushort_t port, void * src, val = *(uint32_t *)src; } - V3_Print("HEARTBEAT> %x (%d)\n", val, val); + V3_Print(core->vm_info, core, "HEARTBEAT> %x (%d)\n", val, val); return length; } @@ -73,25 +73,25 @@ static int handle_hcall(struct guest_info * info, uint_t hcall_id, void * priv_d int buf_is_va = info->vm_regs.rdx; if (msg_len >= BUF_SIZE) { - PrintError("Console message too large for buffer (len=%d)\n", msg_len); + PrintError(info->vm_info, info, "Console message too large for buffer (len=%d)\n", msg_len); return -1; } if (buf_is_va == 1) { if (v3_read_gva_memory(info, msg_gpa, msg_len, (uchar_t *)state->debug_buf) != msg_len) { - PrintError("Could not read debug message\n"); + PrintError(info->vm_info, info, "Could not read debug message\n"); return -1; } } else { if (v3_read_gpa_memory(info, msg_gpa, msg_len, (uchar_t *)state->debug_buf) != msg_len) { - PrintError("Could not read debug message\n"); + PrintError(info->vm_info, info, "Could not read debug message\n"); return -1; } } state->debug_buf[msg_len] = 0; - PrintDebug("VM_CONSOLE>%s\n", state->debug_buf); + PrintDebug(info->vm_info, info, "VM_CONSOLE>%s\n", state->debug_buf); return 0; } @@ -116,7 +116,7 @@ static int debug_save(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; savefailout: - PrintError("Failed to save debug\n"); + PrintError(VM_NONE,VCORE_NONE, "Failed to save debug\n"); return -1; } @@ -131,7 +131,7 @@ static int debug_load(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; loadfailout: - PrintError("Failed to load debug\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to load debug\n"); return -1; } @@ -157,29 +157,29 @@ static int debug_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { state = (struct debug_state *)V3_Malloc(sizeof(struct debug_state)); if (!state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } - PrintDebug("Creating OS Debug Device\n"); + PrintDebug(vm, VCORE_NONE, "Creating OS Debug Device\n"); struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(state); return -1; } if (v3_dev_hook_io(dev, DEBUG_PORT1, NULL, &handle_gen_write) == -1) { - PrintError("Error hooking OS debug IO port\n"); + PrintError(vm, VCORE_NONE, "Error hooking OS debug IO port\n"); v3_remove_device(dev); return -1; } if (v3_dev_hook_io(dev, HEARTBEAT_PORT, NULL, &handle_hb_write) == -1) { - PrintError("error hooking OS heartbeat port\n"); + PrintError(vm, VCORE_NONE, "error hooking OS heartbeat port\n"); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/para_net.c b/palacios/src/devices/para_net.c index 74b4466..46e1418 100644 --- a/palacios/src/devices/para_net.c +++ b/palacios/src/devices/para_net.c @@ -41,11 +41,11 @@ static int tx_call(struct guest_info * info, uint_t call_no, void * priv_data) { uchar_t * pkt = V3_Malloc(pkt_len); if (!pkt) { - PrintError("Cannot allocate in transmit!\n"); + PrintError(info->vm_info, info, "Cannot allocate in transmit!\n"); return -1; } - PrintDebug("Transmitting Packet\n"); + PrintDebug(info->vm_info, info, "Transmitting Packet\n"); if (read_guest_pa_memory(info, pkt_gpa, pkt_len, pkt) != -1) { return -1; @@ -62,7 +62,7 @@ static int rx_call(struct guest_info * info, uint_t call_no, void * priv_data) { uint_t pkt_len = 0; uchar_t * pkt = NULL; - PrintDebug("Receiving Packet\n"); + PrintDebug(info->vm_info, info, "Receiving Packet\n"); return -1; if (write_guest_pa_memory(info, pkt_gpa, pkt_len, pkt) != -1) { @@ -78,10 +78,10 @@ static int macaddr_call(struct guest_info * info, uint_t call_no, void * priv_da addr_t mac_gpa = info->vm_regs.rbx; - PrintDebug("Returning MAC ADDR\n"); + PrintDebug(info->vm_info, info, "Returning MAC ADDR\n"); if (write_guest_pa_memory(info, mac_gpa, 6, nic->mac_addr) != 6) { - PrintError("Could not write mac address\n"); + PrintError(info->vm_info, info, "Could not write mac address\n"); return -1; } @@ -112,16 +112,16 @@ static int net_init(struct guest_info * vm, v3_cfg_tree_t * cfg) { state = (struct nic_state *)V3_Malloc(sizeof(struct nic_state)); if (!state) { - PrintError("Cannot allocate in init\n"); + PrintError(info->vm_info, info, "Cannot allocate in init\n"); return -1; } - PrintDebug("Creating VMNet Device\n"); + PrintDebug(info->vm_info, info, "Creating VMNet Device\n"); struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, state); if (v3_attach_device(vm, dev) == -1) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(info->vm_info, info, "Could not attach device %s\n", dev_id); return -1; } diff --git a/palacios/src/devices/pci.c b/palacios/src/devices/pci.c index 774eb64..b5abc15 100644 --- a/palacios/src/devices/pci.c +++ b/palacios/src/devices/pci.c @@ -170,19 +170,19 @@ static void pci_dump_state(struct pci_internal * pci_state) { struct rb_node * node = v3_rb_first(&(pci_state->bus_list[0].devices)); struct pci_device * tmp_dev = NULL; - PrintDebug("===PCI: Dumping state Begin ==========\n"); + PrintDebug(core->vm_info, core, "===PCI: Dumping state Begin ==========\n"); do { tmp_dev = rb_entry(node, struct pci_device, dev_tree_node); - PrintDebug("PCI Device Number: %d (%s):\n", tmp_dev->dev_num, tmp_dev->name); - PrintDebug("irq = %d\n", tmp_dev->config_header.intr_line); - PrintDebug("Vend ID: 0x%x\n", tmp_dev->config_header.vendor_id); - PrintDebug("Device ID: 0x%x\n", tmp_dev->config_header.device_id); + PrintDebug(core->vm_info, core, "PCI Device Number: %d (%s):\n", tmp_dev->dev_num, tmp_dev->name); + PrintDebug(core->vm_info, core, "irq = %d\n", tmp_dev->config_header.intr_line); + PrintDebug(core->vm_info, core, "Vend ID: 0x%x\n", tmp_dev->config_header.vendor_id); + PrintDebug(core->vm_info, core, "Device ID: 0x%x\n", tmp_dev->config_header.device_id); } while ((node = v3_rb_next(node))); - PrintDebug("====PCI: Dumping state End==========\n"); + PrintDebug(core->vm_info, core, "====PCI: Dumping state End==========\n"); } #endif @@ -195,11 +195,11 @@ static int get_free_dev_num(struct pci_bus * bus) { int i, j; for (i = 0; i < sizeof(bus->dev_map); i++) { - PrintDebug("i=%d\n", i); + PrintDebug(core->vm_info, core, "i=%d\n", i); if (bus->dev_map[i] != 0xff) { // availability for (j = 0; j < 8; j++) { - PrintDebug("\tj=%d\n", j); + PrintDebug(core->vm_info, core, "\tj=%d\n", j); if (!(bus->dev_map[i] & (0x1 << j))) { return ((i * 8) + j); } @@ -312,14 +312,14 @@ int v3_pci_hook_config_range(struct pci_device * pci, if (find_cfg_range_hook(pci, start, length)) { - PrintError("Tried to hook an already hooked config region\n"); + PrintError(VM_NONE, VCORE_NONE, "Tried to hook an already hooked config region\n"); return -1; } hook = V3_Malloc(sizeof(struct cfg_range_hook)); if (!hook) { - PrintError("Could not allocate range hook\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not allocate range hook\n"); return -1; } @@ -427,7 +427,7 @@ int cap_write(struct pci_device * pci, uint32_t offset, void * src, uint_t lengt int msix_was_enabled = 0; - V3_Print("CAP write trapped (val=%x, cfg_offset=%d, write_offset=%d)\n", *(uint32_t *)src, offset, write_offset); + V3_Print(VM_NONE, VCORE_NONE, "CAP write trapped (val=%x, cfg_offset=%d, write_offset=%d)\n", *(uint32_t *)src, offset, write_offset); if (cap_type == PCI_CAP_MSI) { struct msi_msg_ctrl * msg_ctrl = cap_ptr; @@ -449,10 +449,10 @@ int cap_write(struct pci_device * pci, uint32_t offset, void * src, uint_t lengt if (cap_type == PCI_CAP_MSI) { struct msi_msg_ctrl * msg_ctrl = cap_ptr; - V3_Print("MSI Cap Ctrl=%x\n", *(uint16_t *)pci->msi_cap); - V3_Print("MSI ADDR=%x\n", *(uint32_t *)(cap_ptr + 2)); - V3_Print("MSI HI ADDR=%x\n", *(uint32_t *)(cap_ptr + 6)); - V3_Print("MSI Data=%x\n", *(uint16_t *)(cap_ptr + 10)); + V3_Print(VM_NONE, VCORE_NONE, "MSI Cap Ctrl=%x\n", *(uint16_t *)pci->msi_cap); + V3_Print(VM_NONE, VCORE_NONE, "MSI ADDR=%x\n", *(uint32_t *)(cap_ptr + 2)); + V3_Print(VM_NONE, VCORE_NONE, "MSI HI ADDR=%x\n", *(uint32_t *)(cap_ptr + 6)); + V3_Print(VM_NONE, VCORE_NONE, "MSI Data=%x\n", *(uint16_t *)(cap_ptr + 10)); if (msg_ctrl->cap_64bit) { if (msg_ctrl->per_vect_mask) { @@ -492,7 +492,7 @@ int cap_write(struct pci_device * pci, uint32_t offset, void * src, uint_t lengt if (cap_type == PCI_CAP_MSI) { struct msi_msg_ctrl * msg_ctrl = cap_ptr; - V3_Print("msi_was_enabled=%d, msi_is_enabled=%d\n", msi_was_enabled, msg_ctrl->msi_enable); + V3_Print(VM_NONE, VCORE_NONE, "msi_was_enabled=%d, msi_is_enabled=%d\n", msi_was_enabled, msg_ctrl->msi_enable); if ((msg_ctrl->msi_enable == 1) && (msi_was_enabled == 0)) { pci->irq_type = IRQ_MSI; @@ -577,19 +577,19 @@ static int init_pci_cap(struct pci_device * pci, pci_cap_type_t cap_type, uint_t static int scan_pci_caps(struct pci_device * pci) { uint_t cap_offset = pci->config_header.cap_ptr; - V3_Print("Scanning for Capabilities (cap_offset=%d)\n", cap_offset); + V3_Print(VM_NONE, VCORE_NONE, "Scanning for Capabilities (cap_offset=%d)\n", cap_offset); while (cap_offset != 0) { uint8_t id = pci->config_space[cap_offset]; uint8_t next = pci->config_space[cap_offset + 1]; - V3_Print("Found Capability 0x%x at offset %d (0x%x)\n", + V3_Print(VM_NONE, VCORE_NONE, "Found Capability 0x%x at offset %d (0x%x)\n", id, cap_offset, cap_offset); struct pci_cap * cap = V3_Malloc(sizeof(struct pci_cap)); if (!cap) { - PrintError("Error allocating PCI CAP info\n"); + PrintError(VM_NONE, VCORE_NONE, "Error allocating PCI CAP info\n"); return -1; } memset(cap, 0, sizeof(struct pci_cap)); @@ -613,7 +613,7 @@ static int scan_pci_caps(struct pci_device * pci) { // Hook Cap pointer to return cached config space value if (v3_pci_hook_config_range(pci, 0x34, 1, NULL, NULL, NULL) == -1) { - PrintError("Could not hook cap pointer\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not hook cap pointer\n"); return -1; } @@ -651,7 +651,7 @@ int v3_pci_enable_capability(struct pci_device * pci, pci_cap_type_t cap_type) { } - V3_Print("Found Capability %x at %x (%d)\n", cap_type, cap->offset, cap->offset); + V3_Print(VM_NONE, VCORE_NONE, "Found Capability %x at %x (%d)\n", cap_type, cap->offset, cap->offset); // found the capability @@ -698,11 +698,11 @@ int v3_pci_enable_capability(struct pci_device * pci, pci_cap_type_t cap_type) { } - V3_Print("Hooking capability range (offset=%d, size=%d)\n", cap->offset, size); + V3_Print(VM_NONE, VCORE_NONE, "Hooking capability range (offset=%d, size=%d)\n", cap->offset, size); if (v3_pci_hook_config_range(pci, cap->offset, size + 2, cap_write, NULL, cap) == -1) { - PrintError("Could not hook config range (start=%d, size=%d)\n", + PrintError(VM_NONE, VCORE_NONE, "Could not hook config range (start=%d, size=%d)\n", cap->offset + 2, size); return -1; } @@ -724,10 +724,10 @@ static int addr_port_read(struct guest_info * core, ushort_t port, void * dst, u int reg_offset = port & 0x3; uint8_t * reg_addr = ((uint8_t *)&(pci_state->addr_reg.val)) + reg_offset; - PrintDebug("Reading PCI Address Port (%x): %x len=%d\n", port, pci_state->addr_reg.val, length); + PrintDebug(core->vm_info, core, "Reading PCI Address Port (%x): %x len=%d\n", port, pci_state->addr_reg.val, length); if (reg_offset + length > 4) { - PrintError("Invalid Address port write\n"); + PrintError(core->vm_info, core, "Invalid Address port write\n"); return -1; } @@ -743,14 +743,14 @@ static int addr_port_write(struct guest_info * core, ushort_t port, void * src, uint8_t * reg_addr = ((uint8_t *)&(pci_state->addr_reg.val)) + reg_offset; if (reg_offset + length > 4) { - PrintError("Invalid Address port write\n"); + PrintError(core->vm_info, core, "Invalid Address port write\n"); return -1; } // Set address register memcpy(reg_addr, src, length); - PrintDebug("Writing PCI Address Port(%x): AddrReg=%x (op_val = %x, len=%d) \n", port, pci_state->addr_reg.val, *(uint32_t *)src, length); + PrintDebug(core->vm_info, core, "Writing PCI Address Port(%x): AddrReg=%x (op_val = %x, len=%d) \n", port, pci_state->addr_reg.val, *(uint32_t *)src, length); return length; } @@ -776,7 +776,7 @@ static int data_port_read(struct guest_info * core, uint16_t port, void * dst, u return length; } - PrintDebug("Reading PCI Data register. bus = %d, dev = %d, fn = %d, reg = %d (%x), cfg_reg = %x\n", + PrintDebug(core->vm_info, core, "Reading PCI Data register. bus = %d, dev = %d, fn = %d, reg = %d (%x), cfg_reg = %x\n", pci_state->addr_reg.bus_num, pci_state->addr_reg.dev_num, pci_state->addr_reg.fn_num, @@ -801,7 +801,7 @@ static int data_port_read(struct guest_info * core, uint16_t port, void * dst, u } else { if (pci_dev->config_read) { if (pci_dev->config_read(pci_dev, reg_num + i, cfg_dst, 1, pci_dev->priv_data) != 0) { - PrintError("Error in config_read from PCI device (%s)\n", pci_dev->name); + PrintError(core->vm_info, core, "Error in config_read from PCI device (%s)\n", pci_dev->name); } } @@ -812,7 +812,7 @@ static int data_port_read(struct guest_info * core, uint16_t port, void * dst, u memcpy(dst, &(pci_dev->config_space[reg_num]), length); - PrintDebug("\tVal=%x, len=%d\n", *(uint32_t *)dst, length); + PrintDebug(core->vm_info, core, "\tVal=%x, len=%d\n", *(uint32_t *)dst, length); return length; } @@ -826,7 +826,7 @@ static int bar_update(struct pci_device * pci_dev, uint32_t offset, int bar_num = (bar_offset - 0x10) / 4; uint32_t new_val = *(uint32_t *)src; - PrintDebug("Updating BAR Register (Dev=%s) (bar=%d) (old_val=0x%x) (new_val=0x%x)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Updating BAR Register (Dev=%s) (bar=%d) (old_val=0x%x) (new_val=0x%x)\n", pci_dev->name, bar_num, bar->val, new_val); // Cache the changes locally @@ -834,7 +834,7 @@ static int bar_update(struct pci_device * pci_dev, uint32_t offset, if (bar->type == PCI_BAR_PASSTHROUGH) { if (bar->bar_write(bar_num, (void *)(pci_dev->config_space + bar_offset), bar->private_data) == -1) { - PrintError("Error in Passthrough bar write operation\n"); + PrintError(VM_NONE, VCORE_NONE, "Error in Passthrough bar write operation\n"); return -1; } @@ -849,18 +849,18 @@ static int bar_update(struct pci_device * pci_dev, uint32_t offset, case PCI_BAR_IO: { int i = 0; - PrintDebug("\tRehooking %d IO ports from base 0x%x to 0x%x for %d ports\n", + PrintDebug(VM_NONE, VCORE_NONE, "\tRehooking %d IO ports from base 0x%x to 0x%x for %d ports\n", bar->num_ports, PCI_IO_BASE(bar->val), PCI_IO_BASE(new_val), bar->num_ports); // only do this if pci device is enabled.... if (!(pci_dev->config_header.status & 0x1)) { - PrintError("PCI Device IO space not enabled\n"); + PrintError(VM_NONE, VCORE_NONE, "PCI Device IO space not enabled\n"); } for (i = 0; i < bar->num_ports; i++) { - PrintDebug("Rehooking PCI IO port (old port=%u) (new port=%u)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Rehooking PCI IO port (old port=%u) (new port=%u)\n", PCI_IO_BASE(bar->val) + i, PCI_IO_BASE(new_val) + i); v3_unhook_io_port(pci_dev->vm, PCI_IO_BASE(bar->val) + i); @@ -869,7 +869,7 @@ static int bar_update(struct pci_device * pci_dev, uint32_t offset, bar->io_read, bar->io_write, bar->private_data) == -1) { - PrintError("Could not hook PCI IO port (old port=%u) (new port=%u)\n", + PrintError(VM_NONE, VCORE_NONE, "Could not hook PCI IO port (old port=%u) (new port=%u)\n", PCI_IO_BASE(bar->val) + i, PCI_IO_BASE(new_val) + i); v3_print_io_map(pci_dev->vm); return -1; @@ -888,7 +888,7 @@ static int bar_update(struct pci_device * pci_dev, uint32_t offset, PCI_MEM32_BASE(new_val) + (bar->num_pages * PAGE_SIZE_4KB), bar->mem_read, bar->mem_write, pci_dev->priv_data); } else { - PrintError("Write hooks not supported for PCI\n"); + PrintError(VM_NONE, VCORE_NONE, "Write hooks not supported for PCI\n"); return -1; } @@ -897,12 +897,12 @@ static int bar_update(struct pci_device * pci_dev, uint32_t offset, break; } case PCI_BAR_NONE: { - PrintDebug("Reprogramming an unsupported BAR register (Dev=%s) (bar=%d) (val=%x)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Reprogramming an unsupported BAR register (Dev=%s) (bar=%d) (val=%x)\n", pci_dev->name, bar_num, new_val); break; } default: - PrintError("Invalid Bar Reg updated (bar=%d)\n", bar_num); + PrintError(VM_NONE, VCORE_NONE, "Invalid Bar Reg updated (bar=%d)\n", bar_num); return -1; } @@ -921,7 +921,7 @@ static int data_port_write(struct guest_info * core, uint16_t port, void * src, return length; } - PrintDebug("Writing PCI Data register. bus = %d, dev = %d, fn = %d, reg = %d (0x%x) addr_reg = 0x%x (val=0x%x, len=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Writing PCI Data register. bus = %d, dev = %d, fn = %d, reg = %d (0x%x) addr_reg = 0x%x (val=0x%x, len=%d)\n", pci_state->addr_reg.bus_num, pci_state->addr_reg.dev_num, pci_state->addr_reg.fn_num, @@ -933,7 +933,7 @@ static int data_port_write(struct guest_info * core, uint16_t port, void * src, pci_dev = get_device(&(pci_state->bus_list[0]), pci_state->addr_reg.dev_num, pci_state->addr_reg.fn_num); if (pci_dev == NULL) { - PrintError("Writing configuration space for non-present device (dev_num=%d)\n", + PrintError(VM_NONE, VCORE_NONE, "Writing configuration space for non-present device (dev_num=%d)\n", pci_state->addr_reg.dev_num); return -1; } @@ -993,7 +993,7 @@ static int exp_rom_write(struct pci_device * pci_dev, uint32_t offset, return 0; } - PrintError("Expansion ROM update not handled. Will appear to not Exist\n"); + PrintError(VM_NONE, VCORE_NONE, "Expansion ROM update not handled. Will appear to not Exist\n"); return 0; } @@ -1109,7 +1109,7 @@ static int pci_save_extended(struct v3_chkpt *chkpt, char *id, void * private_da ctx = v3_chkpt_open_ctx(chkpt,id); if (!ctx) { - PrintError("Unable to open base context on save\n"); + PrintError(VM_NONE, VCORE_NONE, "Unable to open base context on save\n"); goto savefailout; } @@ -1128,7 +1128,7 @@ static int pci_save_extended(struct v3_chkpt *chkpt, char *id, void * private_da ctx = v3_chkpt_open_ctx(chkpt, buf); if (!ctx) { - PrintError("Failed to open context for %s\n", buf); + PrintError(VM_NONE, VCORE_NONE, "Failed to open context for %s\n", buf); goto savefailout; } @@ -1145,7 +1145,7 @@ static int pci_save_extended(struct v3_chkpt *chkpt, char *id, void * private_da ctx = v3_chkpt_open_ctx(chkpt, buf); if (!ctx) { - PrintError("Failed to open context for device\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to open context for device\n"); goto savefailout; } @@ -1167,7 +1167,7 @@ static int pci_save_extended(struct v3_chkpt *chkpt, char *id, void * private_da return 0; savefailout: - PrintError("Failed to save PCI\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to save PCI\n"); if (ctx) { v3_chkpt_close_ctx(ctx); } return -1; @@ -1183,7 +1183,7 @@ static int pci_load_extended(struct v3_chkpt *chkpt, char *id, void * private_da ctx = v3_chkpt_open_ctx(chkpt,id); if (!ctx) { - PrintError("Unable to open base context on load\n"); + PrintError(VM_NONE, VCORE_NONE, "Unable to open base context on load\n"); goto loadfailout; } @@ -1202,7 +1202,7 @@ static int pci_load_extended(struct v3_chkpt *chkpt, char *id, void * private_da ctx = v3_chkpt_open_ctx(chkpt, buf); if (!ctx) { - PrintError("Failed to open context for %s\n", buf); + PrintError(VM_NONE, VCORE_NONE, "Failed to open context for %s\n", buf); goto loadfailout; } @@ -1219,7 +1219,7 @@ static int pci_load_extended(struct v3_chkpt *chkpt, char *id, void * private_da ctx = v3_chkpt_open_ctx(chkpt, buf); if (!ctx) { - PrintError("Failed to open context for device\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to open context for device\n"); goto loadfailout; } @@ -1240,7 +1240,7 @@ static int pci_load_extended(struct v3_chkpt *chkpt, char *id, void * private_da return 0; loadfailout: - PrintError("Failed to load PCI\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to load PCI\n"); if (ctx) { v3_chkpt_close_ctx(ctx); } return -1; @@ -1267,7 +1267,7 @@ static int pci_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct pci_internal * pci_state = V3_Malloc(sizeof(struct pci_internal)); if (!pci_state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -1275,12 +1275,12 @@ static int pci_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { char * dev_id = v3_cfg_val(cfg, "ID"); int ret = 0; - PrintDebug("PCI internal at %p\n",(void *)pci_state); + PrintDebug(vm, VCORE_NONE, "PCI internal at %p\n",(void *)pci_state); struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, pci_state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(pci_state); return -1; } @@ -1291,7 +1291,7 @@ static int pci_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { init_pci_busses(pci_state); - PrintDebug("Sizeof config header=%d\n", (int)sizeof(struct pci_config_header)); + PrintDebug(vm, VCORE_NONE, "Sizeof config header=%d\n", (int)sizeof(struct pci_config_header)); for (i = 0; i < 4; i++) { ret |= v3_dev_hook_io(dev, CONFIG_ADDR_PORT + i, &addr_port_read, &addr_port_write); @@ -1299,7 +1299,7 @@ static int pci_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { } if (ret != 0) { - PrintError("Error hooking PCI IO ports\n"); + PrintError(vm, VCORE_NONE, "Error hooking PCI IO ports\n"); v3_remove_device(dev); return -1; } @@ -1336,7 +1336,7 @@ static inline int init_bars(struct v3_vm_info * vm, struct pci_device * pci_dev) if (v3_hook_io_port(vm, bar->default_base_port + j, bar->io_read, bar->io_write, bar->private_data) == -1) { - PrintError("Could not hook default io port %x\n", bar->default_base_port + j); + PrintError(vm, VCORE_NONE, "Could not hook default io port %x\n", bar->default_base_port + j); return -1; } } @@ -1362,7 +1362,7 @@ static inline int init_bars(struct v3_vm_info * vm, struct pci_device * pci_dev) bar->mem_read, bar->mem_write, pci_dev->priv_data); } else if (bar->mem_write) { // write hook - PrintError("Write hooks not supported for PCI devices\n"); + PrintError(vm, VCORE_NONE, "Write hooks not supported for PCI devices\n"); return -1; /* v3_hook_write_mem(pci_dev->vm_dev->vm, bar->default_base_addr, @@ -1378,7 +1378,7 @@ static inline int init_bars(struct v3_vm_info * vm, struct pci_device * pci_dev) *(uint32_t *)(pci_dev->config_space + bar_offset) = bar->val; } else if (bar->type == PCI_BAR_MEM24) { - PrintError("16 Bit memory ranges not supported (reg: %d)\n", i); + PrintError(vm, VCORE_NONE, "16 Bit memory ranges not supported (reg: %d)\n", i); return -1; } else if (bar->type == PCI_BAR_NONE) { bar->val = 0x00000000; @@ -1390,7 +1390,7 @@ static inline int init_bars(struct v3_vm_info * vm, struct pci_device * pci_dev) bar->bar_init(i, &(bar->val), bar->private_data); } else { - PrintError("Invalid BAR type for bar #%d\n", i); + PrintError(vm, VCORE_NONE, "Invalid BAR type for bar #%d\n", i); return -1; } @@ -1487,7 +1487,7 @@ int v3_pci_raise_acked_irq(struct vm_device * pci_bus, struct pci_device * dev, struct msi_data * data = NULL; if (dev->bar[bar_idx].type != PCI_BAR_MEM32) { - PrintError("Non 32bit MSIX BAR registers are not supported\n"); + PrintError(VM_NONE, VCORE_NONE, "Non 32bit MSIX BAR registers are not supported\n"); return -1; } @@ -1495,7 +1495,7 @@ int v3_pci_raise_acked_irq(struct vm_device * pci_bus, struct pci_device * dev, msix_table_gpa += dev->msix_cap->table_offset; if (v3_gpa_to_hva(&(dev->vm->cores[0]), msix_table_gpa, (void *)&(msix_table)) != 0) { - PrintError("Could not translate MSIX Table GPA (%p)\n", (void *)msix_table_gpa); + PrintError(VM_NONE, VCORE_NONE, "Could not translate MSIX Table GPA (%p)\n", (void *)msix_table_gpa); return -1; } @@ -1514,7 +1514,7 @@ int v3_pci_raise_acked_irq(struct vm_device * pci_bus, struct pci_device * dev, - V3_Print("Decode MSIX\n"); + V3_Print(VM_NONE, VCORE_NONE, "Decode MSIX\n"); v3_apic_send_ipi(dev->vm, &ipi, dev->apic_dev); @@ -1560,22 +1560,22 @@ struct pci_device * v3_pci_register_device(struct vm_device * pci, int i; if (dev_num > MAX_BUS_DEVICES) { - PrintError("Requested Invalid device number (%d)\n", dev_num); + PrintError(VM_NONE, VCORE_NONE, "Requested Invalid device number (%d)\n", dev_num); return NULL; } if (dev_num == PCI_AUTO_DEV_NUM) { - PrintDebug("Searching for free device number\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Searching for free device number\n"); if ((dev_num = get_free_dev_num(bus)) == -1) { - PrintError("No more available PCI slots on bus %d\n", bus->bus_num); + PrintError(VM_NONE, VCORE_NONE, "No more available PCI slots on bus %d\n", bus->bus_num); return NULL; } } - PrintDebug("Checking for PCI Device\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Checking for PCI Device\n"); if (get_device(bus, dev_num, fn_num) != NULL) { - PrintError("PCI Device already registered at slot %d on bus %d\n", + PrintError(VM_NONE, VCORE_NONE, "PCI Device already registered at slot %d on bus %d\n", dev_num, bus->bus_num); return NULL; } @@ -1584,7 +1584,7 @@ struct pci_device * v3_pci_register_device(struct vm_device * pci, pci_dev = (struct pci_device *)V3_Malloc(sizeof(struct pci_device)); if (pci_dev == NULL) { - PrintError("Could not allocate pci device\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not allocate pci device\n"); return NULL; } @@ -1601,7 +1601,7 @@ struct pci_device * v3_pci_register_device(struct vm_device * pci, pci_dev->config_header.header_type = 0x80; break; default: - PrintError("Unhandled PCI Device Type: %d\n", dev_type); + PrintError(VM_NONE, VCORE_NONE, "Unhandled PCI Device Type: %d\n", dev_type); return NULL; } @@ -1641,14 +1641,14 @@ struct pci_device * v3_pci_register_device(struct vm_device * pci, } } - V3_Print("Scanning for Capabilities\n"); + V3_Print(VM_NONE, VCORE_NONE, "Scanning for Capabilities\n"); // scan for caps scan_pci_caps(pci_dev); pci_dev->irq_type = IRQ_INTX; - V3_Print("Caps scanned\n"); + V3_Print(VM_NONE, VCORE_NONE, "Caps scanned\n"); // hook important regions v3_pci_hook_config_range(pci_dev, 0x30, 4, exp_rom_write, NULL, NULL); // ExpRom @@ -1695,7 +1695,7 @@ struct pci_device * v3_pci_register_device(struct vm_device * pci, } if (init_bars(pci->vm, pci_dev) == -1) { - PrintError("could not initialize bar registers\n"); + PrintError(VM_NONE, VCORE_NONE, "could not initialize bar registers\n"); return NULL; } diff --git a/palacios/src/devices/pci_front.c b/palacios/src/devices/pci_front.c index 68428b5..d4d2de6 100644 --- a/palacios/src/devices/pci_front.c +++ b/palacios/src/devices/pci_front.c @@ -170,18 +170,18 @@ static int pci_front_read_mem(struct guest_info * core, struct vm_device *dev = (struct vm_device *) priv; struct pci_front_internal *state = (struct pci_front_internal *) dev->private_data; - PrintDebug("pci_front (%s): reading 0x%x bytes from gpa 0x%p from host dev 0x%p ...", + PrintDebug(info->vm_info, info, "pci_front (%s): reading 0x%x bytes from gpa 0x%p from host dev 0x%p ...", state->name, len, (void*)gpa, state->host_dev); rc = v3_host_dev_read_mem(state->host_dev, gpa, dst, len); - PrintDebug(" done ... read %d bytes: 0x", rc); + PrintDebug(info->vm_info, info, " done ... read %d bytes: 0x", rc); for (i = 0; i < rc; i++) { - PrintDebug("%x", ((uint8_t *)dst)[i]); + PrintDebug(info->vm_info, info, "%x", ((uint8_t *)dst)[i]); } - PrintDebug("\n"); + PrintDebug(info->vm_info, info, "\n"); return rc; } @@ -197,16 +197,16 @@ static int pci_front_write_mem(struct guest_info * core, struct vm_device *dev = (struct vm_device *) priv; struct pci_front_internal *state = (struct pci_front_internal *) dev->private_data; - PrintDebug("pci_front (%s): writing 0x%x bytes to gpa 0x%p to host dev 0x%p bytes=0x", + PrintDebug(info->vm_info, info, "pci_front (%s): writing 0x%x bytes to gpa 0x%p to host dev 0x%p bytes=0x", state->name, len, (void*)gpa, state->host_dev); for (i = 0; i < len; i++) { - PrintDebug("%x", ((uint8_t *)src)[i]); + PrintDebug(info->vm_info, info, "%x", ((uint8_t *)src)[i]); } rc = v3_host_dev_write_mem(state->host_dev, gpa, src, len); - PrintDebug(" %d bytes written\n",rc); + PrintDebug(info->vm_info, info, " %d bytes written\n",rc); return rc; } @@ -221,18 +221,18 @@ static int pci_front_read_port(struct guest_info * core, int i; struct pci_front_internal *state = (struct pci_front_internal *) priv_data; - PrintDebug("pci_front (%s): reading 0x%x bytes from port 0x%x from host dev 0x%p ...", + PrintDebug(info->vm_info, info, "pci_front (%s): reading 0x%x bytes from port 0x%x from host dev 0x%p ...", state->name, len, port, state->host_dev); int rc = v3_host_dev_read_io(state->host_dev, port, dst, len); - PrintDebug(" done ... read %d bytes: 0x", rc); + PrintDebug(info->vm_info, info, " done ... read %d bytes: 0x", rc); for (i = 0; i < rc; i++) { - PrintDebug("%x", ((uint8_t *)dst)[i]); + PrintDebug(info->vm_info, info, "%x", ((uint8_t *)dst)[i]); } - PrintDebug("\n"); + PrintDebug(info->vm_info, info, "\n"); return rc; @@ -247,16 +247,16 @@ static int pci_front_write_port(struct guest_info * core, int i; struct pci_front_internal *state = (struct pci_front_internal *) priv_data; - PrintDebug("pci_front (%s): writing 0x%x bytes to port 0x%x to host dev 0x%p bytes=0x", + PrintDebug(info->vm_info, info, "pci_front (%s): writing 0x%x bytes to port 0x%x to host dev 0x%p bytes=0x", state->name, len, port, state->host_dev); for (i = 0; i < len; i++) { - PrintDebug("%x", ((uint8_t *)src)[i]); + PrintDebug(info->vm_info, info, "%x", ((uint8_t *)src)[i]); } int rc = v3_host_dev_write_io(state->host_dev, port, src, len); - PrintDebug(" %d bytes written\n",rc); + PrintDebug(info->vm_info, info, " %d bytes written\n",rc); return rc; } @@ -285,7 +285,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { pci_addr.reg = bar_base_reg + bar_num; - PrintDebug("pci_front (%s): pci_bar_init: PCI Address = 0x%x\n", state->name, pci_addr.value); + PrintDebug(info->vm_info, info, "pci_front (%s): pci_bar_init: PCI Address = 0x%x\n", state->name, pci_addr.value); // This assumees that pull_config() has been previously called and // we have a local copy of the host device's configuration space @@ -305,7 +305,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { pbar->size += lo_pbar->size; - PrintDebug("pci_front (%s): pci_bar_init: Adding 64 bit PCI mem region: start=0x%p, end=0x%p as a full hook\n", + PrintDebug(info->vm_info, info, "pci_front (%s): pci_bar_init: Adding 64 bit PCI mem region: start=0x%p, end=0x%p as a full hook\n", state->name, (void *)(addr_t)pbar->addr, (void *)(addr_t)(pbar->addr + pbar->size)); @@ -318,7 +318,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { pci_front_write_mem, dev)<0) { - PrintError("pci_front (%s): pci_bar_init: failed to hook 64 bit region (0x%p, 0x%p)\n", + PrintError(info->vm_info, info, "pci_front (%s): pci_bar_init: failed to hook 64 bit region (0x%p, 0x%p)\n", state->name, (void *)(addr_t)pbar->addr, (void *)(addr_t)(pbar->addr + pbar->size - 1)); @@ -338,7 +338,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { pbar->size = (uint16_t)~PCI_IO_BASE(max_val) + 1; - PrintDebug("pci_front (%s): pci_bar_init: hooking ports 0x%x through 0x%x\n", + PrintDebug(info->vm_info, info, "pci_front (%s): pci_bar_init: hooking ports 0x%x through 0x%x\n", state->name, (uint32_t)pbar->addr, (uint32_t)pbar->addr + pbar->size - 1); for (i = 0; i < pbar->size; i++) { @@ -346,7 +346,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { pbar->addr + i, pci_front_read_port, pci_front_write_port)<0) { - PrintError("pci_front (%s): pci_bar_init: unabled to hook I/O port 0x%x\n",state->name, (unsigned)(pbar->addr+i)); + PrintError(info->vm_info, info, "pci_front (%s): pci_bar_init: unabled to hook I/O port 0x%x\n",state->name, (unsigned)(pbar->addr+i)); return -1; } } @@ -371,7 +371,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { pbar->addr = PCI_MEM32_BASE(bar_val); pbar->size = ~PCI_MEM32_BASE(max_val) + 1; - PrintDebug("pci_front (%s): pci_init_bar: adding 32 bit PCI mem region: start=0x%p, end=0x%p\n", + PrintDebug(info->vm_info, info, "pci_front (%s): pci_init_bar: adding 32 bit PCI mem region: start=0x%p, end=0x%p\n", state->name, (void *)(addr_t)pbar->addr, (void *)(addr_t)(pbar->addr + pbar->size)); @@ -383,7 +383,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { pci_front_read_mem, pci_front_write_mem, dev) < 0 ) { - PrintError("pci_front (%s): pci_init_bar: unable to hook 32 bit memory region 0x%p to 0x%p\n", + PrintError(info->vm_info, info, "pci_front (%s): pci_init_bar: unable to hook 32 bit memory region 0x%p to 0x%p\n", state->name, (void*)(pbar->addr), (void*)(pbar->addr+pbar->size-1)); return -1; } @@ -404,7 +404,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { pci_front_read_mem, pci_front_write_mem, dev) < 0 ) { - PrintError("pci_front (%s): pci_init_bar: unable to hook 24 bit memory region 0x%p to 0x%p\n", + PrintError(info->vm_info, info, "pci_front (%s): pci_init_bar: unable to hook 24 bit memory region 0x%p to 0x%p\n", state->name, (void*)(pbar->addr), (void*)(pbar->addr+pbar->size-1)); return -1; } @@ -422,10 +422,10 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { pbar->addr = PCI_MEM64_BASE_LO(bar_val); pbar->size = ~PCI_MEM64_BASE_LO(max_val) + 1; - PrintDebug("pci_front (%s): pci_bar_init: partial 64 bit update\n",state->name); + PrintDebug(info->vm_info, info, "pci_front (%s): pci_bar_init: partial 64 bit update\n",state->name); } else { - PrintError("pci_front (%s): pci_bar_init: invalid memory bar type\n",state->name); + PrintError(info->vm_info, info, "pci_front (%s): pci_bar_init: invalid memory bar type\n",state->name); return -1; } @@ -458,32 +458,32 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { struct pt_bar * pbar = &(state->bars[bar_num]); - PrintDebug("pci_front (%s): bar update: bar_num=%d, src=0x%x\n", state->name, bar_num, *src); - PrintDebug("pci_front (%s): the current bar has size=%u, type=%d, addr=%p, val=0x%x\n", + PrintDebug(info->vm_info, info, "pci_front (%s): bar update: bar_num=%d, src=0x%x\n", state->name, bar_num, *src); + PrintDebug(info->vm_info, info, "pci_front (%s): the current bar has size=%u, type=%d, addr=%p, val=0x%x\n", state->name, pbar->size, pbar->type, (void *)(addr_t)pbar->addr, pbar->val); if (pbar->type == PT_BAR_NONE) { - PrintDebug("pci_front (%s): bar update is to empty bar - ignored\n",state->name); + PrintDebug(info->vm_info, info, "pci_front (%s): bar update is to empty bar - ignored\n",state->name); return 0; } else if (pbar->type == PT_BAR_IO) { int i = 0; // unhook old ports - PrintDebug("pci_front (%s): unhooking I/O ports 0x%x through 0x%x\n", + PrintDebug(info->vm_info, info, "pci_front (%s): unhooking I/O ports 0x%x through 0x%x\n", state->name, (unsigned)(pbar->addr), (unsigned)(pbar->addr+pbar->size-1)); for (i = 0; i < pbar->size; i++) { if (v3_dev_unhook_io(dev, pbar->addr + i) == -1) { - PrintError("pci_front (%s): could not unhook previously hooked port.... 0x%x\n", + PrintError(info->vm_info, info, "pci_front (%s): could not unhook previously hooked port.... 0x%x\n", state->name, (uint32_t)pbar->addr + i); return -1; } } - PrintDebug("pci_front (%s): setting I/O Port range size=%d\n", state->name, pbar->size); + PrintDebug(info->vm_info, info, "pci_front (%s): setting I/O Port range size=%d\n", state->name, pbar->size); // // Not clear if this cooking is needed... why not trust @@ -498,9 +498,9 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { pbar->addr = PCI_IO_BASE(*src); - PrintDebug("pci_front (%s): cooked src=0x%x\n", state->name, *src); + PrintDebug(info->vm_info, info, "pci_front (%s): cooked src=0x%x\n", state->name, *src); - PrintDebug("pci_front (%s): rehooking I/O ports 0x%x through 0x%x\n", + PrintDebug(info->vm_info, info, "pci_front (%s): rehooking I/O ports 0x%x through 0x%x\n", state->name, (unsigned)(pbar->addr), (unsigned)(pbar->addr+pbar->size-1)); for (i = 0; i < pbar->size; i++) { @@ -508,7 +508,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { pbar->addr + i, pci_front_read_port, pci_front_write_port)<0) { - PrintError("pci_front (%s): unable to rehook port 0x%x\n",state->name, (unsigned)(pbar->addr+i)); + PrintError(info->vm_info, info, "pci_front (%s): unable to rehook port 0x%x\n",state->name, (unsigned)(pbar->addr+i)); return -1; } } @@ -516,7 +516,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { } else if (pbar->type == PT_BAR_MEM32) { if (v3_unhook_mem(dev->vm,V3_MEM_CORE_ANY,pbar->addr)<0) { - PrintError("pci_front (%s): unable to unhook 32 bit memory region starting at 0x%p\n", + PrintError(info->vm_info, info, "pci_front (%s): unable to unhook 32 bit memory region starting at 0x%p\n", state->name, (void*)(pbar->addr)); return -1; } @@ -529,11 +529,11 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { // Set reserved bits *src |= (pbar->val & ~PCI_MEM_MASK); - PrintDebug("pci_front (%s): cooked src=0x%x\n", state->name, *src); + PrintDebug(info->vm_info, info, "pci_front (%s): cooked src=0x%x\n", state->name, *src); pbar->addr = PCI_MEM32_BASE(*src); - PrintDebug("pci_front (%s): rehooking 32 bit memory region 0x%p through 0x%p\n", + PrintDebug(info->vm_info, info, "pci_front (%s): rehooking 32 bit memory region 0x%p through 0x%p\n", state->name, (void*)(pbar->addr), (void*)(pbar->addr + pbar->size - 1)); if (v3_hook_full_mem(dev->vm, @@ -543,7 +543,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { pci_front_read_mem, pci_front_write_mem, dev)<0) { - PrintError("pci_front (%s): unable to rehook 32 bit memory region 0x%p through 0x%p\n", + PrintError(info->vm_info, info, "pci_front (%s): unable to rehook 32 bit memory region 0x%p through 0x%p\n", state->name, (void*)(pbar->addr), (void*)(pbar->addr + pbar->size - 1)); return -1; } @@ -560,13 +560,13 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { // Temp storage, used when hi bar is written pbar->addr = PCI_MEM64_BASE_LO(*src); - PrintDebug("pci_front (%s): handled partial update for 64 bit memory region\n",state->name); + PrintDebug(info->vm_info, info, "pci_front (%s): handled partial update for 64 bit memory region\n",state->name); } else if (pbar->type == PT_BAR_MEM64_HI) { struct pt_bar * lo_vbar = &(state->bars[bar_num - 1]); if (v3_unhook_mem(dev->vm,V3_MEM_CORE_ANY,pbar->addr)<0) { - PrintError("pci_front (%s): unable to unhook 64 bit memory region starting at 0x%p\n", + PrintError(info->vm_info, info, "pci_front (%s): unable to unhook 64 bit memory region starting at 0x%p\n", state->name, (void*)(pbar->addr)); return -1; } @@ -581,7 +581,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { pbar->addr <<= 32; pbar->addr += lo_vbar->addr; - PrintDebug("pci_front (%s): rehooking 64 bit memory region 0x%p through 0x%p\n", + PrintDebug(info->vm_info, info, "pci_front (%s): rehooking 64 bit memory region 0x%p through 0x%p\n", state->name, (void*)(pbar->addr), (void*)(pbar->addr + pbar->size - 1)); if (v3_hook_full_mem(dev->vm, @@ -591,13 +591,13 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { pci_front_read_mem, pci_front_write_mem, dev)<0) { - PrintError("pci_front (%s): unable to rehook 64 bit memory region 0x%p through 0x%p\n", + PrintError(info->vm_info, info, "pci_front (%s): unable to rehook 64 bit memory region 0x%p through 0x%p\n", state->name, (void*)(pbar->addr), (void*)(pbar->addr + pbar->size - 1)); return -1; } } else { - PrintError("pci_front (%s): unhandled PCI bar type %d\n", state->name, pbar->type); + PrintError(info->vm_info, info, "pci_front (%s): unhandled PCI bar type %d\n", state->name, pbar->type); return -1; } @@ -616,20 +616,20 @@ static int pci_front_config_update(struct pci_device *pci_dev, uint_t reg_num, v pci_addr.reg = reg_num >> 2; - PrintDebug("pci_front (%s): configuration update: writing 0x%x bytes at offset 0x%x to host device 0x%p, bytes=0x", + PrintDebug(info->vm_info, info, "pci_front (%s): configuration update: writing 0x%x bytes at offset 0x%x to host device 0x%p, bytes=0x", state->name, length, pci_addr.value, state->host_dev); for (i = 0; i < length; i++) { - PrintDebug("%x", ((uint8_t *)src)[i]); + PrintDebug(info->vm_info, info, "%x", ((uint8_t *)src)[i]); } - PrintDebug("\n"); + PrintDebug(info->vm_info, info, "\n"); if (v3_host_dev_write_config(state->host_dev, pci_addr.value, src, length) != length) { - PrintError("pci_front (%s): configuration update: unable to write all bytes\n",state->name); + PrintError(info->vm_info, info, "pci_front (%s): configuration update: unable to write all bytes\n",state->name); return -1; } @@ -647,18 +647,18 @@ static int unhook_all_mem(struct pci_front_internal *state) for (bar_num=0;bar_num<6;bar_num++) { struct pt_bar * pbar = &(state->bars[bar_num]); - PrintDebug("pci_front (%s): unhooking for bar %d\n", state->name, bar_num); + PrintDebug(info->vm_info, info, "pci_front (%s): unhooking for bar %d\n", state->name, bar_num); if (pbar->type == PT_BAR_MEM32) { if (v3_unhook_mem(bus->vm,V3_MEM_CORE_ANY,pbar->addr)<0) { - PrintError("pci_front (%s): unable to unhook 32 bit memory region starting at 0x%p\n", + PrintError(info->vm_info, info, "pci_front (%s): unable to unhook 32 bit memory region starting at 0x%p\n", state->name, (void*)(pbar->addr)); return -1; } } else if (pbar->type == PT_BAR_MEM64_HI) { if (v3_unhook_mem(bus->vm,V3_MEM_CORE_ANY,pbar->addr)<0) { - PrintError("pci_front (%s): unable to unhook 64 bit memory region starting at 0x%p\n", + PrintError(info->vm_info, info, "pci_front (%s): unable to unhook 64 bit memory region starting at 0x%p\n", state->name, (void*)(pbar->addr)); return -1; } @@ -728,7 +728,7 @@ static int pci_front_free(struct pci_front_internal *state) V3_Free(state); - PrintDebug("pci_front (%s): freed\n",state->name); + PrintDebug(info->vm_info, info, "pci_front (%s): freed\n",state->name); return 0; } @@ -758,27 +758,27 @@ static int pci_front_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) if (!(dev_id = v3_cfg_val(cfg, "ID"))) { - PrintError("pci_front: no id given!\n"); + PrintError(info->vm_info, info, "pci_front: no id given!\n"); return -1; } if (!(bus_id = v3_cfg_val(cfg, "bus"))) { - PrintError("pci_front (%s): no bus given!\n",dev_id); + PrintError(info->vm_info, info, "pci_front (%s): no bus given!\n",dev_id); return -1; } if (!(url = v3_cfg_val(cfg, "hostdev"))) { - PrintError("pci_front (%s): no host device url given!\n",dev_id); + PrintError(info->vm_info, info, "pci_front (%s): no host device url given!\n",dev_id); return -1; } if (!(bus = v3_find_dev(vm,bus_id))) { - PrintError("pci_front (%s): cannot attach to bus %s\n",dev_id,bus_id); + PrintError(info->vm_info, info, "pci_front (%s): cannot attach to bus %s\n",dev_id,bus_id); return -1; } if (!(state = V3_Malloc(sizeof(struct pci_front_internal)))) { - PrintError("pci_front (%s): cannot allocate state for device\n",dev_id); + PrintError(info->vm_info, info, "pci_front (%s): cannot allocate state for device\n",dev_id); return -1; } @@ -788,26 +788,26 @@ static int pci_front_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) strncpy(state->name, dev_id, 32); if (!(dev = v3_add_device(vm, dev_id, &dev_ops, state))) { - PrintError("pci_front (%s): unable to add device\n",state->name); + PrintError(info->vm_info, info, "pci_front (%s): unable to add device\n",state->name); return -1; } if (!(state->host_dev=v3_host_dev_open(url,V3_BUS_CLASS_PCI,dev,vm))) { - PrintError("pci_front (%s): unable to attach to host device %s\n",state->name, url); + PrintError(info->vm_info, info, "pci_front (%s): unable to attach to host device %s\n",state->name, url); v3_remove_device(dev); return -1; } // fetch config space from the host if (pull_config(state,state->config_space)) { - PrintError("pci_front (%s): cannot initially configure device\n",state->name); + PrintError(info->vm_info, info, "pci_front (%s): cannot initially configure device\n",state->name); v3_remove_device(dev); return -1; } // setup virtual device for now if (setup_virt_pci_dev(vm,dev)<0) { - PrintError("pci_front (%s): cannot set up virtual pci device\n", state->name); + PrintError(info->vm_info, info, "pci_front (%s): cannot set up virtual pci device\n", state->name); v3_remove_device(dev); return -1; } @@ -815,7 +815,7 @@ static int pci_front_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) // We do not need to hook anything here since pci will call // us back via the bar_init functions - PrintDebug("pci_front (%s): inited and ready to be Potemkinized\n",state->name); + PrintDebug(info->vm_info, info, "pci_front (%s): inited and ready to be Potemkinized\n",state->name); return 0; diff --git a/palacios/src/devices/pci_passthrough.c b/palacios/src/devices/pci_passthrough.c index 102c6eb..dda9c80 100644 --- a/palacios/src/devices/pci_passthrough.c +++ b/palacios/src/devices/pci_passthrough.c @@ -192,7 +192,7 @@ static int pci_exp_rom_init(struct vm_device * dev, struct pt_dev_state * state) prom->addr = PCI_EXP_ROM_BASE(rom_val); prom->size = ~PCI_EXP_ROM_BASE(max_val) + 1; - PrintDebug("Adding 32 bit PCI mem region: start=%p, end=%p\n", + PrintDebug(VM_NONE, VCORE_NONE, "Adding 32 bit PCI mem region: start=%p, end=%p\n", (void *)(addr_t)prom->addr, (void *)(addr_t)(prom->addr + prom->size)); @@ -208,13 +208,13 @@ static int pci_exp_rom_init(struct vm_device * dev, struct pt_dev_state * state) // Initially the virtual location matches the physical ones memcpy(&(state->virt_exp_rom), &(state->phys_exp_rom), sizeof(struct pt_bar)); - PrintDebug("exp_rom_val=0x%x\n", rom_val); + PrintDebug(VM_NONE, VCORE_NONE, "exp_rom_val=0x%x\n", rom_val); - PrintDebug("phys exp_rom: addr=%p, size=%u\n", + PrintDebug(VM_NONE, VCORE_NONE, "phys exp_rom: addr=%p, size=%u\n", (void *)(addr_t)prom->addr, prom->size); - PrintDebug("virt exp_rom: addr=%p, size=%u\n", + PrintDebug(VM_NONE, VCORE_NONE, "virt exp_rom: addr=%p, size=%u\n", (void *)(addr_t)vrom->addr, vrom->size); @@ -239,7 +239,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { // should read from cached header pci_addr.reg = bar_base_reg + bar_num; - PrintDebug("PCI Address = 0x%x\n", pci_addr.value); + PrintDebug(VM_NONE, VCORE_NONE, "PCI Address = 0x%x\n", pci_addr.value); bar_val = pci_cfg_read32(pci_addr.value); pbar->val = bar_val; @@ -262,7 +262,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { // The right way to do this would be to change 'size' to the order (power of 2) of the region pbar->size += lo_pbar->size; - PrintDebug("Adding 64 bit PCI mem region: start=0x%p, end=0x%p\n", + PrintDebug(VM_NONE, VCORE_NONE, "Adding 64 bit PCI mem region: start=0x%p, end=0x%p\n", (void *)(addr_t)pbar->addr, (void *)(addr_t)(pbar->addr + pbar->size)); @@ -270,7 +270,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { if (v3_add_shadow_mem(dev->vm, V3_MEM_CORE_ANY, pbar->addr, pbar->addr + pbar->size - 1, pbar->addr) == -1) { - PrintError("Fail to insert shadow region (0x%p, 0x%p) -> 0x%p\n", + PrintError(VM_NONE, VCORE_NONE, "Fail to insert shadow region (0x%p, 0x%p) -> 0x%p\n", (void *)(addr_t)pbar->addr, (void *)(addr_t)(pbar->addr + pbar->size - 1), (void *)(addr_t)pbar->addr); @@ -298,12 +298,12 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { //v3_irq_restore(irq_state); - V3_Print("max_val = %x\n", max_val); + V3_Print(VM_NONE, VCORE_NONE, "max_val = %x\n", max_val); pbar->size = (uint16_t)~PCI_IO_BASE(max_val) + 1; - V3_Print("IO Bar with %d (%x) ports %x->%x\n", pbar->size, pbar->size, + V3_Print(VM_NONE, VCORE_NONE, "IO Bar with %d (%x) ports %x->%x\n", pbar->size, pbar->size, (uint32_t)pbar->addr, (uint32_t)pbar->addr + pbar->size); // setup a set of null io hooks // This allows the guest to do passthrough IO to these ports @@ -343,7 +343,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { pbar->addr = PCI_MEM32_BASE(bar_val); pbar->size = ~PCI_MEM32_BASE(max_val) + 1; - PrintDebug("Adding 32 bit PCI mem region: start=%p, end=%p\n", + PrintDebug(VM_NONE, VCORE_NONE, "Adding 32 bit PCI mem region: start=%p, end=%p\n", (void *)(addr_t)pbar->addr, (void *)(addr_t)(pbar->addr + pbar->size)); @@ -374,7 +374,7 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { pbar->size = ~PCI_MEM64_BASE_LO(max_val) + 1; } else { - PrintError("Invalid Memory bar type\n"); + PrintError(VM_NONE, VCORE_NONE, "Invalid Memory bar type\n"); return -1; } @@ -385,13 +385,13 @@ static int pci_bar_init(int bar_num, uint32_t * dst, void * private_data) { // Initially the virtual bars match the physical ones memcpy(&(state->virt_bars[bar_num]), &(state->phys_bars[bar_num]), sizeof(struct pt_bar)); - PrintDebug("bar_num=%d, bar_val=0x%x\n", bar_num, bar_val); + PrintDebug(VM_NONE, VCORE_NONE, "bar_num=%d, bar_val=0x%x\n", bar_num, bar_val); - PrintDebug("phys bar type=%d, addr=%p, size=%d\n", + PrintDebug(VM_NONE, VCORE_NONE, "phys bar type=%d, addr=%p, size=%d\n", pbar->type, (void *)(addr_t)pbar->addr, pbar->size); - PrintDebug("virt bar type=%d, addr=%p, size=%d\n", + PrintDebug(VM_NONE, VCORE_NONE, "virt bar type=%d, addr=%p, size=%d\n", state->virt_bars[bar_num].type, (void *)(addr_t)state->virt_bars[bar_num].addr, state->virt_bars[bar_num].size); @@ -412,7 +412,7 @@ static int pt_io_read(struct guest_info * core, uint16_t port, void * dst, uint_ } else if (length == 4) { *(uint32_t *)dst = v3_indw(pbar->addr + port_offset); } else { - PrintError("Invalid PCI passthrough IO Redirection size read\n"); + PrintError(core->vm_info, core, "Invalid PCI passthrough IO Redirection size read\n"); return -1; } @@ -431,7 +431,7 @@ static int pt_io_write(struct guest_info * core, uint16_t port, void * src, uint } else if (length == 4) { v3_outdw(pbar->addr + port_offset, *(uint32_t *)src); } else { - PrintError("Invalid PCI passthrough IO Redirection size write\n"); + PrintError(core->vm_info, core, "Invalid PCI passthrough IO Redirection size write\n"); return -1; } @@ -450,10 +450,10 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { struct pt_bar * pbar = &(state->phys_bars[bar_num]); struct pt_bar * vbar = &(state->virt_bars[bar_num]); - PrintDebug("Bar update: bar_num=%d, src=0x%x\n", bar_num, *src); - PrintDebug("vbar is size=%u, type=%d, addr=%p, val=0x%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "Bar update: bar_num=%d, src=0x%x\n", bar_num, *src); + PrintDebug(VM_NONE, VCORE_NONE, "vbar is size=%u, type=%d, addr=%p, val=0x%x\n", vbar->size, vbar->type, (void *)(addr_t)vbar->addr, vbar->val); - PrintDebug("pbar is size=%u, type=%d, addr=%p, val=0x%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "pbar is size=%u, type=%d, addr=%p, val=0x%x\n", pbar->size, pbar->type, (void *)(addr_t)pbar->addr, pbar->val); @@ -466,13 +466,13 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { // unhook old ports for (i = 0; i < vbar->size; i++) { if (v3_unhook_io_port(dev->vm, vbar->addr + i) == -1) { - PrintError("Could not unhook previously hooked port.... %d (0x%x)\n", + PrintError(VM_NONE, VCORE_NONE, "Could not unhook previously hooked port.... %d (0x%x)\n", (uint32_t)vbar->addr + i, (uint32_t)vbar->addr + i); return -1; } } - PrintDebug("Setting IO Port range size=%d\n", pbar->size); + PrintDebug(VM_NONE, VCORE_NONE, "Setting IO Port range size=%d\n", pbar->size); // clear the low bits to match the size *src &= ~(pbar->size - 1); @@ -482,9 +482,9 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { vbar->addr = PCI_IO_BASE(*src); - PrintDebug("Cooked src=0x%x\n", *src); + PrintDebug(VM_NONE, VCORE_NONE, "Cooked src=0x%x\n", *src); - PrintDebug("Rehooking passthrough IO ports starting at %d (0x%x)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Rehooking passthrough IO ports starting at %d (0x%x)\n", (uint32_t)vbar->addr, (uint32_t)vbar->addr); if (vbar->addr == pbar->addr) { @@ -504,7 +504,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { if (old_reg == NULL) { // uh oh... - PrintError("Could not find PCI Passthrough memory redirection region (addr=0x%x)\n", (uint32_t)vbar->addr); + PrintError(VM_NONE, VCORE_NONE, "Could not find PCI Passthrough memory redirection region (addr=0x%x)\n", (uint32_t)vbar->addr); return -1; } @@ -516,11 +516,11 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { // Set reserved bits *src |= (pbar->val & ~PCI_MEM_MASK); - PrintDebug("Cooked src=0x%x\n", *src); + PrintDebug(VM_NONE, VCORE_NONE, "Cooked src=0x%x\n", *src); vbar->addr = PCI_MEM32_BASE(*src); - PrintDebug("Adding pci Passthrough remapping: start=0x%x, size=%d, end=0x%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "Adding pci Passthrough remapping: start=0x%x, size=%d, end=0x%x\n", (uint32_t)vbar->addr, vbar->size, (uint32_t)vbar->addr + vbar->size); v3_add_shadow_mem(dev->vm, V3_MEM_CORE_ANY, @@ -546,7 +546,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { if (old_reg == NULL) { // uh oh... - PrintError("Could not find PCI Passthrough memory redirection region (addr=%p)\n", + PrintError(VM_NONE, VCORE_NONE, "Could not find PCI Passthrough memory redirection region (addr=%p)\n", (void *)(addr_t)vbar->addr); return -1; } @@ -563,14 +563,14 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { vbar->addr <<= 32; vbar->addr += lo_vbar->addr; - PrintDebug("Adding pci Passthrough remapping: start=%p, size=%p, end=%p\n", + PrintDebug(VM_NONE, VCORE_NONE, "Adding pci Passthrough remapping: start=%p, size=%p, end=%p\n", (void *)(addr_t)vbar->addr, (void *)(addr_t)vbar->size, (void *)(addr_t)(vbar->addr + vbar->size)); if (v3_add_shadow_mem(dev->vm, V3_MEM_CORE_ANY, vbar->addr, vbar->addr + vbar->size - 1, pbar->addr) == -1) { - PrintDebug("Fail to insert shadow region (%p, %p) -> %p\n", + PrintDebug(VM_NONE, VCORE_NONE, "Fail to insert shadow region (%p, %p) -> %p\n", (void *)(addr_t)vbar->addr, (void *)(addr_t)(vbar->addr + vbar->size - 1), (void *)(addr_t)pbar->addr); @@ -578,7 +578,7 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { } } else { - PrintError("Unhandled Pasthrough PCI Bar type %d\n", vbar->type); + PrintError(VM_NONE, VCORE_NONE, "Unhandled Pasthrough PCI Bar type %d\n", vbar->type); return -1; } @@ -619,9 +619,9 @@ static int pt_exp_rom_write(struct pci_device * pci_dev, uint32_t * src, void * struct pt_bar * prom = &(state->phys_exp_rom); struct pt_bar * vrom = &(state->virt_exp_rom); - PrintDebug("exp_rom update: src=0x%x\n", *src); - PrintDebug("vrom is size=%u, addr=0x%x, val=0x%x\n", vrom->size, (uint32_t)vrom->addr, vrom->val); - PrintDebug("prom is size=%u, addr=0x%x, val=0x%x\n", prom->size, (uint32_t)prom->addr, prom->val); + PrintDebug(VM_NONE, VCORE_NONE, "exp_rom update: src=0x%x\n", *src); + PrintDebug(VM_NONE, VCORE_NONE, "vrom is size=%u, addr=0x%x, val=0x%x\n", vrom->size, (uint32_t)vrom->addr, vrom->val); + PrintDebug(VM_NONE, VCORE_NONE, "prom is size=%u, addr=0x%x, val=0x%x\n", prom->size, (uint32_t)prom->addr, prom->val); // only remove old mapping if present, I.E. if the rom was enabled previously if ((vrom->val & 0x1) == 0x1) { @@ -629,7 +629,7 @@ static int pt_exp_rom_write(struct pci_device * pci_dev, uint32_t * src, void * if (old_reg == NULL) { // uh oh... - PrintError("Could not find PCI Passthrough exp_rom_base redirection region (addr=0x%x)\n", (uint32_t)vrom->addr); + PrintError(VM_NONE, VCORE_NONE, "Could not find PCI Passthrough exp_rom_base redirection region (addr=0x%x)\n", (uint32_t)vrom->addr); return -1; } @@ -642,18 +642,18 @@ static int pt_exp_rom_write(struct pci_device * pci_dev, uint32_t * src, void * // Set reserved bits *src |= (prom->val & ~PCI_EXP_ROM_MASK); - PrintDebug("Cooked src=0x%x\n", *src); + PrintDebug(VM_NONE, VCORE_NONE, "Cooked src=0x%x\n", *src); vrom->addr = PCI_EXP_ROM_BASE(*src); if ((prom->val & 0x1) == 0x1) { - PrintDebug("Adding pci Passthrough exp_rom_base remapping: start=0x%x, size=%u, end=0x%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "Adding pci Passthrough exp_rom_base remapping: start=0x%x, size=%u, end=0x%x\n", (uint32_t)vrom->addr, vrom->size, (uint32_t)vrom->addr + vrom->size); if (v3_add_shadow_mem(dev->vm, V3_MEM_CORE_ANY, vrom->addr, vrom->addr + vrom->size - 1, prom->addr) == -1) { - PrintError("Failed to remap pci exp_rom: start=0x%x, size=%u, end=0x%x\n", + PrintError(VM_NONE, VCORE_NONE, "Failed to remap pci exp_rom: start=0x%x, size=%u, end=0x%x\n", (uint32_t)vrom->addr, vrom->size, (uint32_t)vrom->addr + vrom->size); return -1; } @@ -677,7 +677,7 @@ static int find_real_pci_dev(uint16_t vendor_id, uint16_t device_id, struct pt_d } __attribute__((packed)); } __attribute__((packed)) pci_hdr = {0}; - //PrintDebug("Scanning PCI busses for vendor=%x, device=%x\n", vendor_id, device_id); + //PrintDebug(VM_NONE, VCORE_NONE, "Scanning PCI busses for vendor=%x, device=%x\n", vendor_id, device_id); for (i = 0, pci_addr.bus = 0; i < PCI_BUS_MAX; i++, pci_addr.bus++) { for (j = 0, pci_addr.dev = 0; j < PCI_DEV_MAX; j++, pci_addr.dev++) { for (k = 0, pci_addr.func = 0; k < PCI_FN_MAX; k++, pci_addr.func++) { @@ -685,7 +685,7 @@ static int find_real_pci_dev(uint16_t vendor_id, uint16_t device_id, struct pt_d v3_outdw(PCI_CFG_ADDR, pci_addr.value); pci_hdr.value = v3_indw(PCI_CFG_DATA); - //PrintDebug("\bus=%d, tvendor=%x, device=%x\n", pci_addr.bus, pci_hdr.vendor, pci_hdr.device); + //PrintDebug(VM_NONE, VCORE_NONE, "\bus=%d, tvendor=%x, device=%x\n", pci_addr.bus, pci_hdr.vendor, pci_hdr.device); if ((pci_hdr.vendor == vendor_id) && (pci_hdr.device == device_id)) { uint32_t * cfg_space = (uint32_t *)&state->real_hdr; @@ -698,7 +698,7 @@ static int find_real_pci_dev(uint16_t vendor_id, uint16_t device_id, struct pt_d } - PrintDebug("Found device %x:%x (bus=%d, dev=%d, func=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Found device %x:%x (bus=%d, dev=%d, func=%d)\n", vendor_id, device_id, pci_addr.bus, pci_addr.dev, pci_addr.func); @@ -780,14 +780,14 @@ static int passthrough_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { char * dev_id = v3_cfg_val(cfg, "ID"); if (!state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } memset(state, 0, sizeof(struct pt_dev_state)); if (!pci) { - PrintError("Could not find PCI device\n"); + PrintError(vm, VCORE_NONE, "Could not find PCI device\n"); return -1; } @@ -798,7 +798,7 @@ static int passthrough_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { dev = v3_add_device(vm, dev_id, &dev_ops, state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(state); return -1; } @@ -807,7 +807,7 @@ static int passthrough_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { if (find_real_pci_dev(atox(v3_cfg_val(cfg, "vendor_id")), atox(v3_cfg_val(cfg, "device_id")), state) == -1) { - PrintError("Could not find PCI Device %s:%s\n", + PrintError(vm, VCORE_NONE, "Could not find PCI Device %s:%s\n", v3_cfg_val(cfg, "vendor_id"), v3_cfg_val(cfg, "device_id")); v3_remove_device(dev); diff --git a/palacios/src/devices/piix3.c b/palacios/src/devices/piix3.c index 0143de5..e1709d6 100644 --- a/palacios/src/devices/piix3.c +++ b/palacios/src/devices/piix3.c @@ -383,7 +383,7 @@ static int raise_pci_irq(struct pci_device * pci_dev, void * dev_data, struct v3 irq.private_data = vec->private_data; /* - PrintError("Raising PCI dev %d intr %d via IOAPIC as IRQ %d and via PIRQ as IRQ %d on VM %p\n", + PrintError(info->vm_info, info, "Raising PCI dev %d intr %d via IOAPIC as IRQ %d and via PIRQ as IRQ %d on VM %p\n", pci_dev->dev_num, pci_dev->config_header.intr_pin, 16+irq_index, piix3_cfg->pirq_rc[irq_index], piix3->vm); @@ -394,7 +394,7 @@ static int raise_pci_irq(struct pci_device * pci_dev, void * dev_data, struct v3 if (piix3_cfg->pirq_rc[irq_index] < 16) { irq.irq = piix3_cfg->pirq_rc[irq_index] & 0xf; - // V3_Print("Raising PIIX IRQ %d\n", irq.irq); + // V3_Print(info->vm_info, info, "Raising PIIX IRQ %d\n", irq.irq); v3_raise_acked_irq(piix3->vm, irq); } else { // not an error @@ -404,7 +404,7 @@ static int raise_pci_irq(struct pci_device * pci_dev, void * dev_data, struct v3 // mptable (ioapic, pins 16->19 are used for PCI0) // ideally this would check to verify that an ioapic is actually available irq.irq = (irq_index + 1) + 16; - // V3_Print("Raising PIIX IRQ (#2) %d\n", irq.irq); + // V3_Print(info->vm_info, info, "Raising PIIX IRQ (#2) %d\n", irq.irq); v3_raise_acked_irq(piix3->vm, irq); @@ -423,7 +423,7 @@ static int lower_pci_irq(struct pci_device * pci_dev, void * dev_data, struct v3 irq.ack = vec->ack; irq.private_data = vec->private_data; - // PrintError("Lowering PCI IRQ %d\n", piix3_cfg->pirq_rc[irq_index]); + // PrintError(info->vm_info, info, "Lowering PCI IRQ %d\n", piix3_cfg->pirq_rc[irq_index]); // First, lower the pin on the ioapic irq.irq = (irq_index + 1) + 16; @@ -473,7 +473,7 @@ static int setup_pci(struct v3_southbridge * piix3) { "PIIX3", bars, NULL, NULL, NULL, NULL, piix3); if (pci_dev == NULL) { - PrintError("Could not register PCI Device for PIIX3\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not register PCI Device for PIIX3\n"); return -1; } @@ -498,12 +498,12 @@ static int piix3_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { char * dev_id = v3_cfg_val(cfg, "ID"); if (!piix3) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } if (!pci) { - PrintError("Could not find PCI device\n"); + PrintError(vm, VCORE_NONE, "Could not find PCI device\n"); return -1; } @@ -514,12 +514,12 @@ static int piix3_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { dev = v3_add_device(vm, dev_id, &dev_ops, piix3); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(piix3); return -1; } - PrintDebug("Created PIIX3\n"); + PrintDebug(vm, VCORE_NONE, "Created PIIX3\n"); if (setup_pci(piix3) == -1) { v3_remove_device(dev); diff --git a/palacios/src/devices/ramdisk.c b/palacios/src/devices/ramdisk.c index c8f9639..9fd78a8 100644 --- a/palacios/src/devices/ramdisk.c +++ b/palacios/src/devices/ramdisk.c @@ -35,10 +35,10 @@ struct disk_state { static int read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data) { struct disk_state * disk = (struct disk_state *)private_data; - PrintDebug("Reading %d bytes from %p to %p\n", (uint32_t)num_bytes, (uint8_t *)(disk->disk_image + lba), buf); + PrintDebug(VM_NONE, VCORE_NONE, "Reading %d bytes from %p to %p\n", (uint32_t)num_bytes, (uint8_t *)(disk->disk_image + lba), buf); if (lba + num_bytes > disk->capacity) { - PrintError("read out of bounds: lba=%llu (%p), num_bytes=%llu, capacity=%d (%p)\n", + PrintError(VM_NONE, VCORE_NONE, "read out of bounds: lba=%llu (%p), num_bytes=%llu, capacity=%d (%p)\n", lba, (void *)(addr_t)lba, num_bytes, disk->capacity, (void *)(addr_t)disk->capacity); return -1; } @@ -52,10 +52,10 @@ static int read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_ static int write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data) { struct disk_state * disk = (struct disk_state *)private_data; - PrintDebug("Writing %d bytes from %p to %p\n", (uint32_t)num_bytes, buf, (uint8_t *)(disk->disk_image + lba)); + PrintDebug(VM_NONE, VCORE_NONE, "Writing %d bytes from %p to %p\n", (uint32_t)num_bytes, buf, (uint8_t *)(disk->disk_image + lba)); if (lba + num_bytes > disk->capacity) { - PrintError("write out of bounds: lba=%llu (%p), num_bytes=%llu, capacity=%d (%p)\n", + PrintError(VM_NONE, VCORE_NONE, "write out of bounds: lba=%llu (%p), num_bytes=%llu, capacity=%d (%p)\n", lba, (void *)(addr_t)lba, num_bytes, disk->capacity, (void *)(addr_t)disk->capacity); return -1; } @@ -70,7 +70,7 @@ static int write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private static uint64_t get_capacity(void * private_data) { struct disk_state * disk = (struct disk_state *)private_data; - PrintDebug("Querying RAMDISK capacity %d\n", + PrintDebug(VM_NONE, VCORE_NONE, "Querying RAMDISK capacity %d\n", (uint32_t)(disk->capacity)); return disk->capacity; @@ -107,14 +107,14 @@ static int disk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { v3_cfg_tree_t * frontend_cfg = v3_cfg_subtree(cfg, "frontend"); if (!filename) { - PrintError("Missing filename (%s) for %s\n", filename, dev_id); + PrintError(vm, VCORE_NONE, "Missing filename (%s) for %s\n", filename, dev_id); return -1; } file = v3_cfg_get_file(vm, filename); if (!file) { - PrintError("Invalid ramdisk file: %s\n", filename); + PrintError(vm, VCORE_NONE, "Invalid ramdisk file: %s\n", filename); return -1; } @@ -122,7 +122,7 @@ static int disk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { disk = (struct disk_state *)V3_Malloc(sizeof(struct disk_state)); if (!disk) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -130,14 +130,14 @@ static int disk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { disk->disk_image = file->data; disk->capacity = file->size; - PrintDebug("Registering RAMDISK at %p (size=%d)\n", + PrintDebug(vm, VCORE_NONE, "Registering RAMDISK at %p (size=%d)\n", (void *)file->data, (uint32_t)file->size); struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, disk); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(disk); return -1; } @@ -145,7 +145,7 @@ static int disk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"), &blk_ops, frontend_cfg, disk) == -1) { - PrintError("Could not connect %s to frontend %s\n", + PrintError(vm, VCORE_NONE, "Could not connect %s to frontend %s\n", dev_id, v3_cfg_val(frontend_cfg, "tag")); v3_remove_device(dev); return -1; diff --git a/palacios/src/devices/rtl8139.c b/palacios/src/devices/rtl8139.c index 18e966a..aadfcea 100644 --- a/palacios/src/devices/rtl8139.c +++ b/palacios/src/devices/rtl8139.c @@ -588,7 +588,7 @@ static inline void rtl8139_update_irq(struct rtl8139_state * nic_state) { } static void prom9346_decode_command(struct EEprom9346 * eeprom, uint8_t command) { - PrintDebug("RTL8139: eeprom command 0x%02x\n", command); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: eeprom command 0x%02x\n", command); switch (command & Chip9346_op_mask) { case Chip9346_op_read: @@ -598,7 +598,7 @@ static void prom9346_decode_command(struct EEprom9346 * eeprom, uint8_t command) eeprom->eedo = 0; eeprom->tick = 0; eeprom->mode = Chip9346_data_read; - PrintDebug("RTL8139: eeprom read from address 0x%02x data=0x%04x\n", + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: eeprom read from address 0x%02x data=0x%04x\n", eeprom->address, eeprom->output); } break; @@ -609,7 +609,7 @@ static void prom9346_decode_command(struct EEprom9346 * eeprom, uint8_t command) eeprom->input = 0; eeprom->tick = 0; eeprom->mode = Chip9346_none; /* Chip9346_data_write */ - PrintDebug("RTL8139: eeprom begin write to address 0x%02x\n", + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: eeprom begin write to address 0x%02x\n", eeprom->address); } break; @@ -617,13 +617,13 @@ static void prom9346_decode_command(struct EEprom9346 * eeprom, uint8_t command) eeprom->mode = Chip9346_none; switch (command & Chip9346_op_ext_mask) { case Chip9346_op_write_enable: - PrintDebug("RTL8139: eeprom write enabled\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: eeprom write enabled\n"); break; case Chip9346_op_write_all: - PrintDebug("RTL8139: eeprom begin write all\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: eeprom begin write all\n"); break; case Chip9346_op_write_disable: - PrintDebug("RTL8139: eeprom write disabled\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: eeprom write disabled\n"); break; } break; @@ -635,7 +635,7 @@ static void prom9346_shift_clock(struct EEprom9346 * eeprom) { ++ eeprom->tick; - PrintDebug("eeprom: tick %d eedi=%d eedo=%d\n", eeprom->tick, eeprom->eedi, eeprom->eedo); + PrintDebug(VM_NONE, VCORE_NONE, "eeprom: tick %d eedi=%d eedo=%d\n", eeprom->tick, eeprom->eedi, eeprom->eedo); switch (eeprom->mode) { case Chip9346_enter_command_mode: @@ -643,7 +643,7 @@ static void prom9346_shift_clock(struct EEprom9346 * eeprom) { eeprom->mode = Chip9346_read_command; eeprom->tick = 0; eeprom->input = 0; - PrintDebug("eeprom: +++ synchronized, begin command read\n"); + PrintDebug(VM_NONE, VCORE_NONE, "eeprom: +++ synchronized, begin command read\n"); } break; @@ -666,7 +666,7 @@ static void prom9346_shift_clock(struct EEprom9346 * eeprom) { eeprom->input = 0; eeprom->tick = 0; - PrintDebug("eeprom: +++ end of read, awaiting next command\n"); + PrintDebug(VM_NONE, VCORE_NONE, "eeprom: +++ end of read, awaiting next command\n"); #else // original behaviour ++eeprom->address; @@ -683,7 +683,7 @@ static void prom9346_shift_clock(struct EEprom9346 * eeprom) { case Chip9346_data_write: eeprom->input = (eeprom->input << 1) | (bit & 1); if (eeprom->tick == 16) { - PrintDebug("RTL8139: eeprom write to address 0x%02x data=0x%04x\n", + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: eeprom write to address 0x%02x data=0x%04x\n", eeprom->address, eeprom->input); eeprom->contents[eeprom->address] = eeprom->input; @@ -701,7 +701,7 @@ static void prom9346_shift_clock(struct EEprom9346 * eeprom) { { eeprom->contents[i] = eeprom->input; } - PrintDebug("RTL8139: eeprom filled with data=0x%04x\n", + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: eeprom filled with data=0x%04x\n", eeprom->input); eeprom->mode = Chip9346_enter_command_mode; @@ -736,7 +736,7 @@ static void prom9346_set_wire(struct rtl8139_state * nic_state, eeprom->eesk = eesk; eeprom->eedi = eedi; - PrintDebug("eeprom: +++ wires CS=%d SK=%d DI=%d DO=%d\n", + PrintDebug(VM_NONE, VCORE_NONE, "eeprom: +++ wires CS=%d SK=%d DI=%d DO=%d\n", eeprom->eecs, eeprom->eesk, eeprom->eedi, eeprom->eedo); if (old_eecs == 0 && eecs) { @@ -746,11 +746,11 @@ static void prom9346_set_wire(struct rtl8139_state * nic_state, eeprom->output = 0; eeprom->mode = Chip9346_enter_command_mode; - PrintDebug("=== eeprom: begin access, enter command mode\n"); + PrintDebug(VM_NONE, VCORE_NONE, "=== eeprom: begin access, enter command mode\n"); } if (eecs == 0) { - PrintDebug("=== eeprom: end access\n"); + PrintDebug(VM_NONE, VCORE_NONE, "=== eeprom: end access\n"); return; } @@ -772,7 +772,7 @@ static void rtl8139_reset(struct rtl8139_state *nic_state) { struct rtl8139_regs *regs = &(nic_state->regs); int i; - PrintDebug("Rtl8139: Reset\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Rtl8139: Reset\n"); /* restore MAC address */ memcpy(regs->id, nic_state->mac, ETH_ALEN); @@ -835,7 +835,7 @@ static void rtl8139_reset(struct rtl8139_state *nic_state) { static void rtl8139_9346cr_write(struct rtl8139_state * nic_state, uint32_t val) { val &= 0xff; - PrintDebug("RTL8139: 9346CR write val=0x%02x\n", val); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: 9346CR write val=0x%02x\n", val); /* mask unwriteable bits */ val = SET_MASKED(val, 0x31, nic_state->regs.cmd9346); @@ -872,7 +872,7 @@ static uint32_t rtl8139_9346cr_read(struct rtl8139_state * nic_state) { } } - PrintDebug("RTL8139: 9346CR read val=0x%02x\n", ret); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: 9346CR read val=0x%02x\n", ret); return ret; } @@ -902,7 +902,7 @@ static void rtl8139_rxbuf_write(struct rtl8139_state * nic_state, wrap = MOD2(regs->cbr + size, nic_state->rx_bufsize); if (wrap && !(nic_state->rx_bufsize < 64*1024 && rtl8139_rxwrap(nic_state))){ - PrintDebug("RTL8139: rx packet wrapped in buffer at %d\n", size-wrap); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: rx packet wrapped in buffer at %d\n", size-wrap); if (size > wrap){ memcpy((void *)(host_rxbuf + regs->cbr), buf, size-wrap); @@ -957,51 +957,51 @@ static int rx_one_pkt(struct rtl8139_state * nic_state, uint8_t bcast_addr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; if (regs->rcr & AcceptAllPhys) { - PrintDebug("RTL8139: packet received in promiscuous mode\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: packet received in promiscuous mode\n"); } else { if (!memcmp(pkt, bcast_addr, 6)) { if (!(regs->rcr & AcceptBroadcast)){ - PrintDebug("RTL8139: broadcast packet rejected\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: broadcast packet rejected\n"); return -1; } header |= Rx_Broadcast; - PrintDebug("RTL8139: broadcast packet received\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: broadcast packet received\n"); } else if (pkt[0] & 0x01) { // multicast if (!(regs->rcr & AcceptMulticast)){ - PrintDebug("RTL8139: multicast packet rejected\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: multicast packet rejected\n"); return -1; } int mcast_idx = compute_mcast_idx(pkt); if (!(regs->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7)))){ - PrintDebug("RTL8139: multicast address mismatch\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: multicast address mismatch\n"); return -1; } header |= Rx_Multicast; - PrintDebug("RTL8139: multicast packet received\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: multicast packet received\n"); } else if (!compare_ethaddr(regs->id, pkt)){ if (!(regs->rcr & AcceptMyPhys)){ - PrintDebug("RTL8139: rejecting physical address matching packet\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: rejecting physical address matching packet\n"); return -1; } header |= Rx_Physical; - PrintDebug("RTL8139: physical address matching packet received\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: physical address matching packet received\n"); } else { - PrintDebug("RTL8139: unknown packet\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: unknown packet\n"); return -1; } } if(1){ - PrintDebug("RTL8139: in ring Rx mode\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: in ring Rx mode\n"); int avail = MOD2(rxbufsize + regs->capr - regs->cbr, rxbufsize); if (avail != 0 && len + 8 >= avail){ - PrintError("rx overflow: rx buffer length %d head 0x%04x read 0x%04x === available 0x%04x need 0x%04x\n", + PrintError(VM_NONE, VCORE_NONE, "rx overflow: rx buffer length %d head 0x%04x read 0x%04x === available 0x%04x need 0x%04x\n", rxbufsize, regs->cbr, regs->capr, avail, len + 8); regs->isr |= ISR_Rxovw; @@ -1025,7 +1025,7 @@ static int rx_one_pkt(struct rtl8139_state * nic_state, // correct buffer write pointer regs->cbr = MOD2((regs->cbr + 3) & ~0x3, rxbufsize); - PrintDebug("RTL8139: received: rx buffer length %d CBR: 0x%04x CAPR: 0x%04x\n", + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: received: rx buffer length %d CBR: 0x%04x CAPR: 0x%04x\n", rxbufsize, regs->cbr, regs->capr); } @@ -1043,7 +1043,7 @@ static int rtl8139_rx(uint8_t * pkt, uint32_t len, void * private_data) { struct rtl8139_state *nic_state = (struct rtl8139_state *)private_data; if (!rtl8139_receiver_enabled(nic_state)){ - PrintDebug("RTL8139: receiver disabled\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: receiver disabled\n"); nic_state->statistic.rx_dropped ++; return 0; @@ -1060,7 +1060,7 @@ static int rtl8139_rx(uint8_t * pkt, uint32_t len, void * private_data) { } static void rtl8139_rcr_write(struct rtl8139_state * nic_state, uint32_t val) { - PrintDebug("RTL8139: RCR write val=0x%08x\n", val); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: RCR write val=0x%08x\n", val); val = SET_MASKED(val, 0xf0fc0040, nic_state->regs.rcr); nic_state->regs.rcr = val; @@ -1086,7 +1086,7 @@ static void rtl8139_rcr_write(struct rtl8139_state * nic_state, uint32_t val) { // reset buffer size and read/write pointers rtl8139_reset_rxbuf(nic_state, 8192 << ((nic_state->regs.rcr >> 11) & 0x3)); - PrintDebug("RTL8139: RCR write reset buffer size to %d\n", nic_state->rx_bufsize); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: RCR write reset buffer size to %d\n", nic_state->rx_bufsize); } @@ -1101,7 +1101,7 @@ static int rtl8139_config_writeable(struct vm_device *dev) return 1; } - PrintDebug("RTL8139: Configuration registers are unwriteable\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: Configuration registers are unwriteable\n"); return 0; } @@ -1119,11 +1119,11 @@ static int rxbufempty(struct rtl8139_state * nic_state){ unread = MOD2(regs->cbr + nic_state->rx_bufsize - regs->capr, nic_state->rx_bufsize); if (unread != 0){ - PrintDebug("RTL8139: receiver buffer data available 0x%04x\n", unread); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: receiver buffer data available 0x%04x\n", unread); return 0; } - PrintDebug("RTL8139: receiver buffer is empty\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: receiver buffer is empty\n"); return 1; } @@ -1131,17 +1131,17 @@ static int rxbufempty(struct rtl8139_state * nic_state){ static void rtl8139_cmd_write(struct rtl8139_state * nic_state, uint32_t val){ val &= 0xff; - PrintDebug("RTL8139: Cmd write val=0x%08x\n", val); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: Cmd write val=0x%08x\n", val); if (val & CMD_Rst){ - PrintDebug("RTL8139: Cmd reset\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: Cmd reset\n"); rtl8139_reset(nic_state); } if (val & CMD_Re){ - PrintDebug("RTL8139: Cmd enable receiver\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: Cmd enable receiver\n"); } if (val & CMD_Te){ - PrintDebug("RTL8139: Cmd enable transmitter\n"); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: Cmd enable transmitter\n"); } val = SET_MASKED(val, 0xe3, nic_state->regs.cmd); @@ -1157,19 +1157,19 @@ static int tx_one_packet(struct rtl8139_state * nic_state, int descriptor){ addr_t pkt_gpa = 0, hostva = 0; if (!transmitter_enabled(nic_state)){ - PrintError("RTL8139: fail to send from descriptor %d: transmitter disabled\n", descriptor); + PrintError(VM_NONE, VCORE_NONE, "RTL8139: fail to send from descriptor %d: transmitter disabled\n", descriptor); return 0; } if (regs->tsd[descriptor] & TSD_Own){ - PrintError("RTL8139: fail to send from descriptor %d: owned by host\n", descriptor); + PrintError(VM_NONE, VCORE_NONE, "RTL8139: fail to send from descriptor %d: owned by host\n", descriptor); return 0; } txsize = regs->tsd[descriptor] & 0x1fff; pkt_gpa = (addr_t) regs->tsad[descriptor]; - PrintDebug("RTL8139: sending %d bytes from guest memory at 0x%08x\n", txsize, regs->tsad[descriptor]); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: sending %d bytes from guest memory at 0x%08x\n", txsize, regs->tsad[descriptor]); v3_gpa_to_hva(&(nic_state->vm->cores[0]), (addr_t)pkt_gpa, &hostva); pkt = (uchar_t *)hostva; @@ -1179,15 +1179,15 @@ static int tx_one_packet(struct rtl8139_state * nic_state, int descriptor){ #endif if (TxLoopBack == (regs->tcr & TxLoopBack)){ /* loopback test */ - PrintDebug(("RTL8139: transmit loopback mode\n")); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: transmit loopback mode\n"); rx_one_pkt(nic_state, pkt, txsize); } else{ if (nic_state->net_ops->send(pkt, txsize, nic_state->backend_data) == 0){ - PrintDebug("RTL8139: Sent %d bytes from descriptor %d\n", txsize, descriptor); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: Sent %d bytes from descriptor %d\n", txsize, descriptor); nic_state->statistic.tx_pkts ++; nic_state->statistic.tx_bytes += txsize; } else { - PrintError("Rtl8139: Sending packet error: 0x%p\n", pkt); + PrintError(VM_NONE, VCORE_NONE, "Rtl8139: Sending packet error: 0x%p\n", pkt); nic_state->statistic.tx_dropped ++; } } @@ -1206,12 +1206,12 @@ static void rtl8139_tsd_write(struct rtl8139_state * nic_state, uint8_t descriptor, uint32_t val){ if (!transmitter_enabled(nic_state)){ - PrintDebug("RTL8139: TxStatus write val=0x%08x descriptor=%d, Transmitter not enabled\n", val, descriptor); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: TxStatus write val=0x%08x descriptor=%d, Transmitter not enabled\n", val, descriptor); return; } - PrintDebug("RTL8139: TSD write val=0x%08x descriptor=%d\n", val, descriptor); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: TSD write val=0x%08x descriptor=%d\n", val, descriptor); // mask read-only bits val &= ~0xff00c000; @@ -1247,7 +1247,7 @@ static uint16_t rtl8139_txsad_read(struct rtl8139_state * nic_state){ |((regs->tsd[1] & TSD_Own)?TSAD_OWN1:0) |((regs->tsd[0] & TSD_Own)?TSAD_OWN0:0) ; - PrintDebug("RTL8139: txsad read val=0x%04x\n", (int)ret); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: txsad read val=0x%04x\n", (int)ret); return ret; } @@ -1255,7 +1255,7 @@ static uint16_t rtl8139_txsad_read(struct rtl8139_state * nic_state){ static inline void rtl8139_isr_write(struct rtl8139_state * nic_state, uint32_t val) { struct rtl8139_regs *regs = &(nic_state->regs); - PrintDebug("RTL8139: ISR write val=0x%04x\n", val); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: ISR write val=0x%04x\n", val); uint16_t newisr = regs->isr & ~val; @@ -1283,7 +1283,7 @@ static int rtl8139_mmio_write(struct guest_info * core, memcpy(&val, src, length); - PrintDebug("rtl8139 mmio write: addr:0x%x (%u bytes): 0x%x\n", (int)guest_addr, length, val); + PrintDebug(VM_NONE, VCORE_NONE, "rtl8139 mmio write: addr:0x%x (%u bytes): 0x%x\n", (int)guest_addr, length, val); switch(idx) { case RTL8139_IDR0 ... RTL8139_IDR0 + 5: @@ -1327,7 +1327,7 @@ static int rtl8139_mmio_write(struct guest_info * core, /* this value is off by 16 */ nic_state->regs.capr = MOD2(val + 0x10, nic_state->rx_bufsize); - PrintDebug("RTL 8139: CAPR write: rx buffer length %d head 0x%04x read 0x%04x\n", + PrintDebug(VM_NONE, VCORE_NONE, "RTL 8139: CAPR write: rx buffer length %d head 0x%04x read 0x%04x\n", nic_state->rx_bufsize, nic_state->regs.cbr, nic_state->regs.capr); } break; @@ -1336,7 +1336,7 @@ static int rtl8139_mmio_write(struct guest_info * core, break; case RTL8139_IMR: { - PrintDebug("RTL8139: IMR write val=0x%04x\n", val); + PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: IMR write val=0x%04x\n", val); /* mask unwriteable bits */ val = SET_MASKED(val, 0x1e00, nic_state->regs.imr); @@ -1438,7 +1438,7 @@ static int rtl8139_mmio_write(struct guest_info * core, nic_state->regs.config5 = val & 0xff; break; default: - PrintDebug("rtl8139 write error: invalid port: 0x%x\n", idx); + PrintDebug(VM_NONE, VCORE_NONE, "rtl8139 write error: invalid port: 0x%x\n", idx); } return length; @@ -1602,7 +1602,7 @@ static int rtl8139_mmio_read(struct guest_info * core, memcpy(dst, &val, length); - PrintDebug("rtl8139 mmio read: port:0x%x (%u bytes): 0x%x\n", (int)guest_addr, length, val); + PrintDebug(VM_NONE, VCORE_NONE, "rtl8139 mmio read: port:0x%x (%u bytes): 0x%x\n", (int)guest_addr, length, val); return length; } @@ -1628,7 +1628,7 @@ static int rtl8139_ioport_read(struct guest_info * core, static int rtl8139_init_state(struct rtl8139_state *nic_state) { - PrintDebug("rtl8139: init_state\n"); + PrintDebug(VM_NONE, VCORE_NONE, "rtl8139: init_state\n"); nic_state->regs.tsd[0] = nic_state->regs.tsd[1] = nic_state->regs.tsd[2] = nic_state->regs.tsd[3] = TSD_Own; @@ -1657,7 +1657,7 @@ static inline int rtl8139_start_device(struct rtl8139_state * nic_state) { } static int rtl8139_stop_device(struct rtl8139_state * nic_state) { - PrintDebug("rtl8139: stop device\n"); + PrintDebug(VM_NONE, VCORE_NONE, "rtl8139: stop device\n"); nic_state->regs.cmd &= ~(CMD_Re | CMD_Te); @@ -1672,24 +1672,24 @@ static int rtl8139_hook_iospace(struct rtl8139_state * nic_state, int i; if (base_addr <= 0){ - PrintError("In RTL8139: Fail to Hook IO Space, base address 0x%x\n", (int) base_addr); + PrintError(VM_NONE, VCORE_NONE, "In RTL8139: Fail to Hook IO Space, base address 0x%x\n", (int) base_addr); return -1; } if (type == PCI_BAR_IO){ - PrintDebug("In RTL8139: Hook IO ports starting from %x, size %d\n", (int) base_addr, size); + PrintDebug(VM_NONE, VCORE_NONE, "In RTL8139: Hook IO ports starting from %x, size %d\n", (int) base_addr, size); for (i = 0; i < 0xff; i++){ v3_dev_hook_io(nic_state->dev, base_addr + i, &rtl8139_ioport_read, &rtl8139_ioport_write); } } else if (type == PCI_BAR_MEM32) { - PrintDebug("In RTL8139: Hook memory space starting from %x, size %d\n", (int) base_addr, size); + PrintDebug(VM_NONE, VCORE_NONE, "In RTL8139: Hook memory space starting from %x, size %d\n", (int) base_addr, size); //hook memory mapped I/O v3_hook_full_mem(nic_state->vm, nic_state->vm->cores[0].cpu_id, base_addr, base_addr + 0xff, &rtl8139_mmio_read, &rtl8139_mmio_write, nic_state); } else { - PrintError("In RTL8139: unknown memory type: start %x, size %d\n", (int) base_addr, size); + PrintError(VM_NONE, VCORE_NONE, "In RTL8139: unknown memory type: start %x, size %d\n", (int) base_addr, size); } return 0; @@ -1700,7 +1700,7 @@ static int register_dev(struct rtl8139_state * nic_state) { int i; if (nic_state->pci_bus == NULL) { - PrintError("RTL8139: Not attached to any PCI bus\n"); + PrintError(VM_NONE, VCORE_NONE, "RTL8139: Not attached to any PCI bus\n"); return -1; } @@ -1736,7 +1736,7 @@ static int register_dev(struct rtl8139_state * nic_state) { if (pci_dev == NULL) { - PrintError("RTL8139: Could not register PCI Device\n"); + PrintError(VM_NONE, VCORE_NONE, "RTL8139: Could not register PCI Device\n"); return -1; } @@ -1808,7 +1808,7 @@ static int rtl8139_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { nic_state = (struct rtl8139_state *)V3_Malloc(sizeof(struct rtl8139_state)); if (!nic_state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -1818,16 +1818,16 @@ static int rtl8139_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { nic_state->vm = vm; if (macstr != NULL && !str2mac(macstr, nic_state->mac)) { - PrintDebug("RTL8139: Mac specified %s\n", macstr); + PrintDebug(vm, VCORE_NONE, "RTL8139: Mac specified %s\n", macstr); }else { - PrintDebug("RTL8139: MAC not specified\n"); + PrintDebug(vm, VCORE_NONE, "RTL8139: MAC not specified\n"); random_ethaddr(nic_state->mac); } struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, nic_state); if (dev == NULL) { - PrintError("RTL8139: Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "RTL8139: Could not attach device %s\n", dev_id); V3_Free(nic_state); return -1; } @@ -1835,7 +1835,7 @@ static int rtl8139_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { nic_state->dev = dev; if (v3_dev_add_net_frontend(vm, dev_id, connect_fn, (void *)nic_state) == -1) { - PrintError("RTL8139: Could not register %s as net frontend\n", dev_id); + PrintError(vm, VCORE_NONE, "RTL8139: Could not register %s as net frontend\n", dev_id); v3_remove_device(dev); V3_Free(nic_state); return -1; diff --git a/palacios/src/devices/serial.c b/palacios/src/devices/serial.c index 94576a9..208bf0e 100644 --- a/palacios/src/devices/serial.c +++ b/palacios/src/devices/serial.c @@ -310,7 +310,7 @@ static struct serial_port * get_com_from_port(struct serial_state * serial, uint } else if ((port >= COM4_DATA_PORT) && (port <= COM4_SCRATCH_PORT)) { return &(serial->coms[3]); } else { - PrintError("Error: Could not find serial port associated with IO port %d\n", port); + PrintError(VM_NONE, VCORE_NONE, "Error: Could not find serial port associated with IO port %d\n", port); return NULL; } } @@ -348,7 +348,7 @@ static int updateIRQ(struct v3_vm_info * vm, struct serial_port * com) { if ( (com->ier.erbfi == 0x1) && (receive_buffer_trigger( getNumber(&(com->rx_buffer)), com->fcr.rx_trigger)) ) { - PrintDebug("UART: receive buffer interrupt(trigger level reached)\n"); + PrintDebug(vm, VCORE_NONE, "UART: receive buffer interrupt(trigger level reached)\n"); com->iir.iid = RX_IRQ_TRIGGER_LEVEL; v3_raise_irq(vm, com->irq_number); @@ -370,7 +370,7 @@ static int updateIRQ(struct v3_vm_info * vm, struct serial_port * com) { } else if ( (com->ier.etbei == 0x1) && (getNumber(&(com->tx_buffer)) != SERIAL_BUF_LEN )) { - PrintDebug("UART: transmit buffer interrupt(buffer not full)\n"); + PrintDebug(vm, VCORE_NONE, "UART: transmit buffer interrupt(buffer not full)\n"); com->iir.iid = TX_IRQ_THRE; com->iir.pending = 0; @@ -387,7 +387,7 @@ static int queue_data(struct v3_vm_info * vm, struct serial_port * com, int next_loc = (buf->head + 1) % SERIAL_BUF_LEN; if (buf->full == 1) { - PrintDebug("Buffer is full!\n"); + PrintDebug(vm, VCORE_NONE, "Buffer is full!\n"); if (buf == &(com->rx_buffer)) { com->lsr.oe = 1; //overrun error bit set @@ -424,7 +424,7 @@ static int dequeue_data(struct v3_vm_info * vm, struct serial_port * com, if ( (buf->head == buf->tail) && (buf->full != 1) ) { - PrintDebug("no data to delete!\n"); + PrintDebug(vm, VCORE_NONE, "no data to delete!\n"); return -1; } @@ -457,23 +457,23 @@ static int write_data_port(struct guest_info * core, uint16_t port, uint8_t * val = (uint8_t *)src; struct serial_port * com_port = NULL; - PrintDebug("Write to Data Port 0x%x (val=%x)\n", port, *val); + PrintDebug(core->vm_info, core, "Write to Data Port 0x%x (val=%x)\n", port, *val); if (length != 1) { - PrintError("Invalid length(%d) in write to 0x%x\n", length, port); + PrintError(core->vm_info, core, "Invalid length(%d) in write to 0x%x\n", length, port); return -1; } if ((port != COM1_DATA_PORT) && (port != COM2_DATA_PORT) && (port != COM3_DATA_PORT) && (port != COM4_DATA_PORT)) { - PrintError("Serial Read data port for illegal port Number (%d)\n", port); + PrintError(core->vm_info, core, "Serial Read data port for illegal port Number (%d)\n", port); return -1; } com_port = get_com_from_port(state, port); if (com_port == NULL) { - PrintError("UART:read from NOBODY\n"); + PrintError(core->vm_info, core, "UART:read from NOBODY\n"); return -1; } @@ -504,23 +504,23 @@ static int read_data_port(struct guest_info * core, uint16_t port, uint8_t * val = (uint8_t *)dst; struct serial_port * com_port = NULL; - PrintDebug("Read from Data Port 0x%x\n", port); + PrintDebug(core->vm_info, core, "Read from Data Port 0x%x\n", port); if (length != 1) { - PrintError("Invalid length(%d) in write to 0x%x\n", length, port); + PrintError(core->vm_info, core, "Invalid length(%d) in write to 0x%x\n", length, port); return -1; } if ((port != COM1_DATA_PORT) && (port != COM2_DATA_PORT) && (port != COM3_DATA_PORT) && (port != COM4_DATA_PORT)) { - PrintError("Serial Read data port for illegal port Number (%d)\n", port); + PrintError(core->vm_info, core, "Serial Read data port for illegal port Number (%d)\n", port); return -1; } com_port = get_com_from_port(state, port); if (com_port == NULL) { - PrintError("UART:read from NOBODY\n"); + PrintError(core->vm_info, core, "UART:read from NOBODY\n"); return -1; } @@ -587,17 +587,17 @@ static int write_ctrl_port(struct guest_info * core, uint16_t port, void * src, uint8_t val = *(uint8_t *)src; struct serial_port * com_port = NULL; - PrintDebug("UART:Write to Control Port (val=%x)\n", val); + PrintDebug(core->vm_info, core, "UART:Write to Control Port (val=%x)\n", val); if (length != 1) { - PrintError("UART:Invalid Write length to control port%d\n", port); + PrintError(core->vm_info, core, "UART:Invalid Write length to control port%d\n", port); return -1; } com_port = get_com_from_port(state, port); if (com_port == NULL) { - PrintError("Could not find serial port corresponding to IO port %d\n", port); + PrintError(core->vm_info, core, "Could not find serial port corresponding to IO port %d\n", port); return -1; } @@ -607,7 +607,7 @@ static int write_ctrl_port(struct guest_info * core, uint16_t port, void * src, case COM2_IRQ_ENABLE_PORT: case COM3_IRQ_ENABLE_PORT: case COM4_IRQ_ENABLE_PORT: { - PrintDebug("UART:Write to IER/LATCH port: dlab is %x\n", com_port->lcr.dlab); + PrintDebug(core->vm_info, core, "UART:Write to IER/LATCH port: dlab is %x\n", com_port->lcr.dlab); if (com_port->lcr.dlab == 1) { com_port->dlm.data = val; @@ -621,7 +621,7 @@ static int write_ctrl_port(struct guest_info * core, uint16_t port, void * src, case COM2_FIFO_CTRL_PORT: case COM3_FIFO_CTRL_PORT: case COM4_FIFO_CTRL_PORT: { - PrintDebug("UART:Write to FCR\n"); + PrintDebug(core->vm_info, core, "UART:Write to FCR\n"); if (handle_fcr_write(com_port, val) == -1) { return -1; @@ -633,7 +633,7 @@ static int write_ctrl_port(struct guest_info * core, uint16_t port, void * src, case COM2_LINE_CTRL_PORT: case COM3_LINE_CTRL_PORT: case COM4_LINE_CTRL_PORT: { - PrintDebug("UART:Write to LCR\n"); + PrintDebug(core->vm_info, core, "UART:Write to LCR\n"); com_port->lcr.val = val; break; } @@ -641,7 +641,7 @@ static int write_ctrl_port(struct guest_info * core, uint16_t port, void * src, case COM2_MODEM_CTRL_PORT: case COM3_MODEM_CTRL_PORT: case COM4_MODEM_CTRL_PORT: { - PrintDebug("UART:Write to MCR\n"); + PrintDebug(core->vm_info, core, "UART:Write to MCR\n"); com_port->mcr.val = val; break; } @@ -649,12 +649,12 @@ static int write_ctrl_port(struct guest_info * core, uint16_t port, void * src, case COM2_SCRATCH_PORT: case COM3_SCRATCH_PORT: case COM4_SCRATCH_PORT: { - PrintDebug("UART:Write to SCRATCH\n"); + PrintDebug(core->vm_info, core, "UART:Write to SCRATCH\n"); com_port->scr.data = val; break; } default: - PrintError("UART:Write to NOBODY, ERROR\n"); + PrintError(core->vm_info, core, "UART:Write to NOBODY, ERROR\n"); return -1; } @@ -671,17 +671,17 @@ static int read_ctrl_port(struct guest_info * core, uint16_t port, void * dst, uint8_t * val = (uint8_t *)dst; struct serial_port * com_port = NULL; - PrintDebug("Read from Control Port\n"); + PrintDebug(core->vm_info, core, "Read from Control Port\n"); if (length != 1) { - PrintError("Invalid Read length to control port\n"); + PrintError(core->vm_info, core, "Invalid Read length to control port\n"); return -1; } com_port = get_com_from_port(state, port); if (com_port == NULL) { - PrintError("Could not find serial port corresponding to IO port %d\n", port); + PrintError(core->vm_info, core, "Could not find serial port corresponding to IO port %d\n", port); return -1; } @@ -691,7 +691,7 @@ static int read_ctrl_port(struct guest_info * core, uint16_t port, void * dst, case COM2_IRQ_ENABLE_PORT: case COM3_IRQ_ENABLE_PORT: case COM4_IRQ_ENABLE_PORT: { - PrintDebug("UART:read from IER\n"); + PrintDebug(core->vm_info, core, "UART:read from IER\n"); if (com_port->lcr.dlab == 1) { *val = com_port->dlm.data; @@ -705,7 +705,7 @@ static int read_ctrl_port(struct guest_info * core, uint16_t port, void * dst, case COM2_IIR_PORT: case COM3_IIR_PORT: case COM4_IIR_PORT: - PrintDebug("UART:read from IIR\n"); + PrintDebug(core->vm_info, core, "UART:read from IIR\n"); *val = com_port->iir.val; break; @@ -713,7 +713,7 @@ static int read_ctrl_port(struct guest_info * core, uint16_t port, void * dst, case COM2_LINE_CTRL_PORT: case COM3_LINE_CTRL_PORT: case COM4_LINE_CTRL_PORT: - PrintDebug("UART:read from LCR\n"); + PrintDebug(core->vm_info, core, "UART:read from LCR\n"); *val = com_port->lcr.val; break; @@ -721,7 +721,7 @@ static int read_ctrl_port(struct guest_info * core, uint16_t port, void * dst, case COM2_MODEM_CTRL_PORT: case COM3_MODEM_CTRL_PORT: case COM4_MODEM_CTRL_PORT: - PrintDebug("UART:read from MCR\n"); + PrintDebug(core->vm_info, core, "UART:read from MCR\n"); *val = com_port->mcr.val; break; @@ -729,12 +729,12 @@ static int read_ctrl_port(struct guest_info * core, uint16_t port, void * dst, case COM2_SCRATCH_PORT: case COM3_SCRATCH_PORT: case COM4_SCRATCH_PORT: - PrintDebug("UART:read from SCRATCH\n"); + PrintDebug(core->vm_info, core, "UART:read from SCRATCH\n"); *val = com_port->scr.data; break; default: - PrintError("UART:read from NOBODY\n"); + PrintError(core->vm_info, core, "UART:read from NOBODY\n"); return -1; } @@ -748,17 +748,17 @@ static int write_status_port(struct guest_info * core, uint16_t port, void * src uint8_t val = *(uint8_t *)src; struct serial_port * com_port = NULL; - PrintDebug("Write to Status Port (val=%x)\n", val); + PrintDebug(core->vm_info, core, "Write to Status Port (val=%x)\n", val); if (length != 1) { - PrintError("Invalid Write length to status port %d\n", port); + PrintError(core->vm_info, core, "Invalid Write length to status port %d\n", port); return -1; } com_port = get_com_from_port(state, port); if (com_port == NULL) { - PrintError("Could not find serial port corresponding to IO port %d\n", port); + PrintError(core->vm_info, core, "Could not find serial port corresponding to IO port %d\n", port); return -1; } @@ -767,7 +767,7 @@ static int write_status_port(struct guest_info * core, uint16_t port, void * src case COM2_LINE_STATUS_PORT: case COM3_LINE_STATUS_PORT: case COM4_LINE_STATUS_PORT: - PrintDebug("UART:write to LSR\n"); + PrintDebug(core->vm_info, core, "UART:write to LSR\n"); com_port->lsr.val = val; break; @@ -775,12 +775,12 @@ static int write_status_port(struct guest_info * core, uint16_t port, void * src case COM2_MODEM_STATUS_PORT: case COM3_MODEM_STATUS_PORT: case COM4_MODEM_STATUS_PORT: - PrintDebug("UART:write to MSR\n"); + PrintDebug(core->vm_info, core, "UART:write to MSR\n"); com_port->msr.val = val; break; default: - PrintError("UART:write to NOBODY\n"); + PrintError(core->vm_info, core, "UART:write to NOBODY\n"); return -1; } @@ -793,12 +793,12 @@ static int read_status_port(struct guest_info * core, uint16_t port, void * dst, uint8_t * val = (uint8_t *)dst; struct serial_port * com_port = NULL; - PrintDebug("Read from Status Port 0x%x\n", port); + PrintDebug(core->vm_info, core, "Read from Status Port 0x%x\n", port); com_port = get_com_from_port(state, port); if (com_port == NULL) { - PrintError("Could not find serial port corresponding to IO port %d\n", port); + PrintError(core->vm_info, core, "Could not find serial port corresponding to IO port %d\n", port); return -1; } @@ -809,11 +809,11 @@ static int read_status_port(struct guest_info * core, uint16_t port, void * dst, case COM4_LINE_STATUS_PORT: if (length != 1) { - PrintError("Invalid Read length to control port\n"); + PrintError(core->vm_info, core, "Invalid Read length to control port\n"); return -1; } - PrintDebug("UART:read from LSR\n"); + PrintDebug(core->vm_info, core, "UART:read from LSR\n"); *val = com_port->lsr.val; com_port->lsr.oe = 0; // Why do we clear this?? @@ -824,10 +824,10 @@ static int read_status_port(struct guest_info * core, uint16_t port, void * dst, case COM2_MODEM_STATUS_PORT: case COM3_MODEM_STATUS_PORT: case COM4_MODEM_STATUS_PORT: - PrintDebug("UART:read from COM4 MSR (length = %d)\n", length); + PrintDebug(core->vm_info, core, "UART:read from COM4 MSR (length = %d)\n", length); if (length > 2) { - PrintError("Invalid Read length to MSR port\n"); + PrintError(core->vm_info, core, "Invalid Read length to MSR port\n"); return -1; } @@ -835,7 +835,7 @@ static int read_status_port(struct guest_info * core, uint16_t port, void * dst, /* Windows XP expects to be able to read this register and the next in one go */ if (read_ctrl_port(core, port + 1, val + 1, 1, priv_data) < 0) { - PrintError("Error reading control port for word size read of Status register\n"); + PrintError(core->vm_info, core, "Error reading control port for word size read of Status register\n"); return -1; } } @@ -846,7 +846,7 @@ static int read_status_port(struct guest_info * core, uint16_t port, void * dst, break; default: - PrintError("UART:read from NOBODY (length = %d)\n", length); + PrintError(core->vm_info, core, "UART:read from NOBODY (length = %d)\n", length); return -1; } @@ -881,7 +881,7 @@ static int serial_buffer_save(struct v3_chkpt_ctx * ctx, int port, struct serial return 0; failout: - PrintError("Failed to save serial buffer\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to save serial buffer\n"); return -1; } @@ -902,7 +902,7 @@ static int serial_buffer_load(struct v3_chkpt_ctx * ctx, int port, struct seria return 0; failout: - PrintError("Failed to load serial buffer\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to load serial buffer\n"); return -1; } @@ -940,12 +940,12 @@ static int serial_save(struct v3_chkpt_ctx * ctx, void * private_data) { V3_CHKPT_SAVE(ctx, keyname, serial->dlm.data,failout); if (serial_buffer_save(ctx, i, &(serial->tx_buffer))) { - PrintError("Failed to save serial tx buffer %d\n",i); + PrintError(VM_NONE, VCORE_NONE, "Failed to save serial tx buffer %d\n",i); goto failout; } if (serial_buffer_save(ctx, i, &(serial->rx_buffer))) { - PrintError("Failed to save serial rx buffer %d\n",i); + PrintError(VM_NONE, VCORE_NONE, "Failed to save serial rx buffer %d\n",i); goto failout; } @@ -955,7 +955,7 @@ static int serial_save(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; failout: - PrintError("Failed to save serial device\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to save serial device\n"); return -1; } @@ -994,12 +994,12 @@ static int serial_load(struct v3_chkpt_ctx * ctx, void * private_data) { V3_CHKPT_LOAD(ctx, keyname, serial->dlm.data,failout); if (serial_buffer_load(ctx, i, &(serial->tx_buffer))) { - PrintError("Failed to load serial tx buffer %d\n",i); + PrintError(VM_NONE, VCORE_NONE, "Failed to load serial tx buffer %d\n",i); goto failout; } if (serial_buffer_load(ctx, i, &(serial->rx_buffer))) { - PrintError("Failed to load serial rx buffer %d\n",i); + PrintError(VM_NONE, VCORE_NONE, "Failed to load serial rx buffer %d\n",i); goto failout; } @@ -1009,7 +1009,7 @@ static int serial_load(struct v3_chkpt_ctx * ctx, void * private_data) { return 0; failout: - PrintError("Failed to load serial device\n"); + PrintError(VM_NONE, VCORE_NONE,"Failed to load serial device\n"); return -1; } @@ -1082,14 +1082,14 @@ static int connect_fn(struct v3_vm_info * vm, int com_idx = 0; if (com_port == NULL) { - PrintError("Invalid Serial frontend config: missing \"com_port\"\n"); + PrintError(vm, VCORE_NONE, "Invalid Serial frontend config: missing \"com_port\"\n"); return -1; } com_idx = atoi(com_port) - 1; if ((com_idx > 3) || (com_idx < 0)) { - PrintError("Invalid Com port (%s) \n", com_port); + PrintError(vm, VCORE_NONE, "Invalid Com port (%s) \n", com_port); return -1; } @@ -1112,7 +1112,7 @@ static int serial_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { state = (struct serial_state *)V3_Malloc(sizeof(struct serial_state)); if (state == NULL) { - PrintError("Could not allocate Serial Device\n"); + PrintError(vm,VCORE_NONE, "Could not allocate Serial Device\n"); return -1; } @@ -1132,12 +1132,12 @@ static int serial_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(state); return -1; } - PrintDebug("Serial device attached\n"); + PrintDebug(vm, VCORE_NONE, "Serial device attached\n"); ret |= v3_dev_hook_io(dev, COM1_DATA_PORT, &read_data_port, &write_data_port); ret |= v3_dev_hook_io(dev, COM1_IRQ_ENABLE_PORT, &read_ctrl_port, &write_ctrl_port); @@ -1176,17 +1176,17 @@ static int serial_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { ret |= v3_dev_hook_io(dev, COM4_SCRATCH_PORT, &read_ctrl_port, &write_ctrl_port); if (ret != 0) { - PrintError("Error hooking Serial IO ports\n"); + PrintError(vm, VCORE_NONE, "Error hooking Serial IO ports\n"); v3_remove_device(dev); return -1; } - PrintDebug("Serial ports hooked\n"); + PrintDebug(vm, VCORE_NONE, "Serial ports hooked\n"); if (v3_dev_add_char_frontend(vm, dev_id, connect_fn, (void *)state) == -1) { - PrintError("Could not register %s as frontend\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not register %s as frontend\n", dev_id); v3_remove_device(dev); return -1; } diff --git a/palacios/src/devices/simple_pic.c b/palacios/src/devices/simple_pic.c index 06b6d01..16039e4 100644 --- a/palacios/src/devices/simple_pic.c +++ b/palacios/src/devices/simple_pic.c @@ -84,14 +84,14 @@ static int pic_init(struct guest_info * vm, void * cfg_data) { state = (struct pic_internal *)V3_Malloc(sizeof(struct pic_internal)); if (!state) { - PrintError("Cannot allocate in init\n"); + PrintError(info->vm_info, info, "Cannot allocate in init\n"); return -1; } struct vm_device * dev = v3_allocate_device("SIMPLE_PIC", &dev_ops, state); if (v3_attach_device(vm, dev) == -1) { - PrintError("Could not attach device %s\n", "SIMPLE_PIC"); + PrintError(info->vm_info, info, "Could not attach device %s\n", "SIMPLE_PIC"); V3_Free(state); return -1; } diff --git a/palacios/src/devices/swapbypass_cache.c b/palacios/src/devices/swapbypass_cache.c index 2f6d75b..23e7d41 100644 --- a/palacios/src/devices/swapbypass_cache.c +++ b/palacios/src/devices/swapbypass_cache.c @@ -129,7 +129,7 @@ static inline void * get_swap_entry(uint32_t pg_index, void * private_data) { static uint64_t swap_get_capacity(void * private_data) { struct swap_state * swap = (struct swap_state *)private_data; - PrintDebug("SymSwap: Getting Capacity %d\n", (uint32_t)(swap->capacity)); + PrintDebug(VM_NONE, VCORE_NONE, "SymSwap: Getting Capacity %d\n", (uint32_t)(swap->capacity)); return swap->capacity; } @@ -148,12 +148,12 @@ static int swap_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * pri - PrintDebug("SymSwap: Reading %d bytes to %p from %p\n", length, + PrintDebug(VM_NONE, VCORE_NONE, "SymSwap: Reading %d bytes to %p from %p\n", length, buf, (void *)(swap->swap_space + offset)); if (length % 4096) { - PrintError("Swapping in length that is not a page multiple\n"); + PrintError(VM_NONE, VCORE_NONE, "Swapping in length that is not a page multiple\n"); } memcpy(buf, swap->swap_space + offset, length); @@ -186,28 +186,28 @@ static int swap_write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * p uint32_t length = num_bytes; /* - PrintDebug("SymSwap: Writing %d bytes to %p from %p\n", length, + PrintDebug(VM_NONE, VCORE_NONE, "SymSwap: Writing %d bytes to %p from %p\n", length, (void *)(swap->swap_space + offset), buf); */ if (length % 4096) { - PrintError("Swapping out length that is not a page multiple\n"); + PrintError(VM_NONE, VCORE_NONE, "Swapping out length that is not a page multiple\n"); } if ((swap->active == 0) && (offset == 0)) { // This is the swap header page if (length != 4096) { - PrintError("Initializing Swap space by not writing page multiples. This sucks...\n"); + PrintError(VM_NONE, VCORE_NONE, "Initializing Swap space by not writing page multiples. This sucks...\n"); return -1; } swap->active = 1; - PrintDebug("Swap Type=%d (magic=%s)\n", swap->hdr->info.type, swap->hdr->magic.magic); + PrintDebug(VM_NONE, VCORE_NONE, "Swap Type=%d (magic=%s)\n", swap->hdr->info.type, swap->hdr->magic.magic); if (v3_register_swap_disk(swap->vm, swap->hdr->info.type, &swap_ops, swap) == -1) { - PrintError("Error registering symbiotic swap disk\n"); + PrintError(VM_NONE, VCORE_NONE, "Error registering symbiotic swap disk\n"); return -1; } } @@ -232,7 +232,7 @@ static int swap_write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * p } -static int swap_free(struct vm_device * dev) { +static int swap_free(void * dev) { return -1; } @@ -247,9 +247,6 @@ static struct v3_dev_blk_ops blk_ops = { static struct v3_device_ops dev_ops = { .free = swap_free, - .reset = NULL, - .start = NULL, - .stop = NULL, }; @@ -258,9 +255,9 @@ static void telemetry_cb(struct v3_vm_info * vm, void * private_data, char * hdr struct vm_device * dev = (struct vm_device *)private_data; struct swap_state * swap = (struct swap_state *)(dev->private_data); - V3_Print("%sSwap Device:\n", hdr); - V3_Print("%s\tPages Swapped in=%d\n", hdr, swap->pages_in); - V3_Print("%s\tPages Swapped out=%d\n", hdr, swap->pages_out); + V3_Print(vm, VCORE_NONE, "%sSwap Device:\n", hdr); + V3_Print(vm, VCORE_NONE, "%s\tPages Swapped in=%d\n", hdr, swap->pages_in); + V3_Print(vm, VCORE_NONE, "%s\tPages Swapped out=%d\n", hdr, swap->pages_out); } #endif @@ -276,16 +273,16 @@ static int swap_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { char * dev_id = v3_cfg_val(cfg, "ID"); if (!frontend_cfg) { - PrintError("Initializing sym swap without a frontend device\n"); + PrintError(vm, VCORE_NONE, "Initializing sym swap without a frontend device\n"); return -1; } - PrintDebug("Creating Swap Device (size=%dMB)\n", capacity / (1024 * 1024)); + PrintDebug(vm, VCORE_NONE, "Creating Swap Device (size=%dMB)\n", capacity / (1024 * 1024)); swap = (struct swap_state *)V3_Malloc(sizeof(struct swap_state) + ((capacity / 4096) / 8)); if (!swap) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -302,7 +299,7 @@ static int swap_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { swap->swap_base_addr = (addr_t)V3_AllocPages(swap->capacity / 4096); if (!swap->swap_base_addr) { - PrintError("Cannot allocate swap space\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate swap space\n"); V3_Free(swap); return -1; } @@ -315,13 +312,13 @@ static int swap_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, swap); if (v3_attach_device(vm, dev) == -1) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); return -1; } if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"), &blk_ops, frontend_cfg, swap) == -1) { - PrintError("Could not connect %s to frontend %s\n", + PrintError(vm, VCORE_NONE, "Could not connect %s to frontend %s\n", dev_id, v3_cfg_val(frontend_cfg, "tag")); return -1; } diff --git a/palacios/src/devices/swapbypass_cache2.c b/palacios/src/devices/swapbypass_cache2.c index 776c34a..09d090b 100644 --- a/palacios/src/devices/swapbypass_cache2.c +++ b/palacios/src/devices/swapbypass_cache2.c @@ -148,13 +148,13 @@ static inline void * get_swap_entry(uint32_t pg_index, void * private_data) { return NULL; } - PrintDebug("Getting swap entry for index %d\n", pg_index); + PrintDebug(info->vm_info, info, "Getting swap entry for index %d\n", pg_index); entry = (struct cache_entry *)v3_htable_search(swap->entry_ht, swap_index); if (entry != NULL) { uint32_t cache_index = get_cache_entry_index(swap, entry); - PrintDebug("Found cached entry (%d)\n", cache_index); + PrintDebug(info->vm_info, info, "Found cached entry (%d)\n", cache_index); pg_addr = swap->cache + (cache_index * 4096); } @@ -208,7 +208,7 @@ static int buf_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * priv swap->io_flag = 0; if (length % 4096) { - PrintError("Swapping in length that is not a page multiple\n"); + PrintError(VM_NONE, VCORE_NONE, "Swapping in length that is not a page multiple\n"); } if (swap->disabled) { @@ -216,11 +216,11 @@ static int buf_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * priv } - PrintDebug("SymSwap: Reading %d bytes to %p (lba=%p)\n", (uint32_t)num_bytes, buf, (void *)(addr_t)lba); + PrintDebug(VM_NONE, VCORE_NONE, "SymSwap: Reading %d bytes to %p (lba=%p)\n", (uint32_t)num_bytes, buf, (void *)(addr_t)lba); if (length % 4096) { - PrintError("Swapping in length that is not a page multiple\n"); + PrintError(VM_NONE, VCORE_NONE, "Swapping in length that is not a page multiple\n"); return -1; } @@ -248,7 +248,7 @@ static int buf_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * priv v3_swap_in_notify(swap->vm, get_swap_index_from_offset(offset + i), swap->hdr.info.type); } - PrintDebug("Searching for swap index %d\n", swap_index); + PrintDebug(VM_NONE, VCORE_NONE, "Searching for swap index %d\n", swap_index); entry = (struct cache_entry *)v3_htable_search(swap->entry_ht, (addr_t)swap_index); @@ -256,15 +256,15 @@ static int buf_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * priv cache_index = get_cache_entry_index(swap, entry); - PrintDebug("Reading from cache entry %d\n", cache_index); + PrintDebug(VM_NONE, VCORE_NONE, "Reading from cache entry %d\n", cache_index); memcpy(buf, swap->cache + (cache_index * 4096), 4096); } else { - PrintDebug("Reading from disk offset = %p\n", (void *)(addr_t)offset); + PrintDebug(VM_NONE, VCORE_NONE, "Reading from disk offset = %p\n", (void *)(addr_t)offset); if (read_disk(buf, offset, 4096, swap) == -1) { - PrintError("Error reading disk\n"); + PrintError(VM_NONE, VCORE_NONE, "Error reading disk\n"); return -1; } } @@ -284,7 +284,7 @@ static int buf_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * priv static int flush_cache(struct swap_state * swap, int num_to_flush) { int i; - PrintDebug("Flushing %d pages\n", num_to_flush); + PrintDebug(VM_NONE, VCORE_NONE, "Flushing %d pages\n", num_to_flush); for (i = 0; i < num_to_flush; i++) { struct cache_entry * entry = NULL; @@ -293,10 +293,10 @@ static int flush_cache(struct swap_state * swap, int num_to_flush) { entry = list_first_entry(&(swap->entry_list), struct cache_entry, cache_node); entry_index = get_cache_entry_index(swap, entry); - PrintDebug("Flushing cache entry %d\n", entry_index); + PrintDebug(VM_NONE, VCORE_NONE, "Flushing cache entry %d\n", entry_index); if (write_disk(swap->cache + (entry_index * 4096), entry->disk_index, 4096, swap) == -1) { - PrintError("Error in disk write\n"); + PrintError(VM_NONE, VCORE_NONE, "Error in disk write\n"); return -1; } @@ -340,7 +340,7 @@ static int buf_write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * pr /* - PrintDebug("SymSwap: Writing %d bytes to %p from %p\n", length, + PrintDebug(VM_NONE, VCORE_NONE, "SymSwap: Writing %d bytes to %p from %p\n", length, (void *)(swap->swap_space + offset), buf); */ @@ -354,24 +354,24 @@ static int buf_write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * pr memcpy(&(swap->hdr), buf, sizeof(union swap_header)); - PrintError("Swap Type=%d (magic=%s)\n", swap->hdr.info.type, swap->hdr.magic.magic); + PrintError(VM_NONE, VCORE_NONE, "Swap Type=%d (magic=%s)\n", swap->hdr.info.type, swap->hdr.magic.magic); if (swap->symbiotic == 1) { if (v3_register_swap_disk(swap->vm, swap->hdr.info.type, &swap_ops, swap) == -1) { - PrintError("Error registering symbiotic swap disk\n"); + PrintError(VM_NONE, VCORE_NONE, "Error registering symbiotic swap disk\n"); return -1; } - PrintError("Swap disk registered\n"); + PrintError(VM_NONE, VCORE_NONE, "Swap disk registered\n"); } if (write_disk(buf, lba, num_bytes, swap) == -1) { - PrintError("Error writing swap header to disk\n"); + PrintError(VM_NONE, VCORE_NONE, "Error writing swap header to disk\n"); return -1; } - PrintDebug("Wrote header to disk\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Wrote header to disk\n"); return 0; } @@ -388,7 +388,7 @@ static int buf_write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * pr swap->pages_out += length / 4096; #endif - PrintDebug("available cache space = %d, pages written = %d\n", avail_space, written_pages); + PrintDebug(VM_NONE, VCORE_NONE, "available cache space = %d, pages written = %d\n", avail_space, written_pages); if (avail_space < written_pages) { flush_cache(swap, written_pages - avail_space); @@ -417,7 +417,7 @@ static int buf_write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * pr cache_index = get_cache_entry_index(swap, new_entry); - PrintDebug("Writing to cache entry %d\n", cache_index); + PrintDebug(VM_NONE, VCORE_NONE, "Writing to cache entry %d\n", cache_index); memcpy(swap->cache + (cache_index * 4096), buf, 4096); @@ -425,7 +425,7 @@ static int buf_write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * pr } } else { if (write_disk(buf, lba, num_bytes, swap) == -1) { - PrintError("Error writing swap header to disk\n"); + PrintError(VM_NONE, VCORE_NONE, "Error writing swap header to disk\n"); return -1; } } @@ -443,7 +443,7 @@ static int swap_write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * p int idx = lba % 4096; if (num_bytes != 512) { - PrintError("Write for %d bytes\n", (uint32_t)num_bytes); + PrintError(VM_NONE, VCORE_NONE, "Write for %d bytes\n", (uint32_t)num_bytes); return -1; } @@ -468,13 +468,13 @@ static int swap_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * pr if (num_bytes != 512) { - PrintError("Read for %d bytes\n", (uint32_t)num_bytes); + PrintError(VM_NONE, VCORE_NONE, "Read for %d bytes\n", (uint32_t)num_bytes); return -1; } if (idx == 0) { if (buf_read(read_buf, lba - idx, 4096, private_data) == -1) { - PrintError("Error reading buffer\n"); + PrintError(VM_NONE, VCORE_NONE, "Error reading buffer\n"); return -1; } } @@ -485,7 +485,7 @@ static int swap_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * pr } -static int swap_free(struct vm_device * dev) { +static int swap_free(void * dev) { return -1; } @@ -500,9 +500,6 @@ static struct v3_dev_blk_ops blk_ops = { static struct v3_device_ops dev_ops = { .free = swap_free, - .reset = NULL, - .start = NULL, - .stop = NULL, }; @@ -510,11 +507,11 @@ static struct v3_device_ops dev_ops = { static void telemetry_cb(struct v3_vm_info * vm, void * private_data, char * hdr) { struct swap_state * swap = (struct swap_state *)private_data; - V3_Print("%sSwap Device:\n", hdr); - V3_Print("%s\tPages Swapped in=%d\n", hdr, swap->pages_in); - V3_Print("%s\tPages Swapped out=%d\n", hdr, swap->pages_out); - V3_Print("%s\tPages Written to Disk=%d\n", hdr, swap->disk_writes); - V3_Print("%s\tPages Read from Disk=%d\n", hdr, swap->disk_reads); + V3_Print(vm, VCORE_NONE, "%sSwap Device:\n", hdr); + V3_Print(vm, VCORE_NONE, "%s\tPages Swapped in=%d\n", hdr, swap->pages_in); + V3_Print(vm, VCORE_NONE, "%s\tPages Swapped out=%d\n", hdr, swap->pages_out); + V3_Print(vm, VCORE_NONE, "%s\tPages Written to Disk=%d\n", hdr, swap->disk_writes); + V3_Print(vm, VCORE_NONE, "%s\tPages Read from Disk=%d\n", hdr, swap->disk_reads); } #endif @@ -532,16 +529,16 @@ static int connect_fn(struct v3_vm_info * vm, int i; if (!frontend_cfg) { - PrintError("Initializing sym swap without a frontend device\n"); + PrintError(vm, VCORE_NONE, "Initializing sym swap without a frontend device\n"); return -1; } - PrintError("Creating Swap filter (cache size=%dMB)\n", cache_size / (1024 * 1024)); + PrintError(vm, VCORE_NONE, "Creating Swap filter (cache size=%dMB)\n", cache_size / (1024 * 1024)); swap = (struct swap_state *)V3_Malloc(sizeof(struct swap_state)); if (!swap) { - PrintError("Cannot allocate in connect\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in connect\n"); return -1; } @@ -568,7 +565,7 @@ static int connect_fn(struct v3_vm_info * vm, swap->entry_map = (struct cache_entry *)V3_Malloc(sizeof(struct cache_entry) * (cache_size / 4096)); if (!swap->entry_map) { - PrintError("Cannot allocate in connect\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in connect\n"); return -1; } @@ -584,7 +581,7 @@ static int connect_fn(struct v3_vm_info * vm, swap->cache_base_addr = (addr_t)V3_AllocPages(swap->cache_size / 4096); if (!swap->cache_base_addr) { - PrintError("Cannot allocate cache space\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate cache space\n"); V3_Free(swap); return -1; } @@ -596,7 +593,7 @@ static int connect_fn(struct v3_vm_info * vm, if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"), &blk_ops, frontend_cfg, swap) == -1) { - PrintError("Could not connect to frontend %s\n", + PrintError(vm, VCORE_NONE, "Could not connect to frontend %s\n", v3_cfg_val(frontend_cfg, "tag")); return -1; } @@ -623,12 +620,12 @@ static int swap_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, NULL); if (v3_attach_device(vm, dev) == -1) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); return -1; } if (v3_dev_add_blk_frontend(vm, dev_id, connect_fn, NULL) == -1) { - PrintError("Could not register %s as block frontend\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not register %s as block frontend\n", dev_id); return -1; } diff --git a/palacios/src/devices/telnet_cons.c b/palacios/src/devices/telnet_cons.c index 9562306..98562af 100644 --- a/palacios/src/devices/telnet_cons.c +++ b/palacios/src/devices/telnet_cons.c @@ -48,8 +48,8 @@ struct cons_state { - int server_fd; - int client_fd; + v3_sock_t server_fd; + v3_sock_t client_fd; uint16_t port; @@ -57,7 +57,7 @@ struct cons_state { v3_lock_t cons_lock; - v3_vm_info * vm; + struct v3_vm_info * vm; struct vm_device * frontend_dev; }; @@ -113,7 +113,7 @@ static int deliver_scan_code(struct cons_state * state, struct key_code * key) { key_event.status = 0; key_event.scan_code = (uint8_t)key->scan_code; - PrintDebug("Scan code: 0x%x\n", key_event.scan_code); + PrintDebug(VM_NONE, VCORE_NONE, "Scan code: 0x%x\n", key_event.scan_code); if (cap) { @@ -121,14 +121,14 @@ static int deliver_scan_code(struct cons_state * state, struct key_code * key) { key_shift.scan_code = (uint8_t)0x2A; if (v3_deliver_keyboard_event(state->vm, &key_shift) == -1) { - PrintError("Video: Error delivering key event\n"); + PrintError(VM_NONE, VCORE_NONE, "Video: Error delivering key event\n"); return -1; } } // Press if (v3_deliver_keyboard_event(state->vm, &key_event) == -1) { - PrintError("Video: Error delivering key event\n"); + PrintError(VM_NONE, VCORE_NONE, "Video: Error delivering key event\n"); return -1; } @@ -136,7 +136,7 @@ static int deliver_scan_code(struct cons_state * state, struct key_code * key) { key_event.scan_code = key_event.scan_code | 0x80; if (v3_deliver_keyboard_event(state->vm, &key_event) == -1) { - PrintError("Video: Error delivering key event\n"); + PrintError(VM_NONE, VCORE_NONE, "Video: Error delivering key event\n"); return -1; } @@ -145,31 +145,31 @@ static int deliver_scan_code(struct cons_state * state, struct key_code * key) { key_shift.scan_code = 0x2A | 0x80; if (v3_deliver_keyboard_event(state->vm, &key_shift) == -1) { - PrintError("Video: Error delivering key event\n"); + PrintError(VM_NONE, VCORE_NONE, "Video: Error delivering key event\n"); return -1; } } - PrintDebug("Finished with Key delivery\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Finished with Key delivery\n"); return 0; } -static int recv_all(int socket, char * buf, int length) { +static int recv_all(v3_sock_t socket, char * buf, int length) { int bytes_read = 0; - PrintDebug("Reading %d bytes\n", length - bytes_read); + PrintDebug(VM_NONE, VCORE_NONE, "Reading %d bytes\n", length - bytes_read); while (bytes_read < length) { - int tmp_bytes = V3_Recv(socket, buf + bytes_read, length - bytes_read); - PrintDebug("Received %d bytes\n", tmp_bytes); + int tmp_bytes = v3_socket_recv(socket, buf + bytes_read, length - bytes_read); + PrintDebug(VM_NONE, VCORE_NONE, "Received %d bytes\n", tmp_bytes); if (tmp_bytes == 0) { - PrintError("Connection Closed unexpectedly\n"); + PrintError(VM_NONE, VCORE_NONE, "Connection Closed unexpectedly\n"); return 0; } else if (tmp_bytes == -1) { - PrintError("Socket Error in for V3_RECV\n"); + PrintError(VM_NONE, VCORE_NONE, "Socket Error in for V3_RECV\n"); return -1; } @@ -180,13 +180,13 @@ static int recv_all(int socket, char * buf, int length) { } -static int send_all(const int sock, const char * buf, const int len){ +static int send_all(const v3_sock_t sock, const char * buf, const int len){ int bytes_left = len; while (bytes_left != 0) { int written = 0; - if ((written = V3_Send(sock, buf + (len - bytes_left), bytes_left)) == -1) { + if ((written = v3_socket_send(sock, buf + (len - bytes_left), bytes_left)) == -1) { return -1; } @@ -258,7 +258,7 @@ static int send_update(struct cons_state * state, uint8_t x, uint8_t y, uint8_ buf[i++] = 'H'; buf[i++] = val; - PrintDebug("printing value '%c'\n", val); + PrintDebug(VM_NONE, VCORE_NONE, "printing value '%c'\n", val); if (state->connected) { uint64_t start, end; @@ -267,7 +267,7 @@ static int send_update(struct cons_state * state, uint8_t x, uint8_t y, uint8_ ret = send_all(state->client_fd, buf, 32); rdtscll(end); - PrintDebug("Sendall latency=%d cycles\n", (uint32_t)(end - start)); + PrintDebug(VM_NONE, VCORE_NONE, "Sendall latency=%d cycles\n", (uint32_t)(end - start)); } return ret; @@ -335,7 +335,7 @@ static int screen_update(uint_t x, uint_t y, uint_t length, void * private_data) irq_state = v3_lock_irqsave(state->cons_lock); if (send_update(state, cur_x, cur_y, col[1], col[0]) == -1) { - PrintError("Could not send attribute to telnet session\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not send attribute to telnet session\n"); ret = -1; break; } @@ -368,7 +368,7 @@ static int scroll(int rows, void * private_data) { if (state->connected) { if (send_all(state->client_fd, message, sizeof(message)) == -1) { - PrintError("Could not send scroll command\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not send scroll command\n"); ret = -1; break; } @@ -409,14 +409,14 @@ static struct v3_device_ops dev_ops = { static int key_handler( struct cons_state * state, uint8_t ascii) { - PrintDebug("Character recieved: 0x%x\n", ascii); + PrintDebug(VM_NONE, VCORE_NONE, "Character recieved: 0x%x\n", ascii); // printable if (ascii < 0x80) { const struct key_code * key = &(ascii_to_key_code[ascii]); if (deliver_scan_code(state, (struct key_code *)key) == -1) { - PrintError("Could not deliver scan code to vm\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not deliver scan code to vm\n"); return -1; } @@ -428,16 +428,16 @@ static int key_handler( struct cons_state * state, uint8_t ascii) { int recv = recv_all(state->client_fd, esc_seq, 2); if (recv == -1) { - PrintError("Video: Error getting key from network\n"); + PrintError(VM_NONE, VCORE_NONE, "Video: Error getting key from network\n"); return -1; } else if (recv == 0) { - PrintDebug("Video: Client Disconnected\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Video: Client Disconnected\n"); return -1; } if (esc_seq[0] != '[') { - PrintDebug("Ignoring non handled escape sequence (codes = %d %d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Ignoring non handled escape sequence (codes = %d %d)\n", esc_seq[0], esc_seq[1]); return 0; } @@ -457,7 +457,7 @@ static int key_handler( struct cons_state * state, uint8_t ascii) { deliver_scan_code(state, &left); } } else { - PrintError("Invalid character received from network (%c) (code=%d)\n", + PrintError(VM_NONE, VCORE_NONE, "Invalid character received from network (%c) (code=%d)\n", ascii, ascii); // return 0; } @@ -468,17 +468,17 @@ static int key_handler( struct cons_state * state, uint8_t ascii) { static int cons_server(void * arg) { struct cons_state * state = (struct cons_state *)arg; - state->server_fd = V3_Create_TCP_Socket(); + state->server_fd = v3_create_tcp_socket(state->vm); - PrintDebug("Video: Socket File Descriptor: %d\n", state->server_fd); + PrintDebug(VM_NONE, VCORE_NONE, "Video: Socket File Descriptor: 0x%p\n", state->server_fd); - if (V3_Bind_Socket(state->server_fd, state->port) == -1) { - PrintError("Video: Failed to bind to socket %d\n", state->port); + if (v3_socket_bind(state->server_fd, state->port) == -1) { + PrintError(VM_NONE, VCORE_NONE, "Video: Failed to bind to socket %d\n", state->port); } - if (V3_Listen_Socket(state->server_fd, 8) == -1) { - PrintError("Video: Failed to listen with socket %d\n", state->server_fd); + if (v3_socket_listen(state->server_fd, 8) == -1) { + PrintError(VM_NONE, VCORE_NONE, "Video: Failed to listen with socket 0x%p\n", state->server_fd); } while (1) { @@ -487,10 +487,10 @@ static int cons_server(void * arg) { uint8_t ascii_code = 0; int recv = 0; - if ((state->client_fd = V3_Accept_Socket(state->server_fd, &client_ip, &client_port)) == -1) { - PrintError("Video: Failed to accept connection on port %d\n", client_port); + if ((state->client_fd = v3_socket_accept(state->server_fd, &client_ip, &client_port)) == 0) { + PrintError(VM_NONE, VCORE_NONE, "Video: Failed to accept connection on port %d\n", client_port); } - PrintDebug("Accepted Telnet Console connection\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Accepted Telnet Console connection\n"); state->connected = 1; screen_update(0, 0, SCREEN_SIZE, state); @@ -498,24 +498,24 @@ static int cons_server(void * arg) { while (1) { recv = recv_all(state->client_fd, &ascii_code, sizeof(ascii_code)); - PrintDebug("Telnet console Received %d bytes\n", recv); + PrintDebug(VM_NONE, VCORE_NONE, "Telnet console Received %d bytes\n", recv); if (recv == -1) { - PrintError("Video: Error getting key from network\n"); + PrintError(VM_NONE, VCORE_NONE, "Video: Error getting key from network\n"); break; } else if (recv == 0) { - PrintDebug("Video: Client Disconnected\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Video: Client Disconnected\n"); break; } if (key_handler(state, ascii_code) == -1) { - PrintError("Error in key handler\n"); + PrintError(VM_NONE, VCORE_NONE, "Error in key handler\n"); break; } } state->connected = 0; - V3_Close_Socket(state->client_fd); + v3_socket_close(state->client_fd); } return -1; @@ -529,7 +529,7 @@ static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { char * dev_id = v3_cfg_val(cfg, "ID"); if (!state) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -545,7 +545,7 @@ static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, state); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(state); return -1; } diff --git a/palacios/src/devices/timer.c b/palacios/src/devices/timer.c index 97d5d7d..0186269 100644 --- a/palacios/src/devices/timer.c +++ b/palacios/src/devices/timer.c @@ -30,7 +30,7 @@ struct timer_state { /* static int irq_handler(uint_t irq, struct vm_device * dev) { - PrintDebug("Timer interrupt\n"); + PrintDebug(info->vm_info, info, "Timer interrupt\n"); return 0; } @@ -58,14 +58,14 @@ static int timer_init(struct guest_info * vm, void * cfg_data) { timer = (struct timer_state *)V3_Malloc( sizeof(struct timer_state)); if (!timer) { - PrintError("Cannot allocate in init\n"); + PrintError(info->vm_info, info, "Cannot allocate in init\n"); return -1; } struct vm_device * dev = v3_allocate_device("TIMER", &dev_ops, timer); if (v3_attach_device(vm, dev) == -1) { - PrintError("Could not attach device %s\n", "TIMER"); + PrintError(info->vm_info, info, "Could not attach device %s\n", "TIMER"); return -1; } diff --git a/palacios/src/devices/tmpdisk.c b/palacios/src/devices/tmpdisk.c index 879dc33..0b5fb1f 100644 --- a/palacios/src/devices/tmpdisk.c +++ b/palacios/src/devices/tmpdisk.c @@ -32,7 +32,7 @@ struct blk_state { static uint64_t blk_get_capacity(void * private_data) { struct blk_state * blk = (struct blk_state *)private_data; - // PrintDebug("SymBlk: Getting Capacity %d\n", (uint32_t)(blk->capacity)); + // PrintDebug(info->vm_info, info, "SymBlk: Getting Capacity %d\n", (uint32_t)(blk->capacity)); return blk->capacity; } @@ -42,10 +42,10 @@ static uint64_t blk_get_capacity(void * private_data) { static int blk_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data) { struct blk_state * blk = (struct blk_state *)private_data; - // PrintDebug("TmpDisk Reading %d bytes to %p (lba=%p)\n", (uint32_t)num_bytes, buf, (void *)(addr_t)lba); + // PrintDebug(info->vm_info, info, "TmpDisk Reading %d bytes to %p (lba=%p)\n", (uint32_t)num_bytes, buf, (void *)(addr_t)lba); if (lba + num_bytes > blk->capacity) { - PrintError("TMPDISK Read past end of disk\n"); + PrintError(VM_NONE, VCORE_NONE, "TMPDISK Read past end of disk\n"); return -1; } @@ -60,10 +60,10 @@ static int blk_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * priv static int blk_write(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data) { struct blk_state * blk = (struct blk_state *)private_data; - // PrintDebug("TmpDisk Writing %d bytes to %p (lba=%p)\n", (uint32_t)num_bytes, buf, (void *)(addr_t)lba); + // PrintDebug(VM_NONE, VCORE_NONE, "TmpDisk Writing %d bytes to %p (lba=%p)\n", (uint32_t)num_bytes, buf, (void *)(addr_t)lba); if (lba + num_bytes > blk->capacity) { - PrintError("TMPDISK Write past end of disk\n"); + PrintError(VM_NONE, VCORE_NONE, "TMPDISK Write past end of disk\n"); return -1; } @@ -104,17 +104,17 @@ static int blk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { uint64_t capacity = atoi(v3_cfg_val(cfg, "size")) * 1024 * 1024; if (!frontend_cfg) { - PrintError("Frontend Configuration not present\n"); + PrintError(vm, VCORE_NONE, "Frontend Configuration not present\n"); return -1; } - PrintDebug("Intializing TMPDISK (capacity=%d)\n", (uint32_t)capacity); + PrintDebug(vm, VCORE_NONE, "Intializing TMPDISK (capacity=%d)\n", (uint32_t)capacity); blk = (struct blk_state *)V3_Malloc(sizeof(struct blk_state)); if (!blk) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -123,7 +123,7 @@ static int blk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { blk->blk_base_addr = (addr_t)V3_AllocPages(blk->capacity / 4096); if (!blk->blk_base_addr) { - PrintError("Cannot allocate block space\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate block space\n"); V3_Free(blk); return -1; } @@ -135,14 +135,14 @@ static int blk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, blk); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(blk); return -1; } if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"), &blk_ops, frontend_cfg, blk) == -1) { - PrintError("Could not connect %s to frontend %s\n", + PrintError(vm, VCORE_NONE, "Could not connect %s to frontend %s\n", dev_id, v3_cfg_val(frontend_cfg, "tag")); v3_remove_device(dev); return -1; diff --git a/palacios/src/devices/vga.c b/palacios/src/devices/vga.c index f9c4e90..db11ea4 100644 --- a/palacios/src/devices/vga.c +++ b/palacios/src/devices/vga.c @@ -443,7 +443,7 @@ static void find_text_font_start(struct vga_internal *vga, void **data, uint8_t *data = vga->map[2] + mapb_offset; break; default: - PrintError("vga: unknown char_map given to find_text_font_start\n"); + PrintError(VM_NONE, VCORE_NONE, "vga: unknown char_map given to find_text_font_start\n"); break; } @@ -653,7 +653,7 @@ static void render_graphics(struct vga_internal *vga, void *fb) fh = spec->height; - PrintDebug("vga: attempting graphics render (%s): graphics_res=(%u,%u), fb_res=(%u,%u), " + PrintDebug(VM_NONE, VCORE_NONE, "vga: attempting graphics render (%s): graphics_res=(%u,%u), fb_res=(%u,%u), " "fb=0x%p offset=0x%x\n", sm == PLANAR_SHIFT ? "planar shift" : sm == PACKED_SHIFT ? "packed shift" : @@ -665,7 +665,7 @@ static void render_graphics(struct vga_internal *vga, void *fb) rgh = gh < fh ? gh : fh; if (gw%8) { - PrintError("vga: warning: graphics width is not a multiple of 8\n"); + PrintError(VM_NONE, VCORE_NONE, "vga: warning: graphics width is not a multiple of 8\n"); } @@ -751,7 +751,7 @@ static void render_graphics(struct vga_internal *vga, void *fb) } } - PrintDebug("vga: render done\n"); + PrintDebug(VM_NONE, VCORE_NONE, "vga: render done\n"); } @@ -818,7 +818,7 @@ static void render_text(struct vga_internal *vga, void *fb) find_text_font_start(vga,(void**)&font,0); // will need to switch this as we go since it is part of attr - PrintDebug("vga: attempting text render: graphics_res=(%u,%u), fb_res=(%u,%u), text_res=(%u,%u), " + PrintDebug(VM_NONE, VCORE_NONE, "vga: attempting text render: graphics_res=(%u,%u), fb_res=(%u,%u), text_res=(%u,%u), " "char_res=(%u,%u), cursor=(%u,%u) font=0x%p, text=0x%p, attr=0x%p, curs=0x%p, fb=0x%p" "graphics extension=%u, extended_fontset=%d, blinking=%d\n", gw,gh,fw,fh,tw,th,cw,ch,px,py,font,text,attr,curs,fb, @@ -831,7 +831,7 @@ static void render_text(struct vga_internal *vga, void *fb) rtw = tw < fw/cw ? tw : fw/cw; rth = th < fh/ch ? th : fh/ch; - PrintDebug("\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\n"); // Now let's scan by char across the whole thing for (y=0;yupdates_since_render); + PrintDebug(VM_NONE, VCORE_NONE, "vga: render on update %u\n",vga->updates_since_render); fb = v3_graphics_console_get_frame_buffer_data_rw(vga->host_cons,&(vga->target_spec)); @@ -1055,7 +1055,7 @@ static int render(struct vga_internal *vga) if ((vga->render_model.model & VGA_DRIVEN_PERIODIC_RENDERING) && (vga->updates_since_render > vga->render_model.updates_before_render)) { - PrintDebug("vga: render due to periodic\n"); + PrintDebug(VM_NONE, VCORE_NONE, "vga: render due to periodic\n"); do_render = 1; } @@ -1064,7 +1064,7 @@ static int render(struct vga_internal *vga) && (v3_graphics_console_inform_update(vga->host_cons) > 0) ) { - PrintDebug("vga: render due to advisory\n"); + PrintDebug(VM_NONE, VCORE_NONE, "vga: render due to advisory\n"); do_render = 1; } @@ -1087,7 +1087,7 @@ static int render_callback(v3_graphics_console_t cons, { struct vga_internal *vga = (struct vga_internal *) priv; - PrintDebug("vga: render due to callback\n"); + PrintDebug(VM_NONE, VCORE_NONE, "vga: render due to callback\n"); return render_core(vga); } @@ -1190,27 +1190,27 @@ static int vga_write(struct guest_info * core, struct vm_device *dev = (struct vm_device *)priv_data; struct vga_internal *vga = (struct vga_internal *) dev->private_data; - PrintDebug("vga: memory write: guest_addr=0x%p len=%u write_mode=%d\n",(void*)guest_addr, length, + PrintDebug(core->vm_info, core, "vga: memory write: guest_addr=0x%p len=%u write_mode=%d\n",(void*)guest_addr, length, vga->vga_graphics_controller.vga_graphics_mode.write_mode); if (vga->passthrough) { - PrintDebug("vga: passthrough write to 0x%p\n", V3_VAddr((void*)guest_addr)); + PrintDebug(core->vm_info, core, "vga: passthrough write to 0x%p\n", V3_VAddr((void*)guest_addr)); memcpy(V3_VAddr((void*)guest_addr),src,length); } #if DEBUG_MEM_DATA int i; - PrintDebug("vga: data written was 0x"); + PrintDebug(core->vm_info, core, "vga: data written was 0x"); for (i=0;ivm_info, core, "%.2x", c); } - PrintDebug(" \""); + PrintDebug(core->vm_info, core, " \""); for (i=0;i='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || (c==' ') ? c : '.'); + PrintDebug(core->vm_info, core, "%c", (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || (c==' ') ? c : '.'); } - PrintDebug("\"\n"); + PrintDebug(core->vm_info, core, "\"\n"); #endif /* Write mode determine by Graphics Mode Register (Index 05h).writemode */ @@ -1241,7 +1241,7 @@ static int vga_write(struct guest_info * core, offset = find_offset_write(vga, guest_addr); #if DEBUG_DEEP_MEM - PrintDebug("vga: mode 0 write, offset=0x%llx, ror=%u, func=%u\n", offset,ror,func); + PrintDebug(core->vm_info, core, "vga: mode 0 write, offset=0x%llx, ror=%u, func=%u\n", offset,ror,func); #endif for (i=0;ivm_info, core, "vga: write i=%u, mm=0x%x, bm=0x%x sr=0x%x esr=0x%x offset=0x%x\n",i,(unsigned int)mm,(unsigned int)bm, (unsigned int)sr, (unsigned int)esr,(unsigned int)offset); #endif for (mapnum=0;mapnum<4;mapnum++, sr>>=1, esr>>=1, mm>>=1) { @@ -1261,7 +1261,7 @@ static int vga_write(struct guest_info * core, uint8_t latchval = vga->latch[mapnum]; #if DEBUG_DEEP_MEM - PrintDebug("vga: raw data=0x%x\n",data); + PrintDebug(core->vm_info, core, "vga: raw data=0x%x\n",data); #endif // rotate data right if (ror) { @@ -1269,7 +1269,7 @@ static int vga_write(struct guest_info * core, } #if DEBUG_DEEP_MEM - PrintDebug("vga: data after ror=0x%x\n",data); + PrintDebug(core->vm_info, core, "vga: data after ror=0x%x\n",data); #endif // use SR bit if ESR is on for this map if (esr & 0x1) { @@ -1278,7 +1278,7 @@ static int vga_write(struct guest_info * core, } #if DEBUG_DEEP_MEM - PrintDebug("vga: data after esrr=0x%x\n",data); + PrintDebug(core->vm_info, core, "vga: data after esrr=0x%x\n",data); #endif // Apply function @@ -1297,7 +1297,7 @@ static int vga_write(struct guest_info * core, } #if DEBUG_DEEP_MEM - PrintDebug("vga: data after func=0x%x\n",data); + PrintDebug(core->vm_info, core, "vga: data after func=0x%x\n",data); #endif // mux between the data byte and the latch byte on @@ -1306,14 +1306,14 @@ static int vga_write(struct guest_info * core, #if DEBUG_DEEP_MEM - PrintDebug("vga: data after bm mux=0x%x\n",data); + PrintDebug(core->vm_info, core, "vga: data after bm mux=0x%x\n",data); #endif // selective write if (mm & 0x1) { // write to this map #if DEBUG_DEEP_MEM - PrintDebug("vga: write map %u offset 0x%p map=0x%p pointer=0x%p\n",mapnum,(void*)offset,map,&(map[offset])); + PrintDebug(core->vm_info, core, "vga: write map %u offset 0x%p map=0x%p pointer=0x%p\n",mapnum,(void*)offset,map,&(map[offset])); #endif map[offset] = data; } else { @@ -1338,7 +1338,7 @@ static int vga_write(struct guest_info * core, uint64_t offset = find_offset_write(vga,guest_addr); #if DEBUG_DEEP_MEM - PrintDebug("vga: mode 1 write, offset=0x%llx\n", offset); + PrintDebug(core->vm_info, core, "vga: mode 1 write, offset=0x%llx\n", offset); #endif for (i=0;ivm_info, core, "vga: mode 2 write, offset=0x%llx, func=%u\n", offset,func); #endif for (i=0;ivm_info, core, "vga: mode 3 write, offset=0x%llx, ror=%u\n", offset,ror); for (i=0;iprivate_data; - PrintDebug("vga: memory read: guest_addr=0x%p len=%u read_mode=%d\n",(void*)guest_addr, length, + PrintDebug(core->vm_info, core, "vga: memory read: guest_addr=0x%p len=%u read_mode=%d\n",(void*)guest_addr, length, vga->vga_graphics_controller.vga_graphics_mode.read_mode); @@ -1595,7 +1595,7 @@ static int vga_read(struct guest_info * core, offset = find_offset_read(vga,guest_addr); #if DEBUG_DEEP_MEM - PrintDebug("vga: mode 0 read, offset=0x%llx\n",offset); + PrintDebug(core->vm_info, core, "vga: mode 0 read, offset=0x%llx\n",offset); #endif for (i=0;ivm_info, core, "vga: mode 1 read, offset=0x%llx, cc=0x%x, dc-0x%x\n",offset,cc,dc); #endif @@ -1668,24 +1668,24 @@ static int vga_read(struct guest_info * core, } if (vga->passthrough) { - PrintDebug("vga: passthrough read from 0x%p\n",V3_VAddr((void*)guest_addr)); + PrintDebug(core->vm_info, core, "vga: passthrough read from 0x%p\n",V3_VAddr((void*)guest_addr)); memcpy(dst,V3_VAddr((void*)guest_addr),length); } #if DEBUG_MEM_DATA int i; - PrintDebug("vga: data read is 0x"); + PrintDebug(core->vm_info, core, "vga: data read is 0x"); for (i=0;ivm_info, core, "%.2x", c); } - PrintDebug(" \""); + PrintDebug(core->vm_info, core, " \""); for (i=0;i='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || (c==' ') ? c : '.'); + PrintDebug(core->vm_info, core, "%c", (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || (c==' ') ? c : '.'); } - PrintDebug("\"\n"); + PrintDebug(core->vm_info, core, "\"\n"); #endif return length; @@ -1698,7 +1698,7 @@ static int vga_read(struct guest_info * core, #define ERR_WRONG_SIZE(op,reg,len,min,max) \ if (((len)<(min)) || ((len)>(max))) { \ - PrintError("vga: %s of %s wrong size (%d bytes, but only %d to %d allowed)\n",(op),(reg),(len),(min),(max)); \ + PrintError(core->vm_info, core, "vga: %s of %s wrong size (%d bytes, but only %d to %d allowed)\n",(op),(reg),(len),(min),(max)); \ return -1; \ } @@ -1714,7 +1714,7 @@ static inline void passthrough_io_in(uint16_t port, void * dest, uint_t length) *(uint32_t *)dest = v3_indw(port); break; default: - PrintError("vga: unsupported passthrough io in size %u\n",length); + PrintError(VM_NONE, VCORE_NONE, "vga: unsupported passthrough io in size %u\n",length); break; } } @@ -1732,7 +1732,7 @@ static inline void passthrough_io_out(uint16_t port, const void * src, uint_t le v3_outdw(port, *(uint32_t *)src); break; default: - PrintError("vga: unsupported passthrough io out size %u\n",length); + PrintError(VM_NONE, VCORE_NONE, "vga: unsupported passthrough io out size %u\n",length); break; } } @@ -1747,7 +1747,7 @@ static inline void passthrough_io_out(uint16_t port, const void * src, uint_t le do { if ((vga)->passthrough) { (vga)->skip_next_passthrough_out=true; } } while (0) #define PASSTHROUGH_READ_CHECK(vga,inter,pass) \ - do { if ((vga)->passthrough) { if ((inter)!=(pass)) { PrintError("vga: passthrough error: passthrough value read is 0x%x, but internal value read is 0x%x\n",(pass),(inter)); } } } while (0) + do { if ((vga)->passthrough) { if ((inter)!=(pass)) { PrintError(core->vm_info, core, "vga: passthrough error: passthrough value read is 0x%x, but internal value read is 0x%x\n",(pass),(inter)); } } } while (0) static int misc_out_read(struct guest_info *core, uint16_t port, @@ -1757,7 +1757,7 @@ static int misc_out_read(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: misc out read data=0x%x\n", vga->vga_misc.vga_misc_out.val); + PrintDebug(core->vm_info, core, "vga: misc out read data=0x%x\n", vga->vga_misc.vga_misc_out.val); ERR_WRONG_SIZE("read","misc out",len,1,1); @@ -1778,7 +1778,7 @@ static int misc_out_write(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: misc out write data=0x%x\n", *((uint8_t*)src)); + PrintDebug(core->vm_info, core, "vga: misc out write data=0x%x\n", *((uint8_t*)src)); ERR_WRONG_SIZE("write","misc out",len,1,1); @@ -1801,7 +1801,7 @@ static int input_stat0_read(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: input stat0 read data=0x%x\n", vga->vga_misc.vga_input_stat0.val); + PrintDebug(core->vm_info, core, "vga: input stat0 read data=0x%x\n", vga->vga_misc.vga_input_stat0.val); ERR_WRONG_SIZE("read","input stat0",len,1,1); @@ -1823,7 +1823,7 @@ static int input_stat1_read(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: input stat0 (%s) read data=0x%x\n", + PrintDebug(core->vm_info, core, "vga: input stat0 (%s) read data=0x%x\n", port==0x3ba ? "mono" : "color", vga->vga_misc.vga_input_stat1.val); @@ -1854,7 +1854,7 @@ static int feature_control_read(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: feature control read data=0x%x\n", + PrintDebug(core->vm_info, core, "vga: feature control read data=0x%x\n", vga->vga_misc.vga_feature_control.val); ERR_WRONG_SIZE("read","feature control",len,1,1); @@ -1877,7 +1877,7 @@ static int feature_control_write(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: feature control (%s) write data=0x%x\n", + PrintDebug(core->vm_info, core, "vga: feature control (%s) write data=0x%x\n", port==0x3ba ? "mono" : "color", *((uint8_t*)src)); @@ -1901,7 +1901,7 @@ static int video_subsys_enable_read(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: video subsys enable read data=0x%x\n", + PrintDebug(core->vm_info, core, "vga: video subsys enable read data=0x%x\n", vga->vga_misc.vga_video_subsys_enable.val); ERR_WRONG_SIZE("read","video subsys enable",len,1,1); @@ -1923,7 +1923,7 @@ static int video_subsys_enable_write(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: video subsys enable write data=0x%x\n", *((uint8_t*)src)); + PrintDebug(core->vm_info, core, "vga: video subsys enable write data=0x%x\n", *((uint8_t*)src)); ERR_WRONG_SIZE("write","video subsys enable",len,1,1); @@ -1944,7 +1944,7 @@ static int sequencer_address_read(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: sequencer address read data=0x%x\n", + PrintDebug(core->vm_info, core, "vga: sequencer address read data=0x%x\n", vga->vga_sequencer.vga_sequencer_addr.val); ERR_WRONG_SIZE("read","vga sequencer addr",len,1,1); @@ -1971,7 +1971,7 @@ static int sequencer_data_write(struct guest_info *core, data=*((uint8_t*)src); index=vga->vga_sequencer.vga_sequencer_addr.val; // should mask probably - PrintDebug("vga: sequencer write data (index=%d) with 0x%x\n", + PrintDebug(core->vm_info, core, "vga: sequencer write data (index=%d) with 0x%x\n", index, data); ERR_WRONG_SIZE("write","vga sequencer data",len,1,1); @@ -1980,7 +1980,7 @@ static int sequencer_data_write(struct guest_info *core, if (index>=VGA_SEQUENCER_NUM) { - PrintError("vga: sequencer data write is for invalid index %d, ignoring\n",index); + PrintError(core->vm_info, core, "vga: sequencer data write is for invalid index %d, ignoring\n",index); } else { vga->vga_sequencer.vga_sequencer_regs[index] = data; } @@ -2001,7 +2001,7 @@ static int sequencer_address_write(struct guest_info *core, new_addr=*((uint8_t*)src); - PrintDebug("vga: sequencer address write data=0x%x len=%u\n", len==1 ? *((uint8_t*)src) : len==2 ? *((uint16_t*)src) : *((uint32_t*)src), len); + PrintDebug(core->vm_info, core, "vga: sequencer address write data=0x%x len=%u\n", len==1 ? *((uint8_t*)src) : len==2 ? *((uint16_t*)src) : *((uint32_t*)src), len); ERR_WRONG_SIZE("write","vga sequencer addr",len,1,2); @@ -2013,7 +2013,7 @@ static int sequencer_address_write(struct guest_info *core, PASSTHROUGH_IO_SKIP_NEXT_OUT(vga); // second byte is the data if (sequencer_data_write(core,port,src+1,1,vga)!=1) { - PrintError("vga: write of data failed\n"); + PrintError(core->vm_info, core, "vga: write of data failed\n"); return -1; } } @@ -2035,12 +2035,12 @@ static int sequencer_data_read(struct guest_info *core, if (index>=VGA_SEQUENCER_NUM) { data=0; - PrintError("vga: sequencer data read at invalid index %d, returning zero\n",index); + PrintError(core->vm_info, core, "vga: sequencer data read at invalid index %d, returning zero\n",index); } else { data=vga->vga_sequencer.vga_sequencer_regs[index]; } - PrintDebug("vga: sequencer data read data (index=%d) = 0x%x\n", + PrintDebug(core->vm_info, core, "vga: sequencer data read data (index=%d) = 0x%x\n", index, data); ERR_WRONG_SIZE("read","vga sequencer data",len,1,1); @@ -2066,7 +2066,7 @@ static int crt_controller_address_read(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: crt controller (%s) address read data=0x%x\n", + PrintDebug(core->vm_info, core, "vga: crt controller (%s) address read data=0x%x\n", port==0x3b4 ? "mono" : "color", vga->vga_crt_controller.vga_crt_addr.val); @@ -2095,7 +2095,7 @@ static int crt_controller_data_write(struct guest_info *core, index=vga->vga_crt_controller.vga_crt_addr.val; // should mask probably - PrintDebug("vga: crt controller (%s) write data (index=%d) with 0x%x\n", + PrintDebug(core->vm_info, core, "vga: crt controller (%s) write data (index=%d) with 0x%x\n", port==0x3b5 ? "mono" : "color", index, data); @@ -2104,7 +2104,7 @@ static int crt_controller_data_write(struct guest_info *core, PASSTHROUGH_IO_OUT(vga,port,src,len); if (index>=VGA_CRT_CONTROLLER_NUM) { - PrintError("vga; crt controller write is for illegal index %d, ignoring\n",index); + PrintError(core->vm_info, core, "vga; crt controller write is for illegal index %d, ignoring\n",index); } else { vga->vga_crt_controller.vga_crt_controller_regs[index] = data; } @@ -2125,7 +2125,7 @@ static int crt_controller_address_write(struct guest_info *core, new_addr=*((uint8_t*)src); - PrintDebug("vga: crt controller (%s) address write data=0x%x len=%u\n", + PrintDebug(core->vm_info, core, "vga: crt controller (%s) address write data=0x%x len=%u\n", port==0x3b4 ? "mono" : "color", len==1 ? *((uint8_t*)src) : len==2 ? *((uint16_t*)src) : *((uint32_t*)src), len); @@ -2139,7 +2139,7 @@ static int crt_controller_address_write(struct guest_info *core, PASSTHROUGH_IO_SKIP_NEXT_OUT(vga); // second byte is the data if (crt_controller_data_write(core,port,src+1,1,vga)!=1) { - PrintError("vga: write of data failed\n"); + PrintError(core->vm_info, core, "vga: write of data failed\n"); return -1; } } @@ -2161,12 +2161,12 @@ static int crt_controller_data_read(struct guest_info *core, if (index>=VGA_CRT_CONTROLLER_NUM) { data=0; - PrintError("vga: crt controller data read for illegal index %d, returning zero\n",index); + PrintError(core->vm_info, core, "vga: crt controller data read for illegal index %d, returning zero\n",index); } else { data=vga->vga_crt_controller.vga_crt_controller_regs[index]; } - PrintDebug("vga: crt controller data (index=%d) = 0x%x\n",index,data); + PrintDebug(core->vm_info, core, "vga: crt controller data (index=%d) = 0x%x\n",index,data); ERR_WRONG_SIZE("read","vga crt controller data",len,1,1); @@ -2189,7 +2189,7 @@ static int graphics_controller_address_read(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: graphics controller address read data=0x%x\n", + PrintDebug(core->vm_info, core, "vga: graphics controller address read data=0x%x\n", vga->vga_graphics_controller.vga_graphics_ctrl_addr.val); ERR_WRONG_SIZE("read","vga graphics controller addr",len,1,1); @@ -2217,7 +2217,7 @@ static int graphics_controller_data_write(struct guest_info *core, index=vga->vga_graphics_controller.vga_graphics_ctrl_addr.val; // should mask probably - PrintDebug("vga: graphics_controller write data (index=%d) with 0x%x\n", + PrintDebug(core->vm_info, core, "vga: graphics_controller write data (index=%d) with 0x%x\n", index, data); ERR_WRONG_SIZE("write","vga graphics controller data",len,1,1); @@ -2225,7 +2225,7 @@ static int graphics_controller_data_write(struct guest_info *core, PASSTHROUGH_IO_OUT(vga,port,src,len); if (index>=VGA_GRAPHICS_CONTROLLER_NUM) { - PrintError("vga: graphics controller write for illegal index %d ignored\n",index); + PrintError(core->vm_info, core, "vga: graphics controller write for illegal index %d ignored\n",index); } else { vga->vga_graphics_controller.vga_graphics_controller_regs[index] = data; } @@ -2246,7 +2246,7 @@ static int graphics_controller_address_write(struct guest_info *core, new_addr=*((uint8_t*)src); - PrintDebug("vga: graphics controller address write data=0x%x len=%u\n", + PrintDebug(core->vm_info, core, "vga: graphics controller address write data=0x%x len=%u\n", len==1 ? *((uint8_t*)src) : len==2 ? *((uint16_t*)src) : *((uint32_t*)src), len); ERR_WRONG_SIZE("write","vga graphics controller addr",len,1,2); @@ -2259,7 +2259,7 @@ static int graphics_controller_address_write(struct guest_info *core, PASSTHROUGH_IO_SKIP_NEXT_OUT(vga); // second byte is the data if (graphics_controller_data_write(core,port,src+1,1,vga)!=1) { - PrintError("vga: write of data failed\n"); + PrintError(core->vm_info, core, "vga: write of data failed\n"); return -1; } } @@ -2282,12 +2282,12 @@ static int graphics_controller_data_read(struct guest_info *core, if (index>=VGA_GRAPHICS_CONTROLLER_NUM) { data=0; - PrintError("vga: graphics controller data read from illegal index %d, returning zero\n",index); + PrintError(core->vm_info, core, "vga: graphics controller data read from illegal index %d, returning zero\n",index); } else { data=vga->vga_graphics_controller.vga_graphics_controller_regs[index]; } - PrintDebug("vga: graphics controller data read data (index=%d) = 0x%x\n", + PrintDebug(core->vm_info, core, "vga: graphics controller data read data (index=%d) = 0x%x\n", index, data); ERR_WRONG_SIZE("read","vga graphics controller data",len,1,1); @@ -2314,7 +2314,7 @@ static int attribute_controller_address_read(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: attribute controller address read data=0x%x\n", + PrintDebug(core->vm_info, core, "vga: attribute controller address read data=0x%x\n", vga->vga_attribute_controller.vga_attribute_controller_addr.val); ERR_WRONG_SIZE("read","vga attribute controller addr",len,1,1); @@ -2343,7 +2343,7 @@ static int attribute_controller_address_and_data_write(struct guest_info *core, uint8_t new_addr = *((uint8_t*)src); // We are to treat this as an address write, and flip state // to expect data ON THIS SAME PORT - PrintDebug("vga: attribute controller address write data=0x%x\n", new_addr); + PrintDebug(core->vm_info, core, "vga: attribute controller address write data=0x%x\n", new_addr); ERR_WRONG_SIZE("write","vga attribute controller addr",len,1,1); @@ -2359,14 +2359,14 @@ static int attribute_controller_address_and_data_write(struct guest_info *core, uint8_t data = *((uint8_t*)src); uint8_t index=vga->vga_attribute_controller.vga_attribute_controller_addr.val; // should mask probably - PrintDebug("vga: attribute controller data write index %d with data=0x%x\n", index,data); + PrintDebug(core->vm_info, core, "vga: attribute controller data write index %d with data=0x%x\n", index,data); ERR_WRONG_SIZE("write","vga attribute controller data",len,1,1); PASSTHROUGH_IO_OUT(vga,port,src,len); if (index>=VGA_ATTRIBUTE_CONTROLLER_NUM) { - PrintError("vga: attribute controller write to illegal index %d ignored\n",index); + PrintError(core->vm_info, core, "vga: attribute controller write to illegal index %d ignored\n",index); } else { vga->vga_attribute_controller.vga_attribute_controller_regs[index] = data; } @@ -2394,12 +2394,12 @@ static int attribute_controller_data_read(struct guest_info *core, if (index>=VGA_ATTRIBUTE_CONTROLLER_NUM) { data=0; - PrintError("vga: attribute controller read of illegal index %d, returning zero\n",index); + PrintError(core->vm_info, core, "vga: attribute controller read of illegal index %d, returning zero\n",index); } else { data=vga->vga_attribute_controller.vga_attribute_controller_regs[index]; } - PrintDebug("vga: attribute controller data read data (index=%d) = 0x%x\n", + PrintDebug(core->vm_info, core, "vga: attribute controller data read data (index=%d) = 0x%x\n", index, data); ERR_WRONG_SIZE("read","vga attribute controller data",len,1,1); @@ -2427,7 +2427,7 @@ static int dac_write_address_read(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: dac write address read data=0x%x\n", + PrintDebug(core->vm_info, core, "vga: dac write address read data=0x%x\n", vga->vga_dac.vga_dac_write_addr); ERR_WRONG_SIZE("read","vga dac write addr",len,1,1); @@ -2455,7 +2455,7 @@ static int dac_write_address_write(struct guest_info *core, new_addr=*((uint8_t*)src); - PrintDebug("vga: dac write address write data=0x%x\n", new_addr); + PrintDebug(core->vm_info, core, "vga: dac write address write data=0x%x\n", new_addr); ERR_WRONG_SIZE("write","vga dac write addr",len,1,1); @@ -2482,7 +2482,7 @@ static int dac_read_address_read(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: dac read address read data=0x%x\n", + PrintDebug(core->vm_info, core, "vga: dac read address read data=0x%x\n", vga->vga_dac.vga_dac_read_addr); ERR_WRONG_SIZE("read","vga dac read addr",len,1,1); @@ -2509,7 +2509,7 @@ static int dac_read_address_write(struct guest_info *core, new_addr=*((uint8_t*)src); - PrintDebug("vga: dac read address write data=0x%x\n", new_addr); + PrintDebug(core->vm_info, core, "vga: dac read address write data=0x%x\n", new_addr); ERR_WRONG_SIZE("write","vga dac read addr",len,1,1); @@ -2540,7 +2540,7 @@ static int dac_data_read(struct guest_info *core, uint8_t data; if (vga->vga_dac.state!=DAC_READ) { - PrintError("vga: dac data read while in other state\n"); + PrintError(core->vm_info, core, "vga: dac data read while in other state\n"); // results undefined, so we continue } @@ -2550,7 +2550,7 @@ static int dac_data_read(struct guest_info *core, curchannel = vga->vga_dac.channel; data = (vga->vga_dac.vga_dac_palette[curreg] >> curchannel*8) & 0x3f; - PrintDebug("vga: dac reg %u [%s] = 0x%x\n", + PrintDebug(core->vm_info, core, "vga: dac reg %u [%s] = 0x%x\n", curreg, curchannel == 0 ? "RED" : curchannel == 1 ? "GREEN" : curchannel==2 ? "BLUE" : "BAD CHANNEL", @@ -2589,7 +2589,7 @@ static int dac_data_write(struct guest_info *core, vga_palette_reg mask32; if (vga->vga_dac.state!=DAC_WRITE) { - PrintError("vga: dac data write while in other state\n"); + PrintError(core->vm_info, core, "vga: dac data write while in other state\n"); // results undefined, so we continue } @@ -2601,7 +2601,7 @@ static int dac_data_write(struct guest_info *core, curchannel = vga->vga_dac.channel; data = *((uint8_t *)src); - PrintDebug("vga: dac reg %u [%s] write with 0x%x\n", + PrintDebug(core->vm_info, core, "vga: dac reg %u [%s] write with 0x%x\n", curreg, curchannel == 0 ? "RED" : curchannel == 1 ? "GREEN" : curchannel==2 ? "BLUE" : "BAD CHANNEL", @@ -2637,7 +2637,7 @@ static int dac_pixel_mask_read(struct guest_info *core, { struct vga_internal *vga = (struct vga_internal *) priv_data; - PrintDebug("vga: dac pixel mask read data=0x%x\n", + PrintDebug(core->vm_info, core, "vga: dac pixel mask read data=0x%x\n", vga->vga_dac.vga_pixel_mask); ERR_WRONG_SIZE("read","vga pixel mask",len,1,1); @@ -2662,7 +2662,7 @@ static int dac_pixel_mask_write(struct guest_info *core, new_data=*((uint8_t*)src); - PrintDebug("vga: dac pixel mask write data=0x%x\n", new_data); + PrintDebug(core->vm_info, core, "vga: dac pixel mask write data=0x%x\n", new_data); ERR_WRONG_SIZE("write","pixel mask",len,1,1); @@ -2764,12 +2764,12 @@ static int vga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { char * passthrough = v3_cfg_val(cfg, "passthrough"); char * hostframebuf = v3_cfg_val(cfg, "hostframebuf"); - PrintDebug("vga: init_device\n"); + PrintDebug(vm, VCORE_NONE, "vga: init_device\n"); vga = (struct vga_internal *)V3_Malloc(sizeof(struct vga_internal)); if (!vga) { - PrintError("vga: cannot allocate\n"); + PrintError(vm, VCORE_NONE, "vga: cannot allocate\n"); return -1; } @@ -2779,7 +2779,7 @@ static int vga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { vga->render_model.updates_before_render = DEFAULT_UPDATES_BEFORE_RENDER; if (passthrough && strcasecmp(passthrough,"enable")==0) { - PrintDebug("vga: enabling passthrough\n"); + PrintDebug(vm, VCORE_NONE, "vga: enabling passthrough\n"); vga->passthrough=true; vga->skip_next_passthrough_out=false; } @@ -2788,7 +2788,7 @@ static int vga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { if (hostframebuf && strcasecmp(hostframebuf,"enable")==0) { struct v3_frame_buffer_spec req; - PrintDebug("vga: enabling host frame buffer console (GRAPHICS_CONSOLE)\n"); + PrintDebug(vm, VCORE_NONE, "vga: enabling host frame buffer console (GRAPHICS_CONSOLE)\n"); memset(&req,0,sizeof(struct v3_frame_buffer_spec)); memset(&(vga->target_spec),0,sizeof(struct v3_frame_buffer_spec)); @@ -2805,37 +2805,37 @@ static int vga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { vga->host_cons = v3_graphics_console_open(vm,&req,&(vga->target_spec)); if (!vga->host_cons) { - PrintError("vga: unable to open host OS's graphics console\n"); + PrintError(vm, VCORE_NONE, "vga: unable to open host OS's graphics console\n"); free_vga(vga); return -1; } if (memcmp(&req,&(vga->target_spec),sizeof(req))) { - PrintDebug("vga: warning: target spec differs from requested spec\n"); - PrintDebug("vga: request: %u by %u by %u with %u bpc and r,g,b at %u, %u, %u\n", req.width, req.height, req.bytes_per_pixel, req.bits_per_channel, req.red_offset, req.green_offset, req.blue_offset); - PrintDebug("vga: response: %u by %u by %u with %u bpc and r,g,b at %u, %u, %u\n", vga->target_spec.width, vga->target_spec.height, vga->target_spec.bytes_per_pixel, vga->target_spec.bits_per_channel, vga->target_spec.red_offset, vga->target_spec.green_offset, vga->target_spec.blue_offset); + PrintDebug(vm, VCORE_NONE, "vga: warning: target spec differs from requested spec\n"); + PrintDebug(vm, VCORE_NONE, "vga: request: %u by %u by %u with %u bpc and r,g,b at %u, %u, %u\n", req.width, req.height, req.bytes_per_pixel, req.bits_per_channel, req.red_offset, req.green_offset, req.blue_offset); + PrintDebug(vm, VCORE_NONE, "vga: response: %u by %u by %u with %u bpc and r,g,b at %u, %u, %u\n", vga->target_spec.width, vga->target_spec.height, vga->target_spec.bytes_per_pixel, vga->target_spec.bits_per_channel, vga->target_spec.red_offset, vga->target_spec.green_offset, vga->target_spec.blue_offset); } if (vga->render_model.model & CONSOLE_DRIVEN_RENDERING) { - V3_Print("vga: enabling console-driven rendering\n"); + V3_Print(vm, VCORE_NONE, "vga: enabling console-driven rendering\n"); if (v3_graphics_console_register_render_request(vga->host_cons, render_callback, vga)!=0) { - PrintError("vga: cannot enable console-driven rendering\n"); + PrintError(vm, VCORE_NONE, "vga: cannot enable console-driven rendering\n"); free_vga(vga); return -1; } } - V3_Print("vga: enabling console inquiry for updates\n"); + V3_Print(vm, VCORE_NONE, "vga: enabling console inquiry for updates\n"); if (v3_graphics_console_register_update_inquire(vga->host_cons, update_callback, vga)!=0) { - PrintError("vga: cannot enable console inquiry for updates\n"); + PrintError(vm, VCORE_NONE, "vga: cannot enable console inquiry for updates\n"); free_vga(vga); return -1; } } if (!vga->passthrough && !vga->host_cons) { - V3_Print("vga: neither passthrough nor host console are enabled - no way to display anything!\n"); + V3_Print(vm, VCORE_NONE, "vga: neither passthrough nor host console are enabled - no way to display anything!\n"); } @@ -2849,7 +2849,7 @@ static int vga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { temp = (void*)V3_AllocPages(MAP_SIZE/4096); if (!temp) { - PrintError("vga: cannot allocate maps\n"); + PrintError(vm, VCORE_NONE, "vga: cannot allocate maps\n"); free_vga(vga); return -1; } @@ -2862,7 +2862,7 @@ static int vga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, vga); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); free_vga(vga); return -1; } @@ -2874,7 +2874,7 @@ static int vga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { &vga_read, &vga_write, dev) == -1) { - PrintError("vga: memory book failed\n"); + PrintError(vm, VCORE_NONE, "vga: memory book failed\n"); v3_remove_device(dev); return -1; } @@ -2918,14 +2918,14 @@ static int vga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { ret |= v3_dev_hook_io(dev, VGA_DAC_PIXEL_MASK, &dac_pixel_mask_read, &dac_pixel_mask_write); if (ret != 0) { - PrintError("vga: Error allocating VGA I/O ports\n"); + PrintError(vm, VCORE_NONE, "vga: Error allocating VGA I/O ports\n"); v3_remove_device(dev); return -1; } init_vga(vga); - PrintDebug("vga: successfully added and initialized.\n"); + PrintDebug(vm, VCORE_NONE, "vga: successfully added and initialized.\n"); return 0; diff --git a/palacios/src/devices/vnet_guest_iface.c b/palacios/src/devices/vnet_guest_iface.c index df51d93..ea5a5a2 100644 --- a/palacios/src/devices/vnet_guest_iface.c +++ b/palacios/src/devices/vnet_guest_iface.c @@ -73,7 +73,7 @@ static int handle_header_query_hcall(struct guest_info * info, uint_t hcall_id, struct v3_vnet_header vnet_header; if (hcall_id != VNET_HEADER_QUERY_HCALL) { - PrintError("Unknown hcall 0x%x in vnet_stub\n",hcall_id); + PrintError(info->vm_info, info, "Unknown hcall 0x%x in vnet_stub\n",hcall_id); return -1; } @@ -84,19 +84,19 @@ static int handle_header_query_hcall(struct guest_info * info, uint_t hcall_id, recv = info->vm_regs.r8; if (v3_read_gva_memory(info,src_mac_gva,6,src_mac)!=6) { - PrintError("Cannot read src mac in query\n"); + PrintError(info->vm_info, info, "Cannot read src mac in query\n"); info->vm_regs.rax=-1; return 0; } if (v3_read_gva_memory(info,(addr_t)dest_mac_gva,6,dest_mac)!=6) { - PrintError("Cannot read src mac in query\n"); + PrintError(info->vm_info, info, "Cannot read src mac in query\n"); info->vm_regs.rax=-1; return 0; } if (v3_vnet_query_header(src_mac,dest_mac,recv,&vnet_header) < 0 ) { - PrintError("Failed to lookup header\n"); + PrintError(info->vm_info, info, "Failed to lookup header\n"); info->vm_regs.rax=-1; return 0; } @@ -104,7 +104,7 @@ static int handle_header_query_hcall(struct guest_info * info, uint_t hcall_id, copy_len = (sizeof(vnet_header)vm_info, info, "Failed to write back header\n"); info->vm_regs.rax=-1; return 0; } @@ -128,12 +128,12 @@ static int dev_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { char * name = v3_cfg_val(cfg, "name"); - PrintDebug("VNET guest interface: Initializing as device: %s\n", name); + PrintDebug(vm, VCORE_NONE, "VNET guest interface: Initializing as device: %s\n", name); struct vm_device * dev = v3_add_device(vm, name, &dev_ops, NULL); if (dev == NULL) { - PrintError("Could not attach device %s\n", name); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", name); return -1; } diff --git a/palacios/src/devices/vnet_nic.c b/palacios/src/devices/vnet_nic.c index 375a974..31c026d 100644 --- a/palacios/src/devices/vnet_nic.c +++ b/palacios/src/devices/vnet_nic.c @@ -112,14 +112,14 @@ static int vnet_nic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { v3_cfg_tree_t * frontend_cfg = v3_cfg_subtree(cfg, "frontend"); if (!frontend_cfg || !(v3_cfg_val(frontend_cfg, "tag"))) { - PrintError("No frontend config specified, or frontend has no tag\n"); + PrintError(vm, VCORE_NONE, "No frontend config specified, or frontend has no tag\n"); return -1; } vnetnic = (struct vnet_nic_state *)V3_Malloc(sizeof(struct vnet_nic_state)); if (!vnetnic) { - PrintError("Cannot allocate in init\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in init\n"); return -1; } @@ -127,7 +127,7 @@ static int vnet_nic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, vnetnic); if (dev == NULL) { - PrintError("Could not attach device %s\n", dev_id); + PrintError(vm, VCORE_NONE, "Could not attach device %s\n", dev_id); V3_Free(vnetnic); return -1; } @@ -137,19 +137,19 @@ static int vnet_nic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { if (v3_dev_connect_net(vm, v3_cfg_val(frontend_cfg, "tag"), &(vnetnic->net_ops), frontend_cfg, vnetnic) == -1) { - PrintError("Could not connect %s to frontend %s\n", + PrintError(vm, VCORE_NONE, "Could not connect %s to frontend %s\n", dev_id, v3_cfg_val(frontend_cfg, "tag")); v3_remove_device(dev); return -1; } - PrintDebug("Vnet-nic: Connect %s to frontend %s\n", + PrintDebug(vm, VCORE_NONE, "Vnet-nic: Connect %s to frontend %s\n", dev_id, v3_cfg_val(frontend_cfg, "tag")); if ((vnet_dev_id = v3_vnet_add_dev(vm, vnetnic->net_ops.config.fnt_mac, &vnet_dev_ops, vnetnic->net_ops.config.quote, vnetnic->net_ops.config.poll, (void *)vnetnic)) == -1) { - PrintError("Vnet-nic device %s fails to registered to VNET\n", dev_id); + PrintError(vm, VCORE_NONE, "Vnet-nic device %s fails to registered to VNET\n", dev_id); v3_remove_device(dev); return 0; diff --git a/palacios/src/extensions/ext_inspector.c b/palacios/src/extensions/ext_inspector.c index cceafab..f1683a0 100644 --- a/palacios/src/extensions/ext_inspector.c +++ b/palacios/src/extensions/ext_inspector.c @@ -40,7 +40,7 @@ static int init_inspector(struct v3_vm_info * vm, v3_cfg_tree_t * cfg, void ** p struct v3_inspector_state * state = V3_Malloc(sizeof(struct v3_inspector_state)); if (!state) { - PrintError("Cannot allocate state in inspector\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate state in inspector\n"); return -1; } diff --git a/palacios/src/extensions/ext_mcheck.c b/palacios/src/extensions/ext_mcheck.c index ea746f4..704a1f9 100644 --- a/palacios/src/extensions/ext_mcheck.c +++ b/palacios/src/extensions/ext_mcheck.c @@ -238,7 +238,7 @@ int mcg_write_handler(struct guest_info * core, uint32_t msr, struct v3_msr src, switch (msr) { case MCG_CAP: - PrintDebug(MSG_PRE "Ignoring write to MCG_CAP MSR.\n"); + PrintDebug(core->vm_info, core, MSG_PRE "Ignoring write to MCG_CAP MSR.\n"); break; case MCG_STAT: @@ -247,7 +247,7 @@ int mcg_write_handler(struct guest_info * core, uint32_t msr, struct v3_msr src, case MCG_CTRL: if (!state->mcg_cap.mcg_ctl_p) { - PrintDebug(MSG_PRE "Ignoring write to control MSR '0x%x'. Control MSRs not supported.\n", msr); + PrintDebug(core->vm_info, core, MSG_PRE "Ignoring write to control MSR '0x%x'. Control MSRs not supported.\n", msr); break; } @@ -258,7 +258,7 @@ int mcg_write_handler(struct guest_info * core, uint32_t msr, struct v3_msr src, break; default: - PrintError(MSG_PRE "Reading from invalid MSR: %x\n", msr); + PrintError(core->vm_info, core, MSG_PRE "Reading from invalid MSR: %x\n", msr); return -1; } @@ -284,7 +284,7 @@ int mcg_read_handler(struct guest_info * core, uint32_t msr, struct v3_msr * dst case MCG_CTRL: if (!state->mcg_cap.mcg_ctl_p) { - PrintDebug(MSG_PRE "Ignoring read of control MSR '0x%x'. Control MSRs not supported.\n", msr); + PrintDebug(core->vm_info, core, MSG_PRE "Ignoring read of control MSR '0x%x'. Control MSRs not supported.\n", msr); break; } @@ -292,7 +292,7 @@ int mcg_read_handler(struct guest_info * core, uint32_t msr, struct v3_msr * dst break; default: - PrintError(MSG_PRE "Reading from invalid MSR: %x\n", msr); + PrintError(core->vm_info, core, MSG_PRE "Reading from invalid MSR: %x\n", msr); return -1; } @@ -323,17 +323,17 @@ int mci_read_handler(struct guest_info * const core, struct mcheck_state * const state = (struct mcheck_state *)priv_data; struct mci_bank * mci = get_mci_reg(state, msr); - PrintDebug(MSG_PRE "Reading value '0x%llx' for MSR '0x%x'.\n", dst->value, msr); + PrintDebug(core->vm_info, core, MSG_PRE "Reading value '0x%llx' for MSR '0x%x'.\n", dst->value, msr); if (mci == NULL) { - PrintError(MSG_PRE " MSR read for invalid MCI register 0x%x\n", msr); + PrintError(core->vm_info, core, MSG_PRE " MSR read for invalid MCI register 0x%x\n", msr); return -1; } switch (msr & ~MCi_MASK) { case MCi_CTRL: if (!state->mcg_cap.mcg_ctl_p) { - PrintDebug(MSG_PRE "Ignoring read of control MSR '0x%x'. Control MSRs not supported.\n", msr); + PrintDebug(core->vm_info, core, MSG_PRE "Ignoring read of control MSR '0x%x'. Control MSRs not supported.\n", msr); break; } @@ -353,7 +353,7 @@ int mci_read_handler(struct guest_info * const core, break; default: - PrintError(MSG_PRE "Ignoring read of unhooked MSR '0x%x'. This is a bug.\n", msr); + PrintError(core->vm_info, core, MSG_PRE "Ignoring read of unhooked MSR '0x%x'. This is a bug.\n", msr); break; } @@ -371,12 +371,12 @@ int mci_write_handler(struct guest_info * const core, struct mcheck_state * const state = (struct mcheck_state *)priv_data; struct mci_bank * mci = get_mci_reg(state, msr); - PrintDebug(MSG_PRE "Writing value '0x%llx' for MSR '0x%x'.\n", src.value, msr); + PrintDebug(core->vm_info, core, MSG_PRE "Writing value '0x%llx' for MSR '0x%x'.\n", src.value, msr); switch (msr & ~MCi_MASK) { case MCi_CTRL: if (!state->mcg_cap.mcg_ctl_p) { - PrintDebug(MSG_PRE "Ignoring read of control MSR '0x%x'. Control MSRs not supported.\n", msr); + PrintDebug(core->vm_info, core, MSG_PRE "Ignoring read of control MSR '0x%x'. Control MSRs not supported.\n", msr); break; } @@ -386,7 +386,7 @@ int mci_write_handler(struct guest_info * const core, case MCi_STAT: if (src.value != 0) { // Should be a GPF. - PrintError(MSG_PRE "Ignoring write of illegal value '0x%llx'.\n", src.value); + PrintError(core->vm_info, core, MSG_PRE "Ignoring write of illegal value '0x%llx'.\n", src.value); return -1; } @@ -398,11 +398,11 @@ int mci_write_handler(struct guest_info * const core, break; case MCi_MISC: - V3_Print(MSG_PRE "Ignoring write to read only miscellaneous MSR '0x%x'.\n", msr); + V3_Print(core->vm_info, core, MSG_PRE "Ignoring write to read only miscellaneous MSR '0x%x'.\n", msr); break; default: - PrintError(MSG_PRE "Ignoring write of unhooked MSR '0x%x'. This is a bug.\n", msr); + PrintError(core->vm_info, core, MSG_PRE "Ignoring write of unhooked MSR '0x%x'. This is a bug.\n", msr); break; } @@ -426,8 +426,8 @@ int add_cpuid_fields(struct v3_vm_info * const vm, CPUID_FIELDS, CPUID_FIELDS); if (ret == -1) { - PrintError(MSG_PRE "Failed to add CPUID fields for function 0000_0001.\n"); - return -1; + PrintError(vm, VCORE_NONE, MSG_PRE "Failed to add CPUID fields for function 0000_0001.\n"); + return -1; } // Add bit 7, MCE availability, and bit 14, MCE availability. @@ -438,7 +438,7 @@ int add_cpuid_fields(struct v3_vm_info * const vm, CPUID_FIELDS, CPUID_FIELDS); if (ret == -1) { - PrintError(MSG_PRE "Failed to add CPUID fileds for function 8000_0001.\n"); + PrintError(vm, VCORE_NONE, MSG_PRE "Failed to add CPUID fileds for function 8000_0001.\n"); return -1; } @@ -449,7 +449,7 @@ int add_cpuid_fields(struct v3_vm_info * const vm, static int deinit_mcheck(struct v3_vm_info * vm, void * priv_data) { struct mcheck_state * state = (struct mcheck_state *)v3_get_extension_state(vm, priv_data); if (state == NULL) { - PrintError(MSG_PRE "Failed to get machine-check architecture extension state.\n"); + PrintError(vm, VCORE_NONE, MSG_PRE "Failed to get machine-check architecture extension state.\n"); return -1; } @@ -465,7 +465,7 @@ static int init_mcheck(struct v3_vm_info * vm, v3_cfg_tree_t * cfg, void ** priv state = (struct mcheck_state *)V3_Malloc(sizeof(struct mcheck_state)); if (state == NULL) { - PrintError(MSG_PRE "Failed to allocate machine-check architecture state.\n"); + PrintError(vm, VCORE_NONE, MSG_PRE "Failed to allocate machine-check architecture state.\n"); return -1; } @@ -490,14 +490,14 @@ static int init_mcheck(struct v3_vm_info * vm, v3_cfg_tree_t * cfg, void ** priv } if (ret == -1) { - PrintError(MSG_PRE "Error hooking machine-check architecture resources.\n"); + PrintError(vm, VCORE_NONE, MSG_PRE "Error hooking machine-check architecture resources.\n"); V3_Free(state); return -1; } *priv_data = state; - PrintDebug(MSG_PRE "Initialized machine-check architecture.\n"); + PrintDebug(vm, VCORE_NONE, MSG_PRE "Initialized machine-check architecture.\n"); return 0; } @@ -509,19 +509,19 @@ int v3_mcheck_inject_nb_mce(struct v3_vm_info * const vm, const uint32_t cpu, int ret; if (state == NULL) { - PrintError(MSG_PRE "Machine-check architecture extension state not found.\n"); + PrintError(vm, VCORE_NONE, MSG_PRE "Machine-check architecture extension state not found.\n"); return -1; } // For now only MCE injection on cpu 0 is supported. if (cpu != 0) { - PrintError(MSG_PRE "Injecting MCE on cpu %u not supported.\n", cpu); + PrintError(vm, VCORE_NONE, MSG_PRE "Injecting MCE on cpu %u not supported.\n", cpu); return -1; } // Is the Northbridge bank enabled? if (state->mcg_ctl.nbe != 1) { - PrintDebug(MSG_PRE "Northbridge register bank disabled. Ignoring Northbridge MCE.\n"); + PrintDebug(vm, VCORE_NONE, MSG_PRE "Northbridge register bank disabled. Ignoring Northbridge MCE.\n"); return 0; } @@ -532,13 +532,13 @@ int v3_mcheck_inject_nb_mce(struct v3_vm_info * const vm, const uint32_t cpu, state->mcg_stat.ripv = 1; state->mcg_stat.mcip = 1; - PrintDebug(MSG_PRE "Injecting NB MCE on core %u.\n", 0); + PrintDebug(vm, VCORE_NONE, MSG_PRE "Injecting NB MCE on core %u.\n", 0); // Raise on core 0. ret = v3_raise_exception(&(vm->cores[0]), MCE_INTERRUPT); if (ret == -1) { - PrintError(MSG_PRE "Failed to raise MCE.\n"); + PrintError(vm, VCORE_NONE, MSG_PRE "Failed to raise MCE.\n"); return -1; } diff --git a/palacios/src/extensions/ext_mtrr.c b/palacios/src/extensions/ext_mtrr.c index 1f22345..9232bb7 100644 --- a/palacios/src/extensions/ext_mtrr.c +++ b/palacios/src/extensions/ext_mtrr.c @@ -546,7 +546,7 @@ static int init_mtrrs(struct v3_vm_info * vm, v3_cfg_tree_t * cfg, void ** priv_ state = V3_Malloc(sizeof(struct mtrr_state)); if (!state) { - PrintError("Cannot allocate in initializing MTRRs\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in initializing MTRRs\n"); return -1; } @@ -607,7 +607,7 @@ static int init_mtrrs(struct v3_vm_info * vm, v3_cfg_tree_t * cfg, void ** priv_ ret |= v3_hook_msr(vm, SMRR_PHYS_MASK, intel_smrr_mask_read, intel_smrr_mask_write, state); if (ret != 0) { - PrintError("Failed to hook all MTRR MSRs. Aborting...\n"); + PrintError(vm, VCORE_NONE,"Failed to hook all MTRR MSRs. Aborting...\n"); deinit_mtrrs(vm, state); return -1; } diff --git a/palacios/src/extensions/ext_vmware.c b/palacios/src/extensions/ext_vmware.c index ea1c789..552ce28 100644 --- a/palacios/src/extensions/ext_vmware.c +++ b/palacios/src/extensions/ext_vmware.c @@ -38,11 +38,11 @@ static int io_read(struct guest_info * core, uint16_t port, void * dst, uint_t l uint32_t magic = (uint32_t)(core->vm_regs.rax); uint32_t cmd = (uint32_t)(core->vm_regs.rcx); - PrintError("VMWARE IO READ of size %d (command=%d)\n", length, cmd); + PrintError(core->vm_info, core, "VMWARE IO READ of size %d (command=%d)\n", length, cmd); if (magic != VMWARE_MAGIC) { - PrintError("Invalid VMWARE MAgic number in Persona interface, ignoring for now\n"); + PrintError(core->vm_info, core, "Invalid VMWARE MAgic number in Persona interface, ignoring for now\n"); return length; } @@ -52,7 +52,7 @@ static int io_read(struct guest_info * core, uint16_t port, void * dst, uint_t l core->vm_regs.rax = cpu_hz & 0x00000000ffffffffLL; core->vm_regs.rbx = (cpu_hz >> 32) & 0x00000000ffffffffLL; } else { - PrintError("Unhandled VMWARE IO operation\n"); + PrintError(core->vm_info, core, "Unhandled VMWARE IO operation\n"); return -1; } @@ -62,7 +62,7 @@ static int io_read(struct guest_info * core, uint16_t port, void * dst, uint_t l static int io_write(struct guest_info * core, uint16_t port, void * src, uint_t length, void * priv_data) { - PrintError("VMWARE IO PORT WRITE\n"); + PrintError(core->vm_info, core, "VMWARE IO PORT WRITE\n"); return -1; } @@ -87,7 +87,7 @@ static int vmware_cpuid_handler(struct guest_info * core, uint32_t cpuid, static int vmware_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg, void ** priv_data) { - V3_Print("Using VMWARE virtualization persona\n"); + V3_Print(vm, VCORE_NONE, "Using VMWARE virtualization persona\n"); /* v3_cpuid_add_fields(vm, 0x00000001, diff --git a/palacios/src/gears/ext_code_inject.c b/palacios/src/gears/ext_code_inject.c index 4fb7e32..87e5325 100644 --- a/palacios/src/gears/ext_code_inject.c +++ b/palacios/src/gears/ext_code_inject.c @@ -88,7 +88,7 @@ static int v3_plant_code (struct guest_info * core, struct v3_code_inject_info * inject->old_code = (char*)V3_Malloc(size); if (!inject->old_code) { - PrintError("Cannot allocate in planting code\n"); + PrintError(core->vm_info, core, "Cannot allocate in planting code\n"); return -1; } @@ -108,7 +108,7 @@ static int v3_restore_pre_mmap_state (struct guest_info * core, struct v3_code_i addr_t rip_hva, mmap_gva; if ((mmap_gva = (addr_t)core->vm_regs.rbx) < 0) { - PrintError("Error running mmap in guest: v3_restore_pre_mmap_state\n"); + PrintError(core->vm_info, core, "Error running mmap in guest: v3_restore_pre_mmap_state\n"); return -1; } @@ -118,7 +118,7 @@ static int v3_restore_pre_mmap_state (struct guest_info * core, struct v3_code_i get_addr_linear(core, (addr_t)inject->rip, &(core->segments.cs)), &rip_hva); if (ret == -1) { - PrintError("Error translating RIP address: v3_restore_pre_mmap_state\n"); + PrintError(core->vm_info, core, "Error translating RIP address: v3_restore_pre_mmap_state\n"); return -1; } @@ -143,7 +143,7 @@ static int v3_restore_pre_inject_state (struct guest_info * core, struct v3_code get_addr_linear(core, (addr_t)inject->rip, &(core->segments.cs)), &rip_hva); if (ret == -1) { - PrintError("Error translating RIP address: v3_pre_inject_state\n"); + PrintError(core->vm_info, core, "Error translating RIP address: v3_pre_inject_state\n"); return -1; } @@ -179,14 +179,14 @@ static int inject_code_finish (struct guest_info * core, unsigned int hcall_id, if (v3_gva_to_hva(core, get_addr_linear(core, (addr_t)inject->rip, &(core->segments.cs)), &hva) == -1) { - PrintError("No mapping in shadow page table: inject_code_finish\n"); + PrintError(core->vm_info, core, "No mapping in shadow page table: inject_code_finish\n"); return -1; } inject->old_code = V3_Malloc(MUNMAP_SIZE); if (!inject->old_code) { - PrintError("Problem mallocing old code segment\n"); + PrintError(core->vm_info, core, "Problem mallocing old code segment\n"); return -1; } @@ -215,14 +215,14 @@ static int munmap_finish (struct guest_info * core, unsigned int hcall_id, void addr_t hva; if (core->vm_regs.rbx < 0) { - PrintError("Problem munmapping injected code\n"); + PrintError(core->vm_info, core, "Problem munmapping injected code\n"); return -1; } if (v3_gva_to_hva(core, get_addr_linear(core, (addr_t)inject->rip, &(core->segments.cs)), &hva) == -1) { - PrintError("No mapping in shadow page table: inject_code_finish\n"); + PrintError(core->vm_info, core, "No mapping in shadow page table: inject_code_finish\n"); return -1; } @@ -261,7 +261,7 @@ static int mmap_pf_handler (struct guest_info * core, unsigned int hcall_id, voi if (v3_gva_to_hva(core, get_addr_linear(core, gva, &(core->segments.ds)), &hva) == -1) { - PrintError("No mapping in shadow page table: mmap_pf_handler\n"); + PrintError(core->vm_info, core, "No mapping in shadow page table: mmap_pf_handler\n"); return -1; } @@ -275,7 +275,7 @@ static int mmap_pf_handler (struct guest_info * core, unsigned int hcall_id, voi if (v3_gva_to_hva(core, get_addr_linear(core, inject->rip, &(core->segments.cs)), &hva) == -1) { - PrintError("No mapping for old RIP in shadow page table: mmap_pf_handler: %p\n", (void*)inject->rip); + PrintError(core->vm_info, core, "No mapping for old RIP in shadow page table: mmap_pf_handler: %p\n", (void*)inject->rip); return -1; } @@ -288,7 +288,7 @@ static int mmap_pf_handler (struct guest_info * core, unsigned int hcall_id, voi if (v3_gva_to_hva(core, get_addr_linear(core, core->rip, &(core->segments.cs)), &hva) == -1) { - PrintError("No mapping for new RIP in shadow page table: mmap_pf_handler: %p\n", (void*)core->rip); + PrintError(core->vm_info, core, "No mapping for new RIP in shadow page table: mmap_pf_handler: %p\n", (void*)core->rip); return -1; } @@ -369,7 +369,7 @@ static addr_t v3_get_dyn_entry (struct guest_info * core, addr_t elf_gva, addr_t phdr = (ElfW(Phdr)*)(elf_hva + ehdr->e_phoff); phdr_cursor = phdr; - //PrintDebug("num phdrs: %d\n", ehdr->e_phnum); + //PrintDebug(core->vm_info, core, "num phdrs: %d\n", ehdr->e_phnum); for (i = 0; i < ehdr->e_phnum; i++, phdr_cursor++) { if (phdr_cursor->p_type == PT_DYNAMIC) { num_dyn = phdr_cursor->p_filesz / sizeof(ElfW(Dyn)); @@ -377,7 +377,7 @@ static addr_t v3_get_dyn_entry (struct guest_info * core, addr_t elf_gva, addr_t // make sure this addr is paged in if (v3_gva_to_gpa(core, elf_gva + phdr_cursor->p_offset, &hva) == -1) { - PrintError("Dynamic segment isn't paged in\n"); + PrintError(core->vm_info, core, "Dynamic segment isn't paged in\n"); return 0; } @@ -405,25 +405,25 @@ static int v3_do_resolve (struct guest_info * core, addr_t elf_gva, addr_t elf_h addr_t got_gva, symtab_gva, strtab_gva; if ((got_gva = v3_get_dyn_entry(core, elf_gva, elf_hva, DT_PLTGOT)) == 0) { - PrintError("Problem getting at PLTGOT in v3_do_resolve\n"); + PrintError(core->vm_info, core, "Problem getting at PLTGOT in v3_do_resolve\n"); return -1; } if ((strtab_gva = v3_get_dyn_entry(core, elf_gva, elf_hva, DT_STRTAB)) == 0) { - PrintError("Problem getting at PLTGOT in v3_do_resolve\n"); + PrintError(core->vm_info, core, "Problem getting at PLTGOT in v3_do_resolve\n"); return -1; } if ((symtab_gva = v3_get_dyn_entry(core, elf_gva, elf_hva, DT_SYMTAB)) == 0) { - PrintError("Problem getting at PLTGOT in v3_do_resolve\n"); + PrintError(core->vm_info, core, "Problem getting at PLTGOT in v3_do_resolve\n"); return -1; } - PrintDebug("Got gva: %p\n", (void*)got_gva); - PrintDebug("Symtab gva: %p\n", (void*)symtab_gva); - PrintDebug("Strtab gva: %p\n", (void*)strtab_gva); + PrintDebug(core->vm_info, core, "Got gva: %p\n", (void*)got_gva); + PrintDebug(core->vm_info, core, "Symtab gva: %p\n", (void*)symtab_gva); + PrintDebug(core->vm_info, core, "Strtab gva: %p\n", (void*)strtab_gva); return 0; } @@ -437,7 +437,7 @@ static int v3_do_cont (struct guest_info * core, struct v3_code_inject_info * in // page fault wasn't handled by kernel?? if (ret == -1) { - PrintError("ERROR: no mapping in guest page table!\n"); + PrintError(core->vm_info, core, "ERROR: no mapping in guest page table!\n"); return -1; } @@ -447,7 +447,7 @@ static int v3_do_cont (struct guest_info * core, struct v3_code_inject_info * in // this should never happen... if (ret == -1) { - PrintError("ERROR: no mapping in shadow page table\n"); + PrintError(core->vm_info, core, "ERROR: no mapping in shadow page table\n"); return -1; } @@ -461,14 +461,14 @@ static int v3_do_cont (struct guest_info * core, struct v3_code_inject_info * in err_code.user = 1; if (v3_inject_guest_pf(core, check, err_code) < 0) { - PrintError("Problem injecting pf\n"); + PrintError(core->vm_info, core, "Problem injecting pf\n"); return -1; } return E_NEED_PF; } - PrintDebug("Found ELF!\n"); + PrintDebug(core->vm_info, core, "Found ELF!\n"); V3_Free(inject->cont); inject->cont = NULL; return v3_do_resolve(core, check, hva); @@ -496,7 +496,7 @@ int v3_do_inject (struct guest_info * core, struct v3_code_inject_info * inject, get_addr_linear(core, (addr_t)core->rip, &(core->segments.cs)), &rip_hva); if (ret == -1) { - PrintError("Error translating RIP address in v3_do_inject\n"); + PrintError(core->vm_info, core, "Error translating RIP address in v3_do_inject\n"); return -1; } @@ -511,28 +511,28 @@ int v3_do_inject (struct guest_info * core, struct v3_code_inject_info * inject, // need to page in if (ret == -1) { - PrintDebug("Found a page we need to fault in\n"); + PrintDebug(core->vm_info, core, "Found a page we need to fault in\n"); inject->cont = (struct v3_cont *)V3_Malloc(sizeof(struct v3_cont)); if (!inject->cont) { - PrintError("Cannot allocate in doing inject\n"); + PrintError(core->vm_info, core, "Cannot allocate in doing inject\n"); return -1; } ret = v3_gva_to_gpa(core, elf_gva, &elf_hva); if (ret == -1) { - PrintDebug("no mapping in guest page table\n"); + PrintDebug(core->vm_info, core, "no mapping in guest page table\n"); } inject->cont->check_addr = elf_gva; inject->cont->cont_func = v3_do_cont; err_code.user = 1; - PrintDebug("Injecting pf for addr: %p\n", (void*) elf_gva); + PrintDebug(core->vm_info, core, "Injecting pf for addr: %p\n", (void*) elf_gva); if (v3_inject_guest_pf(core, elf_gva, err_code) < 0) { - PrintError("Problem injecting pf\n"); + PrintError(core->vm_info, core, "Problem injecting pf\n"); return -1; } @@ -540,7 +540,7 @@ int v3_do_inject (struct guest_info * core, struct v3_code_inject_info * inject, } if (strncmp(elf_magic, (char*)elf_hva, ELF_MAG_SIZE) == 0) { - PrintDebug("Found elf_magic!\n"); + PrintDebug(core->vm_info, core, "Found elf_magic!\n"); break; } @@ -551,17 +551,17 @@ int v3_do_inject (struct guest_info * core, struct v3_code_inject_info * inject, inject->cont = NULL; return v3_do_resolve(core, elf_gva, elf_hva); - PrintDebug("Planting code\n"); + PrintDebug(core->vm_info, core, "Planting code\n"); v3_plant_code(core, inject, (char*)rip_hva, mmap_code, MMAP_SIZE); - PrintDebug("Saving register context\n"); - PrintDebug("First 8 bytes 0x%lx\n", *(long*)rip_hva); + PrintDebug(core->vm_info, core, "Saving register context\n"); + PrintDebug(core->vm_info, core, "First 8 bytes 0x%lx\n", *(long*)rip_hva); /* may need to save v3_ctrl registers too... */ memcpy(&inject->regs, &core->vm_regs, sizeof(struct v3_gprs)); inject->rip = core->rip; /* jump to injected code */ - PrintDebug("Jumping to injected code\n"); + PrintDebug(core->vm_info, core, "Jumping to injected code\n"); return 0; } @@ -581,7 +581,7 @@ int v3_do_static_inject (struct guest_info * core, struct v3_code_inject_info * get_addr_linear(core, (addr_t)core->rip, &(core->segments.cs)), &rip_hva); if (ret == -1) { - PrintError("Error translating RIP address: v3_do_static_inject\n"); + PrintError(core->vm_info, core, "Error translating RIP address: v3_do_static_inject\n"); return -1; } @@ -608,7 +608,7 @@ int v3_do_static_inject (struct guest_info * core, struct v3_code_inject_info * get_addr_linear(core, (addr_t)inject->rip, &(core->segments.cs)), &rip_hva); if (ret == -1) { - PrintError("Error translating RIP address: v3_do_static_inject\n"); + PrintError(core->vm_info, core, "Error translating RIP address: v3_do_static_inject\n"); return -1; } @@ -624,7 +624,7 @@ int v3_do_static_inject (struct guest_info * core, struct v3_code_inject_info * // inject the first page fault for the code block if (v3_inject_guest_pf(core, region_gva, err_code) < 0) { - PrintError("Problem injecting page fault in v3_do_static_inject\n"); + PrintError(core->vm_info, core, "Problem injecting page fault in v3_do_static_inject\n"); return -1; } @@ -634,7 +634,7 @@ int v3_do_static_inject (struct guest_info * core, struct v3_code_inject_info * return 0; } default: - PrintError("Invalid mmap state\n"); + PrintError(core->vm_info, core, "Invalid mmap state\n"); return -1; } return 0; @@ -653,7 +653,7 @@ int v3_handle_guest_inject (struct guest_info * core, void * priv_data) { /* eventually this should turn into a mutex lock */ if (current_inject) { - PrintError("An inject is already in progress\n"); + PrintError(core->vm_info, core, "An inject is already in progress\n"); return -1; } else { current_inject = inject; @@ -680,13 +680,13 @@ int v3_insert_code_inject (void * ginfo, void * code, int size, struct v3_code_inject_info * inject; if (!injects->active) { - PrintError("Code injection has not been initialized\n"); + PrintError(vm, VCORE_NONE, "Code injection has not been initialized\n"); return -1; } inject = V3_Malloc(sizeof(struct v3_code_inject_info)); if (!inject) { - PrintError("Error allocating inject info in v3_insert_code_inject\n"); + PrintError(vm, VCORE_NONE, "Error allocating inject info in v3_insert_code_inject\n"); return -1; } @@ -712,10 +712,10 @@ int v3_insert_code_inject (void * ginfo, void * code, int size, int v3_remove_code_inject (struct v3_vm_info * vm, struct v3_code_inject_info * inject) { - PrintDebug("Removing and freeing code inject\n"); + PrintDebug(vm, VCORE_NONE, "Removing and freeing code inject\n"); if (inject->is_exec_hooked) { if (v3_unhook_executable(vm, inject->bin_file) < 0) { - PrintError("Problem unhooking executable in v3_remove_code_inject\n"); + PrintError(vm, VCORE_NONE, "Problem unhooking executable in v3_remove_code_inject\n"); return -1; } } diff --git a/palacios/src/gears/ext_env_inject.c b/palacios/src/gears/ext_env_inject.c index 251029d..4b7590c 100644 --- a/palacios/src/gears/ext_env_inject.c +++ b/palacios/src/gears/ext_env_inject.c @@ -38,13 +38,13 @@ static int v3_env_inject_handler (struct guest_info * core, void * priv_data) { struct v3_env_inject_info * inject = (struct v3_env_inject_info*)priv_data; for (; i < inject->num_env_vars; i++) { - PrintDebug("Envvar[%d]: %s\n", i, inject->env_vars[i]); + PrintDebug(core->vm_info, core, "Envvar[%d]: %s\n", i, inject->env_vars[i]); } int ret = v3_inject_strings(core, (const char**)NULL, (const char**)inject->env_vars, 0, inject->num_env_vars); if (ret == -1) { - PrintDebug("Error injecting strings in v3_env_inject_handler\n"); + PrintDebug(core->vm_info, core, "Error injecting strings in v3_env_inject_handler\n"); return -1; } @@ -76,7 +76,7 @@ int v3_insert_env_inject (void * ginfo, char ** strings, int num_strings, char * struct v3_env_inject_info * inject = V3_Malloc(sizeof(struct v3_env_inject_info)); if (!inject) { - PrintError("Cannot allocate in inserting environment inject\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in inserting environment inject\n"); return -1; } @@ -98,7 +98,7 @@ int v3_insert_env_inject (void * ginfo, char ** strings, int num_strings, char * int v3_remove_env_inject (struct v3_vm_info * vm, struct v3_env_inject_info * inject) { if (v3_unhook_executable(vm, inject->bin_name) < 0) { - PrintError("Problem unhooking executable in v3_remove_env_inject\n"); + PrintError(vm, VCORE_NONE, "Problem unhooking executable in v3_remove_env_inject\n"); return -1; } diff --git a/palacios/src/gears/ext_execve_hook.c b/palacios/src/gears/ext_execve_hook.c index 8c26867..17142eb 100644 --- a/palacios/src/gears/ext_execve_hook.c +++ b/palacios/src/gears/ext_execve_hook.c @@ -62,15 +62,15 @@ static int init_exec_hooks_core (struct guest_info * core, void * priv_data, voi hooks->bin_table = v3_create_htable(0, exec_hash_fn, exec_eq_fn); if (hooks->bin_table == NULL) { - PrintError("Problem creating execve hash table\n"); + PrintError(core->vm_info, core, "Problem creating execve hash table\n"); return -1; } if (core->cpu_mode == LONG || core->cpu_mode == LONG_32_COMPAT) { - PrintDebug("Hooking execve 64\n"); + PrintDebug(core->vm_info, core, "Hooking execve 64\n"); v3_hook_syscall(core, SYS64_EXECVE, v3_execve_handler, NULL); } else { - PrintDebug("Hooking execve, cpu mode: %x\n", core->cpu_mode); + PrintDebug(core->vm_info, core, "Hooking execve, cpu mode: %x\n", core->cpu_mode); v3_hook_syscall(core, SYS32_EXECVE, v3_execve_handler, NULL); } return 0; @@ -101,7 +101,7 @@ int v3_hook_executable (struct v3_vm_info * vm, addr_t key; if (!hook) { - PrintError("Cannot allocate in hooking exec\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in hooking exec\n"); return -1; } @@ -129,12 +129,12 @@ int v3_unhook_executable (struct v3_vm_info * vm, const uchar_t * binfile) { if ((hook = (struct exec_hook*)v3_htable_search(hooks->bin_table, key)) != NULL) { free_hook(vm, hook); } else { - PrintError("Could not unhook executable '%s'\n", binfile); + PrintError(vm, VCORE_NONE, "Could not unhook executable '%s'\n", binfile); return -1; } if (v3_htable_remove(hooks->bin_table, key, 0) == (addr_t)NULL) { - PrintError("Error trying to remove key from htable: v3_unhook_executable\n"); + PrintError(vm, VCORE_NONE, "Error trying to remove key from htable: v3_unhook_executable\n"); return -1; } @@ -169,7 +169,7 @@ int v3_execve_handler (struct guest_info * core, uint_t syscall_nr, void * priv_ } if (ret == -1) { - PrintError("Error translating file path in sysexecve handler\n"); + PrintError(core->vm_info, core, "Error translating file path in sysexecve handler\n"); return 0; } @@ -178,7 +178,7 @@ int v3_execve_handler (struct guest_info * core, uint_t syscall_nr, void * priv_ ret = hook->handler(core, hook->priv_data); if (ret == -1) { - PrintDebug("Error handling execve hook\n"); + PrintDebug(core->vm_info, core, "Error handling execve hook\n"); return -1; } diff --git a/palacios/src/gears/ext_process_environment.c b/palacios/src/gears/ext_process_environment.c index 531edaf..ce2f135 100644 --- a/palacios/src/gears/ext_process_environment.c +++ b/palacios/src/gears/ext_process_environment.c @@ -85,11 +85,11 @@ static int v3_copy_chunk_guest32(struct guest_info * core, addr_t gva, uint_t ar uint32_t tmp_args[var_dump.argc]; uint32_t tmp_envs[var_dump.envc]; - PrintDebug("Initiating copy into guest (32bit)\n"); + PrintDebug(core->vm_info, core, "Initiating copy into guest (32bit)\n"); ret = v3_gva_to_hva(core, get_addr_linear(core, gva, &(core->segments.ds)), &hva); if (ret == -1) { - PrintDebug("Error translating gva in v3_copy_chunk_2guest\n"); + PrintDebug(core->vm_info, core, "Error translating gva in v3_copy_chunk_2guest\n"); return -1; } @@ -99,7 +99,7 @@ static int v3_copy_chunk_guest32(struct guest_info * core, addr_t gva, uint_t ar host_cursor -= strlen(var_dump.envp[i]) + 1; guest_cursor -= strlen(var_dump.envp[i]) + 1; while (i < var_dump.envc) { - //PrintDebug("Copying envvar#%d: %s\n", i, var_dump.envp[i]); + //PrintDebug(core->vm_info, core, "Copying envvar#%d: %s\n", i, var_dump.envp[i]); strcpy(host_cursor, var_dump.envp[i]); tmp_envs[i] = guest_cursor; i++; @@ -114,7 +114,7 @@ static int v3_copy_chunk_guest32(struct guest_info * core, addr_t gva, uint_t ar host_cursor -= strlen(var_dump.argv[i]) + 1; guest_cursor -= strlen(var_dump.argv[i]) + 1; while (i < var_dump.argc) { - //PrintDebug("Copying arg #%d: %s\n", i, var_dump.argv[i]); + //PrintDebug(core->vm_info, core, "Copying arg #%d: %s\n", i, var_dump.argv[i]); strcpy(host_cursor, var_dump.argv[i]); tmp_args[i] = guest_cursor; i++; @@ -180,17 +180,17 @@ static int v3_copy_chunk_vmm32(struct guest_info * core, const char ** argstrs, uint_t argc = 0, envc = 0, bytes = 0; char * cursor; - PrintDebug("Initiating copy into vmm\n"); + PrintDebug(core->vm_info, core, "Initiating copy into vmm\n"); int ret = v3_gva_to_hva(core, get_addr_linear(core, core->vm_regs.rdx, &(core->segments.ds)), &envp); if (ret == -1) { - PrintDebug("Error translating address in rdx\n"); + PrintDebug(core->vm_info, core, "Error translating address in rdx\n"); return 0; } ret = v3_gva_to_hva(core, get_addr_linear(core, core->vm_regs.rcx, &(core->segments.ds)), &argv); if (ret == -1) { - PrintDebug("Error translating address in rcx\n"); + PrintDebug(core->vm_info, core, "Error translating address in rcx\n"); return 0; } @@ -199,7 +199,7 @@ static int v3_copy_chunk_vmm32(struct guest_info * core, const char ** argstrs, addr_t argvn; ret = v3_gva_to_hva(core, get_addr_linear(core, (addr_t)*((uint32_t*)cursor), &(core->segments.ds)), &argvn); if (ret == -1) { - PrintDebug("Error translating address for argvn\n"); + PrintDebug(core->vm_info, core, "Error translating address for argvn\n"); } argc++; cursor += 4; @@ -210,7 +210,7 @@ static int v3_copy_chunk_vmm32(struct guest_info * core, const char ** argstrs, var_dump.argv = (char**)V3_Malloc(sizeof(char*)*argc); if (!var_dump.argv) { - PrintError("Cannot allocate in copying\n"); + PrintError(core->vm_info, core, "Cannot allocate in copying\n"); return -1; } @@ -223,14 +223,14 @@ static int v3_copy_chunk_vmm32(struct guest_info * core, const char ** argstrs, addr_t argvn; ret = v3_gva_to_hva(core, get_addr_linear(core, (addr_t)*((uint32_t*)cursor), &(core->segments.ds)), &argvn); if (ret == -1) { - PrintDebug("Error translating argvn address\n"); + PrintDebug(core->vm_info, core, "Error translating argvn address\n"); } /* malloc room for the string */ char * tmpstr = (char*)V3_Malloc(strlen((char*)argvn) + 1); if (!tmpstr) { - PrintError("Cannot allocate temporary\n"); + PrintError(core->vm_info, core, "Cannot allocate temporary\n"); return -1; } @@ -250,7 +250,7 @@ static int v3_copy_chunk_vmm32(struct guest_info * core, const char ** argstrs, char * tmpstr = (char*)V3_Malloc(strlen(argstrs[j]) + 1); if (!tmpstr) { - PrintError("Cannot allocate temp string\n"); + PrintError(core->vm_info, core, "Cannot allocate temp string\n"); return -1; } @@ -266,7 +266,7 @@ static int v3_copy_chunk_vmm32(struct guest_info * core, const char ** argstrs, addr_t envpn; ret = v3_gva_to_hva(core, get_addr_linear(core, (addr_t)*((uint32_t*)cursor), &(core->segments.ds)), &envpn); if (ret == -1) { - PrintDebug("Error translating address for envpn\n"); + PrintDebug(core->vm_info, core, "Error translating address for envpn\n"); } envc++; cursor += 4; @@ -276,7 +276,7 @@ static int v3_copy_chunk_vmm32(struct guest_info * core, const char ** argstrs, var_dump.envp = (char**)V3_Malloc(sizeof(char*)*envc); if (!var_dump.envp) { - PrintError("Cannot allocate var dump\n"); + PrintError(core->vm_info, core, "Cannot allocate var dump\n"); return -1; } @@ -289,14 +289,14 @@ static int v3_copy_chunk_vmm32(struct guest_info * core, const char ** argstrs, addr_t envpn; ret = v3_gva_to_hva(core, get_addr_linear(core, (addr_t)*((uint32_t*)cursor), &(core->segments.ds)), &envpn); if (ret == -1) { - PrintDebug("Error translating address for envpn\n"); + PrintDebug(core->vm_info, core, "Error translating address for envpn\n"); } /* malloc room for the string */ char * tmpstr = (char*)V3_Malloc(strlen((char*)envpn) + 1); if (!tmpstr) { - PrintError("Cannot allocate temp string\n"); + PrintError(core->vm_info, core, "Cannot allocate temp string\n"); return -1; } @@ -316,7 +316,7 @@ static int v3_copy_chunk_vmm32(struct guest_info * core, const char ** argstrs, char * tmpstr = (char*)V3_Malloc(strlen(envstrs[j]) + 1); if (!tmpstr) { - PrintError("Cannot allocate temp string\n"); + PrintError(core->vm_info, core, "Cannot allocate temp string\n"); return -1; } @@ -342,15 +342,15 @@ static int v3_inject_strings32 (struct guest_info * core, const char ** argstrs, /* copy out all of the arguments and the environment to the VMM */ if ((bytes_needed = v3_copy_chunk_vmm32(core, argstrs, envstrs, argcnt, envcnt)) == -1) { - PrintDebug("Error copying out environment and arguments\n"); + PrintDebug(core->vm_info, core, "Error copying out environment and arguments\n"); return -1; } - PrintDebug("environment successfully copied into VMM\n"); + PrintDebug(core->vm_info, core, "environment successfully copied into VMM\n"); inject_gva = v3_prepare_guest_stack(core, bytes_needed); if (!inject_gva) { - PrintDebug("Not enough space on user stack\n"); + PrintDebug(core->vm_info, core, "Not enough space on user stack\n"); return -1; } @@ -367,11 +367,11 @@ static int v3_copy_chunk_guest64(struct guest_info * core, addr_t gva, uint_t ar uint64_t tmp_args[var_dump.argc]; uint64_t tmp_envs[var_dump.envc]; - PrintDebug("Initiating copy into guest (64bit)\n"); + PrintDebug(core->vm_info, core, "Initiating copy into guest (64bit)\n"); ret = v3_gva_to_hva(core, get_addr_linear(core, gva, &(core->segments.ds)), &hva); if (ret == -1) { - PrintDebug("Error translating gva in v3_copy_chunk_2guest64\n"); + PrintDebug(core->vm_info, core, "Error translating gva in v3_copy_chunk_2guest64\n"); return -1; } @@ -380,7 +380,7 @@ static int v3_copy_chunk_guest64(struct guest_info * core, addr_t gva, uint_t ar host_cursor -= strlen(var_dump.envp[i]) + 1; guest_cursor -= strlen(var_dump.envp[i]) + 1; while (i < var_dump.envc) { - //PrintDebug("Copying envvar#%d: %s\n", i, var_dump.envp[i]); + //PrintDebug(core->vm_info, core, "Copying envvar#%d: %s\n", i, var_dump.envp[i]); strcpy(host_cursor, var_dump.envp[i]); tmp_envs[i] = guest_cursor; i++; @@ -394,7 +394,7 @@ static int v3_copy_chunk_guest64(struct guest_info * core, addr_t gva, uint_t ar host_cursor -= strlen(var_dump.argv[i]) + 1; guest_cursor -= strlen(var_dump.argv[i]) + 1; while (i < var_dump.argc) { - //PrintDebug("Copying arg #%d: %s\n", i, var_dump.argv[i]); + //PrintDebug(core->vm_info, core, "Copying arg #%d: %s\n", i, var_dump.argv[i]); strcpy(host_cursor, var_dump.argv[i]); tmp_args[i] = guest_cursor; i++; @@ -458,17 +458,17 @@ static int v3_copy_chunk_vmm64(struct guest_info * core, const char ** argstrs, uint_t argc = 0, envc = 0, bytes = 0; char * cursor; - PrintDebug("Initiating copy into vmm\n"); + PrintDebug(core->vm_info, core, "Initiating copy into vmm\n"); int ret = v3_gva_to_hva(core, get_addr_linear(core, core->vm_regs.rdx, &(core->segments.ds)), &envp); if (ret == -1) { - PrintDebug("Error translating address in rdx\n"); + PrintDebug(core->vm_info, core, "Error translating address in rdx\n"); return 0; } ret = v3_gva_to_hva(core, get_addr_linear(core, core->vm_regs.rcx, &(core->segments.ds)), &argv); if (ret == -1) { - PrintDebug("Error translating address in rcx\n"); + PrintDebug(core->vm_info, core, "Error translating address in rcx\n"); return 0; } @@ -477,7 +477,7 @@ static int v3_copy_chunk_vmm64(struct guest_info * core, const char ** argstrs, addr_t argvn; ret = v3_gva_to_hva(core, get_addr_linear(core, (addr_t)*((uint64_t*)cursor), &(core->segments.ds)), &argvn); if (ret == -1) { - PrintDebug("Error translating address for argvn\n"); + PrintDebug(core->vm_info, core, "Error translating address for argvn\n"); } argc++; cursor += 8; @@ -488,7 +488,7 @@ static int v3_copy_chunk_vmm64(struct guest_info * core, const char ** argstrs, var_dump.argv = (char**)V3_Malloc(sizeof(char*)*argc); if (!var_dump.argv) { - PrintError("Cannot allocate var dump\n"); + PrintError(core->vm_info, core, "Cannot allocate var dump\n"); return -1; } @@ -501,14 +501,14 @@ static int v3_copy_chunk_vmm64(struct guest_info * core, const char ** argstrs, addr_t argvn; ret = v3_gva_to_hva(core, get_addr_linear(core, (addr_t)*((uint64_t*)cursor), &(core->segments.ds)), &argvn); if (ret == -1) { - PrintDebug("Error translating argvn address\n"); + PrintDebug(core->vm_info, core, "Error translating argvn address\n"); } /* malloc room for the string */ char * tmpstr = (char*)V3_Malloc(strlen((char*)argvn) + 1); if (!tmpstr) { - PrintError("Cannot allocate temp string\n"); + PrintError(core->vm_info, core, "Cannot allocate temp string\n"); return -1; } @@ -528,7 +528,7 @@ static int v3_copy_chunk_vmm64(struct guest_info * core, const char ** argstrs, char * tmpstr = (char*)V3_Malloc(strlen(argstrs[j]) + 1); if (!tmpstr) { - PrintError("Cannot allocate temp string\n"); + PrintError(core->vm_info, core, "Cannot allocate temp string\n"); return -1; } @@ -544,7 +544,7 @@ static int v3_copy_chunk_vmm64(struct guest_info * core, const char ** argstrs, addr_t envpn; ret = v3_gva_to_hva(core, get_addr_linear(core, (addr_t)*((uint64_t*)cursor), &(core->segments.ds)), &envpn); if (ret == -1) { - PrintDebug("Error translating address for envpn\n"); + PrintDebug(core->vm_info, core, "Error translating address for envpn\n"); } envc++; cursor += 8; @@ -554,7 +554,7 @@ static int v3_copy_chunk_vmm64(struct guest_info * core, const char ** argstrs, var_dump.envp = (char**)V3_Malloc(sizeof(char*)*envc); if (!var_dump.envp) { - PrintError("Cannot allocate var dump\n"); + PrintError(core->vm_info, core, "Cannot allocate var dump\n"); return -1; } @@ -568,14 +568,14 @@ static int v3_copy_chunk_vmm64(struct guest_info * core, const char ** argstrs, addr_t envpn; ret = v3_gva_to_hva(core, get_addr_linear(core, (addr_t)*((uint64_t*)cursor), &(core->segments.ds)), &envpn); if (ret == -1) { - PrintDebug("Error translating address for envpn\n"); + PrintDebug(core->vm_info, core, "Error translating address for envpn\n"); } /* malloc room for the string */ char * tmpstr = (char*)V3_Malloc(strlen((char*)envpn) + 1); if (!tmpstr) { - PrintError("Cannot allocate temp string\n"); + PrintError(core->vm_info, core, "Cannot allocate temp string\n"); return -1; } @@ -595,7 +595,7 @@ static int v3_copy_chunk_vmm64(struct guest_info * core, const char ** argstrs, char * tmpstr = (char*)V3_Malloc(strlen(envstrs[j]) + 1); if (!tmpstr) { - PrintError("Cannot allocate temp string\n"); + PrintError(core->vm_info, core, "Cannot allocate temp string\n"); return -1; } @@ -621,15 +621,15 @@ static int v3_inject_strings64 (struct guest_info * core, const char ** argstrs, /* copy out all of the arguments and the environment to the VMM */ if ((bytes_needed = v3_copy_chunk_vmm64(core, argstrs, envstrs, argcnt, envcnt)) == -1) { - PrintDebug("Error copying out environment and arguments\n"); + PrintDebug(core->vm_info, core, "Error copying out environment and arguments\n"); return -1; } - PrintDebug("environment successfully copied into VMM\n"); + PrintDebug(core->vm_info, core, "environment successfully copied into VMM\n"); inject_gva = v3_prepare_guest_stack(core, bytes_needed); if (!inject_gva) { - PrintDebug("Not enough space on user stack\n"); + PrintDebug(core->vm_info, core, "Not enough space on user stack\n"); return -1; } @@ -698,12 +698,12 @@ int v3_inject_strings (struct guest_info * core, const char ** argstrs, const ch if (core->cpu_mode == LONG) { if (v3_inject_strings64(core, argstrs, envstrs, argcnt, envcnt) == -1) { - PrintDebug("Error injecting strings into environment (64)\n"); + PrintDebug(core->vm_info, core, "Error injecting strings into environment (64)\n"); return -1; } } else { if (v3_inject_strings32(core, argstrs, envstrs, argcnt, envcnt) == -1) { - PrintDebug("Error injecting strings into environment (32)\n"); + PrintDebug(core->vm_info, core, "Error injecting strings into environment (32)\n"); return -1; } } diff --git a/palacios/src/gears/ext_sw_intr.c b/palacios/src/gears/ext_sw_intr.c index 8219447..03034dc 100644 --- a/palacios/src/gears/ext_sw_intr.c +++ b/palacios/src/gears/ext_sw_intr.c @@ -73,7 +73,7 @@ static int init_swintr_core_svm (struct guest_info * core, void * priv_data) { static int init_swintr_core_vmx (struct guest_info * core, void * priv_data) { - PrintError("Not implemented!\n"); + PrintError(core->vm_info, core, "Not implemented!\n"); return -1; } @@ -85,7 +85,7 @@ static int init_swintr_intercept_core (struct guest_info * core, void * priv_dat case V3_SVM_CPU: case V3_SVM_REV3_CPU: { if (init_swintr_core_svm(core, priv_data) == -1) { - PrintError("Problem initializing svm software interrupt intercept\n"); + PrintError(core->vm_info, core, "Problem initializing svm software interrupt intercept\n"); return -1; } break; @@ -94,13 +94,13 @@ static int init_swintr_intercept_core (struct guest_info * core, void * priv_dat case V3_VMX_EPT_CPU: case V3_VMX_EPT_UG_CPU: { if (init_swintr_core_vmx(core, priv_data) == -1) { - PrintError("Problem initializing vmx software interrupt intercept\n"); + PrintError(core->vm_info, core, "Problem initializing vmx software interrupt intercept\n"); return -1; } break; } default: - PrintError("software interrupt interception not supported on this architecture\n"); + PrintError(core->vm_info, core, "software interrupt interception not supported on this architecture\n"); return -1; } return 0; @@ -139,12 +139,12 @@ int v3_handle_swintr (struct guest_info * core) { } if (ret == -1) { - PrintError("V3 SWintr Handler: Could not translate Instruction Address (%p)\n", (void *)core->rip); + PrintError(core->vm_info, core, "V3 SWintr Handler: Could not translate Instruction Address (%p)\n", (void *)core->rip); return -1; } if (v3_decode(core, (addr_t)instr_ptr, &instr) == -1) { - PrintError("V3 SWintr Handler: Decoding Error\n"); + PrintError(core->vm_info, core, "V3 SWintr Handler: Decoding Error\n"); return -1; } @@ -154,7 +154,7 @@ int v3_handle_swintr (struct guest_info * core) { if (hook == NULL) { #ifdef V3_CONFIG_EXT_SWINTR_PASSTHROUGH if (v3_hook_passthrough_swintr(core, vector) == -1) { - PrintDebug("V3 SWintr Handler: Error hooking passthrough swintr\n"); + PrintDebug(core->vm_info, core, "V3 SWintr Handler: Error hooking passthrough swintr\n"); return -1; } hook = swintr_hooks[vector]; @@ -166,7 +166,7 @@ int v3_handle_swintr (struct guest_info * core) { ret = hook->handler(core, vector, NULL); if (ret == -1) { - PrintDebug("V3 SWintr Handler: Error in swintr hook\n"); + PrintDebug(core->vm_info, core, "V3 SWintr Handler: Error in swintr hook\n"); return -1; } @@ -195,12 +195,12 @@ int v3_hook_swintr (struct guest_info * core, struct v3_swintr_hook * hook = (struct v3_swintr_hook*)V3_Malloc(sizeof(struct v3_swintr_hook)); if (hook == NULL) { - PrintError("Cannot allocate for swintr hook\n"); + PrintError(core->vm_info, core, "Cannot allocate for swintr hook\n"); return -1; } if (get_swintr_hook(core, vector) != NULL) { - PrintError("swint %d already hooked\n", vector); + PrintError(core->vm_info, core, "swint %d already hooked\n", vector); return -1; } @@ -209,14 +209,14 @@ int v3_hook_swintr (struct guest_info * core, swintr_hooks[vector] = hook; - PrintDebug("Hooked Swintr #%d\n", vector); + PrintDebug(core->vm_info, core, "Hooked Swintr #%d\n", vector); return 0; } static int passthrough_swintr_handler (struct guest_info * core, uint8_t vector, void * priv_data) { - PrintDebug("[passthrough_swint_handler] INT vector=%d (guest=0x%p)\n", + PrintDebug(core->vm_info, core, "[passthrough_swint_handler] INT vector=%d (guest=0x%p)\n", vector, (void*)core); return 0; } @@ -227,10 +227,10 @@ int v3_hook_passthrough_swintr (struct guest_info * core, uint8_t vector) { int rc = v3_hook_swintr(core, vector, passthrough_swintr_handler, NULL); if (rc) { - PrintError("guest_swintr_injection: failed to hook swint 0x%x (guest=0x%p)\n", vector, (void*)core); + PrintError(core->vm_info, core, "guest_swintr_injection: failed to hook swint 0x%x (guest=0x%p)\n", vector, (void*)core); return -1; } else { - PrintDebug("guest_swintr_injection: hooked swint 0x%x (guest=0x%p)\n", vector, (void*)core); + PrintDebug(core->vm_info, core, "guest_swintr_injection: hooked swint 0x%x (guest=0x%p)\n", vector, (void*)core); return 0; } diff --git a/palacios/src/gears/ext_syscall_hijack.c b/palacios/src/gears/ext_syscall_hijack.c index e6cc5e4..a531176 100644 --- a/palacios/src/gears/ext_syscall_hijack.c +++ b/palacios/src/gears/ext_syscall_hijack.c @@ -62,7 +62,7 @@ static void print_arg (struct guest_info * core, v3_reg_t reg, uint8_t argnum) addr_t hva; int ret = 0; - PrintDebug("\t ARG%d: INT - %ld\n", argnum, (long) reg); + PrintDebug(core->vm_info, core, "\t ARG%d: INT - %ld\n", argnum, (long) reg); if (core->mem_mode == PHYSICAL_MEM) { ret = v3_gpa_to_hva(core, get_addr_linear(core, reg, &(core->segments.ds)), &hva); @@ -71,27 +71,27 @@ static void print_arg (struct guest_info * core, v3_reg_t reg, uint8_t argnum) ret = v3_gva_to_hva(core, get_addr_linear(core, reg, &(core->segments.ds)), &hva); } - PrintDebug("\t STR - "); + PrintDebug(core->vm_info, core, "\t STR - "); if (ret == -1) { - PrintDebug("\n"); + PrintDebug(core->vm_info, core, "\n"); return; } uint32_t c = max(MAX_CHARS, 4096 - (hva % 4096)); int i = 0; for (; i < c && *((char*)(hva + i)) != 0; i++) { - PrintDebug("%c", *((char*)(hva + i))); + PrintDebug(core->vm_info, core, "%c", *((char*)(hva + i))); } - PrintDebug("\n"); + PrintDebug(core->vm_info, core, "\n"); } static void print_syscall (uint8_t is64, struct guest_info * core) { if (is64) { - PrintDebug("Syscall #%ld: \"%s\"\n", (long)core->vm_regs.rax, get_linux_syscall_name64(core->vm_regs.rax)); + PrintDebug(core->vm_info, core, "Syscall #%ld: \"%s\"\n", (long)core->vm_regs.rax, get_linux_syscall_name64(core->vm_regs.rax)); } else { - PrintDebug("Syscall #%ld: \"%s\"\n", (long)core->vm_regs.rax, get_linux_syscall_name32(core->vm_regs.rax)); + PrintDebug(core->vm_info, core, "Syscall #%ld: \"%s\"\n", (long)core->vm_regs.rax, get_linux_syscall_name32(core->vm_regs.rax)); } print_arg(core, core->vm_regs.rbx, 1); @@ -116,7 +116,7 @@ int v3_syscall_handler (struct guest_info * core, uint8_t vector, void * priv_da if (hook == NULL) { #ifdef V3_CONFIG_EXT_SYSCALL_PASSTHROUGH if (v3_hook_passthrough_syscall(core, syscall_nr) == -1) { - PrintDebug("Error hooking passthrough syscall\n"); + PrintDebug(core->vm_info, core, "Error hooking passthrough syscall\n"); return -1; } hook = syscall_hooks[syscall_nr]; @@ -140,7 +140,7 @@ int v3_syscall_handler (struct guest_info * core, uint8_t vector, void * priv_da inject_node); if (inject == NULL) { - PrintError("Problem getting inject from inject list\n"); + PrintError(core->vm_info, core, "Problem getting inject from inject list\n"); return -1; } @@ -150,7 +150,7 @@ int v3_syscall_handler (struct guest_info * core, uint8_t vector, void * priv_da // do the inject and don't fall over if there's an inject already in // progress if ((ret = v3_handle_guest_inject(core, (void*)inject)) == -1) { - PrintError("Could not run code injection: v3_syscall_handler\n"); + PrintError(core->vm_info, core, "Could not run code injection: v3_syscall_handler\n"); return 0; } else { return ret; @@ -163,7 +163,7 @@ int v3_syscall_handler (struct guest_info * core, uint8_t vector, void * priv_da err = hook->handler(core, syscall_nr, hook->priv_data); if (err == -1) { - PrintDebug("V3 Syscall Handler: Error in syscall hook\n"); + PrintDebug(core->vm_info, core, "V3 Syscall Handler: Error in syscall hook\n"); return -1; } @@ -179,7 +179,7 @@ int v3_syscall_handler (struct guest_info * core, uint8_t vector, void * priv_da static int v3_handle_lstar_write (struct guest_info * core, uint_t msr, struct v3_msr src, void * priv_data) { syscall_info.target_addr = (uint64_t) ((((uint64_t)src.hi) << 32) | src.lo); - PrintDebug("LSTAR Write: %p\n", (void*)syscall_info.target_addr); + PrintDebug(core->vm_info, core, "LSTAR Write: %p\n", (void*)syscall_info.target_addr); core->msrs.lstar = syscall_info.target_addr; return 0; } @@ -187,7 +187,7 @@ static int v3_handle_lstar_write (struct guest_info * core, uint_t msr, struct v // virtualize the lstar static int v3_handle_lstar_read (struct guest_info * core, uint_t msr, struct v3_msr * dst, void * priv_data) { - PrintDebug("LSTAR Read\n"); + PrintDebug(core->vm_info, core, "LSTAR Read\n"); dst->value = syscall_info.target_addr; return 0; } @@ -200,9 +200,9 @@ static int syscall_setup (struct guest_info * core, unsigned int hcall_id, void syscall_map_gva = (addr_t)core->vm_regs.rcx; ssa_gva = (addr_t)core->vm_regs.rdx; - PrintDebug("syscall setup hypercall:\n"); - PrintDebug("\t&syscall_stub (rbx): %p\n\t&syscall_map (rcx): %p\n", (void*)syscall_stub, (void*)syscall_map_gva); - PrintDebug("\t&ssa (rdx): %p\n", (void*)ssa_gva); + PrintDebug(core->vm_info, core, "syscall setup hypercall:\n"); + PrintDebug(core->vm_info, core, "\t&syscall_stub (rbx): %p\n\t&syscall_map (rcx): %p\n", (void*)syscall_stub, (void*)syscall_map_gva); + PrintDebug(core->vm_info, core, "\t&ssa (rdx): %p\n", (void*)ssa_gva); // the guest vitual address of the asm syscall handling routine syscall_info.syscall_stub = syscall_stub; @@ -210,17 +210,17 @@ static int syscall_setup (struct guest_info * core, unsigned int hcall_id, void // now get the hva of the system call map so we can manipulate it in the VMM if (v3_gva_to_hva(core, get_addr_linear(core, syscall_map_gva, &(core->segments.ds)), &syscall_map_hva) == 1) { - PrintError("Problem translating gva to hva for syscall map\n"); + PrintError(core->vm_info, core, "Problem translating gva to hva for syscall map\n"); return -1; } if (v3_gva_to_hva(core, get_addr_linear(core, ssa_gva, &(core->segments.ds)), &ssa_hva) == 1) { - PrintError("Problem translating gva to hva for syscall map\n"); + PrintError(core->vm_info, core, "Problem translating gva to hva for syscall map\n"); return -1; } - PrintDebug("\t&syscall_map (hva): %p\n", (void*) syscall_map_hva); - PrintDebug("\t&ssa (hva): %p\n", (void*) ssa_hva); + PrintDebug(core->vm_info, core, "\t&syscall_map (hva): %p\n", (void*) syscall_map_hva); + PrintDebug(core->vm_info, core, "\t&ssa (hva): %p\n", (void*) ssa_hva); syscall_info.syscall_map = (uint8_t*)syscall_map_hva; syscall_info.ssa = ssa_hva; @@ -237,7 +237,7 @@ static int syscall_setup (struct guest_info * core, unsigned int hcall_id, void static int syscall_cleanup (struct guest_info * core, unsigned int hcall_id, void * priv_data) { core->msrs.lstar = syscall_info.target_addr; - PrintDebug("original syscall entry point restored\n"); + PrintDebug(core->vm_info, core, "original syscall entry point restored\n"); return 0; } @@ -245,7 +245,7 @@ static int syscall_cleanup (struct guest_info * core, unsigned int hcall_id, voi static int sel_syscall_handle (struct guest_info * core, unsigned int hcall_id, void * priv_data) { struct v3_gprs regs; - PrintDebug("caught a selectively exited syscall\n"); + PrintDebug(core->vm_info, core, "caught a selectively exited syscall\n"); /* setup registers for handler routines. They should be in the same state * as when the system call was originally invoked */ @@ -263,14 +263,14 @@ static int sel_syscall_handle (struct guest_info * core, unsigned int hcall_id, // TODO: make these three functions guest-dependent int v3_syscall_on (void * ginfo, uint8_t syscall_nr) { - PrintDebug("Enabling exiting for syscall #%d\n", syscall_nr); + PrintDebug(VM_NONE, VCORE_NONE, "Enabling exiting for syscall #%d\n", syscall_nr); syscall_info.syscall_map[syscall_nr] = 1; return 0; } int v3_syscall_off (void * ginfo, uint8_t syscall_nr) { - PrintDebug("Disabling exiting for syscall #%d\n", syscall_nr); + PrintDebug(VM_NONE, VCORE_NONE, "Disabling exiting for syscall #%d\n", syscall_nr); syscall_info.syscall_map[syscall_nr] = 0; return 0; } @@ -297,18 +297,18 @@ static int init_syscall_hijack (struct v3_vm_info * vm, v3_cfg_tree_t * cfg, voi #ifdef V3_CONFIG_EXT_SYSCALL_INSTR static int v3_handle_lstar_write (struct guest_info * core, uint_t msr, struct v3_msr src, void * priv_data) { - PrintDebug("KCH: LSTAR Write\n"); - //PrintDebug("\tvalue: 0x%x%x\n", src.hi, src.lo); + PrintDebug(core->vm_info, core, "KCH: LSTAR Write\n"); + //PrintDebug(core->vm_info, core, "\tvalue: 0x%x%x\n", src.hi, src.lo); syscall_info.target_addr = (uint64_t) ((((uint64_t)src.hi) << 32) | src.lo); // Set LSTAR value seen by hardware while the guest is running - PrintDebug("replacing with %lx\n", SYSCALL_MAGIC_ADDR); + PrintDebug(core->vm_info, core, "replacing with %lx\n", SYSCALL_MAGIC_ADDR); core->msrs.lstar = SYSCALL_MAGIC_ADDR; return 0; } static int v3_handle_lstar_read (struct guest_info * core, uint_t msr, struct v3_msr * dst, void * priv_data) { - PrintDebug("KCH: LSTAR Read\n"); + PrintDebug(core->vm_info, core, "KCH: LSTAR Read\n"); dst->value = syscall_info.target_addr; return 0; } @@ -363,12 +363,12 @@ int v3_hook_syscall (struct guest_info * core, if (hook == NULL) { - PrintError("Cannot allocate for syscall hook\n"); + PrintError(core->vm_info, core, "Cannot allocate for syscall hook\n"); return -1; } if (get_syscall_hook(core, syscall_nr) != NULL) { - PrintError("System Call #%d already hooked\n", syscall_nr); + PrintError(core->vm_info, core, "System Call #%d already hooked\n", syscall_nr); return -1; } @@ -377,7 +377,7 @@ int v3_hook_syscall (struct guest_info * core, syscall_hooks[syscall_nr] = hook; - PrintDebug("Hooked Syscall #%d\n", syscall_nr); + PrintDebug(core->vm_info, core, "Hooked Syscall #%d\n", syscall_nr); return 0; } @@ -394,10 +394,10 @@ int v3_hook_passthrough_syscall (struct guest_info * core, uint_t syscall_nr) { int rc = v3_hook_syscall(core, syscall_nr, passthrough_syscall_handler, NULL); if (rc) { - PrintError("failed to hook syscall 0x%x for passthrough (guest=0x%p)\n", syscall_nr, (void *)core); + PrintError(core->vm_info, core, "failed to hook syscall 0x%x for passthrough (guest=0x%p)\n", syscall_nr, (void *)core); return -1; } else { - PrintDebug("hooked syscall 0x%x for passthrough (guest=0x%p)\n", syscall_nr, (void *)core); + PrintDebug(core->vm_info, core, "hooked syscall 0x%x for passthrough (guest=0x%p)\n", syscall_nr, (void *)core); return 0; } diff --git a/palacios/src/interfaces/host_pci.c b/palacios/src/interfaces/host_pci.c index e945b92..8ac41c0 100644 --- a/palacios/src/interfaces/host_pci.c +++ b/palacios/src/interfaces/host_pci.c @@ -31,7 +31,7 @@ static struct v3_host_pci_hooks * pci_hooks = NULL; void V3_Init_Host_PCI(struct v3_host_pci_hooks * hooks) { pci_hooks = hooks; - V3_Print("V3 host PCI interface intialized\n"); + V3_Print(VM_NONE, VCORE_NONE, "V3 host PCI interface intialized\n"); return; } @@ -40,7 +40,7 @@ void V3_Init_Host_PCI(struct v3_host_pci_hooks * hooks) { int V3_get_guest_mem_region(struct v3_vm_info * vm, struct v3_guest_mem_region * region) { if (!vm) { - PrintError("Tried to get a nenregion from a NULL vm pointer\n"); + PrintError(vm, VCORE_NONE, "Tried to get a menregion from a NULL vm pointer\n"); return -1; } @@ -58,14 +58,14 @@ struct v3_host_pci_dev * v3_host_pci_get_dev(struct v3_vm_info * vm, struct v3_host_pci_dev * host_dev = NULL; if ((!pci_hooks) || (!pci_hooks->request_device)) { - PrintError("Host PCI Hooks not initialized\n"); + PrintError(vm, VCORE_NONE, "Host PCI Hooks not initialized\n"); return NULL; } host_dev = pci_hooks->request_device(url, vm); if (host_dev == NULL) { - PrintError("Could not find host PCI device (%s)\n", url); + PrintError(vm, VCORE_NONE, "Could not find host PCI device (%s)\n", url); return NULL; } @@ -81,7 +81,7 @@ int v3_host_pci_config_write(struct v3_host_pci_dev * v3_dev, uint32_t length) { if ((!pci_hooks) || (!pci_hooks->config_write)) { - PrintError("Host PCI hooks not initialized\n"); + PrintError(VM_NONE, VCORE_NONE, "Host PCI hooks not initialized\n"); return -1; } @@ -94,7 +94,7 @@ int v3_host_pci_config_read(struct v3_host_pci_dev * v3_dev, uint32_t length) { if ((!pci_hooks) || (!pci_hooks->config_read)) { - PrintError("Host PCI hooks not initialized\n"); + PrintError(VM_NONE, VCORE_NONE, "Host PCI hooks not initialized\n"); return -1; } @@ -104,7 +104,7 @@ int v3_host_pci_config_read(struct v3_host_pci_dev * v3_dev, int v3_host_pci_ack_irq(struct v3_host_pci_dev * v3_dev, uint32_t vec_index) { if ((!pci_hooks) || (!pci_hooks->ack_irq)) { - PrintError("Host PCI hooks not initialized\n"); + PrintError(VM_NONE, VCORE_NONE, "Host PCI hooks not initialized\n"); return -1; } @@ -116,7 +116,7 @@ int v3_host_pci_ack_irq(struct v3_host_pci_dev * v3_dev, uint32_t vec_index) { int v3_host_pci_cmd_update(struct v3_host_pci_dev * v3_dev, pci_cmd_t cmd, uint64_t arg ) { if ((!pci_hooks) || (!pci_hooks->pci_cmd)) { - PrintError("Host PCI hooks not initialized\n"); + PrintError(VM_NONE, VCORE_NONE, "Host PCI hooks not initialized\n"); return -1; } @@ -129,7 +129,7 @@ int v3_host_pci_cmd_update(struct v3_host_pci_dev * v3_dev, pci_cmd_t cmd, uint6 int V3_host_pci_raise_irq(struct v3_host_pci_dev * v3_dev, uint32_t vec_index) { if (!v3_dev->irq_handler) { - PrintError("No interrupt registerd for host pci device\n"); + PrintError(VM_NONE, VCORE_NONE, "No interrupt registerd for host pci device\n"); return -1; } diff --git a/palacios/src/interfaces/vmm_console.c b/palacios/src/interfaces/vmm_console.c index 244fbf6..b987f24 100644 --- a/palacios/src/interfaces/vmm_console.c +++ b/palacios/src/interfaces/vmm_console.c @@ -29,58 +29,58 @@ struct v3_console_hooks * console_hooks = 0; v3_console_t v3_console_open(struct v3_vm_info * vm, uint32_t width, uint32_t height) { - V3_ASSERT(console_hooks != NULL); - V3_ASSERT(console_hooks->open != NULL); + V3_ASSERT(vm, VCORE_NONE, console_hooks != NULL); + V3_ASSERT(vm, VCORE_NONE, console_hooks->open != NULL); return console_hooks->open(vm->host_priv_data, width, height); } void v3_console_close(v3_console_t cons) { - V3_ASSERT(console_hooks); - V3_ASSERT(console_hooks->close); + V3_ASSERT(VM_NONE, VCORE_NONE, console_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE, console_hooks->close); console_hooks->close(cons); } int v3_console_set_cursor(v3_console_t cons, int x, int y) { - V3_ASSERT(console_hooks != NULL); - V3_ASSERT(console_hooks->set_cursor != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, console_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, console_hooks->set_cursor != NULL); return console_hooks->set_cursor(cons, x, y); } int v3_console_set_char(v3_console_t cons, int x, int y, char c, uint8_t style) { - V3_ASSERT(console_hooks != NULL); - V3_ASSERT(console_hooks->set_character != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, console_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, console_hooks->set_character != NULL); return console_hooks->set_character(cons, x, y, c, style); } int v3_console_scroll(v3_console_t cons, int lines) { - V3_ASSERT(console_hooks != NULL); - V3_ASSERT(console_hooks->scroll != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, console_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, console_hooks->scroll != NULL); return console_hooks->scroll(cons, lines); } int v3_console_set_text_resolution(v3_console_t cons, int cols, int rows) { - V3_ASSERT(console_hooks != NULL); - V3_ASSERT(console_hooks->set_text_resolution != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, console_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, console_hooks->set_text_resolution != NULL); return console_hooks->set_text_resolution(cons, cols, rows); } int v3_console_update(v3_console_t cons) { - V3_ASSERT(console_hooks != NULL); - V3_ASSERT(console_hooks->update != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, console_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, console_hooks->update != NULL); return console_hooks->update(cons); } void V3_Init_Console(struct v3_console_hooks * hooks) { console_hooks = hooks; - PrintDebug("V3 console inited\n"); + PrintDebug(VM_NONE, VCORE_NONE, "V3 console inited\n"); return; } diff --git a/palacios/src/interfaces/vmm_file.c b/palacios/src/interfaces/vmm_file.c index 4827a95..2f72aa5 100644 --- a/palacios/src/interfaces/vmm_file.c +++ b/palacios/src/interfaces/vmm_file.c @@ -28,22 +28,22 @@ static struct v3_file_hooks * file_hooks = NULL; void V3_Init_File(struct v3_file_hooks * hooks) { file_hooks = hooks; - V3_Print("V3 file interface intialized\n"); + V3_Print(VM_NONE, VCORE_NONE, "V3 file interface intialized\n"); return; } int v3_mkdir(char * path, uint16_t permissions, uint8_t recursive) { - V3_ASSERT(file_hooks); - V3_ASSERT(file_hooks->mkdir); + V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks->mkdir); return file_hooks->mkdir(path, permissions, recursive); } v3_file_t v3_file_open(struct v3_vm_info * vm, char * path, uint8_t mode) { void * priv_data = NULL; - V3_ASSERT(file_hooks); - V3_ASSERT(file_hooks->open); + V3_ASSERT(vm, VCORE_NONE, file_hooks); + V3_ASSERT(vm, VCORE_NONE, file_hooks->open); if (vm) { priv_data = vm->host_priv_data; @@ -53,30 +53,30 @@ v3_file_t v3_file_open(struct v3_vm_info * vm, char * path, uint8_t mode) { } int v3_file_close(v3_file_t file) { - V3_ASSERT(file_hooks); - V3_ASSERT(file_hooks->close); + V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks->close); return file_hooks->close(file); } uint64_t v3_file_size(v3_file_t file) { - V3_ASSERT(file_hooks); - V3_ASSERT(file_hooks->size); + V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks->size); return file_hooks->size(file); } uint64_t v3_file_read(v3_file_t file, uint8_t * buf, uint64_t len, uint64_t off) { - V3_ASSERT(file_hooks); - V3_ASSERT(file_hooks->read); + V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks->read); return file_hooks->read(file, buf, len, off); } uint64_t v3_file_write(v3_file_t file, uint8_t * buf, uint64_t len, uint64_t off) { - V3_ASSERT(file_hooks); - V3_ASSERT(file_hooks->write); + V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks->write); return file_hooks->write(file, buf, len, off); } diff --git a/palacios/src/interfaces/vmm_graphics_console.c b/palacios/src/interfaces/vmm_graphics_console.c index 3857f65..ab6ecd0 100644 --- a/palacios/src/interfaces/vmm_graphics_console.c +++ b/palacios/src/interfaces/vmm_graphics_console.c @@ -30,24 +30,24 @@ v3_graphics_console_t v3_graphics_console_open(struct v3_vm_info * vm, struct v3_frame_buffer_spec *desired_spec, struct v3_frame_buffer_spec *actual_spec) { - V3_ASSERT(graphics_console_hooks != NULL); - V3_ASSERT(graphics_console_hooks->open != NULL); + V3_ASSERT(vm, VCORE_NONE, graphics_console_hooks != NULL); + V3_ASSERT(vm, VCORE_NONE, graphics_console_hooks->open != NULL); return graphics_console_hooks->open(vm->host_priv_data, desired_spec, actual_spec); } void v3_graphics_console_close(v3_graphics_console_t cons) { - V3_ASSERT(graphics_console_hooks); - V3_ASSERT(graphics_console_hooks->close); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks->close); graphics_console_hooks->close(cons); } void * v3_graphics_console_get_frame_buffer_data_read(v3_graphics_console_t cons, struct v3_frame_buffer_spec *spec) { - V3_ASSERT(graphics_console_hooks != NULL); - V3_ASSERT(graphics_console_hooks->get_data_read != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks->get_data_read != NULL); return graphics_console_hooks->get_data_read(cons, spec); } @@ -55,24 +55,24 @@ void * v3_graphics_console_get_frame_buffer_data_read(v3_graphics_console_t cons void v3_graphics_console_release_frame_buffer_data_read(v3_graphics_console_t cons) { - V3_ASSERT(graphics_console_hooks != NULL); - V3_ASSERT(graphics_console_hooks->release_data_read != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks->release_data_read != NULL); return graphics_console_hooks->release_data_read(cons); } void * v3_graphics_console_get_frame_buffer_data_rw(v3_graphics_console_t cons, struct v3_frame_buffer_spec *spec) { - V3_ASSERT(graphics_console_hooks != NULL); - V3_ASSERT(graphics_console_hooks->get_data_rw != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks->get_data_rw != NULL); return graphics_console_hooks->get_data_rw(cons, spec); } void v3_graphics_console_release_frame_buffer_data_rw(v3_graphics_console_t cons) { - V3_ASSERT(graphics_console_hooks != NULL); - V3_ASSERT(graphics_console_hooks->release_data_rw != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks->release_data_rw != NULL); return graphics_console_hooks->release_data_rw(cons); } @@ -80,8 +80,8 @@ void v3_graphics_console_release_frame_buffer_data_rw(v3_graphics_console_t cons int v3_graphics_console_inform_update(v3_graphics_console_t cons) { - V3_ASSERT(graphics_console_hooks != NULL); - V3_ASSERT(graphics_console_hooks->changed != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks->changed != NULL); return graphics_console_hooks->changed(cons); } @@ -92,8 +92,8 @@ int v3_graphics_console_register_render_request( void *priv_data), void *priv_data) { - V3_ASSERT(graphics_console_hooks!=NULL); - V3_ASSERT(graphics_console_hooks->register_render_request!=NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks!=NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks->register_render_request!=NULL); return graphics_console_hooks->register_render_request(cons,render_request,priv_data); } @@ -104,8 +104,8 @@ int v3_graphics_console_register_update_inquire( void *priv_data), void *priv_data) { - V3_ASSERT(graphics_console_hooks!=NULL); - V3_ASSERT(graphics_console_hooks->register_update_inquire!=NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks!=NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, graphics_console_hooks->register_update_inquire!=NULL); return graphics_console_hooks->register_update_inquire(cons,update_inquire,priv_data); } @@ -113,7 +113,7 @@ int v3_graphics_console_register_update_inquire( void V3_Init_Graphics_Console(struct v3_graphics_console_hooks * hooks) { graphics_console_hooks = hooks; - PrintDebug("V3 graphics console inited\n"); + PrintDebug(VM_NONE, VCORE_NONE, "V3 graphics console inited\n"); return; } diff --git a/palacios/src/interfaces/vmm_host_dev.c b/palacios/src/interfaces/vmm_host_dev.c index 0002cb2..ebae331 100644 --- a/palacios/src/interfaces/vmm_host_dev.c +++ b/palacios/src/interfaces/vmm_host_dev.c @@ -32,16 +32,16 @@ v3_host_dev_t v3_host_dev_open(char *impl, v3_guest_dev_t gdev, struct v3_vm_info *vm) { - V3_ASSERT(host_dev_hooks != NULL); - V3_ASSERT(host_dev_hooks->open != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->open != NULL); return host_dev_hooks->open(impl,bus,gdev,vm->host_priv_data); } int v3_host_dev_close(v3_host_dev_t hdev) { - V3_ASSERT(host_dev_hooks); - V3_ASSERT(host_dev_hooks->close); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->close); return host_dev_hooks->close(hdev); } @@ -51,8 +51,8 @@ uint64_t v3_host_dev_read_io(v3_host_dev_t hdev, void *dst, uint64_t len) { - V3_ASSERT(host_dev_hooks != NULL); - V3_ASSERT(host_dev_hooks->read_io != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->read_io != NULL); return host_dev_hooks->read_io(hdev,port,dst,len); } @@ -62,8 +62,8 @@ uint64_t v3_host_dev_write_io(v3_host_dev_t hdev, void *src, uint64_t len) { - V3_ASSERT(host_dev_hooks != NULL); - V3_ASSERT(host_dev_hooks->write_io != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->write_io != NULL); return host_dev_hooks->write_io(hdev,port,src,len); } @@ -73,8 +73,8 @@ uint64_t v3_host_dev_read_mem(v3_host_dev_t hdev, void *dst, uint64_t len) { - V3_ASSERT(host_dev_hooks != NULL); - V3_ASSERT(host_dev_hooks->read_mem != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->read_mem != NULL); return host_dev_hooks->read_mem(hdev,(void*)gpa,dst,len); } @@ -84,8 +84,8 @@ uint64_t v3_host_dev_write_mem(v3_host_dev_t hdev, void *src, uint64_t len) { - V3_ASSERT(host_dev_hooks != NULL); - V3_ASSERT(host_dev_hooks->write_mem != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->write_mem != NULL); return host_dev_hooks->write_mem(hdev,(void*)gpa,src,len); } @@ -95,8 +95,8 @@ uint64_t v3_host_dev_read_config(v3_host_dev_t hdev, void *dst, uint64_t len) { - V3_ASSERT(host_dev_hooks != NULL); - V3_ASSERT(host_dev_hooks->read_config); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->read_config); return host_dev_hooks->read_config(hdev,offset,dst,len); } @@ -106,8 +106,8 @@ uint64_t v3_host_dev_write_config(v3_host_dev_t hdev, void *src, uint64_t len) { - V3_ASSERT(host_dev_hooks != NULL); - V3_ASSERT(host_dev_hooks->write_config); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->write_config); return host_dev_hooks->write_config(hdev,offset,src,len); @@ -116,8 +116,8 @@ uint64_t v3_host_dev_write_config(v3_host_dev_t hdev, int v3_host_dev_ack_irq(v3_host_dev_t hdev, uint8_t irq) { - V3_ASSERT(host_dev_hooks != NULL); - V3_ASSERT(host_dev_hooks->ack_irq); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->ack_irq); return host_dev_hooks->ack_irq(hdev,irq); } @@ -185,7 +185,7 @@ uint64_t v3_host_dev_write_guest_mem(v3_host_dev_t hostdev, void V3_Init_Host_Device_Support(struct v3_host_dev_hooks * hooks) { host_dev_hooks = hooks; - PrintDebug("V3 host device interface inited\n"); + PrintDebug(VM_NONE, VCORE_NONE, "V3 host device interface inited\n"); return; } diff --git a/palacios/src/interfaces/vmm_host_hypercall.c b/palacios/src/interfaces/vmm_host_hypercall.c index a053184..614ea30 100644 --- a/palacios/src/interfaces/vmm_host_hypercall.c +++ b/palacios/src/interfaces/vmm_host_hypercall.c @@ -142,7 +142,7 @@ int v3_register_host_hypercall(host_vm_info_t * vm, struct bounce_data *b = V3_Malloc(sizeof(struct bounce_data)); if (!b) { - PrintError("Unable to allocate in registering host hypercall\n"); + PrintError((struct v3_vm_info*)vm, VCORE_NONE, "Unable to allocate in registering host hypercall\n"); return -1; } @@ -153,7 +153,7 @@ int v3_register_host_hypercall(host_vm_info_t * vm, hypercall_id, bounce, b) < 0) { - PrintError("Cannot register host hypercall\n"); + PrintError((struct v3_vm_info*)vm, VCORE_NONE, "Cannot register host hypercall\n"); V3_Free(b); return -1; } diff --git a/palacios/src/interfaces/vmm_keyed_stream.c b/palacios/src/interfaces/vmm_keyed_stream.c index 45d8d20..99e4c22 100644 --- a/palacios/src/interfaces/vmm_keyed_stream.c +++ b/palacios/src/interfaces/vmm_keyed_stream.c @@ -28,8 +28,8 @@ struct v3_keyed_stream_hooks * keyed_stream_hooks = 0; v3_keyed_stream_t v3_keyed_stream_open(char *url, v3_keyed_stream_open_t open_type) { - V3_ASSERT(keyed_stream_hooks != NULL); - V3_ASSERT(keyed_stream_hooks->open != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks->open != NULL); return keyed_stream_hooks->open(url,open_type); } @@ -38,8 +38,8 @@ v3_keyed_stream_t v3_keyed_stream_open(char *url, v3_keyed_stream_open_t ope void v3_keyed_stream_close(v3_keyed_stream_t stream) { - V3_ASSERT(keyed_stream_hooks != NULL); - V3_ASSERT(keyed_stream_hooks->close != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks->close != NULL); return keyed_stream_hooks->close(stream); @@ -48,16 +48,16 @@ void v3_keyed_stream_close(v3_keyed_stream_t stream) void v3_keyed_stream_preallocate_hint_key(v3_keyed_stream_t stream, char *key, uint64_t size) { - V3_ASSERT(keyed_stream_hooks != NULL); - V3_ASSERT(keyed_stream_hooks->preallocate_hint_key != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks->preallocate_hint_key != NULL); return keyed_stream_hooks->preallocate_hint_key(stream,key,size); } v3_keyed_stream_key_t v3_keyed_stream_open_key(v3_keyed_stream_t stream, char *key) { - V3_ASSERT(keyed_stream_hooks != NULL); - V3_ASSERT(keyed_stream_hooks->open_key != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks->open_key != NULL); return keyed_stream_hooks->open_key(stream,key); } @@ -65,8 +65,8 @@ v3_keyed_stream_key_t v3_keyed_stream_open_key(v3_keyed_stream_t stream, char *k void v3_keyed_stream_close_key(v3_keyed_stream_t stream, char *key) { - V3_ASSERT(keyed_stream_hooks != NULL); - V3_ASSERT(keyed_stream_hooks->close_key != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks->close_key != NULL); return keyed_stream_hooks->close_key(stream,key); } @@ -79,8 +79,8 @@ sint64_t v3_keyed_stream_write_key(v3_keyed_stream_t stream, void *buf, sint64_t len) { - V3_ASSERT(keyed_stream_hooks != NULL); - V3_ASSERT(keyed_stream_hooks->write_key != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks->write_key != NULL); return keyed_stream_hooks->write_key(stream,key,tag,taglen,buf,len); } @@ -92,8 +92,8 @@ sint64_t v3_keyed_stream_read_key(v3_keyed_stream_t stream, void *buf, sint64_t len) { - V3_ASSERT(keyed_stream_hooks != NULL); - V3_ASSERT(keyed_stream_hooks->read_key != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, keyed_stream_hooks->read_key != NULL); return keyed_stream_hooks->read_key(stream,key,tag,taglen,buf,len); } @@ -102,7 +102,7 @@ sint64_t v3_keyed_stream_read_key(v3_keyed_stream_t stream, void V3_Init_Keyed_Streams(struct v3_keyed_stream_hooks * hooks) { keyed_stream_hooks = hooks; - PrintDebug("V3 keyed stream support inited\n"); + PrintDebug(VM_NONE, VCORE_NONE, "V3 keyed stream support inited\n"); return; } diff --git a/palacios/src/interfaces/vmm_packet.c b/palacios/src/interfaces/vmm_packet.c index 07c86ee..9356e22 100644 --- a/palacios/src/interfaces/vmm_packet.c +++ b/palacios/src/interfaces/vmm_packet.c @@ -26,7 +26,7 @@ static struct v3_packet_hooks * packet_hooks = 0; void V3_Init_Packet(struct v3_packet_hooks * hooks) { packet_hooks = hooks; - PrintDebug("V3 raw packet interface inited\n"); + PrintDebug(VM_NONE, VCORE_NONE,"V3 raw packet interface inited\n"); return; } @@ -38,13 +38,13 @@ struct v3_packet * v3_packet_connect(struct v3_vm_info * vm, void * guest_packet_data) { struct v3_packet * packet = NULL; - V3_ASSERT(packet_hooks != NULL); - V3_ASSERT(packet_hooks->connect != NULL); + V3_ASSERT(vm, VCORE_NONE, packet_hooks != NULL); + V3_ASSERT(vm, VCORE_NONE, packet_hooks->connect != NULL); packet = V3_Malloc(sizeof(struct v3_packet)); if (!packet) { - PrintError("Cannot allocate in connecting packet\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in connecting packet\n"); return NULL; } @@ -60,15 +60,15 @@ struct v3_packet * v3_packet_connect(struct v3_vm_info * vm, } int v3_packet_send(struct v3_packet * packet, uint8_t * buf, uint32_t len) { - V3_ASSERT(packet_hooks != NULL); - V3_ASSERT(packet_hooks->send != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE,packet_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE,packet_hooks->send != NULL); return packet_hooks->send(packet, buf, len); } void v3_packet_close(struct v3_packet * packet) { - V3_ASSERT(packet_hooks != NULL); - V3_ASSERT(packet_hooks->close != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE,packet_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE,packet_hooks->close != NULL); packet_hooks->close(packet); V3_Free(packet); diff --git a/palacios/src/interfaces/vmm_socket.c b/palacios/src/interfaces/vmm_socket.c index 5ac5c15..5cdd683 100644 --- a/palacios/src/interfaces/vmm_socket.c +++ b/palacios/src/interfaces/vmm_socket.c @@ -205,8 +205,8 @@ uint32_t v3_ntohl(uint32_t n) { v3_sock_t v3_create_udp_socket(struct v3_vm_info * vm) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->udp_socket); + V3_ASSERT(vm, VCORE_NONE, sock_hooks); + V3_ASSERT(vm, VCORE_NONE, sock_hooks->udp_socket); void * priv_data = NULL; if (vm) { @@ -217,8 +217,8 @@ v3_sock_t v3_create_udp_socket(struct v3_vm_info * vm) { } v3_sock_t v3_create_tcp_socket(struct v3_vm_info * vm) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->tcp_socket); + V3_ASSERT(vm, VCORE_NONE, sock_hooks); + V3_ASSERT(vm, VCORE_NONE, sock_hooks->tcp_socket); void * priv_data = NULL; if (vm) { @@ -229,89 +229,89 @@ v3_sock_t v3_create_tcp_socket(struct v3_vm_info * vm) { } void v3_socket_close(v3_sock_t sock) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->close); + V3_ASSERT(VM_NONE, VCORE_NONE, sock_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks->close); sock_hooks->close(sock); } int v3_socket_bind(const v3_sock_t sock, uint16_t port) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->bind); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks->bind); return sock_hooks->bind(sock, port); } int v3_socket_listen(const v3_sock_t sock, int backlog) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->listen); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks->listen); return sock_hooks->listen(sock, backlog); } v3_sock_t v3_socket_accept(const v3_sock_t sock, uint32_t * remote_ip, uint32_t * port) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->accept); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks->accept); return sock_hooks->accept(sock, remote_ip, port); } int v3_connect_to_ip(const v3_sock_t sock, const uint32_t hostip, const uint16_t port) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->connect_to_ip); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks->connect_to_ip); return sock_hooks->connect_to_ip(sock, hostip, port); } int v3_connect_to_host(const v3_sock_t sock, const char * hostname, const uint16_t port) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->connect_to_host); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks->connect_to_host); return sock_hooks->connect_to_host(sock, hostname, port); } int v3_socket_send(const v3_sock_t sock, const uint8_t * buf, const uint32_t len) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->send); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks->send); return sock_hooks->send(sock, buf, len); } int v3_socket_recv(const v3_sock_t sock, uint8_t * buf, const uint32_t len) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->recv); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks->recv); return sock_hooks->recv(sock, buf, len); } int v3_socket_send_to_host(const v3_sock_t sock, const char * hostname, const uint16_t port, const uint8_t * buf, const uint32_t len) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->sendto_host); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks->sendto_host); return sock_hooks->sendto_host(sock, hostname, port, buf, len); } int v3_socket_send_to_ip(const v3_sock_t sock, const uint32_t ip, const uint16_t port, const uint8_t * buf, const uint32_t len) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->sendto_ip); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks->sendto_ip); return sock_hooks->sendto_ip(sock, ip, port, buf, len); } int v3_socket_recv_from_host(const v3_sock_t sock, const char * hostname, const uint16_t port, uint8_t * buf, const uint32_t len) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->recvfrom_host); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks->recvfrom_host); return sock_hooks->recvfrom_host(sock, hostname, port, buf, len); } int v3_socket_recv_from_ip(const v3_sock_t sock, const uint32_t ip, const uint16_t port, uint8_t * buf, const uint32_t len) { - V3_ASSERT(sock_hooks); - V3_ASSERT(sock_hooks->recvfrom_ip); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks); + V3_ASSERT(VM_NONE, VCORE_NONE,sock_hooks->recvfrom_ip); return sock_hooks->recvfrom_ip(sock, ip, port, buf, len); } @@ -321,7 +321,7 @@ int v3_socket_recv_from_ip(const v3_sock_t sock, const uint32_t ip, const uint16 void V3_Init_Sockets(struct v3_socket_hooks * hooks) { sock_hooks = hooks; - PrintDebug("V3 sockets inited\n"); + PrintDebug(VM_NONE, VCORE_NONE,"V3 sockets inited\n"); return; } diff --git a/palacios/src/interfaces/vmm_stream.c b/palacios/src/interfaces/vmm_stream.c index 27269d3..df235aa 100644 --- a/palacios/src/interfaces/vmm_stream.c +++ b/palacios/src/interfaces/vmm_stream.c @@ -33,13 +33,13 @@ struct v3_stream * v3_stream_open(struct v3_vm_info * vm, const char * name, void * guest_stream_data) { struct v3_stream * stream = NULL; - V3_ASSERT(stream_hooks != NULL); - V3_ASSERT(stream_hooks->open != NULL); + V3_ASSERT(vm, VCORE_NONE, stream_hooks != NULL); + V3_ASSERT(vm, VCORE_NONE, stream_hooks->open != NULL); stream = V3_Malloc(sizeof(struct v3_stream)); if (!stream) { - PrintError("Cannot allocate in opening a stream\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in opening a stream\n"); return NULL; } @@ -51,15 +51,15 @@ struct v3_stream * v3_stream_open(struct v3_vm_info * vm, const char * name, } uint64_t v3_stream_output(struct v3_stream * stream, uint8_t * buf, uint32_t len) { - V3_ASSERT(stream_hooks != NULL); - V3_ASSERT(stream_hooks->output != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, stream_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, stream_hooks->output != NULL); return stream_hooks->output(stream, buf, len); } void v3_stream_close(struct v3_stream * stream) { - V3_ASSERT(stream_hooks != NULL); - V3_ASSERT(stream_hooks->close != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, stream_hooks != NULL); + V3_ASSERT(VM_NONE, VCORE_NONE, stream_hooks->close != NULL); stream_hooks->close(stream); @@ -70,7 +70,7 @@ void v3_stream_close(struct v3_stream * stream) { void V3_Init_Stream(struct v3_stream_hooks * hooks) { stream_hooks = hooks; - PrintDebug("V3 stream inited\n"); + PrintDebug(VM_NONE, VCORE_NONE, "V3 stream inited\n"); return; } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_cache.c b/palacios/src/palacios/mmu/vmm_shdw_pg_cache.c index ae0db99..a3bc512 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_cache.c +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_cache.c @@ -134,7 +134,7 @@ static inline int evict_pt(void * pt, addr_t va, page_type_t pt_type) { break; } default: - PrintError("Invalid page type: %d\n", pt_type); + PrintError(VM_NONE, VCORE_NONE, "Invalid page type: %d\n", pt_type); return -1; } @@ -182,7 +182,7 @@ static inline int grab_pt(void * pt, addr_t va, page_type_t pt_type) { break; } default: - PrintError("Invalid page type: %d\n", pt_type); + PrintError(VM_NONE, VCORE_NONE, "Invalid page type: %d\n", pt_type); return -1; } @@ -194,7 +194,7 @@ static int unlink_shdw_pg(struct shdw_pg_data * pg_data) { struct shdw_back_ptr * back_ptr = NULL; struct shdw_back_ptr * tmp_ptr = NULL; - PrintError("Unlinking gpa=%p, type=%d\n", (void *)pg_data->tuple.gpa, pg_data->tuple.pt_type); + PrintError(VM_NONE, VCORE_NONE, "Unlinking gpa=%p, type=%d\n", (void *)pg_data->tuple.gpa, pg_data->tuple.pt_type); list_for_each_entry_safe(back_ptr, tmp_ptr, &(pg_data->back_ptrs), back_ptr_node) { struct shdw_pg_data * parent = back_ptr->pg_data; @@ -222,7 +222,7 @@ static int add_rmap(struct v3_vm_info * vm, struct shdw_pg_data * pg_data, addr_ rmap_list = V3_Malloc(sizeof(struct list_head)); if (!rmap_list) { - PrintError("Cannot allocate\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate\n"); return -1; } @@ -234,7 +234,7 @@ static int add_rmap(struct v3_vm_info * vm, struct shdw_pg_data * pg_data, addr_ entry = V3_Malloc(sizeof(struct rmap_entry)); if (!entry) { - PrintError("Cannot allocate\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate\n"); return -1; } @@ -261,23 +261,23 @@ static int update_rmap_entries(struct v3_vm_info * vm, addr_t gpa) { return 0; } - PrintError("Updating rmap entries\n\t"); + PrintError(vm, VCORE_NONE, "Updating rmap entries\n\t"); list_for_each_entry(entry, rmap_list, rmap_node) { struct shdw_pg_data * pg_data = NULL; struct guest_pg_tuple tuple = {entry->gpa, entry->pt_type}; - V3_Print("%d \n", i); + V3_Print(vm, VCORE_NONE, "%d \n", i); pg_data = (struct shdw_pg_data *)v3_htable_search(cache_state->page_htable, (addr_t)&tuple); if (!pg_data) { - PrintError("Invalid PTE reference... Should Delete rmap entry\n"); + PrintError(vm, VCORE_NONE, "Invalid PTE reference... Should Delete rmap entry\n"); continue; } if (grab_pt(pg_data->hva, entry->gva, entry->pt_type) == -1) { - PrintError("Could not invalidate reverse map entry\n"); + PrintError(vm, VCORE_NONE, "Could not invalidate reverse map entry\n"); return -1; } @@ -295,7 +295,7 @@ static int link_shdw_pg(struct shdw_pg_data * child_pg, struct shdw_pg_data * pa struct shdw_back_ptr * back_ptr = V3_Malloc(sizeof(struct shdw_back_ptr)); if (!back_ptr) { - PrintError("Cannot allocate\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate\n"); return -1; } @@ -333,11 +333,11 @@ static int evict_shdw_pg(struct v3_vm_info * vm, addr_t gpa, page_type_t pt_type pg_data = find_shdw_pt(vm, gpa, pt_type); - PrintError("Evicting GPA: %p, type=%d\n", (void *)gpa, pt_type); + PrintError(vm, VCORE_NONE, "Evicting GPA: %p, type=%d\n", (void *)gpa, pt_type); if (pg_data != NULL) { if (unlink_shdw_pg(pg_data) == -1) { - PrintError("Error unlinking page...\n"); + PrintError(vm, VCORE_NONE, "Error unlinking page...\n"); return -1; } @@ -358,13 +358,13 @@ static struct shdw_pg_data * pop_queue_pg(struct v3_vm_info * vm, struct cache_vm_state * cache_state) { struct shdw_pg_data * pg_data = NULL; - PrintError("popping page from queue\n"); + PrintError(vm, VCORE_NONE, "popping page from queue\n"); pg_data = list_tail_entry(&(cache_state->pg_queue), struct shdw_pg_data, pg_queue_node); if (unlink_shdw_pg(pg_data) == -1) { - PrintError("Error unlinking cached page\n"); + PrintError(vm, VCORE_NONE, "Error unlinking cached page\n"); return NULL; } @@ -381,20 +381,20 @@ static struct shdw_pg_data * create_shdw_pt(struct v3_vm_info * vm, addr_t gpa, struct shdw_pg_data * pg_data = NULL; - PrintError("Creating shdw page: gpa=%p, type=%d\n", (void *)gpa, pt_type); + PrintError(vm, VCORE_NONE, "Creating shdw page: gpa=%p, type=%d\n", (void *)gpa, pt_type); if (cache_state->pgs_in_cache < cache_state->max_cache_pgs) { pg_data = V3_Malloc(sizeof(struct shdw_pg_data)); if (!pg_data) { - PrintError("Cannot allocate\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate\n"); return NULL; } pg_data->hpa = (addr_t)V3_AllocPages(1); if (!pg_data->hpa) { - PrintError("Cannot allocate page for shadow page table\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate page for shadow page table\n"); return NULL; } @@ -402,7 +402,7 @@ static struct shdw_pg_data * create_shdw_pt(struct v3_vm_info * vm, addr_t gpa, } else if (cache_state->pgs_in_free_list) { - PrintError("pulling page from free list\n"); + PrintError(vm, VCORE_NONE, "pulling page from free list\n"); // pull from free list pg_data = list_tail_entry(&(cache_state->free_list), struct shdw_pg_data, pg_queue_node); @@ -416,7 +416,7 @@ static struct shdw_pg_data * create_shdw_pt(struct v3_vm_info * vm, addr_t gpa, if (pg_data == NULL) { - PrintError("Error creating Shadow Page table page\n"); + PrintError(vm, VCORE_NONE, "Error creating Shadow Page table page\n"); return NULL; } @@ -474,12 +474,12 @@ static int cache_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { cache_size = ((atoi(cache_sz_str) * 1024 * 1024) / 4096); } - V3_Print("Shadow Page Cache initialization\n"); + V3_Print(vm, VCORE_NONE, "Shadow Page Cache initialization\n"); cache_state = V3_Malloc(sizeof(struct cache_vm_state)); if (!cache_state) { - PrintError("Cannot allocate\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate\n"); return -1; } @@ -514,7 +514,7 @@ static int cache_activate_shdw_pt(struct guest_info * core) { switch (v3_get_vm_cpu_mode(core)) { case PROTECTED: - PrintError("Calling 32 bit cache activation\n"); + PrintError(core->vm_info, core, "Calling 32 bit cache activation\n"); return activate_shadow_pt_32(core); case PROTECTED_PAE: // return activate_shadow_pt_32pae(core); @@ -523,7 +523,7 @@ static int cache_activate_shdw_pt(struct guest_info * core) { case LONG_16_COMPAT: // return activate_shadow_pt_64(core); default: - PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(core->vm_info, core, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } @@ -532,7 +532,7 @@ static int cache_activate_shdw_pt(struct guest_info * core) { static int cache_invalidate_shdw_pt(struct guest_info * core) { // wipe everything... - V3_Print("Cache invalidation called\n"); + V3_Print(core->vm_info, core, "Cache invalidation called\n"); return cache_activate_shdw_pt(core); } @@ -552,14 +552,14 @@ static int cache_handle_pf(struct guest_info * core, addr_t fault_addr, pf_error case LONG_16_COMPAT: // return handle_shadow_pagefault_64(core, fault_addr, error_code); default: - PrintError("Unhandled CPU Mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(core->vm_info, core, "Unhandled CPU Mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } } static int cache_handle_invlpg(struct guest_info * core, addr_t vaddr) { - PrintError("INVLPG called for %p\n", (void *)vaddr); + PrintError(core->vm_info, core, "INVLPG called for %p\n", (void *)vaddr); switch (v3_get_vm_cpu_mode(core)) { case PROTECTED: @@ -571,7 +571,7 @@ static int cache_handle_invlpg(struct guest_info * core, addr_t vaddr) { case LONG_16_COMPAT: // return handle_shadow_invlpg_64(core, vaddr); default: - PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(core->vm_info, core, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_cache_32.h b/palacios/src/palacios/mmu/vmm_shdw_pg_cache_32.h index fab26fd..6e26d73 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_cache_32.h +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_cache_32.h @@ -24,10 +24,10 @@ static inline int activate_shadow_pt_32(struct guest_info * core) { addr_t gpa = BASE_TO_PAGE_ADDR_4KB(guest_cr3->pdt_base_addr); struct shdw_pg_data * shdw_pg = NULL; - PrintDebug("Activating 32 Bit cacheable page tables\n"); + PrintDebug(info->vm_info, info, "Activating 32 Bit cacheable page tables\n"); shdw_pg = find_shdw_pt(core->vm_info, gpa, PAGE_PD32); - PrintError("shdw_pg returned as %p for CR3:%p\n", shdw_pg, (void *)gpa); + PrintError(core->vm_info, core, "shdw_pg returned as %p for CR3:%p\n", shdw_pg, (void *)gpa); if (shdw_pg == NULL) { shdw_pg = create_shdw_pt(core->vm_info, gpa, PAGE_PD32); @@ -38,7 +38,7 @@ static inline int activate_shadow_pt_32(struct guest_info * core) { update_rmap_entries(core->vm_info, gpa); } - PrintDebug("shdw_pg now exists...\n"); + PrintDebug(core->vm_info, core, "shdw_pg now exists...\n"); shadow_cr3->pdt_base_addr = PAGE_BASE_ADDR_4KB(shdw_pg->hpa); shadow_cr3->pwt = guest_cr3->pwt; @@ -79,11 +79,11 @@ static inline int handle_shadow_pagefault_32(struct guest_info * core, addr_t fa pde32_t * guest_pde = NULL; pde32_t * shadow_pde = (pde32_t *)&(shadow_pd[PDE32_INDEX(fault_addr)]); - PrintDebug("Shadow cache page fault handler: %p\n", (void *)fault_addr ); - PrintDebug("Handling PDE32 Fault\n"); + PrintDebug(core->vm_info, core, "Shadow cache page fault handler: %p\n", (void *)fault_addr ); + PrintDebug(core->vm_info, core, "Handling PDE32 Fault\n"); if (v3_gpa_to_hva(core, guest_cr3, (addr_t*)&guest_pd) == -1) { - PrintError("Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); + PrintError(core->vm_info, core, "Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); return -1; } @@ -97,10 +97,10 @@ static inline int handle_shadow_pagefault_32(struct guest_info * core, addr_t fa /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pde_access, shadow_pde_access) == 1) { - PrintDebug("Injecting PDE pf to guest: (guest access error=%d) (shdw access error=%d) (pf error code=%d)\n", + PrintDebug(core->vm_info, core, "Injecting PDE pf to guest: (guest access error=%d) (shdw access error=%d) (pf error code=%d)\n", *(uint_t *)&guest_pde_access, *(uint_t *)&shadow_pde_access, *(uint_t *)&error_code); if (v3_inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } return 0; @@ -112,11 +112,11 @@ static inline int handle_shadow_pagefault_32(struct guest_info * core, addr_t fa // // PDE Entry marked non user // - PrintDebug("Shadow Paging User access error (shadow_pde_access=0x%x, guest_pde_access=0x%x)\n", + PrintDebug(core->vm_info, core, "Shadow Paging User access error (shadow_pde_access=0x%x, guest_pde_access=0x%x)\n", shadow_pde_access, guest_pde_access); if (v3_inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } return 0; @@ -130,11 +130,11 @@ static inline int handle_shadow_pagefault_32(struct guest_info * core, addr_t fa (shadow_pde_access != PT_ACCESS_OK)) { // inject page fault in guest if (v3_inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } - PrintDebug("Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pde_access); - PrintDebug("Manual Says to inject page fault into guest\n"); + PrintDebug(core->vm_info, core, "Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pde_access); + PrintDebug(core->vm_info, core, "Manual Says to inject page fault into guest\n"); return 0; } @@ -191,10 +191,10 @@ static inline int handle_shadow_pagefault_32(struct guest_info * core, addr_t fa uint32_t page_size = v3_get_max_page_size(core, gpa_4MB, PROTECTED); if (page_size == PAGE_SIZE_4MB) { - PrintDebug("using large page for fault_addr %p (gpa=%p)\n", (void *)fault_addr, (void *)gpa_4MB); + PrintDebug(core->vm_info, core, "using large page for fault_addr %p (gpa=%p)\n", (void *)fault_addr, (void *)gpa_4MB); if (handle_4MB_shadow_pagefault_pde_32(core, fault_addr, error_code, shadow_pde_access, (pde32_4MB_t *)shadow_pde, (pde32_4MB_t *)guest_pde) == -1) { - PrintError("Error handling large pagefault with large page\n"); + PrintError(core->vm_info, core, "Error handling large pagefault with large page\n"); return -1; } @@ -246,18 +246,18 @@ static inline int handle_shadow_pagefault_32(struct guest_info * core, addr_t fa if (guest_pde->large_page == 0) { if (v3_gpa_to_hva(core, BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr), (addr_t*)&guest_pt) == -1) { // Machine check the guest - PrintDebug("Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); + PrintDebug(core->vm_info, core, "Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); v3_raise_exception(core, MC_EXCEPTION); return 0; } if (handle_pte_shadow_pagefault_32(core, fault_addr, error_code, shadow_pt, guest_pt, shdw_page) == -1) { - PrintError("Error handling Page fault caused by PTE\n"); + PrintError(core->vm_info, core, "Error handling Page fault caused by PTE\n"); return -1; } } else { if (handle_4MB_shadow_pagefault_pte_32(core, fault_addr, error_code, shadow_pt, (pde32_4MB_t *)guest_pde, shdw_page) == -1) { - PrintError("Error handling large pagefault\n"); + PrintError(core->vm_info, core, "Error handling large pagefault\n"); return -1; } } @@ -281,7 +281,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintDebug("Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); + PrintDebug(core->vm_info, core, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); v3_raise_exception(core, MC_EXCEPTION); return 0; } @@ -296,13 +296,13 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pte_access, shadow_pte_access) == 1) { - PrintDebug("Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", + PrintDebug(core->vm_info, core, "Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", guest_pte_access, *(uint_t*)&error_code); // inject: if (v3_inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } @@ -314,26 +314,26 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault if (shadow_pte_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush page tables and everything should now work - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(core->vm_info, core, "Inconsistent state... Guest re-entry should flush tlb\n"); return 0; } if (shadow_pte_access == PT_ACCESS_NOT_PRESENT) { // Page Table Entry Not Present - PrintDebug("guest_pa =%p\n", (void *)guest_pa); + PrintDebug(core->vm_info, core, "guest_pa =%p\n", (void *)guest_pa); if ((shdw_reg->flags.alloced == 1) && (shdw_reg->flags.read == 1)) { addr_t shadow_pa = 0; if (v3_gpa_to_hpa(core, guest_pa, &shadow_pa) == -1) { - PrintError("could not translate page fault address (%p)\n", (void *)guest_pa); + PrintError(core->vm_info, core, "could not translate page fault address (%p)\n", (void *)guest_pa); return -1; } shadow_pte->page_base_addr = PAGE_BASE_ADDR(shadow_pa); - PrintDebug("\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); + PrintDebug(core->vm_info, core, "\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); shadow_pte->present = guest_pte->present; shadow_pte->user_page = guest_pte->user_page; @@ -377,7 +377,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault } if (pt_page != NULL) { - PrintError("Found PT page (small), marking RD-ONLY (va=%p), (gpa=%p)\n", + PrintError(core->vm_info, core, "Found PT page (small), marking RD-ONLY (va=%p), (gpa=%p)\n", (void *)fault_addr, (void *)pg_gpa); // This is a page table page... shadow_pte->writable = 0; @@ -389,7 +389,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault // Page fault on unhandled memory region if (shdw_reg->unhandled(core, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -400,16 +400,16 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault if (shadow_pte->vmm_info == V3_CACHED_PG) { addr_t pg_gpa = PAGE_ADDR_4KB(guest_pa); - PrintError("Evicting on a small page\n"); + PrintError(core->vm_info, core, "Evicting on a small page\n"); if (evict_shdw_pg(core->vm_info, pg_gpa, PAGE_PD32) == -1) { - PrintError("Error Evicting PAGE_PD32 cache entry\n"); + PrintError(core->vm_info, core, "Error Evicting PAGE_PD32 cache entry\n"); return -1; } if (evict_shdw_pg(core->vm_info, pg_gpa, PAGE_PT32) == -1) { - PrintError("Error Evicting PAGE_PT32 cache entry\n"); + PrintError(core->vm_info, core, "Error Evicting PAGE_PT32 cache entry\n"); return -1; } @@ -418,11 +418,11 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault if (shdw_reg->flags.write == 1) { - PrintDebug("Shadow PTE Write Error\n"); + PrintDebug(core->vm_info, core, "Shadow PTE Write Error\n"); shadow_pte->writable = guest_pte->writable; } else { if (shdw_reg->unhandled(core, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -433,12 +433,12 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault } else { // Inject page fault into the guest if (v3_inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } - PrintError("PTE Page fault fell through... Not sure if this should ever happen\n"); - PrintError("Manual Says to inject page fault into guest\n"); + PrintError(core->vm_info, core, "PTE Page fault fell through... Not sure if this should ever happen\n"); + PrintError(core->vm_info, core, "Manual Says to inject page fault into guest\n"); return -1; } @@ -456,15 +456,15 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * core, addr_t guest_fault_pa = BASE_TO_PAGE_ADDR_4MB(large_guest_pde->page_base_addr) + PAGE_OFFSET_4MB(fault_addr); - PrintDebug("Handling 4MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); - PrintDebug("ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); + PrintDebug(core->vm_info, core, "Handling 4MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); + PrintDebug(core->vm_info, core, "ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); struct v3_mem_region * shdw_reg = v3_get_mem_region(core->vm_info, core->vcpu_id, guest_fault_pa); if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintDebug("Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); + PrintDebug(core->vm_info, core, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); v3_raise_exception(core, MC_EXCEPTION); return -1; } @@ -472,7 +472,7 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * core, if (shadow_pte_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush tables and everything should now workd - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(core->vm_info, core, "Inconsistent state... Guest re-entry should flush tlb\n"); return 0; } @@ -486,13 +486,13 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * core, if (v3_gpa_to_hpa(core, guest_fault_pa, &shadow_pa) == -1) { - PrintError("could not translate page fault address (%p)\n", (void *)guest_fault_pa); + PrintError(core->vm_info, core, "could not translate page fault address (%p)\n", (void *)guest_fault_pa); return -1; } shadow_pte->page_base_addr = PAGE_BASE_ADDR(shadow_pa); - PrintDebug("\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); + PrintDebug(core->vm_info, core, "\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); shadow_pte->present = 1; @@ -534,7 +534,7 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * core, if (pt_page != NULL) { // This is a page table page... - PrintError("Found PT page (large), marking RD-ONLY (va=%p), (gpa=%p)\n", + PrintError(core->vm_info, core, "Found PT page (large), marking RD-ONLY (va=%p), (gpa=%p)\n", (void *)fault_addr, (void *)pg_gpa); shadow_pte->writable = 0; @@ -545,7 +545,7 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * core, } else { if (shdw_reg->unhandled(core, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -554,15 +554,15 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * core, // check for cache tag and handle invalidations if it exists. if (shadow_pte->vmm_info == V3_CACHED_PG) { addr_t pg_gpa = PAGE_ADDR_4KB(guest_fault_pa); - PrintError("Evicting on a large page\n"); + PrintError(core->vm_info, core, "Evicting on a large page\n"); if (evict_shdw_pg(core->vm_info, pg_gpa, PAGE_PD32) == -1) { - PrintError("Error Evicting PAGE_PD32 cache entry\n"); + PrintError(core->vm_info, core, "Error Evicting PAGE_PD32 cache entry\n"); return -1; } if (evict_shdw_pg(core->vm_info, pg_gpa, PAGE_PT32) == -1) { - PrintError("Error Evicting PAGE_PT32 cache entry\n"); + PrintError(core->vm_info, core, "Error Evicting PAGE_PT32 cache entry\n"); return -1; } @@ -572,7 +572,7 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * core, if (shdw_reg->flags.write == 0) { if (shdw_reg->unhandled(core, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } else { @@ -581,12 +581,12 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * core, } } else { - PrintError("Error in large page fault handler...\n"); - PrintError("This case should have been handled at the top level handler\n"); + PrintError(core->vm_info, core, "Error in large page fault handler...\n"); + PrintError(core->vm_info, core, "This case should have been handled at the top level handler\n"); return -1; } - PrintDebug("Returning from large page->small page fault handler\n"); + PrintDebug(core->vm_info, core, "Returning from large page->small page fault handler\n"); return 0; } @@ -601,7 +601,7 @@ static inline int handle_shadow_invlpg_32(struct guest_info * core, addr_t vaddr pde32_t * guest_pde; if (v3_gpa_to_hva(core, guest_cr3, (addr_t*)&guest_pd) == -1) { - PrintError("Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); + PrintError(core->vm_info, core, "Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); return -1; } @@ -612,20 +612,20 @@ static inline int handle_shadow_invlpg_32(struct guest_info * core, addr_t vaddr if (guest_pde->large_page == 1) { shadow_pde->present = 0; - PrintError("\tInvalidating Large Page (gpa=%p)\n", (void *)BASE_TO_PAGE_ADDR_4MB(guest_pde->pt_base_addr)); + PrintError(core->vm_info, core, "\tInvalidating Large Page (gpa=%p)\n", (void *)BASE_TO_PAGE_ADDR_4MB(guest_pde->pt_base_addr)); } else if (shadow_pde->present == 1) { pte32_t * shadow_pt = (pte32_t *)(addr_t)BASE_TO_PAGE_ADDR_4KB(shadow_pde->pt_base_addr); pte32_t * shadow_pte = (pte32_t *) V3_VAddr( (void*) &shadow_pt[PTE32_INDEX(vaddr)] ); - // PrintError("\tInvalidating small page\n"); + // PrintError(core->vm_info, core, "\tInvalidating small page\n"); shadow_pte->present = 0; } else { - PrintError("What the fuck?\n"); + PrintError(core->vm_info, core, "What the fuck?\n"); } return 0; } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_kvm.c b/palacios/src/palacios/mmu/vmm_shdw_pg_kvm.c index 72e63af..074e2ab 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_kvm.c +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_kvm.c @@ -39,7 +39,7 @@ static void *shadow_cache_alloc(struct shadow_cache *mc, size_t size) { void *p; if (!mc->nobjs) { - PrintDebug("at shadow_cache_alloc mc->nobjs non-exist\n"); + PrintDebug(info->vm_info, info, "at shadow_cache_alloc mc->nobjs non-exist\n"); } p = mc->objects[--mc->nobjs]; @@ -74,7 +74,7 @@ int shadow_topup_cache(struct shadow_cache * cache, size_t objsize, int min) { while (cache->nobjs < ARRAY_SIZE(cache->objects)) { obj = V3_Malloc(objsize); if (!obj) { - PrintDebug("at shadow_topup_cache obj alloc fail\n"); + PrintDebug(info->vm_info, info, "at shadow_topup_cache obj alloc fail\n"); return -1; } cache->objects[cache->nobjs++] = obj; @@ -106,9 +106,9 @@ static struct pde_chain *shadow_alloc_pde_chain(struct guest_info *core) static void shadow_free_pde_chain(struct guest_info *core, struct pde_chain *pc) { - PrintDebug("shdw_free_pdechain: start\n"); + PrintDebug(info->vm_info, info, "shdw_free_pdechain: start\n"); shadow_cache_free(&core->shadow_pde_chain_cache, pc); - PrintDebug("shdw_free_pdechain: return\n"); + PrintDebug(info->vm_info, info, "shdw_free_pdechain: return\n"); } @@ -120,7 +120,7 @@ static void shadow_free_page (struct guest_info * core, struct shadow_page_cache page->page_pa=(addr_t)V3_AllocPages(1); if (!page->page_pa) { - PrintError("Freeing shadow page failed on allocation\n"); + PrintError(info->vm_info, info, "Freeing shadow page failed on allocation\n"); return; } @@ -143,7 +143,7 @@ static struct shadow_page_cache_data * shadow_alloc_page(struct guest_info * cor page->shadow_pde = shadow_pde; --core->n_free_shadow_pages; - PrintDebug("alloc_page: n_free_shdw_pg %d page_pa %p page_va %p\n", + PrintDebug(info->vm_info, info, "alloc_page: n_free_shdw_pg %d page_pa %p page_va %p\n", core->n_free_shadow_pages,(void *)(page->page_pa),V3_VAddr((void *)(page->page_pa))); addr_t shdw_page = (addr_t)V3_VAddr((void *)(page->page_pa)); @@ -183,7 +183,7 @@ static int alloc_shadow_pages(struct guest_info * core) INIT_LIST_HEAD(&page_header->link); if (!(page_header->page_pa = (addr_t)V3_AllocPages(1))) { - PrintError("Allocation failed in allocating shadow page\n"); + PrintError(info->vm_info, info, "Allocation failed in allocating shadow page\n"); goto error_1; } addr_t shdw_page = (addr_t)V3_VAddr((void *)(page_header->page_pa)); @@ -191,7 +191,7 @@ static int alloc_shadow_pages(struct guest_info * core) list_add(&page_header->link, &core->free_pages); ++core->n_free_shadow_pages; - PrintDebug("alloc_shdw_pg: n_free_shdw_pg %d page_pa %p\n", + PrintDebug(info->vm_info, info, "alloc_shdw_pg: n_free_shdw_pg %d page_pa %p\n", core->n_free_shadow_pages,(void*)page_header->page_pa); } return 0; @@ -253,24 +253,24 @@ static void shadow_page_remove_shadow_pde(struct guest_info * core, struct hlist_node * node; int i; - PrintDebug("rm_shdw_pde: multimap %d\n", page->multimapped); + PrintDebug(info->vm_info, info, "rm_shdw_pde: multimap %d\n", page->multimapped); if(!page->multimapped) { - PrintDebug("rm_shdw_pde: no multimap\n"); + PrintDebug(info->vm_info, info, "rm_shdw_pde: no multimap\n"); if(page->shadow_pde != shadow_pde) - PrintDebug("rm_shdw_pde: error page->shadow_pde is not equal to shadow_pde\n"); + PrintDebug(info->vm_info, info, "rm_shdw_pde: error page->shadow_pde is not equal to shadow_pde\n"); page->shadow_pde = 0; - PrintDebug("rm_shdw_pde: return\n"); + PrintDebug(info->vm_info, info, "rm_shdw_pde: return\n"); return; } - PrintDebug("rm_shdw_pde: multimap\n"); + PrintDebug(info->vm_info, info, "rm_shdw_pde: multimap\n"); hlist_for_each_entry (pde_chain, node, &page->shadow_pdes, link) for (i=0; i < NR_PTE_CHAIN_ENTRIES; ++i) { if(!pde_chain->shadow_pdes[i]) break; if(pde_chain->shadow_pdes[i] != shadow_pde) continue; - PrintDebug("rm_shdw_pde: found shadow_pde at i %d\n",i); + PrintDebug(info->vm_info, info, "rm_shdw_pde: found shadow_pde at i %d\n",i); while (i+1 < NR_PTE_CHAIN_ENTRIES && pde_chain->shadow_pdes[i+1]) { pde_chain->shadow_pdes[i] = pde_chain->shadow_pdes[i+1]; ++i; @@ -278,7 +278,7 @@ static void shadow_page_remove_shadow_pde(struct guest_info * core, pde_chain->shadow_pdes[i] = 0; if(i==0) { - PrintDebug("rm_shdw_pde: only one!\n"); + PrintDebug(info->vm_info, info, "rm_shdw_pde: only one!\n"); hlist_del(&pde_chain->link); shadow_free_pde_chain(core, pde_chain); if(hlist_empty(&page->shadow_pdes)) { @@ -287,10 +287,10 @@ static void shadow_page_remove_shadow_pde(struct guest_info * core, } } - PrintDebug("rm_shdw_pde: return\n"); + PrintDebug(info->vm_info, info, "rm_shdw_pde: return\n"); return; } - PrintDebug("rm_shdw_pde: return\n"); + PrintDebug(info->vm_info, info, "rm_shdw_pde: return\n"); } static void shadow_page_search_shadow_pde (struct guest_info* core, addr_t shadow_pde, @@ -305,16 +305,16 @@ static void shadow_page_search_shadow_pde (struct guest_info* core, addr_t shado addr_t pt_base_addr = 0; int metaphysical = 0; - PrintDebug("shadow_page_search_shadow_pde\n"); + PrintDebug(info->vm_info, info, "shadow_page_search_shadow_pde\n"); v3_cpu_mode_t mode = v3_get_vm_cpu_mode(core); if (mode == PROTECTED) { - PrintDebug("shadow_page_search_shadow_pde: PROTECTED\n"); + PrintDebug(info->vm_info, info, "shadow_page_search_shadow_pde: PROTECTED\n"); pt_base_addr = ((pde32_t*)guest_pde)->pt_base_addr; if(((pde32_t*)guest_pde)->large_page == 1) { - PrintDebug("shadow_page_search_shadow_pde: large page\n"); + PrintDebug(info->vm_info, info, "shadow_page_search_shadow_pde: large page\n"); hugepage_access = (((pde32_4MB_t *) guest_pde)->writable) | (((pde32_4MB_t*)guest_pde)->user_page << 1); metaphysical = 1; pt_base_addr = (addr_t) PAGE_BASE_ADDR(BASE_TO_PAGE_ADDR_4MB(((pde32_4MB_t*)guest_pde)->page_base_addr)); @@ -328,7 +328,7 @@ static void shadow_page_search_shadow_pde (struct guest_info* core, addr_t shado } else if (mode == LONG_32_COMPAT || mode == LONG) { - PrintDebug("shadow_page_search_shadow_pde: LONG_32_COMPAT/LONG\n"); + PrintDebug(info->vm_info, info, "shadow_page_search_shadow_pde: LONG_32_COMPAT/LONG\n"); pt_base_addr = ((pde64_t*)guest_pde)->pt_base_addr; @@ -370,7 +370,7 @@ static void shadow_page_search_shadow_pde (struct guest_info* core, addr_t shado hlist_for_each_entry(shdw_page, node, bucket, hash_link) if (shdw_page->guest_fn == pt_base_addr && shdw_page->role.word == role.word ) { - PrintDebug("shadow_page_search_shadow_pde: found\n"); + PrintDebug(info->vm_info, info, "shadow_page_search_shadow_pde: found\n"); shadow_page_remove_shadow_pde(core, shdw_page, (addr_t)shadow_pde); } @@ -385,15 +385,15 @@ static struct shadow_page_cache_data * shadow_page_lookup_page(struct guest_info struct shadow_page_cache_data * page; struct hlist_node * node; - PrintDebug("lookup: guest_fn addr %p\n",(void *)BASE_TO_PAGE_ADDR(guest_fn)); + PrintDebug(info->vm_info, info, "lookup: guest_fn addr %p\n",(void *)BASE_TO_PAGE_ADDR(guest_fn)); index = shadow_page_table_hashfn(guest_fn) % NUM_SHADOW_PAGES; bucket = &core->shadow_page_hash[index]; - PrintDebug("lookup: index %d bucket %p\n",index,(void*)bucket); + PrintDebug(info->vm_info, info, "lookup: index %d bucket %p\n",index,(void*)bucket); hlist_for_each_entry(page, node, bucket, hash_link) if (opt == 0) { - PrintDebug("lookup: page->gfn %p gfn %p metaphysical %d\n", + PrintDebug(info->vm_info, info, "lookup: page->gfn %p gfn %p metaphysical %d\n", (void*)BASE_TO_PAGE_ADDR(page->guest_fn),(void*)BASE_TO_PAGE_ADDR(guest_fn),page->role.metaphysical); if (page->guest_fn == guest_fn && !page->role.metaphysical) { return page; @@ -439,13 +439,13 @@ struct shadow_page_cache_data * shadow_page_get_page(struct guest_info *core, index = shadow_page_table_hashfn(guest_fn) % NUM_SHADOW_PAGES; bucket = &core->shadow_page_hash[index]; - if (force != 2) PrintDebug("get_page: lvl %d idx %d gfn %p role %x\n", level, index, (void *)guest_fn,role.word); + if (force != 2) PrintDebug(info->vm_info, info, "get_page: lvl %d idx %d gfn %p role %x\n", level, index, (void *)guest_fn,role.word); hlist_for_each_entry(page, node, bucket, hash_link) if (page->guest_fn == guest_fn && page->role.word == role.word) { shadow_page_add_shadow_pde(core, page, shadow_pde); //guest_fn is right there if(force != 2) - PrintDebug("get_page: found guest_fn %p, index %d, multi %d, next %p\n", + PrintDebug(info->vm_info, info, "get_page: found guest_fn %p, index %d, multi %d, next %p\n", (void *)page->guest_fn, index, page->multimapped, (void *)page->hash_link.next); if (force == 0 || force == 2) return page; @@ -455,12 +455,12 @@ struct shadow_page_cache_data * shadow_page_get_page(struct guest_info *core, } } else { if(force != 2) - PrintDebug("get_page: no found guest_fn %p, index %d, multimapped %d, next %p\n", + PrintDebug(info->vm_info, info, "get_page: no found guest_fn %p, index %d, multimapped %d, next %p\n", (void *)page->guest_fn, index, page->multimapped, (void *)page->hash_link.next); } if (force != 2) - PrintDebug("get_page: no found\n"); + PrintDebug(info->vm_info, info, "get_page: no found\n"); new_alloc: @@ -474,17 +474,17 @@ new_alloc: page->shadow_pde = 0; if (force != 2) - PrintDebug("get_page: hadd h->first %p, n %p, n->next %p\n", + PrintDebug(info->vm_info, info, "get_page: hadd h->first %p, n %p, n->next %p\n", (void *)bucket->first, (void *)&page->hash_link, (void *)page->hash_link.next); hlist_add_head(&page->hash_link, bucket); shadow_page_add_shadow_pde(core, page, shadow_pde); - if (force != 2) PrintDebug("get_page: hadd h->first %p, n %p, n->next %p\n", + if (force != 2) PrintDebug(info->vm_info, info, "get_page: hadd h->first %p, n %p, n->next %p\n", (void *)bucket->first, (void *)&page->hash_link, (void *)page->hash_link.next); if (!metaphysical) rmap_write_protect(core, guest_fn); //in case rmapped guest_fn being allocated as pt or pd - if (force != 2) PrintDebug("get_page: return\n"); + if (force != 2) PrintDebug(info->vm_info, info, "get_page: return\n"); return page; @@ -510,45 +510,45 @@ static void shadow_page_unlink_children (struct guest_info * core, struct shadow if (mode == PROTECTED) { shdw32_table = (uint32_t*) V3_VAddr((void *)(addr_t)CR3_TO_PDE32_PA(page->page_pa)); - PrintDebug("ulink_chil: pte lvl\n"); + PrintDebug(info->vm_info, info, "ulink_chil: pte lvl\n"); for (i = 0; i < PT32_ENT_PER_PAGE; ++i) { shdw32_entry = (uint32_t*)&(shdw32_table[i]); if (*shdw32_entry & PT_PRESENT_MASK) { rmap_remove(core, (addr_t)shdw32_entry); - PrintDebug("ulink_chil: %d pte: shadow %x\n", i, *shdw32_entry); + PrintDebug(info->vm_info, info, "ulink_chil: %d pte: shadow %x\n", i, *shdw32_entry); } memset((void *)shdw32_entry, 0, sizeof(uint32_t)); } - PrintDebug("ulink_chil: return pte\n"); + PrintDebug(info->vm_info, info, "ulink_chil: return pte\n"); return; } else if (mode == LONG_32_COMPAT || mode == LONG) { shdw64_table = (uint64_t*) V3_VAddr((void *)(addr_t)CR3_TO_PML4E64_PA(page->page_pa)); - PrintDebug("ulink_chil: pte lvl\n"); + PrintDebug(info->vm_info, info, "ulink_chil: pte lvl\n"); for (i = 0; i < PT_ENT_PER_PAGE; ++i) { shdw64_entry = (uint64_t*)&(shdw64_table[i]); if (*shdw64_entry & PT_PRESENT_MASK) { rmap_remove(core, (addr_t)shdw64_entry); - PrintDebug("ulink_chil: %d pte: shadow %p\n", i, (void*)*((uint64_t*)shdw64_entry)); + PrintDebug(info->vm_info, info, "ulink_chil: %d pte: shadow %p\n", i, (void*)*((uint64_t*)shdw64_entry)); } memset((void *)shdw64_entry, 0, sizeof(uint64_t)); } - PrintDebug("ulink_chil: return pte\n"); + PrintDebug(info->vm_info, info, "ulink_chil: return pte\n"); return; } } - PrintDebug("ulink_chil: pde lvl\n"); + PrintDebug(info->vm_info, info, "ulink_chil: pde lvl\n"); if (mode == PROTECTED) { shdw32_table = (uint32_t*) V3_VAddr((void*)(addr_t)CR3_TO_PDE32_PA(page->page_pa)); if (guest_pa_to_host_va(core, BASE_TO_PAGE_ADDR(page->guest_fn), (addr_t*)&guest32_table) == -1) { - PrintError("Invalid Guest PDE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(page->guest_fn)); + PrintError(info->vm_info, info, "Invalid Guest PDE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(page->guest_fn)); return; } @@ -557,13 +557,13 @@ static void shadow_page_unlink_children (struct guest_info * core, struct shadow shdw32_entry = (uint32_t*)&(shdw32_table[i]); guest32_entry = (uint32_t*)&(guest32_table[i]); present = *shdw32_entry & PT_PRESENT_MASK; - if(present) PrintDebug("ulink_chil: pde %dth: shadow %x\n", i, *((uint32_t*)shdw32_entry)); + if(present) PrintDebug(info->vm_info, info, "ulink_chil: pde %dth: shadow %x\n", i, *((uint32_t*)shdw32_entry)); memset((void *)shdw32_entry, 0, sizeof(uint32_t)); if (present != 1) continue; shadow_page_search_shadow_pde(core, (addr_t)shdw32_entry, (addr_t)guest32_entry, page->role.hlevels); } - PrintDebug("ulink_child: before return at pde lvel\n"); + PrintDebug(info->vm_info, info, "ulink_child: before return at pde lvel\n"); return; }else if(mode == LONG_32_COMPAT || mode == LONG) { @@ -572,11 +572,11 @@ static void shadow_page_unlink_children (struct guest_info * core, struct shadow if (guest_pa_to_host_va(core, BASE_TO_PAGE_ADDR(page->guest_fn), (addr_t*)&guest64_table) == -1) { if(page->role.hlevels == PT_DIRECTORY_LEVEL) - PrintError("Invalid Guest PDE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(page->guest_fn)); + PrintError(info->vm_info, info, "Invalid Guest PDE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(page->guest_fn)); if(page->role.hlevels == PT32E_ROOT_LEVEL) - PrintError("Invalid Guest PDPE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(page->guest_fn)); + PrintError(info->vm_info, info, "Invalid Guest PDPE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(page->guest_fn)); if(page->role.hlevels == PT64_ROOT_LEVEL) - PrintError("Invalid Guest PML4E Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(page->guest_fn)); + PrintError(info->vm_info, info, "Invalid Guest PML4E Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(page->guest_fn)); return; } @@ -585,7 +585,7 @@ static void shadow_page_unlink_children (struct guest_info * core, struct shadow shdw64_entry = (uint64_t*)&(shdw64_table[i]); guest64_entry = (uint64_t*)&(guest64_table[i]); present = *shdw64_entry & PT_PRESENT_MASK; - if(present) PrintDebug("ulink_chil: pde: shadow %p\n",(void *)*((uint64_t *)shdw64_entry)); + if(present) PrintDebug(info->vm_info, info, "ulink_chil: pde: shadow %p\n",(void *)*((uint64_t *)shdw64_entry)); memset((void *)shdw64_entry, 0, sizeof(uint64_t)); if (present != 1) continue; @@ -594,16 +594,16 @@ static void shadow_page_unlink_children (struct guest_info * core, struct shadow return; } - //PrintDebug("ulink_chil: return pde\n"); + //PrintDebug(info->vm_info, info, "ulink_chil: return pde\n"); } static void shadow_page_put_page(struct guest_info *core, struct shadow_page_cache_data * page, addr_t shadow_pde) { - PrintDebug("put_page: start\n"); + PrintDebug(info->vm_info, info, "put_page: start\n"); shadow_page_remove_shadow_pde(core, page, shadow_pde); - PrintDebug("put_page: end\n"); + PrintDebug(info->vm_info, info, "put_page: end\n"); } @@ -613,7 +613,7 @@ static void shadow_zap_page(struct guest_info * core, struct shadow_page_cache_d addr_t cr3_base_addr = 0; v3_cpu_mode_t mode = v3_get_vm_cpu_mode(core); - PrintDebug("zap: multimapped %d, metaphysical %d\n", page->multimapped, page->role.metaphysical); + PrintDebug(info->vm_info, info, "zap: multimapped %d, metaphysical %d\n", page->multimapped, page->role.metaphysical); while (page->multimapped || page->shadow_pde) { if (!page->multimapped) { @@ -624,13 +624,13 @@ static void shadow_zap_page(struct guest_info * core, struct shadow_page_cache_d shadow_pde = chain->shadow_pdes[0]; } shadow_page_put_page(core, page, shadow_pde); - PrintDebug("zap_parent: pde: shadow %p\n",(void *)*((addr_t *)shadow_pde)); + PrintDebug(info->vm_info, info, "zap_parent: pde: shadow %p\n",(void *)*((addr_t *)shadow_pde)); memset((void *)shadow_pde, 0, sizeof(uint32_t)); } shadow_page_unlink_children(core, page); - PrintDebug("zap: end of unlink\n"); + PrintDebug(info->vm_info, info, "zap: end of unlink\n"); if (mode == PROTECTED) { cr3_base_addr = ((struct cr3_32 *)&(core->shdw_pg_state.guest_cr3))->pdt_base_addr; @@ -639,23 +639,23 @@ static void shadow_zap_page(struct guest_info * core, struct shadow_page_cache_d } else return; - PrintDebug("zap: before hlist_del\n"); - PrintDebug("zap: page->guest_fn %p\n", (void*) page->guest_fn); + PrintDebug(info->vm_info, info, "zap: before hlist_del\n"); + PrintDebug(info->vm_info, info, "zap: page->guest_fn %p\n", (void*) page->guest_fn); if (page->guest_fn != (addr_t)(cr3_base_addr)) { - PrintDebug("zap: first hlist_del\n"); + PrintDebug(info->vm_info, info, "zap: first hlist_del\n"); hlist_del(&page->hash_link); shadow_free_page(core, page); } else { - PrintDebug("zap: second hlist_del\n"); + PrintDebug(info->vm_info, info, "zap: second hlist_del\n"); list_del(&page->link); list_add(&page->link,&core->active_shadow_pages); } - PrintDebug("zap: end hlist_del\n"); + PrintDebug(info->vm_info, info, "zap: end hlist_del\n"); return; } @@ -671,7 +671,7 @@ int shadow_zap_hierarchy_32(struct guest_info * core, struct shadow_page_cache_d shadow_pd = CR3_TO_PDE32_VA(page->page_pa); if (guest_pa_to_host_va(core, BASE_TO_PAGE_ADDR(page->guest_fn), (addr_t*)&guest_pd) == -1) { - PrintError("Invalid Guest PDE Address: 0x%p\n", (void*)BASE_TO_PAGE_ADDR(page->guest_fn)); + PrintError(info->vm_info, info, "Invalid Guest PDE Address: 0x%p\n", (void*)BASE_TO_PAGE_ADDR(page->guest_fn)); return -1; } @@ -680,7 +680,7 @@ int shadow_zap_hierarchy_32(struct guest_info * core, struct shadow_page_cache_d shadow_pde = (pde32_t*)&(shadow_pd[i]); guest_pde = (pde32_t*)&(guest_pd[i]); present = shadow_pde->present; - if (shadow_pde->present) PrintDebug("ulink_child: pde shadow %x\n", *((uint32_t*)shadow_pde)); + if (shadow_pde->present) PrintDebug(info->vm_info, info, "ulink_child: pde shadow %x\n", *((uint32_t*)shadow_pde)); memset((void*)shadow_pde, 0, sizeof(uint32_t)); if (present != 1) continue; @@ -735,18 +735,18 @@ int shadow_unprotect_page(struct guest_info * core, addr_t guest_fn) { r = 0; index = shadow_page_table_hashfn(guest_fn) % NUM_SHADOW_PAGES; bucket = &core->shadow_page_hash[index]; - PrintDebug("unprotect: gfn %p\n",(void *) guest_fn); + PrintDebug(info->vm_info, info, "unprotect: gfn %p\n",(void *) guest_fn); hlist_for_each_entry_safe(page, node, n, bucket, hash_link) { //hlist_for_each_entry(page, node, bucket, hash_link) { if ((page->guest_fn == guest_fn) && !(page->role.metaphysical)) { - PrintDebug("unprotect: match page.gfn %p page.role %x gfn %p\n",(void *) page->guest_fn,page->role.word,(void *)guest_fn); + PrintDebug(info->vm_info, info, "unprotect: match page.gfn %p page.role %x gfn %p\n",(void *) page->guest_fn,page->role.word,(void *)guest_fn); shadow_zap_page(core, page); r = 1; } } - PrintDebug("at shadow_unprotect_page return %d\n",r); + PrintDebug(info->vm_info, info, "at shadow_unprotect_page return %d\n",r); return r; } @@ -769,45 +769,45 @@ void rmap_add(struct guest_info *core, addr_t shadow_pte) { if (mode == PROTECTED) { page_base_addr = ((pte32_t *)shadow_pte)->page_base_addr; - PrintDebug("at rmap_add shadow_pte: %x\n", (uint32_t)*((uint32_t*)shadow_pte)); + PrintDebug(info->vm_info, info, "at rmap_add shadow_pte: %x\n", (uint32_t)*((uint32_t*)shadow_pte)); } else if (mode == LONG_32_COMPAT || mode == LONG) { page_base_addr = ((pte64_t *)shadow_pte)->page_base_addr; - PrintDebug("at rmap_add shadow_pte: %p\n", (void*)*((uint64_t*)shadow_pte)); + PrintDebug(info->vm_info, info, "at rmap_add shadow_pte: %p\n", (void*)*((uint64_t*)shadow_pte)); } else return; - PrintDebug("debug rmap: at rmap_add shadow_pte->page_base_addr (%p), shadow_pte_present %d, shadow_pte_writable %d\n", + PrintDebug(info->vm_info, info, "debug rmap: at rmap_add shadow_pte->page_base_addr (%p), shadow_pte_present %d, shadow_pte_writable %d\n", (void *)BASE_TO_PAGE_ADDR(page_base_addr), (shadow_pte_gen->present), (shadow_pte_gen->writable)); if (shadow_pte_gen->present == 0 || shadow_pte_gen->writable == 0) return; - PrintDebug("at rmap_add host_fn %p\n", (void *)BASE_TO_PAGE_ADDR(page_base_addr)); + PrintDebug(info->vm_info, info, "at rmap_add host_fn %p\n", (void *)BASE_TO_PAGE_ADDR(page_base_addr)); mem_map = core->vm_info.mem_map.base_region.mem_map; page_private = mem_map[page_base_addr]; - PrintDebug("at rmap_add page_private %p\n", (void *)page_private); + PrintDebug(info->vm_info, info, "at rmap_add page_private %p\n", (void *)page_private); if (!page_private) { - PrintDebug("at rmap_add initial\n"); + PrintDebug(info->vm_info, info, "at rmap_add initial\n"); mem_map[page_base_addr] = (addr_t)shadow_pte; - PrintDebug("rmap_add: shadow_pte %p\n", (void *)shadow_pte); + PrintDebug(info->vm_info, info, "rmap_add: shadow_pte %p\n", (void *)shadow_pte); } else if (!(page_private & 1)) { - PrintDebug("at rmap_add into multi\n"); + PrintDebug(info->vm_info, info, "at rmap_add into multi\n"); desc = shadow_alloc_rmap(core); desc->shadow_ptes[0] = page_private; desc->shadow_ptes[1] = shadow_pte; mem_map[page_base_addr] = (addr_t)desc | 1; desc->more = NULL; - PrintDebug("rmap_add: desc %p desc|1 %p\n",(void *)desc,(void *)((addr_t)desc |1)); + PrintDebug(info->vm_info, info, "rmap_add: desc %p desc|1 %p\n",(void *)desc,(void *)((addr_t)desc |1)); } else { - PrintDebug("at rmap_add multimap\n"); + PrintDebug(info->vm_info, info, "at rmap_add multimap\n"); desc = (struct rmap *)(page_private & ~1ul); while (desc->more && desc->shadow_ptes[RMAP_EXT-1]) desc = desc->more; @@ -836,19 +836,19 @@ static void rmap_desc_remove_entry(struct guest_info *core, desc->shadow_ptes[j] = 0; if (j != 0) { - PrintDebug("rmap_desc_rm: i %d j %d\n",i,j); + PrintDebug(info->vm_info, info, "rmap_desc_rm: i %d j %d\n",i,j); return; } if (!prev_desc && !desc->more) { - PrintDebug("rmap_desc_rm: no more no less\n"); + PrintDebug(info->vm_info, info, "rmap_desc_rm: no more no less\n"); *page_private = desc->shadow_ptes[0]; } else { //more should be null if (prev_desc) { - PrintDebug("rmap_desc_rm: no more\n"); + PrintDebug(info->vm_info, info, "rmap_desc_rm: no more\n"); prev_desc->more = desc->more; } else { - PrintDebug("rmap_desc_rm: no less\n"); + PrintDebug(info->vm_info, info, "rmap_desc_rm: no less\n"); *page_private = (addr_t) desc->more | 1; } } @@ -867,49 +867,49 @@ static void rmap_remove(struct guest_info * core, addr_t shadow_pte) { v3_cpu_mode_t mode = v3_get_vm_cpu_mode(core); if (mode == PROTECTED) { - PrintDebug("rmap_rm: PROTECTED %d\n", mode); + PrintDebug(info->vm_info, info, "rmap_rm: PROTECTED %d\n", mode); page_base_addr = ((pte32_t *)shadow_pte)->page_base_addr; } else if (mode == LONG_32_COMPAT || mode == LONG) { - PrintDebug("rmap_rm: LONG_32_COMPAT/LONG %d\n", mode); + PrintDebug(info->vm_info, info, "rmap_rm: LONG_32_COMPAT/LONG %d\n", mode); page_base_addr = ((pte64_t *)shadow_pte)->page_base_addr; } else { - PrintDebug("rmap_rm: mode %d\n", mode); + PrintDebug(info->vm_info, info, "rmap_rm: mode %d\n", mode); return; } shadow_pte_gen = (gen_pt_t*)shadow_pte; if (shadow_pte_gen->present == 0 || shadow_pte_gen->writable == 0) { - PrintDebug("rmap_rm: present %d, write %d, pte %p\n", + PrintDebug(info->vm_info, info, "rmap_rm: present %d, write %d, pte %p\n", shadow_pte_gen->present, shadow_pte_gen->writable, (void*)*((addr_t*)shadow_pte)); return; } - PrintDebug("rmap_rm: shadow_pte->page_base_addr (%p)\n", (void *)BASE_TO_PAGE_ADDR(page_base_addr)); + PrintDebug(info->vm_info, info, "rmap_rm: shadow_pte->page_base_addr (%p)\n", (void *)BASE_TO_PAGE_ADDR(page_base_addr)); mem_map = core->vm_info.mem_map.base_region.mem_map; page_private = mem_map[page_base_addr]; - PrintDebug("rmap_rm: page_private %p page_private&1 %p\n",(void *)page_private,(void*)(page_private&1)); + PrintDebug(info->vm_info, info, "rmap_rm: page_private %p page_private&1 %p\n",(void *)page_private,(void*)(page_private&1)); if (!page_private) { - PrintDebug("rmap_rm: single page_prive %p\n",(void *)page_private); + PrintDebug(info->vm_info, info, "rmap_rm: single page_prive %p\n",(void *)page_private); } else if (!(page_private & 1)) { - PrintDebug("rmap_rm: multi page_prive %p\n",(void *)page_private); + PrintDebug(info->vm_info, info, "rmap_rm: multi page_prive %p\n",(void *)page_private); mem_map[page_base_addr] = (addr_t)0; } else { - PrintDebug("rmap_rm: multimap page_prive %p\n",(void *)page_private); + PrintDebug(info->vm_info, info, "rmap_rm: multimap page_prive %p\n",(void *)page_private); desc = (struct rmap *)(page_private & ~1ul); prev_desc = NULL; while (desc) { - PrintDebug("rmap_rm: desc loop\n"); + PrintDebug(info->vm_info, info, "rmap_rm: desc loop\n"); for (i = 0; i < RMAP_EXT && desc->shadow_ptes[i]; ++i) if (desc->shadow_ptes[i] == shadow_pte) { - PrintDebug("rmap_rm: rmap_desc_remove_entry i %d\n",i); + PrintDebug(info->vm_info, info, "rmap_rm: rmap_desc_remove_entry i %d\n",i); rmap_desc_remove_entry(core, &mem_map[page_base_addr], desc, i, prev_desc); return; } @@ -928,46 +928,46 @@ static void rmap_write_protect(struct guest_info * core, addr_t guest_fn) { addr_t page_private; addr_t host_pa; - PrintDebug("rmap_wrprot: gfn %p\n",(void *) guest_fn); + PrintDebug(info->vm_info, info, "rmap_wrprot: gfn %p\n",(void *) guest_fn); if (guest_pa_to_host_pa(core, BASE_TO_PAGE_ADDR(guest_fn), &host_pa)!=0) { - PrintDebug("rmap_wrprot: error \n"); + PrintDebug(info->vm_info, info, "rmap_wrprot: error \n"); } page_private = core->vm_info.mem_map.base_region.mem_map[PAGE_BASE_ADDR(host_pa)]; - PrintDebug("rmap_wrprot: host_fn %p\n",(void *)PAGE_BASE_ADDR(host_pa)); + PrintDebug(info->vm_info, info, "rmap_wrprot: host_fn %p\n",(void *)PAGE_BASE_ADDR(host_pa)); while(page_private) { - PrintDebug("rmap_wrprot: page_private %p\n", (void*)page_private); + PrintDebug(info->vm_info, info, "rmap_wrprot: page_private %p\n", (void*)page_private); if(!(page_private & 1)) { - PrintDebug("rmap_wrprot: reverse desc single\n"); + PrintDebug(info->vm_info, info, "rmap_wrprot: reverse desc single\n"); shadow_pte = page_private; } else { desc = (struct rmap *) (page_private & ~1ul); - PrintDebug("rmap_wrprot: reverse desc multimap\n"); + PrintDebug(info->vm_info, info, "rmap_wrprot: reverse desc multimap\n"); shadow_pte = desc->shadow_ptes[0]; } - PrintDebug("rmap_wrprot: pg_priv %p, host_fn %p, shdw_pte %p\n", + PrintDebug(info->vm_info, info, "rmap_wrprot: pg_priv %p, host_fn %p, shdw_pte %p\n", (void *)page_private, (void *)PAGE_BASE_ADDR(host_pa), (void*)*((uint64_t*)shadow_pte)); //CHECKPOINT rmap_remove(core, shadow_pte); - //PrintDebug("rmap_wrprot: shadow_pte->page_base_addr (%p)\n", + //PrintDebug(info->vm_info, info, "rmap_wrprot: shadow_pte->page_base_addr (%p)\n", // (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); ((gen_pt_t *)shadow_pte)->writable = 0; - PrintDebug("rmap_wrprot: %p\n",(void*)*((uint64_t *)shadow_pte)); + PrintDebug(info->vm_info, info, "rmap_wrprot: %p\n",(void*)*((uint64_t *)shadow_pte)); page_private = core->vm_info.mem_map.base_region.mem_map[PAGE_BASE_ADDR(host_pa)]; - PrintDebug("rmap_wrprot: page_private %p\n",(void*)page_private); + PrintDebug(info->vm_info, info, "rmap_wrprot: page_private %p\n",(void*)page_private); } - PrintDebug("rmap_wrprot: done\n"); + PrintDebug(info->vm_info, info, "rmap_wrprot: done\n"); } @@ -1000,13 +1000,13 @@ void shadow_page_pre_write(struct guest_info * core, addr_t guest_pa, int bytes, core->last_pt_write_count = 1; } - PrintDebug("shdw_pre-write: gpa %p byte %d force %d flood %d last_gfn %p last_cnt %d\n", + PrintDebug(info->vm_info, info, "shdw_pre-write: gpa %p byte %d force %d flood %d last_gfn %p last_cnt %d\n", (void *)guest_pa,bytes,force,flooded,(void*)core->last_pt_write_guest_fn,core->last_pt_write_count); index = shadow_page_table_hashfn(guest_fn) % NUM_SHADOW_PAGES; bucket = &core->shadow_page_hash[index]; - PrintDebug("shdw_pre-write: check point after bucket\n"); + PrintDebug(info->vm_info, info, "shdw_pre-write: check point after bucket\n"); //hlist_for_each_entry_safe(page, node, bucket, hash_link) { hlist_for_each_entry_safe(page, node, n, bucket, hash_link) { @@ -1023,14 +1023,14 @@ void shadow_page_pre_write(struct guest_info * core, addr_t guest_pa, int bytes, * Misaligned accesses are too much trobule to fix up * also they usually indicate a page is not used as a page table */ - PrintDebug("shdw_pre-write: misaligned\n"); + PrintDebug(info->vm_info, info, "shdw_pre-write: misaligned\n"); shadow_zap_page(core, page); continue; } level = page->role.hlevels; - PrintDebug("shdw_pre-write: found out one page at the level of %d\n", level); + PrintDebug(info->vm_info, info, "shdw_pre-write: found out one page at the level of %d\n", level); if (mode == PROTECTED) { shdw32_table = (uint32_t*)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR(PAGE_BASE_ADDR(page->page_pa))); @@ -1038,7 +1038,7 @@ void shadow_page_pre_write(struct guest_info * core, addr_t guest_pa, int bytes, if (*shdw32_entry & PT_PRESENT_MASK) { if (level == PT_PAGE_TABLE_LEVEL) { - PrintDebug("shdw_pre-write: pte idx %d\n", (unsigned int)(offset/sizeof(uint32_t))); + PrintDebug(info->vm_info, info, "shdw_pre-write: pte idx %d\n", (unsigned int)(offset/sizeof(uint32_t))); rmap_remove(core, (addr_t)shdw32_entry); memset((void*)shdw32_entry, 0, sizeof(uint32_t)); @@ -1055,7 +1055,7 @@ void shadow_page_pre_write(struct guest_info * core, addr_t guest_pa, int bytes, if (*shdw64_entry & PT_PRESENT_MASK) { if (level == PT_PAGE_TABLE_LEVEL) { - PrintDebug("shdw_pre-write: pte idx %d\n", (unsigned int)(offset/sizeof(uint64_t))); + PrintDebug(info->vm_info, info, "shdw_pre-write: pte idx %d\n", (unsigned int)(offset/sizeof(uint64_t))); rmap_remove(core, (addr_t)shdw64_entry); memset((void*)shdw64_entry, 0, sizeof(uint64_t)); } else { @@ -1076,7 +1076,7 @@ int shadow_unprotect_page_virt(struct guest_info * core, addr_t guest_va) { addr_t guest_pa; if (guest_va_to_guest_pa(core, guest_va, &guest_pa) != 0) { - PrintError("In GVA->HVA: Invalid GVA(%p)->GPA lookup\n", + PrintError(info->vm_info, info, "In GVA->HVA: Invalid GVA(%p)->GPA lookup\n", (void *)guest_va); return -1; } @@ -1111,7 +1111,7 @@ static struct shadow_page_cache_data * create_new_shadow_pt(struct guest_info * static int vtlb_caching_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { - V3_Print("VTLB Caching initialization\n"); + V3_Print(info->vm_info, info, "VTLB Caching initialization\n"); return 0; } @@ -1121,7 +1121,7 @@ static int vtlb_caching_deinit(struct v3_vm_info * vm) { static int vtlb_caching_local_init(struct guest_info * core) { - V3_Print("VTLB local initialization\n"); + V3_Print(info->vm_info, info, "VTLB local initialization\n"); INIT_LIST_HEAD(&core->active_shadow_pages); INIT_LIST_HEAD(&core->free_pages); @@ -1148,7 +1148,7 @@ static int vtlb_caching_activate_shdw_pt(struct guest_info * core) { case LONG_16_COMPAT: return activate_shadow_pt_64(core); default: - PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(info->vm_info, info, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } @@ -1174,7 +1174,7 @@ static int vtlb_caching_handle_pf(struct guest_info * core, addr_t fault_addr, p return handle_shadow_pagefault_64(core, fault_addr, error_code); break; default: - PrintError("Unhandled CPU Mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(info->vm_info, info, "Unhandled CPU Mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } } @@ -1192,7 +1192,7 @@ static int vtlb_caching_handle_invlpg(struct guest_info * core, addr_t vaddr) { case LONG_16_COMPAT: return handle_shadow_invlpg_64(core, vaddr); default: - PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(info->vm_info, info, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_kvm_32.h b/palacios/src/palacios/mmu/vmm_shdw_pg_kvm_32.h index 7035d16..3586a6f 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_kvm_32.h +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_kvm_32.h @@ -13,12 +13,12 @@ static inline int activate_shadow_pt_32(struct guest_info * core) { } shdw_page = shadow_page_get_page(core, (addr_t)(guest_cr3->pdt_base_addr), 2, 0, 0, 0, 0); - PrintDebug("act shdw pt: gcr3 %p\n",(void *)BASE_TO_PAGE_ADDR(guest_cr3->pdt_base_addr)); + PrintDebug(info->vm_info, info, "act shdw pt: gcr3 %p\n",(void *)BASE_TO_PAGE_ADDR(guest_cr3->pdt_base_addr)); shdw_page->cr3 = shdw_page->page_pa; shadow_cr3->pdt_base_addr = PAGE_BASE_ADDR_4KB(shdw_page->page_pa); - PrintDebug( "Created new shadow page table %p\n", (void *)BASE_TO_PAGE_ADDR(shadow_cr3->pdt_base_addr)); + PrintDebug(info->vm_info, info, "Created new shadow page table %p\n", (void *)BASE_TO_PAGE_ADDR(shadow_cr3->pdt_base_addr)); shadow_cr3->pwt = guest_cr3->pwt; shadow_cr3->pcd = guest_cr3->pcd; @@ -38,7 +38,7 @@ static inline int activate_shadow_pt_32(struct guest_info * core) { */ static inline int fix_read_pf_32(pte32_t * shadow_pte, uint_t vmm_info) { - PrintDebug("\trdipf, start vmm_info %d\n",vmm_info); + PrintDebug(info->vm_info, info, "\trdipf, start vmm_info %d\n",vmm_info); if((vmm_info & PT_USER_MASK) && !(shadow_pte->user_page)) { shadow_pte->user_page = 1; shadow_pte->writable = 0; @@ -55,27 +55,27 @@ static inline int fix_write_pf_32(struct guest_info * core, pte32_t * shadow_pte struct shadow_page_cache_data * page; *write_pt = 0; - PrintDebug("\twripf, start vmm_info %d\n",vmm_info); + PrintDebug(info->vm_info, info, "\twripf, start vmm_info %d\n",vmm_info); if(shadow_pte->writable) { return 0; } - PrintDebug("\twrpf: pass writable\n"); + PrintDebug(info->vm_info, info, "\twrpf: pass writable\n"); writable_shadow = vmm_info & PT_WRITABLE_MASK; - PrintDebug("\twrpf: writable_shadow %d\n",writable_shadow); + PrintDebug(info->vm_info, info, "\twrpf: writable_shadow %d\n",writable_shadow); if(user) { if(!(vmm_info & PT_USER_MASK) || !writable_shadow) { - PrintDebug("\twrpf: 1st usr chk\n"); + PrintDebug(info->vm_info, info, "\twrpf: 1st usr chk\n"); return 0; } } else { if(!writable_shadow) { guest_cr0 = (struct cr0_32 *)&(core->shdw_pg_state.guest_cr0); - PrintDebug("\twrpf: wp %d\n",guest_cr0->wp); + PrintDebug(info->vm_info, info, "\twrpf: wp %d\n",guest_cr0->wp); if (guest_cr0->wp) { return 0; @@ -86,7 +86,7 @@ static inline int fix_write_pf_32(struct guest_info * core, pte32_t * shadow_pte if (guest_pte->present == 0) { memset((void *)shadow_pte, 0, sizeof(uint32_t)); - PrintDebug("\twrpf: guest non present\n"); + PrintDebug(info->vm_info, info, "\twrpf: guest non present\n"); return 0; } @@ -95,13 +95,13 @@ static inline int fix_write_pf_32(struct guest_info * core, pte32_t * shadow_pte shadow_zap_page(core,page); } - PrintDebug("\twrpf: zap\n"); + PrintDebug(info->vm_info, info, "\twrpf: zap\n"); } else if((page = shadow_page_lookup_page(core, guest_fn,0)) != NULL) { if ((page = shadow_page_lookup_page(core, guest_fn,0)) != NULL) { guest_pte->dirty = 1; *write_pt = 1; - PrintDebug("\twrpf: write need\n"); + PrintDebug(info->vm_info, info, "\twrpf: write need\n"); return 0; } } @@ -111,7 +111,7 @@ static inline int fix_write_pf_32(struct guest_info * core, pte32_t * shadow_pte rmap_add(core, (addr_t)shadow_pte); - PrintDebug("\twrpf: on writable\n"); + PrintDebug(info->vm_info, info, "\twrpf: on writable\n"); return 1; } @@ -134,11 +134,11 @@ static inline int handle_shadow_pagefault_32(struct guest_info * core, addr_t fa pde32_t * guest_pde = NULL; pde32_t * shadow_pde = (pde32_t *)&(shadow_pd[PDE32_INDEX(fault_addr)]); - PrintDebug("Shadow page fault handler: %p\n", (void*) fault_addr ); - PrintDebug("Handling PDE32 Fault\n"); + PrintDebug(info->vm_info, info, "Shadow page fault handler: %p\n", (void*) fault_addr ); + PrintDebug(info->vm_info, info, "Handling PDE32 Fault\n"); if (guest_pa_to_host_va(core, guest_cr3, (addr_t*)&guest_pd) == -1) { - PrintError("Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); + PrintError(info->vm_info, info, "Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); return -1; } @@ -153,10 +153,10 @@ static inline int handle_shadow_pagefault_32(struct guest_info * core, addr_t fa /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pde_access, shadow_pde_access) == 1) { - PrintDebug("Injecting PDE pf to guest: (guest access error=%d) (shdw access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Injecting PDE pf to guest: (guest access error=%d) (shdw access error=%d) (pf error code=%d)\n", *(uint_t *)&guest_pde_access, *(uint_t *)&shadow_pde_access, *(uint_t *)&error_code); if (v3_inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } return 0; @@ -168,11 +168,11 @@ static inline int handle_shadow_pagefault_32(struct guest_info * core, addr_t fa // // PDE Entry marked non user // - PrintDebug("Shadow Paging User access error (shadow_pde_access=0x%x, guest_pde_access=0x%x)\n", + PrintDebug(info->vm_info, info, "Shadow Paging User access error (shadow_pde_access=0x%x, guest_pde_access=0x%x)\n", shadow_pde_access, guest_pde_access); if (v3_inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } return 0; @@ -186,11 +186,11 @@ static inline int handle_shadow_pagefault_32(struct guest_info * core, addr_t fa (shadow_pde_access != PT_ACCESS_OK)) { // inject page fault in guest if (v3_inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } - PrintDebug("Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pde_access); - PrintDebug("Manual Says to inject page fault into guest\n"); + PrintDebug(info->vm_info, info, "Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pde_access); + PrintDebug(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return 0; } @@ -245,18 +245,18 @@ static inline int handle_shadow_pagefault_32(struct guest_info * core, addr_t fa if (guest_pde->large_page == 0) { if (guest_pa_to_host_va(core, BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr), (addr_t*)&guest_pt) == -1) { // Machine check the guest - PrintDebug("Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); + PrintDebug(info->vm_info, info, "Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); v3_raise_exception(core, MC_EXCEPTION); return 0; } if (handle_pte_shadow_pagefault_32(core, fault_addr, error_code, shadow_pt, guest_pt) == -1) { - PrintError("Error handling Page fault caused by PTE\n"); + PrintError(info->vm_info, info, "Error handling Page fault caused by PTE\n"); return -1; } } else { if (handle_4MB_shadow_pagefault_32(core, fault_addr, error_code, shadow_pt, (pde32_4MB_t *)guest_pde) == -1) { - PrintError("Error handling large pagefault\n"); + PrintError(info->vm_info, info, "Error handling large pagefault\n"); return -1; } } @@ -278,7 +278,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintDebug("Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); + PrintDebug(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); v3_raise_exception(core, MC_EXCEPTION); return 0; } @@ -293,13 +293,13 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pte_access, shadow_pte_access) == 1) { - PrintDebug("Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", guest_pte_access, *(uint_t*)&error_code); // inject: if (v3_inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } @@ -311,14 +311,14 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault if (shadow_pte_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush page tables and everything should now work - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(info->vm_info, info, "Inconsistent state... Guest re-entry should flush tlb\n"); return 0; } if (shadow_pte_access == PT_ACCESS_NOT_PRESENT) { // Page Table Entry Not Present - PrintDebug("guest_pa =%p\n", (void *)guest_pa); + PrintDebug(info->vm_info, info, "guest_pa =%p\n", (void *)guest_pa); if ((shdw_reg->host_type == SHDW_REGION_ALLOCATED) || (shdw_reg->host_type == SHDW_REGION_WRITE_HOOK)) { @@ -326,7 +326,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault shadow_pte->page_base_addr = PAGE_BASE_ADDR(shadow_pa); - PrintDebug("\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); + PrintDebug(info->vm_info, info, "\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); shadow_pte->present = guest_pte->present; shadow_pte->user_page = guest_pte->user_page; @@ -359,7 +359,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault // Page fault handled by hook functions if (v3_handle_mem_full_hook(core, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -368,11 +368,11 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault if (shdw_reg->host_type == SHDW_REGION_WRITE_HOOK) { if (v3_handle_mem_wr_hook(core, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } else { - PrintDebug("Shadow PTE Write Error\n"); + PrintDebug(info->vm_info, info, "Shadow PTE Write Error\n"); shadow_pte->writable = guest_pte->writable; } @@ -382,12 +382,12 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * core, addr_t fault } else { // Inject page fault into the guest if (v3_inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } - PrintError("PTE Page fault fell through... Not sure if this should ever happen\n"); - PrintError("Manual Says to inject page fault into guest\n"); + PrintError(info->vm_info, info, "PTE Page fault fell through... Not sure if this should ever happen\n"); + PrintError(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return -1; } @@ -405,15 +405,15 @@ static int handle_4MB_shadow_pagefault_32(struct guest_info * core, addr_t guest_fault_pa = BASE_TO_PAGE_ADDR_4MB(large_guest_pde->page_base_addr) + PAGE_OFFSET_4MB(fault_addr); - PrintDebug("Handling 4MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); - PrintDebug("ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); + PrintDebug(info->vm_info, info, "Handling 4MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); + PrintDebug(info->vm_info, info, "ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); struct v3_mem_region * shdw_reg = v3_get_mem_region(core->vm_info, core->vcpu_id, guest_fault_pa); if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintDebug("Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); + PrintDebug(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); v3_raise_exception(core, MC_EXCEPTION); return -1; } @@ -421,7 +421,7 @@ static int handle_4MB_shadow_pagefault_32(struct guest_info * core, if (shadow_pte_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush tables and everything should now workd - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(info->vm_info, info, "Inconsistent state... Guest re-entry should flush tlb\n"); return 0; } @@ -435,7 +435,7 @@ static int handle_4MB_shadow_pagefault_32(struct guest_info * core, shadow_pte->page_base_addr = PAGE_BASE_ADDR(shadow_pa); - PrintDebug("\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); + PrintDebug(info->vm_info, info, "\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); shadow_pte->present = 1; @@ -460,7 +460,7 @@ static int handle_4MB_shadow_pagefault_32(struct guest_info * core, } else { if (v3_handle_mem_full_hook(core, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -469,18 +469,18 @@ static int handle_4MB_shadow_pagefault_32(struct guest_info * core, if (shdw_reg->host_type == SHDW_REGION_WRITE_HOOK) { if (v3_handle_mem_wr_hook(core, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } } else { - PrintError("Error in large page fault handler...\n"); - PrintError("This case should have been handled at the top level handler\n"); + PrintError(info->vm_info, info, "Error in large page fault handler...\n"); + PrintError(info->vm_info, info, "This case should have been handled at the top level handler\n"); return -1; } - PrintDebug("Returning from large page fault handler\n"); + PrintDebug(info->vm_info, info, "Returning from large page fault handler\n"); return 0; } @@ -505,7 +505,7 @@ static inline int handle_shadow_invlpg_32(struct guest_info * core, addr_t vaddr pde32_t * guest_pde; if (guest_pa_to_host_va(core, guest_cr3, (addr_t*)&guest_pd) == -1) { - PrintError("Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); + PrintError(info->vm_info, info, "Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); return -1; } @@ -513,12 +513,12 @@ static inline int handle_shadow_invlpg_32(struct guest_info * core, addr_t vaddr if (guest_pde->large_page == 1) { shadow_pde->present = 0; - PrintDebug("Invalidating Large Page\n"); + PrintDebug(info->vm_info, info, "Invalidating Large Page\n"); } else if (shadow_pde->present == 1) { pte32_t * shadow_pt = (pte32_t *)(addr_t)BASE_TO_PAGE_ADDR_4KB(shadow_pde->pt_base_addr); pte32_t * shadow_pte = (pte32_t *) V3_VAddr( (void*) &shadow_pt[PTE32_INDEX(vaddr)] ); - PrintDebug("Setting not present\n"); + PrintDebug(info->vm_info, info, "Setting not present\n"); shadow_pte->present = 0; } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_kvm_32pae.h b/palacios/src/palacios/mmu/vmm_shdw_pg_kvm_32pae.h index 473414b..8174dc3 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_kvm_32pae.h +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_kvm_32pae.h @@ -3,7 +3,7 @@ #ifdef V3_CONFIG_SHADOW_CACHE static inline int activate_shadow_pt_32pae(struct guest_info * info) { - PrintError("Activating 32 bit PAE page tables not implemented\n"); + PrintError(info->vm_info, info, "Activating 32 bit PAE page tables not implemented\n"); return -1; } @@ -21,13 +21,13 @@ static inline int activate_shadow_pt_32pae(struct guest_info * info) { */ static inline int handle_shadow_pagefault_32pae(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) { - PrintError("32 bit PAE shadow paging not implemented\n"); + PrintError(info->vm_info, info, "32 bit PAE shadow paging not implemented\n"); return -1; } static inline int handle_shadow_invlpg_32pae(struct guest_info * info, addr_t vaddr) { - PrintError("32 bit PAE shadow paging not implemented\n"); + PrintError(info->vm_info, info, "32 bit PAE shadow paging not implemented\n"); return -1; } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_kvm_64.h b/palacios/src/palacios/mmu/vmm_shdw_pg_kvm_64.h index fbf0a31..1faad03 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_kvm_64.h +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_kvm_64.h @@ -15,7 +15,7 @@ static inline int activate_shadow_pt_64(struct guest_info * core) { shadow_free_some_pages(core); } shadow_pt = shadow_page_get_page(core, (addr_t)(guest_cr3->pml4t_base_addr), 4, 0, 0, 0, 0); - PrintDebug("Activate shadow_pt %p\n", (void *)BASE_TO_PAGE_ADDR(guest_cr3->pml4t_base_addr)); + PrintDebug(info->vm_info, info, "Activate shadow_pt %p\n", (void *)BASE_TO_PAGE_ADDR(guest_cr3->pml4t_base_addr)); struct shadow_page_cache_data * shadow_pt = create_new_shadow_pt(core); @@ -24,10 +24,10 @@ static inline int activate_shadow_pt_64(struct guest_info * core) { // Because this is a new CR3 load the allocated page is the new CR3 value shadow_pt->cr3 = shadow_pt->page_pa; - PrintDebug("Top level Shadow page pa=%p\n", (void *)shadow_pt_addr); + PrintDebug(info->vm_info, info, "Top level Shadow page pa=%p\n", (void *)shadow_pt_addr); shadow_cr3->pml4t_base_addr = PAGE_BASE_ADDR_4KB(shadow_pt_addr); - PrintDebug("Creating new 64 bit shadow page table %p\n", (void *)BASE_TO_PAGE_ADDR(shadow_cr3->pml4t_base_addr)); + PrintDebug(info->vm_info, info, "Creating new 64 bit shadow page table %p\n", (void *)BASE_TO_PAGE_ADDR(shadow_cr3->pml4t_base_addr)); shadow_cr3->pwt = guest_cr3->pwt; shadow_cr3->pcd = guest_cr3->pcd; @@ -57,10 +57,10 @@ static inline void burst_64 (struct guest_info * core) { int idx; list_for_each_entry_safe(sp, node, &core->active_shadow_pages, link) { pt = (pte64_t *)V3_VAddr((void *)sp->page_pa); - PrintDebug("burst: pt %p\n",(void *)pt); + PrintDebug(info->vm_info, info, "burst: pt %p\n",(void *)pt); for (idx = 0; idx < PT_ENT_PER_PAGE; ++idx) { pte = (pte64_t *)&(pt[idx]); - if(*((uint64_t*)pte)) PrintDebug("%d: s %p\n",idx, (void*)*((uint64_t*)pte)); + if(*((uint64_t*)pte)) PrintDebug(info->vm_info, info, "%d: s %p\n",idx, (void*)*((uint64_t*)pte)); } } @@ -69,7 +69,7 @@ static inline void burst_64 (struct guest_info * core) { static inline int fix_read_pf_64(pte64_t *shadow_pte, uint_t vmm_info) { - PrintDebug("\tReadPf, start vmm_info %d\n", vmm_info); + PrintDebug(info->vm_info, info, "\tReadPf, start vmm_info %d\n", vmm_info); if ((vmm_info & PT_USER_MASK) && !(shadow_pte->user_page)) { shadow_pte->user_page = 1; @@ -87,25 +87,25 @@ static inline int fix_write_pf_64(struct guest_info *core, pte64_t *shadow_pte, struct shadow_page_cache_data *page; *write_pt = 0; - PrintDebug("\tWritePf, start vmm_info %d\n", vmm_info); + PrintDebug(info->vm_info, info, "\tWritePf, start vmm_info %d\n", vmm_info); if (shadow_pte->writable) { return 0; } - PrintDebug("\tWritePf, pass writable\n"); + PrintDebug(info->vm_info, info, "\tWritePf, pass writable\n"); writable_shadow = vmm_info & PT_WRITABLE_MASK; - PrintDebug("\tWritePf, writable_shadow %d\n", writable_shadow); + PrintDebug(info->vm_info, info, "\tWritePf, writable_shadow %d\n", writable_shadow); if (user) { if (!(vmm_info & PT_USER_MASK) || !writable_shadow) { - PrintDebug("\tWritePf: 1st User Check\n"); + PrintDebug(info->vm_info, info, "\tWritePf: 1st User Check\n"); return 0; } } else { if (!writable_shadow) { guest_cr0 = (struct cr0_64 *)&(core->shdw_pg_state.guest_cr0); - PrintDebug("\tWritePf: WP %d\n", guest_cr0->wp); + PrintDebug(info->vm_info, info, "\tWritePf: WP %d\n", guest_cr0->wp); if (guest_cr0->wp) { return 0; @@ -116,7 +116,7 @@ static inline int fix_write_pf_64(struct guest_info *core, pte64_t *shadow_pte, if (guest_pte->present == 0) { memset((void*)shadow_pte, 0, sizeof(uint64_t)); - PrintDebug("\tWritePf: Guest Not Present\n"); + PrintDebug(info->vm_info, info, "\tWritePf: Guest Not Present\n"); return 0; } @@ -125,12 +125,12 @@ static inline int fix_write_pf_64(struct guest_info *core, pte64_t *shadow_pte, shadow_zap_page(core, page); } - PrintDebug("\tWritePf: Zap Page\n"); + PrintDebug(info->vm_info, info, "\tWritePf: Zap Page\n"); } else if ((page = shadow_page_lookup_page(core, guest_fn, 0)) != NULL) { if ((page = shadow_page_lookup_page (core, guest_fn, 0)) != NULL) { guest_pte->dirty = 1; *write_pt = 1; - PrintDebug("\tWritePf: Write Needed\n"); + PrintDebug(info->vm_info, info, "\tWritePf: Write Needed\n"); return 0; } } @@ -140,7 +140,7 @@ static inline int fix_write_pf_64(struct guest_info *core, pte64_t *shadow_pte, rmap_add(core, (addr_t)shadow_pte); - PrintDebug("\tWritePf: On Writable\n"); + PrintDebug(info->vm_info, info, "\tWritePf: On Writable\n"); return 1; } @@ -168,8 +168,8 @@ static inline int handle_shadow_pagefault_64(struct guest_info * core, addr_t fa pml4e64_t * guest_pml4e = NULL; pml4e64_t * shadow_pml4e = (pml4e64_t *)&(shadow_pml[PML4E64_INDEX(fault_addr)]); - PrintDebug("64 bit Shadow page fault handler: %p\n", (void *)fault_addr); - PrintDebug("Handling PML fault\n"); + PrintDebug(info->vm_info, info, "64 bit Shadow page fault handler: %p\n", (void *)fault_addr); + PrintDebug(info->vm_info, info, "Handling PML fault\n"); int metaphysical = 0; unsigned hugepage_access = 0; @@ -187,7 +187,7 @@ static inline int handle_shadow_pagefault_64(struct guest_info * core, addr_t fa #endif if (guest_pa_to_host_va(core, guest_cr3, (addr_t*)&guest_pml) == -1) { - PrintError("Invalid Guest PML4E Address: 0x%p\n", (void *)guest_cr3); + PrintError(info->vm_info, info, "Invalid Guest PML4E Address: 0x%p\n", (void *)guest_cr3); return -1; } @@ -195,11 +195,11 @@ static inline int handle_shadow_pagefault_64(struct guest_info * core, addr_t fa pml4e_base_addr = (addr_t)(guest_pml4e->pdp_base_addr); - PrintDebug("Checking Guest %p\n", (void *)guest_pml); + PrintDebug(info->vm_info, info, "Checking Guest %p\n", (void *)guest_pml); // Check the guest page permissions guest_pml4e_access = v3_can_access_pml4e64(guest_pml, fault_addr, error_code); - PrintDebug("Checking shadow %p\n", (void *)shadow_pml); + PrintDebug(info->vm_info, info, "Checking shadow %p\n", (void *)shadow_pml); // Check the shadow page permissions shadow_pml4e_access = v3_can_access_pml4e64(shadow_pml, fault_addr, error_code); @@ -233,10 +233,10 @@ static inline int handle_shadow_pagefault_64(struct guest_info * core, addr_t fa pml4e_error: - PrintDebug("Injecting PML Pf to Guest: (Guest Access Error = %d) (SHDW Access Error = %d) (Pf Error Code = %d)\n", + PrintDebug(info->vm_info, info, "Injecting PML Pf to Guest: (Guest Access Error = %d) (SHDW Access Error = %d) (Pf Error Code = %d)\n", *(uint_t*)&guest_pml4e_access, *(uint_t*)&shadow_pml4e_access, *(uint_t*)&error_code); if (inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could Not Inject Guest Page Fault\n"); + PrintError(info->vm_info, info, "Could Not Inject Guest Page Fault\n"); return -1; } return 0; @@ -248,7 +248,7 @@ pml4e_noerror: } inherited_ar &= *(uint64_t*)guest_pml4e; - PrintDebug("PML: inherited %x\n", inherited_ar); + PrintDebug(info->vm_info, info, "PML: inherited %x\n", inherited_ar); pdpe64_t * shadow_pdp = NULL; pdpe64_t * guest_pdp = NULL; @@ -274,13 +274,13 @@ pml4e_noerror: if (guest_pa_to_host_va(core, BASE_TO_PAGE_ADDR(guest_pml4e->pdp_base_addr), (addr_t *)&guest_pdp) == -1) { // Machine check the guest - PrintError("Invalid Guest PDP Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pml4e->pdp_base_addr)); + PrintError(info->vm_info, info, "Invalid Guest PDP Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pml4e->pdp_base_addr)); v3_raise_exception(core, MC_EXCEPTION); return 0; } if (handle_pdpe_shadow_pagefault_64(core, fault_addr, error_code, shadow_pdp, guest_pdp, inherited_ar) == -1) { - PrintError("Error handling Page fault caused by PDPE\n"); + PrintError(info->vm_info, info, "Error handling Page fault caused by PDPE\n"); return -1; } @@ -297,12 +297,12 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * core, addr_t faul pdpe64_t * guest_pdpe = (pdpe64_t *)&(guest_pdp[PDPE64_INDEX(fault_addr)]); pdpe64_t * shadow_pdpe = (pdpe64_t *)&(shadow_pdp[PDPE64_INDEX(fault_addr)]); - PrintDebug("Handling PDP fault\n"); + PrintDebug(info->vm_info, info, "Handling PDP fault\n"); if (fault_addr==0) { - PrintDebug("Guest Page Tree for guest virtual address zero fault\n"); + PrintDebug(info->vm_info, info, "Guest Page Tree for guest virtual address zero fault\n"); PrintGuestPageTree(core,fault_addr,(addr_t)(core->shdw_pg_state.guest_cr3)); - PrintDebug("Host Page Tree for guest virtual address zero fault\n"); + PrintDebug(info->vm_info, info, "Host Page Tree for guest virtual address zero fault\n"); PrintHostPageTree(core,fault_addr,(addr_t)(core->ctrl_regs.cr3)); } @@ -318,7 +318,7 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * core, addr_t faul shadow_pdpe_access = v3_can_access_pdpe64(shadow_pdp, fault_addr, error_code); if (guest_pdpe_access == PT_ACCESS_NOT_PRESENT) { - PrintDebug("Guest Page Tree for guest virtual address zero fault\n"); + PrintDebug(info->vm_info, info, "Guest Page Tree for guest virtual address zero fault\n"); error_code.present = 0; goto pdpe_error; } @@ -347,10 +347,10 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * core, addr_t faul pdpe_error: - PrintDebug("Injecting PML Pf to Guest: (Guest Access Error = %d) (SHDW Access Error = %d) (Pf Error Code = %d)\n", + PrintDebug(info->vm_info, info, "Injecting PML Pf to Guest: (Guest Access Error = %d) (SHDW Access Error = %d) (Pf Error Code = %d)\n", *(uint_t*)&guest_pdpe_access, *(uint_t*)&shadow_pdpe_access, *(uint_t*)&error_code); if (inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could Not Inject Guest Page Fault\n"); + PrintError(info->vm_info, info, "Could Not Inject Guest Page Fault\n"); return -1; } return 0; @@ -362,7 +362,7 @@ pdpe_noerror: } inherited_ar &= *(uint64_t*)guest_pdpe; - PrintDebug("PDPE: inherited %x\n", inherited_ar); + PrintDebug(info->vm_info, info, "PDPE: inherited %x\n", inherited_ar); pde64_t * shadow_pd = NULL; pde64_t * guest_pd = NULL; @@ -389,13 +389,13 @@ pdpe_noerror: if (guest_pa_to_host_va(core, BASE_TO_PAGE_ADDR(guest_pdpe->pd_base_addr), (addr_t *)&guest_pd) == -1) { // Machine check the guest - PrintError("Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pdpe->pd_base_addr)); + PrintError(info->vm_info, info, "Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pdpe->pd_base_addr)); v3_raise_exception(core, MC_EXCEPTION); return 0; } if (handle_pde_shadow_pagefault_64(core, fault_addr, error_code, shadow_pd, guest_pd, inherited_ar) == -1) { - PrintError("Error handling Page fault caused by PDE\n"); + PrintError(info->vm_info, info, "Error handling Page fault caused by PDE\n"); return -1; } @@ -410,7 +410,7 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * core, addr_t fault pde64_t * guest_pde = (pde64_t *)&(guest_pd[PDE64_INDEX(fault_addr)]); pde64_t * shadow_pde = (pde64_t *)&(shadow_pd[PDE64_INDEX(fault_addr)]); - PrintDebug("Handling PDE fault\n"); + PrintDebug(info->vm_info, info, "Handling PDE fault\n"); int metaphysical = 0; unsigned hugepage_access = 0; @@ -458,10 +458,10 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * core, addr_t fault pde_error: - PrintDebug("Injecting PML Pf to Guest: (Guest Access Error = %d) (SHDW Access Error = %d) (Pf Error Code = %d)\n", + PrintDebug(info->vm_info, info, "Injecting PML Pf to Guest: (Guest Access Error = %d) (SHDW Access Error = %d) (Pf Error Code = %d)\n", *(uint_t*)&guest_pde_access, *(uint_t*)&shadow_pde_access, *(uint_t*)&error_code); if (inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could Not Inject Guest Page Fault\n"); + PrintError(info->vm_info, info, "Could Not Inject Guest Page Fault\n"); return -1; } return 0; @@ -473,7 +473,7 @@ pde_noerror: } inherited_ar &= *(uint64_t*)guest_pde; - PrintDebug("PDE: inherited %x\n", inherited_ar); + PrintDebug(info->vm_info, info, "PDE: inherited %x\n", inherited_ar); pte64_t * shadow_pt = NULL; pte64_t * guest_pt = NULL; @@ -485,7 +485,7 @@ pde_noerror: hugepage_access, (addr_t) shadow_pde, 0); shadow_pt = (pte64_t *)V3_VAddr((void *)shdw_page->page_pa); - PrintDebug("Creating new shadow PT: %p\n", shadow_pt); + PrintDebug(info->vm_info, info, "Creating new shadow PT: %p\n", shadow_pt); shadow_pde->present =1; shadow_pde->accessed=1; @@ -501,20 +501,20 @@ pde_noerror: if (guest_pde->large_page == 0) { if (guest_pa_to_host_va(core, BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr), (addr_t *)&guest_pt) == -1) { // Machine check the guest - PrintError("Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); + PrintError(info->vm_info, info, "Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); v3_raise_exception(core, MC_EXCEPTION); return 0; } if (handle_pte_shadow_pagefault_64(core, fault_addr, error_code, shadow_pt, guest_pt, inherited_ar) == -1) { - PrintError("Error handling Page fault caused by PDE\n"); + PrintError(info->vm_info, info, "Error handling Page fault caused by PDE\n"); return -1; } } else { if (handle_2MB_shadow_pagefault_64(core, fault_addr, error_code, shadow_pt, (pde64_2MB_t *)guest_pde, inherited_ar) == -1) { - PrintError("Error handling large pagefault\n"); + PrintError(info->vm_info, info, "Error handling large pagefault\n"); return -1; } } @@ -532,7 +532,7 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * core, addr_t fault addr_t guest_pa = BASE_TO_PAGE_ADDR((addr_t)(guest_pte->page_base_addr)) + PAGE_OFFSET(fault_addr); // struct shadow_page_state * state = &(core->shdw_pg_state); - PrintDebug("Handling PTE fault\n"); + PrintDebug(info->vm_info, info, "Handling PTE fault\n"); struct v3_mem_region * shdw_reg = v3_get_mem_region(core->vm_info, core->vcpu_id, guest_pa); @@ -540,7 +540,7 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * core, addr_t fault if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintError("Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); + PrintError(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); v3_raise_exception(core, MC_EXCEPTION); return 0; } @@ -580,10 +580,10 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * core, addr_t fault pte_error: - PrintDebug("Injecting PML Pf to Guest: (Guest Access Error = %d) (SHDW Access Error = %d) (Pf Error Code = %d)\n", + PrintDebug(info->vm_info, info, "Injecting PML Pf to Guest: (Guest Access Error = %d) (SHDW Access Error = %d) (Pf Error Code = %d)\n", *(uint_t*)&guest_pte_access, *(uint_t*)&shadow_pte_access, *(uint_t*)&error_code); if (inject_guest_pf(core, fault_addr, error_code) == -1) { - PrintError("Could Not Inject Guest Page Fault\n"); + PrintError(info->vm_info, info, "Could Not Inject Guest Page Fault\n"); return -1; } return 0; @@ -595,11 +595,11 @@ pte_noerror: } inherited_ar &= *(uint64_t*)guest_pte; - PrintDebug("PTE: inherited %x\n", inherited_ar); + PrintDebug(info->vm_info, info, "PTE: inherited %x\n", inherited_ar); if (shadow_pte_access == PT_ACCESS_NOT_PRESENT) { // Page Table Entry Not Present - PrintDebug("guest_pa =%p\n", (void *)guest_pa); + PrintDebug(info->vm_info, info, "guest_pa =%p\n", (void *)guest_pa); if ((shdw_reg->host_type == SHDW_REGION_ALLOCATED) || (shdw_reg->host_type == SHDW_REGION_WRITE_HOOK)) { @@ -614,7 +614,7 @@ pte_noerror: shadow_pte->present = guest_pte->present; shadow_pte->user_page = inherited_ar_user; - PrintDebug("PTE: inheritied shdow_pte_user %d, guest_pte_user %d\n", shadow_pte->user_page, guest_pte->user_page); + PrintDebug(info->vm_info, info, "PTE: inheritied shdow_pte_user %d, guest_pte_user %d\n", shadow_pte->user_page, guest_pte->user_page); //set according to VMM policy shadow_pte->global_page = guest_pte->global_page; @@ -624,7 +624,7 @@ pte_noerror: shadow_pte->dirty = guest_pte->dirty; shadow_pte->writable = inherited_ar_writable; - PrintDebug("PTE: inheritied shdow_pte_writable %d, guest_pte_writable %d\n", shadow_pte->writable, guest_pte->writable); + PrintDebug(info->vm_info, info, "PTE: inheritied shdow_pte_writable %d, guest_pte_writable %d\n", shadow_pte->writable, guest_pte->writable); // Write hooks trump all, and are set Read Only @@ -645,17 +645,17 @@ pte_noerror: } } - PrintDebug("PTE: Updated Shadow Present %d, Write %d, User %d, Dirty %d, Accessed %d, Global %d\n", + PrintDebug(info->vm_info, info, "PTE: Updated Shadow Present %d, Write %d, User %d, Dirty %d, Accessed %d, Global %d\n", shadow_pte->present, shadow_pte->writable, shadow_pte->user_page, shadow_pte->dirty, shadow_pte->accessed, shadow_pte->global_page); - PrintDebug("PTE: Shadow %p\n", (void*)*((addr_t*)shadow_pte)); + PrintDebug(info->vm_info, info, "PTE: Shadow %p\n", (void*)*((addr_t*)shadow_pte)); rmap_add(core, (addr_t)shadow_pte); } else { // Page fault handled by hook functions if (v3_handle_mem_full_hook(core, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -664,11 +664,11 @@ pte_noerror: if (shdw_reg->host_type == SHDW_REGION_WRITE_HOOK) { if (v3_handle_mem_wr_hook(core, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } else { - PrintDebug("Shadow PTE Write Error\n"); + PrintDebug(info->vm_info, info, "Shadow PTE Write Error\n"); shadow_pte->writable = guest_pte->writable; } @@ -685,25 +685,25 @@ pte_noerror: fixed = fix_read_pf_64(shadow_pte, vmm_info); } - PrintDebug("PTE: Fixed %d Write_Pt %d\n", fixed, write_pt); - PrintDebug("PTE: Shadow Present %d, Write %d, User %d, Dirty %d, Accessed %d, Global %d\n", + PrintDebug(info->vm_info, info, "PTE: Fixed %d Write_Pt %d\n", fixed, write_pt); + PrintDebug(info->vm_info, info, "PTE: Shadow Present %d, Write %d, User %d, Dirty %d, Accessed %d, Global %d\n", shadow_pte->present, shadow_pte->writable, shadow_pte->user_page, shadow_pte->dirty, shadow_pte->accessed, shadow_pte->global_page); - PrintDebug("PTE: Shadow %p\n", (void*)*((addr_t*)shadow_pte)); + PrintDebug(info->vm_info, info, "PTE: Shadow %p\n", (void*)*((addr_t*)shadow_pte)); if (shdw_reg->host_type == SHDW_REGION_ALLOCATED && write_pt == 1) { - PrintDebug("PTE: Emul\n"); + PrintDebug(info->vm_info, info, "PTE: Emul\n"); if (v3_handle_mem_wr_hook(core, fault_addr, guest_pa, shdw_reg, error_code) == -1) { shadow_unprotect_page(core, (addr_t)guest_pte->page_base_addr); } } - PrintDebug("PTE: PTE end\n"); - PrintDebug("PTE: Updated Shadow Present %d, Write %d, User %d, Dirty %d, Accessed %d, Global %d\n", + PrintDebug(info->vm_info, info, "PTE: PTE end\n"); + PrintDebug(info->vm_info, info, "PTE: Updated Shadow Present %d, Write %d, User %d, Dirty %d, Accessed %d, Global %d\n", shadow_pte->present, shadow_pte->writable, shadow_pte->user_page, shadow_pte->dirty, shadow_pte->accessed, shadow_pte->global_page); - PrintDebug("PTE: Updated Shadow %p\n", (void*)*((addr_t*)shadow_pte)); - PrintDebug("PTE: Guest PA %p, Host PA %p\n", (void*)guest_pa, (void*)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); + PrintDebug(info->vm_info, info, "PTE: Updated Shadow %p\n", (void*)*((addr_t*)shadow_pte)); + PrintDebug(info->vm_info, info, "PTE: Guest PA %p, Host PA %p\n", (void*)guest_pa, (void*)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); return 0; } @@ -719,8 +719,8 @@ static int handle_2MB_shadow_pagefault_64(struct guest_info * core, addr_t guest_fault_pa = BASE_TO_PAGE_ADDR_2MB(large_guest_pde->page_base_addr) + PAGE_OFFSET_2MB(fault_addr); // struct shadow_page_state * state = &(core->shdw_pg_state); - PrintDebug("Handling 2MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); - PrintDebug("ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); + PrintDebug(info->vm_info, info, "Handling 2MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); + PrintDebug(info->vm_info, info, "ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); struct v3_mem_region * shdw_reg = v3_get_mem_region(core->vm_info, core->vcpu_id, guest_fault_pa); @@ -730,7 +730,7 @@ static int handle_2MB_shadow_pagefault_64(struct guest_info * core, if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintError("Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); + PrintError(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); v3_raise_exception(core, MC_EXCEPTION); return 0; } @@ -747,9 +747,9 @@ static int handle_2MB_shadow_pagefault_64(struct guest_info * core, shadow_pte->page_base_addr = PAGE_BASE_ADDR(shadow_pa); - PrintDebug("LPTE: inherited_ar %d\n", inherited_ar); + PrintDebug(info->vm_info, info, "LPTE: inherited_ar %d\n", inherited_ar); shadow_pte->user_page = inherited_ar_user; - PrintDebug("LPTE: inheritied shdow_pte_user %d\n", shadow_pte->user_page); + PrintDebug(info->vm_info, info, "LPTE: inheritied shdow_pte_user %d\n", shadow_pte->user_page); shadow_pte->present = large_guest_pde->present; shadow_pte->dirty = large_guest_pde->dirty; @@ -767,7 +767,7 @@ static int handle_2MB_shadow_pagefault_64(struct guest_info * core, shadow_pte->writable = 0; } else { shadow_pte->writable = inherited_ar_writable; - PrintDebug("LPTE: inheritied shdow_pte_writable %d, PT_WRITABLE_MASK %p, inherited_ar & PT_WRITABLE_MASK %p\n", + PrintDebug(info->vm_info, info, "LPTE: inheritied shdow_pte_writable %d, PT_WRITABLE_MASK %p, inherited_ar & PT_WRITABLE_MASK %p\n", shadow_pte->writable, (void*)PT_WRITABLE_MASK, (void*)(inherited_ar & PT_WRITABLE_MASK)); } @@ -792,7 +792,7 @@ static int handle_2MB_shadow_pagefault_64(struct guest_info * core, } else { if (v3_handle_mem_full_hook(core, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -801,7 +801,7 @@ static int handle_2MB_shadow_pagefault_64(struct guest_info * core, if (shdw_reg->host_type == SHDW_REGION_WRITE_HOOK) { if (v3_handle_mem_wr_hook(core, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -819,11 +819,11 @@ static int handle_2MB_shadow_pagefault_64(struct guest_info * core, fixed = fix_read_pf_64(shadow_pte, vmm_info); } - PrintDebug("LPTE: Fixed %d, Write_Pt %d\n", fixed, write_pt); - PrintDebug("LPTE: Shadow Present %d, Write %d, User %d, Dirty %d, Accessed %d, Global %d\n", + PrintDebug(info->vm_info, info, "LPTE: Fixed %d, Write_Pt %d\n", fixed, write_pt); + PrintDebug(info->vm_info, info, "LPTE: Shadow Present %d, Write %d, User %d, Dirty %d, Accessed %d, Global %d\n", shadow_pte->present, shadow_pte->writable, shadow_pte->user_page, shadow_pte->dirty, shadow_pte->accessed, shadow_pte->global_page); - PrintDebug("LPTE: Shadow %p\n", (void*)*((addr_t*)shadow_pte)); + PrintDebug(info->vm_info, info, "LPTE: Shadow %p\n", (void*)*((addr_t*)shadow_pte)); if (shdw_reg->host_type == SHDW_REGION_ALLOCATED && write_pt == 1){ if (v3_handle_mem_wr_hook(core, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { @@ -831,17 +831,17 @@ static int handle_2MB_shadow_pagefault_64(struct guest_info * core, } } - PrintDebug("Updated LPTE: Shadow Present %d, Write %d, User %d, Dirty %d, Accessed %d, Global %d\n", + PrintDebug(info->vm_info, info, "Updated LPTE: Shadow Present %d, Write %d, User %d, Dirty %d, Accessed %d, Global %d\n", shadow_pte->present, shadow_pte->writable, shadow_pte->user_page, shadow_pte->dirty, shadow_pte->accessed, shadow_pte->global_page); - PrintDebug("LPTE: Updated Shadow %p\n", (void*)*((addr_t*)shadow_pte)); - PrintDebug("LPTE: Guest PA %p Host PA %p\n", + PrintDebug(info->vm_info, info, "LPTE: Updated Shadow %p\n", (void*)*((addr_t*)shadow_pte)); + PrintDebug(info->vm_info, info, "LPTE: Guest PA %p Host PA %p\n", (void*)BASE_TO_PAGE_ADDR(PAGE_BASE_ADDR(guest_fault_pa)), (void*)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); - PrintDebug("Returning from Large Page Fault Handler\n"); + PrintDebug(info->vm_info, info, "Returning from Large Page Fault Handler\n"); // PrintHostPageTree(core, fault_addr, info->ctrl_regs.cr3); - PrintDebug("Returning from large page fault handler\n"); + PrintDebug(info->vm_info, info, "Returning from large page fault handler\n"); return 0; } @@ -872,7 +872,7 @@ static int invalidation_cb_64(struct guest_info * core, page_type_t type, } if (pdpe->vmm_info == V3_LARGE_PG) { - PrintError("1 Gigabyte pages not supported\n"); + PrintError(info->vm_info, info, "1 Gigabyte pages not supported\n"); return -1; pdpe->present = 0; @@ -906,23 +906,23 @@ static int invalidation_cb_64(struct guest_info * core, page_type_t type, return 1; } default: - PrintError("Invalid Page Type\n"); + PrintError(info->vm_info, info, "Invalid Page Type\n"); return -1; } // should not get here - PrintError("Should not get here....\n"); + PrintError(info->vm_info, info, "Should not get here....\n"); return -1; } static inline int handle_shadow_invlpg_64(struct guest_info * core, addr_t vaddr) { - PrintDebug("INVLPG64 - %p\n",(void*)vaddr); + PrintDebug(info->vm_info, info, "INVLPG64 - %p\n",(void*)vaddr); int ret = v3_drill_host_pt_64(core, core->ctrl_regs.cr3, vaddr, invalidation_cb_64, NULL); if (ret == -1) { - PrintError("Page table drill returned error.... \n"); + PrintError(info->vm_info, info, "Page table drill returned error.... \n"); PrintHostPageTree(core, vaddr, core->ctrl_regs.cr3); } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass.c b/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass.c index 001e917..a5c77a4 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass.c +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass.c @@ -139,12 +139,12 @@ static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core); static void telemetry_cb(struct v3_vm_info * vm, void * private_data, char * hdr) { struct swapbypass_vm_state * swap_state = (struct swapbypass_vm_state *)(vm->shdw_impl.impl_data); - V3_Print("%sSymbiotic Swap:\n", hdr); - V3_Print("%s\tRead faults=%d\n", hdr, swap_state->read_faults); - V3_Print("%s\tWrite faults=%d\n", hdr, swap_state->write_faults); - V3_Print("%s\tMapped Pages=%d\n", hdr, swap_state->mapped_pages); - V3_Print("%s\tFlushes=%d\n", hdr, swap_state->flushes); - V3_Print("%s\tlist size=%d\n", hdr, swap_state->list_size); + V3_Print(vm, VCORE_NONE, "%sSymbiotic Swap:\n", hdr); + V3_Print(vm, VCORE_NONE, "%s\tRead faults=%d\n", hdr, swap_state->read_faults); + V3_Print(vm, VCORE_NONE, "%s\tWrite faults=%d\n", hdr, swap_state->write_faults); + V3_Print(vm, VCORE_NONE, "%s\tMapped Pages=%d\n", hdr, swap_state->mapped_pages); + V3_Print(vm, VCORE_NONE, "%s\tFlushes=%d\n", hdr, swap_state->flushes); + V3_Print(vm, VCORE_NONE, "%s\tlist size=%d\n", hdr, swap_state->list_size); } #endif @@ -161,11 +161,11 @@ static int get_vaddr_perms(struct guest_info * info, addr_t vaddr, pte32_t * gue // symcall to check if page is in cache or on swap disk if (v3_sym_call3(info, SYMCALL_MEM_LOOKUP, (uint64_t *)&vaddr, (uint64_t *)&pte_val, (uint64_t *)page_perms) == -1) { - PrintError("Sym call error?? that's weird... \n"); + PrintError(info->vm_info, info, "Sym call error?? that's weird... \n"); return -1; } - // V3_Print("page perms = %x\n", *(uint32_t *)page_perms); + // V3_Print(info->vm_info, info, "page perms = %x\n", *(uint32_t *)page_perms); if (vaddr == 0) { return 1; @@ -198,7 +198,7 @@ static addr_t map_swp_page(struct v3_vm_info * vm, pte32_t * shadow_pte, pte32_t if (swp_page_ptr == NULL) { - // PrintError("Swapped out page not found on swap device\n"); + // PrintError(vm, VCORE_NONE, "Swapped out page not found on swap device\n"); return 0; } @@ -208,7 +208,7 @@ static addr_t map_swp_page(struct v3_vm_info * vm, pte32_t * shadow_pte, pte32_t shdw_ptr_list = (struct list_head *)V3_Malloc(sizeof(struct list_head)); if (!shdw_ptr_list) { - PrintError("Cannot allocate\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate\n"); return 0; } @@ -222,7 +222,7 @@ static addr_t map_swp_page(struct v3_vm_info * vm, pte32_t * shadow_pte, pte32_t shdw_ptr = (struct shadow_pointer *)V3_Malloc(sizeof(struct shadow_pointer)); if (shdw_ptr == NULL) { - PrintError("MEMORY LEAK\n"); + PrintError(vm, VCORE_NONE, "MEMORY LEAK\n"); #ifdef V3_CONFIG_SWAPBYPASS_TELEMETRY telemetry_cb(vm, NULL, ""); #endif @@ -261,7 +261,7 @@ static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core) if (page_tail->cr3 != cur_cr3) { - PrintDebug("Reusing old shadow Page: %p (cur_CR3=%p)(page_cr3=%p) \n", + PrintDebug(core->vm_info, core, "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)); @@ -280,18 +280,18 @@ static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core) page_tail = (struct shadow_page_data *)V3_Malloc(sizeof(struct shadow_page_data)); if (!page_tail) { - PrintError("Cannot allocate\n"); - return -1; + PrintError(core->vm_info, core, "Cannot allocate\n"); + return NULL; } page_tail->page_pa = (addr_t)V3_AllocPages(1); if (!page_tail->page_pa) { - PrintError("Cannot allocate page\n"); + PrintError(core->vm_info, core, "Cannot allocate page\n"); return NULL; } - PrintDebug("Allocating new shadow Page: %p (cur_cr3=%p)\n", + PrintDebug(core->vm_info, core, "Allocating new shadow Page: %p (cur_cr3=%p)\n", (void *)(addr_t)page_tail->page_pa, (void *)(addr_t)cur_cr3); @@ -358,14 +358,14 @@ int v3_swap_flush(struct v3_vm_info * vm) { struct swapbypass_vm_state * swap_state = (struct swapbypass_vm_state *)(vm->shdw_impl.impl_data); struct hashtable_iter * ht_iter = v3_create_htable_iter(swap_state->shdw_ptr_ht); - // PrintDebug("Flushing Symbiotic Swap table\n"); + // PrintDebug(vm, VCORE_NONE, "Flushing Symbiotic Swap table\n"); #ifdef V3_CONFIG_SWAPBYPASS_TELEMETRY swap_state->flushes++; #endif if (!ht_iter) { - PrintError("NULL iterator in swap flush!! Probably will crash soon...\n"); + PrintError(vm, VCORE_NONE, "NULL iterator in swap flush!! Probably will crash soon...\n"); } while (ht_iter->entry) { @@ -378,7 +378,7 @@ int v3_swap_flush(struct v3_vm_info * vm) { list_for_each_entry_safe(shdw_ptr, tmp_shdw_ptr, shdw_ptr_list, node) { if (shdw_ptr == NULL) { - PrintError("Null shadow pointer in swap flush!! Probably crashing soon...\n"); + PrintError(vm, VCORE_NONE, "Null shadow pointer in swap flush!! Probably crashing soon...\n"); } // Trigger faults for next shadow access @@ -418,7 +418,7 @@ static int sb_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { impl_state->impl_data = sb_state; - PrintDebug("Initialized SwapBypass\n"); + PrintDebug(vm, VCORE_NONE, "Initialized SwapBypass\n"); return 0; @@ -432,12 +432,12 @@ 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"); + V3_Print(core->vm_info, core, "SWAPBYPASS local initialization\n"); swapbypass_state = (struct swapbypass_local_state *)V3_Malloc(sizeof(struct swapbypass_local_state)); if (!swapbypass_state) { - PrintError("Cannot allocate\n"); + PrintError(core->vm_info, core, "Cannot allocate\n"); return -1; } @@ -462,7 +462,7 @@ static int sb_activate_shdw_pt(struct guest_info * core) { case LONG_16_COMPAT: return activate_shadow_pt_64(core); default: - PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(core->vm_info, core, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } @@ -488,7 +488,7 @@ static int sb_handle_pf(struct guest_info * core, addr_t fault_addr, pf_error_t return handle_shadow_pagefault_64(core, fault_addr, error_code); break; default: - PrintError("Unhandled CPU Mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(core->vm_info, core, "Unhandled CPU Mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } } @@ -506,7 +506,7 @@ static int sb_handle_invlpg(struct guest_info * core, addr_t vaddr) { case LONG_16_COMPAT: return handle_shadow_invlpg_64(core, vaddr); default: - PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(core->vm_info, core, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass_32.h b/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass_32.h index 3b745af..b814e44 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass_32.h +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass_32.h @@ -28,7 +28,7 @@ static inline int activate_shadow_pt_32(struct guest_info * info) { shdw_page->cr3 = shdw_page->page_pa; shadow_cr3->pdt_base_addr = PAGE_BASE_ADDR_4KB(shdw_page->page_pa); - PrintDebug( "Created new shadow page table %p\n", (void *)BASE_TO_PAGE_ADDR(shadow_cr3->pdt_base_addr)); + PrintDebug(info->vm_info, info, "Created new shadow page table %p\n", (void *)BASE_TO_PAGE_ADDR(shadow_cr3->pdt_base_addr)); shadow_cr3->pwt = guest_cr3->pwt; shadow_cr3->pcd = guest_cr3->pcd; @@ -65,11 +65,11 @@ static inline int handle_shadow_pagefault_32(struct guest_info * info, addr_t fa pde32_t * guest_pde = NULL; pde32_t * shadow_pde = (pde32_t *)&(shadow_pd[PDE32_INDEX(fault_addr)]); - PrintDebug("Shadow page fault handler: %p\n", (void*) fault_addr ); - PrintDebug("Handling PDE32 Fault\n"); + PrintDebug(info->vm_info, info, "Shadow page fault handler: %p\n", (void*) fault_addr ); + PrintDebug(info->vm_info, info, "Handling PDE32 Fault\n"); if (v3_gpa_to_hva(info, guest_cr3, (addr_t*)&guest_pd) == -1) { - PrintError("Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); + PrintError(info->vm_info, info, "Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); return -1; } @@ -84,10 +84,10 @@ static inline int handle_shadow_pagefault_32(struct guest_info * info, addr_t fa /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pde_access, shadow_pde_access) == 1) { - PrintDebug("Injecting PDE pf to guest: (guest access error=%d) (shdw access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Injecting PDE pf to guest: (guest access error=%d) (shdw access error=%d) (pf error code=%d)\n", *(uint_t *)&guest_pde_access, *(uint_t *)&shadow_pde_access, *(uint_t *)&error_code); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } return 0; @@ -99,11 +99,11 @@ static inline int handle_shadow_pagefault_32(struct guest_info * info, addr_t fa // // PDE Entry marked non user // - PrintDebug("Shadow Paging User access error (shadow_pde_access=0x%x, guest_pde_access=0x%x)\n", + PrintDebug(info->vm_info, info, "Shadow Paging User access error (shadow_pde_access=0x%x, guest_pde_access=0x%x)\n", shadow_pde_access, guest_pde_access); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } return 0; @@ -117,11 +117,11 @@ static inline int handle_shadow_pagefault_32(struct guest_info * info, addr_t fa (shadow_pde_access != PT_ACCESS_OK)) { // inject page fault in guest if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } - PrintDebug("Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pde_access); - PrintDebug("Manual Says to inject page fault into guest\n"); + PrintDebug(info->vm_info, info, "Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pde_access); + PrintDebug(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return 0; } @@ -176,18 +176,18 @@ static inline int handle_shadow_pagefault_32(struct guest_info * info, addr_t fa if (guest_pde->large_page == 0) { if (v3_gpa_to_hva(info, BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr), (addr_t*)&guest_pt) == -1) { // Machine check the guest - PrintDebug("Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); + PrintDebug(info->vm_info, info, "Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); v3_raise_exception(info, MC_EXCEPTION); return 0; } if (handle_pte_shadow_pagefault_32(info, fault_addr, error_code, shadow_pt, guest_pt) == -1) { - PrintError("Error handling Page fault caused by PTE\n"); + PrintError(info->vm_info, info, "Error handling Page fault caused by PTE\n"); return -1; } } else { if (handle_4MB_shadow_pagefault_32(info, fault_addr, error_code, shadow_pt, (pde32_4MB_t *)guest_pde) == -1) { - PrintError("Error handling large pagefault\n"); + PrintError(info->vm_info, info, "Error handling large pagefault\n"); return -1; } } @@ -209,7 +209,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintDebug("Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); + PrintDebug(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); v3_raise_exception(info, MC_EXCEPTION); return 0; } @@ -224,7 +224,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pte_access, shadow_pte_access) == 1) { - PrintDebug("Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", guest_pte_access, *(uint_t*)&error_code); @@ -253,11 +253,11 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault swp_pg_addr = get_swapped_pg_addr(info->vm_info, guest_pte); if (swp_pg_addr != 0) { - PrintDebug("Swapped page address=%p\n", (void *)swp_pg_addr); + PrintDebug(info->vm_info, info, "Swapped page address=%p\n", (void *)swp_pg_addr); /* if (info->cpl == 0) { - PrintError("Swapped Page fault in kernel mode.... bad...\n"); + PrintError(info->vm_info, info, "Swapped Page fault in kernel mode.... bad...\n"); goto inject; } */ @@ -265,13 +265,13 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault int sym_ret = get_vaddr_perms(info, fault_addr, guest_pte, &swap_perms); if (sym_ret == -1) { - PrintError("Symcall error...\n"); + PrintError(info->vm_info, info, "Symcall error...\n"); return -1; } else if (sym_ret == 0) { if (swap_perms.present == 0) { - PrintError("Nonpresent swapped page\n"); + PrintError(info->vm_info, info, "Nonpresent swapped page\n"); } // swap_perms.write ==1 || error_code.write == 0 @@ -287,7 +287,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault swp_pg_pa = map_swp_page(info->vm_info, shadow_pte, guest_pte, (void *)swp_pg_addr); - PrintDebug("Page fault on swapped out page (vaddr=%p) (pte=%x) (error_code=%x)\n", + PrintDebug(info->vm_info, info, "Page fault on swapped out page (vaddr=%p) (pte=%x) (error_code=%x)\n", (void *)fault_addr, *(uint32_t *)guest_pte, *(uint32_t *)&error_code); shadow_pte->writable = swap_perms.write; @@ -304,12 +304,12 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault #ifdef V3_CONFIG_SYMBIOTIC_SWAP_TELEMETRY info->vm_info->swap_state.mapped_pages++; #endif - // PrintError("Swap fault handled\n"); + // PrintError(info->vm_info, info, "Swap fault handled\n"); return 0; } } } else { - PrintDebug("Not a sym swappable page\n"); + PrintDebug(info->vm_info, info, "Not a sym swappable page\n"); } } @@ -317,7 +317,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault // inject: if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } @@ -329,27 +329,27 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault if (shadow_pte_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush page tables and everything should now work - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(info->vm_info, info, "Inconsistent state... Guest re-entry should flush tlb\n"); return 0; } if (shadow_pte_access == PT_ACCESS_NOT_PRESENT) { // Page Table Entry Not Present - PrintDebug("guest_pa =%p\n", (void *)guest_pa); + PrintDebug(info->vm_info, info, "guest_pa =%p\n", (void *)guest_pa); if ((shdw_reg->flags.alloced == 1) || (shdw_reg->flags.read == 1)) { addr_t shadow_pa = 0; if (v3_gpa_to_hpa(info, guest_pa, &shadow_pa) == -1) { - PrintError("could not translate page fault address (%p)\n", (void *)guest_pa); + PrintError(info->vm_info, info, "could not translate page fault address (%p)\n", (void *)guest_pa); return -1; } shadow_pte->page_base_addr = PAGE_BASE_ADDR(shadow_pa); - PrintDebug("\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); + PrintDebug(info->vm_info, info, "\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); shadow_pte->present = guest_pte->present; shadow_pte->user_page = guest_pte->user_page; @@ -380,7 +380,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault // Page fault handled by hook functions if (shdw_reg->unhandled(info, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -389,11 +389,11 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault if (shdw_reg->flags.write == 1) { - PrintDebug("Shadow PTE Write Error\n"); + PrintDebug(info->vm_info, info, "Shadow PTE Write Error\n"); shadow_pte->writable = guest_pte->writable; } else { if (shdw_reg->unhandled(info, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -404,12 +404,12 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault } else { // Inject page fault into the guest if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } - PrintError("PTE Page fault fell through... Not sure if this should ever happen\n"); - PrintError("Manual Says to inject page fault into guest\n"); + PrintError(info->vm_info, info, "PTE Page fault fell through... Not sure if this should ever happen\n"); + PrintError(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return -1; } @@ -427,15 +427,15 @@ static int handle_4MB_shadow_pagefault_32(struct guest_info * info, addr_t guest_fault_pa = BASE_TO_PAGE_ADDR_4MB(large_guest_pde->page_base_addr) + PAGE_OFFSET_4MB(fault_addr); - PrintDebug("Handling 4MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); - PrintDebug("ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); + PrintDebug(info->vm_info, info, "Handling 4MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); + PrintDebug(info->vm_info, info, "ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); struct v3_mem_region * shdw_reg = v3_get_mem_region(info->vm_info, info->vcpu_id, guest_fault_pa); if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintDebug("Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); + PrintDebug(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); v3_raise_exception(info, MC_EXCEPTION); return -1; } @@ -443,7 +443,7 @@ static int handle_4MB_shadow_pagefault_32(struct guest_info * info, if (shadow_pte_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush tables and everything should now workd - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(info->vm_info, info, "Inconsistent state... Guest re-entry should flush tlb\n"); return 0; } @@ -456,12 +456,12 @@ static int handle_4MB_shadow_pagefault_32(struct guest_info * info, addr_t shadow_pa = 0; if (v3_gpa_to_hpa(info, guest_fault_pa, &shadow_pa) == -1) { - PrintError("could not translate page fault address (%p)\n", (void *)guest_fault_pa); + PrintError(info->vm_info, info, "could not translate page fault address (%p)\n", (void *)guest_fault_pa); return -1; } shadow_pte->page_base_addr = PAGE_BASE_ADDR(shadow_pa); - PrintDebug("\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); + PrintDebug(info->vm_info, info, "\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); shadow_pte->present = 1; @@ -486,22 +486,22 @@ static int handle_4MB_shadow_pagefault_32(struct guest_info * info, } else { if (shdw_reg->unhandled(info, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } } else if (shadow_pte_access == PT_ACCESS_WRITE_ERROR) { if (shdw_reg->unhandled(info, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } else { - PrintError("Error in large page fault handler...\n"); - PrintError("This case should have been handled at the top level handler\n"); + PrintError(info->vm_info, info, "Error in large page fault handler...\n"); + PrintError(info->vm_info, info, "This case should have been handled at the top level handler\n"); return -1; } - PrintDebug("Returning from large page fault handler\n"); + PrintDebug(info->vm_info, info, "Returning from large page fault handler\n"); return 0; } @@ -526,7 +526,7 @@ static inline int handle_shadow_invlpg_32(struct guest_info * info, addr_t vaddr pde32_t * guest_pde; if (v3_gpa_to_hva(info, guest_cr3, (addr_t*)&guest_pd) == -1) { - PrintError("Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); + PrintError(info->vm_info, info, "Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); return -1; } @@ -534,12 +534,12 @@ static inline int handle_shadow_invlpg_32(struct guest_info * info, addr_t vaddr if (guest_pde->large_page == 1) { shadow_pde->present = 0; - PrintDebug("Invalidating Large Page\n"); + PrintDebug(info->vm_info, info, "Invalidating Large Page\n"); } else if (shadow_pde->present == 1) { pte32_t * shadow_pt = (pte32_t *)(addr_t)BASE_TO_PAGE_ADDR_4KB(shadow_pde->pt_base_addr); pte32_t * shadow_pte = (pte32_t *) V3_VAddr( (void*) &shadow_pt[PTE32_INDEX(vaddr)] ); - PrintDebug("Setting not present\n"); + PrintDebug(info->vm_info, info, "Setting not present\n"); shadow_pte->present = 0; } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass_32pae.h b/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass_32pae.h index d6ef1c7..2c79599 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass_32pae.h +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass_32pae.h @@ -19,7 +19,7 @@ static inline int activate_shadow_pt_32pae(struct guest_info * info) { - PrintError("Activating 32 bit PAE page tables not implemented\n"); + PrintError(info->vm_info, info, "Activating 32 bit PAE page tables not implemented\n"); return -1; } @@ -37,13 +37,13 @@ static inline int activate_shadow_pt_32pae(struct guest_info * info) { */ static inline int handle_shadow_pagefault_32pae(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) { - PrintError("32 bit PAE shadow paging not implemented\n"); + PrintError(info->vm_info, info, "32 bit PAE shadow paging not implemented\n"); return -1; } static inline int handle_shadow_invlpg_32pae(struct guest_info * info, addr_t vaddr) { - PrintError("32 bit PAE shadow paging not implemented\n"); + PrintError(info->vm_info, info, "32 bit PAE shadow paging not implemented\n"); return -1; } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass_64.h b/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass_64.h index cb29966..5057654 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass_64.h +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_swapbypass_64.h @@ -27,10 +27,10 @@ static inline int activate_shadow_pt_64(struct guest_info * info) { // Because this is a new CR3 load the allocated page is the new CR3 value shadow_pt->cr3 = shadow_pt->page_pa; - PrintDebug("Top level Shadow page pa=%p\n", (void *)shadow_pt_addr); + PrintDebug(info->vm_info, info, "Top level Shadow page pa=%p\n", (void *)shadow_pt_addr); shadow_cr3->pml4t_base_addr = PAGE_BASE_ADDR_4KB(shadow_pt_addr); - PrintDebug("Creating new 64 bit shadow page table %p\n", (void *)BASE_TO_PAGE_ADDR(shadow_cr3->pml4t_base_addr)); + PrintDebug(info->vm_info, info, "Creating new 64 bit shadow page table %p\n", (void *)BASE_TO_PAGE_ADDR(shadow_cr3->pml4t_base_addr)); shadow_cr3->pwt = guest_cr3->pwt; @@ -74,30 +74,30 @@ static inline int handle_shadow_pagefault_64(struct guest_info * info, addr_t fa pml4e64_t * guest_pml4e = NULL; pml4e64_t * shadow_pml4e = (pml4e64_t *)&(shadow_pml[PML4E64_INDEX(fault_addr)]); - PrintDebug("64 bit Shadow page fault handler: %p\n", (void *)fault_addr); - PrintDebug("Handling PML fault\n"); + PrintDebug(info->vm_info, info, "64 bit Shadow page fault handler: %p\n", (void *)fault_addr); + PrintDebug(info->vm_info, info, "Handling PML fault\n"); if (v3_gpa_to_hva(info, guest_cr3, (addr_t*)&guest_pml) == -1) { - PrintError("Invalid Guest PML4E Address: 0x%p\n", (void *)guest_cr3); + PrintError(info->vm_info, info, "Invalid Guest PML4E Address: 0x%p\n", (void *)guest_cr3); return -1; } guest_pml4e = (pml4e64_t *)&(guest_pml[PML4E64_INDEX(fault_addr)]); - PrintDebug("Checking Guest %p\n", (void *)guest_pml); + PrintDebug(info->vm_info, info, "Checking Guest %p\n", (void *)guest_pml); // Check the guest page permissions guest_pml4e_access = v3_can_access_pml4e64(guest_pml, fault_addr, error_code); - PrintDebug("Checking shadow %p\n", (void *)shadow_pml); + PrintDebug(info->vm_info, info, "Checking shadow %p\n", (void *)shadow_pml); // Check the shadow page permissions shadow_pml4e_access = v3_can_access_pml4e64(shadow_pml, fault_addr, error_code); /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pml4e_access, shadow_pml4e_access) == 1) { - PrintDebug("Injecting PML4E pf to guest: (guest access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Injecting PML4E pf to guest: (guest access error=%d) (pf error code=%d)\n", *(uint_t *)&guest_pml4e_access, *(uint_t *)&error_code); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } return 0; @@ -107,10 +107,10 @@ static inline int handle_shadow_pagefault_64(struct guest_info * info, addr_t fa // // PML4 Entry marked non-user // - PrintDebug("Shadow Paging User access error (shadow_pml4e_access=0x%x, guest_pml4e_access=0x%x)\n", + PrintDebug(info->vm_info, info, "Shadow Paging User access error (shadow_pml4e_access=0x%x, guest_pml4e_access=0x%x)\n", shadow_pml4e_access, guest_pml4e_access); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } return 0; @@ -118,11 +118,11 @@ static inline int handle_shadow_pagefault_64(struct guest_info * info, addr_t fa (shadow_pml4e_access != PT_ACCESS_OK)) { // inject page fault in guest if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } - PrintDebug("Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pml4e_access); - PrintDebug("Manual Says to inject page fault into guest\n"); + PrintDebug(info->vm_info, info, "Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pml4e_access); + PrintDebug(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return 0; } @@ -154,13 +154,13 @@ static inline int handle_shadow_pagefault_64(struct guest_info * info, addr_t fa if (v3_gpa_to_hva(info, BASE_TO_PAGE_ADDR(guest_pml4e->pdp_base_addr), (addr_t *)&guest_pdp) == -1) { // Machine check the guest - PrintError("Invalid Guest PDP Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pml4e->pdp_base_addr)); + PrintError(info->vm_info, info, "Invalid Guest PDP Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pml4e->pdp_base_addr)); v3_raise_exception(info, MC_EXCEPTION); return 0; } if (handle_pdpe_shadow_pagefault_64(info, fault_addr, error_code, shadow_pdp, guest_pdp) == -1) { - PrintError("Error handling Page fault caused by PDPE\n"); + PrintError(info->vm_info, info, "Error handling Page fault caused by PDPE\n"); return -1; } @@ -177,12 +177,12 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * info, addr_t faul pdpe64_t * guest_pdpe = (pdpe64_t *)&(guest_pdp[PDPE64_INDEX(fault_addr)]); pdpe64_t * shadow_pdpe = (pdpe64_t *)&(shadow_pdp[PDPE64_INDEX(fault_addr)]); - PrintDebug("Handling PDP fault\n"); + PrintDebug(info->vm_info, info, "Handling PDP fault\n"); if (fault_addr==0) { - PrintDebug("Guest Page Tree for guest virtual address zero fault\n"); + PrintDebug(info->vm_info, info, "Guest Page Tree for guest virtual address zero fault\n"); PrintGuestPageTree(info,fault_addr,(addr_t)(info->shdw_pg_state.guest_cr3)); - PrintDebug("Host Page Tree for guest virtual address zero fault\n"); + PrintDebug(info->vm_info, info, "Host Page Tree for guest virtual address zero fault\n"); PrintHostPageTree(info,fault_addr,(addr_t)(info->ctrl_regs.cr3)); } @@ -194,10 +194,10 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * info, addr_t faul /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pdpe_access, shadow_pdpe_access) == 1) { - PrintDebug("Injecting PDPE pf to guest: (guest access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Injecting PDPE pf to guest: (guest access error=%d) (pf error code=%d)\n", *(uint_t *)&guest_pdpe_access, *(uint_t *)&error_code); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } return 0; @@ -207,10 +207,10 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * info, addr_t faul // // PML4 Entry marked non-user // - PrintDebug("Shadow Paging User access error (shadow_pdpe_access=0x%x, guest_pdpe_access=0x%x)\n", + PrintDebug(info->vm_info, info, "Shadow Paging User access error (shadow_pdpe_access=0x%x, guest_pdpe_access=0x%x)\n", shadow_pdpe_access, guest_pdpe_access); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } return 0; @@ -218,11 +218,11 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * info, addr_t faul (shadow_pdpe_access != PT_ACCESS_OK)) { // inject page fault in guest if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } - PrintDebug("Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pdpe_access); - PrintDebug("Manual Says to inject page fault into guest\n"); + PrintDebug(info->vm_info, info, "Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pdpe_access); + PrintDebug(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return 0; } @@ -255,13 +255,13 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * info, addr_t faul if (v3_gpa_to_hva(info, BASE_TO_PAGE_ADDR(guest_pdpe->pd_base_addr), (addr_t *)&guest_pd) == -1) { // Machine check the guest - PrintError("Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pdpe->pd_base_addr)); + PrintError(info->vm_info, info, "Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pdpe->pd_base_addr)); v3_raise_exception(info, MC_EXCEPTION); return 0; } if (handle_pde_shadow_pagefault_64(info, fault_addr, error_code, shadow_pd, guest_pd) == -1) { - PrintError("Error handling Page fault caused by PDE\n"); + PrintError(info->vm_info, info, "Error handling Page fault caused by PDE\n"); return -1; } @@ -276,7 +276,7 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault pde64_t * guest_pde = (pde64_t *)&(guest_pd[PDE64_INDEX(fault_addr)]); pde64_t * shadow_pde = (pde64_t *)&(shadow_pd[PDE64_INDEX(fault_addr)]); - PrintDebug("Handling PDE fault\n"); + PrintDebug(info->vm_info, info, "Handling PDE fault\n"); // Check the guest page permissions guest_pde_access = v3_can_access_pde64(guest_pd, fault_addr, error_code); @@ -286,10 +286,10 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pde_access, shadow_pde_access) == 1) { - PrintDebug("Injecting PDE pf to guest: (guest access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Injecting PDE pf to guest: (guest access error=%d) (pf error code=%d)\n", *(uint_t *)&guest_pde_access, *(uint_t *)&error_code); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } return 0; @@ -299,10 +299,10 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault // // PDE Entry marked non-user // - PrintDebug("Shadow Paging User access error (shadow_pdpe_access=0x%x, guest_pdpe_access=0x%x)\n", + PrintDebug(info->vm_info, info, "Shadow Paging User access error (shadow_pdpe_access=0x%x, guest_pdpe_access=0x%x)\n", shadow_pde_access, guest_pde_access); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } return 0; @@ -313,7 +313,7 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault ((pde64_2MB_t *)guest_pde)->dirty = 1; shadow_pde->writable = guest_pde->writable; - //PrintDebug("Returning due to large page Write Error\n"); + //PrintDebug(info->vm_info, info, "Returning due to large page Write Error\n"); //PrintHostPageTree(info, fault_addr, info->ctrl_regs.cr3); return 0; @@ -321,11 +321,11 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault (shadow_pde_access != PT_ACCESS_OK)) { // inject page fault in guest if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } - PrintDebug("Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pde_access); - PrintDebug("Manual Says to inject page fault into guest\n"); + PrintDebug(info->vm_info, info, "Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pde_access); + PrintDebug(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return 0; } @@ -339,7 +339,7 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault struct shadow_page_data * shdw_page = create_new_shadow_pt(info); shadow_pt = (pte64_t *)V3_VAddr((void *)shdw_page->page_pa); - PrintDebug("Creating new shadow PT: %p\n", shadow_pt); + PrintDebug(info->vm_info, info, "Creating new shadow PT: %p\n", shadow_pt); shadow_pde->present = 1; shadow_pde->user_page = guest_pde->user_page; @@ -377,18 +377,18 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault if (guest_pde->large_page == 0) { if (v3_gpa_to_hva(info, BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr), (addr_t *)&guest_pt) == -1) { // Machine check the guest - PrintError("Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); + PrintError(info->vm_info, info, "Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); v3_raise_exception(info, MC_EXCEPTION); return 0; } if (handle_pte_shadow_pagefault_64(info, fault_addr, error_code, shadow_pt, guest_pt) == -1) { - PrintError("Error handling Page fault caused by PDE\n"); + PrintError(info->vm_info, info, "Error handling Page fault caused by PDE\n"); return -1; } } else { if (handle_2MB_shadow_pagefault_64(info, fault_addr, error_code, shadow_pt, (pde64_2MB_t *)guest_pde) == -1) { - PrintError("Error handling large pagefault\n"); + PrintError(info->vm_info, info, "Error handling large pagefault\n"); return -1; } } @@ -406,7 +406,7 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault addr_t guest_pa = BASE_TO_PAGE_ADDR((addr_t)(guest_pte->page_base_addr)) + PAGE_OFFSET(fault_addr); // struct shadow_page_state * state = &(info->shdw_pg_state); - PrintDebug("Handling PTE fault\n"); + PrintDebug(info->vm_info, info, "Handling PTE fault\n"); struct v3_mem_region * shdw_reg = v3_get_mem_region(info->vm_info, info->vcpu_id, guest_pa); @@ -414,7 +414,7 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintError("Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); + PrintError(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); v3_raise_exception(info, MC_EXCEPTION); return 0; } @@ -428,11 +428,11 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pte_access, shadow_pte_access) == 1) { - PrintDebug("Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", guest_pte_access, *(uint_t*)&error_code); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } @@ -443,21 +443,21 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault if (shadow_pte_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush page tables and everything should now work - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(info->vm_info, info, "Inconsistent state... Guest re-entry should flush tlb\n"); return 0; } if (shadow_pte_access == PT_ACCESS_NOT_PRESENT) { // Page Table Entry Not Present - PrintDebug("guest_pa =%p\n", (void *)guest_pa); + PrintDebug(info->vm_info, info, "guest_pa =%p\n", (void *)guest_pa); if ((shdw_reg->flags.alloced == 1) || (shdw_reg->flags.read == 1)) { addr_t shadow_pa = 0; if (v3_gpa_to_hpa(info, guest_pa, &shadow_pa) == -1) { - PrintError("could not translate page fault address (%p)\n", (void *)guest_pa); + PrintError(info->vm_info, info, "could not translate page fault address (%p)\n", (void *)guest_pa); return -1; } @@ -493,7 +493,7 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault // Page fault handled by hook functions if (shdw_reg->unhandled(info, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -503,11 +503,11 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault if (shdw_reg->flags.write == 1) { - PrintDebug("Shadow PTE Write Error\n"); + PrintDebug(info->vm_info, info, "Shadow PTE Write Error\n"); shadow_pte->writable = guest_pte->writable; } else { if (shdw_reg->unhandled(info, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -518,11 +518,11 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault } else { // Inject page fault into the guest if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } - PrintError("PTE Page fault fell through... Not sure if this should ever happen\n"); - PrintError("Manual Says to inject page fault into guest\n"); + PrintError(info->vm_info, info, "PTE Page fault fell through... Not sure if this should ever happen\n"); + PrintError(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return -1; } @@ -540,15 +540,15 @@ static int handle_2MB_shadow_pagefault_64(struct guest_info * info, addr_t guest_fault_pa = BASE_TO_PAGE_ADDR_2MB(large_guest_pde->page_base_addr) + PAGE_OFFSET_2MB(fault_addr); // struct shadow_page_state * state = &(info->shdw_pg_state); - PrintDebug("Handling 2MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); - PrintDebug("ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); + PrintDebug(info->vm_info, info, "Handling 2MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); + PrintDebug(info->vm_info, info, "ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); struct v3_mem_region * shdw_reg = v3_get_mem_region(info->vm_info, info->vcpu_id, guest_fault_pa); if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintError("Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); + PrintError(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); v3_raise_exception(info, MC_EXCEPTION); return 0; } @@ -556,7 +556,7 @@ static int handle_2MB_shadow_pagefault_64(struct guest_info * info, if (shadow_pte_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush tables and everything should now workd - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(info->vm_info, info, "Inconsistent state... Guest re-entry should flush tlb\n"); //PrintHostPageTree(info, fault_addr, info->ctrl_regs.cr3); return 0; } @@ -570,7 +570,7 @@ static int handle_2MB_shadow_pagefault_64(struct guest_info * info, addr_t shadow_pa = 0; if (v3_gpa_to_hpa(info, guest_fault_pa, &shadow_pa) == -1) { - PrintError("could not translate page fault address (%p)\n", (void *)guest_fault_pa); + PrintError(info->vm_info, info, "could not translate page fault address (%p)\n", (void *)guest_fault_pa); return -1; } @@ -599,25 +599,25 @@ static int handle_2MB_shadow_pagefault_64(struct guest_info * info, } else { if (shdw_reg->unhandled(info, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } } else if (shadow_pte_access == PT_ACCESS_WRITE_ERROR) { if (shdw_reg->unhandled(info, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } else { - PrintError("Error in large page fault handler...\n"); - PrintError("This case should have been handled at the top level handler\n"); + PrintError(info->vm_info, info, "Error in large page fault handler...\n"); + PrintError(info->vm_info, info, "This case should have been handled at the top level handler\n"); return -1; } // PrintHostPageTree(info, fault_addr, info->ctrl_regs.cr3); - PrintDebug("Returning from large page fault handler\n"); + PrintDebug(info->vm_info, info, "Returning from large page fault handler\n"); return 0; } @@ -648,7 +648,7 @@ static int invalidation_cb_64(struct guest_info * info, page_type_t type, } if (pdpe->vmm_info == V3_LARGE_PG) { - PrintError("1 Gigabyte pages not supported\n"); + PrintError(info->vm_info, info, "1 Gigabyte pages not supported\n"); return -1; pdpe->present = 0; @@ -682,23 +682,23 @@ static int invalidation_cb_64(struct guest_info * info, page_type_t type, return 1; } default: - PrintError("Invalid Page Type\n"); + PrintError(info->vm_info, info, "Invalid Page Type\n"); return -1; } // should not get here - PrintError("Should not get here....\n"); + PrintError(info->vm_info, info, "Should not get here....\n"); return -1; } static inline int handle_shadow_invlpg_64(struct guest_info * info, addr_t vaddr) { - PrintDebug("INVLPG64 - %p\n",(void*)vaddr); + PrintDebug(info->vm_info, info, "INVLPG64 - %p\n",(void*)vaddr); int ret = v3_drill_host_pt_64(info, info->ctrl_regs.cr3, vaddr, invalidation_cb_64, NULL); if (ret == -1) { - PrintError("Page table drill returned error.... \n"); + PrintError(info->vm_info, info, "Page table drill returned error.... \n"); PrintHostPageTree(info, vaddr, info->ctrl_regs.cr3); } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_tlb.c b/palacios/src/palacios/mmu/vmm_shdw_pg_tlb.c index 06e416a..02be430 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_tlb.c +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_tlb.c @@ -65,7 +65,7 @@ static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core) if (page_tail->cr3 != cur_cr3) { - PrintDebug("Reusing old shadow Page: %p (cur_CR3=%p)(page_cr3=%p) \n", + PrintDebug(core->vm_info, core, "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)); @@ -84,18 +84,18 @@ static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core) page_tail = (struct shadow_page_data *)V3_Malloc(sizeof(struct shadow_page_data)); if (!page_tail) { - PrintError("Cannot allocate\n"); + PrintError(core->vm_info, core, "Cannot allocate\n"); return NULL; } page_tail->page_pa = (addr_t)V3_AllocPages(1); if (!page_tail->page_pa) { - PrintError("Cannot allocate page\n"); + PrintError(core->vm_info, core, "Cannot allocate page\n"); return NULL; } - PrintDebug("Allocating new shadow Page: %p (cur_cr3=%p)\n", + PrintDebug(core->vm_info, core, "Allocating new shadow Page: %p (cur_cr3=%p)\n", (void *)(addr_t)page_tail->page_pa, (void *)(addr_t)cur_cr3); @@ -112,7 +112,7 @@ static struct shadow_page_data * create_new_shadow_pt(struct guest_info * core) static int vtlb_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { - V3_Print("VTLB initialization\n"); + V3_Print(vm, VCORE_NONE, "VTLB initialization\n"); return 0; } @@ -124,12 +124,12 @@ static int vtlb_local_init(struct guest_info * core) { struct v3_shdw_pg_state * state = &(core->shdw_pg_state); struct vtlb_local_state * vtlb_state = NULL; - V3_Print("VTLB local initialization\n"); + V3_Print(core->vm_info, core, "VTLB local initialization\n"); vtlb_state = (struct vtlb_local_state *)V3_Malloc(sizeof(struct vtlb_local_state)); if (!vtlb_state) { - PrintError("Cannot allocate\n"); + PrintError(core->vm_info, core, "Cannot allocate\n"); return -1; } @@ -174,7 +174,7 @@ static int vtlb_activate_shdw_pt(struct guest_info * core) { case LONG_16_COMPAT: return activate_shadow_pt_64(core); default: - PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(core->vm_info, core, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } @@ -200,7 +200,7 @@ static int vtlb_handle_pf(struct guest_info * core, addr_t fault_addr, pf_error_ return handle_shadow_pagefault_64(core, fault_addr, error_code); break; default: - PrintError("Unhandled CPU Mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(core->vm_info, core, "Unhandled CPU Mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } } @@ -218,7 +218,7 @@ static int vtlb_handle_invlpg(struct guest_info * core, addr_t vaddr) { case LONG_16_COMPAT: return handle_shadow_invlpg_64(core, vaddr); default: - PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(core->vm_info, core, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_tlb_32.h b/palacios/src/palacios/mmu/vmm_shdw_pg_tlb_32.h index e638056..502e5e5 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_tlb_32.h +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_tlb_32.h @@ -28,7 +28,7 @@ static inline int activate_shadow_pt_32(struct guest_info * core) { shdw_page->cr3 = shdw_page->page_pa; shadow_cr3->pdt_base_addr = PAGE_BASE_ADDR_4KB(shdw_page->page_pa); - PrintDebug( "Created new shadow page table %p\n", (void *)BASE_TO_PAGE_ADDR(shadow_cr3->pdt_base_addr)); + PrintDebug(core->vm_info, core, "Created new shadow page table %p\n", (void *)BASE_TO_PAGE_ADDR(shadow_cr3->pdt_base_addr)); shadow_cr3->pwt = guest_cr3->pwt; shadow_cr3->pcd = guest_cr3->pcd; @@ -65,11 +65,11 @@ static inline int handle_shadow_pagefault_32(struct guest_info * info, addr_t fa pde32_t * guest_pde = NULL; pde32_t * shadow_pde = (pde32_t *)&(shadow_pd[PDE32_INDEX(fault_addr)]); - PrintDebug("Shadow page fault handler: %p\n", (void*) fault_addr ); - PrintDebug("Handling PDE32 Fault\n"); + PrintDebug(info->vm_info, info, "Shadow page fault handler: %p\n", (void*) fault_addr ); + PrintDebug(info->vm_info, info, "Handling PDE32 Fault\n"); if (v3_gpa_to_hva(info, guest_cr3, (addr_t*)&guest_pd) == -1) { - PrintError("Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); + PrintError(info->vm_info, info, "Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); return -1; } @@ -84,10 +84,10 @@ static inline int handle_shadow_pagefault_32(struct guest_info * info, addr_t fa /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pde_access, shadow_pde_access) == 1) { - PrintDebug("Injecting PDE pf to guest: (guest access error=%d) (shdw access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Injecting PDE pf to guest: (guest access error=%d) (shdw access error=%d) (pf error code=%d)\n", *(uint_t *)&guest_pde_access, *(uint_t *)&shadow_pde_access, *(uint_t *)&error_code); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } return 0; @@ -99,11 +99,11 @@ static inline int handle_shadow_pagefault_32(struct guest_info * info, addr_t fa // // PDE Entry marked non user // - PrintDebug("Shadow Paging User access error (shadow_pde_access=0x%x, guest_pde_access=0x%x)\n", + PrintDebug(info->vm_info, info, "Shadow Paging User access error (shadow_pde_access=0x%x, guest_pde_access=0x%x)\n", shadow_pde_access, guest_pde_access); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } return 0; @@ -117,11 +117,11 @@ static inline int handle_shadow_pagefault_32(struct guest_info * info, addr_t fa (shadow_pde_access != PT_ACCESS_OK)) { // inject page fault in guest if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } - PrintDebug("Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pde_access); - PrintDebug("Manual Says to inject page fault into guest\n"); + PrintDebug(info->vm_info, info, "Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pde_access); + PrintDebug(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return 0; } @@ -139,10 +139,10 @@ static inline int handle_shadow_pagefault_32(struct guest_info * info, addr_t fa uint32_t page_size = v3_get_max_page_size(info, guest_pa, PROTECTED); if (page_size == PAGE_SIZE_4MB) { - PrintDebug("using large page for fault_addr %p (gpa=%p)\n", (void *)fault_addr, (void *)guest_pa); + PrintDebug(info->vm_info, info, "using large page for fault_addr %p (gpa=%p)\n", (void *)fault_addr, (void *)guest_pa); if (handle_4MB_shadow_pagefault_pde_32(info, fault_addr, error_code, shadow_pde_access, (pde32_4MB_t *)shadow_pde, (pde32_4MB_t *)guest_pde) == -1) { - PrintError("Error handling large pagefault with large page\n"); + PrintError(info->vm_info, info, "Error handling large pagefault with large page\n"); return -1; } @@ -189,18 +189,18 @@ static inline int handle_shadow_pagefault_32(struct guest_info * info, addr_t fa if (guest_pde->large_page == 0) { if (v3_gpa_to_hva(info, BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr), (addr_t*)&guest_pt) == -1) { // Machine check the guest - PrintDebug("Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); + PrintDebug(info->vm_info, info, "Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); v3_raise_exception(info, MC_EXCEPTION); return 0; } if (handle_pte_shadow_pagefault_32(info, fault_addr, error_code, shadow_pt, guest_pt) == -1) { - PrintError("Error handling Page fault caused by PTE\n"); + PrintError(info->vm_info, info, "Error handling Page fault caused by PTE\n"); return -1; } } else { if (handle_4MB_shadow_pagefault_pte_32(info, fault_addr, error_code, shadow_pt, (pde32_4MB_t *)guest_pde) == -1) { - PrintError("Error handling large pagefault\n"); + PrintError(info->vm_info, info, "Error handling large pagefault\n"); return -1; } } @@ -222,7 +222,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintDebug("Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); + PrintDebug(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); v3_raise_exception(info, MC_EXCEPTION); return 0; } @@ -237,13 +237,13 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pte_access, shadow_pte_access) == 1) { - PrintDebug("Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", guest_pte_access, *(uint_t*)&error_code); // inject: if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } @@ -255,26 +255,26 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault if (shadow_pte_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush page tables and everything should now work - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(info->vm_info, info, "Inconsistent state... Guest re-entry should flush tlb\n"); return 0; } if (shadow_pte_access == PT_ACCESS_NOT_PRESENT) { // Page Table Entry Not Present - PrintDebug("guest_pa =%p\n", (void *)guest_pa); + PrintDebug(info->vm_info, info, "guest_pa =%p\n", (void *)guest_pa); if ((shdw_reg->flags.alloced == 1) && (shdw_reg->flags.read == 1)) { addr_t shadow_pa = 0; if (v3_gpa_to_hpa(info, guest_pa, &shadow_pa) == -1) { - PrintError("could not translate page fault address (%p)\n", (void *)guest_pa); + PrintError(info->vm_info, info, "could not translate page fault address (%p)\n", (void *)guest_pa); return -1; } shadow_pte->page_base_addr = PAGE_BASE_ADDR(shadow_pa); - PrintDebug("\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); + PrintDebug(info->vm_info, info, "\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); shadow_pte->present = guest_pte->present; shadow_pte->user_page = guest_pte->user_page; @@ -305,7 +305,7 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault // Page fault on unhandled memory region if (shdw_reg->unhandled(info, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -313,11 +313,11 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault guest_pte->dirty = 1; if (shdw_reg->flags.write == 1) { - PrintDebug("Shadow PTE Write Error\n"); + PrintDebug(info->vm_info, info, "Shadow PTE Write Error\n"); shadow_pte->writable = guest_pte->writable; } else { if (shdw_reg->unhandled(info, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -328,12 +328,12 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault } else { // Inject page fault into the guest if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not inject guest page fault for vaddr %p\n", (void *)fault_addr); return -1; } - PrintError("PTE Page fault fell through... Not sure if this should ever happen\n"); - PrintError("Manual Says to inject page fault into guest\n"); + PrintError(info->vm_info, info, "PTE Page fault fell through... Not sure if this should ever happen\n"); + PrintError(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return -1; } @@ -350,15 +350,15 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * info, addr_t guest_fault_pa = BASE_TO_PAGE_ADDR_4MB(large_guest_pde->page_base_addr) + PAGE_OFFSET_4MB(fault_addr); - PrintDebug("Handling 4MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); - PrintDebug("ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); + PrintDebug(info->vm_info, info, "Handling 4MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); + PrintDebug(info->vm_info, info, "ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); struct v3_mem_region * shdw_reg = v3_get_mem_region(info->vm_info, info->vcpu_id, guest_fault_pa); if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintDebug("Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); + PrintDebug(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); v3_raise_exception(info, MC_EXCEPTION); return -1; } @@ -366,7 +366,7 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * info, if (shadow_pte_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush tables and everything should now workd - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(info->vm_info, info, "Inconsistent state... Guest re-entry should flush tlb\n"); return 0; } @@ -380,13 +380,13 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * info, if (v3_gpa_to_hpa(info, guest_fault_pa, &shadow_pa) == -1) { - PrintError("could not translate page fault address (%p)\n", (void *)guest_fault_pa); + PrintError(info->vm_info, info, "could not translate page fault address (%p)\n", (void *)guest_fault_pa); return -1; } shadow_pte->page_base_addr = PAGE_BASE_ADDR(shadow_pa); - PrintDebug("\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); + PrintDebug(info->vm_info, info, "\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR(shadow_pte->page_base_addr)); shadow_pte->present = 1; @@ -412,7 +412,7 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * info, } else { if (shdw_reg->unhandled(info, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -420,18 +420,18 @@ static int handle_4MB_shadow_pagefault_pte_32(struct guest_info * info, if (shdw_reg->flags.write == 0) { if (shdw_reg->unhandled(info, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } } else { - PrintError("Error in large page fault handler...\n"); - PrintError("This case should have been handled at the top level handler\n"); + PrintError(info->vm_info, info, "Error in large page fault handler...\n"); + PrintError(info->vm_info, info, "This case should have been handled at the top level handler\n"); return -1; } - PrintDebug("Returning from large page->small page fault handler\n"); + PrintDebug(info->vm_info, info, "Returning from large page->small page fault handler\n"); return 0; } @@ -445,15 +445,15 @@ static int handle_4MB_shadow_pagefault_pde_32(struct guest_info * info, addr_t guest_fault_pa = BASE_TO_PAGE_ADDR_4MB(large_guest_pde->page_base_addr) + PAGE_OFFSET_4MB(fault_addr); - PrintDebug("Handling 4MB fault with large page (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); - PrintDebug("LargeShadowPDE=%p, LargeGuestPDE=%p\n", large_shadow_pde, large_guest_pde); + PrintDebug(info->vm_info, info, "Handling 4MB fault with large page (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); + PrintDebug(info->vm_info, info, "LargeShadowPDE=%p, LargeGuestPDE=%p\n", large_shadow_pde, large_guest_pde); struct v3_mem_region * shdw_reg = v3_get_mem_region(info->vm_info, info->vcpu_id, guest_fault_pa); if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintDebug("Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); + PrintDebug(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); v3_raise_exception(info, MC_EXCEPTION); return -1; } @@ -461,7 +461,7 @@ static int handle_4MB_shadow_pagefault_pde_32(struct guest_info * info, if (shadow_pde_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush tables and everything should now workd - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(info->vm_info, info, "Inconsistent state... Guest re-entry should flush tlb\n"); return 0; } @@ -475,11 +475,11 @@ static int handle_4MB_shadow_pagefault_pde_32(struct guest_info * info, if (v3_gpa_to_hpa(info, guest_fault_pa, &shadow_pa) == -1) { - PrintError("could not translate page fault address (%p)\n", (void *)guest_fault_pa); + PrintError(info->vm_info, info, "could not translate page fault address (%p)\n", (void *)guest_fault_pa); return -1; } - PrintDebug("shadow PA = %p\n", (void *)shadow_pa); + PrintDebug(info->vm_info, info, "shadow PA = %p\n", (void *)shadow_pa); large_guest_pde->vmm_info = V3_LARGE_PG; /* For invalidations */ @@ -488,7 +488,7 @@ static int handle_4MB_shadow_pagefault_pde_32(struct guest_info * info, large_shadow_pde->present = 1; large_shadow_pde->user_page = 1; - PrintDebug("\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR_4MB(large_shadow_pde->page_base_addr)); + PrintDebug(info->vm_info, info, "\tMapping shadow page (%p)\n", (void *)BASE_TO_PAGE_ADDR_4MB(large_shadow_pde->page_base_addr)); if (shdw_reg->flags.write == 0) { large_shadow_pde->writable = 0; @@ -504,7 +504,7 @@ static int handle_4MB_shadow_pagefault_pde_32(struct guest_info * info, } else { if (shdw_reg->unhandled(info, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -512,18 +512,18 @@ static int handle_4MB_shadow_pagefault_pde_32(struct guest_info * info, if (shdw_reg->flags.write == 0) { if (shdw_reg->unhandled(info, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } } else { - PrintError("Error in large page fault handler...\n"); - PrintError("This case should have been handled at the top level handler\n"); + PrintError(info->vm_info, info, "Error in large page fault handler...\n"); + PrintError(info->vm_info, info, "This case should have been handled at the top level handler\n"); return -1; } - PrintDebug("Returning from large page->large page fault handler\n"); + PrintDebug(info->vm_info, info, "Returning from large page->large page fault handler\n"); return 0; } @@ -537,7 +537,7 @@ static inline int handle_shadow_invlpg_32(struct guest_info * info, addr_t vaddr pde32_t * guest_pde; if (v3_gpa_to_hva(info, guest_cr3, (addr_t*)&guest_pd) == -1) { - PrintError("Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); + PrintError(info->vm_info, info, "Invalid Guest PDE Address: 0x%p\n", (void *)guest_cr3); return -1; } @@ -545,12 +545,12 @@ static inline int handle_shadow_invlpg_32(struct guest_info * info, addr_t vaddr if (guest_pde->large_page == 1) { shadow_pde->present = 0; - PrintDebug("Invalidating Large Page\n"); + PrintDebug(info->vm_info, info, "Invalidating Large Page\n"); } else if (shadow_pde->present == 1) { pte32_t * shadow_pt = (pte32_t *)(addr_t)BASE_TO_PAGE_ADDR_4KB(shadow_pde->pt_base_addr); pte32_t * shadow_pte = (pte32_t *) V3_VAddr( (void*) &shadow_pt[PTE32_INDEX(vaddr)] ); - PrintDebug("Setting not present\n"); + PrintDebug(info->vm_info, info, "Setting not present\n"); shadow_pte->present = 0; } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_tlb_32pae.h b/palacios/src/palacios/mmu/vmm_shdw_pg_tlb_32pae.h index d6ef1c7..2c79599 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_tlb_32pae.h +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_tlb_32pae.h @@ -19,7 +19,7 @@ static inline int activate_shadow_pt_32pae(struct guest_info * info) { - PrintError("Activating 32 bit PAE page tables not implemented\n"); + PrintError(info->vm_info, info, "Activating 32 bit PAE page tables not implemented\n"); return -1; } @@ -37,13 +37,13 @@ static inline int activate_shadow_pt_32pae(struct guest_info * info) { */ static inline int handle_shadow_pagefault_32pae(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) { - PrintError("32 bit PAE shadow paging not implemented\n"); + PrintError(info->vm_info, info, "32 bit PAE shadow paging not implemented\n"); return -1; } static inline int handle_shadow_invlpg_32pae(struct guest_info * info, addr_t vaddr) { - PrintError("32 bit PAE shadow paging not implemented\n"); + PrintError(info->vm_info, info, "32 bit PAE shadow paging not implemented\n"); return -1; } diff --git a/palacios/src/palacios/mmu/vmm_shdw_pg_tlb_64.h b/palacios/src/palacios/mmu/vmm_shdw_pg_tlb_64.h index 4f31b7f..76d22f9 100644 --- a/palacios/src/palacios/mmu/vmm_shdw_pg_tlb_64.h +++ b/palacios/src/palacios/mmu/vmm_shdw_pg_tlb_64.h @@ -27,10 +27,10 @@ static inline int activate_shadow_pt_64(struct guest_info * info) { // Because this is a new CR3 load the allocated page is the new CR3 value shadow_pt->cr3 = shadow_pt->page_pa; - PrintDebug("Top level Shadow page pa=%p\n", (void *)shadow_pt_addr); + PrintDebug(info->vm_info, info, "Top level Shadow page pa=%p\n", (void *)shadow_pt_addr); shadow_cr3->pml4t_base_addr = PAGE_BASE_ADDR_4KB(shadow_pt_addr); - PrintDebug("Creating new 64 bit shadow page table %p\n", (void *)BASE_TO_PAGE_ADDR(shadow_cr3->pml4t_base_addr)); + PrintDebug(info->vm_info, info, "Creating new 64 bit shadow page table %p\n", (void *)BASE_TO_PAGE_ADDR(shadow_cr3->pml4t_base_addr)); shadow_cr3->pwt = guest_cr3->pwt; @@ -77,30 +77,30 @@ static inline int handle_shadow_pagefault_64(struct guest_info * info, addr_t fa pml4e64_t * guest_pml4e = NULL; pml4e64_t * shadow_pml4e = (pml4e64_t *)&(shadow_pml[PML4E64_INDEX(fault_addr)]); - PrintDebug("64 bit Shadow page fault handler: %p\n", (void *)fault_addr); - PrintDebug("Handling PML fault\n"); + PrintDebug(info->vm_info, info, "64 bit Shadow page fault handler: %p\n", (void *)fault_addr); + PrintDebug(info->vm_info, info, "Handling PML fault\n"); if (v3_gpa_to_hva(info, guest_cr3, (addr_t*)&guest_pml) == -1) { - PrintError("Invalid Guest PML4E Address: 0x%p\n", (void *)guest_cr3); + PrintError(info->vm_info, info, "Invalid Guest PML4E Address: 0x%p\n", (void *)guest_cr3); return -1; } guest_pml4e = (pml4e64_t *)&(guest_pml[PML4E64_INDEX(fault_addr)]); - PrintDebug("Checking Guest %p\n", (void *)guest_pml); + PrintDebug(info->vm_info, info, "Checking Guest %p\n", (void *)guest_pml); // Check the guest page permissions guest_pml4e_access = v3_can_access_pml4e64(guest_pml, fault_addr, error_code); - PrintDebug("Checking shadow %p\n", (void *)shadow_pml); + PrintDebug(info->vm_info, info, "Checking shadow %p\n", (void *)shadow_pml); // Check the shadow page permissions shadow_pml4e_access = v3_can_access_pml4e64(shadow_pml, fault_addr, error_code); /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pml4e_access, shadow_pml4e_access) == 1) { - PrintDebug("Injecting PML4E pf to guest: (guest access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Injecting PML4E pf to guest: (guest access error=%d) (pf error code=%d)\n", *(uint_t *)&guest_pml4e_access, *(uint_t *)&error_code); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } return 0; @@ -110,10 +110,10 @@ static inline int handle_shadow_pagefault_64(struct guest_info * info, addr_t fa // // PML4 Entry marked non-user // - PrintDebug("Shadow Paging User access error (shadow_pml4e_access=0x%x, guest_pml4e_access=0x%x)\n", + PrintDebug(info->vm_info, info, "Shadow Paging User access error (shadow_pml4e_access=0x%x, guest_pml4e_access=0x%x)\n", shadow_pml4e_access, guest_pml4e_access); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } return 0; @@ -121,11 +121,11 @@ static inline int handle_shadow_pagefault_64(struct guest_info * info, addr_t fa (shadow_pml4e_access != PT_ACCESS_OK)) { // inject page fault in guest if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } - PrintDebug("Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pml4e_access); - PrintDebug("Manual Says to inject page fault into guest\n"); + PrintDebug(info->vm_info, info, "Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pml4e_access); + PrintDebug(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return 0; } @@ -157,13 +157,13 @@ static inline int handle_shadow_pagefault_64(struct guest_info * info, addr_t fa if (v3_gpa_to_hva(info, BASE_TO_PAGE_ADDR(guest_pml4e->pdp_base_addr), (addr_t *)&guest_pdp) == -1) { // Machine check the guest - PrintError("Invalid Guest PDP Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pml4e->pdp_base_addr)); + PrintError(info->vm_info, info, "Invalid Guest PDP Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pml4e->pdp_base_addr)); v3_raise_exception(info, MC_EXCEPTION); return 0; } if (handle_pdpe_shadow_pagefault_64(info, fault_addr, error_code, shadow_pdp, guest_pdp) == -1) { - PrintError("Error handling Page fault caused by PDPE\n"); + PrintError(info->vm_info, info, "Error handling Page fault caused by PDPE\n"); return -1; } @@ -180,12 +180,12 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * info, addr_t faul pdpe64_t * guest_pdpe = (pdpe64_t *)&(guest_pdp[PDPE64_INDEX(fault_addr)]); pdpe64_t * shadow_pdpe = (pdpe64_t *)&(shadow_pdp[PDPE64_INDEX(fault_addr)]); - PrintDebug("Handling PDP fault\n"); + PrintDebug(info->vm_info, info, "Handling PDP fault\n"); if (fault_addr==0) { - PrintDebug("Guest Page Tree for guest virtual address zero fault\n"); + PrintDebug(info->vm_info, info, "Guest Page Tree for guest virtual address zero fault\n"); PrintGuestPageTree(info,fault_addr,(addr_t)(info->shdw_pg_state.guest_cr3)); - PrintDebug("Host Page Tree for guest virtual address zero fault\n"); + PrintDebug(info->vm_info, info, "Host Page Tree for guest virtual address zero fault\n"); PrintHostPageTree(info,fault_addr,(addr_t)(info->ctrl_regs.cr3)); } @@ -197,10 +197,10 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * info, addr_t faul /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pdpe_access, shadow_pdpe_access) == 1) { - PrintDebug("Injecting PDPE pf to guest: (guest access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Injecting PDPE pf to guest: (guest access error=%d) (pf error code=%d)\n", *(uint_t *)&guest_pdpe_access, *(uint_t *)&error_code); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } return 0; @@ -210,10 +210,10 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * info, addr_t faul // // PML4 Entry marked non-user // - PrintDebug("Shadow Paging User access error (shadow_pdpe_access=0x%x, guest_pdpe_access=0x%x)\n", + PrintDebug(info->vm_info, info, "Shadow Paging User access error (shadow_pdpe_access=0x%x, guest_pdpe_access=0x%x)\n", shadow_pdpe_access, guest_pdpe_access); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } return 0; @@ -221,11 +221,11 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * info, addr_t faul (shadow_pdpe_access != PT_ACCESS_OK)) { // inject page fault in guest if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } - PrintDebug("Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pdpe_access); - PrintDebug("Manual Says to inject page fault into guest\n"); + PrintDebug(info->vm_info, info, "Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pdpe_access); + PrintDebug(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return 0; } @@ -258,13 +258,13 @@ static int handle_pdpe_shadow_pagefault_64(struct guest_info * info, addr_t faul if (v3_gpa_to_hva(info, BASE_TO_PAGE_ADDR(guest_pdpe->pd_base_addr), (addr_t *)&guest_pd) == -1) { // Machine check the guest - PrintError("Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pdpe->pd_base_addr)); + PrintError(info->vm_info, info, "Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pdpe->pd_base_addr)); v3_raise_exception(info, MC_EXCEPTION); return 0; } if (handle_pde_shadow_pagefault_64(info, fault_addr, error_code, shadow_pd, guest_pd) == -1) { - PrintError("Error handling Page fault caused by PDE\n"); + PrintError(info->vm_info, info, "Error handling Page fault caused by PDE\n"); return -1; } @@ -278,7 +278,7 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault pde64_t * guest_pde = (pde64_t *)&(guest_pd[PDE64_INDEX(fault_addr)]); pde64_t * shadow_pde = (pde64_t *)&(shadow_pd[PDE64_INDEX(fault_addr)]); - PrintDebug("Handling PDE fault\n"); + PrintDebug(info->vm_info, info, "Handling PDE fault\n"); // Check the guest page permissions guest_pde_access = v3_can_access_pde64(guest_pd, fault_addr, error_code); @@ -288,10 +288,10 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pde_access, shadow_pde_access) == 1) { - PrintDebug("Injecting PDE pf to guest: (guest access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Injecting PDE pf to guest: (guest access error=%d) (pf error code=%d)\n", *(uint_t *)&guest_pde_access, *(uint_t *)&error_code); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } return 0; @@ -301,10 +301,10 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault // // PDE Entry marked non-user // - PrintDebug("Shadow Paging User access error (shadow_pdpe_access=0x%x, guest_pdpe_access=0x%x)\n", + PrintDebug(info->vm_info, info, "Shadow Paging User access error (shadow_pdpe_access=0x%x, guest_pdpe_access=0x%x)\n", shadow_pde_access, guest_pde_access); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } return 0; @@ -315,7 +315,7 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault ((pde64_2MB_t *)guest_pde)->dirty = 1; shadow_pde->writable = guest_pde->writable; - //PrintDebug("Returning due to large page Write Error\n"); + //PrintDebug(info->vm_info, info, "Returning due to large page Write Error\n"); //PrintHostPageTree(info, fault_addr, info->ctrl_regs.cr3); return 0; @@ -323,11 +323,11 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault (shadow_pde_access != PT_ACCESS_OK)) { // inject page fault in guest if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } - PrintDebug("Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pde_access); - PrintDebug("Manual Says to inject page fault into guest\n"); + PrintDebug(info->vm_info, info, "Unknown Error occurred (shadow_pde_access=%d)\n", shadow_pde_access); + PrintDebug(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return 0; } @@ -346,7 +346,7 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault if (page_size == PAGE_SIZE_2MB) { if (handle_2MB_shadow_pagefault_pde_64(info, fault_addr, error_code, shadow_pde_access, (pde64_2MB_t *)shadow_pde, (pde64_2MB_t *)guest_pde) == -1) { - PrintError("Error handling large pagefault with large page\n"); + PrintError(info->vm_info, info, "Error handling large pagefault with large page\n"); return -1; } @@ -358,7 +358,7 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault struct shadow_page_data * shdw_page = create_new_shadow_pt(info); shadow_pt = (pte64_t *)V3_VAddr((void *)shdw_page->page_pa); - PrintDebug("Creating new shadow PT: %p\n", shadow_pt); + PrintDebug(info->vm_info, info, "Creating new shadow PT: %p\n", shadow_pt); shadow_pde->present = 1; shadow_pde->user_page = guest_pde->user_page; @@ -395,18 +395,18 @@ static int handle_pde_shadow_pagefault_64(struct guest_info * info, addr_t fault if (guest_pde->large_page == 0) { if (v3_gpa_to_hva(info, BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr), (addr_t *)&guest_pt) == -1) { // Machine check the guest - PrintError("Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); + PrintError(info->vm_info, info, "Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr)); v3_raise_exception(info, MC_EXCEPTION); return 0; } if (handle_pte_shadow_pagefault_64(info, fault_addr, error_code, shadow_pt, guest_pt) == -1) { - PrintError("Error handling Page fault caused by PDE\n"); + PrintError(info->vm_info, info, "Error handling Page fault caused by PDE\n"); return -1; } } else { if (handle_2MB_shadow_pagefault_pte_64(info, fault_addr, error_code, shadow_pt, (pde64_2MB_t *)guest_pde) == -1) { - PrintError("Error handling large pagefault with small page\n"); + PrintError(info->vm_info, info, "Error handling large pagefault with small page\n"); return -1; } } @@ -424,7 +424,7 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault addr_t guest_pa = BASE_TO_PAGE_ADDR((addr_t)(guest_pte->page_base_addr)) + PAGE_OFFSET(fault_addr); // struct shadow_page_state * state = &(info->shdw_pg_state); - PrintDebug("Handling PTE fault\n"); + PrintDebug(info->vm_info, info, "Handling PTE fault\n"); struct v3_mem_region * shdw_reg = v3_get_mem_region(info->vm_info, info->vcpu_id, guest_pa); @@ -432,7 +432,7 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintError("Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); + PrintError(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); v3_raise_exception(info, MC_EXCEPTION); return 0; } @@ -446,11 +446,11 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault /* Was the page fault caused by the Guest's page tables? */ if (v3_is_guest_pf(guest_pte_access, shadow_pte_access) == 1) { - PrintDebug("Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", + PrintDebug(info->vm_info, info, "Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", guest_pte_access, *(uint_t*)&error_code); if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } @@ -461,21 +461,21 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault if (shadow_pte_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush page tables and everything should now work - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(info->vm_info, info, "Inconsistent state... Guest re-entry should flush tlb\n"); return 0; } if (shadow_pte_access == PT_ACCESS_NOT_PRESENT) { // Page Table Entry Not Present - PrintDebug("guest_pa =%p\n", (void *)guest_pa); + PrintDebug(info->vm_info, info, "guest_pa =%p\n", (void *)guest_pa); if ((shdw_reg->flags.alloced == 1) || (shdw_reg->flags.read == 1)) { addr_t shadow_pa = 0; if (v3_gpa_to_hpa(info, guest_pa, &shadow_pa) == -1) { - PrintError("could not translate page fault address (%p)\n", (void *)guest_pa); + PrintError(info->vm_info, info, "could not translate page fault address (%p)\n", (void *)guest_pa); return -1; } @@ -510,7 +510,7 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault } else { // Pass to unhandled call back if (shdw_reg->unhandled(info, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -519,11 +519,11 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault if (shdw_reg->flags.write == 1) { - PrintDebug("Shadow PTE Write Error\n"); + PrintDebug(info->vm_info, info, "Shadow PTE Write Error\n"); shadow_pte->writable = guest_pte->writable; } else { if (shdw_reg->unhandled(info, fault_addr, guest_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } @@ -535,11 +535,11 @@ static int handle_pte_shadow_pagefault_64(struct guest_info * info, addr_t fault } else { // Inject page fault into the guest if (v3_inject_guest_pf(info, fault_addr, error_code) == -1) { - PrintError("Could not inject guest page fault\n"); + PrintError(info->vm_info, info, "Could not inject guest page fault\n"); return -1; } - PrintError("PTE Page fault fell through... Not sure if this should ever happen\n"); - PrintError("Manual Says to inject page fault into guest\n"); + PrintError(info->vm_info, info, "PTE Page fault fell through... Not sure if this should ever happen\n"); + PrintError(info->vm_info, info, "Manual Says to inject page fault into guest\n"); return -1; } @@ -555,14 +555,14 @@ static int handle_2MB_shadow_pagefault_pde_64(struct guest_info * info, addr_t guest_fault_pa = BASE_TO_PAGE_ADDR_2MB(large_guest_pde->page_base_addr) + PAGE_OFFSET_2MB(fault_addr); // struct shadow_page_state * state = &(info->shdw_pg_state); - PrintDebug("Handling 2MB fault with large page (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); - PrintDebug("LargeShadowPDE=%p, LargeGuestPDE=%p\n", large_shadow_pde, large_guest_pde); + PrintDebug(info->vm_info, info, "Handling 2MB fault with large page (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); + PrintDebug(info->vm_info, info, "LargeShadowPDE=%p, LargeGuestPDE=%p\n", large_shadow_pde, large_guest_pde); struct v3_mem_region * shdw_reg = v3_get_mem_region(info->vm_info, info->vcpu_id, guest_fault_pa); if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintError("Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); + PrintError(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); v3_raise_exception(info, MC_EXCEPTION); return 0; } @@ -570,7 +570,7 @@ static int handle_2MB_shadow_pagefault_pde_64(struct guest_info * info, if (shadow_pde_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush tables and everything should now workd - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(info->vm_info, info, "Inconsistent state... Guest re-entry should flush tlb\n"); //PrintHostPageTree(info, fault_addr, info->ctrl_regs.cr3); return 0; } @@ -584,7 +584,7 @@ static int handle_2MB_shadow_pagefault_pde_64(struct guest_info * info, addr_t shadow_pa = 0; if (v3_gpa_to_hpa(info, guest_fault_pa, &shadow_pa) == -1) { - PrintError("could not translate page fault address (%p)\n", (void *)guest_fault_pa); + PrintError(info->vm_info, info, "could not translate page fault address (%p)\n", (void *)guest_fault_pa); return -1; } @@ -608,23 +608,23 @@ static int handle_2MB_shadow_pagefault_pde_64(struct guest_info * info, } else { if (shdw_reg->unhandled(info, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } } else if (shadow_pde_access == PT_ACCESS_WRITE_ERROR) { if (shdw_reg->unhandled(info, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } else { - PrintError("Error in large page fault handler...\n"); - PrintError("This case should have been handled at the top level handler\n"); + PrintError(info->vm_info, info, "Error in large page fault handler...\n"); + PrintError(info->vm_info, info, "This case should have been handled at the top level handler\n"); return -1; } // PrintHostPageTree(info, fault_addr, info->ctrl_regs.cr3); - PrintDebug("Returning from large page->large page fault handler\n"); + PrintDebug(info->vm_info, info, "Returning from large page->large page fault handler\n"); return 0; } @@ -637,15 +637,15 @@ static int handle_2MB_shadow_pagefault_pte_64(struct guest_info * info, addr_t guest_fault_pa = BASE_TO_PAGE_ADDR_2MB(large_guest_pde->page_base_addr) + PAGE_OFFSET_2MB(fault_addr); // struct shadow_page_state * state = &(info->shdw_pg_state); - PrintDebug("Handling 2MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); - PrintDebug("ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); + PrintDebug(info->vm_info, info, "Handling 2MB fault (guest_fault_pa=%p) (error_code=%x)\n", (void *)guest_fault_pa, *(uint_t*)&error_code); + PrintDebug(info->vm_info, info, "ShadowPT=%p, LargeGuestPDE=%p\n", shadow_pt, large_guest_pde); struct v3_mem_region * shdw_reg = v3_get_mem_region(info->vm_info, info->vcpu_id, guest_fault_pa); if (shdw_reg == NULL) { // Inject a machine check in the guest - PrintError("Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); + PrintError(info->vm_info, info, "Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); v3_raise_exception(info, MC_EXCEPTION); return 0; } @@ -653,7 +653,7 @@ static int handle_2MB_shadow_pagefault_pte_64(struct guest_info * info, if (shadow_pte_access == PT_ACCESS_OK) { // Inconsistent state... // Guest Re-Entry will flush tables and everything should now workd - PrintDebug("Inconsistent state... Guest re-entry should flush tlb\n"); + PrintDebug(info->vm_info, info, "Inconsistent state... Guest re-entry should flush tlb\n"); //PrintHostPageTree(info, fault_addr, info->ctrl_regs.cr3); return 0; } @@ -667,7 +667,7 @@ static int handle_2MB_shadow_pagefault_pte_64(struct guest_info * info, addr_t shadow_pa = 0; if (v3_gpa_to_hpa(info, guest_fault_pa, &shadow_pa) == -1) { - PrintError("could not translate page fault address (%p)\n", (void *)guest_fault_pa); + PrintError(info->vm_info, info, "could not translate page fault address (%p)\n", (void *)guest_fault_pa); return -1; } @@ -696,23 +696,23 @@ static int handle_2MB_shadow_pagefault_pte_64(struct guest_info * info, } else { if (shdw_reg->unhandled(info, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } } else if (shadow_pte_access == PT_ACCESS_WRITE_ERROR) { if (shdw_reg->unhandled(info, fault_addr, guest_fault_pa, shdw_reg, error_code) == -1) { - PrintError("Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Special Page Fault handler returned error for address: %p\n", (void *)fault_addr); return -1; } } else { - PrintError("Error in large page fault handler...\n"); - PrintError("This case should have been handled at the top level handler\n"); + PrintError(info->vm_info, info, "Error in large page fault handler...\n"); + PrintError(info->vm_info, info, "This case should have been handled at the top level handler\n"); return -1; } // PrintHostPageTree(info, fault_addr, info->ctrl_regs.cr3); - PrintDebug("Returning from large page->small page fault handler\n"); + PrintDebug(info->vm_info, info, "Returning from large page->small page fault handler\n"); return 0; } @@ -743,7 +743,7 @@ static int invalidation_cb_64(struct guest_info * info, page_type_t type, } if (pdpe->vmm_info == V3_LARGE_PG) { - PrintError("1 Gigabyte pages not supported\n"); + PrintError(info->vm_info, info, "1 Gigabyte pages not supported\n"); return -1; pdpe->present = 0; @@ -777,23 +777,23 @@ static int invalidation_cb_64(struct guest_info * info, page_type_t type, return 1; } default: - PrintError("Invalid Page Type\n"); + PrintError(info->vm_info, info, "Invalid Page Type\n"); return -1; } // should not get here - PrintError("Should not get here....\n"); + PrintError(info->vm_info, info, "Should not get here....\n"); return -1; } static inline int handle_shadow_invlpg_64(struct guest_info * info, addr_t vaddr) { - PrintDebug("INVLPG64 - %p\n",(void*)vaddr); + PrintDebug(info->vm_info, info, "INVLPG64 - %p\n",(void*)vaddr); int ret = v3_drill_host_pt_64(info, info->ctrl_regs.cr3, vaddr, invalidation_cb_64, NULL); if (ret == -1) { - PrintError("Page table drill returned error.... \n"); + PrintError(info->vm_info, info, "Page table drill returned error.... \n"); PrintHostPageTree(info, vaddr, info->ctrl_regs.cr3); } diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 99d12d3..f60acda 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -77,7 +77,7 @@ static vmcb_t * Allocate_VMCB() { addr_t vmcb_pa = (addr_t)V3_AllocPages(1); if ((void *)vmcb_pa == NULL) { - PrintError("Error allocating VMCB\n"); + PrintError(VM_NONE, VCORE_NONE, "Error allocating VMCB\n"); return NULL; } @@ -240,7 +240,7 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info * core) { ctrl_area->instrs.MSR_PROT = 1; - PrintDebug("Exiting on interrupts\n"); + PrintDebug(core->vm_info, core, "Exiting on interrupts\n"); ctrl_area->guest_ctrl.V_INTR_MASKING = 1; ctrl_area->instrs.INTR = 1; // The above also assures the TPR changes (CR8) are only virtual @@ -263,7 +263,7 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info * core) { core); if (core->shdw_pg_mode == SHADOW_PAGING) { - PrintDebug("Creating initial shadow page table\n"); + PrintDebug(core->vm_info, core, "Creating initial shadow page table\n"); /* JRL: This is a performance killer, and a simplistic solution */ /* We need to fix this */ @@ -272,13 +272,13 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info * core) { if (v3_init_passthrough_pts(core) == -1) { - PrintError("Could not initialize passthrough page tables\n"); + PrintError(core->vm_info, core, "Could not initialize passthrough page tables\n"); return ; } core->shdw_pg_state.guest_cr0 = 0x0000000000000010LL; - PrintDebug("Created\n"); + PrintDebug(core->vm_info, core, "Created\n"); core->ctrl_regs.cr0 |= 0x80000000; core->ctrl_regs.cr3 = core->direct_map_pt; @@ -306,11 +306,11 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info * core) { // Enable Nested Paging ctrl_area->NP_ENABLE = 1; - PrintDebug("NP_Enable at 0x%p\n", (void *)&(ctrl_area->NP_ENABLE)); + PrintDebug(core->vm_info, core, "NP_Enable at 0x%p\n", (void *)&(ctrl_area->NP_ENABLE)); // Set the Nested Page Table pointer if (v3_init_passthrough_pts(core) == -1) { - PrintError("Could not initialize Nested page tables\n"); + PrintError(core->vm_info, core, "Could not initialize Nested page tables\n"); return ; } @@ -351,19 +351,19 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info * core) { int v3_init_svm_vmcb(struct guest_info * core, v3_vm_class_t vm_class) { - PrintDebug("Allocating VMCB\n"); + PrintDebug(core->vm_info, core, "Allocating VMCB\n"); core->vmm_data = (void *)Allocate_VMCB(); if (core->vmm_data == NULL) { - PrintError("Could not allocate VMCB, Exiting...\n"); + PrintError(core->vm_info, core, "Could not allocate VMCB, Exiting...\n"); return -1; } if (vm_class == V3_PC_VM) { - PrintDebug("Initializing VMCB (addr=%p)\n", (void *)core->vmm_data); + PrintDebug(core->vm_info, core, "Initializing VMCB (addr=%p)\n", (void *)core->vmm_data); Init_VMCB_BIOS((vmcb_t*)(core->vmm_data), core); } else { - PrintError("Invalid VM class\n"); + PrintError(core->vm_info, core, "Invalid VM class\n"); return -1; } @@ -398,14 +398,14 @@ int v3_svm_save_core(struct guest_info * core, void * ctx){ // and then we save the whole enchilada if (v3_chkpt_save(ctx, "VMCB_DATA", PAGE_SIZE, core->vmm_data)) { - PrintError("Could not save SVM vmcb\n"); + PrintError(core->vm_info, core, "Could not save SVM vmcb\n"); goto failout; } return 0; failout: - PrintError("Failed to save SVM state for core\n"); + PrintError(core->vm_info, core, "Failed to save SVM state for core\n"); return -1; } @@ -428,14 +428,14 @@ int v3_svm_load_core(struct guest_info * core, void * ctx){ // and then we load the whole enchilada if (v3_chkpt_load(ctx, "VMCB_DATA", PAGE_SIZE, core->vmm_data)) { - PrintError("Could not load SVM vmcb\n"); + PrintError(core->vm_info, core, "Could not load SVM vmcb\n"); goto failout; } return 0; failout: - PrintError("Failed to save SVM state for core\n"); + PrintError(core->vm_info, core, "Failed to save SVM state for core\n"); return -1; } @@ -450,7 +450,7 @@ static int update_irq_exit_state(struct guest_info * info) { if ((info->intr_core_state.irq_pending == 1) && (guest_ctrl->guest_ctrl.V_IRQ == 0)) { #ifdef V3_CONFIG_DEBUG_INTERRUPTS - PrintDebug("INTAK cycle completed for irq %d\n", info->intr_core_state.irq_vector); + PrintDebug(info->vm_info, info, "INTAK cycle completed for irq %d\n", info->intr_core_state.irq_vector); #endif info->intr_core_state.irq_started = 1; @@ -461,7 +461,7 @@ static int update_irq_exit_state(struct guest_info * info) { if ((info->intr_core_state.irq_started == 1) && (guest_ctrl->exit_int_info.valid == 0)) { #ifdef V3_CONFIG_DEBUG_INTERRUPTS - PrintDebug("Interrupt %d taken by guest\n", info->intr_core_state.irq_vector); + PrintDebug(info->vm_info, info, "Interrupt %d taken by guest\n", info->intr_core_state.irq_vector); #endif // Interrupt was taken fully vectored @@ -469,7 +469,7 @@ static int update_irq_exit_state(struct guest_info * info) { } else if ((info->intr_core_state.irq_started == 1) && (guest_ctrl->exit_int_info.valid == 1)) { #ifdef V3_CONFIG_DEBUG_INTERRUPTS - PrintDebug("EXIT INT INFO is set (vec=%d)\n", guest_ctrl->exit_int_info.vector); + PrintDebug(info->vm_info, info, "EXIT INT INFO is set (vec=%d)\n", guest_ctrl->exit_int_info.vector); #endif } @@ -495,7 +495,7 @@ static int update_irq_entry_state(struct guest_info * info) { guest_ctrl->EVENTINJ.error_code = info->excp_state.excp_error_code; guest_ctrl->EVENTINJ.ev = 1; #ifdef V3_CONFIG_DEBUG_INTERRUPTS - PrintDebug("Injecting exception %d with error code %x\n", excp, guest_ctrl->EVENTINJ.error_code); + PrintDebug(info->vm_info, info, "Injecting exception %d with error code %x\n", excp, guest_ctrl->EVENTINJ.error_code); #endif } @@ -504,7 +504,7 @@ static int update_irq_entry_state(struct guest_info * info) { guest_ctrl->EVENTINJ.valid = 1; #ifdef V3_CONFIG_DEBUG_INTERRUPTS - PrintDebug("<%d> Injecting Exception %d (CR2=%p) (EIP=%p)\n", + PrintDebug(info->vm_info, info, "<%d> Injecting Exception %d (CR2=%p) (EIP=%p)\n", (int)info->num_exits, guest_ctrl->EVENTINJ.vector, (void *)(addr_t)info->ctrl_regs.cr2, @@ -514,7 +514,7 @@ static int update_irq_entry_state(struct guest_info * info) { v3_injecting_excp(info, excp); } else if (info->intr_core_state.irq_started == 1) { #ifdef V3_CONFIG_DEBUG_INTERRUPTS - PrintDebug("IRQ pending from previous injection\n"); + PrintDebug(info->vm_info, info, "IRQ pending from previous injection\n"); #endif guest_ctrl->guest_ctrl.V_IRQ = 1; guest_ctrl->guest_ctrl.V_INTR_VECTOR = info->intr_core_state.irq_vector; @@ -538,7 +538,7 @@ static int update_irq_entry_state(struct guest_info * info) { guest_ctrl->guest_ctrl.V_INTR_PRIO = info->intr_core_state.irq_vector >> 4 ; // 0xf; #ifdef V3_CONFIG_DEBUG_INTERRUPTS - PrintDebug("Injecting Interrupt %d (EIP=%p)\n", + PrintDebug(info->vm_info, info, "Injecting Interrupt %d (EIP=%p)\n", guest_ctrl->guest_ctrl.V_INTR_VECTOR, (void *)(addr_t)info->rip); #endif @@ -555,7 +555,7 @@ static int update_irq_entry_state(struct guest_info * info) { guest_ctrl->EVENTINJ.type = SVM_INJECTION_SOFT_INTR; #ifdef V3_CONFIG_DEBUG_INTERRUPTS - PrintDebug("Injecting software interrupt -- type: %d, vector: %d\n", + PrintDebug(info->vm_info, info, "Injecting software interrupt -- type: %d, vector: %d\n", SVM_INJECTION_SOFT_INTR, info->intr_core_state.swintr_vector); #endif guest_ctrl->EVENTINJ.vector = info->intr_core_state.swintr_vector; @@ -674,7 +674,7 @@ int v3_svm_enter(struct guest_info * info) { /* ** */ /* - PrintDebug("SVM Entry to CS=%p rip=%p...\n", + PrintDebug(info->vm_info, info, "SVM Entry to CS=%p rip=%p...\n", (void *)(addr_t)info->segments.cs.base, (void *)(addr_t)info->rip); */ @@ -682,14 +682,14 @@ int v3_svm_enter(struct guest_info * info) { #ifdef V3_CONFIG_SYMCALL if (info->sym_core_state.symcall_state.sym_call_active == 1) { if (guest_ctrl->guest_ctrl.V_IRQ == 1) { - V3_Print("!!! Injecting Interrupt during Sym call !!!\n"); + V3_Print(info->vm_info, info, "!!! Injecting Interrupt during Sym call !!!\n"); } } #endif v3_svm_config_tsc_virtualization(info); - //V3_Print("Calling v3_svm_launch\n"); + //V3_Print(info->vm_info, info, "Calling v3_svm_launch\n"); { uint64_t entry_tsc = 0; uint64_t exit_tsc = 0; @@ -704,7 +704,7 @@ int v3_svm_enter(struct guest_info * info) { } - //V3_Print("SVM Returned: Exit Code: %x, guest_rip=%lx\n", (uint32_t)(guest_ctrl->exit_code), (unsigned long)guest_state->rip); + //V3_Print(info->vm_info, info, "SVM Returned: Exit Code: %x, guest_rip=%lx\n", (uint32_t)(guest_ctrl->exit_code), (unsigned long)guest_state->rip); v3_last_exit = (uint32_t)(guest_ctrl->exit_code); @@ -772,8 +772,8 @@ int v3_svm_enter(struct guest_info * info) { int ret = v3_handle_svm_exit(info, exit_code, exit_info1, exit_info2); if (ret != 0) { - PrintError("Error in SVM exit handler (ret=%d)\n", ret); - PrintError(" last Exit was %d (exit code=0x%llx)\n", v3_last_exit, (uint64_t) exit_code); + PrintError(info->vm_info, info, "Error in SVM exit handler (ret=%d)\n", ret); + PrintError(info->vm_info, info, " last Exit was %d (exit code=0x%llx)\n", v3_last_exit, (uint64_t) exit_code); return -1; } } @@ -792,12 +792,12 @@ int v3_start_svm_guest(struct guest_info * info) { // vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data)); // vmcb_ctrl_t * guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data)); - PrintDebug("Starting SVM core %u (on logical core %u)\n", info->vcpu_id, info->pcpu_id); + PrintDebug(info->vm_info, info, "Starting SVM core %u (on logical core %u)\n", info->vcpu_id, info->pcpu_id); if (info->vcpu_id == 0) { info->core_run_state = CORE_RUNNING; } else { - PrintDebug("SVM core %u (on %u): Waiting for core initialization\n", info->vcpu_id, info->pcpu_id); + PrintDebug(info->vm_info, info, "SVM core %u (on %u): Waiting for core initialization\n", info->vcpu_id, info->pcpu_id); while (info->core_run_state == CORE_STOPPED) { @@ -807,23 +807,23 @@ int v3_start_svm_guest(struct guest_info * info) { } v3_yield(info,-1); - //PrintDebug("SVM core %u: still waiting for INIT\n", info->vcpu_id); + //PrintDebug(info->vm_info, info, "SVM core %u: still waiting for INIT\n", info->vcpu_id); } - PrintDebug("SVM core %u(on %u) initialized\n", info->vcpu_id, info->pcpu_id); + PrintDebug(info->vm_info, info, "SVM core %u(on %u) initialized\n", info->vcpu_id, info->pcpu_id); // We'll be paranoid about race conditions here v3_wait_at_barrier(info); } - PrintDebug("SVM core %u(on %u): I am starting at CS=0x%x (base=0x%p, limit=0x%x), RIP=0x%p\n", + PrintDebug(info->vm_info, info, "SVM core %u(on %u): I am starting at CS=0x%x (base=0x%p, limit=0x%x), RIP=0x%p\n", info->vcpu_id, info->pcpu_id, info->segments.cs.selector, (void *)(info->segments.cs.base), info->segments.cs.limit, (void *)(info->rip)); - PrintDebug("SVM core %u: Launching SVM VM (vmcb=%p) (on cpu %u)\n", + PrintDebug(info->vm_info, info, "SVM core %u: Launching SVM VM (vmcb=%p) (on cpu %u)\n", info->vcpu_id, (void *)info->vmm_data, info->pcpu_id); //PrintDebugVMCB((vmcb_t*)(info->vmm_data)); @@ -843,17 +843,17 @@ int v3_start_svm_guest(struct guest_info * info) { info->vm_info->run_state = VM_ERROR; - V3_Print("SVM core %u: SVM ERROR!!\n", info->vcpu_id); + V3_Print(info->vm_info, info, "SVM core %u: SVM ERROR!!\n", info->vcpu_id); v3_print_guest_state(info); - V3_Print("SVM core %u: SVM Exit Code: %p\n", info->vcpu_id, (void *)(addr_t)guest_ctrl->exit_code); + V3_Print(info->vm_info, info, "SVM core %u: SVM Exit Code: %p\n", info->vcpu_id, (void *)(addr_t)guest_ctrl->exit_code); - V3_Print("SVM core %u: exit_info1 low = 0x%.8x\n", info->vcpu_id, *(uint_t*)&(guest_ctrl->exit_info1)); - V3_Print("SVM core %u: exit_info1 high = 0x%.8x\n", info->vcpu_id, *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info1)) + 4)); + V3_Print(info->vm_info, info, "SVM core %u: exit_info1 low = 0x%.8x\n", info->vcpu_id, *(uint_t*)&(guest_ctrl->exit_info1)); + V3_Print(info->vm_info, info, "SVM core %u: exit_info1 high = 0x%.8x\n", info->vcpu_id, *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info1)) + 4)); - V3_Print("SVM core %u: exit_info2 low = 0x%.8x\n", info->vcpu_id, *(uint_t*)&(guest_ctrl->exit_info2)); - V3_Print("SVM core %u: exit_info2 high = 0x%.8x\n", info->vcpu_id, *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info2)) + 4)); + V3_Print(info->vm_info, info, "SVM core %u: exit_info2 low = 0x%.8x\n", info->vcpu_id, *(uint_t*)&(guest_ctrl->exit_info2)); + V3_Print(info->vm_info, info, "SVM core %u: exit_info2 high = 0x%.8x\n", info->vcpu_id, *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info2)) + 4)); linear_addr = get_addr_linear(info, info->rip, &(info->segments.cs)); @@ -863,9 +863,9 @@ int v3_start_svm_guest(struct guest_info * info) { v3_gva_to_hva(info, linear_addr, &host_addr); } - V3_Print("SVM core %u: Host Address of rip = 0x%p\n", info->vcpu_id, (void *)host_addr); + V3_Print(info->vm_info, info, "SVM core %u: Host Address of rip = 0x%p\n", info->vcpu_id, (void *)host_addr); - V3_Print("SVM core %u: Instr (15 bytes) at %p:\n", info->vcpu_id, (void *)host_addr); + V3_Print(info->vm_info, info, "SVM core %u: Instr (15 bytes) at %p:\n", info->vcpu_id, (void *)host_addr); v3_dump_mem((uint8_t *)host_addr, 15); v3_print_stack(info); @@ -885,7 +885,7 @@ int v3_start_svm_guest(struct guest_info * info) { /* if ((info->num_exits % 50000) == 0) { - V3_Print("SVM Exit number %d\n", (uint32_t)info->num_exits); + V3_Print(info->vm_info, info, "SVM Exit number %d\n", (uint32_t)info->num_exits); v3_print_guest_state(info); } */ @@ -934,38 +934,38 @@ int v3_is_svm_capable() { v3_cpuid(CPUID_EXT_FEATURE_IDS, &eax, &ebx, &ecx, &edx); - PrintDebug("CPUID_EXT_FEATURE_IDS_ecx=0x%x\n", ecx); + PrintDebug(VM_NONE, VCORE_NONE, "CPUID_EXT_FEATURE_IDS_ecx=0x%x\n", ecx); if ((ecx & CPUID_EXT_FEATURE_IDS_ecx_svm_avail) == 0) { - V3_Print("SVM Not Available\n"); + V3_Print(VM_NONE, VCORE_NONE, "SVM Not Available\n"); return 0; } else { v3_get_msr(SVM_VM_CR_MSR, &vm_cr_high, &vm_cr_low); - PrintDebug("SVM_VM_CR_MSR = 0x%x 0x%x\n", vm_cr_high, vm_cr_low); + PrintDebug(VM_NONE, VCORE_NONE, "SVM_VM_CR_MSR = 0x%x 0x%x\n", vm_cr_high, vm_cr_low); if ((vm_cr_low & SVM_VM_CR_MSR_svmdis) == 1) { - V3_Print("SVM is available but is disabled.\n"); + V3_Print(VM_NONE, VCORE_NONE, "SVM is available but is disabled.\n"); v3_cpuid(CPUID_SVM_REV_AND_FEATURE_IDS, &eax, &ebx, &ecx, &edx); - PrintDebug("CPUID_SVM_REV_AND_FEATURE_IDS_edx=0x%x\n", edx); + PrintDebug(VM_NONE, VCORE_NONE, "CPUID_SVM_REV_AND_FEATURE_IDS_edx=0x%x\n", edx); if ((edx & CPUID_SVM_REV_AND_FEATURE_IDS_edx_svml) == 0) { - V3_Print("SVM BIOS Disabled, not unlockable\n"); + V3_Print(VM_NONE, VCORE_NONE, "SVM BIOS Disabled, not unlockable\n"); } else { - V3_Print("SVM is locked with a key\n"); + V3_Print(VM_NONE, VCORE_NONE, "SVM is locked with a key\n"); } return 0; } else { - V3_Print("SVM is available and enabled.\n"); + V3_Print(VM_NONE, VCORE_NONE, "SVM is available and enabled.\n"); v3_cpuid(CPUID_SVM_REV_AND_FEATURE_IDS, &eax, &ebx, &ecx, &edx); - PrintDebug("CPUID_SVM_REV_AND_FEATURE_IDS_eax=0x%x\n", eax); - PrintDebug("CPUID_SVM_REV_AND_FEATURE_IDS_ebx=0x%x\n", ebx); - PrintDebug("CPUID_SVM_REV_AND_FEATURE_IDS_ecx=0x%x\n", ecx); - PrintDebug("CPUID_SVM_REV_AND_FEATURE_IDS_edx=0x%x\n", edx); + PrintDebug(VM_NONE, VCORE_NONE, "CPUID_SVM_REV_AND_FEATURE_IDS_eax=0x%x\n", eax); + PrintDebug(VM_NONE, VCORE_NONE, "CPUID_SVM_REV_AND_FEATURE_IDS_ebx=0x%x\n", ebx); + PrintDebug(VM_NONE, VCORE_NONE, "CPUID_SVM_REV_AND_FEATURE_IDS_ecx=0x%x\n", ecx); + PrintDebug(VM_NONE, VCORE_NONE, "CPUID_SVM_REV_AND_FEATURE_IDS_edx=0x%x\n", edx); return 1; } @@ -977,13 +977,13 @@ static int has_svm_nested_paging() { v3_cpuid(CPUID_SVM_REV_AND_FEATURE_IDS, &eax, &ebx, &ecx, &edx); - //PrintDebug("CPUID_EXT_FEATURE_IDS_edx=0x%x\n", edx); + //PrintDebug(VM_NONE, VCORE_NONE, "CPUID_EXT_FEATURE_IDS_edx=0x%x\n", edx); if ((edx & CPUID_SVM_REV_AND_FEATURE_IDS_edx_np) == 0) { - V3_Print("SVM Nested Paging not supported\n"); + V3_Print(VM_NONE, VCORE_NONE, "SVM Nested Paging not supported\n"); return 0; } else { - V3_Print("SVM Nested Paging supported\n"); + V3_Print(VM_NONE, VCORE_NONE, "SVM Nested Paging supported\n"); return 1; } } @@ -999,13 +999,13 @@ void v3_init_svm_cpu(int cpu_id) { msr.e_reg.low |= EFER_MSR_svm_enable; v3_set_msr(EFER_MSR, 0, msr.e_reg.low); - V3_Print("SVM Enabled\n"); + V3_Print(VM_NONE, VCORE_NONE, "SVM Enabled\n"); // Setup the host state save area host_vmcbs[cpu_id] = (addr_t)V3_AllocPages(4); if (!host_vmcbs[cpu_id]) { - PrintError("Failed to allocate VMCB\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to allocate VMCB\n"); return; } @@ -1014,7 +1014,7 @@ void v3_init_svm_cpu(int cpu_id) { //msr.e_reg.low = (uint_t)host_vmcb; msr.r_reg = host_vmcbs[cpu_id]; - PrintDebug("Host State being saved at %p\n", (void *)host_vmcbs[cpu_id]); + PrintDebug(VM_NONE, VCORE_NONE, "Host State being saved at %p\n", (void *)host_vmcbs[cpu_id]); v3_set_msr(SVM_VM_HSAVE_PA_MSR, msr.e_reg.high, msr.e_reg.low); @@ -1045,7 +1045,7 @@ void v3_deinit_svm_cpu(int cpu_id) { V3_FreePages((void *)host_vmcbs[cpu_id], 4); - V3_Print("Host CPU %d host area freed, and SVM disabled\n", cpu_id); + V3_Print(VM_NONE, VCORE_NONE, "Host CPU %d host area freed, and SVM disabled\n", cpu_id); return; } @@ -1128,7 +1128,7 @@ void v3_deinit_svm_cpu(int cpu_id) { end <<= 32; end += end_lo; - PrintDebug("VMSave Cycle Latency: %d\n", (uint32_t)(end - start)); + PrintDebug(core->vm_info, core, "VMSave Cycle Latency: %d\n", (uint32_t)(end - start)); __asm__ __volatile__ ( "rdtsc ; " @@ -1150,7 +1150,7 @@ void v3_deinit_svm_cpu(int cpu_id) { end += end_lo; - PrintDebug("VMLoad Cycle Latency: %d\n", (uint32_t)(end - start)); + PrintDebug(core->vm_info, core, "VMLoad Cycle Latency: %d\n", (uint32_t)(end - start)); } /* End Latency Test */ @@ -1250,7 +1250,7 @@ void Init_VMCB_pe(vmcb_t *vmcb, struct guest_info vm_info) { ctrl_area->IOPM_BASE_PA = (uint_t)V3_AllocPages(3); if (!ctrl_area->IOPM_BASE_PA) { - PrintError("Cannot allocate IO bitmap\n"); + PrintError(core->vm_info, core, "Cannot allocate IO bitmap\n"); return; } @@ -1277,12 +1277,12 @@ void Init_VMCB_pe(vmcb_t *vmcb, struct guest_info vm_info) { GetGDTR(gdt_buf); gdt_base = *(ulong_t*)((uchar_t*)gdt_buf + 2) & 0xffffffff; gdt_limit = *(ushort_t*)(gdt_buf) & 0xffff; - PrintDebug("GDT: base: %x, limit: %x\n", gdt_base, gdt_limit); + PrintDebug(core->vm_info, core, "GDT: base: %x, limit: %x\n", gdt_base, gdt_limit); GetIDTR(idt_buf); idt_base = *(ulong_t*)(idt_buf + 2) & 0xffffffff; idt_limit = *(ushort_t*)(idt_buf) & 0xffff; - PrintDebug("IDT: base: %x, limit: %x\n",idt_base, idt_limit); + PrintDebug(core->vm_info, core, "IDT: base: %x, limit: %x\n",idt_base, idt_limit); // gdt_base -= 0x2000; @@ -1307,7 +1307,7 @@ void Init_VMCB_pe(vmcb_t *vmcb, struct guest_info vm_info) { // Enable Nested Paging ctrl_area->NP_ENABLE = 1; - PrintDebug("NP_Enable at 0x%x\n", &(ctrl_area->NP_ENABLE)); + PrintDebug(core->vm_info, core, "NP_Enable at 0x%x\n", &(ctrl_area->NP_ENABLE)); // Set the Nested Page Table pointer ctrl_area->N_CR3 |= ((addr_t)vm_info.page_tables & 0xfffff000); @@ -1318,8 +1318,8 @@ void Init_VMCB_pe(vmcb_t *vmcb, struct guest_info vm_info) { guest_state->g_pat = 0x7040600070406ULL; - PrintDebug("Set Nested CR3: lo: 0x%x hi: 0x%x\n", (uint_t)*(&(ctrl_area->N_CR3)), (uint_t)*((unsigned char *)&(ctrl_area->N_CR3) + 4)); - PrintDebug("Set Guest CR3: lo: 0x%x hi: 0x%x\n", (uint_t)*(&(guest_state->cr3)), (uint_t)*((unsigned char *)&(guest_state->cr3) + 4)); + PrintDebug(core->vm_info, core, "Set Nested CR3: lo: 0x%x hi: 0x%x\n", (uint_t)*(&(ctrl_area->N_CR3)), (uint_t)*((unsigned char *)&(ctrl_area->N_CR3) + 4)); + PrintDebug(core->vm_info, core, "Set Guest CR3: lo: 0x%x hi: 0x%x\n", (uint_t)*(&(guest_state->cr3)), (uint_t)*((unsigned char *)&(guest_state->cr3) + 4)); // Enable Paging // guest_state->cr0 |= 0x80000000; } diff --git a/palacios/src/palacios/svm_exits.c b/palacios/src/palacios/svm_exits.c index b47507d..a0bd5ad 100644 --- a/palacios/src/palacios/svm_exits.c +++ b/palacios/src/palacios/svm_exits.c @@ -37,7 +37,7 @@ static int enable_exit(struct guest_info * core, v3_exit_type_t exit_type) { break; default: - PrintError("Unhandled Exit Type (%d)\n", exit_type); + PrintError(core->vm_info, core, "Unhandled Exit Type (%d)\n", exit_type); return -1; } @@ -58,7 +58,7 @@ static int disable_exit(struct guest_info * core, v3_exit_type_t exit_type) { break; default: - PrintError("Unhandled Exit Type (%d)\n", exit_type); + PrintError(core->vm_info, core, "Unhandled Exit Type (%d)\n", exit_type); return -1; } diff --git a/palacios/src/palacios/svm_handler.c b/palacios/src/palacios/svm_handler.c index d0adffc..7411e4f 100644 --- a/palacios/src/palacios/svm_handler.c +++ b/palacios/src/palacios/svm_handler.c @@ -58,7 +58,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i - // PrintDebug("SVM Returned: Exit Code: %p\n", (void *)exit_code); + // PrintDebug(info->vm_info, info, "SVM Returned: Exit Code: %p\n", (void *)exit_code); switch (exit_code) { case SVM_EXIT_IOIO: { @@ -104,7 +104,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i return -1; } } else { - PrintError("Invalid MSR Operation\n"); + PrintError(info->vm_info, info, "Invalid MSR Operation\n"); return -1; } @@ -112,14 +112,14 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i case SVM_EXIT_CPUID: if (v3_handle_cpuid(info) == -1) { - PrintError("Error handling CPUID\n"); + PrintError(info->vm_info, info, "Error handling CPUID\n"); return -1; } break; case SVM_EXIT_CR0_WRITE: #ifdef V3_CONFIG_DEBUG_CTRL_REGS - PrintDebug("CR0 Write\n"); + PrintDebug(info->vm_info, info, "CR0 Write\n"); #endif if (v3_handle_cr0_write(info) == -1) { return -1; @@ -127,7 +127,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i break; case SVM_EXIT_CR0_READ: #ifdef V3_CONFIG_DEBUG_CTRL_REGS - PrintDebug("CR0 Read\n"); + PrintDebug(info->vm_info, info, "CR0 Read\n"); #endif if (v3_handle_cr0_read(info) == -1) { return -1; @@ -135,7 +135,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i break; case SVM_EXIT_CR3_WRITE: #ifdef V3_CONFIG_DEBUG_CTRL_REGS - PrintDebug("CR3 Write\n"); + PrintDebug(info->vm_info, info, "CR3 Write\n"); #endif if (v3_handle_cr3_write(info) == -1) { return -1; @@ -144,7 +144,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i break; case SVM_EXIT_CR3_READ: #ifdef V3_CONFIG_DEBUG_CTRL_REGS - PrintDebug("CR3 Read\n"); + PrintDebug(info->vm_info, info, "CR3 Read\n"); #endif if (v3_handle_cr3_read(info) == -1) { return -1; @@ -152,7 +152,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i break; case SVM_EXIT_CR4_WRITE: #ifdef V3_CONFIG_DEBUG_CTRL_REGS - PrintDebug("CR4 Write\n"); + PrintDebug(info->vm_info, info, "CR4 Write\n"); #endif if (v3_handle_cr4_write(info) == -1) { return -1; @@ -160,7 +160,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i break; case SVM_EXIT_CR4_READ: #ifdef V3_CONFIG_DEBUG_CTRL_REGS - PrintDebug("CR4 Read\n"); + PrintDebug(info->vm_info, info, "CR4 Read\n"); #endif if (v3_handle_cr4_read(info) == -1) { return -1; @@ -169,7 +169,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i case SVM_EXIT_CR8_WRITE: #ifdef V3_CONFIG_DEBUG_CTRL_REGS - PrintDebug("CR8 Read\n"); + PrintDebug(info->vm_info, info, "CR8 Read\n"); #endif if (v3_handle_cr8_read(info) == -1) { return -1; @@ -178,7 +178,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i case SVM_EXIT_CR8_READ: #ifdef V3_CONFIG_DEBUG_CTRL_REGS - PrintDebug("CR8 Read\n"); + PrintDebug(info->vm_info, info, "CR8 Read\n"); #endif if (v3_handle_cr8_read(info) == -1) { return -1; @@ -189,7 +189,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i addr_t fault_addr = exit_info2; pf_error_t * error_code = (pf_error_t *)&(exit_info1); #ifdef V3_CONFIG_DEBUG_SHADOW_PAGING - PrintDebug("PageFault at %p (error=%d)\n", + PrintDebug(info->vm_info, info, "PageFault at %p (error=%d)\n", (void *)fault_addr, *(uint_t *)error_code); #endif if (info->shdw_pg_mode == SHADOW_PAGING) { @@ -197,7 +197,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i return -1; } } else { - PrintError("Page fault in un implemented paging mode\n"); + PrintError(info->vm_info, info, "Page fault in un implemented paging mode\n"); return -1; } break; @@ -211,7 +211,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i return -1; } } else { - PrintError("Currently unhandled Nested Page Fault\n"); + PrintError(info->vm_info, info, "Currently unhandled Nested Page Fault\n"); return -1; } break; @@ -219,7 +219,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i case SVM_EXIT_INVLPG: if (info->shdw_pg_mode == SHADOW_PAGING) { #ifdef V3_CONFIG_DEBUG_SHADOW_PAGING - PrintDebug("Invlpg\n"); + PrintDebug(info->vm_info, info, "Invlpg\n"); #endif if (v3_handle_shadow_invlpg(info) == -1) { return -1; @@ -236,7 +236,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i info->rip += 3; if (v3_handle_hypercall(info) == -1) { - PrintError("Error handling Hypercall\n"); + PrintError(info->vm_info, info, "Error handling Hypercall\n"); return -1; } @@ -252,7 +252,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i break; case SVM_EXIT_HLT: #ifdef V3_CONFIG_DEBUG_HALT - PrintDebug("Guest halted\n"); + PrintDebug(info->vm_info, info, "Guest halted\n"); #endif if (v3_handle_halt(info) == -1) { return -1; @@ -261,7 +261,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i case SVM_EXIT_MONITOR: #ifdef V3_CONFIG_DEBUG_MWAIT - PrintDebug("Guest issuing MONITOR\n"); + PrintDebug(info->vm_info, info, "Guest issuing MONITOR\n"); #endif if (v3_handle_monitor(info) == -1) { return -1; @@ -271,7 +271,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i case SVM_EXIT_MWAIT: case SVM_EXIT_MWAIT_CONDITIONAL: #ifdef V3_CONFIG_DEBUG_MWAIT - PrintDebug("Guest issuing MWAIT\n"); + PrintDebug(info->vm_info, info, "Guest issuing MWAIT\n"); #endif if (v3_handle_mwait(info) == -1) { return -1; @@ -279,14 +279,14 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i break; case SVM_EXIT_PAUSE: - // PrintDebug("Guest paused\n"); + // PrintDebug(info->vm_info, info, "Guest paused\n"); if (v3_handle_svm_pause(info) == -1) { return -1; } break; case SVM_EXIT_WBINVD: #ifdef V3_CONFIG_DEBUG_EMULATOR - PrintDebug("WBINVD\n"); + PrintDebug(info->vm_info, info, "WBINVD\n"); #endif if (v3_handle_svm_wbinvd(info) == -1) { return -1; @@ -294,25 +294,25 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i break; case SVM_EXIT_RDTSC: #ifdef V3_CONFIG_DEBUG_TIME - PrintDebug("RDTSC/RDTSCP\n"); + PrintDebug(info->vm_info, info, "RDTSC/RDTSCP\n"); #endif if (v3_handle_rdtsc(info) == -1) { - PrintError("Error Handling RDTSC instruction\n"); + PrintError(info->vm_info, info, "Error Handling RDTSC instruction\n"); return -1; } break; case SVM_EXIT_RDTSCP: #ifdef V3_CONFIG_DEBUG_TIME - PrintDebug("RDTSCP\n"); + PrintDebug(info->vm_info, info, "RDTSCP\n"); #endif if (v3_handle_rdtscp(info) == -1) { - PrintError("Error handling RDTSCP instruction\n"); + PrintError(info->vm_info, info, "Error handling RDTSCP instruction\n"); return -1; } break; case SVM_EXIT_SHUTDOWN: - PrintDebug("Guest-initiated shutdown\n"); + PrintDebug(info->vm_info, info, "Guest-initiated shutdown\n"); info->vm_info->run_state = VM_STOPPED; @@ -322,10 +322,10 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i #ifdef V3_CONFIG_EXT_SW_INTERRUPTS case SVM_EXIT_SWINT: #ifdef V3_CONFIG_DEBUG_EXT_SW_INTERRUPTS - PrintDebug("Intercepted a software interrupt\n"); + PrintDebug(info->vm_info, info, "Intercepted a software interrupt\n"); #endif if (v3_handle_swintr(info) == -1) { - PrintError("Error handling software interrupt\n"); + PrintError(info->vm_info, info, "Error handling software interrupt\n"); return -1; } break; @@ -339,22 +339,22 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i addr_t rip_addr; - PrintError("Unhandled SVM Exit: %s\n", v3_svm_exit_code_to_str(exit_code)); + PrintError(info->vm_info, info, "Unhandled SVM Exit: %s\n", v3_svm_exit_code_to_str(exit_code)); rip_addr = get_addr_linear(info, info->rip, &(info->segments.cs)); - PrintError("SVM Returned:(VMCB=%p)\n", (void *)(info->vmm_data)); - PrintError("RIP: %p\n", (void *)(addr_t)(info->rip)); - PrintError("RIP Linear: %p\n", (void *)(addr_t)(rip_addr)); + PrintError(info->vm_info, info, "SVM Returned:(VMCB=%p)\n", (void *)(info->vmm_data)); + PrintError(info->vm_info, info, "RIP: %p\n", (void *)(addr_t)(info->rip)); + PrintError(info->vm_info, info, "RIP Linear: %p\n", (void *)(addr_t)(rip_addr)); - PrintError("SVM Returned: Exit Code: %p\n", (void *)(addr_t)exit_code); + PrintError(info->vm_info, info, "SVM Returned: Exit Code: %p\n", (void *)(addr_t)exit_code); - PrintError("io_info1 low = 0x%.8x\n", *(uint_t*)&(exit_info1)); - PrintError("io_info1 high = 0x%.8x\n", *(uint_t *)(((uint8_t *)&(exit_info1)) + 4)); + PrintError(info->vm_info, info, "io_info1 low = 0x%.8x\n", *(uint_t*)&(exit_info1)); + PrintError(info->vm_info, info, "io_info1 high = 0x%.8x\n", *(uint_t *)(((uint8_t *)&(exit_info1)) + 4)); - PrintError("io_info2 low = 0x%.8x\n", *(uint_t*)&(exit_info2)); - PrintError("io_info2 high = 0x%.8x\n", *(uint_t *)(((uint8_t *)&(exit_info2)) + 4)); + PrintError(info->vm_info, info, "io_info2 low = 0x%.8x\n", *(uint_t*)&(exit_info2)); + PrintError(info->vm_info, info, "io_info2 high = 0x%.8x\n", *(uint_t *)(((uint8_t *)&(exit_info2)) + 4)); if (info->shdw_pg_mode == SHADOW_PAGING) { @@ -375,7 +375,7 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i if (exit_code == SVM_EXIT_INTR) { - //PrintDebug("INTR ret IP = %x\n", guest_state->rip); + //PrintDebug(info->vm_info, info, "INTR ret IP = %x\n", guest_state->rip); } return 0; diff --git a/palacios/src/palacios/svm_io.c b/palacios/src/palacios/svm_io.c index ff85d09..95dc860 100644 --- a/palacios/src/palacios/svm_io.c +++ b/palacios/src/palacios/svm_io.c @@ -53,7 +53,7 @@ int v3_init_svm_io_map(struct v3_vm_info * vm) { temp = V3_AllocPages(3); if (!temp) { - PrintError("Cannot allocate io bitmap\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate io bitmap\n"); return -1; } @@ -87,17 +87,17 @@ int v3_handle_svm_io_in(struct guest_info * core, struct svm_io_info * io_info) read_size = 4; } - PrintDebug("IN of %d bytes on port %d (0x%x)\n", read_size, io_info->port, io_info->port); + PrintDebug(core->vm_info, core, "IN of %d bytes on port %d (0x%x)\n", read_size, io_info->port, io_info->port); if (hook == NULL) { - PrintDebug("IN operation on unhooked IO port 0x%x - returning zero\n", io_info->port); + PrintDebug(core->vm_info, core, "IN operation on unhooked IO port 0x%x - returning zero\n", io_info->port); core->vm_regs.rax >>= 8*read_size; core->vm_regs.rax <<= 8*read_size; } else { if (hook->read(core, io_info->port, &(core->vm_regs.rax), read_size, hook->priv_data) != read_size) { // not sure how we handle errors..... - PrintError("Read Failure for in on port 0x%x\n", io_info->port); + PrintError(core->vm_info, core, "Read Failure for in on port 0x%x\n", io_info->port); return -1; } } @@ -135,7 +135,7 @@ int v3_handle_svm_io_ins(struct guest_info * core, struct svm_io_info * io_info) if (v3_gva_to_hva(core, get_addr_linear(core, core->rip, &(core->segments.cs)), &inst_ptr) == -1) { - PrintError("Can't access instruction\n"); + PrintError(core->vm_info, core, "Can't access instruction\n"); return -1; } @@ -166,7 +166,7 @@ int v3_handle_svm_io_ins(struct guest_info * core, struct svm_io_info * io_info) } - PrintDebug("INS on port %d (0x%x)\n", io_info->port, io_info->port); + PrintDebug(core->vm_info, core, "INS on port %d (0x%x)\n", io_info->port, io_info->port); if (io_info->sz8) { read_size = 1; @@ -175,7 +175,7 @@ int v3_handle_svm_io_ins(struct guest_info * core, struct svm_io_info * io_info) } else if (io_info->sz32) { read_size = 4; } else { - PrintError("io_info Invalid Size\n"); + PrintError(core->vm_info, core, "io_info Invalid Size\n"); return -1; } @@ -190,9 +190,9 @@ int v3_handle_svm_io_ins(struct guest_info * core, struct svm_io_info * io_info) // This value should be set depending on the host register size... mask = get_gpr_mask(core); - PrintDebug("INS io_info invalid address size, mask=0x%p, io_info=0x%p\n", + PrintDebug(core->vm_info, core, "INS io_info invalid address size, mask=0x%p, io_info=0x%p\n", (void *)(addr_t)mask, (void *)(addr_t)(io_info)); - // PrintDebug("INS Aborted... Check implementation\n"); + // PrintDebug(core->vm_info, core, "INS Aborted... Check implementation\n"); //return -1; } @@ -201,28 +201,28 @@ int v3_handle_svm_io_ins(struct guest_info * core, struct svm_io_info * io_info) //rep_num = info->vm_regs.rcx; } - PrintDebug("INS size=%d for %d steps\n", read_size, rep_num); + PrintDebug(core->vm_info, core, "INS size=%d for %d steps\n", read_size, rep_num); while (rep_num > 0) { addr_t host_addr; dst_addr = get_addr_linear(core, (core->vm_regs.rdi & mask), theseg); - // PrintDebug("Writing 0x%p\n", (void *)dst_addr); + // PrintDebug(core->vm_info, core, "Writing 0x%p\n", (void *)dst_addr); if (v3_gva_to_hva(core, dst_addr, &host_addr) == -1) { // either page fault or gpf... - PrintError("Could not convert Guest VA to host VA\n"); + PrintError(core->vm_info, core, "Could not convert Guest VA to host VA\n"); return -1; } if (hook == NULL) { - PrintDebug("INS operation on unhooked IO port 0x%x - returning zeros\n", io_info->port); + PrintDebug(core->vm_info, core, "INS operation on unhooked IO port 0x%x - returning zeros\n", io_info->port); memset((char*)host_addr,0,read_size); } else { if (hook->read(core, io_info->port, (char *)host_addr, read_size, hook->priv_data) != read_size) { // not sure how we handle errors..... - PrintError("Read Failure for ins on port 0x%x\n", io_info->port); + PrintError(core->vm_info, core, "Read Failure for ins on port 0x%x\n", io_info->port); return -1; } } @@ -251,14 +251,14 @@ int v3_handle_svm_io_out(struct guest_info * core, struct svm_io_info * io_info) write_size = 4; } - PrintDebug("OUT of %d bytes on port %d (0x%x)\n", write_size, io_info->port, io_info->port); + PrintDebug(core->vm_info, core, "OUT of %d bytes on port %d (0x%x)\n", write_size, io_info->port, io_info->port); if (hook == NULL) { - PrintDebug("OUT operation on unhooked IO port 0x%x - ignored\n", io_info->port); + PrintDebug(core->vm_info, core, "OUT operation on unhooked IO port 0x%x - ignored\n", io_info->port); } else { if (hook->write(core, io_info->port, &(core->vm_regs.rax), write_size, hook->priv_data) != write_size) { // not sure how we handle errors..... - PrintError("Write Failure for out on port 0x%x\n", io_info->port); + PrintError(core->vm_info, core, "Write Failure for out on port 0x%x\n", io_info->port); return -1; } } @@ -292,7 +292,7 @@ int v3_handle_svm_io_outs(struct guest_info * core, struct svm_io_info * io_info direction = -1; } - PrintDebug("OUTS on port %d (0x%x)\n", io_info->port, io_info->port); + PrintDebug(core->vm_info, core, "OUTS on port %d (0x%x)\n", io_info->port, io_info->port); if (io_info->sz8) { write_size = 1; @@ -313,12 +313,12 @@ int v3_handle_svm_io_outs(struct guest_info * core, struct svm_io_info * io_info // This value should be set depending on the host register size... mask = get_gpr_mask(core); - PrintDebug("OUTS io_info invalid address size, mask=0%p, io_info=0x%p\n", + PrintDebug(core->vm_info, core, "OUTS io_info invalid address size, mask=0%p, io_info=0x%p\n", (void *)(addr_t)mask, (void *)(addr_t)io_info); - // PrintDebug("INS Aborted... Check implementation\n"); + // PrintDebug(core->vm_info, core, "INS Aborted... Check implementation\n"); //return -1; // should never happen - //PrintDebug("Invalid Address length\n"); + //PrintDebug(core->vm_info, core, "Invalid Address length\n"); //return -1; } @@ -330,7 +330,7 @@ int v3_handle_svm_io_outs(struct guest_info * core, struct svm_io_info * io_info if (v3_gva_to_hva(core, get_addr_linear(core, core->rip, &(core->segments.cs)), &inst_ptr) == -1) { - PrintError("Can't access instruction\n"); + PrintError(core->vm_info, core, "Can't access instruction\n"); return -1; } @@ -360,7 +360,7 @@ int v3_handle_svm_io_outs(struct guest_info * core, struct svm_io_info * io_info inst_ptr++; } - PrintDebug("OUTS size=%d for %d steps\n", write_size, rep_num); + PrintDebug(core->vm_info, core, "OUTS size=%d for %d steps\n", write_size, rep_num); while (rep_num > 0) { addr_t host_addr = 0; @@ -368,16 +368,16 @@ int v3_handle_svm_io_outs(struct guest_info * core, struct svm_io_info * io_info dst_addr = get_addr_linear(core, (core->vm_regs.rsi & mask), theseg); if (v3_gva_to_hva(core, dst_addr, &host_addr) == -1) { - PrintError("Could not translate outs dest addr, either page fault or gpf...\n"); + PrintError(core->vm_info, core, "Could not translate outs dest addr, either page fault or gpf...\n"); return -1; } if (hook == NULL) { - PrintDebug("OUTS operation on unhooked IO port 0x%x - ignored\n", io_info->port); + PrintDebug(core->vm_info, core, "OUTS operation on unhooked IO port 0x%x - ignored\n", io_info->port); } else { if (hook->write(core, io_info->port, (char*)host_addr, write_size, hook->priv_data) != write_size) { // not sure how we handle errors..... - PrintError("Write Failure for outs on port 0x%x\n", io_info->port); + PrintError(core->vm_info, core, "Write Failure for outs on port 0x%x\n", io_info->port); return -1; } } diff --git a/palacios/src/palacios/svm_msr.c b/palacios/src/palacios/svm_msr.c index f8ae00f..5c39c6e 100644 --- a/palacios/src/palacios/svm_msr.c +++ b/palacios/src/palacios/svm_msr.c @@ -47,7 +47,7 @@ static int get_bitmap_index(uint_t msr) { (msr <= AMD_7_8_GEN_MSRS_END)) { return (AMD_7_8_GEN_MSRS_INDEX + (msr - AMD_7_8_GEN_MSRS_START)); } else { - PrintError("MSR out of range (MSR=0x%x)\n", msr); + PrintError(VM_NONE, VCORE_NONE, "MSR out of range (MSR=0x%x)\n", msr); return -1; } } @@ -62,7 +62,7 @@ static int update_map(struct v3_vm_info * vm, uint_t msr, int hook_reads, int ho uint8_t * bitmap = (uint8_t *)(vm->msr_map.arch_data); if (index == -1) { - PrintError("MSR (0x%x) out of bitmap range\n", msr); + PrintError(vm, VCORE_NONE, "MSR (0x%x) out of bitmap range\n", msr); return 0; } @@ -90,7 +90,7 @@ int v3_init_svm_msr_map(struct v3_vm_info * vm) { temp = V3_AllocPages(2); if (!temp) { - PrintError("Cannot allocate msr bitmap\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate msr bitmap\n"); return -1; } diff --git a/palacios/src/palacios/svm_wbinvd.c b/palacios/src/palacios/svm_wbinvd.c index eb8a35f..9d96f31 100644 --- a/palacios/src/palacios/svm_wbinvd.c +++ b/palacios/src/palacios/svm_wbinvd.c @@ -31,7 +31,7 @@ int v3_handle_svm_wbinvd(struct guest_info * info) { if (info->cpl != 0) { - PrintDebug("WBINVD: cpl != 0, injecting GPF\n"); + PrintDebug(info->vm_info, info, "WBINVD: cpl != 0, injecting GPF\n"); v3_raise_exception(info, GPF_EXCEPTION); } else { info->rip += 2; diff --git a/palacios/src/palacios/vm_guest.c b/palacios/src/palacios/vm_guest.c index dc47a46..48f0d8a 100644 --- a/palacios/src/palacios/vm_guest.c +++ b/palacios/src/palacios/vm_guest.c @@ -48,8 +48,8 @@ v3_cpu_mode_t v3_get_vm_cpu_mode(struct guest_info * info) { cr0 = (struct cr0_32 *)&(info->ctrl_regs.cr0); efer = (struct efer_64 *)&(info->ctrl_regs.efer); } else { - PrintError("Invalid Paging Mode...\n"); - V3_ASSERT(0); + PrintError(info->vm_info, info, "Invalid Paging Mode...\n"); + V3_ASSERT(info->vm_info, info, 0); return -1; } @@ -82,8 +82,8 @@ uint_t v3_get_addr_width(struct guest_info * info) { cr0 = (struct cr0_32 *)&(info->ctrl_regs.cr0); efer = (struct efer_64 *)&(info->ctrl_regs.efer); } else { - PrintError("Invalid Paging Mode...\n"); - V3_ASSERT(0); + PrintError(info->vm_info, info, "Invalid Paging Mode...\n"); + V3_ASSERT(info->vm_info, info, 0); return -1; } @@ -136,8 +136,8 @@ v3_mem_mode_t v3_get_vm_mem_mode(struct guest_info * info) { } else if (info->shdw_pg_mode == NESTED_PAGING) { cr0 = (struct cr0_32 *)&(info->ctrl_regs.cr0); } else { - PrintError("Invalid Paging Mode...\n"); - V3_ASSERT(0); + PrintError(info->vm_info, info, "Invalid Paging Mode...\n"); + V3_ASSERT(info->vm_info, info, 0); return -1; } @@ -174,7 +174,7 @@ static int info_hcall(struct guest_info * core, uint_t hcall_id, void * priv_dat extern v3_cpu_arch_t v3_mach_type; int cpu_valid = 0; - V3_Print("************** Guest State ************\n"); + V3_Print(core->vm_info, core, "************** Guest State ************\n"); v3_print_guest_state(core); // init SVM/VMX @@ -191,7 +191,7 @@ static int info_hcall(struct guest_info * core, uint_t hcall_id, void * priv_dat } #endif if (!cpu_valid) { - PrintError("Invalid CPU Type 0x%x\n", v3_mach_type); + PrintError(core->vm_info, core, "Invalid CPU Type 0x%x\n", v3_mach_type); return -1; } @@ -238,14 +238,14 @@ int v3_init_vm(struct v3_vm_info * vm) { // Initialize the memory map if (v3_init_mem_map(vm) == -1) { - PrintError("Could not initialize shadow map\n"); + PrintError(vm, VCORE_NONE, "Could not initialize shadow map\n"); return -1; } v3_init_mem_hooks(vm); if (v3_init_shdw_impl(vm) == -1) { - PrintError("VM initialization error in shadow implementaion\n"); + PrintError(vm, VCORE_NONE, "VM initialization error in shadow implementaion\n"); return -1; } @@ -282,13 +282,13 @@ int v3_init_vm(struct v3_vm_info * vm) { break; #endif default: - PrintError("Invalid CPU Type 0x%x\n", v3_mach_type); + PrintError(vm, VCORE_NONE, "Invalid CPU Type 0x%x\n", v3_mach_type); return -1; } v3_register_hypercall(vm, GUEST_INFO_HCALL, info_hcall, NULL); - V3_Print("GUEST_INFO_HCALL=%x\n", GUEST_INFO_HCALL); + V3_Print(vm, VCORE_NONE, "GUEST_INFO_HCALL=%x\n", GUEST_INFO_HCALL); return 0; } @@ -323,7 +323,7 @@ int v3_free_vm_internal(struct v3_vm_info * vm) { break; #endif default: - PrintError("Invalid CPU Type 0x%x\n", v3_mach_type); + PrintError(vm, VCORE_NONE, "Invalid CPU Type 0x%x\n", v3_mach_type); return -1; } @@ -395,7 +395,7 @@ int v3_init_core(struct guest_info * core) { case V3_SVM_CPU: case V3_SVM_REV3_CPU: if (v3_init_svm_vmcb(core, vm->vm_class) == -1) { - PrintError("Error in SVM initialization\n"); + PrintError(vm, core, "Error in SVM initialization\n"); return -1; } break; @@ -405,13 +405,13 @@ int v3_init_core(struct guest_info * core) { case V3_VMX_EPT_CPU: case V3_VMX_EPT_UG_CPU: if (v3_init_vmx_vmcs(core, vm->vm_class) == -1) { - PrintError("Error in VMX initialization\n"); + PrintError(vm, core, "Error in VMX initialization\n"); return -1; } break; #endif default: - PrintError("Invalid CPU Type 0x%x\n", v3_mach_type); + PrintError(vm, core, "Invalid CPU Type 0x%x\n", v3_mach_type); return -1; } @@ -451,7 +451,7 @@ int v3_free_core(struct guest_info * core) { case V3_SVM_CPU: case V3_SVM_REV3_CPU: if (v3_deinit_svm_vmcb(core) == -1) { - PrintError("Error in SVM initialization\n"); + PrintError(VM_NONE,VCORE_NONE, "Error in SVM deinitialization\n"); return -1; } break; @@ -461,13 +461,13 @@ int v3_free_core(struct guest_info * core) { case V3_VMX_EPT_CPU: case V3_VMX_EPT_UG_CPU: if (v3_deinit_vmx_vmcs(core) == -1) { - PrintError("Error in VMX initialization\n"); + PrintError(VM_NONE, VCORE_NONE, "Error in VMX initialization\n"); return -1; } break; #endif default: - PrintError("Invalid CPU Type 0x%x\n", v3_mach_type); + PrintError(core->vm_info, core, "Invalid CPU Type 0x%x\n", v3_mach_type); return -1; } diff --git a/palacios/src/palacios/vm_guest_mem.c b/palacios/src/palacios/vm_guest_mem.c index d05bd39..e2729b9 100644 --- a/palacios/src/palacios/vm_guest_mem.c +++ b/palacios/src/palacios/vm_guest_mem.c @@ -39,12 +39,12 @@ int v3_hva_to_hpa(addr_t hva, addr_t * hpa) { *hpa = (addr_t)(os_hooks)->vaddr_to_paddr((void *)hva); if (*hpa == 0) { - PrintDebug("In HVA->HPA: Invalid HVA(%p)->HPA lookup\n", + PrintDebug(VM_NONE, VCORE_NONE, "In HVA->HPA: Invalid HVA(%p)->HPA lookup\n", (void *)hva); return -1; } } else { - PrintDebug("In HVA->HPA: os_hooks not defined\n"); + PrintDebug(VM_NONE, VCORE_NONE,"In HVA->HPA: os_hooks not defined\n"); return -1; } return 0; @@ -57,12 +57,12 @@ int v3_hpa_to_hva(addr_t hpa, addr_t * hva) { *hva = (addr_t)(os_hooks)->paddr_to_vaddr((void *)hpa); if (*hva == 0) { - PrintDebug("In HPA->HVA: Invalid HPA(%p)->HVA lookup\n", + PrintDebug(VM_NONE, VCORE_NONE,"In HPA->HVA: Invalid HPA(%p)->HVA lookup\n", (void *)hpa); return -1; } } else { - PrintDebug("In HPA->HVA: os_hooks not defined\n"); + PrintDebug(VM_NONE, VCORE_NONE,"In HPA->HVA: os_hooks not defined\n"); return -1; } return 0; @@ -72,13 +72,13 @@ int v3_gpa_to_hpa(struct guest_info * info, addr_t gpa, addr_t * hpa) { struct v3_mem_region * reg = v3_get_mem_region(info->vm_info, info->vcpu_id, gpa); if (reg == NULL) { - PrintDebug("In GPA->HPA: Could not find address in shadow map (addr=%p) (NULL REGION)\n", + PrintDebug(info->vm_info,info,"In GPA->HPA: Could not find address in shadow map (addr=%p) (NULL REGION)\n", (void *)gpa); return -1; } if (reg->flags.alloced == 0) { - //PrintDebug("In GPA->HPA: Tried to translate physical address of non allocated page (addr=%p)\n", + //PrintDebug(info->vm_info, info, "In GPA->HPA: Tried to translate physical address of non allocated page (addr=%p)\n", // (void *)gpa); //v3_print_mem_map(info->vm_info); return -1; @@ -96,7 +96,7 @@ int v3_gpa_to_hpa(struct guest_info * info, addr_t gpa, addr_t * hpa) { // int v3_hpa_to_gpa(struct guest_info * guest_info, addr_t hpa, addr_t * gpa) { *gpa = 0; - PrintDebug("ERROR!!! HPA->GPA currently not implemented!!!\n"); + PrintDebug(guest_info->vm_info, guest_info, "ERROR!!! HPA->GPA currently not implemented!!!\n"); return -1; } @@ -115,13 +115,13 @@ int v3_hva_to_gpa(struct guest_info * guest_info, addr_t hva, addr_t * gpa) { *gpa = 0; if (v3_hva_to_hpa(hva, &hpa) != 0) { - PrintDebug("In HVA->GPA: Invalid HVA(%p)->HPA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In HVA->GPA: Invalid HVA(%p)->HPA lookup\n", (void *)hva); return -1; } if (v3_hpa_to_gpa(guest_info, hpa, gpa) != 0) { - PrintDebug("In HVA->GPA: Invalid HPA(%p)->GPA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In HVA->GPA: Invalid HPA(%p)->GPA lookup\n", (void *)hpa); return -1; } @@ -138,13 +138,13 @@ int v3_gpa_to_hva(struct guest_info * guest_info, addr_t gpa, addr_t * hva) { *hva = 0; if (v3_gpa_to_hpa(guest_info, gpa, &hpa) != 0) { - // PrintDebug("In GPA->HVA: Invalid GPA(%p)->HPA lookup\n", + // PrintDebug(guest_info->vm_info, guest_info, "In GPA->HVA: Invalid GPA(%p)->HPA lookup\n", // (void *)gpa); return -1; } if (v3_hpa_to_hva(hpa, hva) != 0) { - PrintDebug("In GPA->HVA: Invalid HPA(%p)->HVA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In GPA->HVA: Invalid HPA(%p)->HVA lookup\n", (void *)hpa); return -1; } @@ -173,14 +173,14 @@ int v3_gva_to_gpa(struct guest_info * guest_info, addr_t gva, addr_t * gpa) { switch (guest_info->cpu_mode) { case PROTECTED: if (v3_translate_guest_pt_32(guest_info, guest_cr3, gva, gpa) == -1) { - PrintDebug("Could not translate addr (%p) through 32 bit guest PT at %p\n", + PrintDebug(guest_info->vm_info, guest_info, "Could not translate addr (%p) through 32 bit guest PT at %p\n", (void *)gva, (void *)(addr_t)guest_cr3); return -1; } break; case PROTECTED_PAE: if (v3_translate_guest_pt_32pae(guest_info, guest_cr3, gva, gpa) == -1) { - PrintDebug("Could not translate addr (%p) through 32 bitpae guest PT at %p\n", + PrintDebug(guest_info->vm_info, guest_info, "Could not translate addr (%p) through 32 bitpae guest PT at %p\n", (void *)gva, (void *)(addr_t)guest_cr3); return -1; } @@ -189,7 +189,7 @@ int v3_gva_to_gpa(struct guest_info * guest_info, addr_t gva, addr_t * gpa) { case LONG_32_COMPAT: case LONG_16_COMPAT: if (v3_translate_guest_pt_64(guest_info, guest_cr3, gva, gpa) == -1) { - PrintDebug("Could not translate addr (%p) through 64 bit guest PT at %p\n", + PrintDebug(guest_info->vm_info, guest_info, "Could not translate addr (%p) through 64 bit guest PT at %p\n", (void *)gva, (void *)(addr_t)guest_cr3); return -1; } @@ -210,7 +210,7 @@ int v3_gva_to_gpa(struct guest_info * guest_info, addr_t gva, addr_t * gpa) { */ int v3_gpa_to_gva(struct guest_info * guest_info, addr_t gpa, addr_t * gva) { *gva = 0; - PrintDebug("ERROR!!: GPA->GVA Not Implemented!!\n"); + PrintDebug(guest_info->vm_info, guest_info, "ERROR!!: GPA->GVA Not Implemented!!\n"); return -1; } @@ -226,13 +226,13 @@ int v3_gva_to_hpa(struct guest_info * guest_info, addr_t gva, addr_t * hpa) { *hpa = 0; if (v3_gva_to_gpa(guest_info, gva, &gpa) != 0) { - PrintDebug("In GVA->HPA: Invalid GVA(%p)->GPA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In GVA->HPA: Invalid GVA(%p)->GPA lookup\n", (void *)gva); return -1; } if (v3_gpa_to_hpa(guest_info, gpa, hpa) != 0) { - PrintDebug("In GVA->HPA: Invalid GPA(%p)->HPA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In GVA->HPA: Invalid GPA(%p)->HPA lookup\n", (void *)gpa); return -1; } @@ -247,13 +247,13 @@ int v3_hpa_to_gva(struct guest_info * guest_info, addr_t hpa, addr_t * gva) { *gva = 0; if (v3_hpa_to_gpa(guest_info, hpa, &gpa) != 0) { - PrintDebug("In HPA->GVA: Invalid HPA(%p)->GPA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In HPA->GVA: Invalid HPA(%p)->GPA lookup\n", (void *)hpa); return -1; } if (v3_gpa_to_gva(guest_info, gpa, gva) != 0) { - PrintDebug("In HPA->GVA: Invalid GPA(%p)->GVA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In HPA->GVA: Invalid GPA(%p)->GVA lookup\n", (void *)gpa); return -1; } @@ -271,19 +271,19 @@ int v3_gva_to_hva(struct guest_info * guest_info, addr_t gva, addr_t * hva) { *hva = 0; if (v3_gva_to_gpa(guest_info, gva, &gpa) != 0) { - PrintDebug("In GVA->HVA: Invalid GVA(%p)->GPA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In GVA->HVA: Invalid GVA(%p)->GPA lookup\n", (void *)gva); return -1; } if (v3_gpa_to_hpa(guest_info, gpa, &hpa) != 0) { - PrintDebug("In GVA->HVA: Invalid GPA(%p)->HPA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In GVA->HVA: Invalid GPA(%p)->HPA lookup\n", (void *)gpa); return -1; } if (v3_hpa_to_hva(hpa, hva) != 0) { - PrintDebug("In GVA->HVA: Invalid HPA(%p)->HVA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In GVA->HVA: Invalid HPA(%p)->HVA lookup\n", (void *)hpa); return -1; } @@ -300,19 +300,19 @@ int v3_hva_to_gva(struct guest_info * guest_info, addr_t hva, addr_t * gva) { *gva = 0; if (v3_hva_to_hpa(hva, &hpa) != 0) { - PrintDebug("In HVA->GVA: Invalid HVA(%p)->HPA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In HVA->GVA: Invalid HVA(%p)->HPA lookup\n", (void *)hva); return -1; } if (v3_hpa_to_gpa(guest_info, hpa, &gpa) != 0) { - PrintDebug("In HVA->GVA: Invalid HPA(%p)->GPA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In HVA->GVA: Invalid HPA(%p)->GPA lookup\n", (void *)hva); return -1; } if (v3_gpa_to_gva(guest_info, gpa, gva) != 0) { - PrintDebug("In HVA->GVA: Invalid GPA(%p)->GVA lookup\n", + PrintDebug(guest_info->vm_info, guest_info, "In HVA->GVA: Invalid GPA(%p)->GVA lookup\n", (void *)gpa); return -1; } @@ -341,7 +341,7 @@ int v3_read_gva_memory(struct guest_info * guest_info, addr_t gva, int count, uc if (v3_gva_to_hva(guest_info, cursor, &host_addr) != 0) { - PrintDebug("Invalid GVA(%p)->HVA lookup\n", (void *)cursor); + PrintDebug(guest_info->vm_info, guest_info, "Invalid GVA(%p)->HVA lookup\n", (void *)cursor); return bytes_read; } @@ -379,10 +379,10 @@ int v3_read_gpa_memory(struct guest_info * guest_info, addr_t gpa, int count, uc } /* - 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); + PrintDebug(info->vm_info, info, "Trying to read %d bytes\n", bytes_to_copy); + PrintDebug(info->vm_info, info, "Dist to page edge=%d\n", dist_to_pg_edge); + PrintDebug(info->vm_info, info, "PAGE_ADDR=0x%x\n", PAGE_ADDR(cursor)); + PrintDebug(info->vm_info, info, "guest_pa=0x%x\n", guest_pa); */ memcpy(dest + bytes_read, (void*)host_addr, bytes_to_copy); @@ -412,7 +412,7 @@ int v3_write_gva_memory(struct guest_info * guest_info, addr_t gva, int count, u if (v3_gva_to_hva(guest_info, cursor, &host_addr) != 0) { - PrintDebug("Invalid GVA(%p)->HVA lookup\n", (void *)cursor); + PrintDebug(guest_info->vm_info, guest_info, "Invalid GVA(%p)->HVA lookup\n", (void *)cursor); return bytes_written; } diff --git a/palacios/src/palacios/vmcb.c b/palacios/src/palacios/vmcb.c index 9152709..9b0e29e 100644 --- a/palacios/src/palacios/vmcb.c +++ b/palacios/src/palacios/vmcb.c @@ -91,318 +91,318 @@ void PrintDebugVMCB(vmcb_t * vmcb) { vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA(vmcb); vmcb_saved_state_t * guest_area = GET_VMCB_SAVE_STATE_AREA(vmcb); - PrintDebug("VMCB (0x%p)\n", (void *)vmcb); + PrintDebug(VM_NONE, VCORE_NONE, "VMCB (0x%p)\n", (void *)vmcb); - PrintDebug("--Control Area--\n"); - PrintDebug("CR Reads: %x\n", *(ushort_t*)&(ctrl_area->cr_reads)); - PrintDebug("CR Writes: %x\n", *(ushort_t*)&(ctrl_area->cr_writes)); - PrintDebug("DR Reads: %x\n", *(ushort_t*)&(ctrl_area->dr_reads)); - PrintDebug("DR Writes: %x\n", *(ushort_t*)&(ctrl_area->dr_writes)); + PrintDebug(VM_NONE, VCORE_NONE, "--Control Area--\n"); + PrintDebug(VM_NONE, VCORE_NONE, "CR Reads: %x\n", *(ushort_t*)&(ctrl_area->cr_reads)); + PrintDebug(VM_NONE, VCORE_NONE, "CR Writes: %x\n", *(ushort_t*)&(ctrl_area->cr_writes)); + PrintDebug(VM_NONE, VCORE_NONE, "DR Reads: %x\n", *(ushort_t*)&(ctrl_area->dr_reads)); + PrintDebug(VM_NONE, VCORE_NONE, "DR Writes: %x\n", *(ushort_t*)&(ctrl_area->dr_writes)); - PrintDebug("Exception Bitmap: %x (at 0x%p)\n", *(uint_t*)&(ctrl_area->exceptions), (void *)&(ctrl_area->exceptions)); - PrintDebug("\tDivide-by-Zero: %d\n", ctrl_area->exceptions.de); - PrintDebug("\tDebug: %d\n", ctrl_area->exceptions.db); - PrintDebug("\tNon-maskable interrupts: %d\n", ctrl_area->exceptions.nmi); - PrintDebug("\tBreakpoint: %d\n", ctrl_area->exceptions.bp); - PrintDebug("\tOverflow: %d\n", ctrl_area->exceptions.of); - PrintDebug("\tBound-Range: %d\n", ctrl_area->exceptions.br); - PrintDebug("\tInvalid Opcode: %d\n", ctrl_area->exceptions.ud); - PrintDebug("\tDevice not available: %d\n", ctrl_area->exceptions.nm); - PrintDebug("\tDouble Fault: %d\n", ctrl_area->exceptions.df); - PrintDebug("\tInvalid TSS: %d\n", ctrl_area->exceptions.ts); - PrintDebug("\tSegment not present: %d\n", ctrl_area->exceptions.np); - PrintDebug("\tStack: %d\n", ctrl_area->exceptions.ss); - PrintDebug("\tGPF: %d\n", ctrl_area->exceptions.gp); - PrintDebug("\tPage Fault: %d\n", ctrl_area->exceptions.pf); - PrintDebug("\tFloating Point: %d\n", ctrl_area->exceptions.mf); - PrintDebug("\tAlignment Check: %d\n", ctrl_area->exceptions.ac); - PrintDebug("\tMachine Check: %d\n", ctrl_area->exceptions.mc); - PrintDebug("\tSIMD floating point: %d\n", ctrl_area->exceptions.xf); - PrintDebug("\tSecurity: %d\n", ctrl_area->exceptions.sx); - - PrintDebug("Instructions bitmap: %.8x (at 0x%p)\n", *(uint_t*)&(ctrl_area->instrs), &(ctrl_area->instrs)); - PrintDebug("\tINTR: %d\n", ctrl_area->instrs.INTR); - PrintDebug("\tNMI: %d\n", ctrl_area->instrs.NMI); - PrintDebug("\tSMI: %d\n", ctrl_area->instrs.SMI); - PrintDebug("\tINIT: %d\n", ctrl_area->instrs.INIT); - PrintDebug("\tVINTR: %d\n", ctrl_area->instrs.VINTR); - PrintDebug("\tCR0: %d\n", ctrl_area->instrs.CR0); - PrintDebug("\tRD_IDTR: %d\n", ctrl_area->instrs.RD_IDTR); - PrintDebug("\tRD_GDTR: %d\n", ctrl_area->instrs.RD_GDTR); - PrintDebug("\tRD_LDTR: %d\n", ctrl_area->instrs.RD_LDTR); - PrintDebug("\tRD_TR: %d\n", ctrl_area->instrs.RD_TR); - PrintDebug("\tWR_IDTR: %d\n", ctrl_area->instrs.WR_IDTR); - PrintDebug("\tWR_GDTR: %d\n", ctrl_area->instrs.WR_GDTR); - PrintDebug("\tWR_LDTR: %d\n", ctrl_area->instrs.WR_LDTR); - PrintDebug("\tWR_TR: %d\n", ctrl_area->instrs.WR_TR); - PrintDebug("\tRDTSC: %d\n", ctrl_area->instrs.RDTSC); - PrintDebug("\tRDPMC: %d\n", ctrl_area->instrs.RDPMC); - PrintDebug("\tPUSHF: %d\n", ctrl_area->instrs.PUSHF); - PrintDebug("\tPOPF: %d\n", ctrl_area->instrs.POPF); - PrintDebug("\tCPUID: %d\n", ctrl_area->instrs.CPUID); - PrintDebug("\tRSM: %d\n", ctrl_area->instrs.RSM); - PrintDebug("\tIRET: %d\n", ctrl_area->instrs.IRET); - PrintDebug("\tINTn: %d\n", ctrl_area->instrs.INTn); - PrintDebug("\tINVD: %d\n", ctrl_area->instrs.INVD); - PrintDebug("\tPAUSE: %d\n", ctrl_area->instrs.PAUSE); - PrintDebug("\tHLT: %d\n", ctrl_area->instrs.HLT); - PrintDebug("\tINVLPG: %d\n", ctrl_area->instrs.INVLPG); - PrintDebug("\tINVLPGA: %d\n", ctrl_area->instrs.INVLPGA); - PrintDebug("\tIOIO_PROT: %d\n", ctrl_area->instrs.IOIO_PROT); - PrintDebug("\tMSR_PROT: %d\n", ctrl_area->instrs.MSR_PROT); - PrintDebug("\ttask_switch: %d\n", ctrl_area->instrs.task_switch); - PrintDebug("\tFERR_FREEZE: %d\n", ctrl_area->instrs.FERR_FREEZE); - PrintDebug("\tshutdown_evts: %d\n", ctrl_area->instrs.shutdown_evts); - - PrintDebug("SVM Instruction Bitmap: %x (at 0x%p)\n", *(uint_t*)&(ctrl_area->svm_instrs), &(ctrl_area->svm_instrs)); - PrintDebug("\tVMRUN: %d\n", ctrl_area->svm_instrs.VMRUN); - PrintDebug("\tVMMCALL: %d\n", ctrl_area->svm_instrs.VMMCALL); - PrintDebug("\tVMLOAD: %d\n", ctrl_area->svm_instrs.VMLOAD); - PrintDebug("\tVMSAVE: %d\n", ctrl_area->svm_instrs.VMSAVE); - PrintDebug("\tSTGI: %d\n", ctrl_area->svm_instrs.STGI); - PrintDebug("\tCLGI: %d\n", ctrl_area->svm_instrs.CLGI); - PrintDebug("\tSKINIT: %d\n", ctrl_area->svm_instrs.SKINIT); - PrintDebug("\tRDTSCP: %d\n", ctrl_area->svm_instrs.RDTSCP); - PrintDebug("\tICEBP: %d\n", ctrl_area->svm_instrs.ICEBP); - PrintDebug("\tWBINVD: %d\n", ctrl_area->svm_instrs.WBINVD); - PrintDebug("\tMONITOR: %d\n", ctrl_area->svm_instrs.MONITOR); - PrintDebug("\tMWAIT_always: %d\n", ctrl_area->svm_instrs.MWAIT_always); - PrintDebug("\tMWAIT_if_armed: %d\n", ctrl_area->svm_instrs.MWAIT_if_armed); + PrintDebug(VM_NONE, VCORE_NONE, "Exception Bitmap: %x (at 0x%p)\n", *(uint_t*)&(ctrl_area->exceptions), (void *)&(ctrl_area->exceptions)); + PrintDebug(VM_NONE, VCORE_NONE, "\tDivide-by-Zero: %d\n", ctrl_area->exceptions.de); + PrintDebug(VM_NONE, VCORE_NONE, "\tDebug: %d\n", ctrl_area->exceptions.db); + PrintDebug(VM_NONE, VCORE_NONE, "\tNon-maskable interrupts: %d\n", ctrl_area->exceptions.nmi); + PrintDebug(VM_NONE, VCORE_NONE, "\tBreakpoint: %d\n", ctrl_area->exceptions.bp); + PrintDebug(VM_NONE, VCORE_NONE, "\tOverflow: %d\n", ctrl_area->exceptions.of); + PrintDebug(VM_NONE, VCORE_NONE, "\tBound-Range: %d\n", ctrl_area->exceptions.br); + PrintDebug(VM_NONE, VCORE_NONE, "\tInvalid Opcode: %d\n", ctrl_area->exceptions.ud); + PrintDebug(VM_NONE, VCORE_NONE, "\tDevice not available: %d\n", ctrl_area->exceptions.nm); + PrintDebug(VM_NONE, VCORE_NONE, "\tDouble Fault: %d\n", ctrl_area->exceptions.df); + PrintDebug(VM_NONE, VCORE_NONE, "\tInvalid TSS: %d\n", ctrl_area->exceptions.ts); + PrintDebug(VM_NONE, VCORE_NONE, "\tSegment not present: %d\n", ctrl_area->exceptions.np); + PrintDebug(VM_NONE, VCORE_NONE, "\tStack: %d\n", ctrl_area->exceptions.ss); + PrintDebug(VM_NONE, VCORE_NONE, "\tGPF: %d\n", ctrl_area->exceptions.gp); + PrintDebug(VM_NONE, VCORE_NONE, "\tPage Fault: %d\n", ctrl_area->exceptions.pf); + PrintDebug(VM_NONE, VCORE_NONE, "\tFloating Point: %d\n", ctrl_area->exceptions.mf); + PrintDebug(VM_NONE, VCORE_NONE, "\tAlignment Check: %d\n", ctrl_area->exceptions.ac); + PrintDebug(VM_NONE, VCORE_NONE, "\tMachine Check: %d\n", ctrl_area->exceptions.mc); + PrintDebug(VM_NONE, VCORE_NONE, "\tSIMD floating point: %d\n", ctrl_area->exceptions.xf); + PrintDebug(VM_NONE, VCORE_NONE, "\tSecurity: %d\n", ctrl_area->exceptions.sx); + + PrintDebug(VM_NONE, VCORE_NONE, "Instructions bitmap: %.8x (at 0x%p)\n", *(uint_t*)&(ctrl_area->instrs), &(ctrl_area->instrs)); + PrintDebug(VM_NONE, VCORE_NONE, "\tINTR: %d\n", ctrl_area->instrs.INTR); + PrintDebug(VM_NONE, VCORE_NONE, "\tNMI: %d\n", ctrl_area->instrs.NMI); + PrintDebug(VM_NONE, VCORE_NONE, "\tSMI: %d\n", ctrl_area->instrs.SMI); + PrintDebug(VM_NONE, VCORE_NONE, "\tINIT: %d\n", ctrl_area->instrs.INIT); + PrintDebug(VM_NONE, VCORE_NONE, "\tVINTR: %d\n", ctrl_area->instrs.VINTR); + PrintDebug(VM_NONE, VCORE_NONE, "\tCR0: %d\n", ctrl_area->instrs.CR0); + PrintDebug(VM_NONE, VCORE_NONE, "\tRD_IDTR: %d\n", ctrl_area->instrs.RD_IDTR); + PrintDebug(VM_NONE, VCORE_NONE, "\tRD_GDTR: %d\n", ctrl_area->instrs.RD_GDTR); + PrintDebug(VM_NONE, VCORE_NONE, "\tRD_LDTR: %d\n", ctrl_area->instrs.RD_LDTR); + PrintDebug(VM_NONE, VCORE_NONE, "\tRD_TR: %d\n", ctrl_area->instrs.RD_TR); + PrintDebug(VM_NONE, VCORE_NONE, "\tWR_IDTR: %d\n", ctrl_area->instrs.WR_IDTR); + PrintDebug(VM_NONE, VCORE_NONE, "\tWR_GDTR: %d\n", ctrl_area->instrs.WR_GDTR); + PrintDebug(VM_NONE, VCORE_NONE, "\tWR_LDTR: %d\n", ctrl_area->instrs.WR_LDTR); + PrintDebug(VM_NONE, VCORE_NONE, "\tWR_TR: %d\n", ctrl_area->instrs.WR_TR); + PrintDebug(VM_NONE, VCORE_NONE, "\tRDTSC: %d\n", ctrl_area->instrs.RDTSC); + PrintDebug(VM_NONE, VCORE_NONE, "\tRDPMC: %d\n", ctrl_area->instrs.RDPMC); + PrintDebug(VM_NONE, VCORE_NONE, "\tPUSHF: %d\n", ctrl_area->instrs.PUSHF); + PrintDebug(VM_NONE, VCORE_NONE, "\tPOPF: %d\n", ctrl_area->instrs.POPF); + PrintDebug(VM_NONE, VCORE_NONE, "\tCPUID: %d\n", ctrl_area->instrs.CPUID); + PrintDebug(VM_NONE, VCORE_NONE, "\tRSM: %d\n", ctrl_area->instrs.RSM); + PrintDebug(VM_NONE, VCORE_NONE, "\tIRET: %d\n", ctrl_area->instrs.IRET); + PrintDebug(VM_NONE, VCORE_NONE, "\tINTn: %d\n", ctrl_area->instrs.INTn); + PrintDebug(VM_NONE, VCORE_NONE, "\tINVD: %d\n", ctrl_area->instrs.INVD); + PrintDebug(VM_NONE, VCORE_NONE, "\tPAUSE: %d\n", ctrl_area->instrs.PAUSE); + PrintDebug(VM_NONE, VCORE_NONE, "\tHLT: %d\n", ctrl_area->instrs.HLT); + PrintDebug(VM_NONE, VCORE_NONE, "\tINVLPG: %d\n", ctrl_area->instrs.INVLPG); + PrintDebug(VM_NONE, VCORE_NONE, "\tINVLPGA: %d\n", ctrl_area->instrs.INVLPGA); + PrintDebug(VM_NONE, VCORE_NONE, "\tIOIO_PROT: %d\n", ctrl_area->instrs.IOIO_PROT); + PrintDebug(VM_NONE, VCORE_NONE, "\tMSR_PROT: %d\n", ctrl_area->instrs.MSR_PROT); + PrintDebug(VM_NONE, VCORE_NONE, "\ttask_switch: %d\n", ctrl_area->instrs.task_switch); + PrintDebug(VM_NONE, VCORE_NONE, "\tFERR_FREEZE: %d\n", ctrl_area->instrs.FERR_FREEZE); + PrintDebug(VM_NONE, VCORE_NONE, "\tshutdown_evts: %d\n", ctrl_area->instrs.shutdown_evts); + + PrintDebug(VM_NONE, VCORE_NONE, "SVM Instruction Bitmap: %x (at 0x%p)\n", *(uint_t*)&(ctrl_area->svm_instrs), &(ctrl_area->svm_instrs)); + PrintDebug(VM_NONE, VCORE_NONE, "\tVMRUN: %d\n", ctrl_area->svm_instrs.VMRUN); + PrintDebug(VM_NONE, VCORE_NONE, "\tVMMCALL: %d\n", ctrl_area->svm_instrs.VMMCALL); + PrintDebug(VM_NONE, VCORE_NONE, "\tVMLOAD: %d\n", ctrl_area->svm_instrs.VMLOAD); + PrintDebug(VM_NONE, VCORE_NONE, "\tVMSAVE: %d\n", ctrl_area->svm_instrs.VMSAVE); + PrintDebug(VM_NONE, VCORE_NONE, "\tSTGI: %d\n", ctrl_area->svm_instrs.STGI); + PrintDebug(VM_NONE, VCORE_NONE, "\tCLGI: %d\n", ctrl_area->svm_instrs.CLGI); + PrintDebug(VM_NONE, VCORE_NONE, "\tSKINIT: %d\n", ctrl_area->svm_instrs.SKINIT); + PrintDebug(VM_NONE, VCORE_NONE, "\tRDTSCP: %d\n", ctrl_area->svm_instrs.RDTSCP); + PrintDebug(VM_NONE, VCORE_NONE, "\tICEBP: %d\n", ctrl_area->svm_instrs.ICEBP); + PrintDebug(VM_NONE, VCORE_NONE, "\tWBINVD: %d\n", ctrl_area->svm_instrs.WBINVD); + PrintDebug(VM_NONE, VCORE_NONE, "\tMONITOR: %d\n", ctrl_area->svm_instrs.MONITOR); + PrintDebug(VM_NONE, VCORE_NONE, "\tMWAIT_always: %d\n", ctrl_area->svm_instrs.MWAIT_always); + PrintDebug(VM_NONE, VCORE_NONE, "\tMWAIT_if_armed: %d\n", ctrl_area->svm_instrs.MWAIT_if_armed); tmp_reg.r_reg = ctrl_area->IOPM_BASE_PA; - PrintDebug("IOPM_BASE_PA: lo: 0x%x, hi: 0x%x\n", tmp_reg.e_reg.low, tmp_reg.e_reg.high); + PrintDebug(VM_NONE, VCORE_NONE, "IOPM_BASE_PA: lo: 0x%x, hi: 0x%x\n", tmp_reg.e_reg.low, tmp_reg.e_reg.high); tmp_reg.r_reg = ctrl_area->MSRPM_BASE_PA; - PrintDebug("MSRPM_BASE_PA: lo: 0x%x, hi: 0x%x\n", tmp_reg.e_reg.low, tmp_reg.e_reg.high); + PrintDebug(VM_NONE, VCORE_NONE, "MSRPM_BASE_PA: lo: 0x%x, hi: 0x%x\n", tmp_reg.e_reg.low, tmp_reg.e_reg.high); tmp_reg.r_reg = ctrl_area->TSC_OFFSET; - PrintDebug("TSC_OFFSET: lo: 0x%x, hi: 0x%x\n", tmp_reg.e_reg.low, tmp_reg.e_reg.high); + PrintDebug(VM_NONE, VCORE_NONE, "TSC_OFFSET: lo: 0x%x, hi: 0x%x\n", tmp_reg.e_reg.low, tmp_reg.e_reg.high); - PrintDebug("guest_ASID: %d\n", ctrl_area->guest_ASID); - PrintDebug("TLB_CONTROL: %d\n", ctrl_area->TLB_CONTROL); + PrintDebug(VM_NONE, VCORE_NONE, "guest_ASID: %d\n", ctrl_area->guest_ASID); + PrintDebug(VM_NONE, VCORE_NONE, "TLB_CONTROL: %d\n", ctrl_area->TLB_CONTROL); - PrintDebug("Guest Control Bitmap: %x (at 0x%p)\n", *(uint_t*)&(ctrl_area->guest_ctrl), &(ctrl_area->guest_ctrl)); - PrintDebug("\tV_TPR: %d\n", ctrl_area->guest_ctrl.V_TPR); - PrintDebug("\tV_IRQ: %d\n", ctrl_area->guest_ctrl.V_IRQ); - PrintDebug("\tV_INTR_PRIO: %d\n", ctrl_area->guest_ctrl.V_INTR_PRIO); - PrintDebug("\tV_IGN_TPR: %d\n", ctrl_area->guest_ctrl.V_IGN_TPR); - PrintDebug("\tV_INTR_MASKING: %d\n", ctrl_area->guest_ctrl.V_INTR_MASKING); - PrintDebug("\tV_INTR_VECTOR: %d\n", ctrl_area->guest_ctrl.V_INTR_VECTOR); + PrintDebug(VM_NONE, VCORE_NONE, "Guest Control Bitmap: %x (at 0x%p)\n", *(uint_t*)&(ctrl_area->guest_ctrl), &(ctrl_area->guest_ctrl)); + PrintDebug(VM_NONE, VCORE_NONE, "\tV_TPR: %d\n", ctrl_area->guest_ctrl.V_TPR); + PrintDebug(VM_NONE, VCORE_NONE, "\tV_IRQ: %d\n", ctrl_area->guest_ctrl.V_IRQ); + PrintDebug(VM_NONE, VCORE_NONE, "\tV_INTR_PRIO: %d\n", ctrl_area->guest_ctrl.V_INTR_PRIO); + PrintDebug(VM_NONE, VCORE_NONE, "\tV_IGN_TPR: %d\n", ctrl_area->guest_ctrl.V_IGN_TPR); + PrintDebug(VM_NONE, VCORE_NONE, "\tV_INTR_MASKING: %d\n", ctrl_area->guest_ctrl.V_INTR_MASKING); + PrintDebug(VM_NONE, VCORE_NONE, "\tV_INTR_VECTOR: %d\n", ctrl_area->guest_ctrl.V_INTR_VECTOR); - PrintDebug("Interrupt_shadow: %d\n", ctrl_area->interrupt_shadow); + PrintDebug(VM_NONE, VCORE_NONE, "Interrupt_shadow: %d\n", ctrl_area->interrupt_shadow); tmp_reg.r_reg = ctrl_area->exit_code; - PrintDebug("exit_code: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "exit_code: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = ctrl_area->exit_info1; - PrintDebug("exit_info1: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "exit_info1: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = ctrl_area->exit_info2; - PrintDebug("exit_info2: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "exit_info2: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("Exit Int Info: (at 0x%p)\n", &(ctrl_area->exit_int_info)); - PrintDebug("Vector: %d\n", ctrl_area->exit_int_info.vector); - PrintDebug("(type=%d) (ev=%d) (valid=%d)\n", ctrl_area->exit_int_info.type, + PrintDebug(VM_NONE, VCORE_NONE, "Exit Int Info: (at 0x%p)\n", &(ctrl_area->exit_int_info)); + PrintDebug(VM_NONE, VCORE_NONE, "Vector: %d\n", ctrl_area->exit_int_info.vector); + PrintDebug(VM_NONE, VCORE_NONE, "(type=%d) (ev=%d) (valid=%d)\n", ctrl_area->exit_int_info.type, ctrl_area->exit_int_info.ev, ctrl_area->exit_int_info.valid); - PrintDebug("Error Code: %d\n", ctrl_area->exit_int_info.error_code); + PrintDebug(VM_NONE, VCORE_NONE, "Error Code: %d\n", ctrl_area->exit_int_info.error_code); tmp_reg.r_reg = ctrl_area->NP_ENABLE; - PrintDebug("NP_ENABLE: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "NP_ENABLE: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("Event Injection: (at 0x%p)\n", &(ctrl_area->EVENTINJ)); - PrintDebug("Vector: %d\n", ctrl_area->EVENTINJ.vector); - PrintDebug("(type=%d) (ev=%d) (valid=%d)\n", ctrl_area->EVENTINJ.type, + PrintDebug(VM_NONE, VCORE_NONE, "Event Injection: (at 0x%p)\n", &(ctrl_area->EVENTINJ)); + PrintDebug(VM_NONE, VCORE_NONE, "Vector: %d\n", ctrl_area->EVENTINJ.vector); + PrintDebug(VM_NONE, VCORE_NONE, "(type=%d) (ev=%d) (valid=%d)\n", ctrl_area->EVENTINJ.type, ctrl_area->EVENTINJ.ev, ctrl_area->EVENTINJ.valid); - PrintDebug("Error Code: %d\n", ctrl_area->EVENTINJ.error_code); + PrintDebug(VM_NONE, VCORE_NONE, "Error Code: %d\n", ctrl_area->EVENTINJ.error_code); tmp_reg.r_reg = ctrl_area->N_CR3; - PrintDebug("N_CR3: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "N_CR3: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("LBR_VIRTUALIZATION_ENABLE: %d\n", ctrl_area->LBR_VIRTUALIZATION_ENABLE); + PrintDebug(VM_NONE, VCORE_NONE, "LBR_VIRTUALIZATION_ENABLE: %d\n", ctrl_area->LBR_VIRTUALIZATION_ENABLE); - PrintDebug("\n--Guest Saved State--\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\n--Guest Saved State--\n"); - PrintDebug("es Selector (at 0x%p): \n", &(guest_area->es)); - PrintDebug("\tSelector: %d\n", guest_area->es.selector); - PrintDebug("\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "es Selector (at 0x%p): \n", &(guest_area->es)); + PrintDebug(VM_NONE, VCORE_NONE, "\tSelector: %d\n", guest_area->es.selector); + PrintDebug(VM_NONE, VCORE_NONE, "\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", guest_area->es.attrib.fields.type, guest_area->es.attrib.fields.S, guest_area->es.attrib.fields.dpl, guest_area->es.attrib.fields.P, guest_area->es.attrib.fields.avl, guest_area->es.attrib.fields.L, guest_area->es.attrib.fields.db, guest_area->es.attrib.fields.G); - PrintDebug("\tlimit: %u\n", guest_area->es.limit); + PrintDebug(VM_NONE, VCORE_NONE, "\tlimit: %u\n", guest_area->es.limit); tmp_reg.r_reg = guest_area->es.base; - PrintDebug("\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("cs Selector (at 0x%p): \n", &(guest_area->cs)); - PrintDebug("\tSelector: %d\n", guest_area->cs.selector); - PrintDebug("\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "cs Selector (at 0x%p): \n", &(guest_area->cs)); + PrintDebug(VM_NONE, VCORE_NONE, "\tSelector: %d\n", guest_area->cs.selector); + PrintDebug(VM_NONE, VCORE_NONE, "\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", guest_area->cs.attrib.fields.type, guest_area->cs.attrib.fields.S, guest_area->cs.attrib.fields.dpl, guest_area->cs.attrib.fields.P, guest_area->cs.attrib.fields.avl, guest_area->cs.attrib.fields.L, guest_area->cs.attrib.fields.db, guest_area->cs.attrib.fields.G); - PrintDebug("\tlimit: %u\n", guest_area->cs.limit); + PrintDebug(VM_NONE, VCORE_NONE, "\tlimit: %u\n", guest_area->cs.limit); tmp_reg.r_reg = guest_area->cs.base; - PrintDebug("\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("ss Selector (at 0x%p): \n", &(guest_area->ss)); - PrintDebug("\tSelector: %d\n", guest_area->ss.selector); - PrintDebug("\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "ss Selector (at 0x%p): \n", &(guest_area->ss)); + PrintDebug(VM_NONE, VCORE_NONE, "\tSelector: %d\n", guest_area->ss.selector); + PrintDebug(VM_NONE, VCORE_NONE, "\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", guest_area->ss.attrib.fields.type, guest_area->ss.attrib.fields.S, guest_area->ss.attrib.fields.dpl, guest_area->ss.attrib.fields.P, guest_area->ss.attrib.fields.avl, guest_area->ss.attrib.fields.L, guest_area->ss.attrib.fields.db, guest_area->ss.attrib.fields.G); - PrintDebug("\tlimit: %u\n", guest_area->ss.limit); + PrintDebug(VM_NONE, VCORE_NONE, "\tlimit: %u\n", guest_area->ss.limit); tmp_reg.r_reg = guest_area->ss.base; - PrintDebug("\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("ds Selector (at 0x%p): \n", &(guest_area->ds)); - PrintDebug("\tSelector: %d\n", guest_area->ds.selector); - PrintDebug("\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "ds Selector (at 0x%p): \n", &(guest_area->ds)); + PrintDebug(VM_NONE, VCORE_NONE, "\tSelector: %d\n", guest_area->ds.selector); + PrintDebug(VM_NONE, VCORE_NONE, "\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", guest_area->ds.attrib.fields.type, guest_area->ds.attrib.fields.S, guest_area->ds.attrib.fields.dpl, guest_area->ds.attrib.fields.P, guest_area->ds.attrib.fields.avl, guest_area->ds.attrib.fields.L, guest_area->ds.attrib.fields.db, guest_area->ds.attrib.fields.G); - PrintDebug("\tlimit: %u\n", guest_area->ds.limit); + PrintDebug(VM_NONE, VCORE_NONE, "\tlimit: %u\n", guest_area->ds.limit); tmp_reg.r_reg = guest_area->ds.base; - PrintDebug("\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("fs Selector (at 0x%p): \n", &(guest_area->fs)); - PrintDebug("\tSelector: %d\n", guest_area->fs.selector); - PrintDebug("\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "fs Selector (at 0x%p): \n", &(guest_area->fs)); + PrintDebug(VM_NONE, VCORE_NONE, "\tSelector: %d\n", guest_area->fs.selector); + PrintDebug(VM_NONE, VCORE_NONE, "\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", guest_area->fs.attrib.fields.type, guest_area->fs.attrib.fields.S, guest_area->fs.attrib.fields.dpl, guest_area->fs.attrib.fields.P, guest_area->fs.attrib.fields.avl, guest_area->fs.attrib.fields.L, guest_area->fs.attrib.fields.db, guest_area->fs.attrib.fields.G); - PrintDebug("\tlimit: %u\n", guest_area->fs.limit); + PrintDebug(VM_NONE, VCORE_NONE, "\tlimit: %u\n", guest_area->fs.limit); tmp_reg.r_reg = guest_area->fs.base; - PrintDebug("\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("gs Selector (at 0x%p): \n", &(guest_area->gs)); - PrintDebug("\tSelector: %d\n", guest_area->gs.selector); - PrintDebug("\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "gs Selector (at 0x%p): \n", &(guest_area->gs)); + PrintDebug(VM_NONE, VCORE_NONE, "\tSelector: %d\n", guest_area->gs.selector); + PrintDebug(VM_NONE, VCORE_NONE, "\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", guest_area->gs.attrib.fields.type, guest_area->gs.attrib.fields.S, guest_area->gs.attrib.fields.dpl, guest_area->gs.attrib.fields.P, guest_area->gs.attrib.fields.avl, guest_area->gs.attrib.fields.L, guest_area->gs.attrib.fields.db, guest_area->gs.attrib.fields.G); - PrintDebug("\tlimit: %u\n", guest_area->gs.limit); + PrintDebug(VM_NONE, VCORE_NONE, "\tlimit: %u\n", guest_area->gs.limit); tmp_reg.r_reg = guest_area->gs.base; - PrintDebug("\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("gdtr Selector (at 0x%p): \n", &(guest_area->gdtr)); - PrintDebug("\tSelector: %d\n", guest_area->gdtr.selector); - PrintDebug("\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "gdtr Selector (at 0x%p): \n", &(guest_area->gdtr)); + PrintDebug(VM_NONE, VCORE_NONE, "\tSelector: %d\n", guest_area->gdtr.selector); + PrintDebug(VM_NONE, VCORE_NONE, "\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", guest_area->gdtr.attrib.fields.type, guest_area->gdtr.attrib.fields.S, guest_area->gdtr.attrib.fields.dpl, guest_area->gdtr.attrib.fields.P, guest_area->gdtr.attrib.fields.avl, guest_area->gdtr.attrib.fields.L, guest_area->gdtr.attrib.fields.db, guest_area->gdtr.attrib.fields.G); - PrintDebug("\tlimit: %u\n", guest_area->gdtr.limit); + PrintDebug(VM_NONE, VCORE_NONE, "\tlimit: %u\n", guest_area->gdtr.limit); tmp_reg.r_reg = guest_area->gdtr.base; - PrintDebug("\tBase: hi: 0x%.8x, lo: 0x%.8x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "\tBase: hi: 0x%.8x, lo: 0x%.8x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("ldtr Selector (at 0x%p): \n", &(guest_area->ldtr)); - PrintDebug("\tSelector: %d\n", guest_area->ldtr.selector); - PrintDebug("\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "ldtr Selector (at 0x%p): \n", &(guest_area->ldtr)); + PrintDebug(VM_NONE, VCORE_NONE, "\tSelector: %d\n", guest_area->ldtr.selector); + PrintDebug(VM_NONE, VCORE_NONE, "\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", guest_area->ldtr.attrib.fields.type, guest_area->ldtr.attrib.fields.S, guest_area->ldtr.attrib.fields.dpl, guest_area->ldtr.attrib.fields.P, guest_area->ldtr.attrib.fields.avl, guest_area->ldtr.attrib.fields.L, guest_area->ldtr.attrib.fields.db, guest_area->ldtr.attrib.fields.G); - PrintDebug("\tlimit: %u\n", guest_area->ldtr.limit); + PrintDebug(VM_NONE, VCORE_NONE, "\tlimit: %u\n", guest_area->ldtr.limit); tmp_reg.r_reg = guest_area->ldtr.base; - PrintDebug("\tBase: hi: 0x%.8x, lo: 0x%.8x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "\tBase: hi: 0x%.8x, lo: 0x%.8x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("idtr Selector (at 0x%p): \n", &(guest_area->idtr)); - PrintDebug("\tSelector: %d\n", guest_area->idtr.selector); - PrintDebug("\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "idtr Selector (at 0x%p): \n", &(guest_area->idtr)); + PrintDebug(VM_NONE, VCORE_NONE, "\tSelector: %d\n", guest_area->idtr.selector); + PrintDebug(VM_NONE, VCORE_NONE, "\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", guest_area->idtr.attrib.fields.type, guest_area->idtr.attrib.fields.S, guest_area->idtr.attrib.fields.dpl, guest_area->idtr.attrib.fields.P, guest_area->idtr.attrib.fields.avl, guest_area->idtr.attrib.fields.L, guest_area->idtr.attrib.fields.db, guest_area->idtr.attrib.fields.G); - PrintDebug("\tlimit: %u\n", guest_area->idtr.limit); + PrintDebug(VM_NONE, VCORE_NONE, "\tlimit: %u\n", guest_area->idtr.limit); tmp_reg.r_reg = guest_area->idtr.base; - PrintDebug("\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("tr Selector (at 0x%p): \n", &(guest_area->tr)); - PrintDebug("\tSelector: %d\n", guest_area->tr.selector); - PrintDebug("\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "tr Selector (at 0x%p): \n", &(guest_area->tr)); + PrintDebug(VM_NONE, VCORE_NONE, "\tSelector: %d\n", guest_area->tr.selector); + PrintDebug(VM_NONE, VCORE_NONE, "\t(type=%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", guest_area->tr.attrib.fields.type, guest_area->tr.attrib.fields.S, guest_area->tr.attrib.fields.dpl, guest_area->tr.attrib.fields.P, guest_area->tr.attrib.fields.avl, guest_area->tr.attrib.fields.L, guest_area->tr.attrib.fields.db, guest_area->tr.attrib.fields.G); - PrintDebug("\tlimit: %u\n", guest_area->tr.limit); + PrintDebug(VM_NONE, VCORE_NONE, "\tlimit: %u\n", guest_area->tr.limit); tmp_reg.r_reg = guest_area->tr.base; - PrintDebug("\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "\tBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); - PrintDebug("cpl: %d\n", guest_area->cpl); + PrintDebug(VM_NONE, VCORE_NONE, "cpl: %d\n", guest_area->cpl); tmp_reg.r_reg = guest_area->efer; - PrintDebug("EFER: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "EFER: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->cr4; - PrintDebug("CR4: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "CR4: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->cr3; - PrintDebug("CR3: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "CR3: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->cr0; - PrintDebug("CR0: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "CR0: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->dr7; - PrintDebug("DR7: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "DR7: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->dr6; - PrintDebug("DR6: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "DR6: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->rflags; - PrintDebug("RFLAGS: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "RFLAGS: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->rip; - PrintDebug("RIP: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "RIP: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->rsp; - PrintDebug("RSP: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "RSP: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->rax; - PrintDebug("RAX: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "RAX: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->star; - PrintDebug("STAR: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "STAR: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->lstar; - PrintDebug("LSTAR: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "LSTAR: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->cstar; - PrintDebug("CSTAR: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "CSTAR: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->sfmask; - PrintDebug("SFMASK: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "SFMASK: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->KernelGsBase; - PrintDebug("KernelGsBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "KernelGsBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->sysenter_cs; - PrintDebug("sysenter_cs: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "sysenter_cs: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->sysenter_esp; - PrintDebug("sysenter_esp: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "sysenter_esp: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->sysenter_eip; - PrintDebug("sysenter_eip: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "sysenter_eip: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->cr2; - PrintDebug("CR2: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "CR2: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->g_pat; - PrintDebug("g_pat: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "g_pat: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->dbgctl; - PrintDebug("dbgctl: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "dbgctl: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->br_from; - PrintDebug("br_from: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "br_from: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->br_to; - PrintDebug("br_to: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "br_to: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->lastexcpfrom; - PrintDebug("lastexcpfrom: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "lastexcpfrom: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); tmp_reg.r_reg = guest_area->lastexcpto; - PrintDebug("lastexcpto: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); + PrintDebug(VM_NONE, VCORE_NONE, "lastexcpto: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low); } diff --git a/palacios/src/palacios/vmcs.c b/palacios/src/palacios/vmcs.c index 85ee7a7..2e4dcf3 100644 --- a/palacios/src/palacios/vmcs.c +++ b/palacios/src/palacios/vmcs.c @@ -35,7 +35,7 @@ static int inline check_vmcs_write(vmcs_field_t field, addr_t val) { ret = vmcs_write(field, val); if (ret != VMX_SUCCESS) { - PrintError("VMWRITE error on %s!: %d\n", v3_vmcs_field_to_str(field), ret); + PrintError(VM_NONE, VCORE_NONE, "VMWRITE error on %s!: %d\n", v3_vmcs_field_to_str(field), ret); return 1; } @@ -47,7 +47,7 @@ static int inline check_vmcs_read(vmcs_field_t field, void * val) { ret = vmcs_read(field, val); if (ret != VMX_SUCCESS) { - PrintError("VMREAD error on %s!: %d\n", v3_vmcs_field_to_str(field), ret); + PrintError(VM_NONE, VCORE_NONE, "VMREAD error on %s!: %d\n", v3_vmcs_field_to_str(field), ret); } return ret; @@ -552,16 +552,16 @@ static inline void print_vmcs_field(vmcs_field_t vmcs_index) { addr_t val; if (vmcs_read(vmcs_index, &val) != VMX_SUCCESS) { - PrintError("VMCS_READ error for %s\n", v3_vmcs_field_to_str(vmcs_index)); + PrintError(VM_NONE, VCORE_NONE, "VMCS_READ error for %s\n", v3_vmcs_field_to_str(vmcs_index)); return; }; if (len == 2) { - PrintDebug("\t%s: 0x%.4x\n", v3_vmcs_field_to_str(vmcs_index), (uint16_t)val); + PrintDebug(VM_NONE, VCORE_NONE, "\t%s: 0x%.4x\n", v3_vmcs_field_to_str(vmcs_index), (uint16_t)val); } else if (len == 4) { - PrintDebug("\t%s: 0x%.8x\n", v3_vmcs_field_to_str(vmcs_index), (uint32_t)val); + PrintDebug(VM_NONE, VCORE_NONE, "\t%s: 0x%.8x\n", v3_vmcs_field_to_str(vmcs_index), (uint32_t)val); } else if (len == 8) { - PrintDebug("\t%s: 0x%p\n", v3_vmcs_field_to_str(vmcs_index), (void *)(addr_t)val); + PrintDebug(VM_NONE, VCORE_NONE, "\t%s: 0x%p\n", v3_vmcs_field_to_str(vmcs_index), (void *)(addr_t)val); } } @@ -573,59 +573,59 @@ static void print_vmcs_segments() { v3_print_segments(&segs); - PrintDebug(" ==> CS\n"); + PrintDebug(VM_NONE, VCORE_NONE, " ==> CS\n"); print_vmcs_field(VMCS_GUEST_CS_SELECTOR); print_vmcs_field(VMCS_GUEST_CS_BASE); print_vmcs_field(VMCS_GUEST_CS_LIMIT); print_vmcs_field(VMCS_GUEST_CS_ACCESS); - PrintDebug(" ==> SS\n"); + PrintDebug(VM_NONE, VCORE_NONE, " ==> SS\n"); print_vmcs_field(VMCS_GUEST_SS_SELECTOR); print_vmcs_field(VMCS_GUEST_SS_BASE); print_vmcs_field(VMCS_GUEST_SS_LIMIT); print_vmcs_field(VMCS_GUEST_SS_ACCESS); - PrintDebug(" ==> DS\n"); + PrintDebug(VM_NONE, VCORE_NONE, " ==> DS\n"); print_vmcs_field(VMCS_GUEST_DS_SELECTOR); print_vmcs_field(VMCS_GUEST_DS_BASE); print_vmcs_field(VMCS_GUEST_DS_LIMIT); print_vmcs_field(VMCS_GUEST_DS_ACCESS); - PrintDebug(" ==> ES\n"); + PrintDebug(VM_NONE, VCORE_NONE, " ==> ES\n"); print_vmcs_field(VMCS_GUEST_ES_SELECTOR); print_vmcs_field(VMCS_GUEST_ES_BASE); print_vmcs_field(VMCS_GUEST_ES_LIMIT); print_vmcs_field(VMCS_GUEST_ES_ACCESS); - PrintDebug(" ==> FS\n"); + PrintDebug(VM_NONE, VCORE_NONE, " ==> FS\n"); print_vmcs_field(VMCS_GUEST_FS_SELECTOR); print_vmcs_field(VMCS_GUEST_FS_BASE); print_vmcs_field(VMCS_GUEST_FS_LIMIT); print_vmcs_field(VMCS_GUEST_FS_ACCESS); - PrintDebug(" ==> GS\n"); + PrintDebug(VM_NONE, VCORE_NONE, " ==> GS\n"); print_vmcs_field(VMCS_GUEST_GS_SELECTOR); print_vmcs_field(VMCS_GUEST_GS_BASE); print_vmcs_field(VMCS_GUEST_GS_LIMIT); print_vmcs_field(VMCS_GUEST_GS_ACCESS); - PrintDebug(" ==> LDTR\n"); + PrintDebug(VM_NONE, VCORE_NONE, " ==> LDTR\n"); print_vmcs_field(VMCS_GUEST_LDTR_SELECTOR); print_vmcs_field(VMCS_GUEST_LDTR_BASE); print_vmcs_field(VMCS_GUEST_LDTR_LIMIT); print_vmcs_field(VMCS_GUEST_LDTR_ACCESS); - PrintDebug(" ==> TR\n"); + PrintDebug(VM_NONE, VCORE_NONE, " ==> TR\n"); print_vmcs_field(VMCS_GUEST_TR_SELECTOR); print_vmcs_field(VMCS_GUEST_TR_BASE); print_vmcs_field(VMCS_GUEST_TR_LIMIT); print_vmcs_field(VMCS_GUEST_TR_ACCESS); - PrintDebug(" ==> GDTR\n"); + PrintDebug(VM_NONE, VCORE_NONE, " ==> GDTR\n"); print_vmcs_field(VMCS_GUEST_GDTR_BASE); print_vmcs_field(VMCS_GUEST_GDTR_LIMIT); - PrintDebug(" ==> IDTR\n"); + PrintDebug(VM_NONE, VCORE_NONE, " ==> IDTR\n"); print_vmcs_field(VMCS_GUEST_IDTR_BASE); print_vmcs_field(VMCS_GUEST_IDTR_LIMIT); @@ -637,7 +637,7 @@ static void print_vmcs_segments() { static void print_guest_state() { - PrintDebug("VMCS_GUEST_STATE\n"); + PrintDebug(VM_NONE, VCORE_NONE, "VMCS_GUEST_STATE\n"); print_vmcs_field(VMCS_GUEST_RIP); print_vmcs_field(VMCS_GUEST_RSP); print_vmcs_field(VMCS_GUEST_RFLAGS); @@ -653,11 +653,11 @@ static void print_guest_state() #endif - PrintDebug("\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\n"); print_vmcs_segments(); - PrintDebug("\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\n"); print_vmcs_field(VMCS_GUEST_DBG_CTL); #ifdef __V3_32BIT__ @@ -685,7 +685,7 @@ static void print_guest_state() - PrintDebug("GUEST_NON_REGISTER_STATE\n"); + PrintDebug(VM_NONE, VCORE_NONE, "GUEST_NON_REGISTER_STATE\n"); print_vmcs_field(VMCS_GUEST_ACTIVITY_STATE); print_vmcs_field(VMCS_GUEST_INT_STATE); @@ -698,7 +698,7 @@ static void print_guest_state() static void print_host_state() { - PrintDebug("VMCS_HOST_STATE\n"); + PrintDebug(VM_NONE, VCORE_NONE, "VMCS_HOST_STATE\n"); print_vmcs_field(VMCS_HOST_RIP); print_vmcs_field(VMCS_HOST_RSP); @@ -715,7 +715,7 @@ static void print_host_state() #endif - PrintDebug("\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\n"); print_vmcs_field(VMCS_HOST_CS_SELECTOR); print_vmcs_field(VMCS_HOST_SS_SELECTOR); print_vmcs_field(VMCS_HOST_DS_SELECTOR); @@ -724,14 +724,14 @@ static void print_host_state() print_vmcs_field(VMCS_HOST_GS_SELECTOR); print_vmcs_field(VMCS_HOST_TR_SELECTOR); - PrintDebug("\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\n"); print_vmcs_field(VMCS_HOST_FS_BASE); print_vmcs_field(VMCS_HOST_GS_BASE); print_vmcs_field(VMCS_HOST_TR_BASE); print_vmcs_field(VMCS_HOST_GDTR_BASE); print_vmcs_field(VMCS_HOST_IDTR_BASE); - PrintDebug("\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\n"); print_vmcs_field(VMCS_HOST_SYSENTER_CS); print_vmcs_field(VMCS_HOST_SYSENTER_ESP); print_vmcs_field(VMCS_HOST_SYSENTER_EIP); @@ -752,7 +752,7 @@ static void print_host_state() static void print_exec_ctrls() { - PrintDebug("VMCS_EXEC_CTRL_FIELDS\n"); + PrintDebug(VM_NONE, VCORE_NONE, "VMCS_EXEC_CTRL_FIELDS\n"); print_vmcs_field(VMCS_PIN_CTRLS); print_vmcs_field(VMCS_PROC_CTRLS); @@ -778,7 +778,7 @@ static void print_exec_ctrls() { print_vmcs_field(VMCS_TSC_OFFSET_HIGH); #endif - PrintDebug("\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\n"); print_vmcs_field(VMCS_CR0_MASK); print_vmcs_field(VMCS_CR0_READ_SHDW); @@ -794,7 +794,7 @@ static void print_exec_ctrls() { // Check max number of CR3 targets... may continue... - PrintDebug("\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\n"); // if virtualize apic accesses print_vmcs_field(VMCS_APIC_ACCESS_ADDR); @@ -827,7 +827,7 @@ static void print_exec_ctrls() { } static void print_ept_state() { - V3_Print("VMCS EPT INFO\n"); + V3_Print(VM_NONE, VCORE_NONE, "VMCS EPT INFO\n"); // if enable vpid print_vmcs_field(VMCS_VPID); @@ -870,7 +870,7 @@ static void print_ept_state() { static void print_exit_ctrls() { - PrintDebug("VMCS_EXIT_CTRLS\n"); + PrintDebug(VM_NONE, VCORE_NONE, "VMCS_EXIT_CTRLS\n"); print_vmcs_field(VMCS_EXIT_CTRLS); @@ -896,7 +896,7 @@ static void print_exit_ctrls() { static void print_entry_ctrls() { - PrintDebug("VMCS_ENTRY_CTRLS\n"); + PrintDebug(VM_NONE, VCORE_NONE, "VMCS_ENTRY_CTRLS\n"); print_vmcs_field(VMCS_ENTRY_CTRLS); @@ -915,7 +915,7 @@ static void print_entry_ctrls() { static void print_exit_info() { - PrintDebug("VMCS_EXIT_INFO\n"); + PrintDebug(VM_NONE, VCORE_NONE, "VMCS_EXIT_INFO\n"); print_vmcs_field(VMCS_EXIT_REASON); print_vmcs_field(VMCS_EXIT_QUAL); @@ -982,7 +982,7 @@ int v3_vmcs_get_field_len(vmcs_field_t field) { case 3: return sizeof(addr_t); default: - PrintError("Invalid VMCS field: 0x%x\n", field); + PrintError(VM_NONE, VCORE_NONE, "Invalid VMCS field: 0x%x\n", field); return -1; } } diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index bbb5b1b..148b86e 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -54,20 +54,20 @@ static void init_cpu(void * arg) { #ifdef V3_CONFIG_SVM if (v3_is_svm_capable()) { - PrintDebug("Machine is SVM Capable\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Machine is SVM Capable\n"); v3_init_svm_cpu(cpu_id); } else #endif #ifdef V3_CONFIG_VMX if (v3_is_vmx_capable()) { - PrintDebug("Machine is VMX Capable\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Machine is VMX Capable\n"); v3_init_vmx_cpu(cpu_id); } else #endif { - PrintError("CPU has no virtualization Extensions\n"); + PrintError(VM_NONE, VCORE_NONE, "CPU has no virtualization Extensions\n"); } } @@ -80,7 +80,7 @@ static void deinit_cpu(void * arg) { #ifdef V3_CONFIG_SVM case V3_SVM_CPU: case V3_SVM_REV3_CPU: - PrintDebug("Deinitializing SVM CPU %d\n", cpu_id); + PrintDebug(VM_NONE, VCORE_NONE, "Deinitializing SVM CPU %d\n", cpu_id); v3_deinit_svm_cpu(cpu_id); break; #endif @@ -88,13 +88,13 @@ static void deinit_cpu(void * arg) { case V3_VMX_CPU: case V3_VMX_EPT_CPU: case V3_VMX_EPT_UG_CPU: - PrintDebug("Deinitializing VMX CPU %d\n", cpu_id); + PrintDebug(VM_NONE, VCORE_NONE, "Deinitializing VMX CPU %d\n", cpu_id); v3_deinit_vmx_cpu(cpu_id); break; #endif case V3_INVALID_CPU: default: - PrintError("CPU has no virtualization Extensions\n"); + PrintError(VM_NONE, VCORE_NONE, "CPU has no virtualization Extensions\n"); break; } } @@ -105,7 +105,7 @@ void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus) { int minor = 0; int major = 0; - V3_Print("V3 Print statement to fix a Kitten page fault bug\n"); + V3_Print(VM_NONE, VCORE_NONE, "V3 Print statement to fix a Kitten page fault bug\n"); // Set global variables. os_hooks = hooks; @@ -142,7 +142,7 @@ void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus) { minor = i % 8; if ((cpu_mask == NULL) || (*(cpu_mask + major) & (0x1 << minor))) { - V3_Print("Initializing VMM extensions on cpu %d\n", i); + V3_Print(VM_NONE, VCORE_NONE, "Initializing VMM extensions on cpu %d\n", i); hooks->call_on_cpu(i, &init_cpu, (void *)(addr_t)i); if (v3_mach_type == V3_INVALID_CPU) { @@ -193,16 +193,16 @@ struct v3_vm_info * v3_create_vm(void * cfg, void * priv_data, char * name) { struct v3_vm_info * vm = v3_config_guest(cfg, priv_data); if (vm == NULL) { - PrintError("Could not configure guest\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not configure guest\n"); return NULL; } - V3_Print("CORE 0 RIP=%p\n", (void *)(addr_t)(vm->cores[0].rip)); + V3_Print(vm, VCORE_NONE, "CORE 0 RIP=%p\n", (void *)(addr_t)(vm->cores[0].rip)); if (name == NULL) { name = "[V3_VM]"; } else if (strlen(name) >= 128) { - PrintError("VM name is too long. Will be truncated to 128 chars.\n"); + PrintError(vm, VCORE_NONE,"VM name is too long. Will be truncated to 128 chars.\n"); } memset(vm->name, 0, 128); @@ -219,7 +219,7 @@ static int start_core(void * p) struct guest_info * core = (struct guest_info *)p; - PrintDebug("virtual core %u (on logical core %u): in start_core (RIP=%p)\n", + PrintDebug(core->vm_info,core,"virtual core %u (on logical core %u): in start_core (RIP=%p)\n", core->vcpu_id, core->pcpu_id, (void *)(addr_t)core->rip); switch (v3_mach_type) { @@ -237,7 +237,7 @@ static int start_core(void * p) break; #endif default: - PrintError("Attempting to enter a guest on an invalid CPU\n"); + PrintError(core->vm_info, core, "Attempting to enter a guest on an invalid CPU\n"); return -1; } // should not happen @@ -257,7 +257,7 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { if (vm->run_state != VM_STOPPED) { - PrintError("VM has already been launched (state=%d)\n", (int)vm->run_state); + PrintError(vm, VCORE_NONE, "VM has already been launched (state=%d)\n", (int)vm->run_state); return -1; } @@ -266,10 +266,10 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { for (i=0;inum_cores;i++) { if (vm->cores[i].shdw_pg_mode == SHADOW_PAGING) { if ((vm->mem_map.base_region.host_addr + vm->mem_size ) >= 0x100000000ULL) { - PrintError("Base memory region exceeds 4 GB boundary with shadow paging enabled on core %d.\n",i); - PrintError("Any use of non-64 bit mode in the guest is likely to fail in this configuration.\n"); - PrintError("If you would like to proceed anyway, remove this check and recompile Palacios.\n"); - PrintError("Alternatively, change this VM to use nested paging.\n"); + PrintError(vm, VCORE_NONE, "Base memory region exceeds 4 GB boundary with shadow paging enabled on core %d.\n",i); + PrintError(vm, VCORE_NONE, "Any use of non-64 bit mode in the guest is likely to fail in this configuration.\n"); + PrintError(vm, VCORE_NONE, "If you would like to proceed anyway, remove this check and recompile Palacios.\n"); + PrintError(vm, VCORE_NONE, "Alternatively, change this VM to use nested paging.\n"); return -1; } } @@ -279,8 +279,8 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { /// CHECK IF WE ARE MULTICORE ENABLED.... - V3_Print("V3 -- Starting VM (%u cores)\n", vm->num_cores); - V3_Print("CORE 0 RIP=%p\n", (void *)(addr_t)(vm->cores[0].rip)); + V3_Print(vm, VCORE_NONE, "V3 -- Starting VM (%u cores)\n", vm->num_cores); + V3_Print(vm, VCORE_NONE, "CORE 0 RIP=%p\n", (void *)(addr_t)(vm->cores[0].rip)); // Check that enough cores are present in the mask to handle vcores @@ -299,7 +299,7 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { if (vm->num_cores > avail_cores) { - PrintError("Attempted to start a VM with too many cores (vm->num_cores = %d, avail_cores = %d, MAX=%d)\n", + PrintError(vm, VCORE_NONE, "Attempted to start a VM with too many cores (vm->num_cores = %d, avail_cores = %d, MAX=%d)\n", vm->num_cores, avail_cores, MAX_CORES); return -1; } @@ -319,7 +319,7 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { core_idx = atoi(specified_cpu); if ((core_idx < 0) || (core_idx >= MAX_CORES)) { - PrintError("Target CPU out of bounds (%d) (MAX_CORES=%d)\n", core_idx, MAX_CORES); + PrintError(vm, VCORE_NONE, "Target CPU out of bounds (%d) (MAX_CORES=%d)\n", core_idx, MAX_CORES); } i--; // We reset the logical core idx. Not strictly necessary I guess... @@ -331,11 +331,11 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { minor = core_idx % 8; if ((core_mask[major] & (0x1 << minor)) == 0) { - PrintError("Logical CPU %d not available for virtual core %d; not started\n", + PrintError(vm, VCORE_NONE, "Logical CPU %d not available for virtual core %d; not started\n", core_idx, vcore_id); if (specified_cpu != NULL) { - PrintError("CPU was specified explicitly (%d). HARD ERROR\n", core_idx); + PrintError(vm, VCORE_NONE, "CPU was specified explicitly (%d). HARD ERROR\n", core_idx); v3_stop_vm(vm); return -1; } @@ -343,12 +343,12 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { continue; } - PrintDebug("Starting virtual core %u on logical core %u\n", + PrintDebug(vm, VCORE_NONE, "Starting virtual core %u on logical core %u\n", vcore_id, core_idx); sprintf(core->exec_name, "%s-%u", vm->name, vcore_id); - PrintDebug("run: core=%u, func=0x%p, arg=0x%p, name=%s\n", + PrintDebug(vm, VCORE_NONE, "run: core=%u, func=0x%p, arg=0x%p, name=%s\n", core_idx, start_core, core, core->exec_name); core->core_run_state = CORE_STOPPED; // core zero will turn itself on @@ -356,7 +356,7 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { core->core_thread = V3_CREATE_THREAD_ON_CPU(core_idx, start_core, core, core->exec_name); if (core->core_thread == NULL) { - PrintError("Thread launch failed\n"); + PrintError(vm, VCORE_NONE, "Thread launch failed\n"); v3_stop_vm(vm); return -1; } @@ -365,7 +365,7 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { } if (vcore_id >= 0) { - PrintError("Error starting VM: Not enough available CPU cores\n"); + PrintError(vm, VCORE_NONE, "Error starting VM: Not enough available CPU cores\n"); v3_stop_vm(vm); return -1; } @@ -382,19 +382,19 @@ int v3_reset_vm_core(struct guest_info * core, addr_t rip) { #ifdef V3_CONFIG_SVM case V3_SVM_CPU: case V3_SVM_REV3_CPU: - PrintDebug("Resetting SVM Guest CPU %d\n", core->vcpu_id); + PrintDebug(core->vm_info, core, "Resetting SVM Guest CPU %d\n", core->vcpu_id); return v3_reset_svm_vm_core(core, rip); #endif #ifdef V3_CONFIG_VMX case V3_VMX_CPU: case V3_VMX_EPT_CPU: case V3_VMX_EPT_UG_CPU: - PrintDebug("Resetting VMX Guest CPU %d\n", core->vcpu_id); + PrintDebug(core->vm_info, core, "Resetting VMX Guest CPU %d\n", core->vcpu_id); return v3_reset_vmx_vm_core(core, rip); #endif case V3_INVALID_CPU: default: - PrintError("CPU has no virtualization Extensions\n"); + PrintError(core->vm_info, core, "CPU has no virtualization Extensions\n"); break; } @@ -408,31 +408,31 @@ int v3_move_vm_core(struct v3_vm_info * vm, int vcore_id, int target_cpu) { struct guest_info * core = NULL; if ((vcore_id < 0) || (vcore_id >= vm->num_cores)) { - PrintError("Attempted to migrate invalid virtual core (%d)\n", vcore_id); + PrintError(vm, VCORE_NONE, "Attempted to migrate invalid virtual core (%d)\n", vcore_id); return -1; } core = &(vm->cores[vcore_id]); if (target_cpu == core->pcpu_id) { - PrintError("Attempted to migrate to local core (%d)\n", target_cpu); + PrintError(vm, core, "Attempted to migrate to local core (%d)\n", target_cpu); // well that was pointless return 0; } if (core->core_thread == NULL) { - PrintError("Attempted to migrate a core without a valid thread context\n"); + PrintError(vm, core, "Attempted to migrate a core without a valid thread context\n"); return -1; } while (v3_raise_barrier(vm, NULL) == -1); - V3_Print("Performing Migration from %d to %d\n", core->pcpu_id, target_cpu); + V3_Print(vm, core, "Performing Migration from %d to %d\n", core->pcpu_id, target_cpu); // Double check that we weren't preemptively migrated if (target_cpu != core->pcpu_id) { - V3_Print("Moving Core\n"); + V3_Print(vm, core, "Moving Core\n"); #ifdef V3_CONFIG_VMX @@ -440,7 +440,7 @@ int v3_move_vm_core(struct v3_vm_info * vm, int vcore_id, int target_cpu) { case V3_VMX_CPU: case V3_VMX_EPT_CPU: case V3_VMX_EPT_UG_CPU: - PrintDebug("Flushing VMX Guest CPU %d\n", core->vcpu_id); + PrintDebug(vm, core, "Flushing VMX Guest CPU %d\n", core->vcpu_id); V3_Call_On_CPU(core->pcpu_id, (void (*)(void *))v3_flush_vmx_vm_core, (void *)core); break; default: @@ -449,7 +449,7 @@ int v3_move_vm_core(struct v3_vm_info * vm, int vcore_id, int target_cpu) { #endif if (V3_MOVE_THREAD_TO_CPU(target_cpu, core->core_thread) != 0) { - PrintError("Failed to move Vcore %d to CPU %d\n", + PrintError(vm, core, "Failed to move Vcore %d to CPU %d\n", core->vcpu_id, target_cpu); v3_lower_barrier(vm); return -1; @@ -461,7 +461,7 @@ int v3_move_vm_core(struct v3_vm_info * vm, int vcore_id, int target_cpu) { */ core->pcpu_id = target_cpu; - V3_Print("core now at %d\n", core->pcpu_id); + V3_Print(vm, core, "core now at %d\n", core->pcpu_id); } v3_lower_barrier(vm); @@ -475,7 +475,7 @@ int v3_stop_vm(struct v3_vm_info * vm) { if ((vm->run_state != VM_RUNNING) && (vm->run_state != VM_SIMULATING)) { - PrintError("Tried to stop VM in invalid runstate (%d)\n", vm->run_state); + PrintError(vm, VCORE_NONE,"Tried to stop VM in invalid runstate (%d)\n", vm->run_state); return -1; } @@ -505,7 +505,7 @@ int v3_stop_vm(struct v3_vm_info * vm) { v3_yield(NULL,-1); } - V3_Print("VM stopped. Returning\n"); + V3_Print(vm, VCORE_NONE,"VM stopped. Returning\n"); return 0; } @@ -514,7 +514,7 @@ int v3_stop_vm(struct v3_vm_info * vm) { int v3_pause_vm(struct v3_vm_info * vm) { if (vm->run_state != VM_RUNNING) { - PrintError("Tried to pause a VM that was not running\n"); + PrintError(vm, VCORE_NONE,"Tried to pause a VM that was not running\n"); return -1; } @@ -529,7 +529,7 @@ int v3_pause_vm(struct v3_vm_info * vm) { int v3_continue_vm(struct v3_vm_info * vm) { if (vm->run_state != VM_PAUSED) { - PrintError("Tried to continue a VM that was not paused\n"); + PrintError(vm, VCORE_NONE,"Tried to continue a VM that was not paused\n"); return -1; } @@ -547,7 +547,7 @@ static int sim_callback(struct guest_info * core, void * private_data) { v3_bitmap_set(timeout_map, core->vcpu_id); - V3_Print("Simulation callback activated (guest_rip=%p)\n", (void *)core->rip); + V3_Print(core->vm_info, core, "Simulation callback activated (guest_rip=%p)\n", (void *)core->rip); while (v3_bitmap_check(timeout_map, core->vcpu_id) == 1) { v3_yield(NULL,-1); @@ -567,7 +567,7 @@ int v3_simulate_vm(struct v3_vm_info * vm, unsigned int msecs) { uint64_t cpu_khz = V3_CPU_KHZ(); if (vm->run_state != VM_PAUSED) { - PrintError("VM must be paused before simulation begins\n"); + PrintError(vm, VCORE_NONE,"VM must be paused before simulation begins\n"); return -1; } @@ -585,18 +585,18 @@ int v3_simulate_vm(struct v3_vm_info * vm, unsigned int msecs) { - V3_Print("Simulating %u msecs (%llu cycles) [CPU_KHZ=%llu]\n", msecs, cycles, cpu_khz); + V3_Print(vm, VCORE_NONE,"Simulating %u msecs (%llu cycles) [CPU_KHZ=%llu]\n", msecs, cycles, cpu_khz); // set timeout for (i = 0; i < vm->num_cores; i++) { if (v3_add_core_timeout(&(vm->cores[i]), cycles, sim_callback, &timeout_map) == -1) { - PrintError("Could not register simulation timeout for core %d\n", i); + PrintError(vm, VCORE_NONE,"Could not register simulation timeout for core %d\n", i); return -1; } } - V3_Print("timeouts set on all cores\n "); + V3_Print(vm, VCORE_NONE,"timeouts set on all cores\n "); // Run the simulation @@ -605,7 +605,7 @@ int v3_simulate_vm(struct v3_vm_info * vm, unsigned int msecs) { v3_lower_barrier(vm); - V3_Print("Barrier lowered: We are now Simulating!!\n"); + V3_Print(vm, VCORE_NONE,"Barrier lowered: We are now Simulating!!\n"); // block until simulation is complete while (all_blocked == 0) { @@ -625,7 +625,7 @@ int v3_simulate_vm(struct v3_vm_info * vm, unsigned int msecs) { } - V3_Print("Simulation is complete\n"); + V3_Print(vm, VCORE_NONE,"Simulation is complete\n"); // Simulation is complete // Reset back to PAUSED state @@ -729,7 +729,7 @@ int v3_free_vm(struct v3_vm_info * vm) { if ((vm->run_state != VM_STOPPED) && (vm->run_state != VM_ERROR)) { - PrintError("Tried to Free VM in invalid runstate (%d)\n", vm->run_state); + PrintError(vm, VCORE_NONE,"Tried to Free VM in invalid runstate (%d)\n", vm->run_state); return -1; } @@ -789,7 +789,7 @@ void v3_yield_cond(struct guest_info * info, int usec) { cur_cycle = v3_get_host_time(&info->time_state); if (cur_cycle > (info->yield_start_cycle + info->vm_info->yield_cycle_period)) { - //PrintDebug("Conditional Yield (cur_cyle=%p, start_cycle=%p, period=%p)\n", + //PrintDebug(info->vm_info, info, "Conditional Yield (cur_cyle=%p, start_cycle=%p, period=%p)\n", // (void *)cur_cycle, (void *)info->yield_start_cycle, // (void *)info->yield_cycle_period); @@ -836,7 +836,7 @@ void v3_print_cond(const char * fmt, ...) { vsnprintf(buf, 2048, fmt, ap); va_end(ap); - V3_Print("%s", buf); + V3_Print(VM_NONE, VCORE_NONE,"%s", buf); } } @@ -868,7 +868,26 @@ int v3_vm_enter(struct guest_info * info) { break; #endif default: - PrintError("Attemping to enter a guest on an invalid CPU\n"); + PrintError(info->vm_info, info, "Attemping to enter a guest on an invalid CPU\n"); return -1; } } + + +void *v3_get_host_vm(struct v3_vm_info *x) +{ + if (x) { + return x->host_priv_data; + } else { + return 0; + } +} + +int v3_get_vcore(struct guest_info *x) +{ + if (x) { + return x->vcpu_id; + } else { + return -1; + } +} diff --git a/palacios/src/palacios/vmm_barrier.c b/palacios/src/palacios/vmm_barrier.c index 19b2db2..5dc1ce8 100644 --- a/palacios/src/palacios/vmm_barrier.c +++ b/palacios/src/palacios/vmm_barrier.c @@ -198,7 +198,7 @@ int v3_wait_at_barrier(struct guest_info * core) { return 0; } - V3_Print("Core %d waiting at barrier\n", core->vcpu_id); + V3_Print(core->vm_info, core, "Core %d waiting at barrier\n", core->vcpu_id); /* Barrier has been activated. * Wait here until it's lowered @@ -207,7 +207,7 @@ int v3_wait_at_barrier(struct guest_info * core) { // set cpu bit in barrier bitmap v3_bitmap_set(&(barrier->cpu_map), core->vcpu_id); - V3_Print("Core %d bit set as waiting\n", core->vcpu_id); + V3_Print(core->vm_info, core, "Core %d bit set as waiting\n", core->vcpu_id); // wait for cpu bit to clear while (v3_bitmap_check(&(barrier->cpu_map), core->vcpu_id)) { diff --git a/palacios/src/palacios/vmm_bitmap.c b/palacios/src/palacios/vmm_bitmap.c index a94d557..f53ead1 100644 --- a/palacios/src/palacios/vmm_bitmap.c +++ b/palacios/src/palacios/vmm_bitmap.c @@ -30,7 +30,7 @@ int v3_bitmap_init(struct v3_bitmap * bitmap, int num_bits) { if (bitmap->bits == NULL) { - PrintError("Could not allocate bitmap of %d bits\n", num_bits); + PrintError(VM_NONE, VCORE_NONE, "Could not allocate bitmap of %d bits\n", num_bits); return -1; } @@ -61,7 +61,7 @@ int v3_bitmap_set(struct v3_bitmap * bitmap, int index) { uint32_t flags = 0; if (index > (bitmap->num_bits - 1)) { - PrintError("Index out of bitmap range: (pos = %d) (num_bits = %d)\n", + PrintError(VM_NONE, VCORE_NONE, "Index out of bitmap range: (pos = %d) (num_bits = %d)\n", index, bitmap->num_bits); return -1; } @@ -85,7 +85,7 @@ int v3_bitmap_clear(struct v3_bitmap * bitmap, int index) { uint32_t flags = 0; if (index > (bitmap->num_bits - 1)) { - PrintError("Index out of bitmap range: (pos = %d) (num_bits = %d)\n", + PrintError(VM_NONE, VCORE_NONE, "Index out of bitmap range: (pos = %d) (num_bits = %d)\n", index, bitmap->num_bits); return -1; } @@ -105,7 +105,7 @@ int v3_bitmap_check(struct v3_bitmap * bitmap, int index) { int minor = index % 8; if (index > (bitmap->num_bits - 1)) { - PrintError("Index out of bitmap range: (pos = %d) (num_bits = %d)\n", + PrintError(VM_NONE, VCORE_NONE, "Index out of bitmap range: (pos = %d) (num_bits = %d)\n", index, bitmap->num_bits); return -1; } @@ -136,7 +136,7 @@ int v3_bitmap_count(struct v3_bitmap * bitmap) { int v3_bitmap_copy(struct v3_bitmap * dst, struct v3_bitmap * src) { if (src->num_bits != dst->num_bits) { - PrintError("src and dst must be the same size.\n"); + PrintError(VM_NONE, VCORE_NONE, "src and dst must be the same size.\n"); return -1; } diff --git a/palacios/src/palacios/vmm_checkpoint.c b/palacios/src/palacios/vmm_checkpoint.c index 895cfa6..9c55e3f 100644 --- a/palacios/src/palacios/vmm_checkpoint.c +++ b/palacios/src/palacios/vmm_checkpoint.c @@ -115,15 +115,15 @@ int V3_init_checkpoint() { store_table = v3_create_htable(0, store_hash_fn, store_eq_fn); while (tmp_store != __stop__v3_chkpt_stores) { - V3_Print("Registering Checkpoint Backing Store (%s)\n", (*tmp_store)->name); + V3_Print(VM_NONE, VCORE_NONE, "Registering Checkpoint Backing Store (%s)\n", (*tmp_store)->name); if (v3_htable_search(store_table, (addr_t)((*tmp_store)->name))) { - PrintError("Multiple instances of Checkpoint backing Store (%s)\n", (*tmp_store)->name); + PrintError(VM_NONE, VCORE_NONE, "Multiple instances of Checkpoint backing Store (%s)\n", (*tmp_store)->name); return -1; } if (v3_htable_insert(store_table, (addr_t)((*tmp_store)->name), (addr_t)(*tmp_store)) == 0) { - PrintError("Could not register Checkpoint backing store (%s)\n", (*tmp_store)->name); + PrintError(VM_NONE, VCORE_NONE, "Could not register Checkpoint backing store (%s)\n", (*tmp_store)->name); return -1; } @@ -151,13 +151,13 @@ static int chkpt_close(struct v3_chkpt * chkpt) { V3_Free(chkpt); if (rc!=0) { - PrintError("Internal store failed to close valid checkpoint\n"); + PrintError(VM_NONE, VCORE_NONE, "Internal store failed to close valid checkpoint\n"); return -1; } else { return 0; } } else { - PrintError("Attempt to close null checkpoint\n"); + PrintError(VM_NONE, VCORE_NONE, "Attempt to close null checkpoint\n"); return -1; } } @@ -171,14 +171,14 @@ static struct v3_chkpt * chkpt_open(struct v3_vm_info * vm, char * store, char * iface = (void *)v3_htable_search(store_table, (addr_t)store); if (iface == NULL) { - V3_Print("Error: Could not locate Checkpoint interface for store (%s)\n", store); + V3_Print(vm, VCORE_NONE, "Error: Could not locate Checkpoint interface for store (%s)\n", store); return NULL; } store_data = iface->open_chkpt(url, mode); if (store_data == NULL) { - PrintError("Could not open url (%s) for backing store (%s)\n", url, store); + PrintError(vm, VCORE_NONE, "Could not open url (%s) for backing store (%s)\n", url, store); return NULL; } @@ -186,7 +186,7 @@ static struct v3_chkpt * chkpt_open(struct v3_vm_info * vm, char * store, char * chkpt = V3_Malloc(sizeof(struct v3_chkpt)); if (!chkpt) { - PrintError("Could not allocate checkpoint state, closing checkpoint\n"); + PrintError(vm, VCORE_NONE, "Could not allocate checkpoint state, closing checkpoint\n"); iface->close_chkpt(store_data); return NULL; } @@ -205,14 +205,14 @@ struct v3_chkpt_ctx * v3_chkpt_open_ctx(struct v3_chkpt * chkpt, char * name) { struct v3_chkpt_ctx * ctx; if (chkpt->current_ctx) { - PrintError("Attempt to open context %s before old context has been closed\n", name); + PrintError(VM_NONE, VCORE_NONE, "Attempt to open context %s before old context has been closed\n", name); return NULL; } ctx = V3_Malloc(sizeof(struct v3_chkpt_ctx)); if (!ctx) { - PrintError("Unable to allocate context\n"); + PrintError(VM_NONE, VCORE_NONE, "Unable to allocate context\n"); return 0; } @@ -222,7 +222,7 @@ struct v3_chkpt_ctx * v3_chkpt_open_ctx(struct v3_chkpt * chkpt, char * name) { ctx->store_ctx = chkpt->interface->open_ctx(chkpt->store_data, name); if (!(ctx->store_ctx)) { - PrintError("Underlying store failed to open context %s\n",name); + PrintError(VM_NONE, VCORE_NONE, "Underlying store failed to open context %s\n",name); V3_Free(ctx); return NULL; } @@ -237,14 +237,14 @@ int v3_chkpt_close_ctx(struct v3_chkpt_ctx * ctx) { int ret = 0; if (chkpt->current_ctx != ctx) { - PrintError("Attempt to close a context that is not the current context on the store\n"); + PrintError(VM_NONE, VCORE_NONE, "Attempt to close a context that is not the current context on the store\n"); return -1; } ret = chkpt->interface->close_ctx(chkpt->store_data, ctx->store_ctx); if (ret) { - PrintError("Failed to close context on store, closing device-independent context anyway - bad\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to close context on store, closing device-independent context anyway - bad\n"); ret = -1; } @@ -264,19 +264,19 @@ int v3_chkpt_save(struct v3_chkpt_ctx * ctx, char * tag, uint64_t len, void * bu int rc; if (!ctx) { - PrintError("Attempt to save tag %s on null context\n",tag); + PrintError(VM_NONE, VCORE_NONE, "Attempt to save tag %s on null context\n",tag); return -1; } if (chkpt->current_ctx != ctx) { - PrintError("Attempt to save on context that is not the current context for the store\n"); + PrintError(VM_NONE, VCORE_NONE, "Attempt to save on context that is not the current context for the store\n"); return -1; } rc = chkpt->interface->save(chkpt->store_data, ctx->store_ctx, tag , len, buf); if (rc) { - PrintError("Underlying store failed to save tag %s on valid context\n",tag); + PrintError(VM_NONE, VCORE_NONE, "Underlying store failed to save tag %s on valid context\n",tag); return -1; } else { return 0; @@ -289,19 +289,19 @@ int v3_chkpt_load(struct v3_chkpt_ctx * ctx, char * tag, uint64_t len, void * bu int rc; if (!ctx) { - PrintError("Attempt to load tag %s from null context\n",tag); + PrintError(VM_NONE, VCORE_NONE, "Attempt to load tag %s from null context\n",tag); return -1; } if (chkpt->current_ctx != ctx) { - PrintError("Attempt to load from context that is not the current context for the store\n"); + PrintError(VM_NONE, VCORE_NONE, "Attempt to load from context that is not the current context for the store\n"); return -1; } rc = chkpt->interface->load(chkpt->store_data, ctx->store_ctx, tag, len, buf); if (rc) { - PrintError("Underlying store failed to load tag %s from valid context\n",tag); + PrintError(VM_NONE, VCORE_NONE, "Underlying store failed to load tag %s from valid context\n",tag); return -1; } else { return 0; @@ -321,12 +321,12 @@ static int load_memory(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { ctx = v3_chkpt_open_ctx(chkpt, "memory_img"); if (!ctx) { - PrintError("Unable to open context for memory load\n"); + PrintError(vm, VCORE_NONE, "Unable to open context for memory load\n"); return -1; } if (v3_chkpt_load(ctx, "memory_img", vm->mem_size, guest_mem_base)) { - PrintError("Unable to load all of memory (requested=%llu bytes, result=%llu bytes\n",(uint64_t)(vm->mem_size),ret); + PrintError(vm, VCORE_NONE, "Unable to load all of memory (requested=%llu bytes, result=%llu bytes\n",(uint64_t)(vm->mem_size),ret); v3_chkpt_close_ctx(ctx); return -1; } @@ -347,12 +347,12 @@ static int save_memory(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { ctx = v3_chkpt_open_ctx(chkpt, "memory_img"); if (!ctx) { - PrintError("Unable to open context to save memory\n"); + PrintError(vm, VCORE_NONE, "Unable to open context to save memory\n"); return -1; } if (v3_chkpt_save(ctx, "memory_img", vm->mem_size, guest_mem_base)) { - PrintError("Unable to save all of memory (requested=%llu, received=%llu)\n",(uint64_t)(vm->mem_size),ret); + PrintError(vm, VCORE_NONE, "Unable to save all of memory (requested=%llu, received=%llu)\n",(uint64_t)(vm->mem_size),ret); v3_chkpt_close_ctx(ctx); return -1; } @@ -402,14 +402,14 @@ static struct mem_migration_state *start_page_tracking(struct v3_vm_info *vm) m = (struct mem_migration_state *)V3_Malloc(sizeof(struct mem_migration_state)); if (!m) { - PrintError("Cannot allocate\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate\n"); return NULL; } m->vm=vm; if (v3_bitmap_init(&(m->modified_pages),vm->mem_size >> 12) == -1) { - PrintError("Failed to initialize modified_pages bit vector"); + PrintError(vm, VCORE_NONE, "Failed to initialize modified_pages bit vector"); V3_Free(m); } @@ -455,12 +455,12 @@ static int save_inc_memory(struct v3_vm_info * vm, guest_mem_base = V3_VAddr((void *)vm->mem_map.base_region.host_addr); - PrintDebug("Saving incremental memory.\n"); + PrintDebug(vm, VCORE_NONE, "Saving incremental memory.\n"); ctx = v3_chkpt_open_ctx(chkpt,"memory_bitmap_bits"); if (!ctx) { - PrintError("Cannot open context for dirty memory bitmap\n"); + PrintError(vm, VCORE_NONE, "Cannot open context for dirty memory bitmap\n"); return -1; } @@ -469,29 +469,29 @@ static int save_inc_memory(struct v3_vm_info * vm, "memory_bitmap_bits", bitmap_num_bytes, mod_pgs_to_send->bits)) { - PrintError("Unable to write all of the dirty memory bitmap\n"); + PrintError(vm, VCORE_NONE, "Unable to write all of the dirty memory bitmap\n"); v3_chkpt_close_ctx(ctx); return -1; } v3_chkpt_close_ctx(ctx); - PrintDebug("Sent bitmap bits.\n"); + PrintDebug(vm, VCORE_NONE, "Sent bitmap bits.\n"); // Dirty memory pages are sent in bitmap order for (i = 0; i < mod_pgs_to_send->num_bits; i++) { if (v3_bitmap_check(mod_pgs_to_send, i)) { - // PrintDebug("Sending memory page %d.\n",i); + // PrintDebug(vm, VCORE_NONE, "Sending memory page %d.\n",i); ctx = v3_chkpt_open_ctx(chkpt, "memory_page"); if (!ctx) { - PrintError("Unable to open context to send memory page\n"); + PrintError(vm, VCORE_NONE, "Unable to open context to send memory page\n"); return -1; } if (v3_chkpt_save(ctx, "memory_page", page_size_bytes, guest_mem_base + (page_size_bytes * i))) { - PrintError("Unable to send a memory page\n"); + PrintError(vm, VCORE_NONE, "Unable to send a memory page\n"); v3_chkpt_close_ctx(ctx); return -1; } @@ -526,7 +526,7 @@ static int load_inc_memory(struct v3_vm_info * vm, ctx = v3_chkpt_open_ctx(chkpt, "memory_bitmap_bits"); if (!ctx) { - PrintError("Cannot open context to receive memory bitmap\n"); + PrintError(vm, VCORE_NONE, "Cannot open context to receive memory bitmap\n"); return -1; } @@ -534,7 +534,7 @@ static int load_inc_memory(struct v3_vm_info * vm, "memory_bitmap_bits", bitmap_num_bytes, mod_pgs->bits)) { - PrintError("Did not receive all of memory bitmap\n"); + PrintError(vm, VCORE_NONE, "Did not receive all of memory bitmap\n"); v3_chkpt_close_ctx(ctx); return -1; } @@ -544,11 +544,11 @@ static int load_inc_memory(struct v3_vm_info * vm, // Receive also follows bitmap order for (i = 0; i < mod_pgs->num_bits; i ++) { if (v3_bitmap_check(mod_pgs, i)) { - PrintDebug("Loading page %d\n", i); + PrintDebug(vm, VCORE_NONE, "Loading page %d\n", i); empty_bitmap = false; ctx = v3_chkpt_open_ctx(chkpt, "memory_page"); if (!ctx) { - PrintError("Cannot open context to receive memory page\n"); + PrintError(vm, VCORE_NONE, "Cannot open context to receive memory page\n"); return -1; } @@ -556,7 +556,7 @@ static int load_inc_memory(struct v3_vm_info * vm, "memory_page", page_size_bytes, guest_mem_base + (page_size_bytes * i))) { - PrintError("Did not receive all of memory page\n"); + PrintError(vm, VCORE_NONE, "Did not receive all of memory page\n"); v3_chkpt_close_ctx(ctx); return -1; } @@ -566,7 +566,7 @@ static int load_inc_memory(struct v3_vm_info * vm, if (empty_bitmap) { // signal end of receiving pages - PrintDebug("Finished receiving pages.\n"); + PrintDebug(vm, VCORE_NONE, "Finished receiving pages.\n"); return 1; } else { // need to run again @@ -583,7 +583,7 @@ int save_header(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { ctx = v3_chkpt_open_ctx(chkpt, "header"); if (!ctx) { - PrintError("Cannot open context to save header\n"); + PrintError(vm, VCORE_NONE, "Cannot open context to save header\n"); return -1; } @@ -591,7 +591,7 @@ int save_header(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { case V3_SVM_CPU: case V3_SVM_REV3_CPU: { if (v3_chkpt_save(ctx, "header", strlen(svm_chkpt_header), svm_chkpt_header)) { - PrintError("Could not save all of SVM header\n"); + PrintError(vm, VCORE_NONE, "Could not save all of SVM header\n"); v3_chkpt_close_ctx(ctx); return -1; } @@ -601,14 +601,14 @@ int save_header(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { case V3_VMX_EPT_CPU: case V3_VMX_EPT_UG_CPU: { if (v3_chkpt_save(ctx, "header", strlen(vmx_chkpt_header), vmx_chkpt_header)) { - PrintError("Could not save all of VMX header\n"); + PrintError(vm, VCORE_NONE, "Could not save all of VMX header\n"); v3_chkpt_close_ctx(ctx); return -1; } break; } default: - PrintError("checkpoint not supported on this architecture\n"); + PrintError(vm, VCORE_NONE, "checkpoint not supported on this architecture\n"); v3_chkpt_close_ctx(ctx); return -1; } @@ -630,7 +630,7 @@ static int load_header(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { char header[strlen(svm_chkpt_header) + 1]; if (v3_chkpt_load(ctx, "header", strlen(svm_chkpt_header), header)) { - PrintError("Could not load all of SVM header\n"); + PrintError(vm, VCORE_NONE, "Could not load all of SVM header\n"); v3_chkpt_close_ctx(ctx); return -1; } @@ -645,7 +645,7 @@ static int load_header(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { char header[strlen(vmx_chkpt_header) + 1]; if (v3_chkpt_load(ctx, "header", strlen(vmx_chkpt_header), header)) { - PrintError("Could not load all of VMX header\n"); + PrintError(vm, VCORE_NONE, "Could not load all of VMX header\n"); v3_chkpt_close_ctx(ctx); return -1; } @@ -655,7 +655,7 @@ static int load_header(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { break; } default: - PrintError("checkpoint not supported on this architecture\n"); + PrintError(vm, VCORE_NONE, "checkpoint not supported on this architecture\n"); v3_chkpt_close_ctx(ctx); return -1; } @@ -672,7 +672,7 @@ static int load_core(struct guest_info * info, struct v3_chkpt * chkpt) { char key_name[16]; v3_reg_t tempreg; - PrintDebug("Loading core\n"); + PrintDebug(info->vm_info, info, "Loading core\n"); memset(key_name, 0, 16); @@ -681,7 +681,7 @@ static int load_core(struct guest_info * info, struct v3_chkpt * chkpt) { ctx = v3_chkpt_open_ctx(chkpt, key_name); if (!ctx) { - PrintError("Could not open context to load core\n"); + PrintError(info->vm_info, info, "Could not open context to load core\n"); goto loadfailout; } @@ -753,7 +753,7 @@ static int load_core(struct guest_info * info, struct v3_chkpt * chkpt) { v3_chkpt_close_ctx(ctx); ctx=0; - PrintDebug("Finished reading guest_info information\n"); + PrintDebug(info->vm_info, info, "Finished reading guest_info information\n"); info->cpu_mode = v3_get_vm_cpu_mode(info); info->mem_mode = v3_get_vm_mem_mode(info); @@ -761,12 +761,12 @@ static int load_core(struct guest_info * info, struct v3_chkpt * chkpt) { if (info->shdw_pg_mode == SHADOW_PAGING) { if (v3_get_vm_mem_mode(info) == VIRTUAL_MEM) { if (v3_activate_shadow_pt(info) == -1) { - PrintError("Failed to activate shadow page tables\n"); + PrintError(info->vm_info, info, "Failed to activate shadow page tables\n"); goto loadfailout; } } else { if (v3_activate_passthrough_pt(info) == -1) { - PrintError("Failed to activate passthrough page tables\n"); + PrintError(info->vm_info, info, "Failed to activate passthrough page tables\n"); goto loadfailout; } } @@ -782,12 +782,12 @@ static int load_core(struct guest_info * info, struct v3_chkpt * chkpt) { ctx = v3_chkpt_open_ctx(chkpt, key_name); if (!ctx) { - PrintError("Could not open context to load SVM core\n"); + PrintError(info->vm_info, info, "Could not open context to load SVM core\n"); goto loadfailout; } if (v3_svm_load_core(info, ctx) < 0 ) { - PrintError("Failed to patch core %d\n", info->vcpu_id); + PrintError(info->vm_info, info, "Failed to patch core %d\n", info->vcpu_id); goto loadfailout; } @@ -805,12 +805,12 @@ static int load_core(struct guest_info * info, struct v3_chkpt * chkpt) { ctx = v3_chkpt_open_ctx(chkpt, key_name); if (!ctx) { - PrintError("Could not open context to load VMX core\n"); + PrintError(info->vm_info, info, "Could not open context to load VMX core\n"); goto loadfailout; } if (v3_vmx_load_core(info, ctx) < 0) { - PrintError("VMX checkpoint failed\n"); + PrintError(info->vm_info, info, "VMX checkpoint failed\n"); goto loadfailout; } @@ -819,18 +819,18 @@ static int load_core(struct guest_info * info, struct v3_chkpt * chkpt) { break; } default: - PrintError("Invalid CPU Type (%d)\n", v3_mach_type); + PrintError(info->vm_info, info, "Invalid CPU Type (%d)\n", v3_mach_type); goto loadfailout; } - PrintDebug("Load of core succeeded\n"); + PrintDebug(info->vm_info, info, "Load of core succeeded\n"); v3_print_guest_state(info); return 0; loadfailout: - PrintError("Failed to load core\n"); + PrintError(info->vm_info, info, "Failed to load core\n"); if (ctx) { v3_chkpt_close_ctx(ctx);} return -1; @@ -844,7 +844,7 @@ static int save_core(struct guest_info * info, struct v3_chkpt * chkpt) { char key_name[16]; v3_reg_t tempreg; - PrintDebug("Saving core\n"); + PrintDebug(info->vm_info, info, "Saving core\n"); v3_print_guest_state(info); @@ -855,7 +855,7 @@ static int save_core(struct guest_info * info, struct v3_chkpt * chkpt) { ctx = v3_chkpt_open_ctx(chkpt, key_name); if (!ctx) { - PrintError("Unable to open context to save core\n"); + PrintError(info->vm_info, info, "Unable to open context to save core\n"); goto savefailout; } @@ -939,12 +939,12 @@ static int save_core(struct guest_info * info, struct v3_chkpt * chkpt) { ctx = v3_chkpt_open_ctx(chkpt, key_name); if (!ctx) { - PrintError("Could not open context to store SVM core\n"); + PrintError(info->vm_info, info, "Could not open context to store SVM core\n"); goto savefailout; } if (v3_svm_save_core(info, ctx) < 0) { - PrintError("VMCB Unable to be written\n"); + PrintError(info->vm_info, info, "VMCB Unable to be written\n"); goto savefailout; } @@ -961,12 +961,12 @@ static int save_core(struct guest_info * info, struct v3_chkpt * chkpt) { ctx = v3_chkpt_open_ctx(chkpt, key_name); if (!ctx) { - PrintError("Could not open context to store VMX core\n"); + PrintError(info->vm_info, info, "Could not open context to store VMX core\n"); goto savefailout; } if (v3_vmx_save_core(info, ctx) == -1) { - PrintError("VMX checkpoint failed\n"); + PrintError(info->vm_info, info, "VMX checkpoint failed\n"); goto savefailout; } @@ -975,7 +975,7 @@ static int save_core(struct guest_info * info, struct v3_chkpt * chkpt) { break; } default: - PrintError("Invalid CPU Type (%d)\n", v3_mach_type); + PrintError(info->vm_info, info, "Invalid CPU Type (%d)\n", v3_mach_type); goto savefailout; } @@ -983,7 +983,7 @@ static int save_core(struct guest_info * info, struct v3_chkpt * chkpt) { return 0; savefailout: - PrintError("Failed to save core\n"); + PrintError(info->vm_info, info, "Failed to save core\n"); if (ctx) { v3_chkpt_close_ctx(ctx); } return -1; @@ -1002,7 +1002,7 @@ int v3_chkpt_save_vm(struct v3_vm_info * vm, char * store, char * url) { chkpt = chkpt_open(vm, store, url, SAVE); if (chkpt == NULL) { - PrintError("Error creating checkpoint store for url %s\n",url); + PrintError(vm, VCORE_NONE, "Error creating checkpoint store for url %s\n",url); return -1; } @@ -1012,25 +1012,25 @@ int v3_chkpt_save_vm(struct v3_vm_info * vm, char * store, char * url) { } if ((ret = save_memory(vm, chkpt)) == -1) { - PrintError("Unable to save memory\n"); + PrintError(vm, VCORE_NONE, "Unable to save memory\n"); goto out; } if ((ret = v3_save_vm_devices(vm, chkpt)) == -1) { - PrintError("Unable to save devices\n"); + PrintError(vm, VCORE_NONE, "Unable to save devices\n"); goto out; } if ((ret = save_header(vm, chkpt)) == -1) { - PrintError("Unable to save header\n"); + PrintError(vm, VCORE_NONE, "Unable to save header\n"); goto out; } for (i = 0; i < vm->num_cores; i++){ if ((ret = save_core(&(vm->cores[i]), chkpt)) == -1) { - PrintError("chkpt of core %d failed\n", i); + PrintError(vm, VCORE_NONE, "chkpt of core %d failed\n", i); goto out; } } @@ -1056,7 +1056,7 @@ int v3_chkpt_load_vm(struct v3_vm_info * vm, char * store, char * url) { chkpt = chkpt_open(vm, store, url, LOAD); if (chkpt == NULL) { - PrintError("Error creating checkpoint store\n"); + PrintError(vm, VCORE_NONE, "Error creating checkpoint store\n"); return -1; } @@ -1066,26 +1066,26 @@ int v3_chkpt_load_vm(struct v3_vm_info * vm, char * store, char * url) { } if ((ret = load_memory(vm, chkpt)) == -1) { - PrintError("Unable to load memory\n"); + PrintError(vm, VCORE_NONE, "Unable to load memory\n"); goto out; } if ((ret = v3_load_vm_devices(vm, chkpt)) == -1) { - PrintError("Unable to load devies\n"); + PrintError(vm, VCORE_NONE, "Unable to load devies\n"); goto out; } if ((ret = load_header(vm, chkpt)) == -1) { - PrintError("Unable to load header\n"); + PrintError(vm, VCORE_NONE, "Unable to load header\n"); goto out; } //per core cloning for (i = 0; i < vm->num_cores; i++) { if ((ret = load_core(&(vm->cores[i]), chkpt)) == -1) { - PrintError("Error loading core state (core=%d)\n", i); + PrintError(vm, VCORE_NONE, "Error loading core state (core=%d)\n", i); goto out; } } @@ -1134,7 +1134,7 @@ int v3_chkpt_send_vm(struct v3_vm_info * vm, char * store, char * url) { // Currently will work only for shadow paging for (i=0;inum_cores;i++) { if (vm->cores[i].shdw_pg_mode!=SHADOW_PAGING) { - PrintError("Cannot currently handle nested paging\n"); + PrintError(vm, VCORE_NONE, "Cannot currently handle nested paging\n"); return -1; } } @@ -1143,7 +1143,7 @@ int v3_chkpt_send_vm(struct v3_vm_info * vm, char * store, char * url) { chkpt = chkpt_open(vm, store, url, SAVE); if (chkpt == NULL) { - PrintError("Error creating checkpoint store\n"); + PrintError(vm, VCORE_NONE, "Error creating checkpoint store\n"); chkpt_close(chkpt); return -1; } @@ -1154,7 +1154,7 @@ int v3_chkpt_send_vm(struct v3_vm_info * vm, char * store, char * url) { if (v3_bitmap_init(&modified_pages_to_send, vm->mem_size>>12 // number of pages in main region ) == -1) { - PrintError("Could not intialize bitmap.\n"); + PrintError(vm, VCORE_NONE, "Could not intialize bitmap.\n"); return -1; } @@ -1165,14 +1165,14 @@ int v3_chkpt_send_vm(struct v3_vm_info * vm, char * store, char * url) { iter = 0; while (!last_modpage_iteration) { - PrintDebug("Modified memory page iteration %d\n",i++); + PrintDebug(vm, VCORE_NONE, "Modified memory page iteration %d\n",i++); start_time = v3_get_host_time(&(vm->cores[0].time_state)); // We will pause the VM for a short while // so that we can collect the set of changed pages if (v3_pause_vm(vm) == -1) { - PrintError("Could not pause VM\n"); + PrintError(vm, VCORE_NONE, "Could not pause VM\n"); ret = -1; goto out; } @@ -1195,26 +1195,26 @@ int v3_chkpt_send_vm(struct v3_vm_info * vm, char * store, char * url) { // we are done, so we will not restart page tracking // the vm is paused, and so we should be able // to just send the data - PrintDebug("Last modified memory page iteration.\n"); + PrintDebug(vm, VCORE_NONE, "Last modified memory page iteration.\n"); last_modpage_iteration = true; } else { // we are not done, so we will restart page tracking // to prepare for a second round of pages // we will resume the VM as this happens if (!(mm_state=start_page_tracking(vm))) { - PrintError("Error enabling page tracking.\n"); + PrintError(vm, VCORE_NONE, "Error enabling page tracking.\n"); ret = -1; goto out; } if (v3_continue_vm(vm) == -1) { - PrintError("Error resuming the VM\n"); + PrintError(vm, VCORE_NONE, "Error resuming the VM\n"); stop_page_tracking(mm_state); ret = -1; goto out; } stop_time = v3_get_host_time(&(vm->cores[0].time_state)); - PrintDebug("num_mod_pages=%d\ndowntime=%llu\n",num_mod_pages,stop_time-start_time); + PrintDebug(vm, VCORE_NONE, "num_mod_pages=%d\ndowntime=%llu\n",num_mod_pages,stop_time-start_time); } @@ -1223,7 +1223,7 @@ int v3_chkpt_send_vm(struct v3_vm_info * vm, char * store, char * url) { // round in parallel with current execution if (num_mod_pages>0) { if (save_inc_memory(vm, &modified_pages_to_send, chkpt) == -1) { - PrintError("Error sending incremental memory.\n"); + PrintError(vm, VCORE_NONE, "Error sending incremental memory.\n"); ret = -1; goto out; } @@ -1233,40 +1233,40 @@ int v3_chkpt_send_vm(struct v3_vm_info * vm, char * store, char * url) { } if (v3_bitmap_reset(&modified_pages_to_send) == -1) { - PrintError("Error reseting bitmap.\n"); + PrintError(vm, VCORE_NONE, "Error reseting bitmap.\n"); ret = -1; goto out; } // send bitmap of 0s to signal end of modpages if (save_inc_memory(vm, &modified_pages_to_send, chkpt) == -1) { - PrintError("Error sending incremental memory.\n"); + PrintError(vm, VCORE_NONE, "Error sending incremental memory.\n"); ret = -1; goto out; } // save the non-memory state if ((ret = v3_save_vm_devices(vm, chkpt)) == -1) { - PrintError("Unable to save devices\n"); + PrintError(vm, VCORE_NONE, "Unable to save devices\n"); goto out; } if ((ret = save_header(vm, chkpt)) == -1) { - PrintError("Unable to save header\n"); + PrintError(vm, VCORE_NONE, "Unable to save header\n"); goto out; } for (i = 0; i < vm->num_cores; i++){ if ((ret = save_core(&(vm->cores[i]), chkpt)) == -1) { - PrintError("chkpt of core %d failed\n", i); + PrintError(vm, VCORE_NONE, "chkpt of core %d failed\n", i); goto out; } } stop_time = v3_get_host_time(&(vm->cores[0].time_state)); - PrintDebug("num_mod_pages=%d\ndowntime=%llu\n",num_mod_pages,stop_time-start_time); - PrintDebug("Done sending VM!\n"); + PrintDebug(vm, VCORE_NONE, "num_mod_pages=%d\ndowntime=%llu\n",num_mod_pages,stop_time-start_time); + PrintDebug(vm, VCORE_NONE, "Done sending VM!\n"); out: v3_bitmap_deinit(&modified_pages_to_send); chkpt_close(chkpt); @@ -1284,7 +1284,7 @@ int v3_chkpt_receive_vm(struct v3_vm_info * vm, char * store, char * url) { // Currently will work only for shadow paging for (i=0;inum_cores;i++) { if (vm->cores[i].shdw_pg_mode!=SHADOW_PAGING) { - PrintError("Cannot currently handle nested paging\n"); + PrintError(vm, VCORE_NONE, "Cannot currently handle nested paging\n"); return -1; } } @@ -1292,14 +1292,14 @@ int v3_chkpt_receive_vm(struct v3_vm_info * vm, char * store, char * url) { chkpt = chkpt_open(vm, store, url, LOAD); if (chkpt == NULL) { - PrintError("Error creating checkpoint store\n"); + PrintError(vm, VCORE_NONE, "Error creating checkpoint store\n"); chkpt_close(chkpt); return -1; } if (v3_bitmap_init(&mod_pgs,vm->mem_size>>12) == -1) { chkpt_close(chkpt); - PrintError("Could not intialize bitmap.\n"); + PrintError(vm, VCORE_NONE, "Could not intialize bitmap.\n"); return -1; } @@ -1312,27 +1312,27 @@ int v3_chkpt_receive_vm(struct v3_vm_info * vm, char * store, char * url) { while(true) { // 1. Receive copy of bitmap // 2. Receive pages - PrintDebug("Memory page iteration %d\n",i++); + PrintDebug(vm, VCORE_NONE, "Memory page iteration %d\n",i++); int retval = load_inc_memory(vm, &mod_pgs, chkpt); if (retval == 1) { // end of receiving memory pages break; } else if (retval == -1) { - PrintError("Error receiving incremental memory.\n"); + PrintError(vm, VCORE_NONE, "Error receiving incremental memory.\n"); ret = -1; goto out; } } if ((ret = v3_load_vm_devices(vm, chkpt)) == -1) { - PrintError("Unable to load devices\n"); + PrintError(vm, VCORE_NONE, "Unable to load devices\n"); ret = -1; goto out; } if ((ret = load_header(vm, chkpt)) == -1) { - PrintError("Unable to load header\n"); + PrintError(vm, VCORE_NONE, "Unable to load header\n"); ret = -1; goto out; } @@ -1340,23 +1340,23 @@ int v3_chkpt_receive_vm(struct v3_vm_info * vm, char * store, char * url) { //per core cloning for (i = 0; i < vm->num_cores; i++) { if ((ret = load_core(&(vm->cores[i]), chkpt)) == -1) { - PrintError("Error loading core state (core=%d)\n", i); + PrintError(vm, VCORE_NONE, "Error loading core state (core=%d)\n", i); goto out; } } out: if (ret==-1) { - PrintError("Unable to receive VM\n"); + PrintError(vm, VCORE_NONE, "Unable to receive VM\n"); } else { - PrintDebug("Done receving the VM\n"); + PrintDebug(vm, VCORE_NONE, "Done receving the VM\n"); } /* Resume the guest if it was running and we didn't just trash the state*/ if (vm->run_state == VM_RUNNING) { if (ret == -1) { - PrintError("VM was previously running. It is now borked. Pausing it. \n"); + PrintError(vm, VCORE_NONE, "VM was previously running. It is now borked. Pausing it. \n"); vm->run_state = VM_STOPPED; } diff --git a/palacios/src/palacios/vmm_chkpt_stores.h b/palacios/src/palacios/vmm_chkpt_stores.h index 0b9829f..d7bc3f0 100644 --- a/palacios/src/palacios/vmm_chkpt_stores.h +++ b/palacios/src/palacios/vmm_chkpt_stores.h @@ -47,11 +47,11 @@ static struct {} null_store __attribute__((__used__)) \ static void * debug_open_chkpt(char * url, chkpt_mode_t mode) { if (mode == LOAD) { - V3_Print("Cannot load from debug store\n"); + V3_Print(VM_NONE, VCORE_NONE, "Cannot load from debug store\n"); return NULL; } - V3_Print("Opening Checkpoint: %s\n", url); + V3_Print(VM_NONE, VCORE_NONE, "Opening Checkpoint: %s\n", url); return (void *)1; } @@ -59,24 +59,24 @@ static void * debug_open_chkpt(char * url, chkpt_mode_t mode) { static int debug_close_chkpt(void * store_data) { - V3_Print("Closing Checkpoint\n"); + V3_Print(VM_NONE, VCORE_NONE, "Closing Checkpoint\n"); return 0; } static void * debug_open_ctx(void * store_data, char * name) { - V3_Print("[%s]\n", name); + V3_Print(VM_NONE, VCORE_NONE, "[%s]\n", name); return (void *)1; } static int debug_close_ctx(void * store_data, void * ctx) { - V3_Print("[CLOSE]\n"); + V3_Print(VM_NONE, VCORE_NONE, "[CLOSE]\n"); return 0; } static int debug_save(void * store_data, void * ctx, char * tag, uint64_t len, void * buf) { - V3_Print("%s:\n", tag); + V3_Print(VM_NONE, VCORE_NONE, "%s:\n", tag); if (len > 100) { len = 100; @@ -89,7 +89,7 @@ static int debug_save(void * store_data, void * ctx, static int debug_load(void * store_data, void * ctx, char * tag, uint64_t len, void * buf) { - V3_Print("Loading not supported !!!\n"); + V3_Print(VM_NONE, VCORE_NONE, "Loading not supported !!!\n"); return 0; } @@ -221,7 +221,7 @@ static void * dir_open_ctx(void * store_data, ctx = V3_Malloc(sizeof(struct file_ctx)); if (!ctx) { - PrintError("Cannot allocate\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate\n"); return NULL; } @@ -230,7 +230,7 @@ static void * dir_open_ctx(void * store_data, ctx->filename = V3_Malloc(strlen(url) + strlen(name) + 5); if (!ctx->filename) { - PrintError("Cannot allocate\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate\n"); V3_Free(ctx); return NULL; } diff --git a/palacios/src/palacios/vmm_config.c b/palacios/src/palacios/vmm_config.c index 75d9ea7..d8f1961 100644 --- a/palacios/src/palacios/vmm_config.c +++ b/palacios/src/palacios/vmm_config.c @@ -95,7 +95,7 @@ char * v3_cfg_val(v3_cfg_tree_t * tree, char * tag) { char * val = NULL; if ((child_entry != NULL) && (attrib != NULL)) { - PrintError("Duplicate Configuration parameters present for %s\n", tag); + PrintError(VM_NONE, VCORE_NONE, "Duplicate Configuration parameters present for %s\n", tag); return NULL; } @@ -151,25 +151,25 @@ static struct v3_config * parse_config(void * cfg_blob) { v3_cfg_tree_t * file_tree = NULL; int version=-1; - V3_Print("cfg data at %p\n", cfg_blob); + V3_Print(VM_NONE, VCORE_NONE, "cfg data at %p\n", cfg_blob); if (memcmp(cfg_blob, COOKIE_V0, COOKIE_LEN) == 0) { version = 0; } else if (memcmp(cfg_blob, COOKIE_V1, COOKIE_LEN) == 0) { version = 1; } else { - PrintError("Invalid Configuration Header Or Unknown Version\n"); + PrintError(VM_NONE, VCORE_NONE, "Invalid Configuration Header Or Unknown Version\n"); return NULL; } - V3_Print("Handling Palacios Image Format, Version 0x%x\n",version); + V3_Print(VM_NONE, VCORE_NONE, "Handling Palacios Image Format, Version 0x%x\n",version); offset += COOKIE_LEN; cfg = (struct v3_config *)V3_Malloc(sizeof(struct v3_config)); if (!cfg) { - PrintError("Unable to allocate while parsing\n"); + PrintError(VM_NONE, VCORE_NONE, "Unable to allocate while parsing\n"); return NULL; } @@ -180,7 +180,7 @@ static struct v3_config * parse_config(void * cfg_blob) { cfg->file_table = v3_create_htable(0, file_hash_fn, file_eq_fn); if (!(cfg->file_table)) { - PrintError("Unable to allocate hash table while parsing\n"); + PrintError(VM_NONE, VCORE_NONE, "Unable to allocate hash table while parsing\n"); V3_Free(cfg); return NULL; } @@ -196,10 +196,10 @@ static struct v3_config * parse_config(void * cfg_blob) { // This is hideous, but the file formats are still very close if (version==0) { files_v0 = (struct file_idx_table_v0 *)(cfg_blob + offset); - V3_Print("Number of files in cfg: %d\n", (uint32_t)(files_v0->num_files)); + V3_Print(VM_NONE, VCORE_NONE, "Number of files in cfg: %d\n", (uint32_t)(files_v0->num_files)); } else { files_v1 = (struct file_idx_table_v1 *)(cfg_blob + offset); - V3_Print("Number of files in cfg: %d\n", (uint32_t)(files_v1->num_files)); + V3_Print(VM_NONE, VCORE_NONE, "Number of files in cfg: %d\n", (uint32_t)(files_v1->num_files)); } @@ -214,13 +214,13 @@ static struct v3_config * parse_config(void * cfg_blob) { file = (struct v3_cfg_file *)V3_Malloc(sizeof(struct v3_cfg_file)); if (!file) { - PrintError("Could not allocate file structure\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not allocate file structure\n"); v3_free_htable(cfg->file_table,0,0); V3_Free(cfg); return NULL; } - V3_Print("File index=%d id=%s\n", idx, id); + V3_Print(VM_NONE, VCORE_NONE, "File index=%d id=%s\n", idx, id); strncpy(file->tag, id, V3_MAX_TAG_LEN); @@ -231,8 +231,8 @@ static struct v3_config * parse_config(void * cfg_blob) { file->data = cfg_blob + hdr->offset; file->hash = 0; - V3_Print("Storing file data offset = %d, size=%d\n", (uint32_t)hdr->offset, hdr->size); - V3_Print("file data at %p\n", file->data); + V3_Print(VM_NONE, VCORE_NONE, "Storing file data offset = %d, size=%d\n", (uint32_t)hdr->offset, hdr->size); + V3_Print(VM_NONE, VCORE_NONE, "file data at %p\n", file->data); } else if (version==1) { struct file_hdr_v1 * hdr = &(files_v1->hdrs[idx]); @@ -242,30 +242,30 @@ static struct v3_config * parse_config(void * cfg_blob) { file->data = cfg_blob + hdr->offset; file->hash = hdr->hash; - V3_Print("Storing file data offset = %d, size=%d\n", (uint32_t)hdr->offset, hdr->size); - V3_Print("file data at %p\n", file->data); - V3_Print("Checking file data integrity...\n"); + V3_Print(VM_NONE, VCORE_NONE, "Storing file data offset = %d, size=%d\n", (uint32_t)hdr->offset, hdr->size); + V3_Print(VM_NONE, VCORE_NONE, "file data at %p\n", file->data); + V3_Print(VM_NONE, VCORE_NONE, "Checking file data integrity...\n"); if ((hash = v3_hash_buffer(file->data, file->size)) != file->hash) { - PrintError("File data corrupted! (orig hash=0x%lx, new=0x%lx\n", + PrintError(VM_NONE, VCORE_NONE, "File data corrupted! (orig hash=0x%lx, new=0x%lx\n", file->hash, hash); return NULL; } - V3_Print("File data OK\n"); + V3_Print(VM_NONE, VCORE_NONE, "File data OK\n"); } list_add( &(file->file_node), &(cfg->file_list)); - V3_Print("Keying file to name\n"); + V3_Print(VM_NONE, VCORE_NONE, "Keying file to name\n"); v3_htable_insert(cfg->file_table, (addr_t)(file->tag), (addr_t)(file)); - V3_Print("Iterating to next file\n"); + V3_Print(VM_NONE, VCORE_NONE, "Iterating to next file\n"); file_tree = v3_cfg_next_branch(file_tree); } - V3_Print("Configuration parsed successfully\n"); + V3_Print(VM_NONE, VCORE_NONE, "Configuration parsed successfully\n"); return cfg; } @@ -285,8 +285,8 @@ static inline uint32_t get_alignment(char * align_str) { #ifndef V3_CONFIG_ALIGNED_PG_ALLOC if (alignment != PAGE_SIZE_4KB) { - PrintError("Aligned page allocations are not supported in this host (requested alignment=%d)\n", alignment); - PrintError("Ignoring alignment request\n"); + PrintError(VM_NONE, VCORE_NONE, "Aligned page allocations are not supported in this host (requested alignment=%d)\n", alignment); + PrintError(VM_NONE, VCORE_NONE, "Ignoring alignment request\n"); } #endif @@ -303,15 +303,15 @@ static int pre_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * vm_cfg) { if (!memory_str) { - PrintError("Memory is a required configuration parameter\n"); + PrintError(VM_NONE, VCORE_NONE, "Memory is a required configuration parameter\n"); return -1; } - PrintDebug("Memory=%s\n", memory_str); + PrintDebug(VM_NONE, VCORE_NONE, "Memory=%s\n", memory_str); if (align_str) { - PrintDebug("Alignment=%s\n", align_str); + PrintDebug(VM_NONE, VCORE_NONE, "Alignment=%s\n", align_str); } else { - PrintDebug("Alignment defaulted to 4KB.\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Alignment defaulted to 4KB.\n"); } // Amount of ram the Guest will have, always in MB @@ -319,12 +319,12 @@ static int pre_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * vm_cfg) { vm->mem_align = get_alignment(align_str); - PrintDebug("Alignment for %lu bytes of memory computed as 0x%x\n", vm->mem_size, vm->mem_align); + PrintDebug(VM_NONE, VCORE_NONE, "Alignment for %lu bytes of memory computed as 0x%x\n", vm->mem_size, vm->mem_align); if (strcasecmp(vm_class, "PC") == 0) { vm->vm_class = V3_PC_VM; } else { - PrintError("Invalid VM class\n"); + PrintError(VM_NONE, VCORE_NONE, "Invalid VM class\n"); return -1; } @@ -342,7 +342,7 @@ static int pre_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * vm_cfg) { #endif if (v3_init_vm(vm) == -1) { - PrintError("Failed to initialize VM\n"); + PrintError(VM_NONE, VCORE_NONE, "Failed to initialize VM\n"); return -1; } @@ -352,7 +352,7 @@ static int pre_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * vm_cfg) { sched_hz = atoi(schedule_hz_str); } - PrintDebug("CPU_KHZ = %d, schedule_freq=%p\n", V3_CPU_KHZ(), + PrintDebug(VM_NONE, VCORE_NONE, "CPU_KHZ = %d, schedule_freq=%p\n", V3_CPU_KHZ(), (void *)(addr_t)sched_hz); vm->yield_cycle_period = (V3_CPU_KHZ() * 1000) / sched_hz; @@ -368,7 +368,7 @@ static int determine_paging_mode(struct guest_info * info, v3_cfg_tree_t * core_ v3_cfg_tree_t * pg_tree = v3_cfg_subtree(vm_tree, "paging"); char * pg_mode = v3_cfg_val(pg_tree, "mode"); - PrintDebug("Paging mode specified as %s\n", pg_mode); + PrintDebug(info->vm_info, info, "Paging mode specified as %s\n", pg_mode); if (pg_mode) { if ((strcasecmp(pg_mode, "nested") == 0)) { @@ -377,21 +377,21 @@ static int determine_paging_mode(struct guest_info * info, v3_cfg_tree_t * core_ (v3_mach_type == V3_VMX_EPT_CPU) || (v3_mach_type == V3_VMX_EPT_UG_CPU)) { - V3_Print("Setting paging mode to NESTED\n"); + V3_Print(info->vm_info, info, "Setting paging mode to NESTED\n"); info->shdw_pg_mode = NESTED_PAGING; } else { - PrintError("Nested paging not supported on this hardware. Defaulting to shadow paging\n"); + PrintError(info->vm_info, info, "Nested paging not supported on this hardware. Defaulting to shadow paging\n"); info->shdw_pg_mode = SHADOW_PAGING; } } else if ((strcasecmp(pg_mode, "shadow") == 0)) { - V3_Print("Setting paging mode to SHADOW\n"); + V3_Print(info->vm_info, info, "Setting paging mode to SHADOW\n"); info->shdw_pg_mode = SHADOW_PAGING; } else { - PrintError("Invalid paging mode (%s) specified in configuration. Defaulting to shadow paging\n", pg_mode); + PrintError(info->vm_info, info, "Invalid paging mode (%s) specified in configuration. Defaulting to shadow paging\n", pg_mode); info->shdw_pg_mode = SHADOW_PAGING; } } else { - V3_Print("No paging type specified in configuration. Defaulting to shadow paging\n"); + V3_Print(info->vm_info, info, "No paging type specified in configuration. Defaulting to shadow paging\n"); info->shdw_pg_mode = SHADOW_PAGING; } @@ -399,7 +399,7 @@ static int determine_paging_mode(struct guest_info * info, v3_cfg_tree_t * core_ if (v3_cfg_val(pg_tree, "large_pages") != NULL) { if (strcasecmp(v3_cfg_val(pg_tree, "large_pages"), "true") == 0) { info->use_large_pages = 1; - PrintDebug("Use of large pages in memory virtualization enabled.\n"); + PrintDebug(info->vm_info, info, "Use of large pages in memory virtualization enabled.\n"); } } return 0; @@ -411,17 +411,17 @@ static int pre_config_core(struct guest_info * info, v3_cfg_tree_t * core_cfg) { } if (v3_init_core(info) == -1) { - PrintError("Error Initializing Core\n"); + PrintError(info->vm_info, info, "Error Initializing Core\n"); return -1; } if (info->vm_info->vm_class == V3_PC_VM) { if (pre_config_pc_core(info, core_cfg) == -1) { - PrintError("PC Post configuration failure\n"); + PrintError(info->vm_info, info, "PC Post configuration failure\n"); return -1; } } else { - PrintError("Invalid VM Class\n"); + PrintError(info->vm_info, info, "Invalid VM Class\n"); return -1; } @@ -436,18 +436,18 @@ static int post_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { // Configure the memory map for the guest if (setup_memory_map(vm, cfg) == -1) { - PrintError("Setting up guest memory map failed...\n"); + PrintError(vm, VCORE_NONE,"Setting up guest memory map failed...\n"); return -1; } if (vm->vm_class == V3_PC_VM) { if (post_config_pc(vm, cfg) == -1) { - PrintError("PC Post configuration failure\n"); + PrintError(vm, VCORE_NONE,"PC Post configuration failure\n"); return -1; } } else { - PrintError("Invalid VM Class\n"); + PrintError(vm, VCORE_NONE,"Invalid VM Class\n"); return -1; } @@ -456,7 +456,7 @@ static int post_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { * Initialize configured devices */ if (setup_devices(vm, cfg) == -1) { - PrintError("Failed to setup devices\n"); + PrintError(vm, VCORE_NONE,"Failed to setup devices\n"); return -1; } @@ -471,12 +471,12 @@ static int post_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { * Initialize configured extensions */ if (setup_extensions(vm, cfg) == -1) { - PrintError("Failed to setup extensions\n"); + PrintError(vm, VCORE_NONE,"Failed to setup extensions\n"); return -1; } if (v3_setup_performance_tuning(vm, cfg) == -1) { - PrintError("Failed to configure performance tuning parameters\n"); + PrintError(vm, VCORE_NONE,"Failed to configure performance tuning parameters\n"); return -1; } @@ -492,17 +492,17 @@ static int post_config_core(struct guest_info * info, v3_cfg_tree_t * cfg) { if (v3_init_core_extensions(info) == -1) { - PrintError("Error intializing extension core states\n"); + PrintError(info->vm_info, info, "Error intializing extension core states\n"); return -1; } if (info->vm_info->vm_class == V3_PC_VM) { if (post_config_pc_core(info, cfg) == -1) { - PrintError("PC Post configuration failure\n"); + PrintError(info->vm_info, info, "PC Post configuration failure\n"); return -1; } } else { - PrintError("Invalid VM Class\n"); + PrintError(info->vm_info, info, "Invalid VM Class\n"); return -1; } @@ -517,7 +517,7 @@ static struct v3_vm_info * allocate_guest(int num_cores) { struct v3_vm_info * vm = V3_Malloc(guest_state_size); if (!vm) { - PrintError("Unable to allocate space for guest data structures\n"); + PrintError(VM_NONE, VCORE_NONE, "Unable to allocate space for guest data structures\n"); return NULL; } @@ -548,36 +548,36 @@ struct v3_vm_info * v3_config_guest(void * cfg_blob, void * priv_data) { v3_cfg_tree_t * per_core_cfg = NULL; if (v3_mach_type == V3_INVALID_CPU) { - PrintError("Configuring guest on invalid CPU\n"); + PrintError(VM_NONE, VCORE_NONE, "Configuring guest on invalid CPU\n"); return NULL; } cfg_data = parse_config(cfg_blob); if (!cfg_data) { - PrintError("Could not parse configuration\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not parse configuration\n"); return NULL; } cores_cfg = v3_cfg_subtree(cfg_data->cfg, "cores"); if (!cores_cfg) { - PrintError("Could not find core configuration (new config format required)\n"); + PrintError(VM_NONE, VCORE_NONE, "Could not find core configuration (new config format required)\n"); return NULL; } num_cores = atoi(v3_cfg_val(cores_cfg, "count")); if (num_cores == 0) { - PrintError("No cores specified in configuration\n"); + PrintError(VM_NONE, VCORE_NONE, "No cores specified in configuration\n"); return NULL; } - V3_Print("Configuring %d cores\n", num_cores); + V3_Print(VM_NONE, VCORE_NONE, "Configuring %d cores\n", num_cores); vm = allocate_guest(num_cores); if (!vm) { - PrintError("Could not allocate %d core guest\n", vm->num_cores); + PrintError(VM_NONE, VCORE_NONE, "Could not allocate %d core guest\n", vm->num_cores); return NULL; } @@ -585,14 +585,14 @@ struct v3_vm_info * v3_config_guest(void * cfg_blob, void * priv_data) { vm->cfg_data = cfg_data; - V3_Print("Preconfiguration\n"); + V3_Print(vm, VCORE_NONE, "Preconfiguration\n"); if (pre_config_vm(vm, vm->cfg_data->cfg) == -1) { - PrintError("Error in preconfiguration\n"); + PrintError(vm, VCORE_NONE, "Error in preconfiguration\n"); return NULL; } - V3_Print("Per core configuration\n"); + V3_Print(vm, VCORE_NONE, "Per core configuration\n"); per_core_cfg = v3_cfg_subtree(cores_cfg, "core"); // per core configuration @@ -604,7 +604,7 @@ struct v3_vm_info * v3_config_guest(void * cfg_blob, void * priv_data) { info->core_cfg_data = per_core_cfg; if (pre_config_core(info, per_core_cfg) == -1) { - PrintError("Error in core %d preconfiguration\n", i); + PrintError(vm, VCORE_NONE, "Error in core %d preconfiguration\n", i); return NULL; } @@ -613,10 +613,10 @@ struct v3_vm_info * v3_config_guest(void * cfg_blob, void * priv_data) { } - V3_Print("Post Configuration\n"); + V3_Print(vm, VCORE_NONE, "Post Configuration\n"); if (post_config_vm(vm, vm->cfg_data->cfg) == -1) { - PrintError("Error in postconfiguration\n"); + PrintError(vm, VCORE_NONE, "Error in postconfiguration\n"); return NULL; } @@ -632,7 +632,7 @@ struct v3_vm_info * v3_config_guest(void * cfg_blob, void * priv_data) { per_core_cfg = v3_cfg_next_branch(per_core_cfg); } - V3_Print("Configuration successfull\n"); + V3_Print(vm, VCORE_NONE, "Configuration successfull\n"); return vm; } @@ -662,7 +662,7 @@ static int setup_memory_map(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { if (v3_add_shadow_mem(vm, V3_MEM_CORE_ANY, start_addr, end_addr, host_addr) == -1) { - PrintError("Could not map memory region: %p-%p => %p\n", + PrintError(vm, VCORE_NONE,"Could not map memory region: %p-%p => %p\n", (void *)start_addr, (void *)end_addr, (void *)host_addr); return -1; } @@ -681,14 +681,14 @@ static int setup_extensions(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { char * ext_name = v3_cfg_val(extension, "name"); if (!ext_name) { - PrintError("Extension has no name\n"); + PrintError(vm, VCORE_NONE, "Extension has no name\n"); return -1; } - V3_Print("Configuring extension %s\n", ext_name); + V3_Print(vm, VCORE_NONE, "Configuring extension %s\n", ext_name); if (v3_add_extension(vm, ext_name, extension) == -1) { - PrintError("Error adding extension %s\n", ext_name); + PrintError(vm, VCORE_NONE, "Error adding extension %s\n", ext_name); return -1; } @@ -706,10 +706,10 @@ static int setup_devices(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { while (device) { char * dev_class = v3_cfg_val(device, "class"); - V3_Print("configuring device %s\n", dev_class); + V3_Print(vm, VCORE_NONE, "configuring device %s\n", dev_class); if (v3_create_device(vm, dev_class, device) == -1) { - PrintError("Error creating device %s\n", dev_class); + PrintError(vm, VCORE_NONE, "Error creating device %s\n", dev_class); return -1; } diff --git a/palacios/src/palacios/vmm_config_class.h b/palacios/src/palacios/vmm_config_class.h index 3f5b238..7ce2277 100644 --- a/palacios/src/palacios/vmm_config_class.h +++ b/palacios/src/palacios/vmm_config_class.h @@ -55,7 +55,7 @@ static int post_config_pc(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { void * vgabios_dst = 0; if (v3_gpa_to_hva(&(vm->cores[0]), VGABIOS_START, (addr_t *)&vgabios_dst) == -1) { - PrintError("Could not find VGABIOS destination address\n"); + PrintError(vm, VCORE_NONE, "Could not find VGABIOS destination address\n"); return -1; } @@ -69,7 +69,7 @@ static int post_config_pc(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { void * rombios_dst = 0; if (v3_gpa_to_hva(&(vm->cores[0]), ROMBIOS_START, (addr_t *)&rombios_dst) == -1) { - PrintError("Could not find ROMBIOS destination address\n"); + PrintError(vm, VCORE_NONE, "Could not find ROMBIOS destination address\n"); return -1; } diff --git a/palacios/src/palacios/vmm_cpuid.c b/palacios/src/palacios/vmm_cpuid.c index e36f5c2..c170089 100644 --- a/palacios/src/palacios/vmm_cpuid.c +++ b/palacios/src/palacios/vmm_cpuid.c @@ -190,7 +190,7 @@ int v3_cpuid_add_fields(struct v3_vm_info * vm, uint32_t cpuid, if ((~rax_mask & rax) || (~rbx_mask & rbx) || (~rcx_mask & rcx) || (~rdx_mask & rdx)) { - PrintError("Invalid cpuid reg value (mask overrun)\n"); + PrintError(vm, VCORE_NONE, "Invalid cpuid reg value (mask overrun)\n"); return -1; } @@ -199,7 +199,7 @@ int v3_cpuid_add_fields(struct v3_vm_info * vm, uint32_t cpuid, struct masked_cpuid * mask = V3_Malloc(sizeof(struct masked_cpuid)); if (!mask) { - PrintError("Unable to alocate space for cpu id mask\n"); + PrintError(vm, VCORE_NONE, "Unable to alocate space for cpu id mask\n"); return -1; } @@ -215,7 +215,7 @@ int v3_cpuid_add_fields(struct v3_vm_info * vm, uint32_t cpuid, mask->rdx = rdx; if (v3_hook_cpuid(vm, cpuid, mask_hook, mask) == -1) { - PrintError("Error hooking cpuid %d\n", cpuid); + PrintError(vm, VCORE_NONE, "Error hooking cpuid %d\n", cpuid); V3_Free(mask); return -1; } @@ -224,7 +224,7 @@ int v3_cpuid_add_fields(struct v3_vm_info * vm, uint32_t cpuid, uint32_t tmp_val = 0; if (hook->hook_fn != mask_hook) { - PrintError("trying to add fields to a fully hooked cpuid (%d)\n", cpuid); + PrintError(vm, VCORE_NONE, "trying to add fields to a fully hooked cpuid (%d)\n", cpuid); return -1; } @@ -234,7 +234,7 @@ int v3_cpuid_add_fields(struct v3_vm_info * vm, uint32_t cpuid, (mask->rbx_mask & rbx_mask) || (mask->rcx_mask & rcx_mask) || (mask->rdx_mask & rdx_mask)) { - PrintError("Trying to add fields that have already been masked\n"); + PrintError(vm, VCORE_NONE, "Trying to add fields that have already been masked\n"); return -1; } @@ -268,7 +268,7 @@ int v3_unhook_cpuid(struct v3_vm_info * vm, uint32_t cpuid) { struct v3_cpuid_hook * hook = get_cpuid_hook(vm, cpuid); if (hook == NULL) { - PrintError("Could not find cpuid to unhook (0x%x)\n", cpuid); + PrintError(vm, VCORE_NONE, "Could not find cpuid to unhook (0x%x)\n", cpuid); return -1; } @@ -288,14 +288,14 @@ int v3_hook_cpuid(struct v3_vm_info * vm, uint32_t cpuid, struct v3_cpuid_hook * hook = NULL; if (hook_fn == NULL) { - PrintError("CPUID hook requested with null handler\n"); + PrintError(vm, VCORE_NONE, "CPUID hook requested with null handler\n"); return -1; } hook = (struct v3_cpuid_hook *)V3_Malloc(sizeof(struct v3_cpuid_hook)); if (!hook) { - PrintError("Cannot allocate memory to hook cpu id\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate memory to hook cpu id\n"); return -1; } @@ -304,7 +304,7 @@ int v3_hook_cpuid(struct v3_vm_info * vm, uint32_t cpuid, hook->hook_fn = hook_fn; if (insert_cpuid_hook(vm, hook)) { - PrintError("Could not hook cpuid 0x%x (already hooked)\n", cpuid); + PrintError(vm, VCORE_NONE, "Could not hook cpuid 0x%x (already hooked)\n", cpuid); V3_Free(hook); return -1; } @@ -316,10 +316,10 @@ int v3_handle_cpuid(struct guest_info * info) { uint32_t cpuid = info->vm_regs.rax; struct v3_cpuid_hook * hook = get_cpuid_hook(info->vm_info, cpuid); - //PrintDebug("CPUID called for 0x%x\n", cpuid); + //PrintDebug(info->vm_info, info, "CPUID called for 0x%x\n", cpuid); if (hook == NULL) { - //PrintDebug("Calling passthrough handler\n"); + //PrintDebug(info->vm_info, info, "Calling passthrough handler\n"); // call the passthrough handler v3_cpuid(cpuid, (uint32_t *)&(info->vm_regs.rax), @@ -327,7 +327,7 @@ int v3_handle_cpuid(struct guest_info * info) { (uint32_t *)&(info->vm_regs.rcx), (uint32_t *)&(info->vm_regs.rdx)); } else { - // PrintDebug("Calling hook function\n"); + // PrintDebug(info->vm_info, info, "Calling hook function\n"); if (hook->hook_fn(info, cpuid, (uint32_t *)&(info->vm_regs.rax), @@ -335,12 +335,12 @@ int v3_handle_cpuid(struct guest_info * info) { (uint32_t *)&(info->vm_regs.rcx), (uint32_t *)&(info->vm_regs.rdx), hook->private_data) == -1) { - PrintError("Error in cpuid handler for 0x%x\n", cpuid); + PrintError(info->vm_info, info, "Error in cpuid handler for 0x%x\n", cpuid); return -1; } } - // PrintDebug("Cleaning up register contents\n"); + // PrintDebug(info->vm_info, info, "Cleaning up register contents\n"); info->vm_regs.rax &= 0x00000000ffffffffLL; info->vm_regs.rbx &= 0x00000000ffffffffLL; diff --git a/palacios/src/palacios/vmm_ctrl_regs.c b/palacios/src/palacios/vmm_ctrl_regs.c index acf95a7..f09bfb9 100644 --- a/palacios/src/palacios/vmm_ctrl_regs.c +++ b/palacios/src/palacios/vmm_ctrl_regs.c @@ -51,7 +51,7 @@ int v3_handle_cr0_write(struct guest_info * info) { } if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) { - PrintError("Could not decode instruction\n"); + PrintError(info->vm_info, info, "Could not decode instruction\n"); return -1; } @@ -69,7 +69,7 @@ int v3_handle_cr0_write(struct guest_info * info) { return -1; } } else { - PrintError("Unhandled opcode in handle_cr0_write\n"); + PrintError(info->vm_info, info, "Unhandled opcode in handle_cr0_write\n"); return -1; } @@ -91,12 +91,12 @@ static int handle_mov_to_cr0(struct guest_info * info, struct x86_instr * dec_in struct cr0_32 * guest_cr0 = (struct cr0_32 *)&(info->shdw_pg_state.guest_cr0); uint_t paging_transition = 0; - PrintDebug("MOV2CR0 (MODE=%s)\n", v3_cpu_mode_to_str(info->cpu_mode)); + PrintDebug(info->vm_info, info, "MOV2CR0 (MODE=%s)\n", v3_cpu_mode_to_str(info->cpu_mode)); - PrintDebug("OperandVal = %x, length=%d\n", *(uint_t *)new_cr0, dec_instr->src_operand.size); + PrintDebug(info->vm_info, info, "OperandVal = %x, length=%d\n", *(uint_t *)new_cr0, dec_instr->src_operand.size); - PrintDebug("Old CR0=%x\n", *(uint_t *)shadow_cr0); - PrintDebug("Old Guest CR0=%x\n", *(uint_t *)guest_cr0); + PrintDebug(info->vm_info, info, "Old CR0=%x\n", *(uint_t *)shadow_cr0); + PrintDebug(info->vm_info, info, "Old Guest CR0=%x\n", *(uint_t *)guest_cr0); // We detect if this is a paging transition @@ -131,19 +131,19 @@ static int handle_mov_to_cr0(struct guest_info * info, struct x86_instr * dec_in // Check long mode LME to set LME if (guest_efer->lme == 1) { - PrintDebug("Enabing Long Mode\n"); + PrintDebug(info->vm_info, info, "Enabing Long Mode\n"); guest_efer->lma = 1; shadow_efer->lma = 1; shadow_efer->lme = 1; - PrintDebug("New EFER %p\n", (void *)*(addr_t *)(shadow_efer)); + PrintDebug(info->vm_info, info, "New EFER %p\n", (void *)*(addr_t *)(shadow_efer)); } - PrintDebug("Activating Shadow Page Tables\n"); + PrintDebug(info->vm_info, info, "Activating Shadow Page Tables\n"); if (v3_activate_shadow_pt(info) == -1) { - PrintError("Failed to activate shadow page tables\n"); + PrintError(info->vm_info, info, "Failed to activate shadow page tables\n"); return -1; } } else { @@ -151,15 +151,15 @@ static int handle_mov_to_cr0(struct guest_info * info, struct x86_instr * dec_in shadow_cr0->wp = 1; if (v3_activate_passthrough_pt(info) == -1) { - PrintError("Failed to activate passthrough page tables\n"); + PrintError(info->vm_info, info, "Failed to activate passthrough page tables\n"); return -1; } } } - PrintDebug("New Guest CR0=%x\n",*(uint_t *)guest_cr0); - PrintDebug("New CR0=%x\n", *(uint_t *)shadow_cr0); + PrintDebug(info->vm_info, info, "New Guest CR0=%x\n",*(uint_t *)guest_cr0); + PrintDebug(info->vm_info, info, "New CR0=%x\n", *(uint_t *)shadow_cr0); return 0; } @@ -187,28 +187,28 @@ static int handle_lmsw(struct guest_info * info, struct x86_instr * dec_instr) { struct cr0_real * new_cr0 = (struct cr0_real *)(dec_instr->dst_operand.operand); uchar_t new_cr0_val; - PrintDebug("LMSW\n"); + PrintDebug(info->vm_info, info, "LMSW\n"); new_cr0_val = (*(char*)(new_cr0)) & 0x0f; - PrintDebug("OperandVal = %x\n", new_cr0_val); + PrintDebug(info->vm_info, info, "OperandVal = %x\n", new_cr0_val); // We can just copy the new value through // we don't need to virtualize the lower 4 bits - PrintDebug("Old CR0=%x\n", *(uint_t *)real_cr0); + PrintDebug(info->vm_info, info, "Old CR0=%x\n", *(uint_t *)real_cr0); *(uchar_t*)real_cr0 &= 0xf0; *(uchar_t*)real_cr0 |= new_cr0_val; - PrintDebug("New CR0=%x\n", *(uint_t *)real_cr0); + PrintDebug(info->vm_info, info, "New CR0=%x\n", *(uint_t *)real_cr0); // If Shadow paging is enabled we push the changes to the virtualized copy of cr0 if (info->shdw_pg_mode == SHADOW_PAGING) { struct cr0_real * guest_cr0 = (struct cr0_real*)&(info->shdw_pg_state.guest_cr0); - PrintDebug("Old Guest CR0=%x\n", *(uint_t *)guest_cr0); + PrintDebug(info->vm_info, info, "Old Guest CR0=%x\n", *(uint_t *)guest_cr0); *(uchar_t*)guest_cr0 &= 0xf0; *(uchar_t*)guest_cr0 |= new_cr0_val; - PrintDebug("New Guest CR0=%x\n", *(uint_t *)guest_cr0); + PrintDebug(info->vm_info, info, "New Guest CR0=%x\n", *(uint_t *)guest_cr0); } return 0; } @@ -232,12 +232,12 @@ int v3_handle_cr0_read(struct guest_info * info) { if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) { - PrintError("Could not decode instruction\n"); + PrintError(info->vm_info, info, "Could not decode instruction\n"); return -1; } if (dec_instr.op_type == V3_OP_MOVCR2) { - PrintDebug("MOVCR2 (mode=%s)\n", v3_cpu_mode_to_str(info->cpu_mode)); + PrintDebug(info->vm_info, info, "MOVCR2 (mode=%s)\n", v3_cpu_mode_to_str(info->cpu_mode)); if ((v3_get_vm_cpu_mode(info) == LONG) || (v3_get_vm_cpu_mode(info) == LONG_32_COMPAT)) { @@ -251,7 +251,7 @@ int v3_handle_cr0_read(struct guest_info * info) { *dst_reg = *shadow_cr0; } - PrintDebug("returned CR0: %p\n", (void *)*(addr_t *)dst_reg); + PrintDebug(info->vm_info, info, "returned CR0: %p\n", (void *)*(addr_t *)dst_reg); } else { struct cr0_32 * dst_reg = (struct cr0_32 *)(dec_instr.dst_operand.operand); @@ -263,7 +263,7 @@ int v3_handle_cr0_read(struct guest_info * info) { *dst_reg = *shadow_cr0; } - PrintDebug("returned CR0: %x\n", *(uint_t*)dst_reg); + PrintDebug(info->vm_info, info, "returned CR0: %x\n", *(uint_t*)dst_reg); } } else if (dec_instr.op_type == V3_OP_SMSW) { @@ -271,7 +271,7 @@ int v3_handle_cr0_read(struct guest_info * info) { struct cr0_real * dst_reg = (struct cr0_real *)(dec_instr.dst_operand.operand); char cr0_val = *(char*)shadow_cr0 & 0x0f; - PrintDebug("SMSW\n"); + PrintDebug(info->vm_info, info, "SMSW\n"); // The lower 4 bits of the guest/shadow CR0 are mapped through // We can treat nested and shadow paging the same here @@ -279,7 +279,7 @@ int v3_handle_cr0_read(struct guest_info * info) { *(char *)dst_reg |= cr0_val; } else { - PrintError("Unhandled opcode in handle_cr0_read\n"); + PrintError(info->vm_info, info, "Unhandled opcode in handle_cr0_read\n"); return -1; } @@ -305,15 +305,15 @@ int v3_handle_cr3_write(struct guest_info * info) { } if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) { - PrintError("Could not decode instruction\n"); + PrintError(info->vm_info, info, "Could not decode instruction\n"); return -1; } if (dec_instr.op_type == V3_OP_MOV2CR) { - PrintDebug("MOV2CR3 (cpu_mode=%s)\n", v3_cpu_mode_to_str(info->cpu_mode)); + PrintDebug(info->vm_info, info, "MOV2CR3 (cpu_mode=%s)\n", v3_cpu_mode_to_str(info->cpu_mode)); if (info->shdw_pg_mode == SHADOW_PAGING) { - PrintDebug("Old Shadow CR3=%p; Old Guest CR3=%p\n", + PrintDebug(info->vm_info, info, "Old Shadow CR3=%p; Old Guest CR3=%p\n", (void *)(addr_t)(info->ctrl_regs.cr3), (void*)(addr_t)(info->shdw_pg_state.guest_cr3)); @@ -333,12 +333,12 @@ int v3_handle_cr3_write(struct guest_info * info) { // If Paging is enabled in the guest then we need to change the shadow page tables if (info->mem_mode == VIRTUAL_MEM) { if (v3_activate_shadow_pt(info) == -1) { - PrintError("Failed to activate 32 bit shadow page table\n"); + PrintError(info->vm_info, info, "Failed to activate 32 bit shadow page table\n"); return -1; } } - PrintDebug("New Shadow CR3=%p; New Guest CR3=%p\n", + PrintDebug(info->vm_info, info, "New Shadow CR3=%p; New Guest CR3=%p\n", (void *)(addr_t)(info->ctrl_regs.cr3), (void*)(addr_t)(info->shdw_pg_state.guest_cr3)); @@ -357,7 +357,7 @@ int v3_handle_cr3_write(struct guest_info * info) { } } else { - PrintError("Unhandled opcode in handle_cr3_write\n"); + PrintError(info->vm_info, info, "Unhandled opcode in handle_cr3_write\n"); return -1; } @@ -382,12 +382,12 @@ int v3_handle_cr3_read(struct guest_info * info) { } if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) { - PrintError("Could not decode instruction\n"); + PrintError(info->vm_info, info, "Could not decode instruction\n"); return -1; } if (dec_instr.op_type == V3_OP_MOVCR2) { - PrintDebug("MOVCR32 (mode=%s)\n", v3_cpu_mode_to_str(info->cpu_mode)); + PrintDebug(info->vm_info, info, "MOVCR32 (mode=%s)\n", v3_cpu_mode_to_str(info->cpu_mode)); if (info->shdw_pg_mode == SHADOW_PAGING) { @@ -418,7 +418,7 @@ int v3_handle_cr3_read(struct guest_info * info) { } } else { - PrintError("Unhandled opcode in handle_cr3_read\n"); + PrintError(info->vm_info, info, "Unhandled opcode in handle_cr3_read\n"); return -1; } @@ -430,7 +430,7 @@ int v3_handle_cr3_read(struct guest_info * info) { // We don't need to virtualize CR4, all we need is to detect the activation of PAE int v3_handle_cr4_read(struct guest_info * info) { - PrintError("CR4 Read not handled\n"); + PrintError(info->vm_info, info, "CR4 Read not handled\n"); // Do nothing... return 0; } @@ -449,12 +449,12 @@ int v3_handle_cr4_write(struct guest_info * info) { } if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) { - PrintError("Could not decode instruction\n"); + PrintError(info->vm_info, info, "Could not decode instruction\n"); return -1; } if (dec_instr.op_type != V3_OP_MOV2CR) { - PrintError("Invalid opcode in write to CR4\n"); + PrintError(info->vm_info, info, "Invalid opcode in write to CR4\n"); return -1; } @@ -474,7 +474,7 @@ int v3_handle_cr4_write(struct guest_info * info) { if ((cr4->pse != new_cr4->pse) || (cr4->pge != new_cr4->pge) || (cr4->pae != new_cr4->pae)) { - PrintDebug("Handling PSE/PGE/PAE -> TLBFlush case, flag set\n"); + PrintDebug(info->vm_info, info, "Handling PSE/PGE/PAE -> TLBFlush case, flag set\n"); flush_tlb = 1; } @@ -485,18 +485,18 @@ int v3_handle_cr4_write(struct guest_info * info) { struct cr4_32 * new_cr4 = (struct cr4_32 *)(dec_instr.src_operand.operand); struct cr4_32 * cr4 = (struct cr4_32 *)&(info->ctrl_regs.cr4); - PrintDebug("OperandVal = %x, length = %d\n", *(uint_t *)new_cr4, dec_instr.src_operand.size); - PrintDebug("Old CR4=%x\n", *(uint_t *)cr4); + PrintDebug(info->vm_info, info, "OperandVal = %x, length = %d\n", *(uint_t *)new_cr4, dec_instr.src_operand.size); + PrintDebug(info->vm_info, info, "Old CR4=%x\n", *(uint_t *)cr4); if ((info->shdw_pg_mode == SHADOW_PAGING)) { if (v3_get_vm_mem_mode(info) == PHYSICAL_MEM) { if ((cr4->pae == 0) && (new_cr4->pae == 1)) { - PrintDebug("Creating PAE passthrough tables\n"); + PrintDebug(info->vm_info, info, "Creating PAE passthrough tables\n"); // create 32 bit PAE direct map page table if (v3_reset_passthrough_pts(info) == -1) { - PrintError("Could not create 32 bit PAE passthrough pages tables\n"); + PrintError(info->vm_info, info, "Could not create 32 bit PAE passthrough pages tables\n"); return -1; } @@ -505,40 +505,40 @@ int v3_handle_cr4_write(struct guest_info * info) { } else if ((cr4->pae == 1) && (new_cr4->pae == 0)) { // Create passthrough standard 32bit pagetables - PrintError("Switching From PAE to Protected mode not supported\n"); + PrintError(info->vm_info, info, "Switching From PAE to Protected mode not supported\n"); return -1; } } } *cr4 = *new_cr4; - PrintDebug("New CR4=%x\n", *(uint_t *)cr4); + PrintDebug(info->vm_info, info, "New CR4=%x\n", *(uint_t *)cr4); } else if ((cpu_mode == LONG) || (cpu_mode == LONG_32_COMPAT)) { struct cr4_64 * new_cr4 = (struct cr4_64 *)(dec_instr.src_operand.operand); struct cr4_64 * cr4 = (struct cr4_64 *)&(info->ctrl_regs.cr4); - PrintDebug("Old CR4=%p\n", (void *)*(addr_t *)cr4); - PrintDebug("New CR4=%p\n", (void *)*(addr_t *)new_cr4); + PrintDebug(info->vm_info, info, "Old CR4=%p\n", (void *)*(addr_t *)cr4); + PrintDebug(info->vm_info, info, "New CR4=%p\n", (void *)*(addr_t *)new_cr4); if (new_cr4->pae == 0) { // cannot turn off PAE in long mode GPF the guest - PrintError("Cannot disable PAE in long mode, should send GPF\n"); + PrintError(info->vm_info, info, "Cannot disable PAE in long mode, should send GPF\n"); return -1; } *cr4 = *new_cr4; } else { - PrintError("CR4 write not supported in CPU_MODE: %s\n", v3_cpu_mode_to_str(cpu_mode)); + PrintError(info->vm_info, info, "CR4 write not supported in CPU_MODE: %s\n", v3_cpu_mode_to_str(cpu_mode)); return -1; } if (info->shdw_pg_mode == SHADOW_PAGING) { if (flush_tlb) { - PrintDebug("Handling PSE/PGE/PAE -> TLBFlush (doing flush now!)\n"); + PrintDebug(info->vm_info, info, "Handling PSE/PGE/PAE -> TLBFlush (doing flush now!)\n"); if (v3_activate_shadow_pt(info) == -1) { - PrintError("Failed to activate shadow page tables when emulating TLB flush in handling cr4 write\n"); + PrintError(info->vm_info, info, "Failed to activate shadow page tables when emulating TLB flush in handling cr4 write\n"); return -1; } } @@ -590,12 +590,12 @@ int v3_handle_cr8_write(struct guest_info * info) { } if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) { - PrintError("Could not decode instruction\n"); + PrintError(info->vm_info, info, "Could not decode instruction\n"); return -1; } if (dec_instr.op_type == V3_OP_MOV2CR) { - PrintDebug("MOV2CR8 (cpu_mode=%s)\n", v3_cpu_mode_to_str(info->cpu_mode)); + PrintDebug(info->vm_info, info, "MOV2CR8 (cpu_mode=%s)\n", v3_cpu_mode_to_str(info->cpu_mode)); if ((info->cpu_mode == LONG) || (info->cpu_mode == LONG_32_COMPAT)) { @@ -603,13 +603,13 @@ int v3_handle_cr8_write(struct guest_info * info) { info->ctrl_regs.apic_tpr = (*val & 0xf) << 4; - V3_Print("Write of CR8 sets apic_tpr to 0x%llx\n",info->ctrl_regs.apic_tpr); + V3_Print(info->vm_info, info, "Write of CR8 sets apic_tpr to 0x%llx\n",info->ctrl_regs.apic_tpr); } else { // probably should raise exception here } } else { - PrintError("Unhandled opcode in handle_cr8_write\n"); + PrintError(info->vm_info, info, "Unhandled opcode in handle_cr8_write\n"); return -1; } @@ -632,12 +632,12 @@ int v3_handle_cr8_read(struct guest_info * info) { } if (v3_decode(info, (addr_t)instr, &dec_instr) == -1) { - PrintError("Could not decode instruction\n"); + PrintError(info->vm_info, info, "Could not decode instruction\n"); return -1; } if (dec_instr.op_type == V3_OP_MOVCR2) { - PrintDebug("MOVCR82 (mode=%s)\n", v3_cpu_mode_to_str(info->cpu_mode)); + PrintDebug(info->vm_info, info, "MOVCR82 (mode=%s)\n", v3_cpu_mode_to_str(info->cpu_mode)); if ((info->cpu_mode == LONG) || (info->cpu_mode == LONG_32_COMPAT)) { @@ -645,14 +645,14 @@ int v3_handle_cr8_read(struct guest_info * info) { *dst_reg = (info->ctrl_regs.apic_tpr >> 4) & 0xf; - V3_Print("Read of CR8 (apic_tpr) returns 0x%llx\n",*dst_reg); + V3_Print(info->vm_info, info, "Read of CR8 (apic_tpr) returns 0x%llx\n",*dst_reg); } else { // probably should raise exception } } else { - PrintError("Unhandled opcode in handle_cr8_read\n"); + PrintError(info->vm_info, info, "Unhandled opcode in handle_cr8_read\n"); return -1; } @@ -663,7 +663,7 @@ int v3_handle_cr8_read(struct guest_info * info) { int v3_handle_efer_read(struct guest_info * core, uint_t msr, struct v3_msr * dst, void * priv_data) { - PrintDebug("EFER Read HI=%x LO=%x\n", core->shdw_pg_state.guest_efer.hi, core->shdw_pg_state.guest_efer.lo); + PrintDebug(core->vm_info, core, "EFER Read HI=%x LO=%x\n", core->shdw_pg_state.guest_efer.hi, core->shdw_pg_state.guest_efer.lo); dst->value = core->shdw_pg_state.guest_efer.value; @@ -676,7 +676,7 @@ int v3_handle_efer_write(struct guest_info * core, uint_t msr, struct v3_msr src struct efer_64 * hw_efer = (struct efer_64 *)&(core->ctrl_regs.efer); struct efer_64 old_hw_efer = *((struct efer_64 *)&core->ctrl_regs.efer); - PrintDebug("EFER Write HI=%x LO=%x\n", src.hi, src.lo); + PrintDebug(core->vm_info, core, "EFER Write HI=%x LO=%x\n", src.hi, src.lo); // Set EFER value seen by guest if it reads EFER vm_efer->value = src.value; @@ -691,7 +691,7 @@ int v3_handle_efer_write(struct guest_info * core, uint_t msr, struct v3_msr src if (core->shdw_pg_mode == SHADOW_PAGING) { // Catch unsupported features if ((old_hw_efer.lme == 1) && (hw_efer->lme == 0)) { - PrintError("Disabling long mode once it has been enabled is not supported\n"); + PrintError(core->vm_info, core, "Disabling long mode once it has been enabled is not supported\n"); return -1; } @@ -709,8 +709,8 @@ int v3_handle_efer_write(struct guest_info * core, uint_t msr, struct v3_msr src } - PrintDebug("RIP=%p\n", (void *)core->rip); - PrintDebug("New EFER value HW(hi=%p), VM(hi=%p)\n", (void *)*(uint64_t *)hw_efer, (void *)vm_efer->value); + PrintDebug(core->vm_info, core, "RIP=%p\n", (void *)core->rip); + PrintDebug(core->vm_info, core, "New EFER value HW(hi=%p), VM(hi=%p)\n", (void *)*(uint64_t *)hw_efer, (void *)vm_efer->value); return 0; @@ -722,20 +722,20 @@ int v3_handle_vm_cr_read(struct guest_info * core, uint_t msr, struct v3_msr * d * cannot be used */ dst->value = SVM_VM_CR_MSR_lock | SVM_VM_CR_MSR_svmdis; - PrintDebug("VM_CR Read HI=%x LO=%x\n", dst->hi, dst->lo); + PrintDebug(core->vm_info, core, "VM_CR Read HI=%x LO=%x\n", dst->hi, dst->lo); return 0; } int v3_handle_vm_cr_write(struct guest_info * core, uint_t msr, struct v3_msr src, void * priv_data) { - PrintDebug("VM_CR Write\n"); - PrintDebug("VM_CR Write Values: HI=%x LO=%x\n", src.hi, src.lo); + PrintDebug(core->vm_info, core, "VM_CR Write\n"); + PrintDebug(core->vm_info, core, "VM_CR Write Values: HI=%x LO=%x\n", src.hi, src.lo); /* writes to LOCK and SVMDIS are silently ignored (according to the spec), * other writes indicate the guest wants to use some feature we haven't * implemented */ if (src.value & ~(SVM_VM_CR_MSR_lock | SVM_VM_CR_MSR_svmdis)) { - PrintDebug("VM_CR write sets unsupported bits: HI=%x LO=%x\n", src.hi, src.lo); + PrintDebug(core->vm_info, core, "VM_CR write sets unsupported bits: HI=%x LO=%x\n", src.hi, src.lo); return -1; } diff --git a/palacios/src/palacios/vmm_debug.c b/palacios/src/palacios/vmm_debug.c index 2a5bd94..6ae8192 100644 --- a/palacios/src/palacios/vmm_debug.c +++ b/palacios/src/palacios/vmm_debug.c @@ -98,7 +98,7 @@ static int core_handler(struct guest_info * core, uint32_t cmd) { static int evt_handler(struct v3_vm_info * vm, struct v3_debug_event * evt, void * priv_data) { - V3_Print("Debug Event Handler for core %d\n", evt->core_id); + V3_Print(vm, VCORE_NONE,"Debug Event Handler for core %d\n", evt->core_id); if (evt->core_id == -1) { int i = 0; @@ -134,11 +134,11 @@ void v3_print_segments(struct v3_segments * segs) { seg_ptr=(struct v3_segment *)segs; char *seg_names[] = {"CS", "DS" , "ES", "FS", "GS", "SS" , "LDTR", "GDTR", "IDTR", "TR", NULL}; - V3_Print("Segments\n"); + V3_Print(VM_NONE, VCORE_NONE, "Segments\n"); for (i = 0; seg_names[i] != NULL; i++) { - V3_Print("\t%s: Sel=%x, base=%p, limit=%x (long_mode=%d, db=%d)\n", seg_names[i], seg_ptr[i].selector, + V3_Print(VM_NONE, VCORE_NONE, "\t%s: Sel=%x, base=%p, limit=%x (long_mode=%d, db=%d)\n", seg_names[i], seg_ptr[i].selector, (void *)(addr_t)seg_ptr[i].base, seg_ptr[i].limit, seg_ptr[i].long_mode, seg_ptr[i].db); @@ -156,10 +156,10 @@ void v3_print_ctrl_regs(struct guest_info * core) { reg_ptr = (v3_reg_t *)regs; - V3_Print("Ctrl Regs:\n"); + V3_Print(core->vm_info, core,"Ctrl Regs:\n"); for (i = 0; reg_names[i] != NULL; i++) { - V3_Print("\t%s=0x%p (at %p)\n", reg_names[i], (void *)(addr_t)reg_ptr[i], &(reg_ptr[i])); + V3_Print(core->vm_info, core, "\t%s=0x%p (at %p)\n", reg_names[i], (void *)(addr_t)reg_ptr[i], &(reg_ptr[i])); } @@ -188,12 +188,12 @@ static int v3_print_disassembly(struct guest_info * core) { /* start disassembly 64 bytes before current RIP, continue 32 bytes after */ rip = (addr_t) core->rip - 64; while ((int) (rip - core->rip) < 32) { - V3_Print("disassembly step\n"); + V3_Print(info->vm_info, info, "disassembly step\n"); /* always print RIP, even if the instructions before were bad */ if (!passed_rip && rip >= core->rip) { if (rip != core->rip) { - V3_Print("***** bad disassembly up to this point *****\n"); + V3_Print(info->vm_info, info, "***** bad disassembly up to this point *****\n"); rip = core->rip; } passed_rip = 1; @@ -222,16 +222,16 @@ static int v3_print_disassembly(struct guest_info * core) { void v3_print_guest_state(struct guest_info * core) { addr_t linear_addr = 0; - V3_Print("RIP: %p\n", (void *)(addr_t)(core->rip)); + V3_Print(core->vm_info, core, "RIP: %p\n", (void *)(addr_t)(core->rip)); linear_addr = get_addr_linear(core, core->rip, &(core->segments.cs)); - V3_Print("RIP Linear: %p\n", (void *)linear_addr); + V3_Print(core->vm_info, core, "RIP Linear: %p\n", (void *)linear_addr); - V3_Print("NumExits: %u\n", (uint32_t)core->num_exits); + V3_Print(core->vm_info, core, "NumExits: %u\n", (uint32_t)core->num_exits); - V3_Print("IRQ STATE: started=%d, pending=%d\n", + V3_Print(core->vm_info, core, "IRQ STATE: started=%d, pending=%d\n", core->intr_core_state.irq_started, core->intr_core_state.irq_pending); - V3_Print("EXCP STATE: err_code_valid=%d, err_code=%x\n", + V3_Print(core->vm_info, core, "EXCP STATE: err_code_valid=%d, err_code=%x\n", core->excp_state.excp_error_code_valid, core->excp_state.excp_error_code); @@ -240,10 +240,10 @@ void v3_print_guest_state(struct guest_info * core) { v3_print_ctrl_regs(core); if (core->shdw_pg_mode == SHADOW_PAGING) { - V3_Print("Shadow Paging Guest Registers:\n"); - V3_Print("\tGuest CR0=%p\n", (void *)(addr_t)(core->shdw_pg_state.guest_cr0)); - V3_Print("\tGuest CR3=%p\n", (void *)(addr_t)(core->shdw_pg_state.guest_cr3)); - V3_Print("\tGuest EFER=%p\n", (void *)(addr_t)(core->shdw_pg_state.guest_efer.value)); + V3_Print(core->vm_info, core, "Shadow Paging Guest Registers:\n"); + V3_Print(core->vm_info, core, "\tGuest CR0=%p\n", (void *)(addr_t)(core->shdw_pg_state.guest_cr0)); + V3_Print(core->vm_info, core, "\tGuest CR3=%p\n", (void *)(addr_t)(core->shdw_pg_state.guest_cr3)); + V3_Print(core->vm_info, core, "\tGuest EFER=%p\n", (void *)(addr_t)(core->shdw_pg_state.guest_efer.value)); // CR4 } v3_print_GPRs(core); @@ -265,10 +265,10 @@ void v3_print_arch_state(struct guest_info * core) { void v3_print_guest_state_all(struct v3_vm_info * vm) { int i = 0; - V3_Print("VM Core states for %s\n", vm->name); + V3_Print(vm, VCORE_NONE,"VM Core states for %s\n", vm->name); for (i = 0; i < 80; i++) { - V3_Print("-"); + V3_Print(vm, VCORE_NONE, "-"); } for (i = 0; i < vm->num_cores; i++) { @@ -276,10 +276,10 @@ void v3_print_guest_state_all(struct v3_vm_info * vm) { } for (i = 0; i < 80; i++) { - V3_Print("-"); + V3_Print(vm, VCORE_NONE, "-"); } - V3_Print("\n"); + V3_Print(vm, VCORE_NONE, "\n"); } @@ -292,32 +292,32 @@ void v3_print_stack(struct guest_info * core) { linear_addr = get_addr_linear(core, core->vm_regs.rsp, &(core->segments.ss)); - V3_Print("Stack at %p:\n", (void *)linear_addr); + V3_Print(core->vm_info, core, "Stack at %p:\n", (void *)linear_addr); if (core->mem_mode == PHYSICAL_MEM) { if (v3_gpa_to_hva(core, linear_addr, &host_addr) == -1) { - PrintError("Could not translate Stack address\n"); + PrintError(core->vm_info, core, "Could not translate Stack address\n"); return; } } else if (core->mem_mode == VIRTUAL_MEM) { if (v3_gva_to_hva(core, linear_addr, &host_addr) == -1) { - PrintError("Could not translate Virtual Stack address\n"); + PrintError(core->vm_info, core, "Could not translate Virtual Stack address\n"); return; } } - V3_Print("Host Address of rsp = 0x%p\n", (void *)host_addr); + V3_Print(core->vm_info, core, "Host Address of rsp = 0x%p\n", (void *)host_addr); // We start i at one because the current stack pointer points to an unused stack element for (i = 0; i <= 24; i++) { if (cpu_mode == REAL) { - V3_Print("\t0x%.4x\n", *((uint16_t *)host_addr + (i * 2))); + V3_Print(core->vm_info, core, "\t0x%.4x\n", *((uint16_t *)host_addr + (i * 2))); } else if (cpu_mode == LONG) { - V3_Print("\t%p\n", (void *)*(addr_t *)(host_addr + (i * 8))); + V3_Print(core->vm_info, core, "\t%p\n", (void *)*(addr_t *)(host_addr + (i * 8))); } else { // 32 bit stacks... - V3_Print("\t0x%.8x\n", *(uint32_t *)(host_addr + (i * 4))); + V3_Print(core->vm_info, core, "\t0x%.8x\n", *(uint32_t *)(host_addr + (i * 4))); } } @@ -330,8 +330,8 @@ void v3_print_backtrace(struct guest_info * core) { v3_cpu_mode_t cpu_mode = v3_get_vm_cpu_mode(core); struct v3_cfg_file * system_map = v3_cfg_get_file(core->vm_info, "System.map"); - V3_Print("Performing Backtrace for Core %d\n", core->vcpu_id); - V3_Print("\tRSP=%p, RBP=%p\n", (void *)core->vm_regs.rsp, (void *)core->vm_regs.rbp); + V3_Print(core->vm_info, core, "Performing Backtrace for Core %d\n", core->vcpu_id); + V3_Print(core->vm_info, core, "\tRSP=%p, RBP=%p\n", (void *)core->vm_regs.rsp, (void *)core->vm_regs.rbp); gla_rbp = get_addr_linear(core, core->vm_regs.rbp, &(core->segments.ss)); @@ -344,12 +344,12 @@ void v3_print_backtrace(struct guest_info * core) { if (core->mem_mode == PHYSICAL_MEM) { if (v3_gpa_to_hva(core, gla_rbp, &hva_rbp) == -1) { - PrintError("Could not translate Stack address\n"); + PrintError(core->vm_info, core, "Could not translate Stack address\n"); return; } } else if (core->mem_mode == VIRTUAL_MEM) { if (v3_gva_to_hva(core, gla_rbp, &hva_rbp) == -1) { - PrintError("Could not translate Virtual Stack address\n"); + PrintError(core->vm_info, core, "Could not translate Virtual Stack address\n"); return; } } @@ -405,18 +405,18 @@ void v3_print_backtrace(struct guest_info * core) { } if (cpu_mode == REAL) { - V3_Print("Next RBP=0x%.4x, RIP=0x%.4x (%s)\n", + V3_Print(core->vm_info, core, "Next RBP=0x%.4x, RIP=0x%.4x (%s)\n", *(uint16_t *)hva_rbp,*(uint16_t *)hva_rip, sym_name); gla_rbp = *(uint16_t *)hva_rbp; } else if (cpu_mode == LONG) { - V3_Print("Next RBP=%p, RIP=%p (%s)\n", + V3_Print(core->vm_info, core, "Next RBP=%p, RIP=%p (%s)\n", (void *)*(uint64_t *)hva_rbp, (void *)*(uint64_t *)hva_rip, sym_name); gla_rbp = *(uint64_t *)hva_rbp; } else { - V3_Print("Next RBP=0x%.8x, RIP=0x%.8x (%s)\n", + V3_Print(core->vm_info, core, "Next RBP=0x%.8x, RIP=0x%.8x (%s)\n", *(uint32_t *)hva_rbp, *(uint32_t *)hva_rip, sym_name); gla_rbp = *(uint32_t *)hva_rbp; @@ -436,10 +436,10 @@ void v3_print_GPRs(struct guest_info * core) { reg_ptr = (v3_reg_t *)regs; - V3_Print("32 bit GPRs:\n"); + V3_Print(info->vm_info, info, "32 bit GPRs:\n"); for (i = 0; reg_names[i] != NULL; i++) { - V3_Print("\t%s=0x%p (at %p)\n", reg_names[i], (void *)(addr_t)reg_ptr[i], &(reg_ptr[i])); + V3_Print(info->vm_info, info, "\t%s=0x%p (at %p)\n", reg_names[i], (void *)(addr_t)reg_ptr[i], &(reg_ptr[i])); } } @@ -454,10 +454,10 @@ void v3_print_GPRs(struct guest_info * core) { reg_ptr = (v3_reg_t *)regs; - V3_Print("64 bit GPRs:\n"); + V3_Print(core->vm_info, core, "64 bit GPRs:\n"); for (i = 0; reg_names[i] != NULL; i++) { - V3_Print("\t%s=0x%p (at %p)\n", reg_names[i], (void *)(addr_t)reg_ptr[i], &(reg_ptr[i])); + V3_Print(core->vm_info, core, "\t%s=0x%p (at %p)\n", reg_names[i], (void *)(addr_t)reg_ptr[i], &(reg_ptr[i])); } } diff --git a/palacios/src/palacios/vmm_decoder.c b/palacios/src/palacios/vmm_decoder.c index 874e8cf..c6f6eb8 100644 --- a/palacios/src/palacios/vmm_decoder.c +++ b/palacios/src/palacios/vmm_decoder.c @@ -191,40 +191,40 @@ static const ullong_t mask_8 = 0xffffffffffffffffLL; }) void v3_print_instr(struct x86_instr * instr) { - V3_Print("Instr: %s (Len: %d)\n", op_type_to_str(instr->op_type), instr->instr_length); + V3_Print(VM_NONE, VCORE_NONE, "Instr: %s (Len: %d)\n", op_type_to_str(instr->op_type), instr->instr_length); - V3_Print("Prefixes= %x\n", instr->prefixes.val); + V3_Print(VM_NONE, VCORE_NONE, "Prefixes= %x\n", instr->prefixes.val); if (instr->is_str_op) { - V3_Print("String OP (len=%d)\n", (uint32_t)instr->str_op_length); + V3_Print(VM_NONE, VCORE_NONE, "String OP (len=%d)\n", (uint32_t)instr->str_op_length); } - V3_Print("Number of operands: %d\n", instr->num_operands); + V3_Print(VM_NONE, VCORE_NONE, "Number of operands: %d\n", instr->num_operands); if (instr->num_operands > 0) { - V3_Print("Src Operand (%s)\n", operand_type_to_str(instr->src_operand.type)); - V3_Print("\tLen=%d (Addr: %p)\n", instr->src_operand.size, + V3_Print(VM_NONE, VCORE_NONE, "Src Operand (%s)\n", operand_type_to_str(instr->src_operand.type)); + V3_Print(VM_NONE, VCORE_NONE, "\tLen=%d (Addr: %p)\n", instr->src_operand.size, (void *)instr->src_operand.operand); if (instr->src_operand.type == REG_OPERAND) { - V3_Print("\tVal: 0x%llx\n", MASK(*(uint64_t *)(instr->src_operand.operand), instr->src_operand.size)); + V3_Print(VM_NONE, VCORE_NONE, "\tVal: 0x%llx\n", MASK(*(uint64_t *)(instr->src_operand.operand), instr->src_operand.size)); } } if (instr->num_operands > 1) { - V3_Print("Dst Operand (%s)\n", operand_type_to_str(instr->dst_operand.type)); - V3_Print("\tLen=%d (Addr: %p)\n", instr->dst_operand.size, + V3_Print(VM_NONE, VCORE_NONE, "Dst Operand (%s)\n", operand_type_to_str(instr->dst_operand.type)); + V3_Print(VM_NONE, VCORE_NONE, "\tLen=%d (Addr: %p)\n", instr->dst_operand.size, (void *)instr->dst_operand.operand); if (instr->dst_operand.type == REG_OPERAND) { - V3_Print("\tVal: 0x%llx\n", MASK(*(uint64_t *)(instr->dst_operand.operand), instr->dst_operand.size)); + V3_Print(VM_NONE, VCORE_NONE, "\tVal: 0x%llx\n", MASK(*(uint64_t *)(instr->dst_operand.operand), instr->dst_operand.size)); } } if (instr->num_operands > 2) { - V3_Print("Third Operand (%s)\n", operand_type_to_str(instr->third_operand.type)); - V3_Print("\tLen=%d (Addr: %p)\n", instr->third_operand.size, + V3_Print(VM_NONE, VCORE_NONE, "Third Operand (%s)\n", operand_type_to_str(instr->third_operand.type)); + V3_Print(VM_NONE, VCORE_NONE, "\tLen=%d (Addr: %p)\n", instr->third_operand.size, (void *)instr->third_operand.operand); if (instr->third_operand.type == REG_OPERAND) { - V3_Print("\tVal: 0x%llx\n", MASK(*(uint64_t *)(instr->third_operand.operand), instr->third_operand.size)); + V3_Print(VM_NONE, VCORE_NONE, "\tVal: 0x%llx\n", MASK(*(uint64_t *)(instr->third_operand.operand), instr->third_operand.size)); } } } diff --git a/palacios/src/palacios/vmm_dev_mgr.c b/palacios/src/palacios/vmm_dev_mgr.c index 183e906..3709ced 100644 --- a/palacios/src/palacios/vmm_dev_mgr.c +++ b/palacios/src/palacios/vmm_dev_mgr.c @@ -60,28 +60,28 @@ int V3_init_devices() { #ifdef V3_CONFIG_DEBUG_DEV_MGR { int num_devices = (__stop__v3_devices - __start__v3_devices) / sizeof(struct v3_device_info); - PrintDebug("%d Virtual devices registered with Palacios\n", num_devices); + PrintDebug(VM_NONE, VCORE_NONE, "%d Virtual devices registered with Palacios\n", num_devices); } #endif - PrintDebug("Start addres=%p, Stop address=%p\n", __start__v3_devices, __stop__v3_devices); + PrintDebug(VM_NONE, VCORE_NONE, "Start addres=%p, Stop address=%p\n", __start__v3_devices, __stop__v3_devices); master_dev_table = v3_create_htable(0, dev_hash_fn, dev_eq_fn); while (tmp_dev != __stop__v3_devices) { - V3_Print("Registering Device: %s\n", tmp_dev->name); + V3_Print(VM_NONE, VCORE_NONE, "Registering Device: %s\n", tmp_dev->name); if (v3_htable_search(master_dev_table, (addr_t)(tmp_dev->name))) { - PrintError("Multiple instance of device (%s)\n", tmp_dev->name); + PrintError(VM_NONE, VCORE_NONE, "Multiple instance of device (%s)\n", tmp_dev->name); return -1; } if (v3_htable_insert(master_dev_table, (addr_t)(tmp_dev->name), (addr_t)(tmp_dev->init)) == 0) { - PrintError("Could not add device %s to master list\n", tmp_dev->name); + PrintError(VM_NONE, VCORE_NONE, "Could not add device %s to master list\n", tmp_dev->name); return -1; } @@ -148,7 +148,7 @@ int v3_save_vm_devices(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { name_table = V3_Malloc(table_len); if (!name_table) { - PrintError("Unable to allocate space in device manager save\n"); + PrintError(vm, VCORE_NONE, "Unable to allocate space in device manager save\n"); return -1; } @@ -157,7 +157,7 @@ int v3_save_vm_devices(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { dev_mgr_ctx = v3_chkpt_open_ctx(chkpt, "devices"); if (!dev_mgr_ctx) { - PrintError("Unable to open device manager context\n"); + PrintError(vm, VCORE_NONE,"Unable to open device manager context\n"); V3_Free(name_table); return -1; } @@ -168,19 +168,19 @@ int v3_save_vm_devices(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { tbl_offset += V3_MAX_DEVICE_NAME; num_saved_devs++; } else { - PrintDebug("Skipping device %s\n"); + PrintDebug(vm, VCORE_NONE, "Skipping device %s\n", dev->name); } } if (v3_chkpt_save(dev_mgr_ctx, "num_devs", 4, &num_saved_devs) == -1) { - PrintError("Unable to store num_devs\n"); + PrintError(vm, VCORE_NONE,"Unable to store num_devs\n"); v3_chkpt_close_ctx(dev_mgr_ctx); V3_Free(name_table); return -1; } if (v3_chkpt_save(dev_mgr_ctx, "names", num_saved_devs*V3_MAX_DEVICE_NAME, name_table) == -1) { - PrintError("Unable to store names of devices\n"); + PrintError(vm, VCORE_NONE,"Unable to store names of devices\n"); v3_chkpt_close_ctx(dev_mgr_ctx); V3_Free(name_table); return -1; @@ -194,10 +194,10 @@ int v3_save_vm_devices(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { if (dev->ops->save_extended) { - V3_Print("Saving state for device (%s) using extended interface\n",dev->name); + V3_Print(vm, VCORE_NONE,"Saving state for device (%s) using extended interface\n",dev->name); if (dev->ops->save_extended(chkpt,dev->name,dev->private_data)) { - PrintError("Unable to save device %s\n",dev->name); + PrintError(vm, VCORE_NONE,"Unable to save device %s\n",dev->name); return -1; } @@ -205,17 +205,17 @@ int v3_save_vm_devices(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { struct v3_chkpt_ctx * dev_ctx = NULL; - V3_Print("Saving state for device (%s)\n", dev->name); + V3_Print(vm, VCORE_NONE,"Saving state for device (%s)\n", dev->name); dev_ctx = v3_chkpt_open_ctx(chkpt, dev->name); if (!dev_ctx) { - PrintError("Unable to open context for device %s\n",dev->name); + PrintError(vm, VCORE_NONE,"Unable to open context for device %s\n",dev->name); return -1; } if (dev->ops->save(dev_ctx, dev->private_data)) { - PrintError("Unable t save device %s\n",dev->name); + PrintError(vm, VCORE_NONE,"Unable t save device %s\n",dev->name); v3_chkpt_close_ctx(dev_ctx); return -1; } @@ -223,7 +223,7 @@ int v3_save_vm_devices(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { v3_chkpt_close_ctx(dev_ctx); } else { - PrintError("Error: %s save() not implemented\n", dev->name); + PrintError(vm, VCORE_NONE,"Error: %s save() not implemented\n", dev->name); } } @@ -241,28 +241,28 @@ int v3_load_vm_devices(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { dev_mgr_ctx = v3_chkpt_open_ctx(chkpt, "devices"); if (!dev_mgr_ctx) { - PrintError("Unable to open devices for load\n"); + PrintError(vm, VCORE_NONE,"Unable to open devices for load\n"); return -1; } if (v3_chkpt_load(dev_mgr_ctx, "num_devs", 4, &num_devs) == -1) { - PrintError("Unable to load num_devs\n"); + PrintError(vm, VCORE_NONE,"Unable to load num_devs\n"); v3_chkpt_close_ctx(dev_mgr_ctx); return -1; } - V3_Print("Loading State for %d devices\n", num_devs); + V3_Print(vm, VCORE_NONE,"Loading State for %d devices\n", num_devs); name_table = V3_Malloc(V3_MAX_DEVICE_NAME * num_devs); if (!name_table) { - PrintError("Unable to allocate space for device table\n"); + PrintError(vm, VCORE_NONE,"Unable to allocate space for device table\n"); v3_chkpt_close_ctx(dev_mgr_ctx); return -1; } if (v3_chkpt_load(dev_mgr_ctx, "names", V3_MAX_DEVICE_NAME * num_devs, name_table) == -1) { - PrintError("Unable to load device name table\n"); + PrintError(vm, VCORE_NONE,"Unable to load device name table\n"); v3_chkpt_close_ctx(dev_mgr_ctx); V3_Free(name_table); } @@ -275,16 +275,16 @@ int v3_load_vm_devices(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { dev = v3_find_dev(vm, name); if (!dev) { - PrintError("Tried to load state into non existant device: %s\n", name); + PrintError(vm, VCORE_NONE,"Tried to load state into non existant device: %s\n", name); return -1; } if (dev->ops->load_extended) { - V3_Print("Loading state for device (%s) using extended interface\n",name); + V3_Print(vm, VCORE_NONE,"Loading state for device (%s) using extended interface\n",name); if (dev->ops->load_extended(chkpt,name,dev->private_data)) { - PrintError("Load of device %s failed\n",name); + PrintError(vm, VCORE_NONE,"Load of device %s failed\n",name); return -1; } @@ -293,12 +293,12 @@ int v3_load_vm_devices(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { dev_ctx = v3_chkpt_open_ctx(chkpt, name); if (!dev_ctx) { - PrintError("Error missing device context (%s)\n", name); + PrintError(vm, VCORE_NONE,"Error missing device context (%s)\n", name); return -1; } if (dev->ops->load(dev_ctx, dev->private_data)) { - PrintError("Load of device %s failed\n",name); + PrintError(vm, VCORE_NONE,"Load of device %s failed\n",name); v3_chkpt_close_ctx(dev_ctx); return -1; } @@ -307,7 +307,7 @@ int v3_load_vm_devices(struct v3_vm_info * vm, struct v3_chkpt * chkpt) { v3_chkpt_close_ctx(dev_ctx); } else { - PrintError("Error Device (%s) does not support load operation\n", name); + PrintError(vm, VCORE_NONE,"Error Device (%s) does not support load operation\n", name); // this is OK } } @@ -342,13 +342,13 @@ int v3_create_device(struct v3_vm_info * vm, const char * dev_name, v3_cfg_tree_ dev_init = (void *)v3_htable_search(master_dev_table, (addr_t)dev_name); if (dev_init == NULL) { - PrintError("Could not find device %s in master device table\n", dev_name); + PrintError(vm, VCORE_NONE,"Could not find device %s in master device table\n", dev_name); return -1; } if (dev_init(vm, cfg) == -1) { - PrintError("Could not initialize Device %s\n", dev_name); + PrintError(vm, VCORE_NONE,"Could not initialize Device %s\n", dev_name); return -1; } @@ -390,7 +390,7 @@ static int add_resource(struct vm_device * dev, dev_rsrc_type_t type, uint64_t r resource = V3_Malloc(sizeof(struct dev_rsrc)); if (resource == NULL) { - PrintError("Error: Could not allocate device resource\n"); + PrintError(VM_NONE, VCORE_NONE,"Error: Could not allocate device resource\n"); return -1; } @@ -436,7 +436,7 @@ int v3_dev_hook_io(struct vm_device * dev, uint16_t port, if (add_resource(dev, DEV_IO_HOOK, port) == -1) { v3_unhook_io_port(dev->vm, port); - PrintError("Could not allocate io hook dev state\n"); + PrintError(dev->vm, VCORE_NONE,"Could not allocate io hook dev state\n"); return -1; } @@ -502,7 +502,7 @@ int v3_remove_device(struct vm_device * dev) { if (dev->ops->free) { dev->ops->free(dev->private_data); } else { - PrintError("Error: %s free() not implemented\n", dev->name); + PrintError(VM_NONE, VCORE_NONE,"Error: %s free() not implemented\n", dev->name); } list_del(&(dev->dev_link)); @@ -525,14 +525,14 @@ struct vm_device * v3_add_device(struct v3_vm_info * vm, // Check if we already registered a device of the same name if (v3_htable_search(mgr->dev_table, (addr_t)name) != (addr_t)NULL) { - PrintError("Device with name (%s) already registered with VM\n", name); + PrintError(vm, VCORE_NONE,"Device with name (%s) already registered with VM\n", name); return NULL; } dev = (struct vm_device *)V3_Malloc(sizeof(struct vm_device)); if (dev == NULL) { - PrintError("Cannot allocate in adding a device\n"); + PrintError(vm, VCORE_NONE,"Cannot allocate in adding a device\n"); return NULL; } @@ -557,10 +557,10 @@ void v3_print_dev_mgr(struct v3_vm_info * vm) { struct vmm_dev_mgr * mgr = &(vm->dev_mgr); struct vm_device * dev; - V3_Print("%d devices registered with manager\n", mgr->num_devs); + V3_Print(vm, VCORE_NONE,"%d devices registered with manager\n", mgr->num_devs); list_for_each_entry(dev, &(mgr->dev_list), dev_link) { - V3_Print("Device: %s\n", dev->name); + V3_Print(vm, VCORE_NONE,"Device: %s\n", dev->name); } return; @@ -598,7 +598,7 @@ int v3_dev_add_blk_frontend(struct v3_vm_info * vm, frontend = (struct blk_frontend *)V3_Malloc(sizeof(struct blk_frontend)); if (!frontend) { - PrintError("Cannot allocate in adding a block front end\n"); + PrintError(vm, VCORE_NONE,"Cannot allocate in adding a block front end\n"); return -1; } @@ -625,12 +625,12 @@ int v3_dev_connect_blk(struct v3_vm_info * vm, (addr_t)frontend_name); if (frontend == NULL) { - PrintError("Could not find frontend blk device %s\n", frontend_name); + PrintError(vm, VCORE_NONE,"Could not find frontend blk device %s\n", frontend_name); return 0; } if (frontend->connect(vm, frontend->priv_data, ops, cfg, private_data) == -1) { - PrintError("Error connecting to block frontend %s\n", frontend_name); + PrintError(vm, VCORE_NONE,"Error connecting to block frontend %s\n", frontend_name); return -1; } @@ -667,7 +667,7 @@ int v3_dev_add_net_frontend(struct v3_vm_info * vm, frontend = (struct net_frontend *)V3_Malloc(sizeof(struct net_frontend)); if (!frontend) { - PrintError("Cannot allocate in adding a net front end\n"); + PrintError(vm, VCORE_NONE,"Cannot allocate in adding a net front end\n"); return -1; } @@ -695,12 +695,12 @@ int v3_dev_connect_net(struct v3_vm_info * vm, (addr_t)frontend_name); if (frontend == NULL) { - PrintError("Could not find frontend net device %s\n", frontend_name); + PrintError(vm, VCORE_NONE,"Could not find frontend net device %s\n", frontend_name); return 0; } if (frontend->connect(vm, frontend->priv_data, ops, cfg, private_data) == -1) { - PrintError("Error connecting to net frontend %s\n", frontend_name); + PrintError(vm, VCORE_NONE,"Error connecting to net frontend %s\n", frontend_name); return -1; } @@ -735,7 +735,7 @@ int v3_dev_add_console_frontend(struct v3_vm_info * vm, frontend = (struct cons_frontend *)V3_Malloc(sizeof(struct cons_frontend)); if (!frontend) { - PrintError("Cannot allocate in adding a console front end\n"); + PrintError(vm, VCORE_NONE,"Cannot allocate in adding a console front end\n"); return -1; } @@ -763,12 +763,12 @@ int v3_dev_connect_console(struct v3_vm_info * vm, (addr_t)frontend_name); if (frontend == NULL) { - PrintError("Could not find frontend console device %s\n", frontend_name); + PrintError(vm, VCORE_NONE,"Could not find frontend console device %s\n", frontend_name); return 0; } if (frontend->connect(vm, frontend->priv_data, ops, cfg, private_data) == -1) { - PrintError("Error connecting to console frontend %s\n", frontend_name); + PrintError(vm, VCORE_NONE,"Error connecting to console frontend %s\n", frontend_name); return -1; } @@ -804,7 +804,7 @@ int v3_dev_add_char_frontend(struct v3_vm_info * vm, frontend = (struct char_frontend *)V3_Malloc(sizeof(struct char_frontend)); if (!frontend) { - PrintError("Cannot allocate in adding a char front end\n"); + PrintError(vm, VCORE_NONE,"Cannot allocate in adding a char front end\n"); return -1; } @@ -833,12 +833,12 @@ int v3_dev_connect_char(struct v3_vm_info * vm, (addr_t)frontend_name); if (frontend == NULL) { - PrintError("Could not find frontend char device %s\n", frontend_name); + PrintError(vm, VCORE_NONE,"Could not find frontend char device %s\n", frontend_name); return 0; } if (frontend->connect(vm, frontend->priv_data, ops, cfg, private_data, push_fn_arg) == -1) { - PrintError("Error connecting to char frontend %s\n", frontend_name); + PrintError(vm, VCORE_NONE,"Error connecting to char frontend %s\n", frontend_name); return -1; } @@ -887,3 +887,21 @@ static int free_frontends(struct v3_vm_info * vm, struct vmm_dev_mgr * mgr) { return 0; } + +int v3_attach_device(struct v3_vm_info * vm, struct vm_device * dev) +{ + PrintError(vm, VCORE_NONE, "v3_attach_device is deprecated and no longer works\n"); + return -1; +} + +int v3_detach_device(struct vm_device * dev) +{ + PrintError(VM_NONE, VCORE_NONE, "v3_detach_device is deprecated and no longer works\n"); + return -1; +} + +struct vm_device * v3_allocate_device(char * name, struct v3_device_ops * ops, void * private_data) +{ + PrintError(VM_NONE, VCORE_NONE, "v3_allocate_device is deprecated and no longer works\n"); + return 0; +} diff --git a/palacios/src/palacios/vmm_direct_paging.c b/palacios/src/palacios/vmm_direct_paging.c index 421c3aa..11c6b69 100644 --- a/palacios/src/palacios/vmm_direct_paging.c +++ b/palacios/src/palacios/vmm_direct_paging.c @@ -37,7 +37,7 @@ static addr_t create_generic_pt_page() { temp = V3_AllocPages(1); if (!temp) { - PrintError("Cannot allocate page\n"); + PrintError(VM_NONE, VCORE_NONE,"Cannot allocate page\n"); return 0; } @@ -74,7 +74,7 @@ int v3_free_passthrough_pts(struct guest_info * core) { delete_page_tables_32pae((pdpe32pae_t *)V3_VAddr((void *)(core->direct_map_pt))); break; default: - PrintError("Unknown CPU Mode\n"); + PrintError(core->vm_info, core, "Unknown CPU Mode\n"); return -1; break; } @@ -101,7 +101,7 @@ int v3_activate_passthrough_pt(struct guest_info * info) { // So this will cause chaos if it is called at that time info->ctrl_regs.cr3 = *(addr_t*)&(info->direct_map_pt); - //PrintError("Activate Passthrough Page tables not implemented\n"); + //PrintError(info->vm_info, info, "Activate Passthrough Page tables not implemented\n"); return 0; } @@ -121,7 +121,7 @@ int v3_handle_passthrough_pagefault(struct guest_info * info, addr_t fault_addr, return handle_passthrough_pagefault_32pae(info, fault_addr, error_code); default: - PrintError("Unknown CPU Mode\n"); + PrintError(info->vm_info, info, "Unknown CPU Mode\n"); break; } return -1; @@ -133,7 +133,7 @@ int v3_handle_nested_pagefault(struct guest_info * info, addr_t fault_addr, pf_e v3_cpu_mode_t mode = v3_get_host_cpu_mode(); - PrintDebug("Nested PageFault: fault_addr=%p, error_code=%u\n", (void *)fault_addr, *(uint_t *)&error_code); + PrintDebug(info->vm_info, info, "Nested PageFault: fault_addr=%p, error_code=%u\n", (void *)fault_addr, *(uint_t *)&error_code); switch(mode) { case REAL: @@ -148,7 +148,7 @@ int v3_handle_nested_pagefault(struct guest_info * info, addr_t fault_addr, pf_e return handle_passthrough_pagefault_64(info, fault_addr, error_code); default: - PrintError("Unknown CPU Mode\n"); + PrintError(info->vm_info, info, "Unknown CPU Mode\n"); break; } return -1; @@ -169,7 +169,7 @@ int v3_invalidate_passthrough_addr(struct guest_info * info, addr_t inv_addr) { return invalidate_addr_32pae(info, inv_addr); default: - PrintError("Unknown CPU Mode\n"); + PrintError(info->vm_info, info, "Unknown CPU Mode\n"); break; } return -1; @@ -197,7 +197,7 @@ int v3_invalidate_nested_addr(struct guest_info * info, addr_t inv_addr) { return invalidate_addr_64(info, inv_addr); default: - PrintError("Unknown CPU Mode\n"); + PrintError(info->vm_info, info, "Unknown CPU Mode\n"); break; } diff --git a/palacios/src/palacios/vmm_direct_paging_32.h b/palacios/src/palacios/vmm_direct_paging_32.h index ac6f054..7f9ed84 100644 --- a/palacios/src/palacios/vmm_direct_paging_32.h +++ b/palacios/src/palacios/vmm_direct_paging_32.h @@ -42,7 +42,7 @@ static inline int handle_passthrough_pagefault_32(struct guest_info * info, struct v3_mem_region * region = v3_get_mem_region(info->vm_info, info->vcpu_id, fault_addr); if (region == NULL) { - PrintError("Invalid region in passthrough page fault 32, addr=%p\n", + PrintError(info->vm_info, info, "Invalid region in passthrough page fault 32, addr=%p\n", (void *)fault_addr); return -1; } @@ -86,7 +86,7 @@ static inline int handle_passthrough_pagefault_32(struct guest_info * info, } if (v3_gpa_to_hpa(info, fault_addr, &host_addr) == -1) { - PrintError("Could not translate fault address (%p)\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not translate fault address (%p)\n", (void *)fault_addr); return -1; } diff --git a/palacios/src/palacios/vmm_direct_paging_32pae.h b/palacios/src/palacios/vmm_direct_paging_32pae.h index 06e5bb4..ca32a84 100644 --- a/palacios/src/palacios/vmm_direct_paging_32pae.h +++ b/palacios/src/palacios/vmm_direct_paging_32pae.h @@ -43,7 +43,7 @@ static inline int handle_passthrough_pagefault_32pae(struct guest_info * info, struct v3_mem_region * region = v3_get_mem_region(info->vm_info, info->vcpu_id, fault_addr); if (region == NULL) { - PrintError("Invalid region in passthrough page fault 32PAE, addr=%p\n", + PrintError(info->vm_info, info, "Invalid region in passthrough page fault 32PAE, addr=%p\n", (void *)fault_addr); return -1; } @@ -97,7 +97,7 @@ static inline int handle_passthrough_pagefault_32pae(struct guest_info * info, } if (v3_gpa_to_hpa(info, fault_addr, &host_addr) == -1) { - PrintError("Could not translate fault address (%p)\n", (void *)fault_addr); + PrintError(info->vm_info, info, "Could not translate fault address (%p)\n", (void *)fault_addr); return -1; } diff --git a/palacios/src/palacios/vmm_direct_paging_64.h b/palacios/src/palacios/vmm_direct_paging_64.h index 217373a..a79d717 100644 --- a/palacios/src/palacios/vmm_direct_paging_64.h +++ b/palacios/src/palacios/vmm_direct_paging_64.h @@ -46,7 +46,7 @@ static inline int handle_passthrough_pagefault_64(struct guest_info * core, addr int page_size = PAGE_SIZE_4KB; if (region == NULL) { - PrintError("%s: invalid region, addr=%p\n", __FUNCTION__, (void *)fault_addr); + PrintError(core->vm_info, core, "%s: invalid region, addr=%p\n", __FUNCTION__, (void *)fault_addr); return -1; } @@ -58,7 +58,7 @@ static inline int handle_passthrough_pagefault_64(struct guest_info * core, addr page_size = v3_get_max_page_size(core, fault_addr, LONG); } - PrintDebug("Using page size of %dKB\n", page_size / 1024); + PrintDebug(core->vm_info, core, "Using page size of %dKB\n", page_size / 1024); // Lookup the correct PML address based on the PAGING MODE @@ -116,7 +116,7 @@ static inline int handle_passthrough_pagefault_64(struct guest_info * core, addr } if (v3_gpa_to_hpa(core, fault_addr, &host_addr) == -1) { - PrintError("Error Could not translate fault addr (%p)\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Error Could not translate fault addr (%p)\n", (void *)fault_addr); return -1; } @@ -166,7 +166,7 @@ static inline int handle_passthrough_pagefault_64(struct guest_info * core, addr } if (v3_gpa_to_hpa(core, fault_addr, &host_addr) == -1) { - PrintError("Error Could not translate fault addr (%p)\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Error Could not translate fault addr (%p)\n", (void *)fault_addr); return -1; } diff --git a/palacios/src/palacios/vmm_emulator.c b/palacios/src/palacios/vmm_emulator.c index 20c6ecb..1bd777d 100644 --- a/palacios/src/palacios/vmm_emulator.c +++ b/palacios/src/palacios/vmm_emulator.c @@ -35,7 +35,7 @@ static int run_op(struct guest_info * info, v3_op_type_t op_type, int src_op_size, int dst_op_size) { if (src_op_size == 1) { - PrintDebug("Executing 8 bit instruction\n"); + PrintDebug(info->vm_info, info, "Executing 8 bit instruction\n"); switch (op_type) { case V3_OP_ADC: @@ -135,12 +135,12 @@ static int run_op(struct guest_info * info, v3_op_type_t op_type, break; default: - PrintError("Unknown 8 bit instruction\n"); + PrintError(info->vm_info, info, "Unknown 8 bit instruction\n"); return -1; } } else if (src_op_size == 2) { - PrintDebug("Executing 16 bit instruction\n"); + PrintDebug(info->vm_info, info, "Executing 16 bit instruction\n"); switch (op_type) { case V3_OP_ADC: @@ -190,12 +190,12 @@ static int run_op(struct guest_info * info, v3_op_type_t op_type, break; default: - PrintError("Unknown 16 bit instruction\n"); + PrintError(info->vm_info, info, "Unknown 16 bit instruction\n"); return -1; } } else if (src_op_size == 4) { - PrintDebug("Executing 32 bit instruction\n"); + PrintDebug(info->vm_info, info, "Executing 32 bit instruction\n"); switch (op_type) { case V3_OP_ADC: @@ -239,13 +239,13 @@ static int run_op(struct guest_info * info, v3_op_type_t op_type, break; default: - PrintError("Unknown 32 bit instruction\n"); + PrintError(info->vm_info, info, "Unknown 32 bit instruction\n"); return -1; } #ifdef __V3_64BIT__ } else if (src_op_size == 8) { - PrintDebug("Executing 64 bit instruction\n"); + PrintDebug(info->vm_info, info, "Executing 64 bit instruction\n"); switch (op_type) { case V3_OP_ADC: @@ -289,13 +289,13 @@ static int run_op(struct guest_info * info, v3_op_type_t op_type, break; default: - PrintError("Unknown 64 bit instruction\n"); + PrintError(info->vm_info, info, "Unknown 64 bit instruction\n"); return -1; } #endif } else { - PrintError("Invalid Operation Size\n"); + PrintError(info->vm_info, info, "Invalid Operation Size\n"); return -1; } @@ -314,7 +314,7 @@ static int run_str_op(struct guest_info * core, struct x86_instr * instr, struct rflags * flags_reg = (struct rflags *)&(core->ctrl_regs.rflags); - PrintDebug("Emulation_len=%d, tmp_rcx=%d\n", emulation_length, (uint_t)tmp_rcx); + PrintDebug(core->vm_info, core, "Emulation_len=%d, tmp_rcx=%d\n", emulation_length, (uint_t)tmp_rcx); if (instr->op_type == V3_OP_MOVS) { @@ -329,7 +329,7 @@ static int run_str_op(struct guest_info * core, struct x86_instr * instr, movs64((addr_t *)&dst_addr, &src_addr, &tmp_rcx, (addr_t *)&(core->ctrl_regs.rflags)); #endif } else { - PrintError("Invalid operand length\n"); + PrintError(core->vm_info, core, "Invalid operand length\n"); return -1; } @@ -358,7 +358,7 @@ static int run_str_op(struct guest_info * core, struct x86_instr * instr, stos64((addr_t *)&dst_addr, (addr_t *)&(core->vm_regs.rax), &tmp_rcx, (addr_t *)&(core->ctrl_regs.rflags)); #endif } else { - PrintError("Invalid operand length\n"); + PrintError(core->vm_info, core, "Invalid operand length\n"); return -1; } @@ -375,7 +375,7 @@ static int run_str_op(struct guest_info * core, struct x86_instr * instr, core->vm_regs.rcx -= rep_cnt; } } else { - PrintError("Unimplemented String operation\n"); + PrintError(core->vm_info, core, "Unimplemented String operation\n"); return -1; } diff --git a/palacios/src/palacios/vmm_events.c b/palacios/src/palacios/vmm_events.c index a001605..535db09 100644 --- a/palacios/src/palacios/vmm_events.c +++ b/palacios/src/palacios/vmm_events.c @@ -31,7 +31,7 @@ int v3_init_events(struct v3_vm_info * vm) { map->events = V3_Malloc(sizeof(struct list_head) * V3_EVENT_INVALID); if (map->events == NULL) { - PrintError("Error: could not allocate event map\n"); + PrintError(vm, VCORE_NONE, "Error: could not allocate event map\n"); return -1; } @@ -50,7 +50,7 @@ int v3_deinit_events(struct v3_vm_info * vm) { if (!list_empty(&(map->events[i]))) { struct v3_notifier * tmp_notifier = NULL; struct v3_notifier * safe_notifier = NULL; - PrintError("Found orphan notifier for event %d. Probable memory leak detected.\n", i); + PrintError(vm, VCORE_NONE, "Found orphan notifier for event %d. Probable memory leak detected.\n", i); list_for_each_entry_safe(tmp_notifier, safe_notifier, &(map->events[i]), node) { list_del(&(tmp_notifier->node)); @@ -79,14 +79,14 @@ struct v3_notifier * v3_subscribe_event(struct v3_vm_info * vm, struct v3_notifier * notifier = NULL; if (event_type >= V3_EVENT_INVALID) { - PrintError("Tried to request illegal event (%d)\n", event_type); + PrintError(vm, VCORE_NONE, "Tried to request illegal event (%d)\n", event_type); return NULL; } notifier = V3_Malloc(sizeof(struct v3_notifier)); if (notifier == NULL) { - PrintError("Error: Could not allocate notifier\n"); + PrintError(vm, VCORE_NONE, "Error: Could not allocate notifier\n"); return NULL; } @@ -111,12 +111,12 @@ int v3_unsubscribe_event(struct v3_vm_info * vm, struct v3_notifier * notifier, struct v3_notifier * safe_notifier = NULL; if (notifier == NULL) { - PrintError("Could not unsubscribe invalid event notifier\n"); + PrintError(vm, VCORE_NONE, "Could not unsubscribe invalid event notifier\n"); return -1; } if (notifier->event_type >= V3_EVENT_INVALID) { - PrintError("Could not unsubscribe from invalid event\n"); + PrintError(vm, VCORE_NONE, "Could not unsubscribe from invalid event\n"); return -1; } diff --git a/palacios/src/palacios/vmm_excp.c b/palacios/src/palacios/vmm_excp.c index f1f9411..f99ce6f 100644 --- a/palacios/src/palacios/vmm_excp.c +++ b/palacios/src/palacios/vmm_excp.c @@ -39,9 +39,9 @@ int v3_raise_exception_with_error(struct guest_info * info, uint_t excp, uint_t excp_state->excp_num = excp; excp_state->excp_error_code = error_code; excp_state->excp_error_code_valid = 1; - // PrintDebug("[v3_raise_exception_with_error] error code: %x\n", error_code); + // PrintDebug(info->vm_info, info, "[v3_raise_exception_with_error] error code: %x\n", error_code); } else { - PrintError("Error injecting exception_w_error (excp=%d) (error=%d) -- Exception (%d) (error=%d) already pending\n", + PrintError(info->vm_info, info, "Error injecting exception_w_error (excp=%d) (error=%d) -- Exception (%d) (error=%d) already pending\n", excp, error_code, excp_state->excp_num, excp_state->excp_error_code); return -1; } @@ -51,14 +51,14 @@ int v3_raise_exception_with_error(struct guest_info * info, uint_t excp, uint_t int v3_raise_exception(struct guest_info * info, uint_t excp) { struct v3_excp_state * excp_state = &(info->excp_state); - //PrintDebug("[v3_raise_exception]\n"); + //PrintDebug(info->vm_info, info, "[v3_raise_exception]\n"); if (excp_state->excp_pending == 0) { excp_state->excp_pending = 1; excp_state->excp_num = excp; excp_state->excp_error_code = 0; excp_state->excp_error_code_valid = 0; } else { - PrintError("Error injecting exception (excp=%d) -- Exception (%d) (error=%d) already pending\n", + PrintError(info->vm_info, info, "Error injecting exception (excp=%d) -- Exception (%d) (error=%d) already pending\n", excp, excp_state->excp_num, excp_state->excp_error_code); return -1; } diff --git a/palacios/src/palacios/vmm_exits.c b/palacios/src/palacios/vmm_exits.c index 97504bc..c4b26d6 100644 --- a/palacios/src/palacios/vmm_exits.c +++ b/palacios/src/palacios/vmm_exits.c @@ -29,7 +29,7 @@ int v3_init_exit_hooks(struct v3_vm_info * vm) { map->exits = V3_Malloc(sizeof(struct v3_exit_hook) * V3_EXIT_INVALID); if (map->exits == NULL) { - PrintError("Error allocating exit map\n"); + PrintError(vm, VCORE_NONE, "Error allocating exit map\n"); return -1; } @@ -61,7 +61,7 @@ int v3_init_exit_hooks_core(struct guest_info * core) { if (hook->hooked) { if (hook->enable(core, i) != 0) { - PrintError("Error could not enable exit hook %d on core %d\n", i, core->vcpu_id); + PrintError(core->vm_info, core, "Error could not enable exit hook %d on core %d\n", i, core->vcpu_id); return -1; } } @@ -82,14 +82,14 @@ int v3_dispatch_exit_hook(struct guest_info * core, v3_exit_type_t exit_type, vo struct v3_exit_hook * hook = NULL; if (exit_type >= V3_EXIT_INVALID) { - PrintError("Error: Tried to dispatch invalid exit type (%d)\n", exit_type); + PrintError(core->vm_info, core, "Error: Tried to dispatch invalid exit type (%d)\n", exit_type); return -1; } hook = &(map->exits[exit_type]); if (hook->hooked == 0) { - PrintError("Tried to dispatch an unhooked exit (%d)\n", exit_type); + PrintError(core->vm_info, core, "Tried to dispatch an unhooked exit (%d)\n", exit_type); return -1; } @@ -105,14 +105,14 @@ int v3_register_exit(struct v3_vm_info * vm, v3_exit_type_t exit_type, struct v3_exit_hook * hook = NULL; if (exit_type >= V3_EXIT_INVALID) { - PrintError("Error: Tried to register invalid exit type (%d)\n", exit_type); + PrintError(vm, VCORE_NONE, "Error: Tried to register invalid exit type (%d)\n", exit_type); return -1; } hook = &(map->exits[exit_type]); if (hook->registered == 1) { - PrintError("Tried to reregister an exit (%d)\n", exit_type); + PrintError(vm, VCORE_NONE, "Tried to reregister an exit (%d)\n", exit_type); return -1; } @@ -135,19 +135,19 @@ int v3_hook_exit(struct v3_vm_info * vm, v3_exit_type_t exit_type, if (exit_type >= V3_EXIT_INVALID) { - PrintError("Error: Tried to hook invalid exit type (%d)\n", exit_type); + PrintError(vm, VCORE_NONE, "Error: Tried to hook invalid exit type (%d)\n", exit_type); return -1; } hook = &(map->exits[exit_type]); if (hook->registered == 0) { - PrintError("Tried to hook unregistered exit (%d)\n", exit_type); + PrintError(vm, VCORE_NONE, "Tried to hook unregistered exit (%d)\n", exit_type); return -1; } if (hook->hooked != 0) { - PrintError("Tried to rehook exit (%d)\n", exit_type); + PrintError(vm, VCORE_NONE, "Tried to rehook exit (%d)\n", exit_type); return -1; } @@ -164,7 +164,7 @@ int v3_hook_exit(struct v3_vm_info * vm, v3_exit_type_t exit_type, for (i = 0; i < vm->num_cores; i++) { if (hook->enable(&(vm->cores[i]), exit_type) != 0) { - PrintError("Error could not enable exit hook %d on core %d\n", exit_type, i); + PrintError(vm, VCORE_NONE, "Error could not enable exit hook %d on core %d\n", exit_type, i); v3_lower_barrier(vm); return -1; } @@ -184,19 +184,19 @@ int v3_unhook_exit(struct v3_vm_info * vm, v3_exit_type_t exit_type, struct gues if (exit_type >= V3_EXIT_INVALID) { - PrintError("Error: Tried to unhook invalid exit type (%d)\n", exit_type); + PrintError(vm, VCORE_NONE, "Error: Tried to unhook invalid exit type (%d)\n", exit_type); return -1; } hook = &(map->exits[exit_type]); if (hook->registered == 0) { - PrintError("Tried to unhook an unregistered exit (%d)\n", exit_type); + PrintError(vm, VCORE_NONE, "Tried to unhook an unregistered exit (%d)\n", exit_type); return -1; } if (hook->hooked == 0) { - PrintError("Tried to unhook and unhooked exit (%d)\n", exit_type); + PrintError(vm, VCORE_NONE, "Tried to unhook and unhooked exit (%d)\n", exit_type); return -1; } @@ -214,7 +214,7 @@ int v3_unhook_exit(struct v3_vm_info * vm, v3_exit_type_t exit_type, struct gues for (i = 0; i < vm->num_cores; i++) { if (hook->disable(&(vm->cores[i]), exit_type) != 0) { - PrintError("Error could not enable exit hook %d on core %d\n", exit_type, i); + PrintError(vm, VCORE_NONE, "Error could not enable exit hook %d on core %d\n", exit_type, i); v3_lower_barrier(vm); return -1; } diff --git a/palacios/src/palacios/vmm_extensions.c b/palacios/src/palacios/vmm_extensions.c index ee16ca0..f5a14c3 100644 --- a/palacios/src/palacios/vmm_extensions.c +++ b/palacios/src/palacios/vmm_extensions.c @@ -58,15 +58,15 @@ int V3_init_extensions() { ext_table = v3_create_htable(0, ext_hash_fn, ext_eq_fn); while (tmp_ext != __stop__v3_extensions) { - V3_Print("Registering Extension (%s)\n", (*tmp_ext)->name); + V3_Print(VM_NONE, VCORE_NONE, "Registering Extension (%s)\n", (*tmp_ext)->name); if (v3_htable_search(ext_table, (addr_t)((*tmp_ext)->name))) { - PrintError("Multiple instances of Extension (%s)\n", (*tmp_ext)->name); + PrintError(VM_NONE, VCORE_NONE, "Multiple instances of Extension (%s)\n", (*tmp_ext)->name); return -1; } if (v3_htable_insert(ext_table, (addr_t)((*tmp_ext)->name), (addr_t)(*tmp_ext)) == 0) { - PrintError("Could not register Extension (%s)\n", (*tmp_ext)->name); + PrintError(VM_NONE, VCORE_NONE, "Could not register Extension (%s)\n", (*tmp_ext)->name); return -1; } @@ -109,10 +109,10 @@ int v3_deinit_ext_manager(struct v3_vm_info * vm) { list_for_each_entry_safe(ext, tmp, &(ext_state->extensions), node) { - V3_Print("Cleaning up Extension (%s)\n", ext->impl->name); + V3_Print(vm, VCORE_NONE, "Cleaning up Extension (%s)\n", ext->impl->name); if ((ext->impl) && (ext->impl->deinit)) { if (ext->impl->deinit(vm, ext->priv_data) == -1) { - PrintError("Error cleaning up extension (%s)\n", ext->impl->name); + PrintError(vm, VCORE_NONE, "Error cleaning up extension (%s)\n", ext->impl->name); return -1; } } @@ -141,25 +141,25 @@ int v3_add_extension(struct v3_vm_info * vm, const char * name, v3_cfg_tree_t * impl = (void *)v3_htable_search(ext_table, (addr_t)name); if (impl == NULL) { - PrintError("Could not find requested extension (%s)\n", name); + PrintError(vm, VCORE_NONE, "Could not find requested extension (%s)\n", name); return -1; } - V3_ASSERT(impl->init); + V3_ASSERT(vm, VCORE_NONE, impl->init); /* this allows each extension to track its own per-core state */ ext_size = sizeof(struct v3_extension) + (sizeof(void *) * vm->num_cores); ext = V3_Malloc(ext_size); if (!ext) { - PrintError("Could not allocate extension\n"); + PrintError(vm, VCORE_NONE, "Could not allocate extension\n"); return -1; } ext->impl = impl; if (impl->init(vm, cfg, &(ext->priv_data)) == -1) { - PrintError("Error initializing Extension (%s)\n", name); + PrintError(vm, VCORE_NONE, "Error initializing Extension (%s)\n", name); V3_Free(ext); return -1; } @@ -184,7 +184,7 @@ int v3_init_core_extensions(struct guest_info * core) { list_for_each_entry(ext, &(core->vm_info->extensions.extensions), node) { if ((ext->impl) && (ext->impl->core_init)) { if (ext->impl->core_init(core, ext->priv_data, &(ext->core_ext_priv_data[cpuid])) == -1) { - PrintError("Error configuring per core extension %s on core %d\n", + PrintError(core->vm_info, core, "Error configuring per core extension %s on core %d\n", ext->impl->name, core->vcpu_id); return -1; } @@ -204,7 +204,7 @@ int v3_deinit_core_extensions (struct guest_info * core) { list_for_each_entry_safe(ext, tmp, &(vm->extensions.extensions), node) { if ((ext->impl) && (ext->impl->core_deinit)) { if (ext->impl->core_deinit(core, ext->priv_data, ext->core_ext_priv_data[cpuid]) == -1) { - PrintError("Error tearing down per core extension %s on core %d\n", + PrintError(core->vm_info, core, "Error tearing down per core extension %s on core %d\n", ext->impl->name, cpuid); return -1; } diff --git a/palacios/src/palacios/vmm_halt.c b/palacios/src/palacios/vmm_halt.c index b6e1a96..f6b284c 100644 --- a/palacios/src/palacios/vmm_halt.c +++ b/palacios/src/palacios/vmm_halt.c @@ -41,7 +41,7 @@ int v3_handle_halt(struct guest_info * info) } else { uint64_t start_cycles; - PrintDebug("CPU Yield\n"); + PrintDebug(info->vm_info, info, "CPU Yield\n"); start_cycles = v3_get_host_time(&info->time_state); @@ -70,7 +70,7 @@ int v3_handle_halt(struct guest_info * info) } - /* V3_Print("palacios: done with halt\n"); */ + /* V3_Print(info->vm_info, info, "palacios: done with halt\n"); */ info->rip += 1; } diff --git a/palacios/src/palacios/vmm_host_events.c b/palacios/src/palacios/vmm_host_events.c index 9d834d6..4b9dcbe 100644 --- a/palacios/src/palacios/vmm_host_events.c +++ b/palacios/src/palacios/vmm_host_events.c @@ -87,7 +87,7 @@ int v3_hook_host_event(struct v3_vm_info * vm, hook = (struct v3_host_event_hook *)V3_Malloc(sizeof(struct v3_host_event_hook)); if (hook == NULL) { - PrintError("Could not allocate event hook\n"); + PrintError(vm, VCORE_NONE,"Could not allocate event hook\n"); return -1; } diff --git a/palacios/src/palacios/vmm_hypercall.c b/palacios/src/palacios/vmm_hypercall.c index 6899640..59e6484 100644 --- a/palacios/src/palacios/vmm_hypercall.c +++ b/palacios/src/palacios/vmm_hypercall.c @@ -137,7 +137,7 @@ int v3_register_hypercall(struct v3_vm_info * vm, hcall_id_t hypercall_id, struct hypercall * hcall = (struct hypercall *)V3_Malloc(sizeof(struct hypercall)); if (!hcall) { - PrintError("Cannot allocate in registering hypercall\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in registering hypercall\n"); return -1; } @@ -166,7 +166,7 @@ int v3_remove_hypercall(struct v3_vm_info * vm, hcall_id_t hypercall_id) { struct hypercall * hcall = get_hypercall(vm, hypercall_id); if (hcall == NULL) { - PrintError("Attempted to remove non existant hypercall\n"); + PrintError(vm, VCORE_NONE, "Attempted to remove non existant hypercall\n"); return -1; } @@ -181,13 +181,13 @@ int v3_handle_hypercall(struct guest_info * info) { struct hypercall * hcall = get_hypercall(info->vm_info, hypercall_id); if (!hcall) { - PrintError("Invalid Hypercall (%d(0x%x) not registered)\n", + PrintError(info->vm_info, info, "Invalid Hypercall (%d(0x%x) not registered)\n", hypercall_id, hypercall_id); return -1; } if (hcall->hcall_fn(info, hypercall_id, hcall->priv_data) != 0) { - PrintError("Error handling hypercall\n"); + PrintError(info->vm_info, info, "Error handling hypercall\n"); return -1; } diff --git a/palacios/src/palacios/vmm_intr.c b/palacios/src/palacios/vmm_intr.c index 06d5254..5b5dad6 100644 --- a/palacios/src/palacios/vmm_intr.c +++ b/palacios/src/palacios/vmm_intr.c @@ -99,7 +99,7 @@ void * v3_register_intr_controller(struct guest_info * info, struct intr_ctrl_op struct intr_controller * ctrlr = (struct intr_controller *)V3_Malloc(sizeof(struct intr_controller)); if (!ctrlr) { - PrintError("Cannot allocate in registering an interrupt controller\n"); + PrintError(info->vm_info, info, "Cannot allocate in registering an interrupt controller\n"); return NULL; } @@ -125,7 +125,7 @@ void v3_remove_intr_controller(struct guest_info * core, void * handle) { } if (found == 0) { - PrintError("Attempted to remove invalid interrupt controller handle\n"); + PrintError(core->vm_info, core, "Attempted to remove invalid interrupt controller handle\n"); return; } @@ -137,7 +137,7 @@ void * v3_register_intr_router(struct v3_vm_info * vm, struct intr_router_ops * struct intr_router * router = (struct intr_router *)V3_Malloc(sizeof(struct intr_router)); if (!router) { - PrintError("Cannot allocate in registering an interrupt router\n"); + PrintError(vm, VCORE_NONE,"Cannot allocate in registering an interrupt router\n"); return NULL; } @@ -162,7 +162,7 @@ void v3_remove_intr_router(struct v3_vm_info * vm, void * handle) { } if (found == 0) { - PrintError("Attempted to remove invalid interrupt router\n"); + PrintError(vm, VCORE_NONE, "Attempted to remove invalid interrupt router\n"); return; } @@ -173,7 +173,7 @@ void v3_remove_intr_router(struct v3_vm_info * vm, void * handle) { static inline struct v3_irq_hook * get_irq_hook(struct v3_vm_info * vm, uint_t irq) { - V3_ASSERT(irq <= 256); + V3_ASSERT(vm, VCORE_NONE,irq <= 256); return vm->intr_routers.hooks[irq]; } @@ -187,12 +187,12 @@ int v3_hook_irq(struct v3_vm_info * vm, if (hook == NULL) { - PrintError("Cannot allocate when hooking an irq\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate when hooking an irq\n"); return -1; } if (get_irq_hook(vm, irq) != NULL) { - PrintError("IRQ %d already hooked\n", irq); + PrintError(vm, VCORE_NONE, "IRQ %d already hooked\n", irq); V3_Free(hook); return -1; } @@ -203,12 +203,12 @@ int v3_hook_irq(struct v3_vm_info * vm, vm->intr_routers.hooks[irq] = hook; if (V3_Hook_Interrupt(vm, irq)) { - PrintError("hook_irq: failed to hook irq %d\n", irq); + PrintError(vm, VCORE_NONE, "hook_irq: failed to hook irq %d\n", irq); vm->intr_routers.hooks[irq] = NULL; V3_Free(hook); return -1; } else { - PrintDebug("hook_irq: hooked irq %d\n", irq); + PrintDebug(vm, VCORE_NONE, "hook_irq: hooked irq %d\n", irq); return 0; } } @@ -216,7 +216,7 @@ int v3_hook_irq(struct v3_vm_info * vm, static int passthrough_irq_handler(struct v3_vm_info * vm, struct v3_interrupt * intr, void * priv_data) { - PrintDebug("[passthrough_irq_handler] raise_irq=%d (guest=0x%p)\n", + PrintDebug(vm, VCORE_NONE, "[passthrough_irq_handler] raise_irq=%d (guest=0x%p)\n", intr->irq, (void *)vm); return v3_raise_irq(vm, intr->irq); @@ -226,10 +226,10 @@ int v3_hook_passthrough_irq(struct v3_vm_info * vm, uint_t irq) { int rc = v3_hook_irq(vm, irq, passthrough_irq_handler, NULL); if (rc) { - PrintError("guest_irq_injection: failed to hook irq 0x%x (guest=0x%p)\n", irq, (void *)vm); + PrintError(vm, VCORE_NONE, "guest_irq_injection: failed to hook irq 0x%x (guest=0x%p)\n", irq, (void *)vm); return -1; } else { - PrintDebug("guest_irq_injection: hooked irq 0x%x (guest=0x%p)\n", irq, (void *)vm); + PrintDebug(vm, VCORE_NONE, "guest_irq_injection: hooked irq 0x%x (guest=0x%p)\n", irq, (void *)vm); return 0; } } @@ -239,12 +239,12 @@ int v3_hook_passthrough_irq(struct v3_vm_info * vm, uint_t irq) { int v3_deliver_irq(struct v3_vm_info * vm, struct v3_interrupt * intr) { - PrintDebug("v3_deliver_irq: irq=%d state=0x%p, \n", intr->irq, (void *)intr); + PrintDebug(vm, VCORE_NONE, "v3_deliver_irq: irq=%d state=0x%p, \n", intr->irq, (void *)intr); struct v3_irq_hook * hook = get_irq_hook(vm, intr->irq); if (hook == NULL) { - PrintError("Attempting to deliver interrupt to non registered hook(irq=%d)\n", intr->irq); + PrintError(vm, VCORE_NONE, "Attempting to deliver interrupt to non registered hook(irq=%d)\n", intr->irq); return -1; } @@ -257,8 +257,8 @@ int v3_deliver_irq(struct v3_vm_info * vm, struct v3_interrupt * intr) { int v3_raise_swintr (struct guest_info * core, uint8_t vector) { struct v3_intr_core_state * intr_state = &(core->intr_core_state); - PrintDebug("Signaling software interrupt in v3_signal_swintr()\n"); - PrintDebug("\tINT vector: %d\n", vector); + PrintDebug(core->vm_info, core, "Signaling software interrupt in v3_signal_swintr()\n"); + PrintDebug(core->vm_info, core, "\tINT vector: %d\n", vector); intr_state->swintr_posted = 1; intr_state->swintr_vector = vector; @@ -313,7 +313,7 @@ int v3_raise_acked_irq(struct v3_vm_info * vm, struct v3_irq irq) { struct intr_router * router = NULL; struct v3_intr_routers * routers = &(vm->intr_routers); - // PrintDebug("[v3_raise_irq (%d)]\n", irq); + // PrintDebug(info->vm_info, info, "[v3_raise_irq (%d)]\n", irq); addr_t irq_state = v3_lock_irqsave(routers->irq_lock); list_for_each_entry(router, &(routers->router_list), router_node) { @@ -330,7 +330,7 @@ int v3_lower_acked_irq(struct v3_vm_info * vm, struct v3_irq irq) { struct intr_router * router = NULL; struct v3_intr_routers * routers = &(vm->intr_routers); - // PrintDebug("[v3_lower_irq]\n"); + // PrintDebug(info->vm_info, info, "[v3_lower_irq]\n"); addr_t irq_state = v3_lock_irqsave(routers->irq_lock); list_for_each_entry(router, &(routers->router_list), router_node) { @@ -359,7 +359,7 @@ v3_intr_type_t v3_intr_pending(struct guest_info * info) { int ret = V3_INVALID_INTR; int i = 0; - // PrintDebug("[intr_pending]\n"); + // PrintDebug(info->vm_info, info, "[intr_pending]\n"); addr_t irq_state = v3_lock_irqsave(intr_state->irq_lock); // External IRQs have lowest priority @@ -416,7 +416,7 @@ uint32_t v3_get_intr(struct guest_info * info) { if (ctrl->ctrl_ops->intr_pending(info, ctrl->priv_data)) { uint_t intr_num = ctrl->ctrl_ops->get_intr_number(info, ctrl->priv_data); - // PrintDebug("[get_intr_number] intr_number = %d\n", intr_num); + // PrintDebug(info->vm_info, info, "[get_intr_number] intr_number = %d\n", intr_num); ret = intr_num; break; } @@ -438,7 +438,7 @@ intr_type_t v3_get_intr_type(struct guest_info * info) { list_for_each_entry(ctrl, &(intr_state->controller_list), ctrl_node) { if (ctrl->ctrl_ops->intr_pending(ctrl->priv_data) == 1) { - //PrintDebug("[get_intr_type] External_irq\n"); + //PrintDebug(info->vm_info, info, "[get_intr_type] External_irq\n"); type = V3_EXTERNAL_IRQ; break; } @@ -446,7 +446,7 @@ intr_type_t v3_get_intr_type(struct guest_info * info) { #ifdef V3_CONFIG_DEBUG_INTERRUPTS if (type == V3_INVALID_INTR) { - PrintError("[get_intr_type] Invalid_Intr\n"); + PrintError(info->vm_info, info, "[get_intr_type] Invalid_Intr\n"); } #endif @@ -468,7 +468,7 @@ int v3_injecting_intr(struct guest_info * info, uint_t intr_num, v3_intr_type_t addr_t irq_state = v3_lock_irqsave(intr_state->irq_lock); - // PrintDebug("[injecting_intr] External_Irq with intr_num = %x\n", intr_num); + // PrintDebug(info->vm_info, info, "[injecting_intr] External_Irq with intr_num = %x\n", intr_num); list_for_each_entry(ctrl, &(intr_state->controller_list), ctrl_node) { ctrl->ctrl_ops->begin_irq(info, ctrl->priv_data, intr_num); } diff --git a/palacios/src/palacios/vmm_io.c b/palacios/src/palacios/vmm_io.c index 8ed88d8..96ee1d7 100644 --- a/palacios/src/palacios/vmm_io.c +++ b/palacios/src/palacios/vmm_io.c @@ -129,7 +129,7 @@ int v3_hook_io_port(struct v3_vm_info * vm, uint16_t port, struct v3_io_hook * io_hook = (struct v3_io_hook *)V3_Malloc(sizeof(struct v3_io_hook)); if (!io_hook) { - PrintError("Cannot allocate in hooking an I/O port\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in hooking an I/O port\n"); return -1; } @@ -151,7 +151,7 @@ int v3_hook_io_port(struct v3_vm_info * vm, uint16_t port, io_hook->priv_data = priv_data; if (insert_io_hook(vm, io_hook)) { - PrintError("Could not insert IO hook for port %u (0x%x)\n", port, port); + PrintError(vm, VCORE_NONE, "Could not insert IO hook for port %u (0x%x)\n", port, port); V3_Free(io_hook); return -1; } @@ -160,7 +160,7 @@ int v3_hook_io_port(struct v3_vm_info * vm, uint16_t port, if (vm->io_map.update_map(vm, port, ((read == NULL) ? 0 : 1), ((write == NULL) ? 0 : 1)) == -1) { - PrintError("Could not update IO map for port %u (0x%x)\n", port, port); + PrintError(vm, VCORE_NONE, "Could not update IO map for port %u (0x%x)\n", port, port); V3_Free(io_hook); return -1; } @@ -187,7 +187,7 @@ int v3_unhook_io_port(struct v3_vm_info * vm, uint16_t port) { struct v3_io_hook * hook = v3_get_io_hook(vm, port); if (hook == NULL) { - PrintError("Could not find port to unhook %u (0x%x)\n", port, port); + PrintError(vm, VCORE_NONE, "Could not find port to unhook %u (0x%x)\n", port, port); return -1; } @@ -207,7 +207,7 @@ void v3_refresh_io_map(struct v3_vm_info * vm) { struct v3_io_hook * tmp = NULL; if (io_map->update_map == NULL) { - PrintError("Trying to refresh an io map with no backend\n"); + PrintError(vm, VCORE_NONE, "Trying to refresh an io map with no backend\n"); return; } @@ -225,10 +225,10 @@ void v3_print_io_map(struct v3_vm_info * vm) { struct v3_io_map * io_map = &(vm->io_map); struct v3_io_hook * tmp_hook = NULL; - V3_Print("VMM IO Map\n"); + V3_Print(vm, VCORE_NONE, "VMM IO Map\n"); v3_rb_for_each_entry(tmp_hook, &(io_map->map), tree_node) { - V3_Print("IO Port: %hu (Read=%p) (Write=%p)\n", + V3_Print(vm, VCORE_NONE, "IO Port: %hu (Read=%p) (Write=%p)\n", tmp_hook->port, (void *)(tmp_hook->read), (void *)(tmp_hook->write)); } diff --git a/palacios/src/palacios/vmm_mem.c b/palacios/src/palacios/vmm_mem.c index 390de61..0f208b4 100644 --- a/palacios/src/palacios/vmm_mem.c +++ b/palacios/src/palacios/vmm_mem.c @@ -31,7 +31,7 @@ static int mem_offset_hypercall(struct guest_info * info, uint_t hcall_id, void * private_data) { - PrintDebug("V3Vee: Memory offset hypercall (offset=%p)\n", + PrintDebug(info->vm_info, info,"V3Vee: Memory offset hypercall (offset=%p)\n", (void *)(info->vm_info->mem_map.base_region.host_addr)); info->vm_regs.rbx = info->vm_info->mem_map.base_region.host_addr; @@ -42,7 +42,7 @@ static int mem_offset_hypercall(struct guest_info * info, uint_t hcall_id, void static int unhandled_err(struct guest_info * core, addr_t guest_va, addr_t guest_pa, struct v3_mem_region * reg, pf_error_t access_info) { - PrintError("Unhandled memory access error (gpa=%p, gva=%p, error_code=%d)\n", + PrintError(core->vm_info, core, "Unhandled memory access error (gpa=%p, gva=%p, error_code=%d)\n", (void *)guest_pa, (void *)guest_va, *(uint32_t *)&access_info); v3_print_mem_map(core->vm_info); @@ -61,7 +61,7 @@ int v3_init_mem_map(struct v3_vm_info * vm) { map->mem_regions.rb_node = NULL; // There is an underlying region that contains all of the guest memory - // PrintDebug("Mapping %d pages of memory (%u bytes)\n", (int)mem_pages, (uint_t)info->mem_size); + // PrintDebug(info->vm_info, info, "Mapping %d pages of memory (%u bytes)\n", (int)mem_pages, (uint_t)info->mem_size); // 2MB page alignment needed for 2MB hardware nested paging map->base_region.guest_start = 0; @@ -74,7 +74,7 @@ int v3_init_mem_map(struct v3_vm_info * vm) { #endif if ((void*)map->base_region.host_addr == NULL) { - PrintError("Could not allocate guest memory\n"); + PrintError(vm, VCORE_NONE,"Could not allocate guest memory\n"); return -1; } @@ -119,14 +119,14 @@ struct v3_mem_region * v3_create_mem_region(struct v3_vm_info * vm, uint16_t cor struct v3_mem_region * entry = NULL; if (guest_addr_start >= guest_addr_end) { - PrintError("Region start is after region end\n"); + PrintError(vm, VCORE_NONE, "Region start is after region end\n"); return NULL; } entry = (struct v3_mem_region *)V3_Malloc(sizeof(struct v3_mem_region)); if (!entry) { - PrintError("Cannot allocate in creating a memory region\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in creating a memory region\n"); return NULL; } @@ -189,7 +189,7 @@ struct v3_mem_region * __insert_mem_region(struct v3_vm_info * vm, } else { if ((region->guest_end != tmp_region->guest_end) || (region->guest_start != tmp_region->guest_start)) { - PrintError("Trying to map a partial overlapped core specific page...\n"); + PrintError(vm, VCORE_NONE, "Trying to map a partial overlapped core specific page...\n"); return tmp_region; // This is ugly... } else if (region->core_id == tmp_region->core_id) { return tmp_region; @@ -285,7 +285,7 @@ struct v3_mem_region * v3_get_mem_region(struct v3_vm_info * vm, uint16_t core_i // go right, core too small n = n->rb_right; } else { - PrintDebug("v3_get_mem_region: Impossible!\n"); + PrintDebug(vm, VCORE_NONE, "v3_get_mem_region: Impossible!\n"); return NULL; } } @@ -295,7 +295,7 @@ struct v3_mem_region * v3_get_mem_region(struct v3_vm_info * vm, uint16_t core_i // There is not registered region, so we check if its a valid address in the base region if (guest_addr > vm->mem_map.base_region.guest_end) { - PrintError("Guest Address Exceeds Base Memory Size (ga=0x%p), (limit=0x%p) (core=0x%x)\n", + PrintError(vm, VCORE_NONE, "Guest Address Exceeds Base Memory Size (ga=0x%p), (limit=0x%p) (core=0x%x)\n", (void *)guest_addr, (void *)vm->mem_map.base_region.guest_end, core_id); v3_print_mem_map(vm); @@ -343,7 +343,7 @@ static struct v3_mem_region * get_next_mem_region( struct v3_vm_info * vm, uint1 // go right, core too small n = n->rb_right; } else { - PrintError("v3_get_mem_region: Impossible!\n"); + PrintError(vm, VCORE_NONE, "v3_get_mem_region: Impossible!\n"); return NULL; } } @@ -389,7 +389,7 @@ static struct v3_mem_region * get_overlapping_region(struct v3_vm_info * vm, uin struct v3_mem_region * start_region = v3_get_mem_region(vm, core_id, start_gpa); if (start_region == NULL) { - PrintError("Invalid memory region\n"); + PrintError(vm, VCORE_NONE, "Invalid memory region\n"); return NULL; } @@ -543,7 +543,7 @@ uint32_t v3_get_max_page_size(struct guest_info * core, addr_t page_addr, v3_cpu } break; default: - PrintError("Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); + PrintError(core->vm_info, core, "Invalid CPU mode: %s\n", v3_cpu_mode_to_str(v3_get_vm_cpu_mode(core))); return -1; } @@ -557,10 +557,10 @@ void v3_print_mem_map(struct v3_vm_info * vm) { struct v3_mem_region * reg = &(vm->mem_map.base_region); int i = 0; - V3_Print("Memory Layout (all cores):\n"); + V3_Print(vm, VCORE_NONE, "Memory Layout (all cores):\n"); - V3_Print("Base Region (all cores): 0x%p - 0x%p -> 0x%p\n", + V3_Print(vm, VCORE_NONE, "Base Region (all cores): 0x%p - 0x%p -> 0x%p\n", (void *)(reg->guest_start), (void *)(reg->guest_end - 1), (void *)(reg->host_addr)); @@ -574,12 +574,12 @@ void v3_print_mem_map(struct v3_vm_info * vm) { do { reg = rb_entry(node, struct v3_mem_region, tree_node); - V3_Print("%d: 0x%p - 0x%p -> 0x%p\n", i, + V3_Print(vm, VCORE_NONE, "%d: 0x%p - 0x%p -> 0x%p\n", i, (void *)(reg->guest_start), (void *)(reg->guest_end - 1), (void *)(reg->host_addr)); - V3_Print("\t(flags=0x%x) (core=0x%x) (unhandled = 0x%p)\n", + V3_Print(vm, VCORE_NONE, "\t(flags=0x%x) (core=0x%x) (unhandled = 0x%p)\n", reg->flags.value, reg->core_id, reg->unhandled); diff --git a/palacios/src/palacios/vmm_mem_hook.c b/palacios/src/palacios/vmm_mem_hook.c index a820e5b..f4040ff 100644 --- a/palacios/src/palacios/vmm_mem_hook.c +++ b/palacios/src/palacios/vmm_mem_hook.c @@ -61,7 +61,7 @@ int v3_init_mem_hooks(struct v3_vm_info * vm) { temp = V3_AllocPages(vm->num_cores); if (!temp) { - PrintError("Cannot allocate space for mem hooks\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate space for mem hooks\n"); return -1; } @@ -70,7 +70,7 @@ int v3_init_mem_hooks(struct v3_vm_info * vm) { temp = V3_AllocPages(vm->num_cores); if (!temp) { - PrintError("Cannot allocate space for mem hooks\n"); + PrintError(vm, VCORE_NONE,"Cannot allocate space for mem hooks\n"); V3_FreePages(hooks->hook_hvas_1,vm->num_cores); return -1; } @@ -165,12 +165,12 @@ static int handle_mem_hook(struct guest_info * core, addr_t guest_va, addr_t gue } if (ret == -1) { - PrintError("Could not translate Instruction Address (%p)\n", (void *)(addr_t)core->rip); + PrintError(core->vm_info, core, "Could not translate Instruction Address (%p)\n", (void *)(addr_t)core->rip); return -1; } if (v3_decode(core, (addr_t)instr_ptr, &instr) == -1) { - PrintError("Decoding Error\n"); + PrintError(core->vm_info, core, "Decoding Error\n"); return -1; } @@ -203,7 +203,7 @@ static int handle_mem_hook(struct guest_info * core, addr_t guest_va, addr_t gue } if (src_reg == NULL) { - PrintError("Error finding Source region (addr=%p)\n", (void *)src_mem_op_gpa); + PrintError(core->vm_info, core, "Error finding Source region (addr=%p)\n", (void *)src_mem_op_gpa); return -1; } @@ -249,7 +249,7 @@ static int handle_mem_hook(struct guest_info * core, addr_t guest_va, addr_t gue } if (dst_reg == NULL) { - PrintError("Error finding Source region (addr=%p)\n", (void *)dst_mem_op_gpa); + PrintError(core->vm_info, core, "Error finding Source region (addr=%p)\n", (void *)dst_mem_op_gpa); return -1; } @@ -271,7 +271,7 @@ static int handle_mem_hook(struct guest_info * core, addr_t guest_va, addr_t gue mem_op_size = ((uint_t)src_req_size < (uint_t)dst_req_size) ? src_req_size : dst_req_size; if (mem_op_size == -1) { - PrintError("Error: Did not detect any memory operands...\n"); + PrintError(core->vm_info, core, "Error: Did not detect any memory operands...\n"); return -1; } @@ -283,7 +283,7 @@ static int handle_mem_hook(struct guest_info * core, addr_t guest_va, addr_t gue // Read in data from hook if (src_hook->read(core, src_mem_op_gpa, (void *)src_mem_op_hva, mem_op_size, src_hook->priv_data) == -1) { - PrintError("Read hook error at src_mem_op_gpa=%p\n", (void *)src_mem_op_gpa); + PrintError(core->vm_info, core, "Read hook error at src_mem_op_gpa=%p\n", (void *)src_mem_op_gpa); return -1; } } @@ -294,7 +294,7 @@ static int handle_mem_hook(struct guest_info * core, addr_t guest_va, addr_t gue // Read in data from hook if (dst_hook->read(core, dst_mem_op_gpa, (void *)dst_mem_op_hva, mem_op_size, dst_hook->priv_data) == -1) { - PrintError("Read hook error at dst_mem_op_gpa=%p\n", (void *)dst_mem_op_gpa); + PrintError(core->vm_info, core, "Read hook error at dst_mem_op_gpa=%p\n", (void *)dst_mem_op_gpa); return -1; } } @@ -302,7 +302,7 @@ static int handle_mem_hook(struct guest_info * core, addr_t guest_va, addr_t gue bytes_emulated = v3_emulate(core, &instr, mem_op_size, src_mem_op_hva, dst_mem_op_hva); if (bytes_emulated == -1) { - PrintError("Error emulating instruction\n"); + PrintError(core->vm_info, core, "Error emulating instruction\n"); return -1; } @@ -311,7 +311,7 @@ static int handle_mem_hook(struct guest_info * core, addr_t guest_va, addr_t gue (instr.src_operand.write == 1) ) { if (src_hook->write(core, src_mem_op_gpa, (void *)src_mem_op_hva, bytes_emulated, src_hook->priv_data) == -1) { - PrintError("Write hook error at src_mem_op_gpa=%p\n", (void *)src_mem_op_gpa); + PrintError(core->vm_info, core, "Write hook error at src_mem_op_gpa=%p\n", (void *)src_mem_op_gpa); return -1; } @@ -322,7 +322,7 @@ static int handle_mem_hook(struct guest_info * core, addr_t guest_va, addr_t gue (instr.dst_operand.write == 1) ) { if (dst_hook->write(core, dst_mem_op_gpa, (void *)dst_mem_op_hva, bytes_emulated, dst_hook->priv_data) == -1) { - PrintError("Write hook error at dst_mem_op_gpa=%p\n", (void *)dst_mem_op_gpa); + PrintError(core->vm_info, core, "Write hook error at dst_mem_op_gpa=%p\n", (void *)dst_mem_op_gpa); return -1; } } @@ -347,7 +347,7 @@ int v3_hook_write_mem(struct v3_vm_info * vm, uint16_t core_id, struct v3_mem_hooks * hooks = &(vm->mem_hooks); if (!hook) { - PrintError("Cannot allocate in hooking memory for full access\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in hooking memory for full access\n"); return -1; } @@ -394,7 +394,7 @@ int v3_hook_full_mem(struct v3_vm_info * vm, uint16_t core_id, struct v3_mem_hooks * hooks = &(vm->mem_hooks); if (!hook) { - PrintError("Cannot allocate in hooking memory for writing\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in hooking memory for writing\n"); return -1; } @@ -407,7 +407,7 @@ int v3_hook_full_mem(struct v3_vm_info * vm, uint16_t core_id, entry = v3_create_mem_region(vm, core_id, guest_addr_start, guest_addr_end); if (!entry) { - PrintError("Cannot create memory region\n"); + PrintError(vm, VCORE_NONE, "Cannot create memory region\n"); V3_Free(hook); return -1; } @@ -418,7 +418,7 @@ int v3_hook_full_mem(struct v3_vm_info * vm, uint16_t core_id, entry->priv_data = hook; if (v3_insert_mem_region(vm, entry)) { - PrintError("Cannot insert memory region\n"); + PrintError(vm, VCORE_NONE, "Cannot insert memory region\n"); V3_Free(entry); V3_Free(hook); return -1; @@ -448,7 +448,7 @@ int v3_hook_access_mem(struct v3_vm_info * vm, uint16_t core_id, struct v3_mem_hooks * hooks = &(vm->mem_hooks); if (!hook) { - PrintError("Cannot allocate in hooking memory for access\n"); + PrintError(vm, VCORE_NONE,"Cannot allocate in hooking memory for access\n"); return -1; } @@ -460,7 +460,7 @@ int v3_hook_access_mem(struct v3_vm_info * vm, uint16_t core_id, entry = v3_create_mem_region(vm, core_id, guest_addr_start, guest_addr_end); if (!entry) { - PrintError("Cannot create memory region\n"); + PrintError(vm, VCORE_NONE, "Cannot create memory region\n"); V3_Free(hook); return -1; } @@ -471,7 +471,7 @@ int v3_hook_access_mem(struct v3_vm_info * vm, uint16_t core_id, entry->priv_data = hook; if (v3_insert_mem_region(vm, entry)) { - PrintError("Cannot insert memory region\n"); + PrintError(vm, VCORE_NONE, "Cannot insert memory region\n"); V3_Free(entry); V3_Free(hook); return -1; @@ -501,14 +501,14 @@ int v3_unhook_mem(struct v3_vm_info * vm, uint16_t core_id, addr_t guest_addr_st struct mem_hook * hook = NULL; if (reg == NULL) { - PrintError("Could not find region at %p\n", (void *)guest_addr_start); + PrintError(vm, VCORE_NONE, "Could not find region at %p\n", (void *)guest_addr_start); return -1; } hook = reg->priv_data; if (hook == NULL) { - PrintError("Trying to unhook region that is not a hook at %p\n", (void *)guest_addr_start); + PrintError(vm, VCORE_NONE, "Trying to unhook region that is not a hook at %p\n", (void *)guest_addr_start); return -1; } diff --git a/palacios/src/palacios/vmm_msr.c b/palacios/src/palacios/vmm_msr.c index b960187..0ed99ed 100644 --- a/palacios/src/palacios/vmm_msr.c +++ b/palacios/src/palacios/vmm_msr.c @@ -27,7 +27,7 @@ static int free_hook(struct v3_vm_info * vm, struct v3_msr_hook * hook); void v3_init_msr_map(struct v3_vm_info * vm) { struct v3_msr_map * msr_map = &(vm->msr_map); - PrintDebug("Initializing MSR map.\n"); + PrintDebug(vm, VCORE_NONE, "Initializing MSR map.\n"); INIT_LIST_HEAD(&(msr_map->hook_list)); msr_map->num_hooks = 0; @@ -54,7 +54,7 @@ int v3_handle_msr_write(struct guest_info * info) { msr_val.value = 0; - PrintDebug("MSR write for msr 0x%x\n", msr_num); + PrintDebug(info->vm_info, info, "MSR write for msr 0x%x\n", msr_num); hook = v3_get_msr_hook(info->vm_info, msr_num); @@ -66,11 +66,11 @@ int v3_handle_msr_write(struct guest_info * info) { if (hook->write) { if (hook->write(info, msr_num, msr_val, hook->priv_data) == -1) { - PrintError("Error in MSR hook Write\n"); + PrintError(info->vm_info, info, "Error in MSR hook Write\n"); return -1; } } else { - PrintError("No write hook exists for msr 0x%x\n",msr_num); + PrintError(info->vm_info, info, "No write hook exists for msr 0x%x\n",msr_num); } } @@ -93,7 +93,7 @@ int v3_handle_msr_read(struct guest_info * info) { v3_msr_unhandled_read(info, msr_num, &msr_val, NULL); } else { if (hook->read(info, msr_num, &msr_val, hook->priv_data) == -1) { - PrintError("Error in MSR hook Read\n"); + PrintError(info->vm_info, info, "Error in MSR hook Read\n"); return -1; } } @@ -108,7 +108,7 @@ int v3_handle_msr_read(struct guest_info * info) { int v3_msr_unhandled_read(struct guest_info * core, uint32_t msr, struct v3_msr * dst, void * priv_data) { - V3_Print("Palacios: Unhandled MSR Read (MSR=0x%x) - returning zero\n", msr); + V3_Print(core->vm_info, core, "Palacios: Unhandled MSR Read (MSR=0x%x) - returning zero\n", msr); dst->value = 0; @@ -117,7 +117,7 @@ int v3_msr_unhandled_read(struct guest_info * core, uint32_t msr, struct v3_msr } int v3_msr_unhandled_write(struct guest_info * core, uint32_t msr, struct v3_msr src, void * priv_data) { - V3_Print("Palacios: Unhandled MSR Write (MSR=0x%x) - ignored\n", msr); + V3_Print(core->vm_info, core, "Palacios: Unhandled MSR Write (MSR=0x%x) - ignored\n", msr); // should produce GPF for unsupported msr return 0; } @@ -134,7 +134,7 @@ int v3_hook_msr(struct v3_vm_info * vm, uint32_t msr, hook = (struct v3_msr_hook *)V3_Malloc(sizeof(struct v3_msr_hook)); if (hook == NULL) { - PrintError("Could not allocate msr hook for MSR 0x%x\n", msr); + PrintError(vm, VCORE_NONE,"Could not allocate msr hook for MSR 0x%x\n", msr); return -1; } @@ -177,7 +177,7 @@ int v3_unhook_msr(struct v3_vm_info * vm, uint32_t msr) { struct v3_msr_hook * hook = v3_get_msr_hook(vm, msr); if (hook == NULL) { - PrintError("Could not find MSR to unhook %u (0x%x)\n", msr, msr); + PrintError(vm, VCORE_NONE,"Could not find MSR to unhook %u (0x%x)\n", msr, msr); return -1; } @@ -207,12 +207,12 @@ void v3_refresh_msr_map(struct v3_vm_info * vm) { struct v3_msr_hook * hook = NULL; if (msr_map->update_map == NULL) { - PrintError("Trying to refresh an MSR map with no backend\n"); + PrintError(vm, VCORE_NONE, "Trying to refresh an MSR map with no backend\n"); return; } list_for_each_entry(hook, &(msr_map->hook_list), link) { - PrintDebug("updating MSR map for msr 0x%x\n", hook->msr); + PrintDebug(vm, VCORE_NONE, "updating MSR map for msr 0x%x\n", hook->msr); msr_map->update_map(vm, hook->msr, (hook->read == NULL) ? 0 : 1, (hook->write == NULL) ? 0 : 1); @@ -224,7 +224,7 @@ void v3_print_msr_map(struct v3_vm_info * vm) { struct v3_msr_hook * hook = NULL; list_for_each_entry(hook, &(msr_map->hook_list), link) { - V3_Print("MSR HOOK (MSR=0x%x) (read=0x%p) (write=0x%p)\n", + V3_Print(vm, VCORE_NONE, "MSR HOOK (MSR=0x%x) (read=0x%p) (write=0x%p)\n", hook->msr, hook->read, hook->write); } } diff --git a/palacios/src/palacios/vmm_multitree.c b/palacios/src/palacios/vmm_multitree.c index c448e62..06ee0c4 100644 --- a/palacios/src/palacios/vmm_multitree.c +++ b/palacios/src/palacios/vmm_multitree.c @@ -57,11 +57,11 @@ struct v3_mtree * v3_mtree_create_node(struct v3_mtree * root, char * name) { struct v3_mtree * ret = NULL; - PrintDebug("Creating Node %s\n", name); + PrintDebug(VM_NONE, VCORE_NONE, "Creating Node %s\n", name); if (!node) { - PrintError("Cannot allocate multitree node\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate multitree node\n"); return NULL; } @@ -69,16 +69,16 @@ struct v3_mtree * v3_mtree_create_node(struct v3_mtree * root, char * name) { strncpy(node->name, name, V3_MTREE_NAME_LEN); if ((ret = __insert_mtree_node(root, node))) { - PrintError("Insertion failure\n"); + PrintError(VM_NONE, VCORE_NONE, "Insertion failure\n"); V3_Free(node); return NULL; } - PrintDebug("Node (%s)=%p, root=%p, root->child=%p\n", node->name, node, root, root->child.rb_node); + PrintDebug(VM_NONE, VCORE_NONE, "Node (%s)=%p, root=%p, root->child=%p\n", node->name, node, root, root->child.rb_node); v3_rb_insert_color(&(node->tree_node), &(root->child)); - PrintDebug("balanced\n"); + PrintDebug(VM_NONE, VCORE_NONE, "balanced\n"); return node; } @@ -87,7 +87,7 @@ struct v3_mtree * v3_mtree_create_node(struct v3_mtree * root, char * name) { struct v3_mtree * v3_mtree_create_subtree(struct v3_mtree * root, char * name) { struct v3_mtree * node = NULL; - PrintDebug("Creating Subtree %s\n", name); + PrintDebug(VM_NONE, VCORE_NONE, "Creating Subtree %s\n", name); node = v3_mtree_create_node(root, name); if (node == NULL) { @@ -104,7 +104,7 @@ struct v3_mtree * v3_mtree_create_value(struct v3_mtree * root, char * name, uint64_t size, void * value) { struct v3_mtree * node = NULL; - PrintDebug("Creating value %s\n", name); + PrintDebug(VM_NONE, VCORE_NONE, "Creating value %s\n", name); node = v3_mtree_create_node(root, name); if (node == NULL) { @@ -124,7 +124,7 @@ struct v3_mtree * v3_mtree_find_node(struct v3_mtree * root, char * name) { struct v3_mtree * tmp_node = NULL; if (root->subtree == 0) { - PrintError("Searching for node on a non-root mtree (search=%s), root=%s\n", name, root->name); + PrintError(VM_NONE, VCORE_NONE, "Searching for node on a non-root mtree (search=%s), root=%s\n", name, root->name); return NULL; } diff --git a/palacios/src/palacios/vmm_mwait.c b/palacios/src/palacios/vmm_mwait.c index 3196ae2..78e78c5 100644 --- a/palacios/src/palacios/vmm_mwait.c +++ b/palacios/src/palacios/vmm_mwait.c @@ -30,7 +30,7 @@ // int v3_handle_mwait(struct guest_info * info) { - PrintDebug("Raising undefined opcode due to mwait instruction\n"); + PrintDebug(info->vm_info, info, "Raising undefined opcode due to mwait instruction\n"); v3_raise_exception(info, UD_EXCEPTION ); @@ -42,7 +42,7 @@ int v3_handle_mwait(struct guest_info * info) // int v3_handle_monitor(struct guest_info * info) { - PrintDebug("Raising undefined opcode due to monitor instruction\n"); + PrintDebug(info->vm_info, info, "Raising undefined opcode due to monitor instruction\n"); v3_raise_exception(info, UD_EXCEPTION ); diff --git a/palacios/src/palacios/vmm_paging.c b/palacios/src/palacios/vmm_paging.c index 417c2f9..70d6730 100644 --- a/palacios/src/palacios/vmm_paging.c +++ b/palacios/src/palacios/vmm_paging.c @@ -60,13 +60,13 @@ void delete_page_tables_32(pde32_t * pde) { return; } - PrintDebug("Deleting Page Tables (32) -- PDE (%p)\n", pde); + PrintDebug(VM_NONE, VCORE_NONE, "Deleting Page Tables (32) -- PDE (%p)\n", pde); for (i = 0; i < MAX_PDE32_ENTRIES; i++) { if ((pde[i].present == 1) && (pde[i].large_page == 0)) { // We double cast, first to an addr_t to handle 64 bit issues, then to the pointer - PrintDebug("Deleting PT Page %d (%p)\n", i, (void *)(addr_t)BASE_TO_PAGE_ADDR_4KB(pde[i].pt_base_addr)); + PrintDebug(VM_NONE, VCORE_NONE, "Deleting PT Page %d (%p)\n", i, (void *)(addr_t)BASE_TO_PAGE_ADDR_4KB(pde[i].pt_base_addr)); V3_FreePages((void *)(addr_t)BASE_TO_PAGE_ADDR_4KB(pde[i].pt_base_addr), 1); } } @@ -81,7 +81,7 @@ void delete_page_tables_32pae(pdpe32pae_t * pdpe) { return; } - PrintDebug("Deleting Page Tables (32 PAE) -- PDPE (%p)\n", pdpe); + PrintDebug(VM_NONE, VCORE_NONE, "Deleting Page Tables (32 PAE) -- PDPE (%p)\n", pdpe); for (i = 0; i < MAX_PDPE32PAE_ENTRIES; i++) { if (pdpe[i].present == 0) { @@ -112,7 +112,7 @@ void delete_page_tables_64(pml4e64_t * pml4) { return; } - PrintDebug("Deleting Page Tables (64) -- PML4 (%p)\n", pml4); + PrintDebug(VM_NONE, VCORE_NONE,"Deleting Page Tables (64) -- PML4 (%p)\n", pml4); for (i = 0; i < MAX_PML4E64_ENTRIES; i++) { if (pml4[i].present == 0) { @@ -162,7 +162,7 @@ static int translate_pt_32_cb(struct guest_info * info, page_type_t type, addr_t *paddr = page_pa + PAGE_OFFSET_4KB(vaddr); return 0; default: - PrintError("Inavlid page type (%s) in tranlate pt 32 callback\n", v3_page_type_to_str(type)); + PrintError(info->vm_info, info, "Inavlid page type (%s) in tranlate pt 32 callback\n", v3_page_type_to_str(type)); return -1; } } @@ -182,7 +182,7 @@ static int translate_pt_32pae_cb(struct guest_info * info, page_type_t type, add *paddr = page_pa + PAGE_OFFSET_4KB(vaddr); return 0; default: - PrintError("Inavlid page type (%s) in translate pt 32pae callback\n", v3_page_type_to_str(type)); + PrintError(info->vm_info, info, "Inavlid page type (%s) in translate pt 32pae callback\n", v3_page_type_to_str(type)); return -1; } } @@ -206,7 +206,7 @@ static int translate_pt_64_cb(struct guest_info * info, page_type_t type, addr_t *paddr = page_pa + PAGE_OFFSET_4KB(vaddr); return 0; default: - PrintError("Inavlid page type (%s) in translate pt 64 callback\n", v3_page_type_to_str(type)); + PrintError(info->vm_info, info, "Inavlid page type (%s) in translate pt 64 callback\n", v3_page_type_to_str(type)); return -1; } } @@ -247,7 +247,7 @@ static int find_pt_cb(struct guest_info * info, page_type_t type, addr_t vaddr, addr_t page_ptr, addr_t page_pa, void * private_data) { struct pt_find_data * pt_data = (struct pt_find_data *)private_data; - PrintDebug("FIND_PT Type=%s, page_pa = %p\n", + PrintDebug(info->vm_info, info, "FIND_PT Type=%s, page_pa = %p\n", v3_page_type_to_str(type), (void *)page_pa); @@ -353,7 +353,7 @@ static int check_pt_32_cb(struct guest_info * info, page_type_t type, addr_t vad case PAGE_4KB: return 0; default: - PrintError("Inavlid page type (%s) in check pt 32 callback\n", v3_page_type_to_str(type)); + PrintError(info->vm_info, info, "Inavlid page type (%s) in check pt 32 callback\n", v3_page_type_to_str(type)); return -1; } @@ -382,7 +382,7 @@ static int check_pt_32pae_cb(struct guest_info * info, page_type_t type, addr_t case PAGE_4KB: return 0; default: - PrintError("Inavlid page type (%s) in check pt 32pae callback\n", v3_page_type_to_str(type)); + PrintError(info->vm_info, info, "Inavlid page type (%s) in check pt 32pae callback\n", v3_page_type_to_str(type)); return -1; } @@ -415,7 +415,7 @@ static int check_pt_64_cb(struct guest_info * info, page_type_t type, addr_t vad case PAGE_4KB: return 0; default: - PrintError("Inavlid page type (%s) in check pt 64 callback\n", v3_page_type_to_str(type)); + PrintError(info->vm_info, info, "Inavlid page type (%s) in check pt 64 callback\n", v3_page_type_to_str(type)); return -1; } @@ -571,7 +571,7 @@ static pt_entry_type_t pte32_lookup(pte32_t * pt, addr_t addr, addr_t * entry) { if (!pte_entry->present) { *entry = 0; - // PrintDebug("Lookup at non present page (index=%d)\n", PTE32_INDEX(addr)); + // PrintDebug(VM_NONE, VCORE_NONE, "Lookup at non present page (index=%d)\n", PTE32_INDEX(addr)); return PT_ENTRY_NOT_PRESENT; } else { *entry = BASE_TO_PAGE_ADDR(pte_entry->page_base_addr); @@ -900,7 +900,7 @@ int v3_drill_host_pt_64(struct guest_info * info, v3_reg_t host_cr3, addr_t vadd if ((ret == callback(info, PAGE_1GB, vaddr, (addr_t)V3_VAddr((void *)host_pde_pa), host_pde_pa, private_data)) != 0) { return (ret == -1) ? -1 : PAGE_1GB; } - PrintError("1 Gigabyte Pages not supported\n"); + PrintError(info->vm_info, info, "1 Gigabyte Pages not supported\n"); return 0; case PT_ENTRY_PAGE: @@ -955,7 +955,7 @@ int v3_drill_guest_pt_32(struct guest_info * info, v3_reg_t guest_cr3, addr_t va if (v3_gpa_to_hva(info, guest_pde_pa, (addr_t *)&guest_pde) == -1) { - PrintError("Could not get virtual address of Guest PDE32 (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PDE32 (PA=%p)\n", (void *)guest_pde_pa); return -1; } @@ -988,7 +988,7 @@ int v3_drill_guest_pt_32(struct guest_info * info, v3_reg_t guest_cr3, addr_t va addr_t page_pa; if (v3_gpa_to_hva(info, guest_pte_pa, (addr_t*)&guest_pte) == -1) { - PrintError("Could not get virtual address of Guest PTE32 (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PTE32 (PA=%p)\n", (void *)guest_pte_pa); return -1; } @@ -1015,7 +1015,7 @@ int v3_drill_guest_pt_32(struct guest_info * info, v3_reg_t guest_cr3, addr_t va } // should never get here - PrintError("End of drill function (guest 32)... Should never have gotten here...\n"); + PrintError(info->vm_info, info, "End of drill function (guest 32)... Should never have gotten here...\n"); return -1; } @@ -1030,7 +1030,7 @@ int v3_drill_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, addr_t int ret = 0; if (v3_gpa_to_hva(info, guest_pdpe_pa, (addr_t*)&guest_pdpe) == -1) { - PrintError("Could not get virtual address of Guest PDPE32PAE (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PDPE32PAE (PA=%p)\n", (void *)guest_pdpe_pa); return -1; } @@ -1049,7 +1049,7 @@ int v3_drill_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, addr_t addr_t guest_pte_pa = 0; if (v3_gpa_to_hva(info, guest_pde_pa, (addr_t *)&guest_pde) == -1) { - PrintError("Could not get virtual Address of Guest PDE32PAE (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual Address of Guest PDE32PAE (PA=%p)\n", (void *)guest_pde_pa); return -1; } @@ -1082,7 +1082,7 @@ int v3_drill_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, addr_t addr_t page_pa; if (v3_gpa_to_hva(info, guest_pte_pa, (addr_t *)&guest_pte) == -1) { - PrintError("Could not get virtual Address of Guest PTE32PAE (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual Address of Guest PTE32PAE (PA=%p)\n", (void *)guest_pte_pa); return -1; } @@ -1109,12 +1109,12 @@ int v3_drill_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, addr_t } } default: - PrintError("Invalid page type for PD32PAE\n"); + PrintError(info->vm_info, info, "Invalid page type for PD32PAE\n"); return -1; } // should never get here - PrintError("End of drill function (guest 32pae)... Should never have gotten here...\n"); + PrintError(info->vm_info, info, "End of drill function (guest 32pae)... Should never have gotten here...\n"); return -1; } @@ -1127,7 +1127,7 @@ int v3_drill_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, addr_t va int ret = 0; if (v3_gpa_to_hva(info, guest_pml4_pa, (addr_t*)&guest_pmle) == -1) { - PrintError("Could not get virtual address of Guest PML4E64 (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PML4E64 (PA=%p)\n", (void *)guest_pml4_pa); return -1; } @@ -1145,7 +1145,7 @@ int v3_drill_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, addr_t va addr_t guest_pde_pa = 0; if (v3_gpa_to_hva(info, guest_pdpe_pa, (addr_t *)&guest_pdp) == -1) { - PrintError("Could not get virtual address of Guest PDPE64 (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PDPE64 (PA=%p)\n", (void *)guest_pdpe_pa); return -1; } @@ -1169,7 +1169,7 @@ int v3_drill_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, addr_t va if ((ret == callback(info, PAGE_1GB, vaddr, large_page_va, large_page_pa, private_data)) != 0) { return (ret == -1) ? -1 : PAGE_1GB; } - PrintError("1 Gigabyte Pages not supported\n"); + PrintError(info->vm_info, info, "1 Gigabyte Pages not supported\n"); return 0; } case PT_ENTRY_PAGE: @@ -1178,7 +1178,7 @@ int v3_drill_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, addr_t va addr_t guest_pte_pa = 0; if (v3_gpa_to_hva(info, guest_pde_pa, (addr_t *)&guest_pde) == -1) { - PrintError("Could not get virtual address of guest PDE64 (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of guest PDE64 (PA=%p)\n", (void *)guest_pde_pa); return -1; } @@ -1210,7 +1210,7 @@ int v3_drill_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, addr_t va addr_t page_pa; if (v3_gpa_to_hva(info, guest_pte_pa, (addr_t *)&guest_pte) == -1) { - PrintError("Could not get virtual address of guest PTE64 (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of guest PTE64 (PA=%p)\n", (void *)guest_pte_pa); return -1; } @@ -1244,7 +1244,7 @@ int v3_drill_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, addr_t va } // should never get here - PrintError("End of drill function (guest 64)... Should never have gotten here...\n"); + PrintError(info->vm_info, info, "End of drill function (guest 64)... Should never have gotten here...\n"); return -1; } @@ -1261,12 +1261,12 @@ int v3_walk_guest_pt_32(struct guest_info * info, v3_reg_t guest_cr3, int ret = 0; if (!callback) { - PrintError("Call back was not specified\n"); + PrintError(info->vm_info, info, "Call back was not specified\n"); return -1; } if (v3_gpa_to_hva(info, guest_pde_pa, (addr_t *)&guest_pde) == -1) { - PrintError("Could not get virtual address of Guest PDE32 (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PDE32 (PA=%p)\n", (void *)guest_pde_pa); return -1; } @@ -1283,7 +1283,7 @@ int v3_walk_guest_pt_32(struct guest_info * info, v3_reg_t guest_cr3, addr_t large_page_va = 0; if (v3_gpa_to_hva(info, large_page_pa, &large_page_va) == -1) { - PrintDebug("Could not get virtual address of Guest 4MB Page (PA=%p)\n", + PrintDebug(info->vm_info, info,"Could not get virtual address of Guest 4MB Page (PA=%p)\n", (void *)large_page_pa); // We'll let it through for data pages because they may be unmapped or hooked large_page_va = 0; @@ -1299,7 +1299,7 @@ int v3_walk_guest_pt_32(struct guest_info * info, v3_reg_t guest_cr3, pte32_t * tmp_pte = NULL; if (v3_gpa_to_hva(info, pte_pa, (addr_t *)&tmp_pte) == -1) { - PrintError("Could not get virtual address of Guest PTE32 (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PTE32 (PA=%p)\n", (void *)pte_pa); return -1; } @@ -1314,7 +1314,7 @@ int v3_walk_guest_pt_32(struct guest_info * info, v3_reg_t guest_cr3, addr_t page_va = 0; if (v3_gpa_to_hva(info, page_pa, &page_va) == -1) { - PrintDebug("Could not get virtual address of Guest 4KB Page (PA=%p)\n", + PrintDebug(info->vm_info, info, "Could not get virtual address of Guest 4KB Page (PA=%p)\n", (void *)page_pa); // We'll let it through for data pages because they may be unmapped or hooked page_va = 0; @@ -1346,12 +1346,12 @@ int v3_walk_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, int ret = 0; if (!callback) { - PrintError("Call back was not specified\n"); + PrintError(info->vm_info, info, "Call back was not specified\n"); return -1; } if (v3_gpa_to_hva(info, guest_pdpe_pa, (addr_t *)&guest_pdpe) == -1) { - PrintError("Could not get virtual address of Guest PDPE32PAE (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PDPE32PAE (PA=%p)\n", (void *)guest_pdpe_pa); return -1; } @@ -1367,7 +1367,7 @@ int v3_walk_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, pde32pae_t * tmp_pde = NULL; if (v3_gpa_to_hva(info, pde_pa, (addr_t *)&tmp_pde) == -1) { - PrintError("Could not get virtual address of Guest PDE32PAE (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PDE32PAE (PA=%p)\n", (void *)pde_pa); return -1; } @@ -1384,7 +1384,7 @@ int v3_walk_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, addr_t large_page_va = 0; if (v3_gpa_to_hva(info, large_page_pa, &large_page_va) == -1) { - PrintDebug("Could not get virtual address of Guest 2MB Page (PA=%p)\n", + PrintDebug(info->vm_info, info,"Could not get virtual address of Guest 2MB Page (PA=%p)\n", (void *)large_page_pa); // We'll let it through for data pages because they may be unmapped or hooked large_page_va = 0; @@ -1400,7 +1400,7 @@ int v3_walk_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, pte32pae_t * tmp_pte = NULL; if (v3_gpa_to_hva(info, pte_pa, (addr_t *)&tmp_pte) == -1) { - PrintError("Could not get virtual address of Guest PTE32PAE (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PTE32PAE (PA=%p)\n", (void *)pte_pa); return -1; } @@ -1415,7 +1415,7 @@ int v3_walk_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, addr_t page_va = 0; if (v3_gpa_to_hva(info, page_pa, &page_va) == -1) { - PrintDebug("Could not get virtual address of Guest 4KB Page (PA=%p)\n", + PrintDebug(info->vm_info, info,"Could not get virtual address of Guest 4KB Page (PA=%p)\n", (void *)page_pa); // We'll let it through for data pages because they may be unmapped or hooked page_va = 0; @@ -1453,12 +1453,12 @@ int v3_walk_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, int ret = 0; if (!callback) { - PrintError("Call back was not specified\n"); + PrintError(info->vm_info, info, "Call back was not specified\n"); return -1; } if (v3_gpa_to_hva(info, guest_pml_pa, (addr_t *)&guest_pml) == -1) { - PrintError("Could not get virtual address of Guest PML464 (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PML464 (PA=%p)\n", (void *)guest_pml); return -1; } @@ -1475,7 +1475,7 @@ int v3_walk_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, if (v3_gpa_to_hva(info, pdpe_pa, (addr_t *)&tmp_pdpe) == -1) { - PrintError("Could not get virtual address of Guest PDPE64 (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PDPE64 (PA=%p)\n", (void *)pdpe_pa); return -1; } @@ -1492,7 +1492,7 @@ int v3_walk_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, addr_t large_page_va = 0; if (v3_gpa_to_hva(info, large_page_pa, &large_page_va) == -1) { - PrintDebug("Could not get virtual address of Guest 1GB page (PA=%p)\n", + PrintDebug(info->vm_info, info,"Could not get virtual address of Guest 1GB page (PA=%p)\n", (void *)large_page_pa); // We'll let it through for data pages because they may be unmapped or hooked large_page_va = 0; @@ -1508,7 +1508,7 @@ int v3_walk_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, pde64_t * tmp_pde = NULL; if (v3_gpa_to_hva(info, pde_pa, (addr_t *)&tmp_pde) == -1) { - PrintError("Could not get virtual address of Guest PDE64 (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PDE64 (PA=%p)\n", (void *)pde_pa); return -1; } @@ -1525,7 +1525,7 @@ int v3_walk_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, addr_t large_page_va = 0; if (v3_gpa_to_hva(info, large_page_pa, &large_page_va) == -1) { - PrintDebug("Could not get virtual address of Guest 2MB page (PA=%p)\n", + PrintDebug(info->vm_info, info,"Could not get virtual address of Guest 2MB page (PA=%p)\n", (void *)large_page_pa); // We'll let it through for data pages because they may be unmapped or hooked large_page_va = 0; @@ -1541,7 +1541,7 @@ int v3_walk_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, pte64_t * tmp_pte = NULL; if (v3_gpa_to_hva(info, pte_pa, (addr_t *)&tmp_pte) == -1) { - PrintError("Could not get virtual address of Guest PTE64 (PA=%p)\n", + PrintError(info->vm_info, info, "Could not get virtual address of Guest PTE64 (PA=%p)\n", (void *)pte_pa); return -1; } @@ -1556,7 +1556,7 @@ int v3_walk_guest_pt_64(struct guest_info * info, v3_reg_t guest_cr3, addr_t page_va = 0; if (v3_gpa_to_hva(info, page_pa, &page_va) == -1) { - PrintDebug("Could not get virtual address of Guest 4KB Page (PA=%p)\n", + PrintDebug(info->vm_info, info,"Could not get virtual address of Guest 4KB Page (PA=%p)\n", (void *)page_pa); // We'll let it through for data pages because they may be unmapped or hooked page_va = 0; @@ -1596,7 +1596,7 @@ int v3_walk_host_pt_32(struct guest_info * info, v3_reg_t host_cr3, int ret = 0; if (!callback) { - PrintError("Call back was not specified\n"); + PrintError(info->vm_info, info, "Call back was not specified\n"); return -1; } @@ -1655,7 +1655,7 @@ int v3_walk_host_pt_32pae(struct guest_info * info, v3_reg_t host_cr3, int ret = 0; if (!callback) { - PrintError("Callback was not specified\n"); + PrintError(info->vm_info, info, "Callback was not specified\n"); return -1; } @@ -1725,7 +1725,7 @@ int v3_walk_host_pt_64(struct guest_info * info, v3_reg_t host_cr3, int ret = 0; if (!callback) { - PrintError("Callback was not specified\n"); + PrintError(info->vm_info, info, "Callback was not specified\n"); return -1; } diff --git a/palacios/src/palacios/vmm_paging_debug.h b/palacios/src/palacios/vmm_paging_debug.h index 6a592b4..adae3c4 100644 --- a/palacios/src/palacios/vmm_paging_debug.h +++ b/palacios/src/palacios/vmm_paging_debug.h @@ -28,7 +28,7 @@ static void PrintPDE32(addr_t virtual_address, pde32_t * pde) { - PrintDebug("PDE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "PDE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n", (void *)virtual_address, (void *)(addr_t) (pde->pt_base_addr << PAGE_POWER), pde->present, @@ -46,7 +46,7 @@ static void PrintPDE32(addr_t virtual_address, pde32_t * pde) static void PrintPTE32(addr_t virtual_address, pte32_t * pte) { - PrintDebug("PTE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, dirty=%x, pteAttribute=%x, globalPage=%x, vmm_info=%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "PTE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, dirty=%x, pteAttribute=%x, globalPage=%x, vmm_info=%x\n", (void *)virtual_address, (void*)(addr_t)(pte->page_base_addr << PAGE_POWER), pte->present, @@ -70,7 +70,7 @@ static void PrintPTE32(addr_t virtual_address, pte32_t * pte) static void PrintPDPE32PAE(addr_t virtual_address, pdpe32pae_t * pdpe) { - PrintDebug("PDPE %p -> %p : present=%x, wt=%x, cd=%x, accessed=%x, kernelInfo=%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "PDPE %p -> %p : present=%x, wt=%x, cd=%x, accessed=%x, kernelInfo=%x\n", (void *)virtual_address, (void *)(addr_t) (pdpe->pd_base_addr << PAGE_POWER), pdpe->present, @@ -82,7 +82,7 @@ static void PrintPDPE32PAE(addr_t virtual_address, pdpe32pae_t * pdpe) static void PrintPDE32PAE(addr_t virtual_address, pde32pae_t * pde) { - PrintDebug("PDE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "PDE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n", (void *)virtual_address, (void *)(addr_t) (pde->pt_base_addr << PAGE_POWER), pde->present, @@ -99,7 +99,7 @@ static void PrintPDE32PAE(addr_t virtual_address, pde32pae_t * pde) static void PrintPTE32PAE(addr_t virtual_address, pte32pae_t * pte) { - PrintDebug("PTE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, dirty=%x, pteAttribute=%x, globalPage=%x, vmm_info=%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "PTE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, dirty=%x, pteAttribute=%x, globalPage=%x, vmm_info=%x\n", (void *)virtual_address, (void*)(addr_t)(pte->page_base_addr << PAGE_POWER), pte->present, @@ -123,7 +123,7 @@ static void PrintPTE32PAE(addr_t virtual_address, pte32pae_t * pte) static void PrintPML4e64(addr_t virtual_address, pml4e64_t * pml) { - PrintDebug("PML4e64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, kernelInfo=%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "PML4e64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, kernelInfo=%x\n", (void *)virtual_address, (void *)(addr_t) (BASE_TO_PAGE_ADDR(pml->pdp_base_addr)), pml->present, @@ -138,7 +138,7 @@ static void PrintPML4e64(addr_t virtual_address, pml4e64_t * pml) static void PrintPDPE64(addr_t virtual_address, pdpe64_t * pdpe) { - PrintDebug("PDPE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage/zero=%x, kernelInfo=%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "PDPE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage/zero=%x, kernelInfo=%x\n", (void *)virtual_address, (void *)(addr_t) (BASE_TO_PAGE_ADDR(pdpe->pd_base_addr)), pdpe->present, @@ -157,7 +157,7 @@ static void PrintPDPE64(addr_t virtual_address, pdpe64_t * pdpe) static void PrintPDE64(addr_t virtual_address, pde64_t * pde) { - PrintDebug("PDE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "PDE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n", (void *)virtual_address, (void *)(addr_t) (BASE_TO_PAGE_ADDR(pde->pt_base_addr)), pde->present, @@ -175,7 +175,7 @@ static void PrintPDE64(addr_t virtual_address, pde64_t * pde) static void PrintPTE64(addr_t virtual_address, pte64_t * pte) { - PrintDebug("PTE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, dirty=%x, pteAttribute=%x, globalPage=%x, vmm_info=%x\n", + PrintDebug(VM_NONE, VCORE_NONE, "PTE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, dirty=%x, pteAttribute=%x, globalPage=%x, vmm_info=%x\n", (void *)virtual_address, (void*)(addr_t)(BASE_TO_PAGE_ADDR(pte->page_base_addr)), pte->present, @@ -207,7 +207,7 @@ static int print_page_walk_cb(struct guest_info * info, page_type_t type, addr_t case PAGE_PML464: { pml4e64_t * pml = (pml4e64_t *)page_ptr; - PrintDebug("PML4E64 Page\n"); + PrintDebug(info->vm_info, info, "PML4E64 Page\n"); for (i = 0; i < MAX_PML4E64_ENTRIES; i++) { tmp_vaddr = (4096 * MAX_PTE64_ENTRIES); tmp_vaddr *= (MAX_PDE64_ENTRIES * MAX_PDPE64_ENTRIES * i); // break apart to avoid int overflow compile errors @@ -220,7 +220,7 @@ static int print_page_walk_cb(struct guest_info * info, page_type_t type, addr_t case PAGE_PDP64: { pdpe64_t * pdp = (pdpe64_t *)page_ptr; - PrintDebug("PDPE64 Page\n"); + PrintDebug(info->vm_info, info, "PDPE64 Page\n"); for (i = 0; i < MAX_PDPE64_ENTRIES; i++) { tmp_vaddr = 4096 * MAX_PTE64_ENTRIES * MAX_PDE64_ENTRIES * i; tmp_vaddr += vaddr; @@ -232,7 +232,7 @@ static int print_page_walk_cb(struct guest_info * info, page_type_t type, addr_t case PAGE_PD64: { pde64_t * pd = (pde64_t *)page_ptr; - PrintDebug("PDE64 Page\n"); + PrintDebug(info->vm_info, info, "PDE64 Page\n"); for (i = 0; i < MAX_PDE64_ENTRIES; i++) { tmp_vaddr = 4096 * MAX_PTE64_ENTRIES * i; tmp_vaddr += vaddr; @@ -244,7 +244,7 @@ static int print_page_walk_cb(struct guest_info * info, page_type_t type, addr_t case PAGE_PT64: { pte64_t * pt = (pte64_t *)page_ptr; - PrintDebug("PTE64 Page\n"); + PrintDebug(info->vm_info, info, "PTE64 Page\n"); for (i = 0; i < MAX_PTE64_ENTRIES; i++) { tmp_vaddr = 4096 * i; tmp_vaddr += vaddr; @@ -259,7 +259,7 @@ static int print_page_walk_cb(struct guest_info * info, page_type_t type, addr_t case PAGE_PDP32PAE: { pdpe32pae_t * pdp = (pdpe32pae_t *)page_ptr; - PrintDebug("PDPE32PAE Page\n"); + PrintDebug(info->vm_info, info, "PDPE32PAE Page\n"); for (i = 0; i < MAX_PDPE32PAE_ENTRIES; i++) { tmp_vaddr = 4096 * MAX_PTE32PAE_ENTRIES * MAX_PDE32PAE_ENTRIES * i; tmp_vaddr += vaddr; @@ -271,7 +271,7 @@ static int print_page_walk_cb(struct guest_info * info, page_type_t type, addr_t case PAGE_PD32PAE: { pde32pae_t * pd = (pde32pae_t *)page_ptr; - PrintDebug("PDE32PAE Page\n"); + PrintDebug(info->vm_info, info, "PDE32PAE Page\n"); for (i = 0; i < MAX_PDE32PAE_ENTRIES; i++) { tmp_vaddr = 4096 * MAX_PTE32PAE_ENTRIES * i; tmp_vaddr += vaddr; @@ -283,7 +283,7 @@ static int print_page_walk_cb(struct guest_info * info, page_type_t type, addr_t case PAGE_PT32PAE: { pte32pae_t * pt = (pte32pae_t *)page_ptr; - PrintDebug("PTE32PAE Page\n"); + PrintDebug(info->vm_info, info, "PTE32PAE Page\n"); for (i = 0; i < MAX_PTE32PAE_ENTRIES; i++) { tmp_vaddr = 4096 * i; tmp_vaddr += vaddr; @@ -298,7 +298,7 @@ static int print_page_walk_cb(struct guest_info * info, page_type_t type, addr_t case PAGE_PD32: { pde32_t * pd = (pde32_t *)page_ptr; - PrintDebug("PDE32 Page\n"); + PrintDebug(info->vm_info, info, "PDE32 Page\n"); for (i = 0; i < MAX_PTE32_ENTRIES; i++) { tmp_vaddr = 4096 * MAX_PTE32_ENTRIES * i; tmp_vaddr += vaddr; @@ -310,7 +310,7 @@ static int print_page_walk_cb(struct guest_info * info, page_type_t type, addr_t case PAGE_PT32: { pte32_t * pt = (pte32_t *)page_ptr; - PrintDebug("PTE32 Page\n"); + PrintDebug(info->vm_info, info, "PTE32 Page\n"); for (i = 0; i < MAX_PTE32_ENTRIES; i++) { tmp_vaddr = 4096 * i; tmp_vaddr += vaddr; @@ -396,7 +396,7 @@ static int print_page_tree_cb(struct guest_info * info, page_type_t type, addr_t break; } default: - PrintDebug("%s %p->%p \n", v3_page_type_to_str(type), (void *)vaddr, (void *)page_pa); + PrintDebug(info->vm_info, info, "%s %p->%p \n", v3_page_type_to_str(type), (void *)vaddr, (void *)page_pa); break; } @@ -411,7 +411,7 @@ void PrintPTEntry(struct guest_info * info, page_type_t type, addr_t vaddr, void void PrintHostPageTables(struct guest_info * info, v3_cpu_mode_t cpu_mode, addr_t cr3) { - PrintDebug("CR3: %p\n", (void *)cr3); + PrintDebug(info->vm_info, info, "CR3: %p\n", (void *)cr3); switch (cpu_mode) { case PROTECTED: v3_walk_host_pt_32(info, cr3, print_page_walk_cb, NULL); @@ -425,14 +425,14 @@ void PrintHostPageTables(struct guest_info * info, v3_cpu_mode_t cpu_mode, addr_ v3_walk_host_pt_64(info, cr3, print_page_walk_cb, NULL); break; default: - PrintError("Unsupported CPU MODE %s\n", v3_cpu_mode_to_str(info->cpu_mode)); + PrintError(info->vm_info, info, "Unsupported CPU MODE %s\n", v3_cpu_mode_to_str(info->cpu_mode)); break; } } void PrintGuestPageTables(struct guest_info * info, addr_t cr3) { - PrintDebug("CR3: %p\n", (void *)cr3); + PrintDebug(info->vm_info, info, "CR3: %p\n", (void *)cr3); switch (info->cpu_mode) { case REAL: case PROTECTED: @@ -447,13 +447,13 @@ void PrintGuestPageTables(struct guest_info * info, addr_t cr3) { v3_walk_guest_pt_64(info, cr3, print_page_walk_cb, NULL); break; default: - PrintError("Unsupported CPU MODE %s\n", v3_cpu_mode_to_str(info->cpu_mode)); + PrintError(info->vm_info, info, "Unsupported CPU MODE %s\n", v3_cpu_mode_to_str(info->cpu_mode)); break; } } void PrintHostPageTree(struct guest_info * info, addr_t virtual_addr, addr_t cr3) { - PrintDebug("CR3: %p\n", (void *)cr3); + PrintDebug(info->vm_info, info, "CR3: %p\n", (void *)cr3); switch (info->cpu_mode) { case PROTECTED: v3_drill_host_pt_32(info, cr3, virtual_addr, print_page_tree_cb, NULL); @@ -467,13 +467,13 @@ void PrintHostPageTree(struct guest_info * info, addr_t virtual_addr, addr_t cr v3_drill_host_pt_64(info, cr3, virtual_addr, print_page_tree_cb, NULL); break; default: - PrintError("Unsupported CPU MODE %s\n", v3_cpu_mode_to_str(info->cpu_mode)); + PrintError(info->vm_info, info, "Unsupported CPU MODE %s\n", v3_cpu_mode_to_str(info->cpu_mode)); break; } } void PrintGuestPageTree(struct guest_info * info, addr_t virtual_addr, addr_t cr3) { - PrintDebug("CR3: %p\n", (void *)cr3); + PrintDebug(info->vm_info, info, "CR3: %p\n", (void *)cr3); switch (info->cpu_mode) { case PROTECTED: v3_drill_guest_pt_32(info, cr3, virtual_addr, print_page_tree_cb, NULL); @@ -487,7 +487,7 @@ void PrintGuestPageTree(struct guest_info * info, addr_t virtual_addr, addr_t cr v3_drill_guest_pt_64(info, cr3, virtual_addr, print_page_tree_cb, NULL); break; default: - PrintError("Unsupported CPU MODE %s\n", v3_cpu_mode_to_str(info->cpu_mode)); + PrintError(info->vm_info, info, "Unsupported CPU MODE %s\n", v3_cpu_mode_to_str(info->cpu_mode)); break; } } diff --git a/palacios/src/palacios/vmm_perftune.c b/palacios/src/palacios/vmm_perftune.c index 0d58f6f..cef9831 100644 --- a/palacios/src/palacios/vmm_perftune.c +++ b/palacios/src/palacios/vmm_perftune.c @@ -38,7 +38,7 @@ void v3_strategy_driven_yield(struct guest_info *core, uint64_t time_since_l v3_yield(core,-1); } default: - PrintError("Unknown yield strategy (%d) using GREEDY\n",core->vm_info->perf_options.yield_strategy.strategy); + PrintError(core->vm_info, core, "Unknown yield strategy (%d) using GREEDY\n",core->vm_info->perf_options.yield_strategy.strategy); v3_yield(core,-1); break; } @@ -76,27 +76,27 @@ static void set_yield(struct v3_vm_info *vm, v3_cfg_tree_t *cfg) if (t) { if (!strcasecmp(t,"greedy")) { vm->perf_options.yield_strategy.strategy = V3_YIELD_STRATEGY_GREEDY; - V3_Print("Setting yield strategy to GREEDY\n"); + V3_Print(vm, VCORE_NONE, "Setting yield strategy to GREEDY\n"); } else if (!strcasecmp(t, "friendly")) { vm->perf_options.yield_strategy.strategy = V3_YIELD_STRATEGY_FRIENDLY; - V3_Print("Setting yield strategy to FRIENDLY\n"); + V3_Print(vm, VCORE_NONE, "Setting yield strategy to FRIENDLY\n"); } else if (!strcasecmp(t, "adaptive")) { vm->perf_options.yield_strategy.strategy = V3_YIELD_STRATEGY_ADAPTIVE; - V3_Print("Setting yield strategy to ADAPTIVE\n"); + V3_Print(vm, VCORE_NONE, "Setting yield strategy to ADAPTIVE\n"); } else { - V3_Print("Unknown yield strategy '%s', using default\n",t); + V3_Print(vm, VCORE_NONE, "Unknown yield strategy '%s', using default\n",t); } } else { - V3_Print("Yield strategy not given, using default\n"); + V3_Print(vm, VCORE_NONE, "Yield strategy not given, using default\n"); } t = v3_cfg_val(cfg, "threshold"); if (t) { vm->perf_options.yield_strategy.threshold_usec = atoi(t); - V3_Print("Setting yield threshold to %llu\n",vm->perf_options.yield_strategy.threshold_usec); + V3_Print(vm, VCORE_NONE, "Setting yield threshold to %llu\n",vm->perf_options.yield_strategy.threshold_usec); } else { - V3_Print("Yield threshold not given, using default\n"); + V3_Print(vm, VCORE_NONE, "Yield threshold not given, using default\n"); } @@ -104,9 +104,9 @@ static void set_yield(struct v3_vm_info *vm, v3_cfg_tree_t *cfg) if (t) { vm->perf_options.yield_strategy.time_usec = atoi(t); - V3_Print("Setting yield time to %llu\n",vm->perf_options.yield_strategy.time_usec); + V3_Print(vm, VCORE_NONE, "Setting yield time to %llu\n",vm->perf_options.yield_strategy.time_usec); } else { - V3_Print("Yield time not given, using default\n"); + V3_Print(vm, VCORE_NONE, "Yield time not given, using default\n"); } @@ -135,7 +135,7 @@ int v3_setup_performance_tuning(struct v3_vm_info *vm, v3_cfg_tree_t *cfg) v3_cfg_tree_t *t = v3_cfg_subtree(cfg,"perftune"); if (!t) { - V3_Print("No performance tuning tree - using defaults\n"); + V3_Print(vm, VCORE_NONE, "No performance tuning tree - using defaults\n"); set_yield_defaults(vm); return 0; } @@ -145,12 +145,12 @@ int v3_setup_performance_tuning(struct v3_vm_info *vm, v3_cfg_tree_t *cfg) while (t) { char *id = v3_cfg_val(t,"name"); if (!id) { - V3_Print("Skipping performance parameter group without name\n"); + V3_Print(vm, VCORE_NONE, "Skipping performance parameter group without name\n"); } else { if (!strcasecmp(id,"yield")) { set_yield(vm,t); } else { - V3_Print("Skipping unknown performance parameter group\n"); + V3_Print(vm, VCORE_NONE, "Skipping unknown performance parameter group\n"); } } t = v3_cfg_next_branch(t); diff --git a/palacios/src/palacios/vmm_queue.c b/palacios/src/palacios/vmm_queue.c index 5414ce9..a4b5144 100644 --- a/palacios/src/palacios/vmm_queue.c +++ b/palacios/src/palacios/vmm_queue.c @@ -32,7 +32,7 @@ struct v3_queue * v3_create_queue() { struct v3_queue * tmp_queue = V3_Malloc(sizeof(struct v3_queue)); if (!tmp_queue) { - PrintError("Cannot allocate a queue\n"); + PrintError(VM_NONE, VCORE_NONE,"Cannot allocate a queue\n"); return NULL; } @@ -42,7 +42,7 @@ struct v3_queue * v3_create_queue() { void v3_deinit_queue(struct v3_queue * queue) { while (v3_dequeue(queue)) { - PrintError("ERROR: Freeing non-empty queue. PROBABLE MEMORY LEAK DETECTED\n"); + PrintError(VM_NONE, VCORE_NONE,"ERROR: Freeing non-empty queue. PROBABLE MEMORY LEAK DETECTED\n"); } v3_lock_deinit(&(queue->lock)); @@ -56,7 +56,7 @@ void v3_enqueue(struct v3_queue * queue, addr_t entry) { unsigned int flags = 0; if (!q_entry) { - PrintError("Cannot allocate a queue entry for enqueue\n"); + PrintError(VM_NONE, VCORE_NONE,"Cannot allocate a queue entry for enqueue\n"); return ; } diff --git a/palacios/src/palacios/vmm_quix86.c b/palacios/src/palacios/vmm_quix86.c index 480955a..bc87cfd 100644 --- a/palacios/src/palacios/vmm_quix86.c +++ b/palacios/src/palacios/vmm_quix86.c @@ -53,7 +53,7 @@ static int decode_string_op(struct guest_info * core, const qx86_insn * qx86_inst, struct x86_instr * instr) { int status = 0; - PrintDebug("String operation\n"); + PrintDebug(info->vm_info, info, "String operation\n"); if (instr->prefixes.rep == 1) { uint64_t a_mask = ~(~0ULL << @@ -71,7 +71,7 @@ static int decode_string_op(struct guest_info * core, if((status = qx86_calculate_linear_address(qx86_inst, 0, (qx86_uint64*)&instr->dst_operand.operand)) != QX86_SUCCESS) { - PrintError("Could not get destination memory operand: " + PrintError(info->vm_info, info, "Could not get destination memory operand: " "qx86_calculate_linear_address: %d\n", status); return -1; } @@ -82,7 +82,7 @@ static int decode_string_op(struct guest_info * core, if((status = qx86_calculate_linear_address(qx86_inst, 1, (qx86_uint64*)&instr->src_operand.operand)) != QX86_SUCCESS) { - PrintError("Could not get source memory operand: " + PrintError(info->vm_info, info, "Could not get source memory operand: " "qx86_calculate_linear_address: %d\n", status); return -1; } @@ -99,7 +99,7 @@ static int decode_string_op(struct guest_info * core, if((status = qx86_calculate_linear_address(qx86_inst, 0, (qx86_uint64*)&instr->dst_operand.operand)) != QX86_SUCCESS) { - PrintError("Could not get destination memory operand: " + PrintError(info->vm_info, info, "Could not get destination memory operand: " "qx86_calculate_linear_address: %d\n", status); return -1; } @@ -119,15 +119,15 @@ static int decode_string_op(struct guest_info * core, } else { - PrintError("Unhandled String OP\n"); + PrintError(info->vm_info, info, "Unhandled String OP\n"); return -1; } #ifdef V3_CONFIG_DEBUG_DECODER - V3_Print("Decoding Instr at %p\n", (void *)core->rip); + V3_Print(info->vm_info, info, "Decoding Instr at %p\n", (void *)core->rip); v3_print_instr(instr); - V3_Print("CS DB FLag=%x\n", core->segments.cs.db); + V3_Print(info->vm_info, info, "CS DB FLag=%x\n", core->segments.cs.db); #endif @@ -144,7 +144,7 @@ static int callback(void *data, int rindex, int subreg, unsigned char *value) { (addr_t*)®_addr, ®_size); if(v3_reg_type == -1) { - PrintError("Callback failed to get register index %d\n", rindex); + PrintError(info->vm_info, info, "Callback failed to get register index %d\n", rindex); return 0; } @@ -157,7 +157,7 @@ static int callback(void *data, int rindex, int subreg, unsigned char *value) { *(uint32_t*)value = ((struct v3_segment*)reg_addr)->limit; break; case QX86_SUBREG_FLAGS: - PrintError("Callback doesn't know how to give flags.\n"); + PrintError(info->vm_info, info, "Callback doesn't know how to give flags.\n"); return 0; case QX86_SUBREG_NONE: { switch(qx86_rtab[rindex].size) { @@ -183,7 +183,7 @@ static inline int qx86_op_to_v3_op(struct guest_info *info, qx86_insn *qx86_insn &(v3_op->operand), &(v3_op->size)); if (v3_reg_type == -1) { - PrintError("Operand %d is an Unhandled Operand: %s\n", op_num, + PrintError(info->vm_info, info, "Operand %d is an Unhandled Operand: %s\n", op_num, qx86_rtab[qx86_op->u.r.rindex].name); v3_op->type = INVALID_OPERAND; return -1; @@ -194,10 +194,10 @@ static inline int qx86_op_to_v3_op(struct guest_info *info, qx86_insn *qx86_insn v3_op->type = REG_OPERAND; } else if(qx86_op->ot == QX86_OPERAND_TYPE_MEMORY) { - PrintDebug("Memory operand (%d)\n", op_num); + PrintDebug(info->vm_info, info, "Memory operand (%d)\n", op_num); if((status = qx86_calculate_linear_address(qx86_insn, op_num, (qx86_uint64*)&v3_op->operand)) != QX86_SUCCESS) { - PrintError("Could not get memory operand %d: " + PrintError(info->vm_info, info, "Could not get memory operand %d: " "qx86_calculate_linear_address() returns %d\n", op_num, status); return -1; } @@ -208,14 +208,14 @@ static inline int qx86_op_to_v3_op(struct guest_info *info, qx86_insn *qx86_insn v3_op->size = qx86_op->u.i.valueSize; if (v3_op->size > 4) { - PrintError("Unhandled 64 bit immediates\n"); + PrintError(info->vm_info, info, "Unhandled 64 bit immediates\n"); return -1; } v3_op->operand = (addr_t)*(uint64_t*)qx86_op->u.i.value; v3_op->type = IMM_OPERAND; } else { - PrintError("Unhandled Operand %d Type %d\n", op_num, qx86_op->ot); + PrintError(info->vm_info, info, "Unhandled Operand %d Type %d\n", op_num, qx86_op->ot); return -1; } @@ -246,7 +246,7 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins case LONG: proc_mode = QX86_SIZE_64; break; default: - PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info, "Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } @@ -263,13 +263,13 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins (info->rip & ~0xfffULL) + 0x1000, &(info->segments.cs)), &instr_ptr2); } if (status == -1) { - PrintError("Could not translate Instruction Address at second stage " + PrintError(info->vm_info, info, "Could not translate Instruction Address at second stage " "translation (%p)\n", (void *)(addr_t)info->rip); return -1; } if(((instr_ptr & ~0xfffUL) + 0x1000) != instr_ptr2) { - PrintError("Note: physical page non-contiguous\n"); + PrintError(info->vm_info, info, "Note: physical page non-contiguous\n"); memcpy(inst_buf, (const void*)instr_ptr, left_in_page); memcpy(inst_buf + left_in_page, (const void*)instr_ptr2, QX86_INSN_SIZE_MAX - left_in_page); @@ -283,14 +283,14 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins int status = qx86_decode(&qx86_inst, proc_mode, (const void*)instr_ptr, QX86_INSN_SIZE_MAX); if(status != QX86_SUCCESS) { - PrintError("qx86_decode() returned %d\n", status); + PrintError(info->vm_info, info, "qx86_decode() returned %d\n", status); return -1; } instr->instr_length = qx86_inst.rawSize; if ((instr->op_type = get_opcode(&qx86_inst)) == V3_INVALID_OP) { - PrintError("Could not get opcode. (mnemonic=%s)\n", + PrintError(info->vm_info, info, "Could not get opcode. (mnemonic=%s)\n", qx86_mtab[qx86_inst.mnemonic].name); return -1; } @@ -328,11 +328,11 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins char buf[128]; int buf_sz = 128; if(qx86_print_intel(&qx86_inst, &opt, buf, &buf_sz) != QX86_SUCCESS) { - PrintDebug("Print failed!\n"); + PrintDebug(info->vm_info, info, "Print failed!\n"); } else { - PrintDebug("Instruction (%p): %s\n", (void*)info->rip, buf); + PrintDebug(info->vm_info, info, "Instruction (%p): %s\n", (void*)info->rip, buf); } - PrintDebug("Operands: dst %p src %p 3rd %p\n", (void*)instr->dst_operand.operand, + PrintDebug(info->vm_info, info, "Operands: dst %p src %p 3rd %p\n", (void*)instr->dst_operand.operand, (void*)instr->src_operand.operand, (void*)instr->third_operand.operand); #endif return 0; @@ -353,7 +353,7 @@ static int get_opcode(qx86_insn *inst) { if(IS_CR(1)) return V3_OP_MOVCR2; - PrintError("Bad operand types for MOV: %d %d\n", inst->operands[0].ot, + PrintError(info->vm_info, info, "Bad operand types for MOV: %d %d\n", inst->operands[0].ot, inst->operands[1].ot); return V3_INVALID_OP; } @@ -481,7 +481,7 @@ static int get_opcode(qx86_insn *inst) { static int qx86_register_to_v3_reg(struct guest_info * info, int qx86_reg, addr_t * v3_reg, uint_t * reg_len) { - PrintDebug("qx86 Register: %s\n", qx86_rtab[qx86_reg].name); + PrintDebug(info->vm_info, info, "qx86 Register: %s\n", qx86_rtab[qx86_reg].name); switch (qx86_reg) { case QX86_REGISTER_INVALID: diff --git a/palacios/src/palacios/vmm_ringbuffer.c b/palacios/src/palacios/vmm_ringbuffer.c index 0797a72..fc33a60 100644 --- a/palacios/src/palacios/vmm_ringbuffer.c +++ b/palacios/src/palacios/vmm_ringbuffer.c @@ -27,7 +27,7 @@ void NO_INST v3_init_ringbuf(struct v3_ringbuf * ring, uint_t size) { ring->buf = V3_Malloc(size); if (!(ring->buf)) { - PrintError("Cannot init a ring buffer\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot init a ring buffer\n"); return; } @@ -43,7 +43,7 @@ struct v3_ringbuf * v3_create_ringbuf(uint_t size) { struct v3_ringbuf * ring = (struct v3_ringbuf *)V3_Malloc(sizeof(struct v3_ringbuf)); if (!ring) { - PrintError("Cannot allocate a ring buffer\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate a ring buffer\n"); return NULL; } @@ -192,7 +192,7 @@ int v3_ringbuf_write(struct v3_ringbuf * ring, uchar_t * src, uint_t len) { if (is_write_loop(ring, write_len)) { int section_len = get_write_section_size(ring); - // PrintDebug("Write loop: write_ptr=%p, src=%p, sec_len=%d\n", + // PrintDebug(info->vm_info, info, "Write loop: write_ptr=%p, src=%p, sec_len=%d\n", // (void *)get_write_ptr(ring),(void*)src, section_len); memcpy(get_write_ptr(ring), src, section_len); @@ -202,7 +202,7 @@ int v3_ringbuf_write(struct v3_ringbuf * ring, uchar_t * src, uint_t len) { ring->end += write_len - section_len; } else { - // PrintDebug("Writing: write_ptr=%p, src=%p, write_len=%d\n", + // PrintDebug(info->vm_info, info, "Writing: write_ptr=%p, src=%p, write_len=%d\n", // (void *)get_write_ptr(ring),(void*)src, write_len); memcpy(get_write_ptr(ring), src, write_len); @@ -223,6 +223,6 @@ void v3_print_ringbuf(struct v3_ringbuf * ring) { for (ctr = 0; ctr < ring->current_len; ctr++) { int index = (ctr + ring->start) % ring->size; - PrintDebug("Entry %d (index=%d): %c\n", ctr, index, ring->buf[index]); + PrintDebug(VM_NONE, VCORE_NONE, "Entry %d (index=%d): %c\n", ctr, index, ring->buf[index]); } } diff --git a/palacios/src/palacios/vmm_shadow_paging.c b/palacios/src/palacios/vmm_shadow_paging.c index 129560b..d87ee11 100644 --- a/palacios/src/palacios/vmm_shadow_paging.c +++ b/palacios/src/palacios/vmm_shadow_paging.c @@ -100,17 +100,17 @@ int V3_init_shdw_paging() { while (tmp_impl != __stop__v3_shdw_pg_impls) { - V3_Print("Registering Shadow Paging Impl (%s)\n", (*tmp_impl)->name); + V3_Print(VM_NONE, VCORE_NONE, "Registering Shadow Paging Impl (%s)\n", (*tmp_impl)->name); if (v3_htable_search(master_shdw_pg_table, (addr_t)((*tmp_impl)->name))) { - PrintError("Multiple instances of shadow paging impl (%s)\n", (*tmp_impl)->name); + PrintError(VM_NONE, VCORE_NONE, "Multiple instances of shadow paging impl (%s)\n", (*tmp_impl)->name); return -1; } if (v3_htable_insert(master_shdw_pg_table, (addr_t)((*tmp_impl)->name), (addr_t)(*tmp_impl)) == 0) { - PrintError("Could not register shadow paging impl (%s)\n", (*tmp_impl)->name); + PrintError(VM_NONE, VCORE_NONE, "Could not register shadow paging impl (%s)\n", (*tmp_impl)->name); return -1; } @@ -138,7 +138,7 @@ static void telemetry_cb(struct v3_vm_info * vm, void * private_data, char * hdr for (i = 0; i < vm->num_cores; i++) { struct guest_info * core = &(vm->cores[i]); - V3_Print("%s Guest Page faults: %d\n", hdr, core->shdw_pg_state.guest_faults); + V3_Print(vm, core, "%s Guest Page faults: %d\n", hdr, core->shdw_pg_state.guest_faults); } } #endif @@ -155,7 +155,7 @@ int v3_init_shdw_pg_state(struct guest_info * core) { state->guest_efer.value = 0x0LL; if (impl->local_init(core) == -1) { - PrintError("Error in Shadow paging local initialization (%s)\n", impl->name); + PrintError(core->vm_info, core, "Error in Shadow paging local initialization (%s)\n", impl->name); return -1; } @@ -173,7 +173,7 @@ int v3_deinit_shdw_pg_state(struct guest_info * core) { struct v3_shdw_pg_impl * impl = core->vm_info->shdw_impl.current_impl; if (impl->local_deinit(core) == -1) { - PrintError("Error deinitializing shadow paging state\n"); + PrintError(core->vm_info, core, "Error deinitializing shadow paging state\n"); return -1; } @@ -190,9 +190,9 @@ int v3_init_shdw_impl(struct v3_vm_info * vm) { char * pg_strat = v3_cfg_val(pg_cfg, "strategy"); struct v3_shdw_pg_impl * impl = NULL; - PrintDebug("Checking if shadow paging requested.\n"); + PrintDebug(vm, VCORE_NONE, "Checking if shadow paging requested.\n"); if ((pg_mode != NULL) && (strcasecmp(pg_mode, "nested") == 0)) { - PrintDebug("Nested paging specified - not initializing shadow paging.\n"); + PrintDebug(vm, VCORE_NONE, "Nested paging specified - not initializing shadow paging.\n"); return 0; } @@ -200,12 +200,12 @@ int v3_init_shdw_impl(struct v3_vm_info * vm) { pg_strat = (char *)default_strategy; } - V3_Print("Initialization of Shadow Paging implementation\n"); + V3_Print(vm, VCORE_NONE,"Initialization of Shadow Paging implementation\n"); impl = (struct v3_shdw_pg_impl *)v3_htable_search(master_shdw_pg_table, (addr_t)pg_strat); if (impl == NULL) { - PrintError("Could not find shadow paging impl (%s)\n", pg_strat); + PrintError(vm, VCORE_NONE, "Could not find shadow paging impl (%s)\n", pg_strat); return -1; } @@ -214,7 +214,7 @@ int v3_init_shdw_impl(struct v3_vm_info * vm) { impl_state->current_impl = impl; if (impl->init(vm, pg_cfg) == -1) { - PrintError("Could not initialize Shadow paging implemenation (%s)\n", impl->name); + PrintError(vm, VCORE_NONE, "Could not initialize Shadow paging implemenation (%s)\n", impl->name); return -1; } @@ -233,7 +233,7 @@ int v3_deinit_shdw_impl(struct v3_vm_info * vm) { } if (impl->deinit(vm) == -1) { - PrintError("Error deinitializing shadow paging implementation\n"); + PrintError(vm, VCORE_NONE,"Error deinitializing shadow paging implementation\n"); return -1; } @@ -318,7 +318,7 @@ int v3_handle_shadow_pagefault(struct guest_info * core, addr_t fault_addr, pf_e rc = impl->handle_pagefault(core, fault_addr, error_code); } else { - PrintError("Invalid Memory mode\n"); + PrintError(core->vm_info, core, "Invalid Memory mode\n"); rc = -1; } @@ -340,7 +340,7 @@ int v3_handle_shadow_invlpg(struct guest_info * core) { if (v3_get_vm_mem_mode(core) != VIRTUAL_MEM) { // Paging must be turned on... // should handle with some sort of fault I think - PrintError("ERROR: INVLPG called in non paged mode\n"); + PrintError(core->vm_info, core, "ERROR: INVLPG called in non paged mode\n"); return -1; } @@ -351,19 +351,19 @@ int v3_handle_shadow_invlpg(struct guest_info * core) { } if (ret == -1) { - PrintError("Could not read instruction into buffer\n"); + PrintError(core->vm_info, core, "Could not read instruction into buffer\n"); return -1; } if (v3_decode(core, (addr_t)instr, &dec_instr) == -1) { - PrintError("Decoding Error\n"); + PrintError(core->vm_info, core, "Decoding Error\n"); return -1; } if ((dec_instr.op_type != V3_OP_INVLPG) || (dec_instr.num_operands != 1) || (dec_instr.dst_operand.type != MEM_OPERAND)) { - PrintError("Decoder Error: Not a valid INVLPG instruction...\n"); + PrintError(core->vm_info, core, "Decoder Error: Not a valid INVLPG instruction...\n"); return -1; } @@ -456,7 +456,7 @@ int v3_register_shadow_paging_event_callback(struct v3_vm_info *vm, struct event_callback *ec = V3_Malloc(sizeof(struct event_callback)); if (!ec) { - PrintError("Unable to allocate for a shadow paging event callback\n"); + PrintError(vm, VCORE_NONE, "Unable to allocate for a shadow paging event callback\n"); return -1; } @@ -488,7 +488,7 @@ int v3_unregister_shadow_paging_event_callback(struct v3_vm_info *vm, } } - PrintError("No callback found!\n"); + PrintError(vm, VCORE_NONE, "No callback found!\n"); return -1; } diff --git a/palacios/src/palacios/vmm_sprintf.c b/palacios/src/palacios/vmm_sprintf.c index 6403007..dbc700f 100644 --- a/palacios/src/palacios/vmm_sprintf.c +++ b/palacios/src/palacios/vmm_sprintf.c @@ -575,35 +575,35 @@ void v3_hexdump(const void * ptr, int length, const char * hdr, int flags) { cp = ptr; for (i = 0; i < length; i+= cols) { if (hdr != NULL) - V3_Print("%s", hdr); + V3_Print(VM_NONE, VCORE_NONE, "%s", hdr); if ((flags & HD_OMIT_COUNT) == 0) - V3_Print("%04x ", i); + V3_Print(VM_NONE, VCORE_NONE, "%04x ", i); if ((flags & HD_OMIT_HEX) == 0) { for (j = 0; j < cols; j++) { k = i + j; if (k < length) - V3_Print("%c%02x", delim, cp[k]); + V3_Print(VM_NONE, VCORE_NONE, "%c%02x", delim, cp[k]); else - V3_Print(" "); + V3_Print(VM_NONE, VCORE_NONE, " "); } } if ((flags & HD_OMIT_CHARS) == 0) { - V3_Print(" |"); + V3_Print(VM_NONE, VCORE_NONE, " |"); for (j = 0; j < cols; j++) { k = i + j; if (k >= length) - V3_Print(" "); + V3_Print(VM_NONE, VCORE_NONE, " "); else if (cp[k] >= ' ' && cp[k] <= '~') - V3_Print("%c", cp[k]); + V3_Print(VM_NONE, VCORE_NONE, "%c", cp[k]); else - V3_Print("."); + V3_Print(VM_NONE, VCORE_NONE, "."); } - V3_Print("|"); + V3_Print(VM_NONE, VCORE_NONE, "|"); } - V3_Print("\n"); + V3_Print(VM_NONE, VCORE_NONE, "\n"); } } diff --git a/palacios/src/palacios/vmm_string.c b/palacios/src/palacios/vmm_string.c index af102f7..01c408c 100644 --- a/palacios/src/palacios/vmm_string.c +++ b/palacios/src/palacios/vmm_string.c @@ -73,7 +73,7 @@ void * memmove(void * dst, const void * src, size_t n) { uint8_t * tmp = (uint8_t *)V3_Malloc(n); if (!tmp) { - PrintError("Cannot allocate in built-in memmove\n"); + PrintError(info->vm_info, info, "Cannot allocate in built-in memmove\n"); return NULL; } @@ -292,7 +292,7 @@ char * strdup(const char * s1) { ret = V3_Malloc(strlen(s1) + 1); if (!ret) { - PrintError("Cannot allocate in built-in strdup\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in built-in strdup\n"); return NULL; } diff --git a/palacios/src/palacios/vmm_symbiotic.c b/palacios/src/palacios/vmm_symbiotic.c index 8fda86e..6ef8c44 100644 --- a/palacios/src/palacios/vmm_symbiotic.c +++ b/palacios/src/palacios/vmm_symbiotic.c @@ -52,20 +52,20 @@ int v3_init_symbiotic_vm(struct v3_vm_info * vm) { v3_hook_cpuid(vm, SYM_CPUID_NUM, cpuid_fn, NULL); if (v3_init_symspy_vm(vm, &(vm_state->symspy_state)) == -1) { - PrintError("Error initializing global SymSpy state\n"); + PrintError(vm,VCORE_NONE, "Error initializing global SymSpy state\n"); return -1; } #ifdef V3_CONFIG_SYMCALL if (v3_init_symcall_vm(vm) == -1) { - PrintError("Error intializing global SymCall state\n"); + PrintError(vm, VCORE_NONE, "Error intializing global SymCall state\n"); return -1; } #endif #ifdef V3_CONFIG_SYMMOD if (v3_init_symmod_vm(vm, vm->cfg_data->cfg) == -1) { - PrintError("Error initializing global SymMod state\n"); + PrintError(vm, VCORE_NONE, "Error initializing global SymMod state\n"); return -1; } #endif @@ -79,7 +79,7 @@ int v3_deinit_symbiotic_vm(struct v3_vm_info * vm) { #ifdef V3_CONFIG_SYMMOD if (v3_deinit_symmod_vm(vm) == -1) { - PrintError("Error deinitializing global SymMod state\n"); + PrintError(vm, VCORE_NONE, "Error deinitializing global SymMod state\n"); return -1; } #endif @@ -98,7 +98,7 @@ int v3_init_symbiotic_core(struct guest_info * core) { if (v3_init_symspy_core(core, &(core_state->symspy_state)) == -1) { - PrintError("Error intializing local SymSpy state\n"); + PrintError(core->vm_info, core, "Error intializing local SymSpy state\n"); return -1; } diff --git a/palacios/src/palacios/vmm_symcall.c b/palacios/src/palacios/vmm_symcall.c index 7044e9a..3d64c1f 100644 --- a/palacios/src/palacios/vmm_symcall.c +++ b/palacios/src/palacios/vmm_symcall.c @@ -18,9 +18,12 @@ */ #include +#include #include #include #include +#include +#include // A succesfull symcall returns via the RET_HCALL, with the return values in registers // A symcall error returns via the ERR_HCALL with the error code in rbx @@ -88,7 +91,7 @@ static int symcall_msr_write(struct guest_info * core, uint_t msr, struct v3_msr state->sym_call_fs = src.value; break; default: - PrintError("Invalid Symbiotic MSR write (0x%x)\n", msr); + PrintError(core->vm_info, core, "Invalid Symbiotic MSR write (0x%x)\n", msr); return -1; } return 0; @@ -123,7 +126,7 @@ int v3_init_symcall_vm(struct v3_vm_info * vm) { static int sym_call_err(struct guest_info * core, uint_t hcall_id, void * private_data) { struct v3_symcall_state * state = (struct v3_symcall_state *)&(core->sym_core_state.symcall_state); - PrintError("sym call error\n"); + PrintError(core->vm_info, core, "sym call error\n"); state->sym_call_errno = (int)core->vm_regs.rbx; v3_print_guest_state(core); @@ -139,7 +142,7 @@ static int sym_call_err(struct guest_info * core, uint_t hcall_id, void * privat static int sym_call_ret(struct guest_info * core, uint_t hcall_id, void * private_data) { struct v3_symcall_state * state = (struct v3_symcall_state *)&(core->sym_core_state.symcall_state); - // PrintError("Return from sym call (ID=%x)\n", hcall_id); + // PrintError(info->vm_info, info, "Return from sym call (ID=%x)\n", hcall_id); // v3_print_guest_state(info); state->sym_call_returned = 1; @@ -152,7 +155,7 @@ static int execute_symcall(struct guest_info * core) { while (state->sym_call_returned == 0) { if (v3_vm_enter(core) == -1) { - PrintError("Error in Sym call\n"); + PrintError(core->vm_info, core, "Error in Sym call\n"); return -1; } } @@ -177,12 +180,12 @@ static int translate_segment(struct guest_info * info, uint16_t selector, struct sel.value = selector; if (sel.ti == 1) { - PrintError("LDT translations not supported\n"); + PrintError(info->vm_info, info, "LDT translations not supported\n"); return -1; } if (v3_gva_to_hva(info, gdt->base, &gdt_addr) == -1) { - PrintError("Unable to translate GDT address\n"); + PrintError(info->vm_info, info, "Unable to translate GDT address\n"); return -1; } @@ -230,7 +233,7 @@ int v3_sym_call(struct guest_info * core, struct v3_segment sym_ss; uint64_t trash_args[5] = { [0 ... 4] = 0 }; - // PrintDebug("Making Sym call\n"); + // PrintDebug(core->vm_info, core, "Making Sym call\n"); // v3_print_guest_state(info); if ((symspy_state->local_page->sym_call_enabled == 0) || @@ -279,12 +282,12 @@ int v3_sym_call(struct guest_info * core, state->sym_call_active = 1; state->sym_call_returned = 0; - // PrintDebug("Sym state\n"); + // PrintDebug(core->vm_info, core, "Sym state\n"); // v3_print_guest_state(core); // Do the sym call entry if (execute_symcall(core) == -1) { - PrintError("SYMCALL error\n"); + PrintError(core->vm_info, core, "SYMCALL error\n"); return -1; } @@ -309,7 +312,7 @@ int v3_sym_call(struct guest_info * core, - // PrintError("restoring guest state\n"); + // PrintError(core->vm_info, core, "restoring guest state\n"); // v3_print_guest_state(core); return 0; diff --git a/palacios/src/palacios/vmm_symmod.c b/palacios/src/palacios/vmm_symmod.c index 36a7685..82d2f35 100644 --- a/palacios/src/palacios/vmm_symmod.c +++ b/palacios/src/palacios/vmm_symmod.c @@ -62,7 +62,7 @@ int V3_init_symmod() { int i = 0; if (tmp_def == __stop__v3_capsules) { - PrintDebug("No Symbiotic capsules found\n"); + PrintDebug(VM_NONE, VCORE_NONE, "No Symbiotic capsules found\n"); return 0; } @@ -72,7 +72,7 @@ int V3_init_symmod() { struct v3_sym_capsule * capsule = NULL; if (v3_htable_search(capsule_table, (addr_t)(tmp_def->name))) { - PrintError("Multiple instances of Module (%s)\n", tmp_def->name); + PrintError(VM_NONE, VCORE_NONE, "Multiple instances of Module (%s)\n", tmp_def->name); return -1; } @@ -80,7 +80,7 @@ int V3_init_symmod() { capsule = V3_Malloc(sizeof(struct v3_sym_capsule)); if (!capsule) { - PrintError("Cannot allocate in initializing symmod\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in initializing symmod\n"); return -1; } @@ -102,16 +102,16 @@ int V3_init_symmod() { capsule->guest_size = capsule->size; capsule->capsule_data = NULL; } else { - V3_Free(capsule) + V3_Free(capsule); return -1; } - PrintDebug("Registering Symbiotic Module (%s)\n", tmp_def->name); + PrintDebug(VM_NONE, VCORE_NONE, "Registering Symbiotic Module (%s)\n", tmp_def->name); if (v3_htable_insert(capsule_table, (addr_t)(tmp_def->name), (addr_t)(capsule)) == 0) { - PrintError("Could not insert module %s to master list\n", tmp_def->name); + PrintError(VM_NONE, VCORE_NONE, "Could not insert module %s to master list\n", tmp_def->name); V3_Free(capsule); return -1; } @@ -166,7 +166,7 @@ static int symbol_hcall_handler(struct guest_info * core, hcall_id_t hcall_id, v int i = 0; - PrintError("Received SYMMOD symbol tables addr=%p, size=%d\n", (void *)sym_start_gva, sym_size); + PrintError(core->vm_info, core, "Received SYMMOD symbol tables addr=%p, size=%d\n", (void *)sym_start_gva, sym_size); for (i = 0; i < sym_size; i++) { char * sym_name = NULL; @@ -176,21 +176,21 @@ static int symbol_hcall_handler(struct guest_info * core, hcall_id_t hcall_id, v if (v3_gva_to_hva(core, sym_gva, (addr_t *)&(tmp_symbol)) == -1) { - PrintError("Could not locate symbiotic symbol definition\n"); + PrintError(core->vm_info, core, "Could not locate symbiotic symbol definition\n"); continue; } if (v3_gva_to_hva(core, tmp_symbol->name_gva, (addr_t *)&(sym_name)) == -1) { - PrintError("Could not locate symbiotic symbol name\n"); + PrintError(core->vm_info, core, "Could not locate symbiotic symbol name\n"); continue; } - PrintError("Symbiotic Symbol (%s) at %p\n", sym_name, (void *)(addr_t)tmp_symbol->value); + PrintError(core->vm_info, core, "Symbiotic Symbol (%s) at %p\n", sym_name, (void *)(addr_t)tmp_symbol->value); new_symbol = (struct v3_symbol *)V3_Malloc(sizeof(struct v3_symbol)); if (!new_symbol) { - PrintError("Cannot allocate in symbiotic hcall handler\n"); + PrintError(core->vm_info, core, "Cannot allocate in symbiotic hcall handler\n"); return -1; } @@ -214,11 +214,11 @@ int v3_init_symmod_vm(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { // Add modules to local hash table, should be keyed to config list_for_each_entry(tmp_capsule, &capsule_list, node) { - V3_Print("Adding %s to local module table\n", tmp_capsule->name); + V3_Print(vm, VCORE_NONE, "Adding %s to local module table\n", tmp_capsule->name); if (v3_htable_insert(symmod_state->capsule_table, (addr_t)(tmp_capsule->name), (addr_t)(tmp_capsule)) == 0) { - PrintError("Could not insert module %s to vm local list\n", tmp_capsule->name); + PrintError(vm, VCORE_NONE, "Could not insert module %s to vm local list\n", tmp_capsule->name); return -1; } symmod_state->num_avail_capsules++; @@ -231,7 +231,7 @@ int v3_init_symmod_vm(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { INIT_LIST_HEAD(&(symmod_state->v3_sym_list)); - V3_Print("Symmod initialized\n"); + V3_Print(vm, VCORE_NONE, "Symmod initialized\n"); return 0; } @@ -272,11 +272,11 @@ int v3_load_sym_capsule(struct v3_vm_info * vm, char * name) { struct v3_sym_capsule * capsule = (struct v3_sym_capsule *)v3_htable_search(capsule_table, (addr_t)name); if (!capsule) { - PrintError("Could not find capsule %s\n", name); + PrintError(vm, VCORE_NONE, "Could not find capsule %s\n", name); return -1; } - PrintDebug("Loading Capsule (%s)\n", name); + PrintDebug(vm, VCORE_NONE, "Loading Capsule (%s)\n", name); return symmod_state->loader_ops->load_capsule(vm, capsule, symmod_state->loader_data); } @@ -292,7 +292,7 @@ struct v3_sym_capsule * v3_get_sym_capsule(struct v3_vm_info * vm, char * name) struct v3_sym_capsule * mod = (struct v3_sym_capsule *)v3_htable_search(capsule_table, (addr_t)name); if (!mod) { - PrintError("Could not find module %s\n", name); + PrintError(vm, VCORE_NONE, "Could not find module %s\n", name); return NULL; } diff --git a/palacios/src/palacios/vmm_symspy.c b/palacios/src/palacios/vmm_symspy.c index 1698d0b..58f8aed 100644 --- a/palacios/src/palacios/vmm_symspy.c +++ b/palacios/src/palacios/vmm_symspy.c @@ -52,7 +52,7 @@ static int symspy_msr_write(struct guest_info * core, uint_t msr, struct v3_msr if (msr == SYMSPY_GLOBAL_MSR) { struct v3_symspy_global_state * global_state = &(core->vm_info->sym_vm_state.symspy_state); - PrintDebug("Symbiotic Glbal MSR write for page %p\n", (void *)(addr_t)src.value); + PrintDebug(core->vm_info, core, "Symbiotic Glbal MSR write for page %p\n", (void *)(addr_t)src.value); if (global_state->active == 1) { // unmap page @@ -60,7 +60,7 @@ static int symspy_msr_write(struct guest_info * core, uint_t msr, struct v3_msr (addr_t)global_state->global_guest_pa); if (old_reg == NULL) { - PrintError("Could not find previously active symbiotic page (%p)\n", + PrintError(core->vm_info, core, "Could not find previously active symbiotic page (%p)\n", (void *)(addr_t)global_state->global_guest_pa); return -1; } @@ -80,7 +80,7 @@ static int symspy_msr_write(struct guest_info * core, uint_t msr, struct v3_msr } else if (msr == SYMSPY_LOCAL_MSR) { struct v3_symspy_local_state * local_state = &(core->sym_core_state.symspy_state); - PrintDebug("Symbiotic Local MSR write for page %p\n", (void *)(addr_t)src.value); + PrintDebug(core->vm_info, core, "Symbiotic Local MSR write for page %p\n", (void *)(addr_t)src.value); if (local_state->active == 1) { // unmap page @@ -88,7 +88,7 @@ static int symspy_msr_write(struct guest_info * core, uint_t msr, struct v3_msr (addr_t)local_state->local_guest_pa); if (old_reg == NULL) { - PrintError("Could not find previously active symbiotic page (%p)\n", + PrintError(core->vm_info, core, "Could not find previously active symbiotic page (%p)\n", (void *)(addr_t)local_state->local_guest_pa); return -1; } @@ -106,7 +106,7 @@ static int symspy_msr_write(struct guest_info * core, uint_t msr, struct v3_msr (addr_t)(local_state->local_guest_pa + PAGE_SIZE_4KB - 1), local_state->local_page_pa); } else { - PrintError("Invalid Symbiotic MSR write (0x%x)\n", msr); + PrintError(core->vm_info, core, "Invalid Symbiotic MSR write (0x%x)\n", msr); return -1; } @@ -119,7 +119,7 @@ int v3_init_symspy_vm(struct v3_vm_info * vm, struct v3_symspy_global_state * st state->global_page_pa = (addr_t)V3_AllocPages(1); if (!state->global_page_pa) { - PrintError("Cannot allocate page\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate page\n"); return -1; } @@ -140,7 +140,7 @@ int v3_init_symspy_core(struct guest_info * core, struct v3_symspy_local_state * state->local_page_pa = (addr_t)V3_AllocPages(1); if (!state->local_page_pa) { - PrintError("Cannot allocate page\n"); + PrintError(core->vm_info, core, "Cannot allocate page\n"); return -1; } state->local_page = (struct v3_symspy_local_page *)V3_VAddr((void *)state->local_page_pa); @@ -160,17 +160,17 @@ int v3_sym_map_pci_passthrough(struct v3_vm_info * vm, uint_t bus, uint_t dev, u uint_t minor = dev_index % 8; if (bus > 3) { - PrintError("Invalid PCI bus %d\n", bus); + PrintError(vm, VCORE_NONE, "Invalid PCI bus %d\n", bus); return -1; } - PrintDebug("Setting passthrough pci map for index=%d\n", dev_index); + PrintDebug(vm, VCORE_NONE, "Setting passthrough pci map for index=%d\n", dev_index); global_state->sym_page->pci_pt_map[major] |= 0x1 << minor; - PrintDebug("pt_map entry=%x\n", global_state->sym_page->pci_pt_map[major]); + PrintDebug(vm, VCORE_NONE, "pt_map entry=%x\n", global_state->sym_page->pci_pt_map[major]); - PrintDebug("pt map vmm addr=%p\n", global_state->sym_page->pci_pt_map); + PrintDebug(vm, VCORE_NONE, "pt map vmm addr=%p\n", global_state->sym_page->pci_pt_map); return 0; } @@ -182,7 +182,7 @@ int v3_sym_unmap_pci_passthrough(struct v3_vm_info * vm, uint_t bus, uint_t dev, uint_t minor = dev_index % 8; if (bus > 3) { - PrintError("Invalid PCI bus %d\n", bus); + PrintError(vm, VCORE_NONE, "Invalid PCI bus %d\n", bus); return -1; } diff --git a/palacios/src/palacios/vmm_telemetry.c b/palacios/src/palacios/vmm_telemetry.c index 1fb128a..988090f 100644 --- a/palacios/src/palacios/vmm_telemetry.c +++ b/palacios/src/palacios/vmm_telemetry.c @@ -163,7 +163,7 @@ static inline struct exit_event * create_exit(uint_t exit_code) { struct exit_event * evt = V3_Malloc(sizeof(struct exit_event)); if (!evt) { - PrintError("Cannot allocate in createing exit in telemetry\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in createing exit in telemetry\n"); return NULL; } @@ -225,7 +225,7 @@ void v3_add_telemetry_cb(struct v3_vm_info * vm, struct telemetry_cb * cb = (struct telemetry_cb *)V3_Malloc(sizeof(struct telemetry_cb)); if (!cb) { - PrintError("Cannot allocate in adding a telemtry callback\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate in adding a telemtry callback\n"); return ; } @@ -256,13 +256,13 @@ static void print_telemetry_start(struct v3_vm_info *vm, char *hdr_buf) struct v3_telemetry_state * telemetry = &(vm->telemetry); uint64_t invoke_tsc = 0; rdtscll(invoke_tsc); - V3_Print("%stelemetry window tsc cnt: %u\n", hdr_buf, (uint32_t)(invoke_tsc - telemetry->prev_tsc)); + V3_Print(vm, VCORE_NONE, "%stelemetry window tsc cnt: %u\n", hdr_buf, (uint32_t)(invoke_tsc - telemetry->prev_tsc)); telemetry->prev_tsc = invoke_tsc; } static void print_telemetry_end(struct v3_vm_info *vm, char *hdr_buf) { - V3_Print("%s Telemetry done\n", hdr_buf); + V3_Print(vm, VCORE_NONE, "%s Telemetry done\n", hdr_buf); } static void print_core_telemetry(struct guest_info * core, char *hdr_buf) @@ -270,10 +270,10 @@ static void print_core_telemetry(struct guest_info * core, char *hdr_buf) struct exit_event * evt = NULL; struct rb_node * node = v3_rb_first(&(core->core_telem.exit_root)); - V3_Print("Exit information for Core %d\n", core->vcpu_id); + V3_Print(core->vm_info, core, "Exit information for Core %d\n", core->vcpu_id); if (!node) { - V3_Print("No information yet for this core\n"); + V3_Print(core->vm_info, core, "No information yet for this core\n"); return; } @@ -299,7 +299,7 @@ static void print_core_telemetry(struct guest_info * core, char *hdr_buf) continue; } - V3_Print("%s%s:%sCnt=%u,%sAvg. Time=%u\n", + V3_Print(core->vm_info, core, "%s%s:%sCnt=%u,%sAvg. Time=%u\n", hdr_buf, code_str, (strlen(code_str) > 13) ? "\t" : "\t\t", evt->cnt, diff --git a/palacios/src/palacios/vmm_time.c b/palacios/src/palacios/vmm_time.c index 3fb36ce..b2f31a4 100644 --- a/palacios/src/palacios/vmm_time.c +++ b/palacios/src/palacios/vmm_time.c @@ -79,7 +79,7 @@ static int handle_cpufreq_hcall(struct guest_info * info, uint_t hcall_id, void info->vm_regs.rbx = time_state->guest_cpu_freq; - PrintDebug("Guest request cpu frequency: return %ld\n", (long)info->vm_regs.rbx); + PrintDebug(info->vm_info, info, "Guest request cpu frequency: return %ld\n", (long)info->vm_regs.rbx); return 0; } @@ -89,7 +89,7 @@ static int handle_rdhtsc_hcall(struct guest_info * info, uint_t hcall_id, void * info->vm_regs.rbx = v3_get_host_time(time_state); - // PrintDebug("Guest request host TSC: return %ld\n", (long)info->vm_regs.rbx); + // PrintDebug(info->vm_info, info, "Guest request host TSC: return %ld\n", (long)info->vm_regs.rbx); return 0; } @@ -105,7 +105,7 @@ int v3_start_time(struct guest_info * info) { info->time_state.last_update = 0; info->time_state.guest_cycles = 0; - PrintDebug("Starting time for core %d at host time %llu/guest time %llu.\n", + PrintDebug(info->vm_info, info, "Starting time for core %d at host time %llu/guest time %llu.\n", info->vcpu_id, t, info->time_state.guest_cycles); v3_yield(info,-1); return 0; @@ -164,11 +164,11 @@ struct v3_timer * v3_add_timer(struct guest_info * info, timer = (struct v3_timer *)V3_Malloc(sizeof(struct v3_timer)); if (!timer) { - PrintError("Cannot allocate in adding a timer\n"); + PrintError(info->vm_info, info, "Cannot allocate in adding a timer\n"); return NULL; } - V3_ASSERT(timer != NULL); + V3_ASSERT(info->vm_info, info,timer != NULL); timer->ops = ops; timer->private_data = private_data; @@ -196,12 +196,12 @@ void v3_update_timers(struct guest_info * info) { time_state->last_update = v3_get_guest_time(time_state); cycles = (sint64_t)(time_state->last_update - old_time); if (cycles < 0) { - PrintError("Cycles appears to have rolled over - old time %lld, current time %lld.\n", + PrintError(info->vm_info, info, "Cycles appears to have rolled over - old time %lld, current time %lld.\n", old_time, time_state->last_update); return; } - //PrintDebug("Updating timers with %lld elapsed cycles.\n", cycles); + //PrintDebug(info->vm_info, info, "Updating timers with %lld elapsed cycles.\n", cycles); list_for_each_entry(tmp_timer, &(time_state->timers), timer_link) { tmp_timer->ops->update_timer(info, cycles, time_state->guest_cpu_freq, tmp_timer->private_data); } @@ -227,7 +227,7 @@ int v3_rdtsc(struct guest_info * info) { } int v3_handle_rdtsc(struct guest_info * info) { - PrintDebug("Handling virtual RDTSC call.\n"); + PrintDebug(info->vm_info, info, "Handling virtual RDTSC call.\n"); v3_rdtsc(info); info->vm_regs.rax &= 0x00000000ffffffffLL; @@ -263,7 +263,7 @@ int v3_rdtscp(struct guest_info * info) { int v3_handle_rdtscp(struct guest_info * info) { - PrintDebug("Handling virtual RDTSCP call.\n"); + PrintDebug(info->vm_info, info, "Handling virtual RDTSCP call.\n"); v3_rdtscp(info); @@ -280,7 +280,7 @@ static int tsc_aux_msr_read_hook(struct guest_info *info, uint_t msr_num, struct v3_msr *msr_val, void *priv) { struct vm_core_time * time_state = &(info->time_state); - V3_ASSERT(msr_num == TSC_AUX_MSR); + V3_ASSERT(info->vm_info, info,msr_num == TSC_AUX_MSR); msr_val->lo = time_state->tsc_aux.lo; msr_val->hi = time_state->tsc_aux.hi; @@ -292,7 +292,7 @@ static int tsc_aux_msr_write_hook(struct guest_info *info, uint_t msr_num, struct v3_msr msr_val, void *priv) { struct vm_core_time * time_state = &(info->time_state); - V3_ASSERT(msr_num == TSC_AUX_MSR); + V3_ASSERT(info->vm_info, info,msr_num == TSC_AUX_MSR); time_state->tsc_aux.lo = msr_val.lo; time_state->tsc_aux.hi = msr_val.hi; @@ -304,8 +304,8 @@ static int tsc_msr_read_hook(struct guest_info *info, uint_t msr_num, struct v3_msr *msr_val, void *priv) { uint64_t time = v3_get_guest_tsc(&info->time_state); - PrintDebug("Handling virtual TSC MSR read call.\n"); - V3_ASSERT(msr_num == TSC_MSR); + PrintDebug(info->vm_info, info, "Handling virtual TSC MSR read call.\n"); + V3_ASSERT(info->vm_info, info,msr_num == TSC_MSR); msr_val->hi = time >> 32; msr_val->lo = time & 0xffffffffLL; @@ -318,8 +318,8 @@ static int tsc_msr_write_hook(struct guest_info *info, uint_t msr_num, struct vm_core_time * time_state = &(info->time_state); uint64_t guest_time, new_tsc; - PrintDebug("Handling virtual TSC MSR write call.\n"); - V3_ASSERT(msr_num == TSC_MSR); + PrintDebug(info->vm_info, info, "Handling virtual TSC MSR write call.\n"); + V3_ASSERT(info->vm_info, info,msr_num == TSC_MSR); new_tsc = (((uint64_t)msr_val.hi) << 32) | (uint64_t)msr_val.lo; guest_time = v3_get_guest_time(time_state); @@ -342,9 +342,9 @@ handle_time_configuration(struct v3_vm_info * vm, v3_cfg_tree_t *cfg) { if (strcasecmp(source, "none") == 0) { vm->time_state.flags &= ~V3_TIME_SLAVE_HOST; } else if (strcasecmp(source, "host") != 0) { - PrintError("Unknown time source for VM core time management.\n"); + PrintError(vm, VCORE_NONE, "Unknown time source for VM core time management.\n"); } else { - PrintDebug("VM time slaved to host TSC.\n"); + PrintDebug(vm, VCORE_NONE,"VM time slaved to host TSC.\n"); } } @@ -353,18 +353,18 @@ handle_time_configuration(struct v3_vm_info * vm, v3_cfg_tree_t *cfg) { if (tsc) { if (strcasecmp(tsc, "host") == 0) { if (!(vm->time_state.flags & V3_TIME_SLAVE_HOST)) { - PrintError("WARNING: Guest TSC set to passthrough host TSC, but guest time not slaved to host time."); + PrintError(vm, VCORE_NONE, "WARNING: Guest TSC set to passthrough host TSC, but guest time not slaved to host time."); } vm->time_state.flags |= V3_TIME_TSC_PASSTHROUGH; } else if (strcasecmp(source, "guest") != 0) { - PrintError("ERROR: Unknown TSC configuration in time configuration.\n"); + PrintError(vm, VCORE_NONE, "ERROR: Unknown TSC configuration in time configuration.\n"); } } dilation = v3_cfg_val(cfg, "dilation"); if (dilation) { if (!(vm->time_state.flags & VM_TIME_SLAVE_HOST)) { - PrintError("Time dilation only valid when slaved to host time.\n"); + PrintError(vm, VCORE_NONE, "Time dilation only valid when slaved to host time.\n"); } else { uint32_t num = 1, denom = 1; denom = atoi(dilation); @@ -375,11 +375,11 @@ handle_time_configuration(struct v3_vm_info * vm, v3_cfg_tree_t *cfg) { } if ((vm->time_state.td_num != 1) || (vm->time_state.td_denom != 1)) { - V3_Print("Time dilated from host time by a factor of %d/%d" + V3_Print(vm, VCORE_NONE, "Time dilated from host time by a factor of %d/%d" " in guest.\n", vm->time_state.td_denom, vm->time_state.td_num); } else { - PrintError("Time dilation specifier in configuration did not" + PrintError(vm, VCORE_NONE,"Time dilation specifier in configuration did not" " result in actual time dilation in VM.\n"); } } @@ -390,7 +390,7 @@ int v3_init_time_vm(struct v3_vm_info * vm) { v3_cfg_tree_t * cfg_tree = vm->cfg_data->cfg; int ret; - PrintDebug("Installing TSC MSR hook.\n"); + PrintDebug(vm, VCORE_NONE, "Installing TSC MSR hook.\n"); ret = v3_hook_msr(vm, TSC_MSR, tsc_msr_read_hook, tsc_msr_write_hook, NULL); @@ -398,7 +398,7 @@ int v3_init_time_vm(struct v3_vm_info * vm) { return ret; } - PrintDebug("Installing TSC_AUX MSR hook.\n"); + PrintDebug(vm, VCORE_NONE, "Installing TSC_AUX MSR hook.\n"); ret = v3_hook_msr(vm, TSC_AUX_MSR, tsc_aux_msr_read_hook, tsc_aux_msr_write_hook, NULL); @@ -406,10 +406,10 @@ int v3_init_time_vm(struct v3_vm_info * vm) { return ret; } - PrintDebug("Registering TIME_CPUFREQ hypercall.\n"); + PrintDebug(vm, VCORE_NONE, "Registering TIME_CPUFREQ hypercall.\n"); ret = v3_register_hypercall(vm, TIME_CPUFREQ_HCALL, handle_cpufreq_hcall, NULL); - PrintDebug("Registering TIME_RDHTSC hypercall.\n"); + PrintDebug(vm, VCORE_NONE, "Registering TIME_RDHTSC hypercall.\n"); ret = v3_register_hypercall(vm, TIME_RDHTSC_HCALL, handle_rdhtsc_hcall, NULL); @@ -466,7 +466,7 @@ void v3_init_time_core(struct guest_info * info) { if (khz) { time_state->guest_cpu_freq = atoi(khz); - PrintDebug("Logical Core %d (vcpu=%d) CPU frequency requested at %d khz.\n", + PrintDebug(info->vm_info, info, "Logical Core %d (vcpu=%d) CPU frequency requested at %d khz.\n", info->pcpu_id, info->vcpu_id, time_state->guest_cpu_freq); } @@ -491,22 +491,22 @@ void v3_init_time_core(struct guest_info * info) { (info->vm_info->time_state.td_num != 1) || (info->vm_info->time_state.td_denom != 1)) { if (time_state->flags | VM_TIME_TSC_PASSTHROUGH) { - PrintError("WARNING: Cannot use reqested passthrough TSC with clock or time modification also requested.\n"); + PrintError(info->vm_info, info, "WARNING: Cannot use reqested passthrough TSC with clock or time modification also requested.\n"); time_state->flags &= ~VM_TIME_TSC_PASSTHROUGH; } time_state->flags |= VM_TIME_TRAP_RDTSC; } - PrintDebug("Logical Core %d (vcpu=%d) CPU frequency set to %d KHz (host CPU frequency = %d KHz).\n", + PrintDebug(info->vm_info, info, "Logical Core %d (vcpu=%d) CPU frequency set to %d KHz (host CPU frequency = %d KHz).\n", info->pcpu_id, info->vcpu_id, time_state->guest_cpu_freq, time_state->host_cpu_freq); - PrintDebug(" td_mult = %d/%d, cl_mult = %u/%u, ipc_mult = %u/%u.\n", + PrintDebug(info->vm_info, info, " td_mult = %d/%d, cl_mult = %u/%u, ipc_mult = %u/%u.\n", info->vm_info->time_state.td_num, info->vm_info->time_state.td_denom, time_state->clock_ratio_num, time_state->clock_ratio_denom, time_state->ipc_ratio_num, time_state->ipc_ratio_denom); - PrintDebug(" time source = %s, tsc handling = %s\n", + PrintDebug(info->vm_info, info, " time source = %s, tsc handling = %s\n", (time_state->flags & VM_TIME_SLAVE_HOST) ? "host" : "none", (time_state->flags & VM_TIME_TSC_PASSTHROUGH) ? "passthrough" : (time_state->flags & VM_TIME_TRAP_RDTSC) ? "trapping" diff --git a/palacios/src/palacios/vmm_timeout.c b/palacios/src/palacios/vmm_timeout.c index ad951e2..7e0992f 100644 --- a/palacios/src/palacios/vmm_timeout.c +++ b/palacios/src/palacios/vmm_timeout.c @@ -31,7 +31,7 @@ int v3_add_core_timeout(struct guest_info * core, uint64_t cycles, struct v3_core_timeouts * timeouts = &(core->timeouts); if (timeouts->timeout_active) { - PrintError("Tried to activate a timeout whiel one is already active\n"); + PrintError(core->vm_info, core, "Tried to activate a timeout whiel one is already active\n"); return -1; } @@ -40,8 +40,7 @@ int v3_add_core_timeout(struct guest_info * core, uint64_t cycles, timeouts->timeout_active = 1; timeouts->next_timeout = cycles; - return 0; -} + return 0;} @@ -49,7 +48,7 @@ int v3_handle_timeouts(struct guest_info * core, uint64_t guest_cycles) { struct v3_core_timeouts * timeouts = &(core->timeouts); /* - V3_Print("Handling timeout from %llu guest cycles (Next timeout=%llu)\n", guest_cycles, + V3_Print(core->vm_info, core, "Handling timeout from %llu guest cycles (Next timeout=%llu)\n", guest_cycles, timeouts->next_timeout); */ @@ -59,7 +58,7 @@ int v3_handle_timeouts(struct guest_info * core, uint64_t guest_cycles) { if (timeouts->callback) { - V3_Print("Calling timeout callback\n"); + V3_Print(core->vm_info, core, "Calling timeout callback\n"); timeouts->callback(core, timeouts->private_data); } } else { diff --git a/palacios/src/palacios/vmm_util.c b/palacios/src/palacios/vmm_util.c index fb9cce0..678a42b 100644 --- a/palacios/src/palacios/vmm_util.c +++ b/palacios/src/palacios/vmm_util.c @@ -36,7 +36,7 @@ void v3_dump_mem(uint8_t * start, int n) { } snprintf(buf+strlen(buf),128-strlen(buf), "\n"); buf[strlen(buf)]=0; - V3_Print("%s",buf); + V3_Print(VM_NONE, VCORE_NONE, "%s",buf); } } diff --git a/palacios/src/palacios/vmm_v3dec.c b/palacios/src/palacios/vmm_v3dec.c index 343be38..ea6fc53 100644 --- a/palacios/src/palacios/vmm_v3dec.c +++ b/palacios/src/palacios/vmm_v3dec.c @@ -75,7 +75,7 @@ int v3_decode(struct guest_info * core, addr_t instr_ptr, struct x86_instr * ins int length = 0; - PrintDebug("Decoding Instruction at %p\n", (void *)instr_ptr); + PrintDebug(core->vm_info, core, "Decoding Instruction at %p\n", (void *)instr_ptr); memset(instr, 0, sizeof(struct x86_instr)); @@ -102,10 +102,10 @@ int v3_decode(struct guest_info * core, addr_t instr_ptr, struct x86_instr * ins form = op_code_to_form((uint8_t *)(instr_ptr + length), &length); - PrintDebug("\t decoded as (%s)\n", op_form_to_str(form)); + PrintDebug(core->vm_info, core, "\t decoded as (%s)\n", op_form_to_str(form)); if (form == INVALID_INSTR) { - PrintError("Could not find instruction form (%x)\n", *(uint32_t *)(instr_ptr + length)); + PrintError(core->vm_info, core, "Could not find instruction form (%x)\n", *(uint32_t *)(instr_ptr + length)); return -1; } @@ -114,7 +114,7 @@ int v3_decode(struct guest_info * core, addr_t instr_ptr, struct x86_instr * ins ret = parse_operands(core, (uint8_t *)(instr_ptr + length), instr, form); if (ret == -1) { - PrintError("Could not parse instruction operands\n"); + PrintError(core->vm_info, core, "Could not parse instruction operands\n"); return -1; } length += ret; @@ -122,9 +122,9 @@ int v3_decode(struct guest_info * core, addr_t instr_ptr, struct x86_instr * ins instr->instr_length += length; #ifdef V3_CONFIG_DEBUG_DECODER - V3_Print("Decoding Instr at %p\n", (void *)core->rip); + V3_Print(core->vm_info, core, "Decoding Instr at %p\n", (void *)core->rip); v3_print_instr(instr); - V3_Print("CS DB FLag=%x\n", core->segments.cs.db); + V3_Print(core->vm_info, core, "CS DB FLag=%x\n", core->segments.cs.db); #endif return 0; @@ -140,7 +140,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, uint8_t * instr_start = instr_ptr; - PrintDebug("\tOperand width=%d, Addr width=%d\n", operand_width, addr_width); + PrintDebug(core->vm_info, core, "\tOperand width=%d, Addr width=%d\n", operand_width, addr_width); switch (form) { case ADC_IMM2_8: @@ -162,7 +162,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, ret = decode_rm_operand(core, instr_ptr, form, instr, &(instr->dst_operand), ®_code); if (ret == -1) { - PrintError("Error decoding operand\n"); + PrintError(core->vm_info, core, "Error decoding operand\n"); return -1; } @@ -181,7 +181,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, } else if (operand_width == 8) { instr->src_operand.operand = *(sint32_t *)instr_ptr; // This is a special case for sign extended 64bit ops } else { - PrintError("Illegal operand width (%d)\n", operand_width); + PrintError(core->vm_info, core, "Illegal operand width (%d)\n", operand_width); return -1; } @@ -213,7 +213,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, ret = decode_rm_operand(core, instr_ptr, form, instr, &(instr->dst_operand), ®_code); if (ret == -1) { - PrintError("Error decoding operand\n"); + PrintError(core->vm_info, core, "Error decoding operand\n"); return -1; } @@ -250,7 +250,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, ret = decode_rm_operand(core, instr_ptr, form, instr, &(instr->src_operand), ®_code); if (ret == -1) { - PrintError("Error decoding operand\n"); + PrintError(core->vm_info, core, "Error decoding operand\n"); return -1; } @@ -275,7 +275,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, instr->src_operand.size = 1; if (ret == -1) { - PrintError("Error decoding operand\n"); + PrintError(core->vm_info, core, "Error decoding operand\n"); return -1; } @@ -300,7 +300,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, instr->src_operand.size = 2; if (ret == -1) { - PrintError("Error decoding operand\n"); + PrintError(core->vm_info, core, "Error decoding operand\n"); return -1; } @@ -328,7 +328,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, ret = decode_rm_operand(core, instr_ptr, form, instr, &(instr->dst_operand), ®_code); if (ret == -1) { - PrintError("Error decoding operand\n"); + PrintError(core->vm_info, core, "Error decoding operand\n"); return -1; } @@ -384,7 +384,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, ®_code); if (ret == -1) { - PrintError("Error decoding operand for (%s)\n", op_form_to_str(form)); + PrintError(core->vm_info, core, "Error decoding operand for (%s)\n", op_form_to_str(form)); return -1; } @@ -407,7 +407,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, ®_code); if (ret == -1) { - PrintError("Error decoding operand for (%s)\n", op_form_to_str(form)); + PrintError(core->vm_info, core, "Error decoding operand for (%s)\n", op_form_to_str(form)); return -1; } @@ -463,7 +463,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, ret = decode_rm_operand(core, instr_ptr, form, instr, &(instr->dst_operand), ®_code); if (ret == -1) { - PrintError("Error decoding operand for (%s)\n", op_form_to_str(form)); + PrintError(core->vm_info, core, "Error decoding operand for (%s)\n", op_form_to_str(form)); return -1; } @@ -479,7 +479,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, ret = decode_rm_operand(core, instr_ptr, form, instr, &(instr->dst_operand), ®_code); if (ret == -1) { - PrintError("Error decoding operand for (%s)\n", op_form_to_str(form)); + PrintError(core->vm_info, core, "Error decoding operand for (%s)\n", op_form_to_str(form)); return -1; } @@ -495,7 +495,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, break; } default: - PrintError("Invalid Instruction form: %s\n", op_form_to_str(form)); + PrintError(core->vm_info, core, "Invalid Instruction form: %s\n", op_form_to_str(form)); return -1; } diff --git a/palacios/src/palacios/vmm_xed.c b/palacios/src/palacios/vmm_xed.c index 350840b..d5984fd 100644 --- a/palacios/src/palacios/vmm_xed.c +++ b/palacios/src/palacios/vmm_xed.c @@ -130,7 +130,7 @@ static int set_decoder_mode(struct guest_info * info, xed_state_t * state) { break; case LONG: if (state->mmode != XED_MACHINE_MODE_LONG_64) { - PrintDebug("Setting decoder to long mode\n"); + PrintDebug(info->vm_info, info, "Setting decoder to long mode\n"); // state->mmode = XED_MACHINE_MODE_LONG_64; //xed_state_set_machine_mode(state, XED_MACHINE_MODE_LONG_64); xed_state_init(state, @@ -140,7 +140,7 @@ static int set_decoder_mode(struct guest_info * info, xed_state_t * state) { } break; default: - PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info, "Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } return 0; @@ -169,7 +169,7 @@ int v3_init_decoder(struct guest_info * info) { xed_state_t * decoder_state = (xed_state_t *)V3_Malloc(sizeof(xed_state_t)); if (!decoder_state) { - PrintError("Cannot allocate in initializing decoder\n"); + PrintError(info->vm_info, info, "Cannot allocate in initializing decoder\n"); return -1; } @@ -199,19 +199,19 @@ static int decode_string_op(struct guest_info * info, xed_decoded_inst_t * xed_instr, const xed_inst_t * xi, struct x86_instr * instr) { - PrintDebug("String operation\n"); + PrintDebug(info->vm_info, info, "String operation\n"); if (instr->op_type == V3_OP_MOVS) { instr->num_operands = 2; if (get_memory_operand(info, xed_instr, 0, &(instr->dst_operand)) == -1) { - PrintError("Could not get Destination memory operand\n"); + PrintError(info->vm_info, info, "Could not get Destination memory operand\n"); return -1; } if (get_memory_operand(info, xed_instr, 1, &(instr->src_operand)) == -1) { - PrintError("Could not get Source memory operand\n"); + PrintError(info->vm_info, info, "Could not get Source memory operand\n"); return -1; } @@ -232,7 +232,7 @@ static int decode_string_op(struct guest_info * info, instr->num_operands = 2; if (get_memory_operand(info, xed_instr, 0, &(instr->dst_operand)) == -1) { - PrintError("Could not get Destination memory operand\n"); + PrintError(info->vm_info, info, "Could not get Destination memory operand\n"); return -1; } @@ -257,7 +257,7 @@ static int decode_string_op(struct guest_info * info, } } else { - PrintError("Unhandled String OP\n"); + PrintError(info->vm_info, info, "Unhandled String OP\n"); return -1; } @@ -275,7 +275,7 @@ int v3_disasm(struct guest_info * info, void *instr_ptr, addr_t * rip, int mark) /* disassemble the specified instruction */ if (set_decoder_mode(info, info->decoder_state) == -1) { - PrintError("Could not set decoder mode\n"); + PrintError(info->vm_info, info, "Could not set decoder mode\n"); return -1; } @@ -286,27 +286,27 @@ int v3_disasm(struct guest_info * info, void *instr_ptr, addr_t * rip, int mark) XED_MAX_INSTRUCTION_BYTES); if (xed_error != XED_ERROR_NONE) { - PrintError("Xed error: %s\n", xed_error_enum_t2str(xed_error)); + PrintError(info->vm_info, info, "Xed error: %s\n", xed_error_enum_t2str(xed_error)); return -1; } /* obtain string representation in AT&T syntax */ if (!xed_format_att(&xed_instr, buffer, sizeof(buffer), *rip)) { - PrintError("Xed error: cannot disaaemble\n"); + PrintError(info->vm_info, info, "Xed error: cannot disaaemble\n"); return -1; } /* print address, opcode bytes and the disassembled instruction */ length = xed_decoded_inst_get_length(&xed_instr); - V3_Print("0x%p %c ", (void *) *rip, mark ? '*' : ' '); + V3_Print(info->vm_info, info, "0x%p %c ", (void *) *rip, mark ? '*' : ' '); for (i = 0; i < length; i++) { unsigned char b = ((unsigned char *) instr_ptr)[i]; - V3_Print("%x%x ", b >> 4, b & 0xf); + V3_Print(info->vm_info, info, "%x%x ", b >> 4, b & 0xf); } while (i++ < 8) { - V3_Print(" "); + V3_Print(info->vm_info, info, " "); } - V3_Print("%s\n", buffer); + V3_Print(info->vm_info, info, "%s\n", buffer); /* move on to next instruction */ *rip += length; @@ -325,7 +325,7 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins v3_get_prefixes((uchar_t *)instr_ptr, &(instr->prefixes)); if (set_decoder_mode(info, info->decoder_state) == -1) { - PrintError("Could not set decoder mode\n"); + PrintError(info->vm_info, info, "Could not set decoder mode\n"); return -1; } @@ -337,7 +337,7 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins if (xed_error != XED_ERROR_NONE) { - PrintError("Xed error: %s\n", xed_error_enum_t2str(xed_error)); + PrintError(info->vm_info, info, "Xed error: %s\n", xed_error_enum_t2str(xed_error)); return -1; } @@ -351,12 +351,12 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins #ifdef V3_CONFIG_DEBUG_DECODER xed_iclass_enum_t iclass = xed_decoded_inst_get_iclass(&xed_instr); - PrintDebug("iform=%s, iclass=%s\n", xed_iform_enum_t2str(iform), xed_iclass_enum_t2str(iclass)); + PrintDebug(info->vm_info, info, "iform=%s, iclass=%s\n", xed_iform_enum_t2str(iform), xed_iclass_enum_t2str(iclass)); #endif if ((instr->op_type = get_opcode(iform)) == V3_INVALID_OP) { - PrintError("Could not get opcode. (iform=%s)\n", xed_iform_enum_t2str(iform)); + PrintError(info->vm_info, info, "Could not get opcode. (iform=%s)\n", xed_iform_enum_t2str(iform)); return -1; } @@ -374,7 +374,7 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins /* if (instr->num_operands > 3) { - PrintDebug("Special Case Not Handled (more than 3 operands) (iform=%s)\n", xed_iform_enum_t2str(iform) + PrintDebug(info->vm_info, info, "Special Case Not Handled (more than 3 operands) (iform=%s)\n", xed_iform_enum_t2str(iform) return -1; // special case } else if (instr->num_operands == 3) { @@ -384,14 +384,14 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins if ((!xed_operand_is_register(op_enum)) || (!is_flags_reg(xed_decoded_inst_get_reg(&xed_instr, op_enum)))) { // special case - PrintError("Special Case not handled (iform=%s)\n", xed_iform_enum_t2str(iform)); + PrintError(info->vm_info, info, "Special Case not handled (iform=%s)\n", xed_iform_enum_t2str(iform)); return -1; } } */ - //PrintDebug("Number of operands: %d\n", instr->num_operands); - //PrintDebug("INSTR length: %d\n", instr->instr_length); + //PrintDebug(info->vm_info, info, "Number of operands: %d\n", instr->num_operands); + //PrintDebug(info->vm_info, info, "INSTR length: %d\n", instr->instr_length); // set first operand if (instr->num_operands >= 1) { @@ -418,7 +418,7 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins &(v3_op->size)); if (v3_reg_type == -1) { - PrintError("First operand is an Unhandled Operand: %s\n", xed_reg_enum_t2str(xed_reg)); + PrintError(info->vm_info, info, "First operand is an Unhandled Operand: %s\n", xed_reg_enum_t2str(xed_reg)); v3_op->type = INVALID_OPERAND; return -1; } else if (v3_reg_type == SEGMENT_REGISTER) { @@ -433,9 +433,9 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins case XED_OPERAND_MEM0: { - PrintDebug("Memory operand (1)\n"); + PrintDebug(info->vm_info, info, "Memory operand (1)\n"); if (get_memory_operand(info, &xed_instr, 0, v3_op) == -1) { - PrintError("Could not get first memory operand\n"); + PrintError(info->vm_info, info, "Could not get first memory operand\n"); return -1; } } @@ -444,7 +444,7 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins case XED_OPERAND_MEM1: case XED_OPERAND_IMM1: // illegal - PrintError("Illegal Operand Order\n"); + PrintError(info->vm_info, info, "Illegal Operand Order\n"); return -1; @@ -453,7 +453,7 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins v3_op->size = xed_decoded_inst_get_immediate_width(&xed_instr); if (v3_op->size > 4) { - PrintError("Unhandled 64 bit immediates\n"); + PrintError(info->vm_info, info, "Unhandled 64 bit immediates\n"); return -1; } v3_op->operand = xed_decoded_inst_get_unsigned_immediate(&xed_instr); @@ -466,12 +466,12 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins case XED_OPERAND_PTR: case XED_OPERAND_RELBR: default: - PrintError("Unhandled Operand Type\n"); + PrintError(info->vm_info, info, "Unhandled Operand Type\n"); return -1; } } -// V3_Print("Operand 0 mode: %s\n", xed_operand_action_enum_t2str(xed_operand_rw(op))); +// V3_Print(info->vm_info, info, "Operand 0 mode: %s\n", xed_operand_action_enum_t2str(xed_operand_rw(op))); if (xed_operand_read(op)) { @@ -509,7 +509,7 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins &(v3_op->operand), &(v3_op->size)); if (v3_reg_type == -1) { - PrintError("Second operand is an Unhandled Operand: %s\n", xed_reg_enum_t2str(xed_reg)); + PrintError(info->vm_info, info, "Second operand is an Unhandled Operand: %s\n", xed_reg_enum_t2str(xed_reg)); v3_op->type = INVALID_OPERAND; return -1; } else if (v3_reg_type == SEGMENT_REGISTER) { @@ -523,9 +523,9 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins case XED_OPERAND_MEM0: { - PrintDebug("Memory operand (2)\n"); + PrintDebug(info->vm_info, info, "Memory operand (2)\n"); if (get_memory_operand(info, &xed_instr, 0, v3_op) == -1) { - PrintError("Could not get first memory operand\n"); + PrintError(info->vm_info, info, "Could not get first memory operand\n"); return -1; } } @@ -536,7 +536,7 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins instr->src_operand.size = xed_decoded_inst_get_immediate_width(&xed_instr); if (instr->src_operand.size > 4) { - PrintError("Unhandled 64 bit immediates\n"); + PrintError(info->vm_info, info, "Unhandled 64 bit immediates\n"); return -1; } instr->src_operand.operand = xed_decoded_inst_get_unsigned_immediate(&xed_instr); @@ -549,19 +549,19 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins case XED_OPERAND_MEM1: case XED_OPERAND_IMM1: // illegal - PrintError("Illegal Operand Order\n"); + PrintError(info->vm_info, info, "Illegal Operand Order\n"); return -1; case XED_OPERAND_AGEN: case XED_OPERAND_PTR: case XED_OPERAND_RELBR: default: - PrintError("Unhandled Operand Type\n"); + PrintError(info->vm_info, info, "Unhandled Operand Type\n"); return -1; } } -// V3_Print("Operand 1 mode: %s\n", xed_operand_action_enum_t2str(xed_operand_rw(op))); +// V3_Print(info->vm_info, info, "Operand 1 mode: %s\n", xed_operand_action_enum_t2str(xed_operand_rw(op))); if (xed_operand_read(op)) { v3_op->read = 1; @@ -589,7 +589,7 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins &(instr->third_operand.size)); if (v3_reg_type == -1) { - PrintError("Third operand is an Unhandled Operand: %s\n", xed_reg_enum_t2str(xed_reg)); + PrintError(info->vm_info, info, "Third operand is an Unhandled Operand: %s\n", xed_reg_enum_t2str(xed_reg)); instr->third_operand.type = INVALID_OPERAND; return -1; } else if (v3_reg_type == SEGMENT_REGISTER) { @@ -600,7 +600,7 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins instr->third_operand.type = REG_OPERAND; - PrintDebug("Operand 2 mode: %s\n", xed_operand_action_enum_t2str(xed_operand_rw(op))); + PrintDebug(info->vm_info, info, "Operand 2 mode: %s\n", xed_operand_action_enum_t2str(xed_operand_rw(op))); if (xed_operand_read(op)) { @@ -612,7 +612,7 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins } } else { - PrintError("Unhandled third operand type %s\n", xed_operand_type_enum_t2str(op_type)); + PrintError(info->vm_info, info, "Unhandled third operand type %s\n", xed_operand_type_enum_t2str(op_type)); instr->num_operands = 2; } } @@ -642,10 +642,10 @@ static int get_memory_operand(struct guest_info * info, xed_decoded_inst_t * xe v3_cpu_mode_t cpu_mode = v3_get_vm_cpu_mode(info); // struct v3_segment * seg_reg; - PrintDebug("Xed mode = %s\n", xed_machine_mode_enum_t2str(xed_state_get_machine_mode(info->decoder_state))); - PrintDebug("Address width: %s\n", + PrintDebug(info->vm_info, info, "Xed mode = %s\n", xed_machine_mode_enum_t2str(xed_state_get_machine_mode(info->decoder_state))); + PrintDebug(info->vm_info, info, "Address width: %s\n", xed_address_width_enum_t2str(xed_state_get_address_width(info->decoder_state))); - PrintDebug("Stack Address width: %s\n", + PrintDebug(info->vm_info, info, "Stack Address width: %s\n", xed_address_width_enum_t2str(xed_state_get_stack_address_width(info->decoder_state))); @@ -656,7 +656,7 @@ static int get_memory_operand(struct guest_info * info, xed_decoded_inst_t * xe if (xed_seg != XED_REG_INVALID) { struct v3_segment *tmp_segment; if (xed_reg_to_v3_reg(info, xed_seg, (addr_t *)&tmp_segment, &(mem_op.segment_size)) == -1) { - PrintError("Unhandled Segment Register\n"); + PrintError(info->vm_info, info, "Unhandled Segment Register\n"); return -1; } mem_op.segment = tmp_segment->base; @@ -666,7 +666,7 @@ static int get_memory_operand(struct guest_info * info, xed_decoded_inst_t * xe if (xed_base != XED_REG_INVALID) { addr_t base_reg; if (xed_reg_to_v3_reg(info, xed_base, &base_reg, &(mem_op.base_size)) == -1) { - PrintError("Unhandled Base register\n"); + PrintError(info->vm_info, info, "Unhandled Base register\n"); return -1; } mem_op.base = *(addr_t *)base_reg; @@ -679,7 +679,7 @@ static int get_memory_operand(struct guest_info * info, xed_decoded_inst_t * xe addr_t index_reg; if (xed_reg_to_v3_reg(info, xed_idx, &index_reg, &(mem_op.index_size)) == -1) { - PrintError("Unhandled Index Register\n"); + PrintError(info->vm_info, info, "Unhandled Index Register\n"); return -1; } @@ -705,12 +705,12 @@ static int get_memory_operand(struct guest_info * info, xed_decoded_inst_t * xe - PrintDebug("Struct: Seg=%p (size=%d), base=%p, index=%p, scale=%p, displacement=%p (size=%d)\n", + PrintDebug(info->vm_info, info, "Struct: Seg=%p (size=%d), base=%p, index=%p, scale=%p, displacement=%p (size=%d)\n", (void *)mem_op.segment, mem_op.segment_size, (void*)mem_op.base, (void *)mem_op.index, (void *)mem_op.scale, (void *)(addr_t)mem_op.displacement, mem_op.displacement_size); - PrintDebug("operand size: %d\n", operand->size); + PrintDebug(info->vm_info, info, "operand size: %d\n", operand->size); seg = MASK(mem_op.segment, mem_op.segment_size); base = MASK(mem_op.base, mem_op.base_size); @@ -727,7 +727,7 @@ static int get_memory_operand(struct guest_info * info, xed_decoded_inst_t * xe displacement = ((sllong_t)displacement) >> (64 - mem_op.displacement_size * 8); - PrintDebug("Seg=%p, base=%p, index=%p, scale=%p, displacement=%p\n", + PrintDebug(info->vm_info, info, "Seg=%p, base=%p, index=%p, scale=%p, displacement=%p\n", (void *)seg, (void *)base, (void *)index, (void *)scale, (void *)(addr_t)displacement); if (cpu_mode == REAL) { @@ -743,7 +743,7 @@ static int get_memory_operand(struct guest_info * info, xed_decoded_inst_t * xe static int xed_reg_to_v3_reg(struct guest_info * info, xed_reg_enum_t xed_reg, addr_t * v3_reg, uint_t * reg_len) { - PrintDebug("Xed Register: %s\n", xed_reg_enum_t2str(xed_reg)); + PrintDebug(info->vm_info, info, "Xed Register: %s\n", xed_reg_enum_t2str(xed_reg)); switch (xed_reg) { case XED_REG_INVALID: @@ -1150,7 +1150,7 @@ static int xed_reg_to_v3_reg(struct guest_info * info, xed_reg_enum_t xed_reg, case XED_REG_LDTR: case XED_REG_IDTR: case XED_REG_TR: - PrintError("Segment selector operand... Don't know how to handle this...\n"); + PrintError(info->vm_info, info, "Segment selector operand... Don't know how to handle this...\n"); return -1; /* diff --git a/palacios/src/palacios/vmm_xml.c b/palacios/src/palacios/vmm_xml.c index 3581d98..a797e63 100644 --- a/palacios/src/palacios/vmm_xml.c +++ b/palacios/src/palacios/vmm_xml.c @@ -67,7 +67,7 @@ static void * tmp_realloc(void * old_ptr, size_t old_size, size_t new_size) { new_buf = V3_Malloc(new_size); if (new_buf == NULL) { - PrintError("Cannot allocate in tmp_realloc in xml\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in tmp_realloc in xml\n"); return NULL; } @@ -98,7 +98,7 @@ static void v3_xml_err(struct v3_xml_root * root, char * xml_str, const char * e vsnprintf(root->err, V3_XML_ERRL, fmt, ap); va_end(ap); - PrintError("XML Error: %s\n", root->err); + PrintError(VM_NONE, VCORE_NONE, "XML Error: %s\n", root->err); // free memory v3_xml_free(&(root->xml)); @@ -305,7 +305,7 @@ static void v3_xml_char_content(struct v3_xml_root * root, char * s, size_t len, tmp = V3_Malloc((l = strlen(xml->txt)) + len); if (!tmp) { - PrintError("Cannot allocate in xml char content\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml char content\n"); return ; } @@ -371,7 +371,7 @@ static struct v3_xml * v3_xml_new(const char * name) { struct v3_xml_root * root = (struct v3_xml_root *)V3_Malloc(sizeof(struct v3_xml_root)); if (!root) { - PrintError("Cannot allocate in xml_new\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml_new\n"); return NULL; } @@ -472,7 +472,7 @@ static struct v3_xml * v3_xml_add_child(struct v3_xml * xml, const char * name, child = (struct v3_xml *)V3_Malloc(sizeof(struct v3_xml)); if (!child) { - PrintError("Cannot allocate in xml_add_child\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml_add_child\n"); return NULL; } @@ -585,7 +585,7 @@ static struct v3_xml * parse_str(char * buf, size_t len) { (2 * sizeof(char *)))); if (!attr) { - PrintError("Cannot reallocate in xml parse string\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot reallocate in xml parse string\n"); return NULL; } @@ -594,19 +594,19 @@ static struct v3_xml * parse_str(char * buf, size_t len) { (attr_cnt + 1)); if (!attr[last_idx]) { - PrintError("Cannot reallocate in xml parse string\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot reallocate in xml parse string\n"); return NULL; } } else { attr = V3_Malloc(4 * sizeof(char *)); if (!attr) { - PrintError("Cannot allocate in xml parse string\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml parse string\n"); return NULL; } attr[last_idx] = V3_Malloc(2); if (!attr[last_idx]) { - PrintError("Cannot alloocate in xml parse string\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot alloocate in xml parse string\n"); return NULL; } } @@ -774,7 +774,7 @@ struct v3_xml * v3_xml_parse(char * buf) { xml_buf = (char *)V3_Malloc(str_len + 1); if (!xml_buf) { - PrintError("Cannot allocate in xml parse\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml parse\n"); return NULL; } @@ -870,7 +870,7 @@ struct v3_xml * v3_xml_set_attr(struct v3_xml * xml, const char * name, const ch xml->attr = V3_Malloc(4 * sizeof(char *)); if (!xml->attr) { - PrintError("Cannot allocate in xml set attr\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml set attr\n"); return NULL; } @@ -878,7 +878,7 @@ struct v3_xml * v3_xml_set_attr(struct v3_xml * xml, const char * name, const ch xml->attr[1] = strdup(""); if (!xml->attr[1]) { - PrintError("Cannot strdup in xml set attr\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot strdup in xml set attr\n"); return NULL; } @@ -886,7 +886,7 @@ struct v3_xml * v3_xml_set_attr(struct v3_xml * xml, const char * name, const ch xml->attr = tmp_realloc(xml->attr, l * sizeof(char *), (l + 4) * sizeof(char *)); if (!xml->attr) { - PrintError("Cannot reallocate in xml set attr\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot reallocate in xml set attr\n"); return NULL; } } @@ -903,7 +903,7 @@ struct v3_xml * v3_xml_set_attr(struct v3_xml * xml, const char * name, const ch if (!xml->attr[l + 3]) { - PrintError("Cannot reallocate in xml set attr\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot reallocate in xml set attr\n"); return NULL; } @@ -1126,7 +1126,7 @@ char * v3_xml_tostr(struct v3_xml * xml) { char *s = V3_Malloc(max); if (!s) { - PrintError("Cannot allocate in xml tostrr\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml tostrr\n"); return NULL; } diff --git a/palacios/src/palacios/vmx.c b/palacios/src/palacios/vmx.c index 2718b1c..d6471a1 100644 --- a/palacios/src/palacios/vmx.c +++ b/palacios/src/palacios/vmx.c @@ -66,7 +66,7 @@ static int inline check_vmcs_write(vmcs_field_t field, addr_t val) { ret = vmcs_write(field, val); if (ret != VMX_SUCCESS) { - PrintError("VMWRITE error on %s!: %d\n", v3_vmcs_field_to_str(field), ret); + PrintError(VM_NONE, VCORE_NONE, "VMWRITE error on %s!: %d\n", v3_vmcs_field_to_str(field), ret); return 1; } @@ -82,7 +82,7 @@ static int inline check_vmcs_read(vmcs_field_t field, void * val) { ret = vmcs_read(field, val); if (ret != VMX_SUCCESS) { - PrintError("VMREAD error on %s!: %d\n", v3_vmcs_field_to_str(field), ret); + PrintError(VM_NONE, VCORE_NONE, "VMREAD error on %s!: %d\n", v3_vmcs_field_to_str(field), ret); } return ret; @@ -95,18 +95,18 @@ static addr_t allocate_vmcs() { void *temp; struct vmcs_data * vmcs_page = NULL; - PrintDebug("Allocating page\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Allocating page\n"); temp = V3_AllocPages(1); if (!temp) { - PrintError("Cannot allocate VMCS\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate VMCS\n"); return -1; } vmcs_page = (struct vmcs_data *)V3_VAddr(temp); memset(vmcs_page, 0, 4096); vmcs_page->revision = hw_info.basic_info.revision; - PrintDebug("VMX Revision: 0x%x\n", vmcs_page->revision); + PrintDebug(VM_NONE, VCORE_NONE, "VMX Revision: 0x%x\n", vmcs_page->revision); return (addr_t)V3_PAddr((void *)vmcs_page); } @@ -115,7 +115,7 @@ static addr_t allocate_vmcs() { #if 0 static int debug_efer_read(struct guest_info * core, uint_t msr, struct v3_msr * src, void * priv_data) { struct v3_msr * efer = (struct v3_msr *)&(core->ctrl_regs.efer); - V3_Print("\n\nEFER READ (val = %p)\n", (void *)efer->value); + V3_Print(core->vm_info, core, "\n\nEFER READ (val = %p)\n", (void *)efer->value); v3_print_guest_state(core); v3_print_vmcs(); @@ -127,7 +127,7 @@ static int debug_efer_read(struct guest_info * core, uint_t msr, struct v3_msr * static int debug_efer_write(struct guest_info * core, uint_t msr, struct v3_msr src, void * priv_data) { struct v3_msr * efer = (struct v3_msr *)&(core->ctrl_regs.efer); - V3_Print("\n\nEFER WRITE (old_val = %p) (new_val = %p)\n", (void *)efer->value, (void *)src.value); + V3_Print(core->vm_info, core, "\n\nEFER WRITE (old_val = %p) (new_val = %p)\n", (void *)efer->value, (void *)src.value); v3_print_guest_state(core); v3_print_vmcs(); @@ -151,12 +151,12 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) // disable global interrupts for vm state initialization v3_disable_ints(); - PrintDebug("Loading VMCS\n"); + PrintDebug(core->vm_info, core, "Loading VMCS\n"); vmx_ret = vmcs_load(vmx_state->vmcs_ptr_phys); vmx_state->state = VMX_UNLAUNCHED; if (vmx_ret != VMX_SUCCESS) { - PrintError("VMPTRLD failed\n"); + PrintError(core->vm_info, core, "VMPTRLD failed\n"); return -1; } @@ -170,8 +170,8 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) vmx_state->sec_proc_ctrls.value = hw_info.sec_proc_ctrls.def_val; /* Print Control MSRs */ - V3_Print("CR0 MSR: req_val=%p, req_mask=%p\n", (void *)(addr_t)hw_info.cr0.req_val, (void *)(addr_t)hw_info.cr0.req_mask); - V3_Print("CR4 MSR: req_val=%p, req_mask=%p\n", (void *)(addr_t)hw_info.cr4.req_val, (void *)(addr_t)hw_info.cr4.req_mask); + V3_Print(core->vm_info, core, "CR0 MSR: req_val=%p, req_mask=%p\n", (void *)(addr_t)hw_info.cr0.req_val, (void *)(addr_t)hw_info.cr0.req_mask); + V3_Print(core->vm_info, core, "CR4 MSR: req_val=%p, req_mask=%p\n", (void *)(addr_t)hw_info.cr4.req_val, (void *)(addr_t)hw_info.cr4.req_mask); @@ -191,7 +191,7 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) /* We enable the preemption timer by default to measure accurate guest time */ if (avail_pin_ctrls.active_preempt_timer) { - V3_Print("VMX Preemption Timer is available\n"); + V3_Print(core->vm_info, core, "VMX Preemption Timer is available\n"); vmx_state->pin_ctrls.active_preempt_timer = 1; vmx_state->exit_ctrls.save_preempt_timer = 1; } @@ -255,10 +255,10 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) /* Setup paging */ if (core->shdw_pg_mode == SHADOW_PAGING) { - PrintDebug("Creating initial shadow page table\n"); + PrintDebug(core->vm_info, core, "Creating initial shadow page table\n"); if (v3_init_passthrough_pts(core) == -1) { - PrintError("Could not initialize passthrough page tables\n"); + PrintError(core->vm_info, core, "Could not initialize passthrough page tables\n"); return -1; } @@ -327,7 +327,7 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) if (v3_init_ept(core, &hw_info) == -1) { - PrintError("Error initializing EPT\n"); + PrintError(core->vm_info, core, "Error initializing EPT\n"); return -1; } @@ -425,7 +425,7 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) ((struct cr0_32 *)&(core->shdw_pg_state.guest_cr0))->cd = 0; if (v3_init_ept(core, &hw_info) == -1) { - PrintError("Error initializing EPT\n"); + PrintError(core->vm_info, core, "Error initializing EPT\n"); return -1; } @@ -433,7 +433,7 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) // v3_hook_msr(core->vm_info, EFER_MSR, &debug_efer_read, &debug_efer_write, core); v3_hook_msr(core->vm_info, EFER_MSR, NULL, NULL, NULL); } else { - PrintError("Invalid Virtual paging mode (pg_mode=%d) (mach_type=%d)\n", core->shdw_pg_mode, v3_mach_type); + PrintError(core->vm_info, core, "Invalid Virtual paging mode (pg_mode=%d) (mach_type=%d)\n", core->shdw_pg_mode, v3_mach_type); return -1; } @@ -449,17 +449,17 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) int max_msrs = (hw_info.misc_info.max_msr_cache_size + 1) * 4; int msr_ret = 0; - V3_Print("Setting up MSR load/store areas (max_msr_count=%d)\n", max_msrs); + V3_Print(core->vm_info, core, "Setting up MSR load/store areas (max_msr_count=%d)\n", max_msrs); if (max_msrs < 4) { - PrintError("Max MSR cache size is too small (%d)\n", max_msrs); + PrintError(core->vm_info, core, "Max MSR cache size is too small (%d)\n", max_msrs); return -1; } vmx_state->msr_area_paddr = (addr_t)V3_AllocPages(1); if (vmx_state->msr_area_paddr == (addr_t)NULL) { - PrintError("could not allocate msr load/store area\n"); + PrintError(core->vm_info, core, "could not allocate msr load/store area\n"); return -1; } @@ -507,7 +507,7 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) msr_ret |= v3_hook_msr(core->vm_info, IA32_CSTAR_MSR, NULL, NULL, NULL); if (msr_ret != 0) { - PrintError("Error configuring MSR save/restore area\n"); + PrintError(core->vm_info, core, "Error configuring MSR save/restore area\n"); return -1; } @@ -544,13 +544,13 @@ static int init_vmcs_bios(struct guest_info * core, struct vmx_data * vmx_state) if (v3_update_vmcs_ctrl_fields(core)) { - PrintError("Could not write control fields!\n"); + PrintError(core->vm_info, core, "Could not write control fields!\n"); return -1; } /* if (v3_update_vmcs_host_state(core)) { - PrintError("Could not write host state\n"); + PrintError(core->vm_info, core, "Could not write host state\n"); return -1; } */ @@ -572,46 +572,46 @@ static void __init_vmx_vmcs(void * arg) { vmx_state = (struct vmx_data *)V3_Malloc(sizeof(struct vmx_data)); if (!vmx_state) { - PrintError("Unable to allocate in initializing vmx vmcs\n"); + PrintError(core->vm_info, core, "Unable to allocate in initializing vmx vmcs\n"); return; } memset(vmx_state, 0, sizeof(struct vmx_data)); - PrintDebug("vmx_data pointer: %p\n", (void *)vmx_state); + PrintDebug(core->vm_info, core, "vmx_data pointer: %p\n", (void *)vmx_state); - PrintDebug("Allocating VMCS\n"); + PrintDebug(core->vm_info, core, "Allocating VMCS\n"); vmx_state->vmcs_ptr_phys = allocate_vmcs(); - PrintDebug("VMCS pointer: %p\n", (void *)(vmx_state->vmcs_ptr_phys)); + PrintDebug(core->vm_info, core, "VMCS pointer: %p\n", (void *)(vmx_state->vmcs_ptr_phys)); core->vmm_data = vmx_state; vmx_state->state = VMX_UNLAUNCHED; - PrintDebug("Initializing VMCS (addr=%p)\n", core->vmm_data); + PrintDebug(core->vm_info, core, "Initializing VMCS (addr=%p)\n", core->vmm_data); // TODO: Fix vmcs fields so they're 32-bit - PrintDebug("Clearing VMCS: %p\n", (void *)vmx_state->vmcs_ptr_phys); + PrintDebug(core->vm_info, core, "Clearing VMCS: %p\n", (void *)vmx_state->vmcs_ptr_phys); vmx_ret = vmcs_clear(vmx_state->vmcs_ptr_phys); if (vmx_ret != VMX_SUCCESS) { - PrintError("VMCLEAR failed\n"); + PrintError(core->vm_info, core, "VMCLEAR failed\n"); return; } if (core->vm_info->vm_class == V3_PC_VM) { - PrintDebug("Initializing VMCS\n"); + PrintDebug(core->vm_info, core, "Initializing VMCS\n"); if (init_vmcs_bios(core, vmx_state) == -1) { - PrintError("Error initializing VMCS to BIOS state\n"); + PrintError(core->vm_info, core, "Error initializing VMCS to BIOS state\n"); return; } } else { - PrintError("Invalid VM Class\n"); + PrintError(core->vm_info, core, "Invalid VM Class\n"); return; } - PrintDebug("Serializing VMCS: %p\n", (void *)vmx_state->vmcs_ptr_phys); + PrintDebug(core->vm_info, core, "Serializing VMCS: %p\n", (void *)vmx_state->vmcs_ptr_phys); vmx_ret = vmcs_clear(vmx_state->vmcs_ptr_phys); core->core_run_state = CORE_STOPPED; @@ -633,7 +633,7 @@ int v3_init_vmx_vmcs(struct guest_info * core, v3_vm_class_t vm_class) { } if (i == V3_CONFIG_MAX_CPUS) { - PrintError("Could not find VALID CPU for VMX guest initialization\n"); + PrintError(core->vm_info, core, "Could not find VALID CPU for VMX guest initialization\n"); return -1; } @@ -644,7 +644,7 @@ int v3_init_vmx_vmcs(struct guest_info * core, v3_vm_class_t vm_class) { } if (core->core_run_state != CORE_STOPPED) { - PrintError("Error initializing VMX Core\n"); + PrintError(core->vm_info, core, "Error initializing VMX Core\n"); return -1; } @@ -675,7 +675,7 @@ int v3_vmx_save_core(struct guest_info * core, void * ctx){ // note that the vmcs pointer is an HPA, but we need an HVA if (v3_chkpt_save(ctx, "vmcs_data", PAGE_SIZE_4KB, V3_VAddr((void*) (vmx_info->vmcs_ptr_phys)))) { - PrintError("Could not save vmcs data for VMX\n"); + PrintError(core->vm_info, core, "Could not save vmcs data for VMX\n"); return -1; } @@ -690,13 +690,13 @@ int v3_vmx_load_core(struct guest_info * core, void * ctx){ vmcs_page_paddr = (addr_t) V3_AllocPages(1); if (!vmcs_page_paddr) { - PrintError("Could not allocate space for a vmcs in VMX\n"); + PrintError(core->vm_info, core, "Could not allocate space for a vmcs in VMX\n"); return -1; } if (v3_chkpt_load(ctx, "vmcs_data", PAGE_SIZE_4KB, V3_VAddr((void *)vmcs_page_paddr)) == -1) { - PrintError("Could not load vmcs data for VMX\n"); + PrintError(core->vm_info, core, "Could not load vmcs data for VMX\n"); V3_FreePages((void*)vmcs_page_paddr,1); return -1; } @@ -718,12 +718,12 @@ int v3_vmx_load_core(struct guest_info * core, void * ctx){ if (core->shdw_pg_mode == SHADOW_PAGING) { if (v3_get_vm_mem_mode(core) == VIRTUAL_MEM) { if (v3_activate_shadow_pt(core) == -1) { - PrintError("Failed to activate shadow page tables\n"); + PrintError(core->vm_info, core, "Failed to activate shadow page tables\n"); return -1; } } else { if (v3_activate_passthrough_pt(core) == -1) { - PrintError("Failed to activate passthrough page tables\n"); + PrintError(core->vm_info, core, "Failed to activate passthrough page tables\n"); return -1; } } @@ -749,7 +749,7 @@ static int update_irq_exit_state(struct guest_info * info) { if ((info->intr_core_state.irq_started == 1) && (idt_vec_info.valid == 0)) { #ifdef V3_CONFIG_DEBUG_INTERRUPTS - V3_Print("Calling v3_injecting_intr\n"); + V3_Print(info->vm_info, info, "Calling v3_injecting_intr\n"); #endif info->intr_core_state.irq_started = 0; v3_injecting_intr(info, info->intr_core_state.irq_vector, V3_EXTERNAL_IRQ); @@ -781,14 +781,14 @@ static int update_irq_entry_state(struct guest_info * info) { int_info.error_code = 1; #ifdef V3_CONFIG_DEBUG_INTERRUPTS - V3_Print("Injecting exception %d with error code %x\n", + V3_Print(info->vm_info, info, "Injecting exception %d with error code %x\n", int_info.vector, info->excp_state.excp_error_code); #endif } int_info.valid = 1; #ifdef V3_CONFIG_DEBUG_INTERRUPTS - V3_Print("Injecting exception %d (EIP=%p)\n", int_info.vector, (void *)(addr_t)info->rip); + V3_Print(info->vm_info, info, "Injecting exception %d (EIP=%p)\n", int_info.vector, (void *)(addr_t)info->rip); #endif check_vmcs_write(VMCS_ENTRY_INT_INFO, int_info.value); @@ -800,7 +800,7 @@ static int update_irq_entry_state(struct guest_info * info) { if ((info->intr_core_state.irq_started == 1) && (idt_vec_info.valid == 1)) { #ifdef V3_CONFIG_DEBUG_INTERRUPTS - V3_Print("IRQ pending from previous injection\n"); + V3_Print(info->vm_info, info, "IRQ pending from previous injection\n"); #endif // Copy the IDT vectoring info over to reinject the old interrupt @@ -827,7 +827,7 @@ static int update_irq_entry_state(struct guest_info * info) { ent_int.valid = 1; #ifdef V3_CONFIG_DEBUG_INTERRUPTS - V3_Print("Injecting Interrupt %d at exit %u(EIP=%p)\n", + V3_Print(info->vm_info, info, "Injecting Interrupt %d at exit %u(EIP=%p)\n", info->intr_core_state.irq_vector, (uint32_t)info->num_exits, (void *)(addr_t)info->rip); @@ -839,7 +839,7 @@ static int update_irq_entry_state(struct guest_info * info) { break; } case V3_NMI: - PrintDebug("Injecting NMI\n"); + PrintDebug(info->vm_info, info, "Injecting NMI\n"); ent_int.type = 2; ent_int.vector = 2; @@ -848,7 +848,7 @@ static int update_irq_entry_state(struct guest_info * info) { break; case V3_SOFTWARE_INTR: - PrintDebug("Injecting software interrupt\n"); + PrintDebug(info->vm_info, info, "Injecting software interrupt\n"); ent_int.type = 4; ent_int.valid = 1; @@ -872,7 +872,7 @@ static int update_irq_entry_state(struct guest_info * info) { check_vmcs_read(VMCS_EXIT_INSTR_LEN, &instr_len); #ifdef V3_CONFIG_DEBUG_INTERRUPTS - V3_Print("Enabling Interrupt-Window exiting: %d\n", instr_len); + V3_Print(info->vm_info, info, "Enabling Interrupt-Window exiting: %d\n", instr_len); #endif vmx_info->pri_proc_ctrls.int_wndw_exit = 1; @@ -895,18 +895,18 @@ static void print_exit_log(struct guest_info * info) { int i = 0; - V3_Print("\nExit Log (%d total exits):\n", (uint32_t)info->num_exits); + V3_Print(info->vm_info, info, "\nExit Log (%d total exits):\n", (uint32_t)info->num_exits); for (i = 0; i < 10; i++) { struct vmx_exit_info * tmp = &exit_log[cnt]; - V3_Print("%d:\texit_reason = %p\n", i, (void *)(addr_t)tmp->exit_reason); - V3_Print("\texit_qual = %p\n", (void *)tmp->exit_qual); - V3_Print("\tint_info = %p\n", (void *)(addr_t)tmp->int_info); - V3_Print("\tint_err = %p\n", (void *)(addr_t)tmp->int_err); - V3_Print("\tinstr_info = %p\n", (void *)(addr_t)tmp->instr_info); - V3_Print("\tguest_linear_addr= %p\n", (void *)(addr_t)tmp->guest_linear_addr); - V3_Print("\tRIP = %p\n", (void *)rip_log[cnt]); + V3_Print(info->vm_info, info, "%d:\texit_reason = %p\n", i, (void *)(addr_t)tmp->exit_reason); + V3_Print(info->vm_info, info, "\texit_qual = %p\n", (void *)tmp->exit_qual); + V3_Print(info->vm_info, info, "\tint_info = %p\n", (void *)(addr_t)tmp->int_info); + V3_Print(info->vm_info, info, "\tint_err = %p\n", (void *)(addr_t)tmp->int_err); + V3_Print(info->vm_info, info, "\tinstr_info = %p\n", (void *)(addr_t)tmp->instr_info); + V3_Print(info->vm_info, info, "\tguest_linear_addr= %p\n", (void *)(addr_t)tmp->guest_linear_addr); + V3_Print(info->vm_info, info, "\tRIP = %p\n", (void *)rip_log[cnt]); cnt--; @@ -1007,7 +1007,7 @@ int v3_vmx_enter(struct guest_info * info) { if (v3_update_vmcs_host_state(info)) { v3_enable_ints(); - PrintError("Could not write host state\n"); + PrintError(info->vm_info, info, "Could not write host state\n"); return -1; } @@ -1034,7 +1034,7 @@ int v3_vmx_enter(struct guest_info * info) { rdtscll(exit_tsc); } else { - V3_ASSERT(vmx_info->state != VMX_UNLAUNCHED); + V3_ASSERT(info->vm_info, info,vmx_info->state != VMX_UNLAUNCHED); rdtscll(entry_tsc); ret = v3_vmx_resume(&(info->vm_regs), info, &(info->ctrl_regs)); rdtscll(exit_tsc); @@ -1043,7 +1043,7 @@ int v3_vmx_enter(struct guest_info * info) { guest_cycles = exit_tsc - entry_tsc; } - // PrintDebug("VMX Exit: ret=%d\n", ret); + // PrintDebug(info->vm_info, info, "VMX Exit: ret=%d\n", ret); if (ret != VMX_SUCCESS) { uint32_t error = 0; @@ -1051,7 +1051,7 @@ int v3_vmx_enter(struct guest_info * info) { v3_enable_ints(); - PrintError("VMENTRY Error: %d (launch_ret = %d)\n", error, ret); + PrintError(info->vm_info, info, "VMENTRY Error: %d (launch_ret = %d)\n", error, ret); return -1; } @@ -1095,7 +1095,7 @@ int v3_vmx_enter(struct guest_info * info) { check_vmcs_read(VMCS_GUEST_PHYS_ADDR, &(exit_info.ept_fault_addr)); } - //PrintDebug("VMX Exit taken, id-qual: %u-%lu\n", exit_info.exit_reason, exit_info.exit_qual); + //PrintDebug(info->vm_info, info, "VMX Exit taken, id-qual: %u-%lu\n", exit_info.exit_reason, exit_info.exit_qual); exit_log[info->num_exits % 10] = exit_info; rip_log[info->num_exits % 10] = get_addr_linear(info, info->rip, &(info->segments.cs)); @@ -1115,7 +1115,7 @@ int v3_vmx_enter(struct guest_info * info) { vmcs_write(VMCS_PROC_CTRLS, vmx_info->pri_proc_ctrls.value); #ifdef V3_CONFIG_DEBUG_INTERRUPTS - V3_Print("Interrupts available again! (RIP=%llx)\n", info->rip); + V3_Print(info->vm_info, info, "Interrupts available again! (RIP=%llx)\n", info->rip); #endif } @@ -1140,7 +1140,7 @@ int v3_vmx_enter(struct guest_info * info) { v3_update_timers(info); if (v3_handle_vmx_exit(info, &exit_info) == -1) { - PrintError("Error in VMX exit handler (Exit reason=%x)\n", exit_info.exit_reason); + PrintError(info->vm_info, info, "Error in VMX exit handler (Exit reason=%x)\n", exit_info.exit_reason); return -1; } @@ -1155,13 +1155,13 @@ int v3_vmx_enter(struct guest_info * info) { int v3_start_vmx_guest(struct guest_info * info) { - PrintDebug("Starting VMX core %u\n", info->vcpu_id); + PrintDebug(info->vm_info, info, "Starting VMX core %u\n", info->vcpu_id); if (info->vcpu_id == 0) { info->core_run_state = CORE_RUNNING; } else { - PrintDebug("VMX core %u: Waiting for core initialization\n", info->vcpu_id); + PrintDebug(info->vm_info, info, "VMX core %u: Waiting for core initialization\n", info->vcpu_id); while (info->core_run_state == CORE_STOPPED) { @@ -1171,22 +1171,22 @@ int v3_start_vmx_guest(struct guest_info * info) { } v3_yield(info,-1); - //PrintDebug("VMX core %u: still waiting for INIT\n",info->vcpu_id); + //PrintDebug(info->vm_info, info, "VMX core %u: still waiting for INIT\n",info->vcpu_id); } - PrintDebug("VMX core %u initialized\n", info->vcpu_id); + PrintDebug(info->vm_info, info, "VMX core %u initialized\n", info->vcpu_id); // We'll be paranoid about race conditions here v3_wait_at_barrier(info); } - PrintDebug("VMX core %u: I am starting at CS=0x%x (base=0x%p, limit=0x%x), RIP=0x%p\n", + PrintDebug(info->vm_info, info, "VMX core %u: I am starting at CS=0x%x (base=0x%p, limit=0x%x), RIP=0x%p\n", info->vcpu_id, info->segments.cs.selector, (void *)(info->segments.cs.base), info->segments.cs.limit, (void *)(info->rip)); - PrintDebug("VMX core %u: Launching VMX VM on logical core %u\n", info->vcpu_id, info->pcpu_id); + PrintDebug(info->vm_info, info, "VMX core %u: Launching VMX VM on logical core %u\n", info->vcpu_id, info->pcpu_id); v3_start_time(info); @@ -1204,11 +1204,11 @@ int v3_start_vmx_guest(struct guest_info * info) { info->vm_info->run_state = VM_ERROR; - V3_Print("VMX core %u: VMX ERROR!!\n", info->vcpu_id); + V3_Print(info->vm_info, info, "VMX core %u: VMX ERROR!!\n", info->vcpu_id); v3_print_guest_state(info); - V3_Print("VMX core %u\n", info->vcpu_id); + V3_Print(info->vm_info, info, "VMX core %u\n", info->vcpu_id); linear_addr = get_addr_linear(info, info->rip, &(info->segments.cs)); @@ -1218,9 +1218,9 @@ int v3_start_vmx_guest(struct guest_info * info) { v3_gva_to_hva(info, linear_addr, &host_addr); } - V3_Print("VMX core %u: Host Address of rip = 0x%p\n", info->vcpu_id, (void *)host_addr); + V3_Print(info->vm_info, info, "VMX core %u: Host Address of rip = 0x%p\n", info->vcpu_id, (void *)host_addr); - V3_Print("VMX core %u: Instr (15 bytes) at %p:\n", info->vcpu_id, (void *)host_addr); + V3_Print(info->vm_info, info, "VMX core %u: Instr (15 bytes) at %p:\n", info->vcpu_id, (void *)host_addr); v3_dump_mem((uint8_t *)host_addr, 15); v3_print_stack(info); @@ -1240,7 +1240,7 @@ int v3_start_vmx_guest(struct guest_info * info) { } /* if ((info->num_exits % 5000) == 0) { - V3_Print("VMX Exit number %d\n", (uint32_t)info->num_exits); + V3_Print(info->vm_info, info, "VMX Exit number %d\n", (uint32_t)info->num_exits); } */ @@ -1262,20 +1262,20 @@ int v3_is_vmx_capable() { v3_cpuid(0x1, &eax, &ebx, &ecx, &edx); - PrintDebug("ECX: 0x%x\n", ecx); + PrintDebug(VM_NONE, VCORE_NONE, "ECX: 0x%x\n", ecx); if (ecx & CPUID_1_ECX_VTXFLAG) { v3_get_msr(VMX_FEATURE_CONTROL_MSR, &(feature_msr.hi), &(feature_msr.lo)); - PrintDebug("MSRREGlow: 0x%.8x\n", feature_msr.lo); + PrintDebug(VM_NONE, VCORE_NONE, "MSRREGlow: 0x%.8x\n", feature_msr.lo); if ((feature_msr.lo & CPUID_VMX_FEATURES) != CPUID_VMX_FEATURES) { - PrintDebug("VMX is locked -- enable in the BIOS\n"); + PrintDebug(VM_NONE, VCORE_NONE, "VMX is locked -- enable in the BIOS\n"); return 0; } } else { - PrintDebug("VMX not supported on this cpu\n"); + PrintDebug(VM_NONE, VCORE_NONE, "VMX not supported on this cpu\n"); return 0; } @@ -1310,7 +1310,7 @@ void v3_init_vmx_cpu(int cpu_id) { if (v3_mach_type == V3_INVALID_CPU) { if (v3_init_vmx_hw(&hw_info) == -1) { - PrintError("Could not initialize VMX hardware features on cpu %d\n", cpu_id); + PrintError(VM_NONE, VCORE_NONE, "Could not initialize VMX hardware features on cpu %d\n", cpu_id); return; } } @@ -1323,27 +1323,27 @@ void v3_init_vmx_cpu(int cpu_id) { if (vmx_on(vmx_on_region) == VMX_SUCCESS) { - V3_Print("VMX Enabled\n"); + V3_Print(VM_NONE, VCORE_NONE, "VMX Enabled\n"); host_vmcs_ptrs[cpu_id] = vmx_on_region; } else { - V3_Print("VMX already enabled\n"); + V3_Print(VM_NONE, VCORE_NONE, "VMX already enabled\n"); V3_FreePages((void *)vmx_on_region, 1); } - PrintDebug("VMXON pointer: 0x%p\n", (void *)host_vmcs_ptrs[cpu_id]); + PrintDebug(VM_NONE, VCORE_NONE, "VMXON pointer: 0x%p\n", (void *)host_vmcs_ptrs[cpu_id]); { struct vmx_sec_proc_ctrls sec_proc_ctrls; sec_proc_ctrls.value = v3_vmx_get_ctrl_features(&(hw_info.sec_proc_ctrls)); if (sec_proc_ctrls.enable_ept == 0) { - V3_Print("VMX EPT (Nested) Paging not supported\n"); + V3_Print(VM_NONE, VCORE_NONE, "VMX EPT (Nested) Paging not supported\n"); v3_cpu_types[cpu_id] = V3_VMX_CPU; } else if (sec_proc_ctrls.unrstrct_guest == 0) { - V3_Print("VMX EPT (Nested) Paging supported\n"); + V3_Print(VM_NONE, VCORE_NONE, "VMX EPT (Nested) Paging supported\n"); v3_cpu_types[cpu_id] = V3_VMX_EPT_CPU; } else { - V3_Print("VMX EPT (Nested) Paging + Unrestricted guest supported\n"); + V3_Print(VM_NONE, VCORE_NONE, "VMX EPT (Nested) Paging + Unrestricted guest supported\n"); v3_cpu_types[cpu_id] = V3_VMX_EPT_UG_CPU; } } @@ -1356,10 +1356,10 @@ void v3_deinit_vmx_cpu(int cpu_id) { v3_cpu_types[cpu_id] = V3_INVALID_CPU; if (host_vmcs_ptrs[cpu_id] != 0) { - V3_Print("Disabling VMX\n"); + V3_Print(VM_NONE, VCORE_NONE, "Disabling VMX\n"); if (vmx_off() != VMX_SUCCESS) { - PrintError("Error executing VMXOFF\n"); + PrintError(VM_NONE, VCORE_NONE, "Error executing VMXOFF\n"); } V3_FreePages((void *)host_vmcs_ptrs[cpu_id], 1); diff --git a/palacios/src/palacios/vmx_assist.c b/palacios/src/palacios/vmx_assist.c index 01a2f6f..058f503 100644 --- a/palacios/src/palacios/vmx_assist.c +++ b/palacios/src/palacios/vmx_assist.c @@ -111,23 +111,23 @@ int v3_vmxassist_ctx_switch(struct guest_info * info) { if (v3_gpa_to_hva(info, VMXASSIST_START, (addr_t *)&hdr) == -1) { - PrintError("Could not translate address for vmxassist header\n"); + PrintError(info->vm_info, info, "Could not translate address for vmxassist header\n"); return -1; } if (hdr->magic != VMXASSIST_MAGIC) { - PrintError("VMXASSIST_MAGIC field is invalid\n"); + PrintError(info->vm_info, info, "VMXASSIST_MAGIC field is invalid\n"); return -1; } if (v3_gpa_to_hva(info, (addr_t)(hdr->old_ctx_gpa), (addr_t *)&(old_ctx)) == -1) { - PrintError("Could not translate address for VMXASSIST old context\n"); + PrintError(info->vm_info, info, "Could not translate address for VMXASSIST old context\n"); return -1; } if (v3_gpa_to_hva(info, (addr_t)(hdr->new_ctx_gpa), (addr_t *)&(new_ctx)) == -1) { - PrintError("Could not translate address for VMXASSIST new context\n"); + PrintError(info->vm_info, info, "Could not translate address for VMXASSIST new context\n"); return -1; } @@ -182,7 +182,7 @@ static void load_segment(struct vmx_assist_segment * vmx_assist_seg, struct v3_s static void vmx_save_world_ctx(struct guest_info * info, struct vmx_assist_context * ctx) { struct vmx_data * vmx_info = (struct vmx_data *)(info->vmm_data); - PrintDebug("Writing from RIP: 0x%p\n", (void *)(addr_t)info->rip); + PrintDebug(info->vm_info, info, "Writing from RIP: 0x%p\n", (void *)(addr_t)info->rip); ctx->eip = info->rip; ctx->esp = info->vm_regs.rsp; @@ -213,7 +213,7 @@ static void vmx_save_world_ctx(struct guest_info * info, struct vmx_assist_conte static void vmx_restore_world_ctx(struct guest_info * info, struct vmx_assist_context * ctx) { struct vmx_data * vmx_info = (struct vmx_data *)(info->vmm_data); - PrintDebug("ctx rip: %p\n", (void *)(addr_t)ctx->eip); + PrintDebug(info->vm_info, info, "ctx rip: %p\n", (void *)(addr_t)ctx->eip); info->rip = ctx->eip; info->vm_regs.rsp = ctx->esp; @@ -307,7 +307,7 @@ int v3_vmxassist_init(struct guest_info * core, struct vmx_data * vmx_state) { addr_t vmxassist_gdt = 0; if (v3_gpa_to_hva(core, VMXASSIST_GDT, &vmxassist_gdt) == -1) { - PrintError("Could not find VMXASSIST GDT destination\n"); + PrintError(core->vm_info, core, "Could not find VMXASSIST GDT destination\n"); return -1; } @@ -338,10 +338,10 @@ int v3_vmxassist_init(struct guest_info * core, struct vmx_data * vmx_state) { int i = 0; pde32_4MB_t * pde = NULL; - PrintError("Setting up internal VMXASSIST page tables\n"); + PrintError(core->vm_info, core, "Setting up internal VMXASSIST page tables\n"); if (v3_gpa_to_hva(core, VMXASSIST_1to1_PT, (addr_t *)(&pde)) == -1) { - PrintError("Could not find VMXASSIST 1to1 PT destination\n"); + PrintError(core->vm_info, core, "Could not find VMXASSIST 1to1 PT destination\n"); return -1; } @@ -354,7 +354,7 @@ int v3_vmxassist_init(struct guest_info * core, struct vmx_data * vmx_state) { pde[i].large_page = 1; pde[i].page_base_addr = PAGE_BASE_ADDR_4MB(i * PAGE_SIZE_4MB); - // PrintError("PDE %d: %x\n", i, *(uint32_t *)&(pde[i])); + // PrintError(core->vm_info, core, "PDE %d: %x\n", i, *(uint32_t *)&(pde[i])); } core->ctrl_regs.cr3 = VMXASSIST_1to1_PT; @@ -369,7 +369,7 @@ int v3_vmxassist_init(struct guest_info * core, struct vmx_data * vmx_state) { addr_t vmxassist_dst = 0; if (v3_gpa_to_hva(core, VMXASSIST_START, &vmxassist_dst) == -1) { - PrintError("Could not find VMXASSIST destination\n"); + PrintError(core->vm_info, core, "Could not find VMXASSIST destination\n"); return -1; } diff --git a/palacios/src/palacios/vmx_ctrl_regs.c b/palacios/src/palacios/vmx_ctrl_regs.c index 0f10f7e..8a7c3bf 100644 --- a/palacios/src/palacios/vmx_ctrl_regs.c +++ b/palacios/src/palacios/vmx_ctrl_regs.c @@ -45,19 +45,19 @@ int v3_vmx_handle_cr0_access(struct guest_info * info, struct vmx_exit_cr_qual * if (cr_qual->access_type == 0) { if (handle_mov_to_cr0(info, reg, exit_info) != 0) { - PrintError("Could not handle CR0 write\n"); + PrintError(info->vm_info, info, "Could not handle CR0 write\n"); return -1; } } else { // Mov from cr - PrintError("Mov From CR0 not handled\n"); + PrintError(info->vm_info, info, "Mov From CR0 not handled\n"); return -1; } return 0; } - PrintError("Invalid CR0 Access type?? (type=%d)\n", cr_qual->access_type); + PrintError(info->vm_info, info, "Invalid CR0 Access type?? (type=%d)\n", cr_qual->access_type); return -1; } @@ -73,7 +73,7 @@ int v3_vmx_handle_cr3_access(struct guest_info * info, struct vmx_exit_cr_qual * } } - PrintError("Invalid CR3 Access type?? (type=%d)\n", cr_qual->access_type); + PrintError(info->vm_info, info, "Invalid CR3 Access type?? (type=%d)\n", cr_qual->access_type); return -1; } @@ -82,13 +82,13 @@ int v3_vmx_handle_cr4_access(struct guest_info * info, struct vmx_exit_cr_qual * if (cr_qual->access_type == 0) { if (v3_handle_cr4_write(info) != 0) { - PrintError("Could not handle CR4 write\n"); + PrintError(info->vm_info, info, "Could not handle CR4 write\n"); return -1; } info->ctrl_regs.cr4 |= 0x2000; // no VMX allowed in guest, so mask CR4.VMXE } else { if (v3_handle_cr4_read(info) != 0) { - PrintError("Could not handle CR4 read\n"); + PrintError(info->vm_info, info, "Could not handle CR4 read\n"); return -1; } } @@ -96,7 +96,7 @@ int v3_vmx_handle_cr4_access(struct guest_info * info, struct vmx_exit_cr_qual * return 0; } - PrintError("Invalid CR4 Access type?? (type=%d)\n", cr_qual->access_type); + PrintError(info->vm_info, info, "Invalid CR4 Access type?? (type=%d)\n", cr_qual->access_type); return -1; } @@ -105,12 +105,12 @@ int v3_vmx_handle_cr8_access(struct guest_info * info, struct vmx_exit_cr_qual * if (cr_qual->access_type == 0) { if (v3_handle_cr8_write(info) != 0) { - PrintError("Could not handle CR8 write\n"); + PrintError(info->vm_info, info, "Could not handle CR8 write\n"); return -1; } } else { if (v3_handle_cr8_read(info) != 0) { - PrintError("Could not handle CR8 read\n"); + PrintError(info->vm_info, info, "Could not handle CR8 read\n"); return -1; } } @@ -118,7 +118,7 @@ int v3_vmx_handle_cr8_access(struct guest_info * info, struct vmx_exit_cr_qual * return 0; } - PrintError("Invalid CR8 Access type?? (type=%d)\n", cr_qual->access_type); + PrintError(info->vm_info, info, "Invalid CR8 Access type?? (type=%d)\n", cr_qual->access_type); return -1; } @@ -127,7 +127,7 @@ static int handle_mov_to_cr3(struct guest_info * info, v3_reg_t * cr3_reg) { if (info->shdw_pg_mode == SHADOW_PAGING) { /* - PrintDebug("Old Guest CR3=%p, Old Shadow CR3=%p\n", + PrintDebug(info->vm_info, info, "Old Guest CR3=%p, Old Shadow CR3=%p\n", (void *)info->ctrl_regs.cr3, (void *)info->shdw_pg_state.guest_cr3); */ @@ -141,17 +141,17 @@ static int handle_mov_to_cr3(struct guest_info * info, v3_reg_t * cr3_reg) { if (v3_get_vm_mem_mode(info) == VIRTUAL_MEM) { if (v3_activate_shadow_pt(info) == -1) { - PrintError("Failed to activate 32 bit shadow page table\n"); + PrintError(info->vm_info, info, "Failed to activate 32 bit shadow page table\n"); return -1; } } /* - PrintDebug("New guest CR3=%p, New shadow CR3=%p\n", + PrintDebug(info->vm_info, info, "New guest CR3=%p, New shadow CR3=%p\n", (void *)info->ctrl_regs.cr3, (void *)info->shdw_pg_state.guest_cr3); */ } else if (info->shdw_pg_mode == NESTED_PAGING) { - PrintError("Nested paging not available in VMX right now!\n"); + PrintError(info->vm_info, info, "Nested paging not available in VMX right now!\n"); return -1; } @@ -174,7 +174,7 @@ static int handle_mov_from_cr3(struct guest_info * info, v3_reg_t * cr3_reg) { } } else { - PrintError("Unhandled paging mode\n"); + PrintError(info->vm_info, info, "Unhandled paging mode\n"); return -1; } @@ -191,26 +191,26 @@ static int handle_mov_to_cr0(struct guest_info * info, v3_reg_t * new_cr0, struc extern v3_cpu_arch_t v3_mach_type; - PrintDebug("Mov to CR0\n"); - PrintDebug("Old shadow CR0: 0x%x, New shadow CR0: 0x%x\n", + PrintDebug(info->vm_info, info, "Mov to CR0\n"); + PrintDebug(info->vm_info, info, "Old shadow CR0: 0x%x, New shadow CR0: 0x%x\n", (uint32_t)info->shdw_pg_state.guest_cr0, (uint32_t)*new_cr0); if ((new_shdw_cr0->pe != shdw_cr0->pe) && (vmx_info->assist_state != VMXASSIST_DISABLED)) { /* - PrintDebug("Guest CR0: 0x%x\n", *(uint32_t *)guest_cr0); - PrintDebug("Old shadow CR0: 0x%x\n", *(uint32_t *)shdw_cr0); - PrintDebug("New shadow CR0: 0x%x\n", *(uint32_t *)new_shdw_cr0); + PrintDebug(info->vm_info, info, "Guest CR0: 0x%x\n", *(uint32_t *)guest_cr0); + PrintDebug(info->vm_info, info, "Old shadow CR0: 0x%x\n", *(uint32_t *)shdw_cr0); + PrintDebug(info->vm_info, info, "New shadow CR0: 0x%x\n", *(uint32_t *)new_shdw_cr0); */ if (v3_vmxassist_ctx_switch(info) != 0) { - PrintError("Unable to execute VMXASSIST context switch!\n"); + PrintError(info->vm_info, info, "Unable to execute VMXASSIST context switch!\n"); return -1; } if (vmx_info->assist_state == VMXASSIST_ON) { - PrintDebug("Loading VMXASSIST at RIP: %p\n", (void *)(addr_t)info->rip); + PrintDebug(info->vm_info, info, "Loading VMXASSIST at RIP: %p\n", (void *)(addr_t)info->rip); } else { - PrintDebug("Leaving VMXASSIST and entering protected mode at RIP: %p\n", + PrintDebug(info->vm_info, info, "Leaving VMXASSIST and entering protected mode at RIP: %p\n", (void *)(addr_t)info->rip); } @@ -263,7 +263,7 @@ static int handle_mov_to_cr0(struct guest_info * info, v3_reg_t * new_cr0, struc if (vmx_info->assist_state != VMXASSIST_DISABLED) { if (vm_efer->lme) { - PrintDebug("Enabling long mode\n"); + PrintDebug(info->vm_info, info, "Enabling long mode\n"); hw_efer->lma = 1; hw_efer->lme = 1; @@ -272,7 +272,7 @@ static int handle_mov_to_cr0(struct guest_info * info, v3_reg_t * new_cr0, struc } } else { if (hw_efer->lme) { - PrintDebug("Enabling long mode\n"); + PrintDebug(info->vm_info, info, "Enabling long mode\n"); hw_efer->lma = 1; @@ -280,11 +280,11 @@ static int handle_mov_to_cr0(struct guest_info * info, v3_reg_t * new_cr0, struc } } - // PrintDebug("Activating Shadow Page tables\n"); + // PrintDebug(info->vm_info, info, "Activating Shadow Page tables\n"); if (info->shdw_pg_mode == SHADOW_PAGING) { if (v3_activate_shadow_pt(info) == -1) { - PrintError("Failed to activate shadow page tables\n"); + PrintError(info->vm_info, info, "Failed to activate shadow page tables\n"); return -1; } } @@ -293,7 +293,7 @@ static int handle_mov_to_cr0(struct guest_info * info, v3_reg_t * new_cr0, struc if (info->shdw_pg_mode == SHADOW_PAGING) { if (v3_activate_passthrough_pt(info) == -1) { - PrintError("Failed to activate passthrough page tables\n"); + PrintError(info->vm_info, info, "Failed to activate passthrough page tables\n"); return -1; } } else { diff --git a/palacios/src/palacios/vmx_ept.c b/palacios/src/palacios/vmx_ept.c index 2a7055d..82f084a 100644 --- a/palacios/src/palacios/vmx_ept.c +++ b/palacios/src/palacios/vmx_ept.c @@ -32,7 +32,7 @@ static addr_t create_ept_page() { temp = V3_AllocPages(1); if (!temp) { - PrintError("Cannot allocate EPT page\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate EPT page\n"); return 0; } page = V3_VAddr(temp); @@ -57,7 +57,7 @@ int v3_init_ept(struct guest_info * core, struct vmx_hw_info * hw_info) { if (ept_info->pg_walk_len4) { ept_ptr->pwl1 = 3; } else { - PrintError("Unsupported EPT Table depth\n"); + PrintError(core->vm_info, core, "Unsupported EPT Table depth\n"); return -1; } @@ -94,7 +94,7 @@ int v3_handle_ept_fault(struct guest_info * core, addr_t fault_addr, struct ept_ error_code.write = ept_qual->write; if (region == NULL) { - PrintError("invalid region, addr=%p\n", (void *)fault_addr); + PrintError(core->vm_info, core, "invalid region, addr=%p\n", (void *)fault_addr); return -1; } @@ -161,7 +161,7 @@ int v3_handle_ept_fault(struct guest_info * core, addr_t fault_addr, struct ept_ } if (v3_gpa_to_hpa(core, fault_addr, &host_addr) == -1) { - PrintError("Error: Could not translate fault addr (%p)\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Error: Could not translate fault addr (%p)\n", (void *)fault_addr); return -1; } @@ -216,7 +216,7 @@ int v3_handle_ept_fault(struct guest_info * core, addr_t fault_addr, struct ept_ } if (v3_gpa_to_hpa(core, fault_addr, &host_addr) == -1) { - PrintError("Error Could not translate fault addr (%p)\n", (void *)fault_addr); + PrintError(core->vm_info, core, "Error Could not translate fault addr (%p)\n", (void *)fault_addr); return -1; } diff --git a/palacios/src/palacios/vmx_exits.c b/palacios/src/palacios/vmx_exits.c index b3f5ad9..38fe326 100644 --- a/palacios/src/palacios/vmx_exits.c +++ b/palacios/src/palacios/vmx_exits.c @@ -37,7 +37,7 @@ static int enable_exit(struct guest_info * core, v3_exit_type_t exit_type) { break; default: - PrintError("Unhandled Exit Type (%d)\n", exit_type); + PrintError(core->vm_info, core, "Unhandled Exit Type (%d)\n", exit_type); return -1; } @@ -58,7 +58,7 @@ static int disable_exit(struct guest_info * core, v3_exit_type_t exit_type) { break; default: - PrintError("Unhandled Exit Type (%d)\n", exit_type); + PrintError(core->vm_info, core, "Unhandled Exit Type (%d)\n", exit_type); return -1; } diff --git a/palacios/src/palacios/vmx_handler.c b/palacios/src/palacios/vmx_handler.c index 5a789db..8f5e12a 100644 --- a/palacios/src/palacios/vmx_handler.c +++ b/palacios/src/palacios/vmx_handler.c @@ -50,7 +50,7 @@ int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_inf struct vmx_basic_exit_info * basic_info = (struct vmx_basic_exit_info *)&(exit_info->exit_reason); /* - PrintError("Handling VMX_EXIT: %s (%u), %lu (0x%lx)\n", + PrintError(info->vm_info, info, "Handling VMX_EXIT: %s (%u), %lu (0x%lx)\n", v3_vmx_exit_code_to_str(exit_info->exit_reason), exit_info->exit_reason, exit_info->exit_qual, exit_info->exit_qual); @@ -62,15 +62,15 @@ int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_inf if (basic_info->entry_error == 1) { switch (basic_info->reason) { case VMX_EXIT_INVALID_GUEST_STATE: - PrintError("VM Entry failed due to invalid guest state\n"); - PrintError("Printing VMCS: (NOTE: This VMCS may not belong to the correct guest)\n"); + PrintError(info->vm_info, info, "VM Entry failed due to invalid guest state\n"); + PrintError(info->vm_info, info, "Printing VMCS: (NOTE: This VMCS may not belong to the correct guest)\n"); v3_print_vmcs(); break; case VMX_EXIT_INVALID_MSR_LOAD: - PrintError("VM Entry failed due to error loading MSRs\n"); + PrintError(info->vm_info, info, "VM Entry failed due to error loading MSRs\n"); break; default: - PrintError("Entry failed for unknown reason (%d)\n", basic_info->reason); + PrintError(info->vm_info, info, "Entry failed for unknown reason (%d)\n", basic_info->reason); break; } @@ -93,23 +93,23 @@ int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_inf // JRL: Change "0x0e" to a macro value if ((uint8_t)exit_info->int_info == 14) { #ifdef V3_CONFIG_DEBUG_SHADOW_PAGING - PrintDebug("Page Fault at %p error_code=%x\n", (void *)exit_info->exit_qual, *(uint32_t *)&error_code); + PrintDebug(info->vm_info, info, "Page Fault at %p error_code=%x\n", (void *)exit_info->exit_qual, *(uint32_t *)&error_code); #endif if (info->shdw_pg_mode == SHADOW_PAGING) { if (v3_handle_shadow_pagefault(info, (addr_t)exit_info->exit_qual, error_code) == -1) { - PrintError("Error handling shadow page fault\n"); + PrintError(info->vm_info, info, "Error handling shadow page fault\n"); return -1; } } else { - PrintError("Page fault in unimplemented paging mode\n"); + PrintError(info->vm_info, info, "Page fault in unimplemented paging mode\n"); return -1; } } else if ((uint8_t)exit_info->int_info == 2) { // NMI. Don't do anything } else { - PrintError("Unknown exception: 0x%x\n", (uint8_t)exit_info->int_info); + PrintError(info->vm_info, info, "Unknown exception: 0x%x\n", (uint8_t)exit_info->int_info); v3_print_GPRs(info); return -1; } @@ -120,7 +120,7 @@ int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_inf struct ept_exit_qual * ept_qual = (struct ept_exit_qual *)&(exit_info->exit_qual); if (v3_handle_ept_fault(info, exit_info->ept_fault_addr, ept_qual) == -1) { - PrintError("Error handling EPT fault\n"); + PrintError(info->vm_info, info, "Error handling EPT fault\n"); return -1; } @@ -129,7 +129,7 @@ int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_inf case VMX_EXIT_INVLPG: if (info->shdw_pg_mode == SHADOW_PAGING) { if (v3_handle_shadow_invlpg(info) == -1) { - PrintError("Error handling INVLPG\n"); + PrintError(info->vm_info, info, "Error handling INVLPG\n"); return -1; } } @@ -138,10 +138,10 @@ int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_inf case VMX_EXIT_RDTSC: #ifdef V3_CONFIG_DEBUG_TIME - PrintDebug("RDTSC\n"); + PrintDebug(info->vm_info, info, "RDTSC\n"); #endif if (v3_handle_rdtsc(info) == -1) { - PrintError("Error Handling RDTSC instruction\n"); + PrintError(info->vm_info, info, "Error Handling RDTSC instruction\n"); return -1; } @@ -149,21 +149,21 @@ int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_inf case VMX_EXIT_CPUID: if (v3_handle_cpuid(info) == -1) { - PrintError("Error Handling CPUID instruction\n"); + PrintError(info->vm_info, info, "Error Handling CPUID instruction\n"); return -1; } break; case VMX_EXIT_RDMSR: if (v3_handle_msr_read(info) == -1) { - PrintError("Error handling MSR Read\n"); + PrintError(info->vm_info, info, "Error handling MSR Read\n"); return -1; } break; case VMX_EXIT_WRMSR: if (v3_handle_msr_write(info) == -1) { - PrintError("Error handling MSR Write\n"); + PrintError(info->vm_info, info, "Error handling MSR Write\n"); return -1; } @@ -187,24 +187,24 @@ int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_inf if (io_qual->dir == 0) { if (io_qual->string) { if (v3_handle_vmx_io_outs(info, exit_info) == -1) { - PrintError("Error in outs IO handler\n"); + PrintError(info->vm_info, info, "Error in outs IO handler\n"); return -1; } } else { if (v3_handle_vmx_io_out(info, exit_info) == -1) { - PrintError("Error in out IO handler\n"); + PrintError(info->vm_info, info, "Error in out IO handler\n"); return -1; } } } else { if (io_qual->string) { if(v3_handle_vmx_io_ins(info, exit_info) == -1) { - PrintError("Error in ins IO handler\n"); + PrintError(info->vm_info, info, "Error in ins IO handler\n"); return -1; } } else { if (v3_handle_vmx_io_in(info, exit_info) == -1) { - PrintError("Error in in IO handler\n"); + PrintError(info->vm_info, info, "Error in in IO handler\n"); return -1; } } @@ -214,37 +214,37 @@ int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_inf case VMX_EXIT_CR_REG_ACCESSES: { struct vmx_exit_cr_qual * cr_qual = (struct vmx_exit_cr_qual *)&(exit_info->exit_qual); - // PrintDebug("Control register: %d\n", cr_qual->access_type); + // PrintDebug(info->vm_info, info, "Control register: %d\n", cr_qual->access_type); switch(cr_qual->cr_id) { case 0: - //PrintDebug("Handling CR0 Access\n"); + //PrintDebug(info->vm_info, info, "Handling CR0 Access\n"); if (v3_vmx_handle_cr0_access(info, cr_qual, exit_info) == -1) { - PrintError("Error in CR0 access handler\n"); + PrintError(info->vm_info, info, "Error in CR0 access handler\n"); return -1; } break; case 3: - //PrintDebug("Handling CR3 Access\n"); + //PrintDebug(info->vm_info, info, "Handling CR3 Access\n"); if (v3_vmx_handle_cr3_access(info, cr_qual) == -1) { - PrintError("Error in CR3 access handler\n"); + PrintError(info->vm_info, info, "Error in CR3 access handler\n"); return -1; } break; case 4: - //PrintDebug("Handling CR4 Access\n"); + //PrintDebug(info->vm_info, info, "Handling CR4 Access\n"); if (v3_vmx_handle_cr4_access(info, cr_qual) == -1) { - PrintError("Error in CR4 access handler\n"); + PrintError(info->vm_info, info, "Error in CR4 access handler\n"); return -1; } break; case 8: if (v3_vmx_handle_cr8_access(info, cr_qual) == -1) { - PrintError("Error in CR8 access handler\n"); + PrintError(info->vm_info, info, "Error in CR8 access handler\n"); return -1; } break; default: - PrintError("Unhandled CR access: %d\n", cr_qual->cr_id); + PrintError(info->vm_info, info, "Unhandled CR access: %d\n", cr_qual->cr_id); return -1; } @@ -256,30 +256,30 @@ int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_inf break; } case VMX_EXIT_HLT: - PrintDebug("Guest halted\n"); + PrintDebug(info->vm_info, info, "Guest halted\n"); if (v3_handle_halt(info) == -1) { - PrintError("Error handling halt instruction\n"); + PrintError(info->vm_info, info, "Error handling halt instruction\n"); return -1; } break; case VMX_EXIT_MONITOR: - PrintDebug("Guest Executing monitor\n"); + PrintDebug(info->vm_info, info, "Guest Executing monitor\n"); if (v3_handle_monitor(info) == -1) { - PrintError("Error handling monitor instruction\n"); + PrintError(info->vm_info, info, "Error handling monitor instruction\n"); return -1; } break; case VMX_EXIT_MWAIT: - PrintDebug("Guest Executing mwait\n"); + PrintDebug(info->vm_info, info, "Guest Executing mwait\n"); if (v3_handle_mwait(info) == -1) { - PrintError("Error handling mwait instruction\n"); + PrintError(info->vm_info, info, "Error handling mwait instruction\n"); return -1; } @@ -299,12 +299,12 @@ int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_inf // not in the generic (interruptable) vmx handler break; case VMX_EXIT_EXPIRED_PREEMPT_TIMER: - V3_Print("VMX Preempt Timer Expired.\n"); + V3_Print(info->vm_info, info, "VMX Preempt Timer Expired.\n"); // This just forces an exit and is handled outside the switch break; default: - PrintError("Unhandled VMX_EXIT: %s (%u), %lu (0x%lx)\n", + PrintError(info->vm_info, info, "Unhandled VMX_EXIT: %s (%u), %lu (0x%lx)\n", v3_vmx_exit_code_to_str(basic_info->reason), basic_info->reason, exit_info->exit_qual, exit_info->exit_qual); diff --git a/palacios/src/palacios/vmx_hw_info.c b/palacios/src/palacios/vmx_hw_info.c index d5fe494..cbd34da 100644 --- a/palacios/src/palacios/vmx_hw_info.c +++ b/palacios/src/palacios/vmx_hw_info.c @@ -102,7 +102,7 @@ int v3_init_vmx_hw(struct vmx_hw_info * hw_info) { v3_get_msr(VMX_MISC_MSR, &(hw_info->misc_info.hi), &(hw_info->misc_info.lo)); - PrintError("BASIC_MSR: Lo: %x, Hi: %x\n", hw_info->basic_info.lo, hw_info->basic_info.hi); + PrintError(VM_NONE, VCORE_NONE, "BASIC_MSR: Lo: %x, Hi: %x\n", hw_info->basic_info.lo, hw_info->basic_info.hi); get_ex_ctrl_caps(hw_info, &(hw_info->pin_ctrls), VMX_PINBASED_CTLS_MSR, VMX_TRUE_PINBASED_CTLS_MSR); get_ex_ctrl_caps(hw_info, &(hw_info->proc_ctrls), VMX_PROCBASED_CTLS_MSR, VMX_TRUE_PROCBASED_CTLS_MSR); diff --git a/palacios/src/palacios/vmx_io.c b/palacios/src/palacios/vmx_io.c index 1c33f11..1910f01 100644 --- a/palacios/src/palacios/vmx_io.c +++ b/palacios/src/palacios/vmx_io.c @@ -53,7 +53,7 @@ int v3_init_vmx_io_map(struct v3_vm_info * vm) { temp = V3_AllocPages(2); if (!temp) { - PrintError("Cannot allocate io bitmap\n"); + PrintError(vm, VCORE_NONE, "Cannot allocate io bitmap\n"); return -1; } @@ -80,16 +80,16 @@ int v3_handle_vmx_io_in(struct guest_info * core, struct vmx_exit_info * exit_in read_size = io_qual.access_size + 1; - PrintDebug("IN of %d bytes on port %d (0x%x)\n", read_size, io_qual.port, io_qual.port); + PrintDebug(core->vm_info, core, "IN of %d bytes on port %d (0x%x)\n", read_size, io_qual.port, io_qual.port); if (hook == NULL) { - PrintDebug("IN operation on unhooked IO port 0x%x - returning zeros\n", io_qual.port); + PrintDebug(core->vm_info, core, "IN operation on unhooked IO port 0x%x - returning zeros\n", io_qual.port); core->vm_regs.rax >>= 8*read_size; core->vm_regs.rax <<= 8*read_size; } else { if (hook->read(core, io_qual.port, &(core->vm_regs.rax), read_size, hook->priv_data) != read_size) { - PrintError("Read failure for IN on port %x\n", io_qual.port); + PrintError(core->vm_info, core, "Read failure for IN on port %x\n", io_qual.port); return -1; } } @@ -113,7 +113,7 @@ int v3_handle_vmx_io_ins(struct guest_info * core, struct vmx_exit_info * exit_i hook = v3_get_io_hook(core->vm_info, io_qual.port); - PrintDebug("INS on port 0x%x\n", io_qual.port); + PrintDebug(core->vm_info, core, "INS on port 0x%x\n", io_qual.port); read_size = io_qual.access_size + 1; @@ -127,7 +127,7 @@ int v3_handle_vmx_io_ins(struct guest_info * core, struct vmx_exit_info * exit_i } else if(instr_info.addr_size == 2) { rep_num = core->vm_regs.rcx & 0xffffffffffffffffLL; } else { - PrintDebug("Unknown INS address size!\n"); + PrintDebug(core->vm_info, core, "Unknown INS address size!\n"); return -1; } } @@ -138,25 +138,25 @@ int v3_handle_vmx_io_ins(struct guest_info * core, struct vmx_exit_info * exit_i rdi_change = read_size; } - PrintDebug("INS size=%d for %ld steps\n", read_size, rep_num); + PrintDebug(core->vm_info, core, "INS size=%d for %u steps\n", read_size, rep_num); if (v3_gva_to_hva(core, guest_va, &host_addr) == -1) { - PrintError("Could not convert Guest VA to host VA\n"); + PrintError(core->vm_info, core, "Could not convert Guest VA to host VA\n"); return -1; } do { if (hook == NULL) { - PrintDebug("INS operation on unhooked IO port 0x%x - returning zeros\n", io_qual.port); + PrintDebug(core->vm_info, core, "INS operation on unhooked IO port 0x%x - returning zeros\n", io_qual.port); memset((char*)host_addr,0,read_size); } else { if (hook->read(core, io_qual.port, (char *)host_addr, read_size, hook->priv_data) != read_size) { - PrintError("Read Failure for INS on port 0x%x\n", io_qual.port); + PrintError(core->vm_info, core, "Read Failure for INS on port 0x%x\n", io_qual.port); return -1; } } @@ -189,13 +189,13 @@ int v3_handle_vmx_io_out(struct guest_info * core, struct vmx_exit_info * exit_i write_size = io_qual.access_size + 1; - PrintDebug("OUT of %d bytes on port %d (0x%x)\n", write_size, io_qual.port, io_qual.port); + PrintDebug(core->vm_info, core, "OUT of %d bytes on port %d (0x%x)\n", write_size, io_qual.port, io_qual.port); if (hook == NULL) { - PrintDebug("OUT operation on unhooked IO port 0x%x - ignored\n", io_qual.port); + PrintDebug(core->vm_info, core, "OUT operation on unhooked IO port 0x%x - ignored\n", io_qual.port); } else { if (hook->write(core, io_qual.port, &(core->vm_regs.rax), write_size, hook->priv_data) != write_size) { - PrintError("Write failure for out on port %x\n",io_qual.port); + PrintError(core->vm_info, core, "Write failure for out on port %x\n",io_qual.port); return -1; } } @@ -219,7 +219,7 @@ int v3_handle_vmx_io_outs(struct guest_info * core, struct vmx_exit_info * exit_ hook = v3_get_io_hook(core->vm_info, io_qual.port); - PrintDebug("OUTS on port 0x%x\n", io_qual.port); + PrintDebug(core->vm_info, core, "OUTS on port 0x%x\n", io_qual.port); write_size = io_qual.access_size + 1; @@ -234,7 +234,7 @@ int v3_handle_vmx_io_outs(struct guest_info * core, struct vmx_exit_info * exit_ } else if(instr_info.addr_size == 2) { rep_num = core->vm_regs.rcx & 0xffffffffffffffffLL; } else { - PrintDebug("Unknown INS address size!\n"); + PrintDebug(core->vm_info, core, "Unknown INS address size!\n"); return -1; } } @@ -247,20 +247,20 @@ int v3_handle_vmx_io_outs(struct guest_info * core, struct vmx_exit_info * exit_ - PrintDebug("OUTS size=%d for %ld steps\n", write_size, rep_num); + PrintDebug(core->vm_info, core, "OUTS size=%d for %u steps\n", write_size, rep_num); if (v3_gva_to_hva(core, guest_va, &host_addr) == -1) { - PrintError("Could not convert guest VA to host VA\n"); + PrintError(core->vm_info, core, "Could not convert guest VA to host VA\n"); return -1; } do { if (hook == NULL) { - PrintDebug("OUTS operation on unhooked IO port 0x%x - ignored\n", io_qual.port); + PrintDebug(core->vm_info, core, "OUTS operation on unhooked IO port 0x%x - ignored\n", io_qual.port); } else { if (hook->write(core, io_qual.port, (char *)host_addr, write_size, hook->priv_data) != write_size) { - PrintError("Read failure for INS on port 0x%x\n", io_qual.port); + PrintError(core->vm_info, core, "Read failure for INS on port 0x%x\n", io_qual.port); return -1; } } diff --git a/palacios/src/palacios/vmx_msr.c b/palacios/src/palacios/vmx_msr.c index bb70fa7..9d6e42a 100644 --- a/palacios/src/palacios/vmx_msr.c +++ b/palacios/src/palacios/vmx_msr.c @@ -36,7 +36,7 @@ static int get_bitmap_index(uint_t msr) } else if (( msr >= HIGH_MSR_START ) && (msr <= HIGH_MSR_END)) { return (HIGH_MSR_INDEX * 8) + (msr - HIGH_MSR_START); } else { - PrintError("MSR out of range: 0x%x\n", msr); + PrintError(VM_NONE, VCORE_NONE, "MSR out of range: 0x%x\n", msr); return -1; } } @@ -75,7 +75,7 @@ int v3_init_vmx_msr_map(struct v3_vm_info * vm) { temp = V3_AllocPages(1); if (!temp) { - PrintError("Cannot allocat MSR bitmap\n"); + PrintError(vm, VCORE_NONE, "Cannot allocat MSR bitmap\n"); return -1; } msr_map->arch_data = V3_VAddr(temp); diff --git a/palacios/src/vnet/vnet_core.c b/palacios/src/vnet/vnet_core.c index d10d18a..7d9942d 100644 --- a/palacios/src/vnet/vnet_core.c +++ b/palacios/src/vnet/vnet_core.c @@ -141,15 +141,15 @@ static void print_route(struct v3_vnet_route * route){ char str[50]; mac2str(route->src_mac, str); - PrintDebug("Src Mac (%s), src_qual (%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Src Mac (%s), src_qual (%d)\n", str, route->src_mac_qual); mac2str(route->dst_mac, str); - PrintDebug("Dst Mac (%s), dst_qual (%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Dst Mac (%s), dst_qual (%d)\n", str, route->dst_mac_qual); - PrintDebug("Src dev id (%d), src type (%d)", + PrintDebug(VM_NONE, VCORE_NONE, "Src dev id (%d), src type (%d)", route->src_id, route->src_type); - PrintDebug("Dst dev id (%d), dst type (%d)\n", + PrintDebug(VM_NONE, VCORE_NONE, "Dst dev id (%d), dst type (%d)\n", route->dst_id, route->dst_type); } @@ -157,13 +157,13 @@ static void print_route(struct v3_vnet_route * route){ static void dump_routes(){ struct vnet_route_info *route; - PrintDebug("\n========Dump routes starts ============\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\n========Dump routes starts ============\n"); list_for_each_entry(route, &(vnet_state.routes), node) { - PrintDebug("\nroute %d:\n", route->idx); + PrintDebug(VM_NONE, VCORE_NONE, "\nroute %d:\n", route->idx); print_route(&(route->route_def)); if (route->route_def.dst_type == LINK_INTERFACE) { - PrintDebug("dst_dev (%p), dst_dev_id (%d), dst_dev_ops(%p), dst_dev_data (%p)\n", + PrintDebug(VM_NONE, VCORE_NONE, "dst_dev (%p), dst_dev_id (%d), dst_dev_ops(%p), dst_dev_data (%p)\n", route->dst_dev, route->dst_dev->dev_id, (void *)&(route->dst_dev->dev_ops), @@ -171,7 +171,7 @@ static void dump_routes(){ } } - PrintDebug("\n========Dump routes end ============\n"); + PrintDebug(VM_NONE, VCORE_NONE, "\n========Dump routes end ============\n"); } #endif @@ -195,7 +195,7 @@ static int add_route_to_cache(const struct v3_vnet_pkt * pkt, struct route_list memcpy(routes->hash_buf, pkt->hash_buf, VNET_HASH_SIZE); if (vnet_htable_insert(vnet_state.route_cache, (addr_t)routes->hash_buf, (addr_t)routes) == 0) { - PrintError("VNET/P Core: Failed to insert new route entry to the cache\n"); + PrintError(VM_NONE, VCORE_NONE, "VNET/P Core: Failed to insert new route entry to the cache\n"); return -1; } @@ -266,14 +266,14 @@ int v3_vnet_add_route(struct v3_vnet_route route) { new_route = (struct vnet_route_info *)Vnet_Malloc(sizeof(struct vnet_route_info)); if (!new_route) { - PrintError("Cannot allocate new route\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate new route\n"); return -1; } memset(new_route, 0, sizeof(struct vnet_route_info)); #ifdef V3_CONFIG_DEBUG_VNET - PrintDebug("VNET/P Core: add_route_entry:\n"); + PrintDebug(VM_NONE, VCORE_NONE, "VNET/P Core: add_route_entry:\n"); print_route(&route); #endif @@ -398,7 +398,7 @@ static inline uint8_t match_mac(uint8_t test_mac[ETH_ALEN], } break; default: - PrintError("Unknown qualifier %u\n",route_qual); + PrintError(VM_NONE, VCORE_NONE, "Unknown qualifier %u\n",route_qual); return NONE; break; } @@ -505,7 +505,7 @@ static struct route_list * match_route(const struct v3_vnet_pkt * pkt) char dst_str[32], src_str[32]; mac2str(hdr->src_mac, src_str); mac2str(hdr->dst_mac, dst_str); - PrintDebug("VNET/P Core: match_route. pkt: SRC(%s), DEST(%s)\n", src_str, dst_str); + PrintDebug(VM_NONE, VCORE_NONE, "VNET/P Core: match_route. pkt: SRC(%s), DEST(%s)\n", src_str, dst_str); } #endif @@ -535,7 +535,7 @@ static struct route_list * match_route(const struct v3_vnet_pkt * pkt) mac2str(route_def->src_mac, src_str); mac2str(route_def->dst_mac, dst_str); - PrintDebug("Tested match against SRC(%s) SRC_QUAL(%s), DEST(%s) DST_QUAL(%s): " + PrintDebug(VM_NONE, VCORE_NONE, "Tested match against SRC(%s) SRC_QUAL(%s), DEST(%s) DST_QUAL(%s): " "SRC_MATCH=%s DEST_MATCH=%s PRIORITY=%d\n", src_str, QUAL_TO_STR(route_def->src_mac_qual), dst_str, QUAL_TO_STR(route_def->dst_mac_qual), @@ -546,12 +546,12 @@ static struct route_list * match_route(const struct v3_vnet_pkt * pkt) #endif if (priority<0) { - PrintDebug("No match to this rule\n"); + PrintDebug(VM_NONE, VCORE_NONE, "No match to this rule\n"); continue; } if (priority > max_priority) { - PrintDebug("New highest priority match, reseting list\n"); + PrintDebug(VM_NONE, VCORE_NONE, "New highest priority match, reseting list\n"); max_priority = priority; struct vnet_route_info *my_route, *tmp_route; @@ -564,7 +564,7 @@ static struct route_list * match_route(const struct v3_vnet_pkt * pkt) num_matches = 1; } else if (priority == max_priority) { - PrintDebug("Equal priority match, adding to list\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Equal priority match, adding to list\n"); list_add(&(route->match_node), &match_list); num_matches++; @@ -572,7 +572,7 @@ static struct route_list * match_route(const struct v3_vnet_pkt * pkt) } - PrintDebug("VNET/P Core: match_route: Matches=%d\n", num_matches); + PrintDebug(VM_NONE, VCORE_NONE, "VNET/P Core: match_route: Matches=%d\n", num_matches); if (num_matches <= 0) { return NULL; @@ -583,7 +583,7 @@ static struct route_list * match_route(const struct v3_vnet_pkt * pkt) if (!matches) { - PrintError("VNET/P Core: Unable to allocate matches\n"); + PrintError(VM_NONE, VCORE_NONE, "VNET/P Core: Unable to allocate matches\n"); return NULL; } @@ -593,7 +593,7 @@ static struct route_list * match_route(const struct v3_vnet_pkt * pkt) list_for_each_entry(route, &match_list, match_node) { if (i==num_matches) { // the list should never have more than num_matches on it... - PrintError("Weird list behavior\n"); + PrintError(VM_NONE, VCORE_NONE, "Weird list behavior\n"); break; } else { matches->routes[i++] = route; @@ -635,7 +635,7 @@ int v3_vnet_query_header(uint8_t src_mac[ETH_ALEN], routes = match_route(&p); if (!routes) { vnet_unlock_irqrestore(vnet_state.lock,flags); - PrintError("Cannot match route\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot match route\n"); header->header_type=VNET_HEADER_NOMATCH; header->header_len=0; return -1; @@ -647,14 +647,14 @@ int v3_vnet_query_header(uint8_t src_mac[ETH_ALEN], vnet_unlock_irqrestore(vnet_state.lock,flags); if (routes->num_routes<1) { - PrintError("Less than one route\n"); + PrintError(VM_NONE, VCORE_NONE, "Less than one route\n"); header->header_type=VNET_HEADER_NOMATCH; header->header_len=0; return -1; } if (routes->num_routes>1) { - PrintError("More than one route, building header for the first one only\n"); + PrintError(VM_NONE, VCORE_NONE, "More than one route, building header for the first one only\n"); } r=routes->routes[0]; @@ -690,7 +690,7 @@ int v3_vnet_query_header(uint8_t src_mac[ETH_ALEN], break; default: - PrintError("Unknown destination type\n"); + PrintError(VM_NONE, VCORE_NONE, "Unknown destination type\n"); return -1; break; @@ -724,14 +724,14 @@ int v3_vnet_send_pkt(struct v3_vnet_pkt * pkt, void * private_data) { look_into_cache(pkt, &matched_routes); if (matched_routes == NULL) { - PrintDebug("VNET/P Core: sending pkt - matching route\n"); + PrintDebug(VM_NONE, VCORE_NONE, "VNET/P Core: sending pkt - matching route\n"); matched_routes = match_route(pkt); if (matched_routes) { add_route_to_cache(pkt, matched_routes); } else { - PrintDebug("VNET/P Core: Could not find route for packet... discarding packet\n"); + PrintDebug(VM_NONE, VCORE_NONE, "VNET/P Core: Could not find route for packet... discarding packet\n"); vnet_unlock_irqrestore(vnet_state.lock, flags); return 0; /* do we return -1 here?*/ } @@ -739,7 +739,7 @@ int v3_vnet_send_pkt(struct v3_vnet_pkt * pkt, void * private_data) { vnet_unlock_irqrestore(vnet_state.lock, flags); - PrintDebug("VNET/P Core: send pkt route matches %d\n", matched_routes->num_routes); + PrintDebug(VM_NONE, VCORE_NONE, "VNET/P Core: send pkt route matches %d\n", matched_routes->num_routes); for (i = 0; i < matched_routes->num_routes; i++) { struct vnet_route_info * route = matched_routes->routes[i]; @@ -816,7 +816,7 @@ int v3_vnet_add_dev(struct v3_vm_info * vm, uint8_t * mac, v3_enqueue(vnet_state.poll_devs, (addr_t)new_dev); } } else { - PrintError("VNET/P: Device with the same MAC has already been added\n"); + PrintError(VM_NONE, VCORE_NONE,"VNET/P: Device with the same MAC has already been added\n"); } vnet_unlock_irqrestore(vnet_state.lock, flags); @@ -829,7 +829,7 @@ int v3_vnet_add_dev(struct v3_vm_info * vm, uint8_t * mac, return -1; } - PrintDebug("VNET/P Core: Add Device: dev_id %d\n", new_dev->dev_id); + PrintDebug(VM_NONE, VCORE_NONE, "VNET/P Core: Add Device: dev_id %d\n", new_dev->dev_id); return new_dev->dev_id; } @@ -856,7 +856,7 @@ int v3_vnet_del_dev(int dev_id){ Vnet_Free(dev); - PrintDebug("VNET/P Core: Removed Device: dev_id %d\n", dev_id); + PrintDebug(VM_NONE, VCORE_NONE, "VNET/P Core: Removed Device: dev_id %d\n", dev_id); return 0; } @@ -906,14 +906,14 @@ int v3_vnet_add_bridge(struct v3_vm_info * vm, vnet_unlock_irqrestore(vnet_state.lock, flags); if (bridge_free == 0) { - PrintError("VNET/P Core: Bridge already set\n"); + PrintError(VM_NONE, VCORE_NONE, "VNET/P Core: Bridge already set\n"); return -1; } tmp_bridge = (struct vnet_brg_dev *)Vnet_Malloc(sizeof(struct vnet_brg_dev)); if (tmp_bridge == NULL) { - PrintError("VNET/P Core: Unable to allocate new bridge\n"); + PrintError(VM_NONE, VCORE_NONE, "VNET/P Core: Unable to allocate new bridge\n"); vnet_state.bridge = NULL; return -1; } @@ -974,7 +974,7 @@ static int vnet_tx_flush(void * args){ struct v3_queue * tq = v3_create_queue(); if (!tq) { - PrintError("VNET/P polling thread cannot allocate queue\n"); + PrintError(VM_NONE, VCORE_NONE, "VNET/P polling thread cannot allocate queue\n"); return -1; } @@ -1063,12 +1063,12 @@ int v3_init_vnet() vnet_state.num_routes = 0; if (vnet_lock_init(&(vnet_state.lock)) == -1){ - PrintError("VNET/P: Fails to initiate lock\n"); + PrintError(VM_NONE, VCORE_NONE, "VNET/P: Fails to initiate lock\n"); } vnet_state.route_cache = vnet_create_htable(0, &hash_fn, &hash_eq); if (vnet_state.route_cache == NULL) { - PrintError("VNET/P: Fails to initiate route cache\n"); + PrintError(VM_NONE, VCORE_NONE, "VNET/P: Fails to initiate route cache\n"); return -1; } @@ -1076,7 +1076,7 @@ int v3_init_vnet() start_vnet_kick_threads(); - PrintDebug("VNET/P is initiated (%d tx kick threads active)\n",VNET_NUM_TX_KICK_THREADS); + PrintDebug(VM_NONE, VCORE_NONE, "VNET/P is initiated (%d tx kick threads active)\n",VNET_NUM_TX_KICK_THREADS); return 0; } @@ -1085,11 +1085,11 @@ int v3_init_vnet() void v3_deinit_vnet() { - PrintDebug("Stopping kick threads\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Stopping kick threads\n"); stop_vnet_kick_threads(); - PrintDebug("Deiniting poll devices\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Deiniting poll devices\n"); v3_deinit_queue(vnet_state.poll_devs); Vnet_Free(vnet_state.poll_devs); @@ -1099,26 +1099,26 @@ void v3_deinit_vnet() Vnet_Free(vnet_state.poll_devs); - PrintDebug("Deiniting Device List\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Deiniting Device List\n"); // close any devices we have open deinit_devices_list(); - PrintDebug("Deiniting Route List\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Deiniting Route List\n"); // remove any routes we have deinit_routes_list(); - PrintDebug("Freeing hash table\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Freeing hash table\n"); // remove the hash table vnet_free_htable(vnet_state.route_cache, 1, 1); - PrintDebug("Removing Bridge\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Removing Bridge\n"); // remove bridge if it was added if (vnet_state.bridge) { Vnet_Free(vnet_state.bridge); } - PrintDebug("Deleting lock\n"); + PrintDebug(VM_NONE, VCORE_NONE, "Deleting lock\n"); // eliminate the lock vnet_lock_deinit(&(vnet_state.lock)); diff --git a/palacios/src/vnet/vnet_host.c b/palacios/src/vnet/vnet_host.c index 459f6b7..5d0c3bf 100644 --- a/palacios/src/vnet/vnet_host.c +++ b/palacios/src/vnet/vnet_host.c @@ -28,7 +28,7 @@ struct vnet_thread * vnet_start_thread(int (*func)(void *), void *arg, char * na struct vnet_thread * thread = Vnet_Malloc(sizeof(struct vnet_thread)); if (!thread) { - PrintError("Cannot allocate space to create a vnet thread\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate space to create a vnet thread\n"); return NULL; } @@ -51,7 +51,7 @@ struct vnet_timer * vnet_create_timer(unsigned long interval, struct vnet_timer * timer = Vnet_Malloc(sizeof(struct vnet_timer)); if (!timer) { - PrintError("Cannot allocate space to create a vnet timer\n"); + PrintError(VM_NONE, VCORE_NONE, "Cannot allocate space to create a vnet timer\n"); return NULL; }