Commit c94bf1c1 authored by Anthony Liguori's avatar Anthony Liguori
Browse files

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



* afaerber/qom-cpu:
  target-i386: Use switch in check_hw_breakpoints()
  target-i386: Avoid goto in hw_breakpoint_insert()
  target-i386: Introduce hw_{local,global}_breakpoint_enabled()
  target-i386: Define DR7 bit field constants
  target-i386: Move kvm_check_features_against_host() check to realize time
  target-i386: cpu_x86_register() consolidate freeing resources
  target-i386: Move setting defaults out of cpu_x86_parse_featurestr()
  target-i386: check/enforce: Check all feature words
  target-i386/cpu.c: Add feature name array for ext4_features
  target-i386: kvm_check_features_against_host(): Use feature_word_info
  target-i386/cpu: Introduce FeatureWord typedefs
  target-i386: Disable kvm_mmu by default
  kvm: Add fake KVM constants to avoid #ifdefs on KVM-specific code
  exec: Return CPUState from qemu_get_cpu()
  xen: Simplify halting of first CPU
  kvm: Pass CPUState to kvm_init_vcpu()
  cpu: Move cpu_index field to CPUState
  cpu: Move numa_node field to CPUState
  target-mips: Clean up mips_cpu_map_tc() documentation
  cpu: Move nr_{cores,threads} fields to CPUState

Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parents bdb8872c e175bce5
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -390,13 +390,15 @@ void hw_error(const char *fmt, ...)
{
    va_list ap;
    CPUArchState *env;
    CPUState *cpu;

    va_start(ap, fmt);
    fprintf(stderr, "qemu: hardware error: ");
    vfprintf(stderr, fmt, ap);
    fprintf(stderr, "\n");
    for (env = first_cpu; env != NULL; env = env->next_cpu) {
        fprintf(stderr, "CPU #%d:\n", env->cpu_index);
        cpu = ENV_GET_CPU(env);
        fprintf(stderr, "CPU #%d:\n", cpu->cpu_index);
        cpu_dump_state(env, stderr, fprintf, CPU_DUMP_FPU);
    }
    va_end(ap);
@@ -740,7 +742,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg)
    cpu->thread_id = qemu_get_thread_id();
    cpu_single_env = env;

    r = kvm_init_vcpu(env);
    r = kvm_init_vcpu(cpu);
    if (r < 0) {
        fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(-r));
        exit(1);
