1476
1476
error_propagate(errp, err);
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,
1481
1482
x86_def_t *def;
1484
1486
if (name == NULL) {
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);
1744
1748
memset(def, 0, sizeof(*def));
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);
1824
error_propagate(errp, error);
1828
if (error != NULL) {
1829
error_propagate(errp, error);
1830
object_unref(OBJECT(cpu));
1825
1833
g_strfreev(model_pieces);
2019
2027
/* Architectural Performance Monitoring Leaf */
2020
if (kvm_enabled()) {
2028
if (kvm_enabled() && cpu->enable_pmu) {
2021
2029
KVMState *s = cs->kvm_state;
2023
2031
*eax = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EAX);
2176
2184
CPUX86State *env = &cpu->env;
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);
2184
2187
xcc->parent_reset(s);
2340
2343
static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
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;
2506
2510
return env->cpuid_apic_id;
2513
static bool x86_cpu_get_paging_enabled(const CPUState *cs)
2515
X86CPU *cpu = X86_CPU(cs);
2517
return cpu->env.cr[0] & CR0_PG_MASK;
2520
static void x86_cpu_set_pc(CPUState *cs, vaddr value)
2522
X86CPU *cpu = X86_CPU(cs);
2524
cpu->env.eip = value;
2527
static void x86_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb)
2529
X86CPU *cpu = X86_CPU(cs);
2531
cpu->env.eip = tb->pc - tb->cs_base;
2534
static Property x86_cpu_properties[] = {
2535
DEFINE_PROP_BOOL("pmu", X86CPU, enable_pmu, false),
2536
DEFINE_PROP_END_OF_LIST()
2509
2539
static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
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;
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;
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;
2529
cpu_class_set_vmsd(cc, &vmstate_x86_cpu);
2531
cc->get_arch_id = x86_cpu_get_arch_id;
2571
cc->gdb_num_core_regs = CPU_NB_REGS * 2 + 25;
2534
2574
static const TypeInfo x86_cpu_type_info = {