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.
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;
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);
#include <linux/debugfs.h>
#include <linux/uaccess.h>
-#include <interfaces/vmm_mcheck.h>
+//#include <interfaces/vmm_mcheck.h>
#include "palacios.h"
#include "vm.h"
#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)
{
/**
* 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
va_list ap;
char *buf;
unsigned int cpu = palacios_get_cpu();
+ struct v3_guest *guest = (struct v3_guest *)vm;
buf = print_buffer[cpu];
}
#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
}
-
/*
* Allocates a contiguous region of pages of the requested size.
* Returns the physical address of the first page in the region.
* 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,
-
-
static struct vnet_host_hooks vnet_host_hooks = {
.timer_create = host_create_timer,
.timer_del = host_del_timer,
.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,
// 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);
--- /dev/null
+#!/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 = <DMESG>) {
+ $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);
#define __VMM_H__
-/*#include <palacios/vm_guest.h>*/
-
-struct guest_info;
#ifdef __V3VEE__
#include <palacios/vmm_mem.h>
#include <palacios/vmm_types.h>
-
-//#include <palacios/vmm_types.h>
#include <palacios/vmm_string.h>
/* 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)
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; \
})
/* ** */
-#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){ \
/* 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);
failout:
- PrintError("Failed to save device\n");
+ PrintError(info->vm_info, info, "Failed to save device\n");
return -1;
}
case LONG:
return 0xffffffffffffffffLL;
default:
- PrintError("Unsupported Address Mode\n");
+ PrintError(info->vm_info, info, "Unsupported Address Mode\n");
return -1;
}
}
}
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;
}
}
#include <palacios/vmm_hashtable.h>
#include <palacios/vmm_msr.h>
#include <palacios/vmm_config.h>
-#include <palacios/vmm_ethernet.h>
#ifdef V3_CONFIG_CHECKPOINT
#include <palacios/vmm_checkpoint.h>
#include <palacios/vmm.h>
-#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;
}
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;
}
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]);
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;
}
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;
}
}
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:
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 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 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;
}
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;
}
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:
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;
}
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);
} 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;
}
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);
} 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;
}
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 {
} 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;
}
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;
}
}
/* 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);
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)
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;
}
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--;
}
/*
- 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;
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 {
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) {
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;
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;
}
break;
case HW_STROBE:
- PrintError("Hardware strobe not implemented\n");
+ PrintError(VM_NONE, VCORE_NONE, "Hardware strobe not implemented\n");
return -1;
break;
default:
/*
- 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) {
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);
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);
}
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:
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;
}
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;
}
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);
}
}
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;
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;
}
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;
}
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;
}
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:
return 0;
savefailout:
- PrintError("Failed to save pit\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to save pit\n");
return -1;
}
return 0;
loadfailout:
- PrintError("Failed to load pit\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to load pit\n");
return -1;
}
#endif
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;
}
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;
}
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
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;
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);
}
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;
}
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;
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) {
//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;
}
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;
}
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;
}
}
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;
}
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 {
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);
}
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
// 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;
} 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;
}
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;
}
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;
} 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;
}
} 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;
}
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) {
// 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;
} 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");
}
}
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;
}
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;
}
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;
} 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;
}
} 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;
}
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;
}
} 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;
}
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;
}
} 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;
}
return 0;
savefailout:
- PrintError("Failed to save PIC\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to save PIC\n");
return -1;
}
return 0;
loadfailout:
- PrintError("Failed to load PIC\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to load PIC\n");
return -1;
}
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;
}
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;
}
// 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));
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;
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;
}
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;
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;
}
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);
}
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;
}
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;
}
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
}
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;
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) {
}
#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;
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;
}
}
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);
}
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);
}
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);
}
// 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);
}
}
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;
// 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;
}
// 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?
// 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;
}
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;
}
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,
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) {
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;
}
}
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) {
// 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);
}
}
}
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;
}
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;
}
}
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;
}
}
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;
}
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;
}
/* 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; */
/* } */
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;
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;
}
*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;
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;
}
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;
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;
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;
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;
}
}
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;
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) &&
*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);
}
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);
}
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;
}
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--;
return 0;
savefailout:
- PrintError("Failed to save apic\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to save apic\n");
return -1;
}
return 0;
loadfailout:
- PrintError("Failed to load apic\n");
+ PrintError(VM_NONE,VCORE_NONE, "Failed to load apic\n");
return -1;
}
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;
}
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;
}
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);
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;
}
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;
}
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)));
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;
}
ide_raise_irq(ide, channel);
- PrintDebug("Returning from read sectors\n");
+ PrintDebug(VM_NONE, VCORE_NONE,"Returning from read sectors\n");
return 0;
}
// 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;
}
//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;
}
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;
}
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;
}
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)
}
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);
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
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;
}
}
}
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;
}
// 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;
}
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);
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;
}
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) {
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);
- 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;
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;
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;
// 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;
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;
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;
*/
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;
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;
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;
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;
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;
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;
#include <palacios/vmm.h>
#include <palacios/vmm_dev_mgr.h>
#include <palacios/vmm_io.h>
+#include <palacios/vm_guest.h>
#define BUF_SIZE 1024
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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,
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);
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);
}
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 */
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;
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;
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 */
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 */
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 */
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);
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;
/* 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) {
}
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) {
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;
}
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;
}
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);
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;
}
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;
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;
}
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
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;
}
}
((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;
}
}
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;
}
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;
}
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;
}
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;
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;
}
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;
/* 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 */
/* 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 */
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);
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));
}
return 0;
savefailout:
- PrintError("Failed to save CGA\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to save CGA\n");
return -1;
}
return 0;
loadfailout:
- PrintError("Failed to load cga\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to load cga\n");
return -1;
}
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;
}
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;
}
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;
}
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)) {;
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;
}
}
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;
}
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;
}
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;
}
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;
}
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;
// 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
/* 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;
}
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;
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;
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);
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;
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;
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;
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);
}
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);
}
}
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;
}
/*
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;
}
*/
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;
}
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];
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
video_state->pci_dev = pci_dev;
}
- PrintDebug("Video: init complete\n");
+ PrintDebug(info->vm_info, info, "Video: init complete\n");
return 0;
}
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;
/* 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;
}
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);
/* 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;
}
/* 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;
}
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 */
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;
}
}
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;
}
/* 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;
}
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;
}
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;
}
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;
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;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
}
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;
}
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;
}
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;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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");
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;
}
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;
}
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;
}
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) {
// We need to handle unhooking memory regions
for (i=0;i<state->num_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;
}
}
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" :
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;
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;
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;
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;
}
}
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" :
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;
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;
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;
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;
}
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;i<msg_len;i++) {
if (buf_is_va == 1) {
if (v3_read_gva_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;
}
} 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;
}
}
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;
}
#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;
}
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;
}
#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) {
} 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;
}
} 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;
}
#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;
}
- 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));
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);
} 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;
}
} 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;
}
// 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;
}
// 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) {
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;
}
// 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,
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;
}
// 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);
}
} 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;
}
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
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);
}
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
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;
}
// 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;
}
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);
#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
}
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;
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;
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;
}
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;
}
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;
}
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;
}
*/
#include <palacios/vmm.h>
+#include <palacios/vm_guest.h>
#include <palacios/vmm_dev_mgr.h>
#include <devices/pci.h>
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;
}
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;
}
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 (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;
}
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);
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;
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);
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);
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) {
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....
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) {
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);
}
}
- 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++;
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;
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;
}
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;
}
}
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) {
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);
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;
}
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);
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) {
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;
}
}
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;
}
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;
}
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;
}
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;
}
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;
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;
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;
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;
}
}
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;
}
}
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;
}
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);
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;
}
}
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;
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);
*/
(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;
// 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;
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;
}
}
// 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 {
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)) {
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 {
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
// 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 {
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;
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)) {
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;
}
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;
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;
}
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;
}
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;
}
} 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;
}
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;
}
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;
}
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;
}
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;
}
} 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;
}
}
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;
if ((!type_str) || (!drive_str) || (!bus_str)) {
- PrintError("Incomplete IDE Configuration\n");
+ PrintError(vm, VCORE_NONE, "Incomplete IDE Configuration\n");
return -1;
}
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;
}
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;
}
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;
}
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;
}
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);
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;
}
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;
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;
}
}
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;
}
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;
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;
}
}
}
- 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;
}
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
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;
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;
}
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;
}
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);
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;
}
}
return 0;
savefailout:
- PrintError("ioapic save failed\n");
+ PrintError(VM_NONE, VCORE_NONE, "ioapic save failed\n");
return -1;
}
return 0;
loadfailout:
- PrintError("ioapic load failed\n");
+ PrintError(VM_NONE, VCORE_NONE, "ioapic load failed\n");
return -1;
}
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;
}
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;
}
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)
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;
}
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);
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;
#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;
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);
}
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;
}
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);
}
break;
default:
- PrintError("Invalid mouse state\n");
+ PrintError(vm, VCORE_NONE, "Invalid mouse state\n");
ret = -1;
break;
}
/* 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; */
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
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;
}
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;
}
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;
}
}
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;
}
// 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;
}
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;
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;
}
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);
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;
}
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);
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;
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;
/* 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;
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
// 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:
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
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;
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;
}
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;
}
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;
return 0;
savefailout:
- PrintError("Failed to save keyboard\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to save keyboard\n");
return -1;
}
return 0;
loadfailout:
- PrintError("Failed to load keyboard\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to load keyboard\n");
return -1;
}
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;
}
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;
}
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;
}
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) {
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);
}
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;
}
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);
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->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;
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;
}
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;
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);
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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;
}
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;
}
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;
}
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;
}
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);
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);
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) {
*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;
}
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) {
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;
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;
}
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;
}
}
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;
}
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);
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:
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;
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;
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);
}
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);
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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;
}
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;
}
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;
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;
}
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;
}
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;
}
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) {
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;
}
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;
}
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);
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;
}
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);
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->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;
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;
}
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;
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);
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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;
}
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;
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]);
/* 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);
// 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;
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;
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;
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;
}
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;
}
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;
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) {
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) {
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;
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;
}
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;
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;
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));
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;
}
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,
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;
}
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;
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;
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;
}
// 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;
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;
}
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;
}
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;
}
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) {
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;
}
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;
}
/*
- 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);
*/
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;
}
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;
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;
}
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;
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);
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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;
}
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;
}
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;
}
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
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;
}
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);
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;
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;
}
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;
}
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;
}
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;
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;
}
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;
}
} 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;
}
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);
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
}
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;
}
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;
}
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;
}
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;
}
}
- 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);
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;
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;
}
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;
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
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;
}
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;
}
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;
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;
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;
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;
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){
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;
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;
}
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;
}
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);
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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);
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);
}
}
}
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;
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;
}
nic_state->statistics.rx_interrupts ++;
- PrintDebug("NE2000: Raise IRQ\n");
+ PrintDebug(VM_NONE, VCORE_NONE, "NE2000: Raise IRQ\n");
}
return 0;
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
}
if (ne2k_rxbuf_full(regs)) {
- PrintError("Ne2k: received buffer overflow\n");
+ PrintError(VM_NONE, VCORE_NONE, "Ne2k: received buffer overflow\n");
return -1;
}
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
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;
}
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;
}
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;
}
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;
}
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;
}
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) {
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) {
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) {
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;
}
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;
}
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) {
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) {
*(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;
}
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;
}
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;
}
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? */
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;
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;
}
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);
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;
}
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;
}
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;
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;
}
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;
}
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;
}
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;
}
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 ");
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;
}
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);
}
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;
}
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);
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;
}
#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
#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
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;
}
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;
}
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,
(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;
}
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;
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)) ||
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)) ||
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)) ||
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");
}
}
}
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);
}
}
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;
}
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) {
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;
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;
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;
}
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;
}
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;
}
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;
}
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;
}
return 0;
savefailout:
- PrintError("Failed to save debug\n");
+ PrintError(VM_NONE,VCORE_NONE, "Failed to save debug\n");
return -1;
}
return 0;
loadfailout:
- PrintError("Failed to load debug\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to load debug\n");
return -1;
}
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;
}
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;
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) {
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;
}
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;
}
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
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);
}
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;
}
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;
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) {
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;
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));
// 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;
}
}
- 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
}
- 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;
}
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;
}
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;
}
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,
} 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);
}
}
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;
}
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
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;
}
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);
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;
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;
}
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;
}
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,
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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;
}
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;
}
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;
}
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;
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;
}
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;
}
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);
}
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;
}
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;
}
}
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,
*(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;
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;
}
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;
}
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;
}
- V3_Print("Decode MSIX\n");
+ V3_Print(VM_NONE, VCORE_NONE, "Decode MSIX\n");
v3_apic_send_ipi(dev->vm, &ipi, dev->apic_dev);
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;
}
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;
}
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;
}
}
}
- 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
}
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;
}
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;
}
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;
}
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;
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;
}
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
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));
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));
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++) {
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;
}
}
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));
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;
}
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;
}
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;
}
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
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++) {
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;
}
}
} 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;
}
// 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,
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;
}
// 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;
}
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,
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
// 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;
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));
// 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);
// 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;
// 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));
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);
//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
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));
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;
}
// 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);
} 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;
}
} 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;
}
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);
// 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);
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) {
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;
}
// 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,
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;
}
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);
}
} 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;
}
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) {
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;
}
// 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;
}
} __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++) {
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;
}
- 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);
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;
}
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 (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);
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);
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
// 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);
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;
"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;
}
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;
}
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);
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;
}
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;
}
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;
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;
}
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;
}
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;
}
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;
}
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:
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;
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;
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;
++ 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:
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;
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;
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;
{
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;
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) {
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;
}
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);
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);
}
}
- PrintDebug("RTL8139: 9346CR read val=0x%02x\n", ret);
+ PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: 9346CR read val=0x%02x\n", ret);
return ret;
}
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);
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;
// 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);
}
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;
}
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;
// 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);
}
return 1;
}
- PrintDebug("RTL8139: Configuration registers are unwriteable\n");
+ PrintDebug(VM_NONE, VCORE_NONE, "RTL8139: Configuration registers are unwriteable\n");
return 0;
}
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;
}
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);
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;
#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 ++;
}
}
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;
|((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;
}
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;
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:
/* 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;
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);
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;
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;
}
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;
}
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);
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;
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;
}
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;
}
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;
}
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;
}
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;
} 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;
}
}
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);
} 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;
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
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;
}
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;
}
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;
}
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;
}
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;
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;
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;
}
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;
}
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;
}
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;
}
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;
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;
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;
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;
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;
}
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;
}
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;
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;
}
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;
}
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??
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;
}
/* 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;
}
}
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;
}
return 0;
failout:
- PrintError("Failed to save serial buffer\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to save serial buffer\n");
return -1;
}
return 0;
failout:
- PrintError("Failed to load serial buffer\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to load serial buffer\n");
return -1;
}
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;
}
return 0;
failout:
- PrintError("Failed to save serial device\n");
+ PrintError(VM_NONE, VCORE_NONE, "Failed to save serial device\n");
return -1;
}
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;
}
return 0;
failout:
- PrintError("Failed to load serial device\n");
+ PrintError(VM_NONE, VCORE_NONE,"Failed to load serial device\n");
return -1;
}
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;
}
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;
}
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);
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;
}
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;
}
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;
}
- 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);
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;
}
}
}
-static int swap_free(struct vm_device * dev) {
+static int swap_free(void * dev) {
return -1;
}
static struct v3_device_ops dev_ops = {
.free = swap_free,
- .reset = NULL,
- .start = NULL,
- .stop = NULL,
};
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
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;
}
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;
}
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;
}
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);
}
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) {
}
- 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;
}
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);
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;
}
}
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;
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;
}
/*
- 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);
*/
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;
}
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);
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);
}
} 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;
}
}
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;
}
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;
}
}
}
-static int swap_free(struct vm_device * dev) {
+static int swap_free(void * dev) {
return -1;
}
static struct v3_device_ops dev_ops = {
.free = swap_free,
- .reset = NULL,
- .start = NULL,
- .stop = NULL,
};
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
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;
}
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;
}
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;
}
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;
}
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;
}
struct cons_state {
- int server_fd;
- int client_fd;
+ v3_sock_t server_fd;
+ v3_sock_t client_fd;
uint16_t port;
v3_lock_t cons_lock;
- v3_vm_info * vm;
+ struct v3_vm_info * vm;
struct vm_device * frontend_dev;
};
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) {
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;
}
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;
}
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;
}
}
-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;
}
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;
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;
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;
}
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;
}
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;
}
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;
}
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;
}
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) {
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);
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;
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;
}
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;
}
/*
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
*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;
}
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" :
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");
}
}
}
- PrintDebug("vga: render done\n");
+ PrintDebug(VM_NONE, VCORE_NONE, "vga: render done\n");
}
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,
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;y<th;y++) {
ca = *attr;
a.val = ca;
- PrintDebug("%c",ct);
+ PrintDebug(VM_NONE, VCORE_NONE, "%c",ct);
// find the character's font bitmap (one byte per row)
find_text_font_start(vga,(void**)&font,
}
}
}
- PrintDebug("\n");
+ PrintDebug(VM_NONE, VCORE_NONE, "\n");
}
}
{
void *fb;
- PrintDebug("vga: render on update %u\n",vga->updates_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));
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;
}
&&
(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;
}
{
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);
}
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;i<length;i++) {
uint8_t c= ((char*)src)[i];
- PrintDebug("%.2x", c);
+ PrintDebug(core->vm_info, core, "%.2x", c);
}
- PrintDebug(" \"");
+ PrintDebug(core->vm_info, core, " \"");
for (i=0;i<length;i++) {
char c= ((char*)src)[i];
- PrintDebug("%c", (c>='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 */
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;i<length;i++,offset+=find_increment_write(vga,guest_addr+i)) {
uint8_t mm = find_map_write(vga,guest_addr+i);
#if DEBUG_DEEP_MEM
- PrintDebug("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);
+ PrintDebug(core->vm_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) {
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) {
}
#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) {
}
#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
}
#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
#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 {
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;i<length;i++,offset+=find_increment_write(vga,guest_addr+i)) {
offset = find_offset_write(vga, guest_addr);
#if DEBUG_DEEP_MEM
- PrintDebug("vga: mode 2 write, offset=0x%llx, func=%u\n", offset,func);
+ PrintDebug(core->vm_info, core, "vga: mode 2 write, offset=0x%llx, func=%u\n", offset,func);
#endif
for (i=0;i<length;i++,offset+=find_increment_write(vga,guest_addr+i)) {
offset = find_offset_write(vga, guest_addr);
- PrintDebug("vga: mode 3 write, offset=0x%llx, ror=%u\n", offset,ror);
+ PrintDebug(core->vm_info, core, "vga: mode 3 write, offset=0x%llx, ror=%u\n", offset,ror);
for (i=0;i<length;i++,offset+=find_increment_write(vga,guest_addr+i)) {
// now for each map
struct vga_internal *vga = (struct vga_internal *) dev->private_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);
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;i<length;i++,offset+=find_increment_read(vga,guest_addr+i)) {
offset = find_offset_read(vga,guest_addr);
#if DEBUG_DEEP_MEM
- PrintDebug("vga: mode 1 read, offset=0x%llx, cc=0x%x, dc-0x%x\n",offset,cc,dc);
+ PrintDebug(core->vm_info, core, "vga: mode 1 read, offset=0x%llx, cc=0x%x, dc-0x%x\n",offset,cc,dc);
#endif
}
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;i<length;i++) {
uint8_t c= ((char*)dst)[i];
- PrintDebug("%.2x", c);
+ PrintDebug(core->vm_info, core, "%.2x", c);
}
- PrintDebug(" \"");
+ PrintDebug(core->vm_info, core, " \"");
for (i=0;i<length;i++) {
char c= ((char*)dst)[i];
- PrintDebug("%c", (c>='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;
#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; \
}
*(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;
}
}
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;
}
}
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,
{
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);
{
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);
{
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);
{
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);
{
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);
{
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));
{
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);
{
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);
{
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);
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);
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;
}
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);
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;
}
}
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);
{
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);
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);
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;
}
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);
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;
}
}
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);
{
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);
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);
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;
}
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);
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;
}
}
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);
{
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);
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);
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;
}
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);
{
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);
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);
{
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);
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);
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
}
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",
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
}
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",
{
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);
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);
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;
}
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;
}
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));
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");
}
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;
}
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;
}
&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;
}
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;
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;
}
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;
}
copy_len = (sizeof(vnet_header)<header_len) ? sizeof(vnet_header) : header_len;
if (v3_write_gva_memory(info,header_ptr_gva,copy_len,(uchar_t*)&vnet_header) != copy_len) {
- PrintError("Failed to write back header\n");
+ PrintError(info->vm_info, info, "Failed to write back header\n");
info->vm_regs.rax=-1;
return 0;
}
{
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;
}
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;
}
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;
}
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;
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;
}
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:
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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.
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;
}
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;
}
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;
}
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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,
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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));
// 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;
}
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;
}
// 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;
}
// 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;
}
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);
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;
}
// 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;
}
}
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;
}
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;
}
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;
}
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;
}
// 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;
}
return 0;
}
default:
- PrintError("Invalid mmap state\n");
+ PrintError(core->vm_info, core, "Invalid mmap state\n");
return -1;
}
return 0;
/* 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;
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;
}
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;
}
}
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;
}
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;
}
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;
}
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;
addr_t key;
if (!hook) {
- PrintError("Cannot allocate in hooking exec\n");
+ PrintError(vm, VCORE_NONE, "Cannot allocate in hooking exec\n");
return -1;
}
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;
}
}
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;
}
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;
}
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;
}
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++;
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++;
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;
}
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;
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;
}
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;
}
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;
}
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;
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;
}
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;
}
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;
}
/* 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;
}
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;
}
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++;
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++;
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;
}
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;
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;
}
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;
}
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;
}
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;
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;
}
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;
}
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;
}
/* 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;
}
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;
}
}
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;
}
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;
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;
}
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;
}
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];
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;
}
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;
}
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;
}
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;
}
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);
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);
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];
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;
}
// 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;
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;
}
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;
}
// 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;
}
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;
// 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;
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;
}
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 */
// 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;
}
#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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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;
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
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);
}
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;
}
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;
}
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;
}
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);
}
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);
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);
}
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);
}
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);
}
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);
}
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;
}
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;
}
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;
}
}
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);
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) {
}
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) {
}
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);
}
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;
}
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;
}
}
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);
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;
}
break;
}
default:
- PrintError("Invalid page type: %d\n", pt_type);
+ PrintError(VM_NONE, VCORE_NONE, "Invalid page type: %d\n", pt_type);
return -1;
}
break;
}
default:
- PrintError("Invalid page type: %d\n", pt_type);
+ PrintError(VM_NONE, VCORE_NONE, "Invalid page type: %d\n", pt_type);
return -1;
}
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;
rmap_list = V3_Malloc(sizeof(struct list_head));
if (!rmap_list) {
- PrintError("Cannot allocate\n");
+ PrintError(vm, VCORE_NONE, "Cannot allocate\n");
return -1;
}
entry = V3_Malloc(sizeof(struct rmap_entry));
if (!entry) {
- PrintError("Cannot allocate\n");
+ PrintError(vm, VCORE_NONE, "Cannot allocate\n");
return -1;
}
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;
}
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;
}
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;
}
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;
}
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;
}
} 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);
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;
}
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;
}
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);
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;
}
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);
}
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:
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;
}
}
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);
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;
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;
}
/* 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;
//
// 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;
(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;
}
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;
}
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;
}
}
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;
}
/* 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;
}
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;
}
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;
// 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;
}
}
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;
}
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;
}
}
} 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;
}
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;
}
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;
}
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;
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;
} 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;
}
}
// 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;
}
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 {
}
} 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;
}
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;
}
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;
}
{
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];
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;
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");
}
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;
}
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));
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));
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;
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;
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)) {
}
}
- 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,
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));
} 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;
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);
}
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;
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;
}
} 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:
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;
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;
}
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) {
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;
}
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;
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");
}
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) {
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;
}
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;
}
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;
}
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;
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;
}
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;
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;
}
}
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;
}
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");
}
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) {
* 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)));
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));
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 {
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;
}
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;
}
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);
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;
}
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;
}
}
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;
}
}
}
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;
*/
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;
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;
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;
}
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;
}
}
rmap_add(core, (addr_t)shadow_pte);
- PrintDebug("\twrpf: on writable\n");
+ PrintDebug(info->vm_info, info, "\twrpf: on writable\n");
return 1;
}
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;
}
/* 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;
//
// 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;
(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;
}
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;
}
}
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;
}
/* 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;
}
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)) {
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;
// 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;
}
}
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;
}
} 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;
}
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;
}
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;
}
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;
} 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;
}
}
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;
}
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;
}
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;
}
#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;
}
*/
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;
}
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);
// 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;
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));
}
}
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;
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;
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;
}
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;
}
}
rmap_add(core, (addr_t)shadow_pte);
- PrintDebug("\tWritePf: On Writable\n");
+ PrintDebug(info->vm_info, info, "\tWritePf: On Writable\n");
return 1;
}
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;
#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;
}
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);
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;
}
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;
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;
}
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));
}
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;
}
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;
}
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;
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;
}
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;
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;
}
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;
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;
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;
}
}
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);
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;
}
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;
}
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)) {
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;
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
}
}
- 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;
}
}
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;
}
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;
}
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);
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;
}
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;
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));
}
} 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;
}
}
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;
}
}
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) {
}
}
- 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;
}
}
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;
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);
}
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
// 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;
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;
}
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;
}
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
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));
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);
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) {
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
impl_state->impl_data = sb_state;
- PrintDebug("Initialized SwapBypass\n");
+ PrintDebug(vm, VCORE_NONE, "Initialized SwapBypass\n");
return 0;
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;
}
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;
}
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;
}
}
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;
}
}
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;
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;
}
/* 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;
//
// 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;
(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;
}
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;
}
}
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;
}
/* 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);
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;
}
*/
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
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;
#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");
}
}
// 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;
}
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;
// 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;
}
}
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;
}
}
} 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;
}
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;
}
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;
}
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;
} 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;
}
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;
}
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;
}
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;
}
*/
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;
}
// 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;
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;
//
// 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;
(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;
}
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;
}
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));
}
/* 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;
//
// 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;
(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;
}
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;
}
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);
/* 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;
//
// 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;
((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;
(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;
}
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;
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;
}
}
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);
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;
}
/* 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;
}
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;
}
// 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;
}
}
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;
}
}
} 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;
}
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;
}
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;
}
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;
}
} 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;
}
}
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;
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);
}
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));
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);
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;
}
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;
}
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;
}
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;
}
}
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;
}
}
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;
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;
}
/* 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;
//
// 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;
(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;
}
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;
}
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;
}
}
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;
}
/* 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;
}
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;
// 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;
}
}
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;
}
}
} 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;
}
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;
}
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;
}
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;
} 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;
}
}
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;
}
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;
}
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;
}
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 */
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;
} 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;
}
}
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;
}
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;
}
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;
}
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;
}
*/
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;
}
// 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;
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;
//
// 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;
(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;
}
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;
}
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));
}
/* 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;
//
// 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;
(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;
}
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;
}
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);
/* 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;
//
// 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;
((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;
(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;
}
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;
}
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;
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;
}
}
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);
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;
}
/* 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;
}
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;
}
} 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;
}
}
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;
}
}
} 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;
}
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;
}
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;
}
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;
}
} 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;
}
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;
}
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;
}
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;
}
} 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;
}
}
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;
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);
}
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;
}
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
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 */
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;
// 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 ;
}
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;
}
// 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;
}
// 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;
}
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;
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
} 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
}
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
}
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,
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;
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
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;
/* ** */
/*
- 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);
*/
#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;
}
- //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);
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;
}
}
// 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) {
}
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));
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));
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);
/*
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);
}
*/
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;
}
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;
}
}
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;
}
//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);
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;
}
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 ; "
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 */
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;
}
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;
// 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);
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;
}
break;
default:
- PrintError("Unhandled Exit Type (%d)\n", exit_type);
+ PrintError(core->vm_info, core, "Unhandled Exit Type (%d)\n", exit_type);
return -1;
}
break;
default:
- PrintError("Unhandled Exit Type (%d)\n", exit_type);
+ PrintError(core->vm_info, core, "Unhandled Exit Type (%d)\n", exit_type);
return -1;
}
- // 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: {
return -1;
}
} else {
- PrintError("Invalid MSR Operation\n");
+ PrintError(info->vm_info, info, "Invalid MSR Operation\n");
return -1;
}
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;
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;
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;
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;
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;
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;
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;
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;
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) {
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;
return -1;
}
} else {
- PrintError("Currently unhandled Nested Page Fault\n");
+ PrintError(info->vm_info, info, "Currently unhandled Nested Page Fault\n");
return -1;
}
break;
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;
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;
}
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;
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;
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;
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;
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;
#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;
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) {
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;
temp = V3_AllocPages(3);
if (!temp) {
- PrintError("Cannot allocate io bitmap\n");
+ PrintError(vm, VCORE_NONE, "Cannot allocate io bitmap\n");
return -1;
}
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;
}
}
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;
}
}
- 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;
} 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;
}
// 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;
}
//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;
}
}
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;
}
}
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;
// 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;
}
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;
}
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;
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;
}
}
(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;
}
}
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;
}
temp = V3_AllocPages(2);
if (!temp) {
- PrintError("Cannot allocate msr bitmap\n");
+ PrintError(vm, VCORE_NONE, "Cannot allocate msr bitmap\n");
return -1;
}
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;
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;
}
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;
}
} 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;
}
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
}
#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;
}
// 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;
}
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;
}
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;
}
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;
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;
}
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;
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;
}
*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;
*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;
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;
//
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;
}
*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;
}
*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;
}
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;
}
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;
}
*/
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;
}
*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;
}
*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;
}
*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;
}
*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;
}
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;
}
}
/*
- 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);
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;
}
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);
}
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;
}
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;
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);
}
}
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);
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);
#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__
- 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);
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);
#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);
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);
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);
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);
// 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);
}
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);
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);
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);
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);
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;
}
}
#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");
}
}
#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
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;
}
}
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;
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) {
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);
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) {
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
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;
}
for (i=0;i<vm->num_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;
}
}
/// 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
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;
}
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...
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;
}
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
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;
}
}
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;
}
#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;
}
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
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:
#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;
*/
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);
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;
}
v3_yield(NULL,-1);
}
- V3_Print("VM stopped. Returning\n");
+ V3_Print(vm, VCORE_NONE,"VM stopped. Returning\n");
return 0;
}
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;
}
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;
}
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);
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;
}
- 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
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) {
}
- V3_Print("Simulation is complete\n");
+ V3_Print(vm, VCORE_NONE,"Simulation is complete\n");
// Simulation is complete
// Reset back to PAUSED state
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;
}
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);
vsnprintf(buf, 2048, fmt, ap);
va_end(ap);
- V3_Print("%s", buf);
+ V3_Print(VM_NONE, VCORE_NONE,"%s", buf);
}
}
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;
+ }
+}
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
// 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)) {
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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;
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;
}
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;
}
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);
}
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;
}
"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;
}
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;
}
"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;
}
// 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;
}
"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;
}
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
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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);
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;
}
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);
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;
}
}
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;
}
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;
}
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;
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);
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;
}
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;
}
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;
}
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;
}
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;
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;
}
}
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;
}
}
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;
}
}
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;
}
}
// Currently will work only for shadow paging
for (i=0;i<vm->num_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;
}
}
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;
}
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;
}
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;
}
// 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);
}
// 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;
}
}
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);
// Currently will work only for shadow paging
for (i=0;i<vm->num_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;
}
}
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;
}
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;
}
//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;
}
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;
}
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;
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;
}
ctx = V3_Malloc(sizeof(struct file_ctx));
if (!ctx) {
- PrintError("Cannot allocate\n");
+ PrintError(VM_NONE, VCORE_NONE, "Cannot allocate\n");
return NULL;
}
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;
}
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;
}
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;
}
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;
}
// 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));
}
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);
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]);
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;
}
#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
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
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;
}
#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;
}
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;
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)) {
(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;
}
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;
}
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;
}
// 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;
}
* 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;
}
* 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;
}
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;
}
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;
}
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;
}
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
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;
}
}
- 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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
(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;
}
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;
}
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;
}
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;
}
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),
(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),
(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;
}
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;
}
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;
}
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
// 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 {
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;
}
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;
}
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)) {
*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);
*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) {
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
*(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;
}
}
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));
// 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));
}
} else {
- PrintError("Unhandled opcode in handle_cr3_write\n");
+ PrintError(info->vm_info, info, "Unhandled opcode in handle_cr3_write\n");
return -1;
}
}
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) {
}
} else {
- PrintError("Unhandled opcode in handle_cr3_read\n");
+ PrintError(info->vm_info, info, "Unhandled opcode in handle_cr3_read\n");
return -1;
}
// 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;
}
}
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;
}
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;
}
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;
}
} 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;
}
}
}
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)) {
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;
}
}
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)) {
*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;
}
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;
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;
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;
}
}
- 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;
* 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;
}
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;
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);
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]));
}
/* 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;
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);
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);
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++) {
}
for (i = 0; i < 80; i++) {
- V3_Print("-");
+ V3_Print(vm, VCORE_NONE, "-");
}
- V3_Print("\n");
+ V3_Print(vm, VCORE_NONE, "\n");
}
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)));
}
}
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));
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;
}
}
}
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;
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]));
}
}
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]));
}
}
})
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));
}
}
}
#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;
}
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;
}
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;
}
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;
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;
}
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;
}
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);
}
}
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);
}
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;
}
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;
}
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
}
}
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;
}
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;
}
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;
}
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));
// 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;
}
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;
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;
}
(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;
}
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;
}
(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;
}
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;
}
(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;
}
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;
}
(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;
}
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;
+}
temp = V3_AllocPages(1);
if (!temp) {
- PrintError("Cannot allocate page\n");
+ PrintError(VM_NONE, VCORE_NONE,"Cannot allocate page\n");
return 0;
}
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;
}
// 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;
}
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;
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:
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;
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;
return invalidate_addr_64(info, inv_addr);
default:
- PrintError("Unknown CPU Mode\n");
+ PrintError(info->vm_info, info, "Unknown CPU Mode\n");
break;
}
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;
}
}
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;
}
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;
}
}
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;
}
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;
}
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
}
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;
}
}
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;
}
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:
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:
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:
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:
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;
}
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) {
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;
}
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;
}
core->vm_regs.rcx -= rep_cnt;
}
} else {
- PrintError("Unimplemented String operation\n");
+ PrintError(core->vm_info, core, "Unimplemented String operation\n");
return -1;
}
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;
}
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));
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
}
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;
}
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;
}
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;
}
} 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);
}
- /* V3_Print("palacios: done with halt\n"); */
+ /* V3_Print(info->vm_info, info, "palacios: done with halt\n"); */
info->rip += 1;
}
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;
}
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;
}
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;
}
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;
}
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;
}
}
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;
}
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;
}
}
if (found == 0) {
- PrintError("Attempted to remove invalid interrupt router\n");
+ PrintError(vm, VCORE_NONE, "Attempted to remove invalid interrupt router\n");
return;
}
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];
}
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;
}
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;
}
}
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);
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;
}
}
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;
}
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;
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) {
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) {
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
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;
}
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;
}
#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
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);
}
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;
}
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;
}
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;
}
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;
}
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;
}
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));
}
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;
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);
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;
#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;
}
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;
}
} 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;
// 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;
}
}
// 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);
// 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;
}
}
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;
}
}
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;
}
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));
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);
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;
}
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;
}
}
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;
}
}
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;
}
}
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;
}
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;
}
// 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;
}
}
// 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;
}
}
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;
}
(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;
}
(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;
}
}
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;
}
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;
}
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;
}
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;
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;
}
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;
}
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;
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;
}
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;
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);
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);
}
}
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;
}
}
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;
}
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;
}
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;
}
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;
}
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);
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);
}
}
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;
}
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;
}
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) {
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) {
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;
}
//
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 );
//
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 );
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);
}
}
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) {
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) {
*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;
}
}
*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;
}
}
*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;
}
}
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);
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;
}
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;
}
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;
}
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);
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:
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;
}
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;
}
}
// 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;
}
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;
}
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;
}
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;
}
}
}
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;
}
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;
}
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;
}
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:
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;
}
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;
}
}
// 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;
}
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;
}
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;
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;
}
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;
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;
}
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;
}
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;
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;
}
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;
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;
}
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;
}
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;
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;
}
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;
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;
}
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;
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;
}
int ret = 0;
if (!callback) {
- PrintError("Callback was not specified\n");
+ PrintError(info->vm_info, info, "Callback was not specified\n");
return -1;
}
int ret = 0;
if (!callback) {
- PrintError("Callback was not specified\n");
+ PrintError(info->vm_info, info, "Callback was not specified\n");
return -1;
}
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,
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,
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,
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,
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,
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,
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,
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,
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,
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
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;
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;
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;
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;
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;
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;
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;
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;
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;
}
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);
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:
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);
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);
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;
}
}
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;
}
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");
}
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");
}
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;
}
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);
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;
}
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));
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 ;
}
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 <<
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;
}
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;
}
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;
}
} 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
(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;
}
*(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) {
&(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;
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;
}
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;
}
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;
}
(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);
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;
}
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;
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;
}
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:
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;
}
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;
}
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);
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);
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]);
}
}
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;
}
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
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;
}
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;
}
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;
}
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;
}
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;
}
}
if (impl->deinit(vm) == -1) {
- PrintError("Error deinitializing shadow paging implementation\n");
+ PrintError(vm, VCORE_NONE,"Error deinitializing shadow paging implementation\n");
return -1;
}
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;
}
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;
}
}
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;
}
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;
}
}
}
- PrintError("No callback found!\n");
+ PrintError(vm, VCORE_NONE, "No callback found!\n");
return -1;
}
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");
}
}
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;
}
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;
}
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
#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
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;
}
*/
#include <palacios/vm_guest.h>
+#include <palacios/vm_guest_mem.h>
#include <palacios/vmm_symcall.h>
#include <palacios/vmm_symspy.h>
#include <palacios/vmm_msr.h>
+#include <palacios/vmm_lowlevel.h>
+#include <palacios/vmm_debug.h>
// 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
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;
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);
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;
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;
}
}
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;
}
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) ||
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;
}
- // PrintError("restoring guest state\n");
+ // PrintError(core->vm_info, core, "restoring guest state\n");
// v3_print_guest_state(core);
return 0;
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;
}
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;
}
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;
}
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;
}
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;
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;
}
// 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++;
INIT_LIST_HEAD(&(symmod_state->v3_sym_list));
- V3_Print("Symmod initialized\n");
+ V3_Print(vm, VCORE_NONE, "Symmod initialized\n");
return 0;
}
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);
}
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;
}
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
(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;
}
} 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
(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;
}
(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;
}
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;
}
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);
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;
}
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;
}
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;
}
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 ;
}
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)
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;
}
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,
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;
}
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;
}
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;
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;
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);
}
}
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;
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);
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;
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;
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;
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);
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");
}
}
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);
}
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");
}
}
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);
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);
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);
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);
}
(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"
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;
}
timeouts->timeout_active = 1;
timeouts->next_timeout = cycles;
- return 0;
-}
+ return 0;}
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);
*/
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 {
}
snprintf(buf+strlen(buf),128-strlen(buf), "\n");
buf[strlen(buf)]=0;
- V3_Print("%s",buf);
+ V3_Print(VM_NONE, VCORE_NONE, "%s",buf);
}
}
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));
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;
}
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;
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;
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:
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;
}
} 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;
}
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;
}
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;
}
instr->src_operand.size = 1;
if (ret == -1) {
- PrintError("Error decoding operand\n");
+ PrintError(core->vm_info, core, "Error decoding operand\n");
return -1;
}
instr->src_operand.size = 2;
if (ret == -1) {
- PrintError("Error decoding operand\n");
+ PrintError(core->vm_info, core, "Error decoding operand\n");
return -1;
}
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;
}
®_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;
}
®_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;
}
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;
}
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;
}
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;
}
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,
}
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;
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;
}
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;
}
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;
}
}
} else {
- PrintError("Unhandled String OP\n");
+ PrintError(info->vm_info, info, "Unhandled String OP\n");
return -1;
}
/* 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;
}
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;
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;
}
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;
}
#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;
}
/*
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) {
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) {
&(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) {
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;
}
}
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;
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);
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)) {
&(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) {
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;
}
}
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);
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;
&(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) {
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)) {
}
} 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;
}
}
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)));
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;
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;
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;
}
- 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);
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) {
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:
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;
/*
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;
}
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));
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 ;
}
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;
}
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;
}
(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;
}
(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;
}
}
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;
}
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;
}
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;
}
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;
}
}
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;
}
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;
}
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;
}
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;
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);
}
#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();
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();
// 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;
}
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);
/* 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;
}
/* 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;
}
if (v3_init_ept(core, &hw_info) == -1) {
- PrintError("Error initializing EPT\n");
+ PrintError(core->vm_info, core, "Error initializing EPT\n");
return -1;
}
((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;
}
// 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;
}
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;
}
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;
}
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;
}
*/
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;
}
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;
}
}
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;
}
// 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;
}
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;
}
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;
}
}
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);
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);
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
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);
break;
}
case V3_NMI:
- PrintDebug("Injecting NMI\n");
+ PrintDebug(info->vm_info, info, "Injecting NMI\n");
ent_int.type = 2;
ent_int.vector = 2;
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;
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;
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--;
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;
}
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);
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;
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;
}
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));
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
}
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;
}
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) {
}
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);
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));
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);
}
/*
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);
}
*/
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;
}
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;
}
}
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;
}
}
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);
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;
}
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;
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;
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;
}
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;
}
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;
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;
}
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;
}
}
}
- 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;
}
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;
}
}
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;
}
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;
}
}
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;
}
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);
*/
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;
}
}
} else {
- PrintError("Unhandled paging mode\n");
+ PrintError(info->vm_info, info, "Unhandled paging mode\n");
return -1;
}
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);
}
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;
}
} else {
if (hw_efer->lme) {
- PrintDebug("Enabling long mode\n");
+ PrintDebug(info->vm_info, info, "Enabling long mode\n");
hw_efer->lma = 1;
}
}
- // 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;
}
}
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 {
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);
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;
}
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;
}
}
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;
}
}
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;
}
break;
default:
- PrintError("Unhandled Exit Type (%d)\n", exit_type);
+ PrintError(core->vm_info, core, "Unhandled Exit Type (%d)\n", exit_type);
return -1;
}
break;
default:
- PrintError("Unhandled Exit Type (%d)\n", exit_type);
+ PrintError(core->vm_info, core, "Unhandled Exit Type (%d)\n", exit_type);
return -1;
}
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);
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;
}
// 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;
}
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;
}
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;
}
}
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;
}
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;
}
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;
}
}
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;
}
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;
}
// 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);
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);
temp = V3_AllocPages(2);
if (!temp) {
- PrintError("Cannot allocate io bitmap\n");
+ PrintError(vm, VCORE_NONE, "Cannot allocate io bitmap\n");
return -1;
}
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;
}
}
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;
} 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;
}
}
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;
}
}
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;
}
}
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;
} 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;
}
}
- 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;
}
}
} 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;
}
}
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);
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);
}
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),
}
}
- PrintDebug("\n========Dump routes end ============\n");
+ PrintDebug(VM_NONE, VCORE_NONE, "\n========Dump routes end ============\n");
}
#endif
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;
}
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
}
break;
default:
- PrintError("Unknown qualifier %u\n",route_qual);
+ PrintError(VM_NONE, VCORE_NONE, "Unknown qualifier %u\n",route_qual);
return NONE;
break;
}
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
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),
#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;
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++;
}
- 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;
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;
}
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;
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;
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];
break;
default:
- PrintError("Unknown destination type\n");
+ PrintError(VM_NONE, VCORE_NONE, "Unknown destination type\n");
return -1;
break;
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?*/
}
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];
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);
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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);
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));
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;
}
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;
}