The proposal in v2 was to allocate all defined address spaces (CPUAddressSpace structs) statically, modifying the Address Space (AS) API by renaming cpu_address_space_init() to cpu_address_space_add() and by introducing a new cpu_address_space_init() meant to be used to set the total number of address spaces in a CPU (instead of setting the cpu->num_ases invariant directly, as we currently do).
However, Phil said that what he actually had in mind was to set cpu->num_ases automatically in the CPUClass, hence without the need to set cpu->num_ases using any AS API function, burying the details of initializing cpu->num_ases within the CPUClass. This way, the initialization of the ASes is reduced to the simple and unique use of cpu_address_space_init(). This version (v3) is essentially based on what Phil proposed in the v2 review, but I removed the re-setting of cs->num_ases to 1 in x86_cpu_realizefn(), avoiding changes to num_ases beyond the CPUClass instantiation. First, it will become inconsistent as new ASes are added. Second, it risks causing confusion about the new AS API semantics, which require using cpu_address_space_init on demand, as ASes are required by the target, without modifying num_ases elsewhere in the code beyond CPUClass instantiation. I hope that now we have a strong candidate to be merged that enhances the current situation, allowing adding new address spaces in the target quite easily. CI results: https://gitlab.com/gusbromero/qemu/-/pipelines/2228868887 v1: https://mail.gnu.org/archive/html/qemu-devel/2025-11/msg04406.html v2: https://mail.gnu.org/archive/html/qemu-devel/2025-12/msg02298.html Cheers, Gustavo Gustavo Romero (3): target/arm: Initialize AS 0 first target/i386: Add a _MAX sentinel to X86ASIdx enum target/arm: Add a _MAX sentinel to ARMASIdx enum Philippe Mathieu-Daudé (1): cpus: Define total number of address spaces in CPUClass hw/core/cpu-common.c | 2 +- hw/core/cpu-system.c | 6 ------ include/hw/core/cpu.h | 3 +++ system/cpus.c | 7 ++++--- system/physmem.c | 22 ++++++++++++++++------ target/arm/cpu.c | 5 +++-- target/arm/cpu.h | 2 ++ target/i386/cpu.c | 1 + target/i386/cpu.h | 2 ++ target/i386/kvm/kvm-cpu.c | 1 - 10 files changed, 32 insertions(+), 19 deletions(-) -- 2.34.1
