Commit 3c3adde0 authored by Anthony Liguori's avatar Anthony Liguori
Browse files

Merge remote-tracking branch 'afaerber/qom-cpu' into staging

# By Andreas Färber
# Via Andreas Färber
* afaerber/qom-cpu: (47 commits)
  target-i386: Split command line parsing out of cpu_x86_register()
  target-i386: Move cpu_x86_init()
  target-lm32: Drop unused cpu_lm32_close() prototype
  target-s390x: Drop unused cpu_s390x_close() prototype
  spapr_hcall: Replace open-coded CPU loop with qemu_get_cpu()
  ppce500_spin: Replace open-coded CPU loop with qemu_get_cpu()
  e500: Replace open-coded loop with qemu_get_cpu()
  cpu: Add CPUArchState pointer to CPUState
  cputlb: Pass CPUState to cpu_unlink_tb()
  cpu: Move current_tb field to CPUState
  cpu: Move exit_request field to CPUState
  cpu: Move running field to CPUState
  cpu: Move host_tid field to CPUState
  target-cris: Introduce CRISCPU subclasses
  target-m68k: Pass M68kCPU to m68k_set_irq_level()
  mcf_intc: Pass M68kCPU to mcf_intc_init()
  mcf5206: Pass M68kCPU to mcf5206_init()
  target-m68k: Return M68kCPU from cpu_m68k_init()
  ppc405_uc: Pass PowerPCCPU to ppc40x_{core,chip,system}_reset()
  target-xtensa: Move TCG initialization to XtensaCPU initfn
  ...
parents f4c0f986 2d64255b
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -32,7 +32,9 @@ bool qemu_cpu_has_work(CPUState *cpu)

void cpu_loop_exit(CPUArchState *env)
{
    env->current_tb = NULL;
    CPUState *cpu = ENV_GET_CPU(env);

    cpu->current_tb = NULL;
    longjmp(env->jmp_env, 1);
}

