aboutsummaryrefslogtreecommitdiff
path: root/target/i386/kvm/kvm-cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'target/i386/kvm/kvm-cpu.c')
-rw-r--r--target/i386/kvm/kvm-cpu.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c
index 16bde4d..9c25b55 100644
--- a/target/i386/kvm/kvm-cpu.c
+++ b/target/i386/kvm/kvm-cpu.c
@@ -13,6 +13,7 @@
#include "qapi/error.h"
#include "system/system.h"
#include "hw/boards.h"
+#include "hw/i386/x86.h"
#include "kvm_i386.h"
#include "accel/accel-cpu-target.h"
@@ -41,6 +42,7 @@ static void kvm_set_guest_phys_bits(CPUState *cs)
static bool kvm_cpu_realizefn(CPUState *cs, Error **errp)
{
X86CPU *cpu = X86_CPU(cs);
+ X86CPUClass *xcc = X86_CPU_GET_CLASS(cpu);
CPUX86State *env = &cpu->env;
bool ret;
@@ -63,7 +65,7 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp)
* check/update ucode_rev, phys_bits, guest_phys_bits, mwait
* cpu_common_realizefn() (via xcc->parent_realize)
*/
- if (cpu->max_features) {
+ if (xcc->max_features) {
if (enable_cpu_pm) {
if (kvm_has_waitpkg()) {
env->features[FEAT_7_0_ECX] |= CPUID_7_0_ECX_WAITPKG;
@@ -72,7 +74,7 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp)
if (env->features[FEAT_1_ECX] & CPUID_EXT_MONITOR) {
host_cpuid(5, 0, &cpu->mwait.eax, &cpu->mwait.ebx,
&cpu->mwait.ecx, &cpu->mwait.edx);
- }
+ }
}
if (cpu->ucode_rev == 0) {
cpu->ucode_rev =
@@ -90,6 +92,15 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp)
kvm_set_guest_phys_bits(cs);
}
+ /*
+ * When SMM is enabled, there is 2 address spaces. Otherwise only 1.
+ *
+ * Only initialize address space 0 here, the second one for SMM is
+ * initialized at register_smram_listener() after machine init done.
+ */
+ cs->num_ases = x86_machine_is_smm_enabled(X86_MACHINE(current_machine)) ? 2 : 1;
+ cpu_address_space_init(cs, X86ASIdx_MEM, "cpu-memory", cs->memory);
+
return true;
}
@@ -108,7 +119,7 @@ static void kvm_cpu_max_instance_init(X86CPU *cpu)
CPUX86State *env = &cpu->env;
KVMState *s = kvm_state;
- host_cpu_max_instance_init(cpu);
+ object_property_set_bool(OBJECT(cpu), "pmu", true, &error_abort);
if (lmce_supported()) {
object_property_set_bool(OBJECT(cpu), "lmce", true, &error_abort);
@@ -216,7 +227,7 @@ static void kvm_cpu_instance_init(CPUState *cs)
x86_cpu_apply_props(cpu, kvm_default_props);
}
- if (cpu->max_features) {
+ if (xcc->max_features) {
kvm_cpu_max_instance_init(cpu);
}