~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to target-i386/cpu.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2013-10-22 22:47:07 UTC
  • mfrom: (1.8.3) (10.1.42 sid)
  • Revision ID: package-import@ubuntu.com-20131022224707-1lya34fw3k3f24tv
Tags: 1.6.0+dfsg-2ubuntu1
* Merge 1.6.0~rc0+dfsg-2exp from debian experimental.  Remaining changes:
  - debian/control
    * update maintainer
    * remove libiscsi, usb-redir, vde, vnc-jpeg, and libssh2-1-dev
      from build-deps
    * enable rbd
    * add qemu-system and qemu-common B/R to qemu-keymaps
    * add D:udev, R:qemu, R:qemu-common and B:qemu-common to
      qemu-system-common
    * qemu-system-arm, qemu-system-ppc, qemu-system-sparc:
      - add qemu-kvm to Provides
      - add qemu-common, qemu-kvm, kvm to B/R
      - remove openbios-sparc from qemu-system-sparc D
      - drop openbios-ppc and openhackware Depends to Suggests (for now)
    * qemu-system-x86:
      - add qemu-common to Breaks/Replaces.
      - add cpu-checker to Recommends.
    * qemu-user: add B/R:qemu-kvm
    * qemu-kvm:
      - add armhf armel powerpc sparc to Architecture
      - C/R/P: qemu-kvm-spice
    * add qemu-common package
    * drop qemu-slof which is not packaged in ubuntu
  - add qemu-system-common.links for tap ifup/down scripts and OVMF link.
  - qemu-system-x86.links:
    * remove pxe rom links which are in kvm-ipxe
    * add symlink for kvm.1 manpage
  - debian/rules
    * add kvm-spice symlink to qemu-kvm
    * call dh_installmodules for qemu-system-x86
    * update dh_installinit to install upstart script
    * run dh_installman (Closes: #709241) (cherrypicked from 1.5.0+dfsg-2)
  - Add qemu-utils.links for kvm-* symlinks.
  - Add qemu-system-x86.qemu-kvm.upstart and .default
  - Add qemu-system-x86.modprobe to set nesting=1
  - Add qemu-system-common.preinst to add kvm group
  - qemu-system-common.postinst: remove bad group acl if there, then have
    udev relabel /dev/kvm.
  - New linaro patches from qemu-linaro rebasing branch
  - Dropped patches:
    * xen-simplify-xen_enabled.patch
    * sparc-linux-user-fix-missing-symbols-in-.rel-.rela.plt-sections.patch
    * main_loop-do-not-set-nonblocking-if-xen_enabled.patch
    * xen_machine_pv-do-not-create-a-dummy-CPU-in-machine-.patch
    * virtio-rng-fix-crash
  - Kept patches:
    * expose_vms_qemu64cpu.patch - updated
    * linaro arm patches from qemu-linaro rebasing branch
  - New patches:
    * fix-pci-add: change CONFIG variable in ifdef to make sure that
      pci_add is defined.
* Add linaro patches
* Add experimental mach-virt patches for arm virtualization.
* qemu-system-common.install: add debian/tmp/usr/lib to install the
  qemu-bridge-helper

Show diffs side-by-side

added added

removed removed

Lines of Context:
221
221
 
222
222
const char *get_register_name_32(unsigned int reg)
223
223
{
224
 
    if (reg > CPU_NB_REGS32) {
 
224
    if (reg >= CPU_NB_REGS32) {
225
225
        return NULL;
226
226
    }
227
227
    return x86_reg_info_32[reg].name;
670
670
    },
671
671
    {
672
672
        .name = "Conroe",
673
 
        .level = 2,
 
673
        .level = 4,
674
674
        .vendor = CPUID_VENDOR_INTEL,
675
675
        .family = 6,
676
 
        .model = 2,
 
676
        .model = 15,
677
677
        .stepping = 3,
678
678
        .features[FEAT_1_EDX] =
679
679
            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
692
692
    },
693
693
    {
694
694
        .name = "Penryn",
695
 
        .level = 2,
 
695
        .level = 4,
696
696
        .vendor = CPUID_VENDOR_INTEL,
697
697
        .family = 6,
698
 
        .model = 2,
 
698
        .model = 23,
699
699
        .stepping = 3,
700
700
        .features[FEAT_1_EDX] =
701
701
            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
715
715
    },
716
716
    {
717
717
        .name = "Nehalem",
718
 
        .level = 2,
 
718
        .level = 4,
719
719
        .vendor = CPUID_VENDOR_INTEL,
720
720
        .family = 6,
721
 
        .model = 2,
 
721
        .model = 26,
722
722
        .stepping = 3,
723
723
        .features[FEAT_1_EDX] =
724
724
            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
1476
1476
    error_propagate(errp, err);
1477
1477
}
1478
1478
 
1479
 
static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *name)
 
1479
static int cpu_x86_find_by_name(X86CPU *cpu, x86_def_t *x86_cpu_def,
 
1480
                                const char *name)
1480
1481
{
1481
1482
    x86_def_t *def;
 
1483
    Error *err = NULL;
1482
1484
    int i;
1483
1485
 
1484
1486
    if (name == NULL) {
1486
1488
    }
1487
1489
    if (kvm_enabled() && strcmp(name, "host") == 0) {
1488
1490
        kvm_cpu_fill_host(x86_cpu_def);
 
1491
        object_property_set_bool(OBJECT(cpu), true, "pmu", &err);
 
1492
        assert_no_error(err);
1489
1493
        return 0;
1490
1494
    }
1491
1495
 
1743
1747
 
1744
1748
    memset(def, 0, sizeof(*def));
1745
1749
 
1746
 
    if (cpu_x86_find_by_name(def, name) < 0) {
 
1750
    if (cpu_x86_find_by_name(cpu, def, name) < 0) {
1747
1751
        error_setg(errp, "Unable to find CPU definition: %s", name);
1748
1752
        return;
1749
1753
    }
1821
1825
    }
1822
1826
 
1823
1827
out:
1824
 
    error_propagate(errp, error);
 
1828
    if (error != NULL) {
 
1829
        error_propagate(errp, error);
 
1830
        object_unref(OBJECT(cpu));
 
1831
        cpu = NULL;
 
1832
    }
1825
1833
    g_strfreev(model_pieces);
1826
1834
    return cpu;
1827
1835
}
2017
2025
        break;
2018
2026
    case 0xA:
2019
2027
        /* Architectural Performance Monitoring Leaf */
2020
 
        if (kvm_enabled()) {
 
2028
        if (kvm_enabled() && cpu->enable_pmu) {
2021
2029
            KVMState *s = cs->kvm_state;
2022
2030
 
2023
2031
            *eax = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EAX);
2176
2184
    CPUX86State *env = &cpu->env;
2177
2185
    int i;
2178
2186
 
2179
 
    if (qemu_loglevel_mask(CPU_LOG_RESET)) {
2180
 
        qemu_log("CPU Reset (CPU %d)\n", s->cpu_index);
2181
 
        log_cpu_state(env, CPU_DUMP_FPU | CPU_DUMP_CCOP);
2182
 
    }
2183
 
 
2184
2187
    xcc->parent_reset(s);
2185
2188
 
2186
2189
 
2339
2342
 
2340
2343
static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
2341
2344
{
 
2345
    CPUState *cs = CPU(dev);
2342
2346
    X86CPU *cpu = X86_CPU(dev);
2343
2347
    X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
2344
2348
    CPUX86State *env = &cpu->env;
2393
2397
#endif
2394
2398
 
2395
2399
    mce_init(cpu);
2396
 
    qemu_init_vcpu(&cpu->env);
 
2400
    qemu_init_vcpu(cs);
2397
2401
 
2398
2402
    x86_cpu_apic_realize(cpu, &local_err);
2399
2403
    if (local_err != NULL) {
2400
2404
        goto out;
2401
2405
    }
2402
 
    cpu_reset(CPU(cpu));
 
2406
    cpu_reset(cs);
2403
2407
 
2404
2408
    xcc->parent_realize(dev, &local_err);
2405
2409
out:
2506
2510
    return env->cpuid_apic_id;
2507
2511
}
2508
2512
 
 
2513
static bool x86_cpu_get_paging_enabled(const CPUState *cs)
 
2514
{
 
2515
    X86CPU *cpu = X86_CPU(cs);
 
2516
 
 
2517
    return cpu->env.cr[0] & CR0_PG_MASK;
 
2518
}
 
2519
 
 
2520
static void x86_cpu_set_pc(CPUState *cs, vaddr value)
 
2521
{
 
2522
    X86CPU *cpu = X86_CPU(cs);
 
2523
 
 
2524
    cpu->env.eip = value;
 
2525
}
 
2526
 
 
2527
static void x86_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb)
 
2528
{
 
2529
    X86CPU *cpu = X86_CPU(cs);
 
2530
 
 
2531
    cpu->env.eip = tb->pc - tb->cs_base;
 
2532
}
 
2533
 
 
2534
static Property x86_cpu_properties[] = {
 
2535
    DEFINE_PROP_BOOL("pmu", X86CPU, enable_pmu, false),
 
2536
    DEFINE_PROP_END_OF_LIST()
 
2537
};
 
2538
 
2509
2539
static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
2510
2540
{
2511
2541
    X86CPUClass *xcc = X86_CPU_CLASS(oc);
2515
2545
    xcc->parent_realize = dc->realize;
2516
2546
    dc->realize = x86_cpu_realizefn;
2517
2547
    dc->bus_type = TYPE_ICC_BUS;
 
2548
    dc->props = x86_cpu_properties;
2518
2549
 
2519
2550
    xcc->parent_reset = cc->reset;
2520
2551
    cc->reset = x86_cpu_reset;
 
2552
    cc->reset_dump_flags = CPU_DUMP_FPU | CPU_DUMP_CCOP;
2521
2553
 
2522
2554
    cc->do_interrupt = x86_cpu_do_interrupt;
 
2555
    cc->dump_state = x86_cpu_dump_state;
 
2556
    cc->set_pc = x86_cpu_set_pc;
 
2557
    cc->synchronize_from_tb = x86_cpu_synchronize_from_tb;
 
2558
    cc->gdb_read_register = x86_cpu_gdb_read_register;
 
2559
    cc->gdb_write_register = x86_cpu_gdb_write_register;
 
2560
    cc->get_arch_id = x86_cpu_get_arch_id;
 
2561
    cc->get_paging_enabled = x86_cpu_get_paging_enabled;
2523
2562
#ifndef CONFIG_USER_ONLY
 
2563
    cc->get_memory_mapping = x86_cpu_get_memory_mapping;
 
2564
    cc->get_phys_page_debug = x86_cpu_get_phys_page_debug;
2524
2565
    cc->write_elf64_note = x86_cpu_write_elf64_note;
2525
2566
    cc->write_elf64_qemunote = x86_cpu_write_elf64_qemunote;
2526
2567
    cc->write_elf32_note = x86_cpu_write_elf32_note;
2527
2568
    cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote;
 
2569
    cc->vmsd = &vmstate_x86_cpu;
2528
2570
#endif
2529
 
    cpu_class_set_vmsd(cc, &vmstate_x86_cpu);
2530
 
 
2531
 
    cc->get_arch_id = x86_cpu_get_arch_id;
 
2571
    cc->gdb_num_core_regs = CPU_NB_REGS * 2 + 25;
2532
2572
}
2533
2573
 
2534
2574
static const TypeInfo x86_cpu_type_info = {