From nobody Sat Nov 29 10:17:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1764333820; cv=none; d=zohomail.com; s=zohoarc; b=aShQniFPSTd4gguFExA1/tS6b48S2n+Y4XtWOUirUL9xDQ8jPBU/eSi/drGmKoEYDppLEfxqUIgBOnbRlUJqU/WIjpfwieqIq2R63IkFNKFnydUdIYBVrZRwdhe3eLDJq20GFPEp+dDDKVu+wwxt1e3Rlcr0MLamlyRdjrn3vK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764333820; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TvuhIn8uZaMtJm4NBcfBnin3FaZy0VdfFZGXB/Y9EHQ=; b=gbTjg/bSyEMpsV6LhdXPE7fb/yUVwf6WoX0PMaB8m9Z2yKAmIVvC2+8/lDWa2xfAYvFOXOZSIDODzgyasnn0G6ly0z8C+Wt+WNU4Io5TJMkVsjqU5J7DO2TX44lkVIgrqOTp0iOAcOobteNgC944mlznZBR2qNBiTgqYWvq0pIM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764333820002839.0421032227308; Fri, 28 Nov 2025 04:43:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vOxo3-0001z0-Fr; Fri, 28 Nov 2025 07:42:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vOxnx-0001r5-Do for qemu-devel@nongnu.org; Fri, 28 Nov 2025 07:42:30 -0500 Received: from mail-vk1-xa2c.google.com ([2607:f8b0:4864:20::a2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vOxnt-00035l-RI for qemu-devel@nongnu.org; Fri, 28 Nov 2025 07:42:29 -0500 Received: by mail-vk1-xa2c.google.com with SMTP id 71dfb90a1353d-559836d04f6so1319477e0c.0 for ; Fri, 28 Nov 2025 04:42:24 -0800 (PST) Received: from gromero0.. ([177.139.2.175]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-55cf4e1d56asm1776930e0c.4.2025.11.28.04.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 04:42:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764333744; x=1764938544; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TvuhIn8uZaMtJm4NBcfBnin3FaZy0VdfFZGXB/Y9EHQ=; b=HNN2S9y7vX5nElQA4RKQyM0dYnqBybZzEJ/xftUHwwskp54rjW9mxhZJfcap0jMflr G5iLuo+7IiggREUpNJKmRZohFlUWgReKRwpfYNv65R6cUZS1qhyYc008EbDO/wxM7JZi i2Lk8Ny9YvAhIzSaYDVxhzLDsGOzvFPgwEPcar3egq1jdlOadHiJZCsKFdLR6/z6hZC0 7oz44nTuvJ7I1/n3klmubAsc2xlsedM91E2qX/Tx5z45hrsnomGgDGvx8R06T6WN1VsA o6abracmNlw7bGQw4TIAOfi49eGfuKD7tOp3xkr9+mdKtZ8Il3hHSfjAkLhK9C8BZJnp 1sCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764333744; x=1764938544; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TvuhIn8uZaMtJm4NBcfBnin3FaZy0VdfFZGXB/Y9EHQ=; b=mOj348toO7lEwMwhaitUZnRJuG7g9aqPY39xKtea8pFZ/aqcBb49HA6aDWLuWfxYz2 AyV7Ph5WbAw0GJBKs8DpF+Uv5j06a1R+xuLJlL37YulXcb17gqQ81usuR23U37pKCb6K VSr/RDKAFCboVhklfr88/3veBMSqZYydZTePS3MiKJ7pWyLx/oT497pJkgNqptZ3+wu6 5iOSGFEV1e6GxBlQD2jG7StE0YssgQqLuZacCvX2vZDN+RDE09yR8cmj0rlnl9uR7/2O cQXWtas4WL72BuuHbCemOI6DWUoSCipVutteqRaxTSmtgN+r/sgR8EauA2GrcGdNd5F2 1wOw== X-Gm-Message-State: AOJu0YxIuEuvVlSE5Kyf/2JyOwP/a6CShqY1zw0iyZOkOA47+NMJIuiR laxGJfQJOQYWLdIS0yp8fOvzm5XkXrzj9mtod66YK/Ew7ebSw4WrBfWVfn9UbA4jHC0kmkD7O87 wmvSe X-Gm-Gg: ASbGncsCvP19xiiq7Uzy7YoLps6x1qzHnp8O27vP7XIzj5zmCl3vuYeU0l+BdL/XCIp ad/lDJmIN1YDwaa5lKDtZ6zWkioQTpjyesPpFfoV9UZE4b7D1zupCb2tDqRvW+47SYyHSh5LrjJ bEqzt0NdV4Jk/VmnJ0HkI7Nh+BgX50tiZ9U+w+p2v0J8IOEgaUCva6oSI6mp12waIhaIb8BvyOe v8avV8JgGVHXZs07VPOD2NnWBSZ875oM2BuOQLJLXcGhy8pdM7PAZhhpiX3q7wOBo4btoIVXbOv VRqtX3OQfFcANCSz4NCIZt0/IwhsGajRZrOH9Vrin7aP1mzHOy6Zt8G2+UO12TZEpfDHMVZQH2P T9wf86lmGIHcs7nSkxVcHG3RrSbgilPuDHKg5GRm7yxVNDvk9Hiw3HBnq3D+G3iGbjYhSdNrhKZ bVx3+Au3O5TPIOvFY= X-Google-Smtp-Source: AGHT+IEou8H9OT3q+BTzkiYzJRkn+KMoghYpSS/0UflTxuYL8Xgpy8HI5SRZKQKTKHdtMce/NRyyQg== X-Received: by 2002:a05:6122:2893:b0:55b:1a3a:aae5 with SMTP id 71dfb90a1353d-55b8f00e3c4mr9319308e0c.16.1764333743886; Fri, 28 Nov 2025 04:42:23 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org, philmd@linaro.org Cc: peter.maydell@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v1 1/6] system/physmem: Enhance the Address Space API Date: Fri, 28 Nov 2025 12:41:05 +0000 Message-Id: <20251128124110.1272336-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128124110.1272336-1-gustavo.romero@linaro.org> References: <20251128124110.1272336-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a2c; envelope-from=gustavo.romero@linaro.org; helo=mail-vk1-xa2c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1764333821287019200 Content-Type: text/plain; charset="utf-8" Currently, the Address Space (AS) API allocates the ASes for a CPU statically using g_new0 in cpu_address_space_init(). This requires computing the number of ASes and setting cpu->num_ases, directly, before calling cpu_address_space_init() to initialize the ASes for a CPU. The number of ASes usually depends on the number of CPU features that require an AS. Since it's necessary to know the total number of ASes to set it in cpu->num_ases before calling cpu_address_space_init(), and because we usually only check for the CPU features that require an AS later in the code, having to set cpu->num_ases earlier complicates the code that uses the current API. Moreover, the number of ASes currently allocated statically is tightly coupled to the AS index defined in an enum. For example, if ASes with indexes 0 and 2 are required but not the AS at index 1, three ASes, i.e. three CPUAddressSpace structs, will be allocated in the cpu->cpu_ases array, but only two will be effectively used. This commit addresses both issues by allocating the CPUAddressSpace dynamically, using g_array_new and g_array_append instead of g_new0 in cpu_address_space_add(). It introduces a new cpu_address_space_init(), used only to initialize the number of ASes and that is called only once before adding the ASes. An index map is also introduced, cpu->as_to_cpuas_idx, which is meant to map the AS indexes, which can form a sparse sequence, to the CPU AS indexes, which must be a dense sequence, as they are the indexes used to access the CPU ASes in the cpu->cpu_ases array. The old cpu_address_space_init() is renamed to cpu_address_space_add(). It can be called any number of times, once per AS type, up to the maximum number of ASes defined by an architecture. Hence, no prior computation of the number of ASes is required. Signed-off-by: Gustavo Romero --- include/exec/cpu-common.h | 16 +++++++-- include/hw/core/cpu.h | 6 +++- stubs/cpu-destroy-address-spaces.c | 2 +- system/cpus.c | 4 +-- system/physmem.c | 56 ++++++++++++++++++++++-------- 5 files changed, 63 insertions(+), 21 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index e0be4ee2b8..f3a1accdad 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -103,6 +103,17 @@ size_t qemu_ram_pagesize_largest(void); =20 /** * cpu_address_space_init: + * @cpu: CPU to init the address space(s) + * @num_ases: number of address space(s) to init in the @cpu + * + * This function must be called before calling + * cpu_address_space_add and it sets the number of address + * spaces in @cpu. + */ +void cpu_address_space_init(CPUState *cpu, int num_ases); + +/** + * cpu_address_space_add: * @cpu: CPU to add this address space to * @asidx: integer index of this address space * @prefix: prefix to be used as name of address space @@ -120,8 +131,9 @@ size_t qemu_ram_pagesize_largest(void); * * Note that with KVM only one address space is supported. */ -void cpu_address_space_init(CPUState *cpu, int asidx, - const char *prefix, MemoryRegion *mr); +void cpu_address_space_add(CPUState *cpu, int asidx, + const char *prefix, MemoryRegion *mr); + /** * cpu_destroy_address_spaces: * @cpu: CPU for which address spaces need to be destroyed diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 9615051774..cb26d6acf0 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -402,6 +402,9 @@ struct qemu_work_item; =20 #define CPU_UNSET_NUMA_NODE_ID -1 =20 +#define CPUAS_IDX(asidx) (cpu->as_to_cpuas_idx[asidx]) +#define CPU_ASES(cpuas_idx) (g_array_index(cpu->cpu_ases, CPUAddressSpace= *, cpuas_idx)) + /** * struct CPUState - common state of one CPU core or thread. * @@ -515,7 +518,8 @@ struct CPUState { QemuMutex work_mutex; QSIMPLEQ_HEAD(, qemu_work_item) work_list; =20 - struct CPUAddressSpace *cpu_ases; + GArray *cpu_ases; + int *as_to_cpuas_idx; int num_ases; AddressSpace *as; MemoryRegion *memory; diff --git a/stubs/cpu-destroy-address-spaces.c b/stubs/cpu-destroy-address= -spaces.c index dc6813f5bd..a86e8d4db1 100644 --- a/stubs/cpu-destroy-address-spaces.c +++ b/stubs/cpu-destroy-address-spaces.c @@ -5,7 +5,7 @@ =20 /* * user-mode CPUs never create address spaces with - * cpu_address_space_init(), so the cleanup function doesn't + * cpu_address_space_add(), so the cleanup function doesn't * need to do anything. We need this stub because cpu-common.c * is built-once so it can't #ifndef CONFIG_USER around the * call; the real function is in physmem.c which is system-only. diff --git a/system/cpus.c b/system/cpus.c index ef2d2f241f..cfe05ef0be 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 =3D 1; - cpu_address_space_init(cpu, 0, "cpu-memory", cpu->memory); + cpu_address_space_init(cpu, 1 /* Number of address spaces */); + cpu_address_space_add(cpu, 0 /* AS index */, "cpu-memory", cpu->me= mory); } =20 /* accelerators all implement the AccelOpsClass */ diff --git a/system/physmem.c b/system/physmem.c index c9869e4049..03a2ecf495 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -692,7 +692,7 @@ address_space_translate_for_iotlb(CPUState *cpu, int as= idx, hwaddr orig_addr, IOMMUTLBEntry iotlb; int iommu_idx; hwaddr addr =3D orig_addr; - AddressSpaceDispatch *d =3D address_space_to_dispatch(cpu->cpu_ases[as= idx].as); + AddressSpaceDispatch *d =3D address_space_to_dispatch(CPU_ASES(CPUAS_I= DX(asidx))->as); =20 for (;;) { section =3D address_space_translate_internal(d, addr, &addr, plen,= false); @@ -752,7 +752,7 @@ MemoryRegionSection *iotlb_to_section(CPUState *cpu, hwaddr index, MemTxAttrs attrs) { int asidx =3D cpu_asidx_from_attrs(cpu, attrs); - CPUAddressSpace *cpuas =3D &cpu->cpu_ases[asidx]; + CPUAddressSpace *cpuas =3D CPU_ASES(CPUAS_IDX(asidx)); AddressSpaceDispatch *d =3D address_space_to_dispatch(cpuas->as); int section_index =3D index & ~TARGET_PAGE_MASK; MemoryRegionSection *ret; @@ -775,10 +775,23 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, =20 #endif /* CONFIG_TCG */ =20 -void cpu_address_space_init(CPUState *cpu, int asidx, - const char *prefix, MemoryRegion *mr) +void cpu_address_space_init(CPUState *cpu, int num_ases) { - CPUAddressSpace *newas; + /* Must be called only once per vCPU. */ + assert(cpu->as_to_cpuas_idx =3D=3D NULL); + + cpu->num_ases =3D num_ases; + cpu->as_to_cpuas_idx =3D g_new0(int, num_ases); + /* Mark all AS indexes as uninitialized. */ + for (int i =3D 0; i < num_ases; i++) { + cpu->as_to_cpuas_idx[i] =3D -1; + } +} + +void cpu_address_space_add(CPUState *cpu, int asidx, + const char *prefix, MemoryRegion *mr) +{ + CPUAddressSpace *newas =3D g_new0(CPUAddressSpace, 1); AddressSpace *as =3D g_new0(AddressSpace, 1); char *as_name; =20 @@ -787,19 +800,24 @@ void cpu_address_space_init(CPUState *cpu, int asidx, address_space_init(as, mr, as_name); g_free(as_name); =20 - /* Target code should have set num_ases before calling us */ + /* + * Target code should have called cpu_address_space_init() + * before to set the number of address spaces in a vCPU. + */ assert(asidx < cpu->num_ases); =20 + /* An address space can only be initialized once. */ + assert(cpu->as_to_cpuas_idx[asidx] =3D=3D -1); + if (asidx =3D=3D 0) { /* address space 0 gets the convenience alias */ cpu->as =3D as; } =20 if (!cpu->cpu_ases) { - cpu->cpu_ases =3D g_new0(CPUAddressSpace, cpu->num_ases); + cpu->cpu_ases =3D g_array_new(true, true, sizeof(CPUAddressSpace *= )); } =20 - newas =3D &cpu->cpu_ases[asidx]; newas->cpu =3D cpu; newas->as =3D as; if (tcg_enabled()) { @@ -808,20 +826,25 @@ void cpu_address_space_init(CPUState *cpu, int asidx, newas->tcg_as_listener.name =3D "tcg"; memory_listener_register(&newas->tcg_as_listener, as); } + + /* Map the AS index to the next available index in the CPU ASes array. = */ + cpu->as_to_cpuas_idx[asidx] =3D cpu->cpu_ases->len; + /* Add the new CPU AS to the slot at the next available index. */ + g_array_append_val(cpu->cpu_ases, newas); } =20 void cpu_destroy_address_spaces(CPUState *cpu) { CPUAddressSpace *cpuas; - int asidx; + int cpuas_idx; =20 assert(cpu->cpu_ases); =20 /* convenience alias just points to some cpu_ases[n] */ cpu->as =3D NULL; =20 - for (asidx =3D 0; asidx < cpu->num_ases; asidx++) { - cpuas =3D &cpu->cpu_ases[asidx]; + for (cpuas_idx =3D cpu->cpu_ases->len; cpuas_idx-- > 0; ) { + cpuas =3D CPU_ASES(cpuas_idx); if (!cpuas->as) { /* This index was never initialized; no deinit needed */ continue; @@ -829,16 +852,19 @@ void cpu_destroy_address_spaces(CPUState *cpu) if (tcg_enabled()) { memory_listener_unregister(&cpuas->tcg_as_listener); } + /* Free CPUAddressSpace->AddressSpace. */ g_clear_pointer(&cpuas->as, address_space_destroy_free); + /* Free CPUAddressSpace. */ + g_free(cpuas); + /* Remove pointer to freed CPUAddressSpace. */ + g_array_remove_index(cpu->cpu_ases, cpuas_idx); } - - g_clear_pointer(&cpu->cpu_ases, g_free); } =20 AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx) { /* Return the AddressSpace corresponding to the specified index */ - return cpu->cpu_ases[asidx].as; + return CPU_ASES(CPUAS_IDX(asidx))->as; } =20 /* Called from RCU critical section */ @@ -4056,7 +4082,7 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, if (l > len) l =3D len; phys_addr +=3D (addr & ~TARGET_PAGE_MASK); - res =3D address_space_rw(cpu->cpu_ases[asidx].as, phys_addr, attrs= , buf, + res =3D address_space_rw(CPU_ASES(CPUAS_IDX(asidx))->as, phys_addr= , attrs, buf, l, is_write); if (res !=3D MEMTX_OK) { return -1; --=20 2.34.1 From nobody Sat Nov 29 10:17:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1764333827; cv=none; d=zohomail.com; s=zohoarc; b=I17lHgDtOHPRbNNG0vHkyXCQObLSICpZEJ64dcPd5Wu/uoW9eCPq/kTo2J7mYpPLEdiprxjhkv4vVhBKB8f62R6q8376HA2iwsiPf++w9dNRMa7klxn/ALKzfQ/y7Kt8rcGwE6FNzl2OZMb6EA8KCaLwkSRC9PW9MiOhK/9vs7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764333827; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ux7V/vcnfKVnQVQzXuR5cKKTLtK6T4UuaelCSQB/P7E=; b=jsekH1JKhdOPRiqgEsH9K9cx2xE5w6vpNsjtFYnXckp/HysCvSLWpJkNyzH44ANbfcB1SqmFu9UAzWF+QHK8zHzGVlQGMBGjfImO6ZPIsbiD2xyJU75E81PNoUiNnb3AEyVrgL1wj3zyU1KNUIztMRn+QI9hRiufi7BP96q7hNY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764333827288244.93319703506893; Fri, 28 Nov 2025 04:43:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vOxo7-0002AD-An; Fri, 28 Nov 2025 07:42:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vOxnz-0001rj-9J for qemu-devel@nongnu.org; Fri, 28 Nov 2025 07:42:31 -0500 Received: from mail-vk1-xa2a.google.com ([2607:f8b0:4864:20::a2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vOxnv-00036O-M9 for qemu-devel@nongnu.org; Fri, 28 Nov 2025 07:42:30 -0500 Received: by mail-vk1-xa2a.google.com with SMTP id 71dfb90a1353d-55b09f54e98so659251e0c.1 for ; Fri, 28 Nov 2025 04:42:27 -0800 (PST) Received: from gromero0.. ([177.139.2.175]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-55cf4e1d56asm1776930e0c.4.2025.11.28.04.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 04:42:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764333746; x=1764938546; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ux7V/vcnfKVnQVQzXuR5cKKTLtK6T4UuaelCSQB/P7E=; b=si3MJAc/yCGXyhXydOp7QVjyOFg+wl71mMH5NW7+PF+VaPD0FGwZVgxYLXjuzqMT7p 1Y0/UvIH813YHUiyEVTTs+soidgSIcssgA9eYpIcplB3ELh6O/f2IhHbscIu+gO68MHm M5FJIcF1lGK4+4RXTqDsSwO2z5Ct/2vUsxAfBqnuz0V8/n5k6KXO45bpuioDNsJSEPpW lMWYOUjANFRg214cIVS/FgJVdpdDQx8ZNa8hoTrybslK9q+fgkvfX58nQLOLCX5naHfG 657gMFMK4pwLIDIJr8lgAGD5Vc/KbCwnO71UbaG6XceyBIoLuMvgLd9QOZRsF2vc+kfz HSqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764333746; x=1764938546; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ux7V/vcnfKVnQVQzXuR5cKKTLtK6T4UuaelCSQB/P7E=; b=p+X/O2qk4WmaMlKuDZhy5K0nfY6Ynpuvyfam5ObNnSGjQz7GT5cv7HqsvwcmnFv1Mn 0Kr15V9UlSeIUUDxidLsxMxBMzBRC04NcF8L7XmQNPTrLoLC3MPAj1+MQLzUpM4f0B/2 6O4n1fMiqV89p4kVw7ObZqO00qLLh2IyNhA5hFdTOL97MKWDN2FB3d+G7+G/frPsHiQb 2KviGN7W3u4FqEWDNW0namBkDGnxmMwvT6L/ey+5VqiQ3DG3Xbpep4S2btGL2npGzyw3 rSJZcnXnPlP9jMCxWR4OLGSfe8Px0iC0z2PUfOWaJYW7pec8/A4UbK2QuZWRnLCRNZbX JaDw== X-Gm-Message-State: AOJu0YzwRRi9TygoGQoaEXmIjDmbDQPfkLlAI5t6EaStJwfL+Q4aEly0 t++JQByv4kSt1weyjLxnF6EDdyiBKDAOhkmY3NbiDFMzTHbRycp9k5z1M5GmWuiZPWZeTSva0vc 4+Jyg X-Gm-Gg: ASbGnctQ64SD+Uu3i51DeyMD08gnRkVig7zoD2qJ+50Z+Mqt+32JPaTZuvMxI1cnCod cR20j2ijpF58nBkzAU6vhil2fxb4M8c81Hz6IiL2y7OcF/b2GPD0M16yrUEvIoVn8yAFAfHSG14 uC9npI+wZTpfbLVkpwk0aY+gc7q6NRLqndxFkYyJ89xP+tBiQCws9uHcgGKUMl06H/AaMeeE3RW CX2Dn2msZ5jd5FpjX7WS/IVcqCyRjHhqGQquHuCBjxy+d43v4XywerHC0pI8zHso2w4l4lbOolo D5CkVOCnZOZ32SElnCZdMEK2J/tboPwDTwhT2D2+cpzFbYnuBt8rV74VA5dcss8m1BNWHKNWQwb efpTZcWHSlkwBstswH+NzL3ZFr4ZmTEmsq/G3M2iHsnJB+5aisHXPjHnjtjVqyHIdOMAj0TBUD2 L7weuNZC4Tyff+MYI= X-Google-Smtp-Source: AGHT+IHlzQ57t4dcBZK6NHRL2f5576mqrLpy4QrKB9k4lPeKHAYQOHUVFPBq4iB8CQgiCSiBYcMoXA== X-Received: by 2002:a05:6122:6602:b0:559:ed61:4693 with SMTP id 71dfb90a1353d-55b8eff01fcmr10420434e0c.10.1764333746328; Fri, 28 Nov 2025 04:42:26 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org, philmd@linaro.org Cc: peter.maydell@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v1 2/6] target/arm: Initialize AS 0 first Date: Fri, 28 Nov 2025 12:41:06 +0000 Message-Id: <20251128124110.1272336-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128124110.1272336-1-gustavo.romero@linaro.org> References: <20251128124110.1272336-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a2a; envelope-from=gustavo.romero@linaro.org; helo=mail-vk1-xa2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1764333829053019201 Move the initialization of AS of index 0 (ARMASIdx_NS) so it happens before the initialization of the other address spaces. This is purely a code organization change with no effect on behavior. Signed-off-by: Gustavo Romero Suggested-by: Alex Benn=C3=A9e --- target/arm/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 39292fb9bc..1640b20b4d 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2158,6 +2158,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) cs->num_ases =3D 1 + has_secure; } =20 + cpu_address_space_init(cs, ARMASIdx_NS, "cpu-memory", cs->memory); + if (has_secure) { if (!cpu->secure_memory) { cpu->secure_memory =3D cs->memory; @@ -2175,8 +2177,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) } } =20 - cpu_address_space_init(cs, ARMASIdx_NS, "cpu-memory", cs->memory); - /* No core_count specified, default to smp_cpus. */ if (cpu->core_count =3D=3D -1) { cpu->core_count =3D smp_cpus; --=20 2.34.1 From nobody Sat Nov 29 10:17:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1764333843; cv=none; d=zohomail.com; s=zohoarc; b=CWVs+6GnTgRtzFE/TVGvS3VUgm8DSJlUJ7Cz0sBWCFLYtIKlEHExDy3NBoLIkOqDqVPYm2FfXJaAI6n1s716bV2QCL1FEdAcO4iUVFJtVUzkXJ42TEVH+gAy7eCerEh5m08IQRBvclyHv7dIiMjzie5tgBaPQ0oZQ/Ar4/pCgWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764333843; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=u2+w7aKeM4mn6IUIq7PiZicrN3KwLnQcc+QlfR75hvY=; b=RK5MxtjFukWLbhp4VPWOKYylXH1mojmphgNw3NkG3T1B8KUKcNbavvTa7UZtaFfPuDl5cgdmfD3CfbzbCsa+FxgUPlkP5QaeM4HrLmE8qq5uPOHuEshZSNaFdHRd7sFLpMQSJ/iRJoQcA2CxbRdtbtPX9AiP6D5ldTdva9faLYo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764333843541842.9487917037294; Fri, 28 Nov 2025 04:44:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vOxoE-0002CI-LK; Fri, 28 Nov 2025 07:42:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vOxo1-0001xi-DL for qemu-devel@nongnu.org; Fri, 28 Nov 2025 07:42:35 -0500 Received: from mail-vk1-xa2b.google.com ([2607:f8b0:4864:20::a2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vOxny-00037T-UH for qemu-devel@nongnu.org; Fri, 28 Nov 2025 07:42:32 -0500 Received: by mail-vk1-xa2b.google.com with SMTP id 71dfb90a1353d-55b6a642a4cso1213403e0c.3 for ; Fri, 28 Nov 2025 04:42:29 -0800 (PST) Received: from gromero0.. ([177.139.2.175]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-55cf4e1d56asm1776930e0c.4.2025.11.28.04.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 04:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764333749; x=1764938549; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u2+w7aKeM4mn6IUIq7PiZicrN3KwLnQcc+QlfR75hvY=; b=FAahTJDvZDOJi8pH598gbhliuHmCsPbZUbxc4bebao+wZQU7tNLUED9NPTW/drHcDb plOM/B6dwwEZQNE42F4w7H1ZdbrzDea7iDSjFDiS/lTjokwdxKuzoBUguUy8as/Krz11 gS4M9RydQdzpQ+1XO4F4fF7JjUNLlV+K3yw50nBOBUvMGre43J1c98AS7Kgy7GSDWnwl pd0f82k1j1jM6D8k/eGoU8wEobMhFQJxrJ3cnN1d4HSKRTbBr1eiugS11PNIesFDKm7Z RBFZarQ1+FCpjOQhCrFOjzBdgBCpc+NiXzOjIvxOX3+fvibgcBbvc3h60Jhwvy1pg6S5 8v4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764333749; x=1764938549; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=u2+w7aKeM4mn6IUIq7PiZicrN3KwLnQcc+QlfR75hvY=; b=qjWReRKao/maTtkRdF3TtK7I5vLw20p4sk5NJ9g5RIHGuUq4GYs4lwdVhRHu1U0qiS msN0j+UXfrXzP02gWuFY3e0rh7ANBkNY7+GG6wR1wNoYKFd5Apyd1xL9HOdpD4fS1U9A 0K1sGUhvXR5FSBaklTp0hOIG+Njt4iWTrcXMARb1iIODFxocq3bCfOLCiSsePXzKyUxp h/dvIjAr9ATdRlRbR8LgrKm0J9sBSJBNiinzl3KP4T03eTjG3Z85VyskRqMSjBfveIuB PEJ24/SLhjbR4Fe7Gzpok9F0o9PLYw6BA3k8uZyfj1TnlC3jr/e7ZrX7ztajQMfMQN6/ w9Ng== X-Gm-Message-State: AOJu0YxGOyj4SnIWZwcqC9eLy86iS5h+eaGDKL5sXyKM3eBn/8NMXflK ayUXO+TaDCntni3rfyyVaDdZHlniCbXWOpzW+YzF553C6UxI3NzeHqlP8/syL4GPyUV4i00pc/u vWEW4 X-Gm-Gg: ASbGncuuiXvpEP3puUFhEQ1UI+2d496GrrgJpCLTCTxqrkPRuSC8jngeudul+25ZXS+ ddyGknqeugtFJ+eHFCfOUTNPXbyAIfmsgkL9VlyIakRFPoZ+AoWIza8F7aJALXGTUGYvCwgJjEF Q842dGzCQVHTgQJY9Rju4hKzDbUHHIHYd5vvTfkkkRrBabO9dxjHW4NZsojmo3aSaN7hWmBurNn /9LyYGwsEtgyD0/PxlBlUP+1Wm2Ge7CjIrYP1wnN2ZBZWEkKZ+FYVPPSNyQaB6qkxGiajah+7mP dOmLlhYLaecvskxGiU2T9sDGtO6WX0kaLhSraGgMRqjluMHJUuIHiaWcEbISkm26yKvHaA+OIu3 pYGx0qXfuXQ4GrBX8WGXMtyH7Zk74NNxjHNpNj6g1vvJvLSj0d4IBOJsLNJiJcf+u+8J7eXcyqK bqHsYcVy/241XTciJZvTTZtfSnFg== X-Google-Smtp-Source: AGHT+IFkEOO1HxrrFhHSwQQNPPj4Qz3a19ayGVICN9yh2joO63JaDcXWtGBCWeTJTQPUFQsbSXaOHw== X-Received: by 2002:a05:6122:3d06:b0:55b:9c2d:1147 with SMTP id 71dfb90a1353d-55cd761e433mr5654983e0c.1.1764333748670; Fri, 28 Nov 2025 04:42:28 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org, philmd@linaro.org Cc: peter.maydell@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v1 3/6] target/arm: Add a _MAX sentinel to ARMASIdx enum Date: Fri, 28 Nov 2025 12:41:07 +0000 Message-Id: <20251128124110.1272336-4-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128124110.1272336-1-gustavo.romero@linaro.org> References: <20251128124110.1272336-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a2b; envelope-from=gustavo.romero@linaro.org; helo=mail-vk1-xa2b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1764333844973019200 Content-Type: text/plain; charset="utf-8" Add a sentinel to the ARMASIdx enum so it can be used when the total number of address spaces is required. Signed-off-by: Gustavo Romero --- target/arm/cpu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 39f2b2e54d..00f5af0fcd 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2336,6 +2336,7 @@ typedef enum ARMASIdx { ARMASIdx_S =3D 1, ARMASIdx_TagNS =3D 2, ARMASIdx_TagS =3D 3, + ARMASIdx_MAX } ARMASIdx; =20 static inline ARMMMUIdx arm_space_to_phys(ARMSecuritySpace space) --=20 2.34.1 From nobody Sat Nov 29 10:17:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1764333839; cv=none; d=zohomail.com; s=zohoarc; b=VOq95db4f4gO9Clzz2Nhu4unDAWaJQKXGr3pIYGxBX8dGqF1xQ3HwePZ8ChH8GoSYEZxgH14lfKJ6Rh5Wv7d1f284q2OH4LeGDCOZzfuvDVELhhZGBceeQaZnmbvipX7p/WY90rDU3oGtZJweXNmwx9ZiFdguUsT8DTgXwINRIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764333839; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8EnHLBHH/9x6RQh+DJhX2515VrjyRTLJawVS+ytU3po=; b=kru/yqbpuya3UlNsDufh6jaohcGorFUPrlicgJDsYAomp2+cBGfgGABqAt/0pRCBkJ94kNIJouWTC58qQsnRX/asaK/DAHO+RZNFpijkTRQHNbRip+DAB9nxpdfiQ7ulxukw7jsK8+rSoYzRTb1On3l05WbKBVSAvy2/VAGH8Zk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764333839211828.4424745085281; Fri, 28 Nov 2025 04:43:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vOxoE-0002EK-LE; Fri, 28 Nov 2025 07:42:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vOxo3-00026N-IQ for qemu-devel@nongnu.org; Fri, 28 Nov 2025 07:42:35 -0500 Received: from mail-vk1-xa2a.google.com ([2607:f8b0:4864:20::a2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vOxo1-00038Z-5L for qemu-devel@nongnu.org; Fri, 28 Nov 2025 07:42:35 -0500 Received: by mail-vk1-xa2a.google.com with SMTP id 71dfb90a1353d-55b2f2ae1cbso1223242e0c.1 for ; Fri, 28 Nov 2025 04:42:31 -0800 (PST) Received: from gromero0.. ([177.139.2.175]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-55cf4e1d56asm1776930e0c.4.2025.11.28.04.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 04:42:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764333751; x=1764938551; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8EnHLBHH/9x6RQh+DJhX2515VrjyRTLJawVS+ytU3po=; b=bhhLVW3lAzqtoLuPNy1OM+dJyGy6Saz3hC38fRL2FAfxZ8sGX6hXdSjqrlrN6mwkJd cPebKEVDL7fnboCp6GdzD+cWmYM9SSxH1s2PJxVI9rAFPgklbOTqLOmUW/eP9aqh5Rzf W0DmLOVLuKlL0HrO0y+t84lXEkbygAhyQSQSzVMfMs8y/4w0CM6507mYDIyyCPo1Zk9E OMrGZqOA/XKm6uJ9V20gKbGzMF/XJWp5SIlmg+WFOgCGuZMVyMz1Tc5V4/HxsiLBKD90 yQHK1B+n0SLIwGoyNMcBlzB210DQ3ngZ7vzbjMJ9IBAZS5BTKtP7oRo3YZqSrNRao5fn 1apQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764333751; x=1764938551; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8EnHLBHH/9x6RQh+DJhX2515VrjyRTLJawVS+ytU3po=; b=BNmB/uiQlX3WnEQDDH9rTL692546D4GQrjK0OBjMguZukXSDDuJjp5r35RasMd/cF3 qv3Mj1darWzBhwGZpOzFd1U93GUTwJkFTsxWumvgQ4zGK7bbg5vQMcXZlj8XbtEAqkA3 Op25xvb/UXAjgUmg8WBJX9yno+Qjtp3tZOH9wh+lJNvK/CKyVW6Vc/rIqHDqZ7Q3P+qF 4oY8y+anp/35k+YGTvWRGqG0VYK6XCWGX8UB0qzlLchDSZCvrv18FwWZeX2Km7SS4w9c oaJVzC5XdgKDLfxAioQwG6xu0bJbfdcDTgenU+lTmBQlyum6242SL4BXmeCluIz4lPUx X6Rg== X-Gm-Message-State: AOJu0YzKSsZh1LigtseHXCHPMuP3VPTx8GbA8Xv63QnCYG+VKcOyJPSD T0y8UacVSV3qFQJAR3O4dU6wgAYxGKezvmoKsSbggsyZhOxW9LHhJw7oAmwYY+4mNT3TOGFbPoE JlphB X-Gm-Gg: ASbGncsnfbAogfqaP93wv2S8LuqPj1bQXzc5gGtimAWkna8BkrzIbe+aQ98xXeKHuGo uA06OQfyJ2QV4VZ4WMgxn+T53o5H0xU5XWNxsUhFrjuQeoXFaStDJhe4PosYM5nBxf9TbFLb+LD XK9yNjIcQEvkbZBOg28LdRt4JvCjtGpFOOawL+BW5vsnpDbBwcMl4/3InpihBO6zsqzSRbC0Wpw dQ5DvAq0ZnARO8qnPxOZ7zbcjJb/1JsXOH5n9IAxXGA5XCISQ/GVdVw/iHEoiwjorxt1ATNo7l2 VYCfoo1UyclkEa573nrfTqNoz9ImN5qqtg6BuaYg6Qd2jOkheoNG42HAs+qtIQeSORDradmD34j 02mY+NxSmFkQeiAsbVjTJsdpjs+IWIno8lrVYTSlLNac1bhptEZklZB4Pn03RrxyGKyouGeBGJh r+1O3hC3mACduIgR4= X-Google-Smtp-Source: AGHT+IE1XwJbhnwRfpKp/QmFEs/Vyr3ToUaWkjZtCzNVh3Ue+/R4Dd09aT4bwBukw92fekOy+d98rQ== X-Received: by 2002:a05:6122:2224:b0:559:7acd:1d3a with SMTP id 71dfb90a1353d-55cd755d6c6mr4455044e0c.2.1764333751255; Fri, 28 Nov 2025 04:42:31 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org, philmd@linaro.org Cc: peter.maydell@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v1 4/6] target/arm: Use new CPU address space API Date: Fri, 28 Nov 2025 12:41:08 +0000 Message-Id: <20251128124110.1272336-5-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128124110.1272336-1-gustavo.romero@linaro.org> References: <20251128124110.1272336-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a2a; envelope-from=gustavo.romero@linaro.org; helo=mail-vk1-xa2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1764333840948019200 Content-Type: text/plain; charset="utf-8" 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 --- 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, Err= or **errp) unsigned int smp_cpus =3D ms->smp.cpus; bool has_secure =3D cpu->has_el3 || arm_feature(env, ARM_FEATURE_M_SEC= URITY); =20 - /* - * We must set cs->num_ases to the final value before - * the first call to cpu_address_space_init. - */ - if (cpu->tag_memory !=3D NULL) { - cs->num_ases =3D 3 + has_secure; - } else { - cs->num_ases =3D 1 + has_secure; - } + cpu_address_space_init(cs, ARMASIdx_MAX); =20 - cpu_address_space_init(cs, ARMASIdx_NS, "cpu-memory", cs->memory); + cpu_address_space_add(cs, ARMASIdx_NS, "cpu-memory", cs->memory); =20 if (has_secure) { if (!cpu->secure_memory) { cpu->secure_memory =3D 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); } =20 if (cpu->tag_memory !=3D 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); } } --=20 2.34.1 From nobody Sat Nov 29 10:17:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1764333827; cv=none; d=zohomail.com; s=zohoarc; b=Pl7GMcCe8cOM9JefYkU76yfnARfLrNMYbB4GRWQktwbh2hOqNx8JghkN6t0TeNjD2a15HjXQdczwplpT/TBfz0vdfDYP16sWX5d4kAUotpVvhAuM/vKC7XL0JL8LfIWku8QkN2e7W39ZE2c+luQLHBv85IZr9iUEkvag/G2HrPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764333827; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=P6rMJ3udbgIpgAiy6d31R0Vx2kkWCqkcA13MTheL8sQ=; b=nFbBdrQL+jXIuu7s+pwTz0Ggp7phgbyQM0CUEP1QwX/2NOSv/3BZSadRviiTcxTr6+0z0pHPAX7fawx2ESKgiKsRGVmamj1v4/EgJrLTpig6hC+RKZHIIocmfXZU5mbV7jgCmAw4atreId8o5DtMjgbYWM4uvceAeCVnY18FLM4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764333827075423.6810524010483; Fri, 28 Nov 2025 04:43:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vOxoN-0002M9-K6; Fri, 28 Nov 2025 07:42:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vOxo5-00027Y-8M for qemu-devel@nongnu.org; Fri, 28 Nov 2025 07:42:37 -0500 Received: from mail-vk1-xa29.google.com ([2607:f8b0:4864:20::a29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vOxo3-00039C-4A for qemu-devel@nongnu.org; Fri, 28 Nov 2025 07:42:36 -0500 Received: by mail-vk1-xa29.google.com with SMTP id 71dfb90a1353d-5599b119b4aso455836e0c.0 for ; Fri, 28 Nov 2025 04:42:34 -0800 (PST) Received: from gromero0.. ([177.139.2.175]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-55cf4e1d56asm1776930e0c.4.2025.11.28.04.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 04:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764333754; x=1764938554; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P6rMJ3udbgIpgAiy6d31R0Vx2kkWCqkcA13MTheL8sQ=; b=iSOV6Y5XrC7FZfRL0QtU7751OKv8dUjthFa3epUQJ/uQ6/o643RLX5REpuEFaEmc+f RqwW3X7kE3SCyhUDo0jLfXcZ4/Xv2rJcTBVXkhe08vQS0G8AN1ZkLl2jcD9V+NgC9qix 3N9WF8HczJDp/Wql7ZYh1d4inu8EdfySQagvZRvK5zaq1MH775ZIpT6H88X1BV98KfCZ IAwBnp8wMrZ1JcdGf76K8pFUusstVcXMOD7vMlLo2nsjKNCD8Kmd2OW6Be72QzO8LA6h e9C6S18l1VKnYflHCuNrX4OFocHcVGEoLrWlq6/OUyDPbFIn2Cvb7fg4MN6OBCHmUUOk HV+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764333754; x=1764938554; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=P6rMJ3udbgIpgAiy6d31R0Vx2kkWCqkcA13MTheL8sQ=; b=n0wc4J/xJa61eb5eqBo2oVEbRl8t8L3kT7lSu68Ucx8pU2r699lLPHRev33KKTQFnm siqxdukr2qe94NNpqSwMnSd+B/huNNIonmU1nrEDDtwPCIzMzhTDK/0DD8mzTdYYc9Iz XPmkkBHdMlZ0u/xxP1KR7dxZ+REfwbbNencRBTqCRDhHtTEDQfOPrXUeQGe391EqxNYe tdmI/89vz44Cejo4xX+M1H9C3+gxOXdNk0BJ3iBM5OTjtZ/DwK1XrA0tXV7LZ7fwSYlp SWZLa55A3pDp1iCUNPwcmLV1fqspo1xRNKoslZp7BDJ5i5dE5QxHKORQDk2zuJBd1m5B ka2w== X-Gm-Message-State: AOJu0YyCksmcoXaTDSIvIdQcYQK5EMMZGKFQgjGR6UVT1rI0mAxXF/wj IfYuo9/5xxNeZRhkgq5YSfHrXFlR7h6IjD/DyUGXtOd812/2z53PhiIxWrXmFEGTIciMjkZLHKH wn6V9 X-Gm-Gg: ASbGncvx+1PUeZ2mTwn3FThoHfgY+Law0NkK9iPrKRzmCE82OwOcrqy9HlQ5e/LDJNi vlObZanOQaVBlO8x8IhQQIcRJSRvUKptT1qZaSc8ong435Fbt9yD2+4yF0Q50/kV408aTQ6oEzI KUou1BFG9wnfBMfLnnEsS3FWYBv/TZ+3DeH908mZVbXkbt8+WFf8ZZRWlhmOSknavlTnee4NRCZ 4qq0AkjQi/cROn9Y0drKzXPMEvjz4ikY7DI9Ylsu4gfgUS/ExgVBEXhUbQGeH20qQ+WVMJlCKhV QVHtZomxNTRNhXsD61n1WP2MpyPOPw2YdkSueLponKFo6FXheU5V0eZ/9gIvK+D0TTApQWjLXJ0 i42BUD8bB3rnDoq+dxGpUgcs8O1xyaKa9avsZa0lNyoG29L3CBQPV/4p4lq1oLpsdszlfk3jFd8 uD1sFBtbil7CSOl1E= X-Google-Smtp-Source: AGHT+IEsb/oawwXBRNjapEzXqc75pUgGhNNk26dnwbq0ojjBMQeG+AWSNtLm+Pm7/YeOvu/HZ3rTSA== X-Received: by 2002:a05:6122:7cc:b0:559:eef7:39f with SMTP id 71dfb90a1353d-55b8d75c040mr8547626e0c.12.1764333753723; Fri, 28 Nov 2025 04:42:33 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org, philmd@linaro.org Cc: peter.maydell@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v1 5/6] target/i386: Add a _MAX sentinel to X86ASIdx enum Date: Fri, 28 Nov 2025 12:41:09 +0000 Message-Id: <20251128124110.1272336-6-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128124110.1272336-1-gustavo.romero@linaro.org> References: <20251128124110.1272336-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a29; envelope-from=gustavo.romero@linaro.org; helo=mail-vk1-xa29.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1764333829037019201 Content-Type: text/plain; charset="utf-8" Add a sentinel to the X86ASIdx enum so it can be used when the total number of address spaces is required. Signed-off-by: Gustavo Romero --- target/i386/cpu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index cee1f692a1..783ad66d74 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2600,6 +2600,7 @@ void cpu_sync_avx_hflag(CPUX86State *env); typedef enum X86ASIdx { X86ASIdx_MEM =3D 0, X86ASIdx_SMM =3D 1, + X86ASIdx_MAX } X86ASIdx; =20 #ifndef CONFIG_USER_ONLY --=20 2.34.1 From nobody Sat Nov 29 10:17:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1764333853; cv=none; d=zohomail.com; s=zohoarc; b=gmoEROr2ZENoa6g+T3/UC/fTOCUjXcuGj7KgV68KgMpY/O685mCEjxLELvPpDj6Q0rBFrHm2JJOoAmQAZ6bDs5LjEuFR92Lide2IORtvftRpvDWkqlJgM7kz2WkrjhBZuRSlbRe87Qd3PN8hLV46h0Li43dOKmIZb+JT5ZahoVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764333853; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zOnxGpqlMZmxE2gECJcZmS8f1X72UBHCp7cH7nU2V2c=; b=joy8V9UO+sCgyofLdzBJRPErCC0spIjbTAEPLMFOU28qfvNvZEqdGp2un7VqksAHvGFqILB6vRrn7EYAkgyRDKJNnSODP7yC9E9R2SxI5WIV8NWuxhipjDoDnGgnmAc7eQl4H21gA/Fm4fmcUNpxetYGb7sBk98l80WymgSmlJk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764333853931330.87261952960034; Fri, 28 Nov 2025 04:44:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vOxoN-0002MC-Oz; Fri, 28 Nov 2025 07:42:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vOxo7-0002AV-E6 for qemu-devel@nongnu.org; Fri, 28 Nov 2025 07:42:40 -0500 Received: from mail-ua1-x936.google.com ([2607:f8b0:4864:20::936]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vOxo5-00039f-H0 for qemu-devel@nongnu.org; Fri, 28 Nov 2025 07:42:38 -0500 Received: by mail-ua1-x936.google.com with SMTP id a1e0cc1a2514c-9372a52af7eso484596241.3 for ; Fri, 28 Nov 2025 04:42:36 -0800 (PST) Received: from gromero0.. ([177.139.2.175]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-55cf4e1d56asm1776930e0c.4.2025.11.28.04.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 04:42:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764333756; x=1764938556; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zOnxGpqlMZmxE2gECJcZmS8f1X72UBHCp7cH7nU2V2c=; b=hrA5wclT1FVDwtM4aFPLrT491rK9uw76HV3gqCVxRrzdGrAd4kXE+0a0ziXtzrW07D mrfSlghsmxKJKaQSKG3JyxSpRNAZV3EuNDprLOrFG5MZJfq9XYgbdycty7A5WzrnV1Ry r73GpvL+6aKtuyl6pnzShiHLM2x7PJod/ceXHp6T+nIo/28yyfavk5d0The3ZuDsQDgU LBQ/5rxeMmfpLMc3Ovz7Pe8Rn8BXSc4YjOTMpi3kFxpWBz4+YC8KugiJyxYkYqOJg8mh oEJaL8MVxAxoL/64g+EiwUdToSf9HS2xn+k1Qzess5DiDfjLQaNAsgWVwNUH1O/Zz7HX CZow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764333756; x=1764938556; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=zOnxGpqlMZmxE2gECJcZmS8f1X72UBHCp7cH7nU2V2c=; b=i3MrjkZSlKiQ2+tWCylUzfdeNT81BFkvBTuPDPicapAe0tSA96e3ylK8BwtJXZsVHK Sk+lwct7o4ForYSI6ii4PsrqjsDyGdMeUyx4Pg3jI3KLN/3Wmve8okqRi4RrnSbplAwP c3bzWF/fhCLzYa2WtMrrZ+cFyJJgwDGMwBa/iEyaPIALak1M43KGS33+Ct1InUrL9XM3 WdhdE01F/TWcExfeS7hIMMZAQWTxPKnbMTxkvdofPIpmNTlEuYMlu+AvveUHczCoP7mv raHIc8AjZdJFQbkkXzHI7ecZtPc+BwdxLklBeifb96zrxhCuUXdftp5OKdZW5XfsPvTb M28Q== X-Gm-Message-State: AOJu0YyEcISSgs5tyGsnWukGMmUrm0o22Cq1ZLsnjwPytk8uJsQFQsY2 jQxKZYUcIc/QUhQ9U6lxZNVS6FBVLuIxgrq0jrGwe+UXIqgcys91DtGM98UK35ZmFWoMMjnWTIp eSerG X-Gm-Gg: ASbGnctsBVbdATp7axjPNONajZggVxliFmaJ2heNH6H/gmcuAew3iEyozavVEjxy2ov Gv5uhm7+iI8tnSk73uxIRyfO3d5Oc7EM7LaQoWBRHb/JbXSW6WkDXGNDTdPRtViLcvxeLs9qQps 5NmoQT0q3sUj69sECSQ/fA5pLbzpXxnhc/Sf6uLzsKgJ8CELAWrr2f+i6qgblHuUMp0VANsYq5Z 5u7E5E6nHxZmwDJ9FbRCAtAg44F944+dLokaDwcDex5gcUV2umdzPvL0uO/lJLh7Ub684ZxKd0d VSFdE77etBMFdqJYjSZChXpIN2V2Yqvj4be0Gp4BlaPrsPQ12vBh/+Zp79wVtzkCWbT7vuuQVtt kKARHZIPC3D96dKzbnQSvNYHLCfme/oTbLiRgYurEdp8oT8anWCas06EzbpWLYiAJ2DHmHu82AA 4etvLZ71EphQq7JQo= X-Google-Smtp-Source: AGHT+IE/GUTosPwJTPVKplxZbX7N85n6XkeIfrYjoX4owl4pUjdsju0IX+w6UxjHEunloqf77eKthA== X-Received: by 2002:a05:6122:4886:b0:55b:305b:4e48 with SMTP id 71dfb90a1353d-55b8d7ca793mr9424172e0c.20.1764333756182; Fri, 28 Nov 2025 04:42:36 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org, philmd@linaro.org Cc: peter.maydell@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v1 6/6] target/i386: Use new CPU address space API Date: Fri, 28 Nov 2025 12:41:10 +0000 Message-Id: <20251128124110.1272336-7-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128124110.1272336-1-gustavo.romero@linaro.org> References: <20251128124110.1272336-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::936; envelope-from=gustavo.romero@linaro.org; helo=mail-ua1-x936.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1764333855070019200 Content-Type: text/plain; charset="utf-8" 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 --- target/i386/kvm/kvm-cpu.c | 4 ++-- target/i386/kvm/kvm.c | 4 ++-- target/i386/tcg/system/tcg-cpu.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 9c25b55839..9b7364f1c6 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -98,8 +98,8 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp) * Only initialize address space 0 here, the second one for SMM is * initialized at register_smram_listener() after machine init done. */ - cs->num_ases =3D x86_machine_is_smm_enabled(X86_MACHINE(current_machin= e)) ? 2 : 1; - cpu_address_space_init(cs, X86ASIdx_MEM, "cpu-memory", cs->memory); + cpu_address_space_init(cs, X86ASIdx_MAX); + cpu_address_space_add(cs, X86ASIdx_MEM, "cpu-memory", cs->memory); =20 return true; } diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 60c7981138..dcc7e5eeae 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2744,14 +2744,14 @@ static void register_smram_listener(Notifier *n, vo= id *unused) &smram_address_space, X86ASIdx_SMM, "kvm-= smram"); =20 CPU_FOREACH(cpu) { - cpu_address_space_init(cpu, X86ASIdx_SMM, "cpu-smm", &smram_as_roo= t); + cpu_address_space_add(cpu, X86ASIdx_SMM, "cpu-smm", &smram_as_root= ); } } =20 /* It should only be called in cpu's hotplug callback */ void kvm_smm_cpu_address_space_init(X86CPU *cpu) { - cpu_address_space_init(CPU(cpu), X86ASIdx_SMM, "cpu-smm", &smram_as_ro= ot); + cpu_address_space_add(CPU(cpu), X86ASIdx_SMM, "cpu-smm", &smram_as_roo= t); } =20 static void *kvm_msr_energy_thread(void *data) diff --git a/target/i386/tcg/system/tcg-cpu.c b/target/i386/tcg/system/tcg-= cpu.c index 7255862c24..ab72c5ff7b 100644 --- a/target/i386/tcg/system/tcg-cpu.c +++ b/target/i386/tcg/system/tcg-cpu.c @@ -73,9 +73,9 @@ bool tcg_cpu_realizefn(CPUState *cs, Error **errp) memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, cpu->cpu_as_m= em, 0); memory_region_set_enabled(cpu->cpu_as_mem, true); =20 - cs->num_ases =3D 2; - cpu_address_space_init(cs, X86ASIdx_MEM, "cpu-memory", cs->memory); - cpu_address_space_init(cs, X86ASIdx_SMM, "cpu-smm", cpu->cpu_as_root); + 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); =20 /* ... SMRAM with higher priority, linked from /machine/smram. */ cpu->machine_done.notify =3D tcg_cpu_machine_done; --=20 2.34.1