Use the new cpu_address_space_init function to set the total number of
ASes in a CPU instead of directly setting it via cpu->num_ases.
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
---
system/cpus.c | 4 ++--
target/arm/cpu.c | 10 +---------
target/i386/kvm/kvm-cpu.c | 3 ++-
target/i386/tcg/system/tcg-cpu.c | 2 +-
4 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/system/cpus.c b/system/cpus.c
index fa9deafa29..54be6a3faf 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -718,8 +718,8 @@ void qemu_init_vcpu(CPUState *cpu)
/* If the target cpu hasn't set up any address spaces itself,
* give it the default one.
*/
- cpu->num_ases = 1;
- cpu_address_space_add(cpu, 0, "cpu-memory", cpu->memory);
+ cpu_address_space_init(cpu, 1 /* Number of ASes */);
+ cpu_address_space_add(cpu, 0 /* AS index */, "cpu-memory", cpu->memory);
}
/* accelerators all implement the AccelOpsClass */
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 1902c510f9..67ad6f0a6e 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -2148,15 +2148,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
unsigned int smp_cpus = ms->smp.cpus;
bool has_secure = cpu->has_el3 || arm_feature(env, ARM_FEATURE_M_SECURITY);
- /*
- * We must set cs->num_ases to the final value before
- * the first call to cpu_address_space_init.
- */
- if (cpu->tag_memory != NULL) {
- cs->num_ases = 3 + has_secure;
- } else {
- cs->num_ases = 1 + has_secure;
- }
+ cpu_address_space_init(cs, ARMASIdx_MAX);
cpu_address_space_add(cs, ARMASIdx_NS, "cpu-memory", cs->memory);
diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c
index a6d94d0620..dbb04ef051 100644
--- a/target/i386/kvm/kvm-cpu.c
+++ b/target/i386/kvm/kvm-cpu.c
@@ -92,13 +92,14 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp)
kvm_set_guest_phys_bits(cs);
}
+ cpu_address_space_init(cs, X86ASIdx_MAX);
+
/*
* 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_add(cs, X86ASIdx_MEM, "cpu-memory", cs->memory);
return true;
diff --git a/target/i386/tcg/system/tcg-cpu.c b/target/i386/tcg/system/tcg-cpu.c
index 231a4bdf55..ab72c5ff7b 100644
--- a/target/i386/tcg/system/tcg-cpu.c
+++ b/target/i386/tcg/system/tcg-cpu.c
@@ -73,7 +73,7 @@ bool tcg_cpu_realizefn(CPUState *cs, Error **errp)
memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, cpu->cpu_as_mem, 0);
memory_region_set_enabled(cpu->cpu_as_mem, true);
- cs->num_ases = 2;
+ cpu_address_space_init(cs, X86ASIdx_MAX);
cpu_address_space_add(cs, X86ASIdx_MEM, "cpu-memory", cs->memory);
cpu_address_space_add(cs, X86ASIdx_SMM, "cpu-smm", cpu->cpu_as_root);
--
2.34.1