From 730244762408464fa646c351fb0367cc30c94af0 Mon Sep 17 00:00:00 2001 From: George Hotz Date: Fri, 1 Aug 2014 11:00:21 -0700 Subject: [PATCH] things for a broken qemu system --- .gitignore | 1 + qemu_mods/tci.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/.gitignore b/.gitignore index cfb4edb0..36ef15d7 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ libs/ qiradb/build cda/clang qemu +tests/system diff --git a/qemu_mods/tci.c b/qemu_mods/tci.c index b2b6572e..601888cc 100644 --- a/qemu_mods/tci.c +++ b/qemu_mods/tci.c @@ -419,6 +419,11 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) return result; } +// if it's not softmmu, assume it's user +#ifndef CONFIG_SOFTMMU +#define QEMU_USER +#endif + #define QIRA_TRACKING #ifdef QIRA_TRACKING @@ -426,7 +431,10 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) #include #include #include + +#ifdef QEMU_USER #include "qemu.h" +#endif #define QIRA_DEBUG(...) {} //#define QIRA_DEBUG qemu_debug @@ -630,6 +638,8 @@ void track_write(target_ulong base, target_ulong offset, target_ulong data, int //else add_change(offset, data, IS_WRITE | size); } +#ifdef QEMU_USER + void track_kernel_read(void *host_addr, target_ulong guest_addr, long len) { if (unlikely(GLOBAL_QIRA_did_init == 0)) return; @@ -651,6 +661,8 @@ void track_kernel_write(void *host_addr, target_ulong guest_addr, long len) { for (; i < len; i+=1) add_change(guest_addr+i, ((unsigned char*)host_addr)[i], IS_MEM | IS_WRITE | 8); } +#endif + // careful, this does it twice, MMIO? #define R(x,y,z) (track_load(x,(uint64_t)y,z),y) #define W(x,y,z) (track_store(x,(uint64_t)y,z),x) @@ -739,6 +751,7 @@ int run_QIRA_log_from_fd(CPUArchState *env, int qira_log_fd, uint32_t to_change) if (pchange.changelist_number >= to_change) break; QIRA_DEBUG("running old change %lX %d\n", pchange.address, pchange.changelist_number); +#ifdef QEMU_USER #ifdef R_EAX if (flags & IS_SYSCALL) { // replay all the syscalls? @@ -752,12 +765,14 @@ int run_QIRA_log_from_fd(CPUArchState *env, int qira_log_fd, uint32_t to_change) } #endif + // wrong for system, we need this if (flags & IS_WRITE) { void *base; if (flags & IS_MEM) { base = g2h(pchange.address); } else { base = ((void *)env) + pchange.address; } memcpy(base, &pchange.data, (flags&SIZE_MASK) >> 3); } +#endif ret++; } return ret; @@ -845,7 +860,9 @@ uint32_t GLOBAL_last_fork_change = -1; target_long last_pc = 0; void write_out_base(CPUArchState *env, int id); + void write_out_base(CPUArchState *env, int id) { +#ifdef QEMU_USER CPUState *cpu = ENV_GET_CPU(env); TaskState *ts = (TaskState *)cpu->opaque; @@ -904,6 +921,7 @@ void write_out_base(CPUArchState *env, int id) { fprintf(f, TARGET_ABI_FMT_lx "-" TARGET_ABI_FMT_lx " %"PRIx64" %s\n", ss, se, (uint64_t)0, envfn); fclose(f); +#endif } /* Interpret pseudo code in tb. */