Merge branch 'w64' of git://qemu.weilnetz.de/qemu

* 'w64' of git://qemu.weilnetz.de/qemu:
  w64: Fix time conversion for some versions of MinGW-w64
  nbd: Fix compiler warning (w64)
  disas: Replace 'unsigned long' by 'uintptr_t'
  cpu-exec: Remove non-portable type cast and fix format string
  target-mips: Fix type cast for w64 (uintptr_t)
  w64: Fix type cast in os_host_main_loop_wait
  w64: Fix data types in softmmu*.h
  w64: Use uintptr_t in exec.c
  softmmu: Use uintptr_t for physaddr and rename it
  w64: Fix struct CPUTLBEntry
  w64: Fix definition of setjmp
  w32: Move defines for socket specific errors to qemu-os-win32.h
  w64: Use larger alignment for section with generated code
  w64: Fix data types in cpu-all.h, exec.c
  w64: Fix type casts used in some macros in cpu-all.h
  tcg/i386: Add support for w64 ABI
  tcg/i386: Use GDB JIT debugging interface only for hosts with ELF
This commit is contained in:
Blue Swirl 2012-04-15 19:56:06 +00:00
commit e6f5d0be73
15 changed files with 152 additions and 112 deletions

View File

@ -222,8 +222,8 @@ extern unsigned long reserved_va;
#else /* !CONFIG_USER_ONLY */ #else /* !CONFIG_USER_ONLY */
/* NOTE: we use double casts if pointers and target_ulong have /* NOTE: we use double casts if pointers and target_ulong have
different sizes */ different sizes */
#define saddr(x) (uint8_t *)(long)(x) #define saddr(x) (uint8_t *)(intptr_t)(x)
#define laddr(x) (uint8_t *)(long)(x) #define laddr(x) (uint8_t *)(intptr_t)(x)
#endif #endif
#define ldub_raw(p) ldub_p(laddr((p))) #define ldub_raw(p) ldub_p(laddr((p)))
@ -299,10 +299,10 @@ extern unsigned long reserved_va;
#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) #define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)
#define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) #define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK)
/* ??? These should be the larger of unsigned long and target_ulong. */ /* ??? These should be the larger of uintptr_t and target_ulong. */
extern unsigned long qemu_real_host_page_size; extern uintptr_t qemu_real_host_page_size;
extern unsigned long qemu_host_page_size; extern uintptr_t qemu_host_page_size;
extern unsigned long qemu_host_page_mask; extern uintptr_t qemu_host_page_mask;
#define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask) #define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)

View File

@ -98,12 +98,12 @@ typedef struct CPUTLBEntry {
target_ulong addr_code; target_ulong addr_code;
/* Addend to virtual address to get host address. IO accesses /* Addend to virtual address to get host address. IO accesses
use the corresponding iotlb value. */ use the corresponding iotlb value. */
unsigned long addend; uintptr_t addend;
/* padding to get a power of two size */ /* padding to get a power of two size */
uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) - uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) -
(sizeof(target_ulong) * 3 + (sizeof(target_ulong) * 3 +
((-sizeof(target_ulong) * 3) & (sizeof(unsigned long) - 1)) + ((-sizeof(target_ulong) * 3) & (sizeof(uintptr_t) - 1)) +
sizeof(unsigned long))]; sizeof(uintptr_t))];
} CPUTLBEntry; } CPUTLBEntry;
extern int CPUTLBEntry_wrong_size[sizeof(CPUTLBEntry) == (1 << CPU_TLB_ENTRY_BITS) ? 1 : -1]; extern int CPUTLBEntry_wrong_size[sizeof(CPUTLBEntry) == (1 << CPU_TLB_ENTRY_BITS) ? 1 : -1];

View File

