Use new cpu_addess_space_init() to initialize the ASes for CPU, instead of setting cpu->num_ases directly and use cpu_address_space_add() to add the required ASes dynamically.
Signed-off-by: Gustavo Romero <[email protected]> --- target/arm/cpu.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 1640b20b4d..c7151a2c1e 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2148,31 +2148,23 @@ 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_init(cs, ARMASIdx_NS, "cpu-memory", cs->memory); + cpu_address_space_add(cs, ARMASIdx_NS, "cpu-memory", cs->memory); if (has_secure) { if (!cpu->secure_memory) { cpu->secure_memory = cs->memory; } - cpu_address_space_init(cs, ARMASIdx_S, "cpu-secure-memory", + cpu_address_space_add(cs, ARMASIdx_S, "cpu-secure-memory", cpu->secure_memory); } if (cpu->tag_memory != NULL) { - cpu_address_space_init(cs, ARMASIdx_TagNS, "cpu-tag-memory", + cpu_address_space_add(cs, ARMASIdx_TagNS, "cpu-tag-memory", cpu->tag_memory); if (has_secure) { - cpu_address_space_init(cs, ARMASIdx_TagS, "cpu-tag-memory", + cpu_address_space_add(cs, ARMASIdx_TagS, "cpu-tag-memory", cpu->secure_tag_memory); } } -- 2.34.1
