From: Erik van der Kouwe Date: Tue, 13 Apr 2010 22:07:57 +0000 (-0500) Subject: s patch fixes some issues I've had when compiling Palacios 32-bit. X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=6541ca672276d841db22cc18a003303cf517ea89 s patch fixes some issues I've had when compiling Palacios 32-bit. --- diff --git a/palacios/include/palacios/vmx_lowlevel.h b/palacios/include/palacios/vmx_lowlevel.h index 9ea6ffb..01bca79 100644 --- a/palacios/include/palacios/vmx_lowlevel.h +++ b/palacios/include/palacios/vmx_lowlevel.h @@ -128,7 +128,7 @@ static inline int vmcs_store(addr_t vmcs_ptr) { } static inline int vmcs_read(vmcs_field_t vmcs_field, void * dst) { - uint64_t val = 0; + addr_t val = 0; uint8_t ret_valid = 0; uint8_t ret_invalid = 0; @@ -170,7 +170,7 @@ static inline int vmcs_write(vmcs_field_t vmcs_field, addr_t value) { EAX_ECX_MODRM "seteb %0;" // fail valid (ZF=1) "setnaeb %1;" // fail invalid (CF=1) - : "=r" (ret_valid), "=r" (ret_invalid) + : "=q" (ret_valid), "=q" (ret_invalid) : "a" (vmcs_field), "c"(value) : "memory"); diff --git a/palacios/src/devices/netdisk.c b/palacios/src/devices/netdisk.c index 3052a9b..006776a 100644 --- a/palacios/src/devices/netdisk.c +++ b/palacios/src/devices/netdisk.c @@ -261,7 +261,7 @@ static int socket_init(struct disk_state * disk) { return -1; } - PrintDebug("Capacity: %p\n", (void *)(disk->capacity)); + PrintDebug("Capacity: %p\n", (void *)(addr_t)disk->capacity); } diff --git a/palacios/src/palacios/vmcs.c b/palacios/src/palacios/vmcs.c index 9156e23..a77de77 100644 --- a/palacios/src/palacios/vmcs.c +++ b/palacios/src/palacios/vmcs.c @@ -270,24 +270,45 @@ int v3_update_vmcs_host_state(struct guest_info * info) { struct vmx_data * arch_data = (struct vmx_data *)(info->vmm_data); struct v3_msr tmp_msr; +#ifdef __V3_64BIT__ __asm__ __volatile__ ( "movq %%cr0, %0; " : "=q"(tmp) : ); +#else + __asm__ __volatile__ ( "movl %%cr0, %0; " + : "=q"(tmp) + : + ); +#endif vmx_ret |= check_vmcs_write(VMCS_HOST_CR0, tmp); +#ifdef __V3_64BIT__ __asm__ __volatile__ ( "movq %%cr3, %0; " : "=q"(tmp) : ); +#else + __asm__ __volatile__ ( "movl %%cr3, %0; " + : "=q"(tmp) + : + ); +#endif vmx_ret |= check_vmcs_write(VMCS_HOST_CR3, tmp); +#ifdef __V3_64BIT__ __asm__ __volatile__ ( "movq %%cr4, %0; " : "=q"(tmp) : ); +#else + __asm__ __volatile__ ( "movl %%cr4, %0; " + : "=q"(tmp) + : + ); +#endif vmx_ret |= check_vmcs_write(VMCS_HOST_CR4, tmp); @@ -309,40 +330,82 @@ int v3_update_vmcs_host_state(struct guest_info * info) { +#ifdef __V3_64BIT__ __asm__ __volatile__ ( "movq %%cs, %0; " : "=q"(tmp) : ); +#else + __asm__ __volatile__ ( "movl %%cs, %0; " + : "=q"(tmp) + : + ); +#endif vmx_ret |= check_vmcs_write(VMCS_HOST_CS_SELECTOR, tmp); +#ifdef __V3_64BIT__ __asm__ __volatile__ ( "movq %%ss, %0; " : "=q"(tmp) : ); +#else + __asm__ __volatile__ ( "movl %%ss, %0; " + : "=q"(tmp) + : + ); +#endif vmx_ret |= check_vmcs_write(VMCS_HOST_SS_SELECTOR, tmp); +#ifdef __V3_64BIT__ __asm__ __volatile__ ( "movq %%ds, %0; " : "=q"(tmp) : ); +#else + __asm__ __volatile__ ( "movl %%ds, %0; " + : "=q"(tmp) + : + ); +#endif vmx_ret |= check_vmcs_write(VMCS_HOST_DS_SELECTOR, tmp); +#ifdef __V3_64BIT__ __asm__ __volatile__ ( "movq %%es, %0; " : "=q"(tmp) : ); +#else + __asm__ __volatile__ ( "movl %%es, %0; " + : "=q"(tmp) + : + ); +#endif vmx_ret |= check_vmcs_write(VMCS_HOST_ES_SELECTOR, tmp); +#ifdef __V3_64BIT__ __asm__ __volatile__ ( "movq %%fs, %0; " : "=q"(tmp) : ); +#else + __asm__ __volatile__ ( "movl %%fs, %0; " + : "=q"(tmp) + : + ); +#endif vmx_ret |= check_vmcs_write(VMCS_HOST_FS_SELECTOR, tmp); +#ifdef __V3_64BIT__ __asm__ __volatile__ ( "movq %%gs, %0; " : "=q"(tmp) : ); +#else + __asm__ __volatile__ ( "movl %%gs, %0; " + : "=q"(tmp) + : + ); +#endif vmx_ret |= check_vmcs_write(VMCS_HOST_GS_SELECTOR, tmp); vmx_ret |= check_vmcs_write(VMCS_HOST_TR_SELECTOR, arch_data->host_state.tr.selector); diff --git a/palacios/src/palacios/vmx.c b/palacios/src/palacios/vmx.c index 4a8c021..efc8e24 100644 --- a/palacios/src/palacios/vmx.c +++ b/palacios/src/palacios/vmx.c @@ -494,7 +494,7 @@ static int update_irq_entry_state(struct guest_info * info) { int_info.valid = 1; #ifdef CONFIG_DEBUG_INTERRUPTS - PrintDebug("Injecting exception %d (EIP=%p)\n", int_info.vector, (void *)info->rip); + PrintDebug("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); @@ -536,7 +536,7 @@ static int update_irq_entry_state(struct guest_info * info) { PrintDebug("Injecting Interrupt %d at exit %u(EIP=%p)\n", info->intr_state.irq_vector, (uint32_t)info->num_exits, - (void *)info->rip); + (void *)(addr_t)info->rip); #endif check_vmcs_write(VMCS_ENTRY_INT_INFO, ent_int.value); @@ -825,9 +825,9 @@ void v3_init_vmx_cpu(int cpu_id) { ); #elif __V3_32BIT__ __asm__ __volatile__ ( - "movq %%cr4, %%ecx;" - "orq $0x00002000, %%ecx;" - "movq %%ecx, %0;" + "movl %%cr4, %%ecx;" + "orl $0x00002000, %%ecx;" + "movl %%ecx, %0;" : "=m"(ret) : : "%ecx" @@ -835,7 +835,7 @@ void v3_init_vmx_cpu(int cpu_id) { if ((~ret & tmp_msr.value) == 0) { __asm__ __volatile__ ( - "movq %0, %%cr4;" + "movl %0, %%cr4;" : : "q"(ret) ); @@ -845,9 +845,9 @@ void v3_init_vmx_cpu(int cpu_id) { } __asm__ __volatile__ ( - "movq %%cr0, %%ecx; " - "orq $0x00000020,%%ecx; " - "movq %%ecx, %%cr0;" + "movl %%cr0, %%ecx; " + "orl $0x00000020,%%ecx; " + "movl %%ecx, %%cr0;" : : : "%ecx" diff --git a/palacios/src/palacios/vmx_assist.c b/palacios/src/palacios/vmx_assist.c index f926c42..892a69e 100644 --- a/palacios/src/palacios/vmx_assist.c +++ b/palacios/src/palacios/vmx_assist.c @@ -105,7 +105,7 @@ static void load_segment(struct vmx_assist_segment * vmx_assist_seg, struct v3_s static void vmx_save_world_ctx(struct guest_info * info, struct vmx_assist_context * ctx) { struct vmx_data * vmx_info = (struct vmx_data *)(info->vmm_data); - PrintDebug("Writing from RIP: 0x%p\n", (void *)info->rip); + PrintDebug("Writing from RIP: 0x%p\n", (void *)(addr_t)info->rip); ctx->eip = info->rip; ctx->esp = info->vm_regs.rsp; diff --git a/palacios/src/palacios/vmx_ctrl_regs.c b/palacios/src/palacios/vmx_ctrl_regs.c index c7bf6e3..eb12760 100644 --- a/palacios/src/palacios/vmx_ctrl_regs.c +++ b/palacios/src/palacios/vmx_ctrl_regs.c @@ -157,10 +157,10 @@ static int handle_mov_to_cr0(struct guest_info * info, v3_reg_t * new_cr0, struc } if (vmx_info->state == VMXASSIST_ENABLED) { - PrintDebug("Loading VMXASSIST at RIP: %p\n", (void *)info->rip); + PrintDebug("Loading VMXASSIST at RIP: %p\n", (void *)(addr_t)info->rip); } else { PrintDebug("Leaving VMXASSIST and entering protected mode at RIP: %p\n", - (void *)info->rip); + (void *)(addr_t)info->rip); } // PE switches modify the RIP directly, so we clear the instr_len field to avoid catastrophe