@ -541,8 +541,8 @@ int cpu_exec(CPUArchState *env)
tb_invalidated_flag = 0; tb_invalidated_flag = 0;
} }
#ifdef CONFIG_DEBUG_EXEC #ifdef CONFIG_DEBUG_EXEC
qemu_log_mask(CPU_LOG_EXEC, "Trace 0x%08lx [" TARGET_FMT_lx "] %s\n", qemu_log_mask(CPU_LOG_EXEC, "Trace %p [" TARGET_FMT_lx "] %s\n",
(long)tb->tc_ptr, tb->pc, tb->tc_ptr, tb->pc,
lookup_symbol(tb->pc)); lookup_symbol(tb->pc));
#endif #endif
/* see if we can patch the calling TB. When the TB /* see if we can patch the calling TB. When the TB

View File

@ -268,7 +268,7 @@ void target_disas(FILE *out, target_ulong code, target_ulong size, int flags)
/* Disassemble this for me please... (debugging). */ /* Disassemble this for me please... (debugging). */
void disas(FILE *out, void *code, unsigned long size) void disas(FILE *out, void *code, unsigned long size)
{ {
unsigned long pc; uintptr_t pc;
int count; int count;
struct disassemble_info disasm_info; struct disassemble_info disasm_info;
int (*print_insn)(bfd_vma pc, disassemble_info *info); int (*print_insn)(bfd_vma pc, disassemble_info *info);
@ -276,7 +276,7 @@ void disas(FILE *out, void *code, unsigned long size)
INIT_DISASSEMBLE_INFO(disasm_info, out, fprintf); INIT_DISASSEMBLE_INFO(disasm_info, out, fprintf);
disasm_info.buffer = code; disasm_info.buffer = code;
disasm_info.buffer_vma = (unsigned long)code; disasm_info.buffer_vma = (uintptr_t)code;
disasm_info.buffer_length = size; disasm_info.buffer_length = size;
#ifdef HOST_WORDS_BIGENDIAN #ifdef HOST_WORDS_BIGENDIAN
@ -320,8 +320,8 @@ void disas(FILE *out, void *code, unsigned long size)
(long) code); (long) code);
return; return;
#endif #endif
for (pc = (unsigned long)code; size > 0; pc += count, size -= count) { for (pc = (uintptr_t)code; size > 0; pc += count, size -= count) {
fprintf(out, "0x%08lx: ", pc); fprintf(out, "0x%08" PRIxPTR ": ", pc);
count = print_insn(pc, &disasm_info); count = print_insn(pc, &disasm_info);
fprintf(out, "\n"); fprintf(out, "\n");
if (count < 0) if (count < 0)

86
exec.c
View File

@ -93,8 +93,7 @@ spinlock_t tb_lock = SPIN_LOCK_UNLOCKED;
#define code_gen_section \ #define code_gen_section \
__attribute__((__section__(".gen_code"))) \ __attribute__((__section__(".gen_code"))) \
__attribute__((aligned (32))) __attribute__((aligned (32)))
#elif defined(_WIN32) #elif defined(_WIN32) && !defined(_WIN64)
/* Maximum alignment for Win32 is 16. */
#define code_gen_section \ #define code_gen_section \
__attribute__((aligned (16))) __attribute__((aligned (16)))
#else #else
@ -177,9 +176,9 @@ typedef struct PageDesc {
#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS) #define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)
unsigned long qemu_real_host_page_size; uintptr_t qemu_real_host_page_size;
unsigned long qemu_host_page_size; uintptr_t qemu_host_page_size;
unsigned long qemu_host_page_mask; uintptr_t qemu_host_page_mask;
/* This is a multi-level map on the virtual address space. /* This is a multi-level map on the virtual address space.
The bottom level has pointers to PageDesc. */ The bottom level has pointers to PageDesc. */
@ -888,8 +887,8 @@ static inline void tb_page_remove(TranslationBlock **ptb, TranslationBlock *tb)
for(;;) { for(;;) {
tb1 = *ptb; tb1 = *ptb;
n1 = (long)tb1 & 3; n1 = (uintptr_t)tb1 & 3;
tb1 = (TranslationBlock *)((long)tb1 & ~3); tb1 = (TranslationBlock *)((uintptr_t)tb1 & ~3);
if (tb1 == tb) { if (tb1 == tb) {
*ptb = tb1->page_next[n1]; *ptb = tb1->page_next[n1];
break; break;
@ -909,8 +908,8 @@ static inline void tb_jmp_remove(TranslationBlock *tb, int n)
/* find tb(n) in circular list */ /* find tb(n) in circular list */
for(;;) { for(;;) {
tb1 = *ptb; tb1 = *ptb;
n1 = (long)tb1 & 3; n1 = (uintptr_t)tb1 & 3;
tb1 = (TranslationBlock *)((long)tb1 & ~3); tb1 = (TranslationBlock *)((uintptr_t)tb1 & ~3);
if (n1 == n && tb1 == tb) if (n1 == n && tb1 == tb)
break; break;
if (n1 == 2) { if (n1 == 2) {
@ -930,7 +929,7 @@ static inline void tb_jmp_remove(TranslationBlock *tb, int n)
another TB */ another TB */
static inline void tb_reset_jump(TranslationBlock *tb, int n) static inline void tb_reset_jump(TranslationBlock *tb, int n)
{ {
tb_set_jmp_target(tb, n, (unsigned long)(tb->tc_ptr + tb->tb_next_offset[n])); tb_set_jmp_target(tb, n, (uintptr_t)(tb->tc_ptr + tb->tb_next_offset[n]));
} }
void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)
@ -975,16 +974,16 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)
/* suppress any remaining jumps to this TB */ /* suppress any remaining jumps to this TB */
tb1 = tb->jmp_first; tb1 = tb->jmp_first;
for(;;) { for(;;) {
n1 = (long)tb1 & 3; n1 = (uintptr_t)tb1 & 3;
if (n1 == 2) if (n1 == 2)
break; break;
tb1 = (TranslationBlock *)((long)tb1 & ~3); tb1 = (TranslationBlock *)((uintptr_t)tb1 & ~3);
tb2 = tb1->jmp_next[n1]; tb2 = tb1->jmp_next[n1];
tb_reset_jump(tb1, n1); tb_reset_jump(tb1, n1);
tb1->jmp_next[n1] = NULL; tb1->jmp_next[n1] = NULL;
tb1 = tb2; tb1 = tb2;
} }
tb->jmp_first = (TranslationBlock *)((long)tb | 2); /* fail safe */ tb->jmp_first = (TranslationBlock *)((uintptr_t)tb | 2); /* fail safe */
tb_phys_invalidate_count++; tb_phys_invalidate_count++;
} }
@ -1025,8 +1024,8 @@ static void build_page_bitmap(PageDesc *p)
tb = p->first_tb; tb = p->first_tb;
while (tb != NULL) { while (tb != NULL) {
n = (long)tb & 3; n = (uintptr_t)tb & 3;
tb = (TranslationBlock *)((long)tb & ~3); tb = (TranslationBlock *)((uintptr_t)tb & ~3);
/* NOTE: this is subtle as a TB may span two physical pages */ /* NOTE: this is subtle as a TB may span two physical pages */
if (n == 0) { if (n == 0) {
/* NOTE: tb_end may be after the end of the page, but /* NOTE: tb_end may be after the end of the page, but
@ -1070,7 +1069,8 @@ TranslationBlock *tb_gen_code(CPUArchState *env,
tb->flags = flags; tb->flags = flags;
tb->cflags = cflags; tb->cflags = cflags;
cpu_gen_code(env, tb, &code_gen_size); cpu_gen_code(env, tb, &code_gen_size);
code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1)); code_gen_ptr = (void *)(((uintptr_t)code_gen_ptr + code_gen_size +
CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));
/* check next page if needed */ /* check next page if needed */
virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK; virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
@ -1118,8 +1118,8 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,
/* XXX: see if in some cases it could be faster to invalidate all the code */ /* XXX: see if in some cases it could be faster to invalidate all the code */
tb = p->first_tb; tb = p->first_tb;
while (tb != NULL) { while (tb != NULL) {
n = (long)tb & 3; n = (uintptr_t)tb & 3;
tb = (TranslationBlock *)((long)tb & ~3); tb = (TranslationBlock *)((uintptr_t)tb & ~3);
tb_next = tb->page_next[n]; tb_next = tb->page_next[n];
/* NOTE: this is subtle as a TB may span two physical pages */ /* NOTE: this is subtle as a TB may span two physical pages */
if (n == 0) { if (n == 0) {
@ -1202,7 +1202,8 @@ static inline void tb_invalidate_phys_page_fast(tb_page_addr_t start, int len)
qemu_log("modifying code at 0x%x size=%d EIP=%x PC=%08x\n", qemu_log("modifying code at 0x%x size=%d EIP=%x PC=%08x\n",
cpu_single_env->mem_io_vaddr, len, cpu_single_env->mem_io_vaddr, len,
cpu_single_env->eip, cpu_single_env->eip,
cpu_single_env->eip + (long)cpu_single_env->segs[R_CS].base); cpu_single_env->eip +
(intptr_t)cpu_single_env->segs[R_CS].base);
} }
#endif #endif
p = page_find(start >> TARGET_PAGE_BITS); p = page_find(start >> TARGET_PAGE_BITS);
@ -1246,8 +1247,8 @@ static void tb_invalidate_phys_page(tb_page_addr_t addr,
} }
#endif #endif
while (tb != NULL) { while (tb != NULL) {
n = (long)tb & 3; n = (uintptr_t)tb & 3;
tb = (TranslationBlock *)((long)tb & ~3); tb = (TranslationBlock *)((uintptr_t)tb & ~3);
#ifdef TARGET_HAS_PRECISE_SMC #ifdef TARGET_HAS_PRECISE_SMC
if (current_tb == tb && if (current_tb == tb &&
(current_tb->cflags & CF_COUNT_MASK) != 1) { (current_tb->cflags & CF_COUNT_MASK) != 1) {
@ -1295,7 +1296,7 @@ static inline void tb_alloc_page(TranslationBlock *tb,
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY
page_already_protected = p->first_tb != NULL; page_already_protected = p->first_tb != NULL;
#endif #endif
p->first_tb = (TranslationBlock *)((long)tb | n); p->first_tb = (TranslationBlock *)((uintptr_t)tb | n);
invalidate_page_bitmap(p); invalidate_page_bitmap(p);
#if defined(TARGET_HAS_SMC) || 1 #if defined(TARGET_HAS_SMC) || 1
@ -1362,7 +1363,7 @@ void tb_link_page(TranslationBlock *tb,
else else
tb->page_addr[1] = -1; tb->page_addr[1] = -1;
tb->jmp_first = (TranslationBlock *)((long)tb | 2); tb->jmp_first = (TranslationBlock *)((uintptr_t)tb | 2);
tb->jmp_next[0] = NULL; tb->jmp_next[0] = NULL;
tb->jmp_next[1] = NULL; tb->jmp_next[1] = NULL;
@ -1383,21 +1384,22 @@ void tb_link_page(TranslationBlock *tb,
TranslationBlock *tb_find_pc(uintptr_t tc_ptr) TranslationBlock *tb_find_pc(uintptr_t tc_ptr)
{ {
int m_min, m_max, m; int m_min, m_max, m;
unsigned long v; uintptr_t v;
TranslationBlock *tb; TranslationBlock *tb;
if (nb_tbs <= 0) if (nb_tbs <= 0)
return NULL; return NULL;
if (tc_ptr < (unsigned long)code_gen_buffer || if (tc_ptr < (uintptr_t)code_gen_buffer ||
tc_ptr >= (unsigned long)code_gen_ptr) tc_ptr >= (uintptr_t)code_gen_ptr) {
return NULL; return NULL;
}
/* binary search (cf Knuth) */ /* binary search (cf Knuth) */
m_min = 0; m_min = 0;
m_max = nb_tbs - 1; m_max = nb_tbs - 1;
while (m_min <= m_max) { while (m_min <= m_max) {
m = (m_min + m_max) >> 1; m = (m_min + m_max) >> 1;
tb = &tbs[m]; tb = &tbs[m];
v = (unsigned long)tb->tc_ptr; v = (uintptr_t)tb->tc_ptr;
if (v == tc_ptr) if (v == tc_ptr)
return tb; return tb;
else if (tc_ptr < v) { else if (tc_ptr < v) {
@ -1420,8 +1422,8 @@ static inline void tb_reset_jump_recursive2(TranslationBlock *tb, int n)
if (tb1 != NULL) { if (tb1 != NULL) {
/* find head of list */ /* find head of list */
for(;;) { for(;;) {
n1 = (long)tb1 & 3; n1 = (uintptr_t)tb1 & 3;
tb1 = (TranslationBlock *)((long)tb1 & ~3); tb1 = (TranslationBlock *)((uintptr_t)tb1 & ~3);
if (n1 == 2) if (n1 == 2)
break; break;
tb1 = tb1->jmp_next[n1]; tb1 = tb1->jmp_next[n1];
@ -1433,8 +1435,8 @@ static inline void tb_reset_jump_recursive2(TranslationBlock *tb, int n)
ptb = &tb_next->jmp_first; ptb = &tb_next->jmp_first;
for(;;) { for(;;) {
tb1 = *ptb; tb1 = *ptb;
n1 = (long)tb1 & 3; n1 = (uintptr_t)tb1 & 3;
tb1 = (TranslationBlock *)((long)tb1 & ~3); tb1 = (TranslationBlock *)((uintptr_t)tb1 & ~3);
if (n1 == n && tb1 == tb) if (n1 == n && tb1 == tb)
break; break;
ptb = &tb1->jmp_next[n1]; ptb = &tb1->jmp_next[n1];
@ -2041,9 +2043,9 @@ static bool tlb_is_dirty_ram(CPUTLBEntry *tlbe)
} }
static inline void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, static inline void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry,
unsigned long start, unsigned long length) uintptr_t start, uintptr_t length)
{ {
unsigned long addr; uintptr_t addr;
if (tlb_is_dirty_ram(tlb_entry)) { if (tlb_is_dirty_ram(tlb_entry)) {
addr = (tlb_entry->addr_write & TARGET_PAGE_MASK) + tlb_entry->addend; addr = (tlb_entry->addr_write & TARGET_PAGE_MASK) + tlb_entry->addend;
if ((addr - start) < length) { if ((addr - start) < length) {
@ -2057,7 +2059,7 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
int dirty_flags) int dirty_flags)
{ {
CPUArchState *env; CPUArchState *env;
unsigned long length, start1; uintptr_t length, start1;
int i; int i;
start &= TARGET_PAGE_MASK; start &= TARGET_PAGE_MASK;
@ -2070,10 +2072,10 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
/* we modify the TLB cache so that the dirty bit will be set again /* we modify the TLB cache so that the dirty bit will be set again
when accessing the range */ when accessing the range */
start1 = (unsigned long)qemu_safe_ram_ptr(start); start1 = (uintptr_t)qemu_safe_ram_ptr(start);
/* Check that we don't span multiple blocks - this breaks the /* Check that we don't span multiple blocks - this breaks the
address comparisons below. */ address comparisons below. */
if ((unsigned long)qemu_safe_ram_ptr(end - 1) - start1 if ((uintptr_t)qemu_safe_ram_ptr(end - 1) - start1
!= (end - 1) - start) { != (end - 1) - start) {
abort(); abort();
} }
@ -2101,7 +2103,7 @@ static inline void tlb_update_dirty(CPUTLBEntry *tlb_entry)
void *p; void *p;
if (tlb_is_dirty_ram(tlb_entry)) { if (tlb_is_dirty_ram(tlb_entry)) {
p = (void *)(unsigned long)((tlb_entry->addr_write & TARGET_PAGE_MASK) p = (void *)(uintptr_t)((tlb_entry->addr_write & TARGET_PAGE_MASK)
+ tlb_entry->addend); + tlb_entry->addend);
ram_addr = qemu_ram_addr_from_host_nofail(p); ram_addr = qemu_ram_addr_from_host_nofail(p);
if (!cpu_physical_memory_is_dirty(ram_addr)) { if (!cpu_physical_memory_is_dirty(ram_addr)) {
@ -2191,7 +2193,7 @@ void tlb_set_page(CPUArchState *env, target_ulong vaddr,
unsigned int index; unsigned int index;
target_ulong address; target_ulong address;
target_ulong code_address; target_ulong code_address;
unsigned long addend; uintptr_t addend;
CPUTLBEntry *te; CPUTLBEntry *te;
CPUWatchpoint *wp; CPUWatchpoint *wp;
target_phys_addr_t iotlb; target_phys_addr_t iotlb;
@ -2213,7 +2215,7 @@ void tlb_set_page(CPUArchState *env, target_ulong vaddr,
address |= TLB_MMIO; address |= TLB_MMIO;
} }
if (is_ram_rom_romd(section)) { if (is_ram_rom_romd(section)) {
addend = (unsigned long)memory_region_get_ram_ptr(section->mr) addend = (uintptr_t)memory_region_get_ram_ptr(section->mr)
+ section_addr(section, paddr); + section_addr(section, paddr);
} else { } else {
addend = 0; addend = 0;
@ -2303,7 +2305,7 @@ struct walk_memory_regions_data
{ {
walk_memory_regions_fn fn; walk_memory_regions_fn fn;
void *priv; void *priv;
unsigned long start; uintptr_t start;
int prot; int prot;
}; };
@ -2364,7 +2366,7 @@ static int walk_memory_regions_1(struct walk_memory_regions_data *data,
int walk_memory_regions(void *priv, walk_memory_regions_fn fn) int walk_memory_regions(void *priv, walk_memory_regions_fn fn)
{ {
struct walk_memory_regions_data data; struct walk_memory_regions_data data;
unsigned long i; uintptr_t i;
data.fn = fn; data.fn = fn;
data.priv = priv; data.priv = priv;
@ -2552,7 +2554,7 @@ int page_unprotect(target_ulong address, uintptr_t pc, void *puc)
} }
static inline void tlb_set_dirty(CPUArchState *env, static inline void tlb_set_dirty(CPUArchState *env,
unsigned long addr, target_ulong vaddr) uintptr_t addr, target_ulong vaddr)
{ {
} }
#endif /* defined(CONFIG_USER_ONLY) */ #endif /* defined(CONFIG_USER_ONLY) */

View File

@ -430,7 +430,7 @@ static int os_host_main_loop_wait(int timeout)
g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds)); g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds));
for (i = 0; i < w->num; i++) { for (i = 0; i < w->num; i++) {
poll_fds[n_poll_fds + i].fd = (DWORD) w->events[i]; poll_fds[n_poll_fds + i].fd = (DWORD_PTR)w->events[i];
poll_fds[n_poll_fds + i].events = G_IO_IN; poll_fds[n_poll_fds + i].events = G_IO_IN;
} }

2
nbd.c
View File

@ -813,7 +813,7 @@ static void nbd_trip(void *opaque)
LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64 LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64
", Offset: %" PRIu64 "\n", ", Offset: %" PRIu64 "\n",
request.from, request.len, request.from, request.len,
(uint64_t)exp->size, exp->dev_offset); (uint64_t)exp->size, (uint64_t)exp->dev_offset);
LOG("requested operation past EOF--bad client?"); LOG("requested operation past EOF--bad client?");
goto invalid_request; goto invalid_request;
} }

View File

@ -30,6 +30,41 @@
#include <winsock2.h> #include <winsock2.h>
#include "main-loop.h" #include "main-loop.h"
/* Workaround for older versions of MinGW. */
#ifndef ECONNREFUSED
# define ECONNREFUSED WSAECONNREFUSED
#endif
#ifndef EINPROGRESS
# define EINPROGRESS WSAEINPROGRESS
#endif
#ifndef EHOSTUNREACH
# define EHOSTUNREACH WSAEHOSTUNREACH
#endif
#ifndef EINTR
# define EINTR WSAEINTR
#endif
#ifndef EINPROGRESS
# define EINPROGRESS WSAEINPROGRESS
#endif
#ifndef ENETUNREACH
# define ENETUNREACH WSAENETUNREACH
#endif
#ifndef ENOTCONN
# define ENOTCONN WSAENOTCONN
#endif
#ifndef EWOULDBLOCK
# define EWOULDBLOCK WSAEWOULDBLOCK
#endif
#if defined(_WIN64)
/* On w64, setjmp is implemented by _setjmp which needs a second parameter.
* If this parameter is NULL, longjump does no stack unwinding.
* That is what we need for QEMU. Passing the value of register rsp (default)
* lets longjmp try a stack unwinding which will crash with generated code. */
# undef setjmp
# define setjmp(env) _setjmp(env, NULL)
#endif
/* Declaration of ffs() is missing in MinGW's strings.h. */ /* Declaration of ffs() is missing in MinGW's strings.h. */
int ffs(int i); int ffs(int i);

View File

@ -8,12 +8,6 @@
#include <ws2tcpip.h> #include <ws2tcpip.h>
#define socket_error() WSAGetLastError() #define socket_error() WSAGetLastError()
#undef EWOULDBLOCK
#undef EINTR
#undef EINPROGRESS
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINTR WSAEINTR
#define EINPROGRESS WSAEINPROGRESS
int inet_aton(const char *cp, struct in_addr *ia); int inet_aton(const char *cp, struct in_addr *ia);

View File

@ -2106,7 +2106,8 @@ void do_savevm(Monitor *mon, const QDict *qdict)
} }
} else { } else {
#ifdef _WIN32 #ifdef _WIN32
ptm = localtime(&tb.time); time_t t = tb.time;
ptm = localtime(&t);
strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", ptm); strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", ptm);
#else #else
/* cast below needed for OpenBSD where tv_sec is still 'long' */ /* cast below needed for OpenBSD where tv_sec is still 'long' */

View File

@ -15,18 +15,6 @@ typedef char *caddr_t;
# include <sys/timeb.h> # include <sys/timeb.h>
# include <iphlpapi.h> # include <iphlpapi.h>
# undef EWOULDBLOCK
# undef EINPROGRESS
# undef ENOTCONN
# undef EHOSTUNREACH
# undef ENETUNREACH
# undef ECONNREFUSED
# define EWOULDBLOCK WSAEWOULDBLOCK
# define EINPROGRESS WSAEINPROGRESS
# define ENOTCONN WSAENOTCONN
# define EHOSTUNREACH WSAEHOSTUNREACH
# define ENETUNREACH WSAENETUNREACH
# define ECONNREFUSED WSAECONNREFUSED
#else #else
# define ioctlsocket ioctl # define ioctlsocket ioctl
# define closesocket(s) close(s) # define closesocket(s) close(s)

View File

@ -99,7 +99,6 @@ glue(glue(glue(CPU_PREFIX, ld), USUFFIX), MEMSUFFIX)(ENV_PARAM
int page_index; int page_index;
RES_TYPE res; RES_TYPE res;
target_ulong addr; target_ulong addr;
unsigned long physaddr;
int mmu_idx; int mmu_idx;
addr = ptr; addr = ptr;
@ -111,8 +110,8 @@ glue(glue(glue(CPU_PREFIX, ld), USUFFIX), MEMSUFFIX)(ENV_PARAM
addr, addr,
mmu_idx); mmu_idx);
} else { } else {
physaddr = addr + env->tlb_table[mmu_idx][page_index].addend; uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)physaddr); res = glue(glue(ld, USUFFIX), _raw)(hostaddr);
} }
return res; return res;
} }
@ -124,7 +123,6 @@ glue(glue(glue(CPU_PREFIX, lds), SUFFIX), MEMSUFFIX)(ENV_PARAM
{ {
int res, page_index; int res, page_index;
target_ulong addr; target_ulong addr;
unsigned long physaddr;
int mmu_idx; int mmu_idx;
addr = ptr; addr = ptr;
@ -135,8 +133,8 @@ glue(glue(glue(CPU_PREFIX, lds), SUFFIX), MEMSUFFIX)(ENV_PARAM
res = (DATA_STYPE)glue(glue(glue(HELPER_PREFIX, ld), SUFFIX), res = (DATA_STYPE)glue(glue(glue(HELPER_PREFIX, ld), SUFFIX),
MMUSUFFIX)(ENV_VAR addr, mmu_idx); MMUSUFFIX)(ENV_VAR addr, mmu_idx);
} else { } else {
physaddr = addr + env->tlb_table[mmu_idx][page_index].addend; uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
res = glue(glue(lds, SUFFIX), _raw)((uint8_t *)physaddr); res = glue(glue(lds, SUFFIX), _raw)(hostaddr);
} }
return res; return res;
} }
@ -152,7 +150,6 @@ glue(glue(glue(CPU_PREFIX, st), SUFFIX), MEMSUFFIX)(ENV_PARAM target_ulong ptr,
{ {
int page_index; int page_index;
target_ulong addr; target_ulong addr;
unsigned long physaddr;
int mmu_idx; int mmu_idx;
addr = ptr; addr = ptr;
@ -163,8 +160,8 @@ glue(glue(glue(CPU_PREFIX, st), SUFFIX), MEMSUFFIX)(ENV_PARAM target_ulong ptr,
glue(glue(glue(HELPER_PREFIX, st), SUFFIX), MMUSUFFIX)(ENV_VAR addr, v, glue(glue(glue(HELPER_PREFIX, st), SUFFIX), MMUSUFFIX)(ENV_VAR addr, v,
mmu_idx); mmu_idx);
} else { } else {
physaddr = addr + env->tlb_table[mmu_idx][page_index].addend; uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
glue(glue(st, SUFFIX), _raw)((uint8_t *)physaddr, v); glue(glue(st, SUFFIX), _raw)(hostaddr, v);
} }
} }

View File

@ -112,7 +112,6 @@ glue(glue(glue(HELPER_PREFIX, ld), SUFFIX), MMUSUFFIX)(ENV_PARAM
int index; int index;
target_ulong tlb_addr; target_ulong tlb_addr;
target_phys_addr_t ioaddr; target_phys_addr_t ioaddr;
unsigned long addend;
uintptr_t retaddr; uintptr_t retaddr;
/* test if there is match for unaligned or IO access */ /* test if there is match for unaligned or IO access */
@ -139,6 +138,7 @@ glue(glue(glue(HELPER_PREFIX, ld), SUFFIX), MMUSUFFIX)(ENV_PARAM
mmu_idx, retaddr); mmu_idx, retaddr);
} else { } else {
/* unaligned/aligned access in the same page */ /* unaligned/aligned access in the same page */
uintptr_t addend;
#ifdef ALIGNED_ONLY #ifdef ALIGNED_ONLY
if ((addr & (DATA_SIZE - 1)) != 0) { if ((addr & (DATA_SIZE - 1)) != 0) {
retaddr = GETPC(); retaddr = GETPC();
@ -146,7 +146,8 @@ glue(glue(glue(HELPER_PREFIX, ld), SUFFIX), MMUSUFFIX)(ENV_PARAM
} }
#endif #endif
addend = env->tlb_table[mmu_idx][index].addend; addend = env->tlb_table[mmu_idx][index].addend;
res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(long)(addr+addend)); res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(intptr_t)
(addr + addend));
} }
} else { } else {
/* the page is not in the TLB : fill it */ /* the page is not in the TLB : fill it */
@ -171,7 +172,6 @@ glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(ENV_PARAM
DATA_TYPE res, res1, res2; DATA_TYPE res, res1, res2;
int index, shift; int index, shift;
target_phys_addr_t ioaddr; target_phys_addr_t ioaddr;
unsigned long addend;
target_ulong tlb_addr, addr1, addr2; target_ulong tlb_addr, addr1, addr2;
index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
@ -202,8 +202,9 @@ glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(ENV_PARAM
res = (DATA_TYPE)res; res = (DATA_TYPE)res;
} else { } else {
/* unaligned/aligned access in the same page */ /* unaligned/aligned access in the same page */
addend = env->tlb_table[mmu_idx][index].addend; uintptr_t addend = env->tlb_table[mmu_idx][index].addend;
res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(long)(addr+addend)); res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(intptr_t)
(addr + addend));
} }
} else { } else {
/* the page is not in the TLB : fill it */ /* the page is not in the TLB : fill it */
@ -258,7 +259,6 @@ void glue(glue(glue(HELPER_PREFIX, st), SUFFIX), MMUSUFFIX)(ENV_PARAM
int mmu_idx) int mmu_idx)
{ {
target_phys_addr_t ioaddr; target_phys_addr_t ioaddr;
unsigned long addend;
target_ulong tlb_addr; target_ulong tlb_addr;
uintptr_t retaddr; uintptr_t retaddr;
int index; int index;
@ -284,6 +284,7 @@ void glue(glue(glue(HELPER_PREFIX, st), SUFFIX), MMUSUFFIX)(ENV_PARAM
mmu_idx, retaddr); mmu_idx, retaddr);
} else { } else {
/* aligned/unaligned access in the same page */ /* aligned/unaligned access in the same page */
uintptr_t addend;
#ifdef ALIGNED_ONLY #ifdef ALIGNED_ONLY
if ((addr & (DATA_SIZE - 1)) != 0) { if ((addr & (DATA_SIZE - 1)) != 0) {
retaddr = GETPC(); retaddr = GETPC();
@ -291,7 +292,8 @@ void glue(glue(glue(HELPER_PREFIX, st), SUFFIX), MMUSUFFIX)(ENV_PARAM
} }
#endif #endif
addend = env->tlb_table[mmu_idx][index].addend; addend = env->tlb_table[mmu_idx][index].addend;
glue(glue(st, SUFFIX), _raw)((uint8_t *)(long)(addr+addend), val); glue(glue(st, SUFFIX), _raw)((uint8_t *)(intptr_t)
(addr + addend), val);
} }
} else { } else {
/* the page is not in the TLB : fill it */ /* the page is not in the TLB : fill it */
@ -313,7 +315,6 @@ static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(ENV_PARAM
uintptr_t retaddr) uintptr_t retaddr)
{ {
target_phys_addr_t ioaddr; target_phys_addr_t ioaddr;
unsigned long addend;
target_ulong tlb_addr; target_ulong tlb_addr;
int index, i; int index, i;
@ -345,8 +346,9 @@ static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(ENV_PARAM
} }
} else { } else {
/* aligned/unaligned access in the same page */ /* aligned/unaligned access in the same page */
addend = env->tlb_table[mmu_idx][index].addend; uintptr_t addend = env->tlb_table[mmu_idx][index].addend;
glue(glue(st, SUFFIX), _raw)((uint8_t *)(long)(addr+addend), val); glue(glue(st, SUFFIX), _raw)((uint8_t *)(intptr_t)
(addr + addend), val);
} }
} else { } else {
/* the page is not in the TLB : fill it */ /* the page is not in the TLB : fill it */

View File

@ -2275,7 +2275,7 @@ void helper_pmon (int function)
break; break;
case 158: case 158:
{ {
unsigned char *fmt = (void *)(unsigned long)env->active_tc.gpr[4]; unsigned char *fmt = (void *)(uintptr_t)env->active_tc.gpr[4];
printf("%s", fmt); printf("%s", fmt);
} }
break; break;

View File

@ -63,10 +63,15 @@ static const int tcg_target_reg_alloc_order[] = {
static const int tcg_target_call_iarg_regs[] = { static const int tcg_target_call_iarg_regs[] = {
#if TCG_TARGET_REG_BITS == 64 #if TCG_TARGET_REG_BITS == 64
#if defined(_WIN64)
TCG_REG_RCX,
TCG_REG_RDX,
#else
TCG_REG_RDI, TCG_REG_RDI,
TCG_REG_RSI, TCG_REG_RSI,
TCG_REG_RDX, TCG_REG_RDX,
TCG_REG_RCX, TCG_REG_RCX,
#endif
TCG_REG_R8, TCG_REG_R8,
TCG_REG_R9, TCG_REG_R9,
#else #else
@ -176,10 +181,10 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
ct->ct |= TCG_CT_REG; ct->ct |= TCG_CT_REG;
if (TCG_TARGET_REG_BITS == 64) { if (TCG_TARGET_REG_BITS == 64) {
tcg_regset_set32(ct->u.regs, 0, 0xffff); tcg_regset_set32(ct->u.regs, 0, 0xffff);
tcg_regset_reset_reg(ct->u.regs, TCG_REG_RSI); tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[0]);
tcg_regset_reset_reg(ct->u.regs, TCG_REG_RDI); tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[1]);
#ifdef CONFIG_TCG_PASS_AREG0 #ifdef CONFIG_TCG_PASS_AREG0
tcg_regset_reset_reg(ct->u.regs, TCG_REG_RDX); tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[2]);
#endif #endif
} else { } else {
tcg_regset_set32(ct->u.regs, 0, 0xff); tcg_regset_set32(ct->u.regs, 0, 0xff);
@ -1300,9 +1305,12 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
use the ADDR32 prefix. For now, do nothing. */ use the ADDR32 prefix. For now, do nothing. */
if (offset != GUEST_BASE) { if (offset != GUEST_BASE) {
tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_RDI, GUEST_BASE); tcg_out_movi(s, TCG_TYPE_I64,
tgen_arithr(s, ARITH_ADD + P_REXW, TCG_REG_RDI, base); tcg_target_call_iarg_regs[0], GUEST_BASE);
base = TCG_REG_RDI, offset = 0; tgen_arithr(s, ARITH_ADD + P_REXW,
tcg_target_call_iarg_regs[0], base);
base = tcg_target_call_iarg_regs[0];
offset = 0;
} }
} }
@ -1434,8 +1442,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
#endif #endif
#else #else
tcg_out_mov(s, (opc == 3 ? TCG_TYPE_I64 : TCG_TYPE_I32), tcg_out_mov(s, (opc == 3 ? TCG_TYPE_I64 : TCG_TYPE_I32),
TCG_REG_RSI, data_reg); tcg_target_call_iarg_regs[1], data_reg);
tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_RDX, mem_index); tcg_out_movi(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2], mem_index);
stack_adjust = 0; stack_adjust = 0;
#ifdef CONFIG_TCG_PASS_AREG0 #ifdef CONFIG_TCG_PASS_AREG0
/* XXX/FIXME: suboptimal */ /* XXX/FIXME: suboptimal */
@ -1474,9 +1482,12 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
use the ADDR32 prefix. For now, do nothing. */ use the ADDR32 prefix. For now, do nothing. */
if (offset != GUEST_BASE) { if (offset != GUEST_BASE) {
tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_RDI, GUEST_BASE); tcg_out_movi(s, TCG_TYPE_I64,
tgen_arithr(s, ARITH_ADD + P_REXW, TCG_REG_RDI, base); tcg_target_call_iarg_regs[0], GUEST_BASE);
base = TCG_REG_RDI, offset = 0; tgen_arithr(s, ARITH_ADD + P_REXW,
tcg_target_call_iarg_regs[0], base);
base = tcg_target_call_iarg_regs[0];
offset = 0;
} }
} }
@ -1977,6 +1988,10 @@ static int tcg_target_callee_save_regs[] = {
#if TCG_TARGET_REG_BITS == 64 #if TCG_TARGET_REG_BITS == 64
TCG_REG_RBP, TCG_REG_RBP,
TCG_REG_RBX, TCG_REG_RBX,
#if defined(_WIN64)
TCG_REG_RDI,
TCG_REG_RSI,
#endif
TCG_REG_R12, TCG_REG_R12,
TCG_REG_R13, TCG_REG_R13,
TCG_REG_R14, /* Currently used for the global env. */ TCG_REG_R14, /* Currently used for the global env. */
@ -2064,8 +2079,10 @@ static void tcg_target_init(TCGContext *s)
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_EDX); tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_EDX);
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_ECX); tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_ECX);
if (TCG_TARGET_REG_BITS == 64) { if (TCG_TARGET_REG_BITS == 64) {
#if !defined(_WIN64)
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_RDI); tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_RDI);
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_RSI); tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_RSI);
#endif
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R8); tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R8);
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R9); tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R9);
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R10); tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R10);
@ -2102,7 +2119,9 @@ typedef struct {
DebugFrameFDE fde; DebugFrameFDE fde;
} DebugFrame; } DebugFrame;
#if TCG_TARGET_REG_BITS == 64 #if !defined(__ELF__)
/* Host machine without ELF. */
#elif TCG_TARGET_REG_BITS == 64
#define ELF_HOST_MACHINE EM_X86_64 #define ELF_HOST_MACHINE EM_X86_64
static DebugFrame debug_frame = { static DebugFrame debug_frame = {
.cie.len = sizeof(DebugFrameCIE)-4, /* length after .len member */ .cie.len = sizeof(DebugFrameCIE)-4, /* length after .len member */
@ -2156,6 +2175,7 @@ static DebugFrame debug_frame = {
}; };
#endif #endif
#if defined(ELF_HOST_MACHINE)
void tcg_register_jit(void *buf, size_t buf_size) void tcg_register_jit(void *buf, size_t buf_size)
{ {
/* We're expecting a 2 byte uleb128 encoded value. */ /* We're expecting a 2 byte uleb128 encoded value. */
@ -2166,3 +2186,4 @@ void tcg_register_jit(void *buf, size_t buf_size)
tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame));
} }
#endif