From: Jack Lange Date: Tue, 27 Jan 2009 21:07:20 +0000 (-0600) Subject: fixed instruction emulation for 64 bit machines X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=dc450df7818a872a3e8a3725ec97bdc273756b06 fixed instruction emulation for 64 bit machines --- diff --git a/palacios/build/Makefile b/palacios/build/Makefile index 8ebcd21..6b8332b 100644 --- a/palacios/build/Makefile +++ b/palacios/build/Makefile @@ -265,6 +265,7 @@ VMM_OBJS := \ palacios/vmm_msr.o \ palacios/svm_msr.o \ palacios/vmm_socket.o \ + palacios/vmm_xed.o \ # vmx.c vmcs_gen.c vmcs.c @@ -296,17 +297,6 @@ DEVICES_OBJS := \ $(DEVICES_OBJS) :: EXTRA_CFLAGS = \ $(JRLDEBUG) \ -# -# DECODER is the decoder that will be used -# currently we only support xed -# -DECODER=XED - -ifeq ($(DECODER),XED) -VMM_OBJS += palacios/vmm_xed.o -else -# This is an error -endif diff --git a/palacios/include/palacios/vmm_instr_emulator.h b/palacios/include/palacios/vmm_instr_emulator.h index 190dcee..74701a5 100644 --- a/palacios/include/palacios/vmm_instr_emulator.h +++ b/palacios/include/palacios/vmm_instr_emulator.h @@ -250,8 +250,8 @@ "pushf; " \ "pop %0; " \ "popf; " \ - : "=b"(*flags) \ - : "D"(*dst),"S"(*src),"c"(*ecx),"b"(*flags) \ + : "=q"(*flags) \ + : "D"(*dst),"S"(*src),"c"(*ecx),"q"(*flags) \ ); \ \ /* : "=D"(*dst),"=S"(*src),"=c"(*ecx),"=q"(*flags)*/ \ @@ -273,8 +273,8 @@ "pushf; " \ "pop %0; " \ "popf; " \ - : "=b"(*flags) \ - : "D"(*dst),"S"(*src),"c"(*ecx),"b"(*flags) \ + : "=q"(*flags) \ + : "D"(*dst),"S"(*src),"c"(*ecx),"q"(*flags) \ ); \ *flags |= flags_rsvd; \ } @@ -296,8 +296,8 @@ "pushf; " \ "pop %0; " \ "popf; " \ - : "=b"(*flags) \ - : "D"(*dst),"S"(*src),"c"(*ecx),"b"(*flags) \ + : "=q"(*flags) \ + : "D"(*dst),"S"(*src),"c"(*ecx),"q"(*flags) \ ); \ *flags |= flags_rsvd; \ } diff --git a/palacios/include/palacios/vmm_mem.h b/palacios/include/palacios/vmm_mem.h index e08e473..3616bc7 100644 --- a/palacios/include/palacios/vmm_mem.h +++ b/palacios/include/palacios/vmm_mem.h @@ -127,7 +127,7 @@ int v3_hook_write_mem(struct guest_info * info, addr_t guest_addr_start, addr_t int (*write)(addr_t guest_addr, void * src, uint_t length, void * priv_data), void * priv_data); -int unhook_guest_mem(struct guest_info * info, addr_t guest_addr); + diff --git a/palacios/include/palacios/vmm_rbtree.h b/palacios/include/palacios/vmm_rbtree.h index 44131fc..6b72d6d 100644 --- a/palacios/include/palacios/vmm_rbtree.h +++ b/palacios/include/palacios/vmm_rbtree.h @@ -96,6 +96,11 @@ static inline struct page * rb_insert_page_cache(struct inode * inode, #ifdef __V3VEE__ +#include + + +#undef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ diff --git a/palacios/src/palacios/vmm_paging.c b/palacios/src/palacios/vmm_paging.c index 12163f8..271ee3f 100644 --- a/palacios/src/palacios/vmm_paging.c +++ b/palacios/src/palacios/vmm_paging.c @@ -46,6 +46,11 @@ static pt_entry_type_t pte64_lookup(pte64_t * pt, addr_t addr, addr_t * entry); +#ifndef DEBUG_SHADOW_PAGING +#undef PrintDebug +#define PrintDebug(fmt, args...) +#endif + void delete_page_tables_32(pde32_t * pde) { diff --git a/palacios/src/palacios/vmm_xed.c b/palacios/src/palacios/vmm_xed.c index f34408b..3c39b13 100644 --- a/palacios/src/palacios/vmm_xed.c +++ b/palacios/src/palacios/vmm_xed.c @@ -67,12 +67,16 @@ static const ullong_t mask_8 = 0xffffffffffffffffLL; switch (length) { \ case 1: \ mask = mask_1; \ + break; \ case 2: \ mask = mask_2; \ + break; \ case 4: \ mask = mask_4; \ + break; \ case 8: \ mask = mask_8; \ + break; \ } \ val & mask;}) \ @@ -581,14 +585,14 @@ static int get_memory_operand(struct guest_info * info, xed_decoded_inst_t * xe - PrintDebug("Struct: Seg=%p, base=%p, index=%p, scale=%p, displacement=%p\n", + PrintDebug("Struct: Seg=%p, base=%p, index=%p, scale=%p, displacement=%p (size=%d)\n", (void *)mem_op.segment, (void*)mem_op.base, (void *)mem_op.index, - (void *)mem_op.scale, (void *)(addr_t)mem_op.displacement); + (void *)mem_op.scale, (void *)(addr_t)mem_op.displacement, mem_op.displacement_size); PrintDebug("operand size: %d\n", operand->size); - seg = mem_op.segment; + seg = MASK(mem_op.segment, mem_op.segment_size); base = MASK(mem_op.base, mem_op.base_size); index = MASK(mem_op.index, mem_op.index_size); scale = mem_op.scale;