@@ -1041,8 +1043,8 @@ void qemu_init_vcpu(void *_env)
    CPUArchState *env = _env;
    CPUState *cpu = ENV_GET_CPU(env);

    env->nr_cores = smp_cores;
    env->nr_threads = smp_threads;
    cpu->nr_cores = smp_cores;
    cpu->nr_threads = smp_threads;
    cpu->stopped = true;
    if (kvm_enabled()) {
        qemu_kvm_start_vcpu(env);
@@ -1160,12 +1162,14 @@ static void tcg_exec_all(void)
void set_numa_modes(void)
{
    CPUArchState *env;
    CPUState *cpu;
    int i;

    for (env = first_cpu; env != NULL; env = env->next_cpu) {
        cpu = ENV_GET_CPU(env);
        for (i = 0; i < nb_numa_nodes; i++) {
            if (test_bit(env->cpu_index, node_cpumask[i])) {
                env->numa_node = i;
            if (test_bit(cpu->cpu_index, node_cpumask[i])) {
                cpu->numa_node = i;
            }
        }
    }
@@ -1213,7 +1217,7 @@ CpuInfoList *qmp_query_cpus(Error **errp)

        info = g_malloc0(sizeof(*info));
        info->value = g_malloc0(sizeof(*info->value));
        info->value->CPU = env->cpu_index;
        info->value->CPU = cpu->cpu_index;
        info->value->current = (env == first_cpu);
        info->value->halted = env->halted;
        info->value->thread_id = cpu->thread_id;
@@ -1251,6 +1255,7 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename,
    FILE *f;
    uint32_t l;
    CPUArchState *env;
    CPUState *cpu;
    uint8_t buf[1024];

    if (!has_cpu) {
@@ -1258,7 +1263,8 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename,
    }

    for (env = first_cpu; env; env = env->next_cpu) {
        if (cpu_index == env->cpu_index) {
        cpu = ENV_GET_CPU(env);
        if (cpu_index == cpu->cpu_index) {
            break;
        }
    }
+9 −10
Original line number Diff line number Diff line
@@ -247,24 +247,25 @@ static const VMStateDescription vmstate_cpu_common = {
};
#endif

CPUArchState *qemu_get_cpu(int cpu)
CPUState *qemu_get_cpu(int index)
{
    CPUArchState *env = first_cpu;
    CPUState *cpu = NULL;

    while (env) {
        if (env->cpu_index == cpu)
        cpu = ENV_GET_CPU(env);
        if (cpu->cpu_index == index) {
            break;
        }
        env = env->next_cpu;
    }

    return env;
    return cpu;
}

void cpu_exec_init(CPUArchState *env)
{
#ifndef CONFIG_USER_ONLY
    CPUState *cpu = ENV_GET_CPU(env);
#endif
    CPUArchState **penv;
    int cpu_index;

@@ -278,8 +279,8 @@ void cpu_exec_init(CPUArchState *env)
        penv = &(*penv)->next_cpu;
        cpu_index++;
    }
    env->cpu_index = cpu_index;
    env->numa_node = 0;
    cpu->cpu_index = cpu_index;
    cpu->numa_node = 0;
    QTAILQ_INIT(&env->breakpoints);
    QTAILQ_INIT(&env->watchpoints);
#ifndef CONFIG_USER_ONLY
@@ -531,7 +532,6 @@ CPUArchState *cpu_copy(CPUArchState *env)
{
    CPUArchState *new_env = cpu_init(env->cpu_model_str);
    CPUArchState *next_cpu = new_env->next_cpu;
    int cpu_index = new_env->cpu_index;
#if defined(TARGET_HAS_ICE)
    CPUBreakpoint *bp;
    CPUWatchpoint *wp;
@@ -539,9 +539,8 @@ CPUArchState *cpu_copy(CPUArchState *env)

    memcpy(new_env, env, sizeof(CPUArchState));

    /* Preserve chaining and index. */
    /* Preserve chaining. */
    new_env->next_cpu = next_cpu;
    new_env->cpu_index = cpu_index;

    /* Clone all break/watchpoints.
       Note: Once we support ptrace with hw-debug register access, make sure
+2 −1
Original line number Diff line number Diff line
@@ -2401,9 +2401,10 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
            thread = strtoull(p+16, (char **)&p, 16);
            env = find_cpu(thread);
            if (env != NULL) {
                CPUState *cpu = ENV_GET_CPU(env);
                cpu_synchronize_state(env);
                len = snprintf((char *)mem_buf, sizeof(mem_buf),
                               "CPU#%d [%s]", env->cpu_index,
                               "CPU#%d [%s]", cpu->cpu_index,
                               env->halted ? "halted " : "running");
                memtohex(buf, mem_buf, len);
                put_packet(s, buf);
+3 −1
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ static uint64_t cchip_read(void *opaque, hwaddr addr, unsigned size)
{
    CPUAlphaState *env = cpu_single_env;
    TyphoonState *s = opaque;
    CPUState *cpu;
    uint64_t ret = 0;

    if (addr & 4) {
@@ -95,7 +96,8 @@ static uint64_t cchip_read(void *opaque, hwaddr addr, unsigned size)

    case 0x0080:
        /* MISC: Miscellaneous Register.  */
        ret = s->cchip.misc | (env->cpu_index & 3);
        cpu = ENV_GET_CPU(env);
        ret = s->cchip.misc | (cpu->cpu_index & 3);
        break;

    case 0x00c0:
+2 −1
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ static const uint8_t gic_id[] = {
static inline int gic_get_current_cpu(GICState *s)
{
    if (s->num_cpu > 1) {
        return cpu_single_env->cpu_index;
        CPUState *cpu = ENV_GET_CPU(cpu_single_env);
        return cpu->cpu_index;
    }
    return 0;
}
Loading