@@ -54,6 +56,7 @@ void cpu_resume_from_signal(CPUArchState *env, void *puc)
static void cpu_exec_nocache(CPUArchState *env, int max_cycles,
                             TranslationBlock *orig_tb)
{
    CPUState *cpu = ENV_GET_CPU(env);
    tcg_target_ulong next_tb;
    TranslationBlock *tb;

@@ -64,10 +67,10 @@ static void cpu_exec_nocache(CPUArchState *env, int max_cycles,

    tb = tb_gen_code(env, orig_tb->pc, orig_tb->cs_base, orig_tb->flags,
                     max_cycles);
    env->current_tb = tb;
    cpu->current_tb = tb;
    /* execute the generated code */
    next_tb = tcg_qemu_tb_exec(env, tb->tc_ptr);
    env->current_tb = NULL;
    cpu->current_tb = NULL;

    if ((next_tb & 3) == 2) {
        /* Restore PC.  This may happen if async event occurs before
@@ -196,7 +199,7 @@ int cpu_exec(CPUArchState *env)
    cpu_single_env = env;

    if (unlikely(exit_request)) {
        env->exit_request = 1;
        cpu->exit_request = 1;
    }

#if defined(TARGET_I386)
@@ -537,8 +540,8 @@ int cpu_exec(CPUArchState *env)
                        next_tb = 0;
                    }
                }
                if (unlikely(env->exit_request)) {
                    env->exit_request = 0;
                if (unlikely(cpu->exit_request)) {
                    cpu->exit_request = 0;
                    env->exception_index = EXCP_INTERRUPT;
                    cpu_loop_exit(env);
                }
@@ -589,9 +592,9 @@ int cpu_exec(CPUArchState *env)
                   TB, but before it is linked into a potentially
                   infinite loop and becomes env->current_tb. Avoid
                   starting execution if there is a pending interrupt. */
                env->current_tb = tb;
                cpu->current_tb = tb;
                barrier();
                if (likely(!env->exit_request)) {
                if (likely(!cpu->exit_request)) {
                    tc_ptr = tb->tc_ptr;
                    /* execute the generated code */
                    next_tb = tcg_qemu_tb_exec(env, tc_ptr);
@@ -623,7 +626,7 @@ int cpu_exec(CPUArchState *env)
                        }
                    }
                }
                env->current_tb = NULL;
                cpu->current_tb = NULL;
                /* reset soft MMU for next block (it can currently
                   only be set by a memory fault) */
            } /* for(;;) */
+4 −2
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ static const CPUTLBEntry s_cputlb_empty_entry = {
 */
void tlb_flush(CPUArchState *env, int flush_global)
{
    CPUState *cpu = ENV_GET_CPU(env);
    int i;

#if defined(DEBUG_TLB)
@@ -61,7 +62,7 @@ void tlb_flush(CPUArchState *env, int flush_global)
#endif
    /* must reset current TB so that interrupts cannot modify the
       links while we are modifying them */
    env->current_tb = NULL;
    cpu->current_tb = NULL;

    for (i = 0; i < CPU_TLB_SIZE; i++) {
        int mmu_idx;
@@ -92,6 +93,7 @@ static inline void tlb_flush_entry(CPUTLBEntry *tlb_entry, target_ulong addr)

void tlb_flush_page(CPUArchState *env, target_ulong addr)
{
    CPUState *cpu = ENV_GET_CPU(env);
    int i;
    int mmu_idx;

@@ -110,7 +112,7 @@ void tlb_flush_page(CPUArchState *env, target_ulong addr)
    }
    /* must reset current TB so that interrupts cannot modify the
       links while we are modifying them */
    env->current_tb = NULL;
    cpu->current_tb = NULL;

    addr &= TARGET_PAGE_MASK;
    i = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
+6 −2
Original line number Diff line number Diff line
@@ -271,11 +271,13 @@ static int write_elf64_note(DumpState *s)
static int write_elf64_notes(DumpState *s)
{
    CPUArchState *env;
    CPUState *cpu;
    int ret;
    int id;

    for (env = first_cpu; env != NULL; env = env->next_cpu) {
        id = cpu_index(env);
        cpu = ENV_GET_CPU(env);
        id = cpu_index(cpu);
        ret = cpu_write_elf64_note(fd_write_vmcore, env, id, s);
        if (ret < 0) {
            dump_error(s, "dump: failed to write elf notes.\n");
@@ -321,11 +323,13 @@ static int write_elf32_note(DumpState *s)
static int write_elf32_notes(DumpState *s)
{
    CPUArchState *env;
    CPUState *cpu;
    int ret;
    int id;

    for (env = first_cpu; env != NULL; env = env->next_cpu) {
        id = cpu_index(env);
        cpu = ENV_GET_CPU(env);
        id = cpu_index(cpu);
        ret = cpu_write_elf32_note(fd_write_vmcore, env, id, s);
        if (ret < 0) {
            dump_error(s, "dump: failed to write elf notes.\n");
+4 −2
Original line number Diff line number Diff line
@@ -492,8 +492,10 @@ void cpu_reset_interrupt(CPUArchState *env, int mask)

void cpu_exit(CPUArchState *env)
{
    env->exit_request = 1;
    cpu_unlink_tb(env);
    CPUState *cpu = ENV_GET_CPU(env);

    cpu->exit_request = 1;
    cpu_unlink_tb(cpu);
}

void cpu_abort(CPUArchState *env, const char *fmt, ...)
+9 −5
Original line number Diff line number Diff line
@@ -2066,9 +2066,11 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)
static CPUArchState *find_cpu(uint32_t thread_id)
{
    CPUArchState *env;
    CPUState *cpu;

    for (env = first_cpu; env != NULL; env = env->next_cpu) {
        if (cpu_index(env) == thread_id) {
        cpu = ENV_GET_CPU(env);
        if (cpu_index(cpu) == thread_id) {
            return env;
        }
    }
@@ -2096,7 +2098,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
    case '?':
        /* TODO: Make this return the correct value for user-mode.  */
        snprintf(buf, sizeof(buf), "T%02xthread:%02x;", GDB_SIGNAL_TRAP,
                 cpu_index(s->c_cpu));
                 cpu_index(ENV_GET_CPU(s->c_cpu)));
        put_packet(s, buf);
        /* Remove all the breakpoints when this query is issued,
         * because gdb is doing and initial connect and the state
@@ -2391,7 +2393,8 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
        } else if (strcmp(p,"sThreadInfo") == 0) {
        report_cpuinfo:
            if (s->query_cpu) {
                snprintf(buf, sizeof(buf), "m%x", cpu_index(s->query_cpu));
                snprintf(buf, sizeof(buf), "m%x",
                         cpu_index(ENV_GET_CPU(s->query_cpu)));
                put_packet(s, buf);
                s->query_cpu = s->query_cpu->next_cpu;
            } else
@@ -2512,6 +2515,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state)
{
    GDBState *s = gdbserver_state;
    CPUArchState *env = s->c_cpu;
    CPUState *cpu = ENV_GET_CPU(env);
    char buf[256];
    const char *type;
    int ret;
@@ -2540,7 +2544,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state)
            }
            snprintf(buf, sizeof(buf),
                     "T%02xthread:%02x;%swatch:" TARGET_FMT_lx ";",
                     GDB_SIGNAL_TRAP, cpu_index(env), type,
                     GDB_SIGNAL_TRAP, cpu_index(cpu), type,
                     env->watchpoint_hit->vaddr);
            env->watchpoint_hit = NULL;
            goto send_packet;
@@ -2573,7 +2577,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state)
        ret = GDB_SIGNAL_UNKNOWN;
        break;
    }
    snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, cpu_index(env));
    snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, cpu_index(cpu));

send_packet:
    put_packet(s, buf);
Loading