From nobody Sat Nov 15 10:38:43 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=1754178309; cv=none; d=zohomail.com; s=zohoarc; b=Cl1RkwD0l+4jb/stZZhmK+LmzGZ9TFeVoKwCi8wTwBnIYa518VIT8s/iGbKJzEePVwkgDw/uB85/RvhQyNovir4wfa+wenSHCoHEm9G3T+ZLtnR54m/XoCAW7omD55tU0A6uV+epkmcJ1iqHR0ir6hwfnVJxR+9BaIRMtVYB2GQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754178309; 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=1d9dQVqrNWqrEXWej/JwzyJrCDkscWOsMBodTniFYpE=; b=VKgc3OKtBpktxprddb/dt8tBlBmF1zQQIq0X/CAkLhVHvQhOyAVv3N13t5tQsTkQ1CSKbAMwktApfO/huo7noQ0SVLNpanm1KcoZ7A8Ja0Y4UgMhI0fZNARnVYxQxHk2P/VLiLYKlzs3sYy9YvscgJJNuzaqdAWvmB9py+pijzU= 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 1754178309305963.6230025964162; Sat, 2 Aug 2025 16:45:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uiLjm-0005L6-F1; Sat, 02 Aug 2025 19:34:02 -0400 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 1uiLi1-0000XE-JR for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:13 -0400 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uiLhz-00059I-KF for qemu-devel@nongnu.org; Sat, 02 Aug 2025 19:32:13 -0400 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-741a0ec1a05so314974a34.2 for ; Sat, 02 Aug 2025 16:32:11 -0700 (PDT) Received: from stoup.. ([172.58.111.133]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-30b8e3c9b32sm71031fac.24.2025.08.02.16.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1754177530; x=1754782330; 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=1d9dQVqrNWqrEXWej/JwzyJrCDkscWOsMBodTniFYpE=; b=oIyUWgZzkuy2d9Vt4lH7cY47dld5bwbnWIzvC1V4GFFFy9si6dXqSXmop8j/Anzp9T 25akouLFLthqxIKUUb8GjM1EsnT+c+FcEr9bNML4MQcvdWq64lQwwV3593H/+B2oIRU2 7f84bjUU/1QAkZ7pv1wLA/sxv/F2zsXHsuMwnLwNZJVRzPc57oJgyQwDSt63LpGK5oWD MPiborCptozRYMwVm/xCG0iapHHOlVgkabAX+BO7Xmx20MhtpWh25FWnvzpu9YqB518q AckrN/YDntEs1so9WkGVhVTt+OYhzgv38NnbfiPU9fAitY0fAdsyYkOH6wcFuIcxntvI T9pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754177530; x=1754782330; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1d9dQVqrNWqrEXWej/JwzyJrCDkscWOsMBodTniFYpE=; b=WbaAhrMa8Rmyo/eO3/h+AFtaTx4zLhr8ch8BtIX6qSXBeMuWwTrqHNpBGv4iA7/cyE aen8UFBn4j9rvXshSt2hugtPZCz7qqzK4yJX/4Y6LRVleA47RvGuLNYM7yQ77hWg4mZt SFYlpTgI1hV881ehCUVzOIeNYOQsLE5EU+Ksup8IcZgcjUZ0vnMDvKiiJnzMWyrsWtrD GurJ1jCifWeIkRQXK0SoyIyt2zNWwI976TeXC40Z8uc/zbN04kn90YYBNOLSukyzgZ4o TETe5nSwPP6J9LD51jsMka5QKzzSk8IX6CdODVoWBWg0cuTUzzLCeJ9OsZLwsLgrrule qgyA== X-Gm-Message-State: AOJu0YzMSN3bsWUAnRi5sE5YUz9MO2My0lXdDP//sLiI5kCBrS8o+V2G TknJTzTNROdMAaVkTpkShVrhLRhyWyRPOckVBE1sknQWhFk2ShpvVpNTbzxrTBWh+jF9tw1vors 5u/ZiZNc= X-Gm-Gg: ASbGncu/A56jcmYNb5Fig+UpnAP66phW4tMEVqE6v9VAU+/sEM7BXqyb2Bso3jiIq2s g5uOY6Dxt2mJu6OB7WnJhCxGc/TyY/Akg+hmBurPG+tAZbhEMdtffIPmzeeiuoIBxanLQ0a8q5O J5ddq4QqHSvu4o7Qc9zRtgC+72yBuSH2FRRR0aJREtb1rCsXEqq3P7gRYcNPCORPGPOb9vO3GPF FgRmCVaBymnhgDtScxRl5MNsG889tAalKyjZFmlxHztWnS22vAb2fuS2Kj05ge5jrmoMdjpmlr3 fOTf+w4VBBe8EnKhYpe27Gk+v4SG81+ICeNxC7HXh8iqWRZppBi+W3c+FPclFg+b8cvmv8hrRlp 9j/0qD5ln/Rv3PWyYKLFXIEVAiTNI5WSo03mrA0Bwy0TTeN11q86Z X-Google-Smtp-Source: AGHT+IHgcPZ5Lzyeh1ys/R0BlrxMmuQonLdotkK3Mu5rKHzjSEd9UKKV2Vae2U+3ukwyRWoOd1spHA== X-Received: by 2002:a05:6871:4519:b0:308:51fe:ea07 with SMTP id 586e51a60fabf-30b67558bf1mr2385170fac.1.1754177530420; Sat, 02 Aug 2025 16:32:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Pierrick Bouvier Subject: [PATCH v2 27/85] include/hw/core/cpu: Introduce cpu_tlb_fast Date: Sun, 3 Aug 2025 09:28:55 +1000 Message-ID: <20250802232953.413294-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250802232953.413294-1-richard.henderson@linaro.org> References: <20250802232953.413294-1-richard.henderson@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::331; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x331.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: 1754178310137116600 Content-Type: text/plain; charset="utf-8" Encapsulate access to cpu->neg.tlb.f[] in a function. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/core/cpu.h | 7 +++++++ accel/tcg/cputlb.c | 16 ++++++++-------- tcg/aarch64/tcg-target.c.inc | 2 +- tcg/arm/tcg-target.c.inc | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 1153cadb70..bd835b07d5 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -593,6 +593,13 @@ static inline CPUArchState *cpu_env(CPUState *cpu) return (CPUArchState *)(cpu + 1); } =20 +#ifdef CONFIG_TCG +static inline CPUTLBDescFast *cpu_tlb_fast(CPUState *cpu, int mmu_idx) +{ + return &cpu->neg.tlb.f[mmu_idx]; +} +#endif + typedef QTAILQ_HEAD(CPUTailQ, CPUState) CPUTailQ; extern CPUTailQ cpus_queue; =20 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index d324f33339..2a6aa01c57 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -129,7 +129,7 @@ static inline uint64_t tlb_addr_write(const CPUTLBEntry= *entry) static inline uintptr_t tlb_index(CPUState *cpu, uintptr_t mmu_idx, vaddr addr) { - uintptr_t size_mask =3D cpu->neg.tlb.f[mmu_idx].mask >> CPU_TLB_ENTRY_= BITS; + uintptr_t size_mask =3D cpu_tlb_fast(cpu, mmu_idx)->mask >> CPU_TLB_EN= TRY_BITS; =20 return (addr >> TARGET_PAGE_BITS) & size_mask; } @@ -138,7 +138,7 @@ static inline uintptr_t tlb_index(CPUState *cpu, uintpt= r_t mmu_idx, static inline CPUTLBEntry *tlb_entry(CPUState *cpu, uintptr_t mmu_idx, vaddr addr) { - return &cpu->neg.tlb.f[mmu_idx].table[tlb_index(cpu, mmu_idx, addr)]; + return &cpu_tlb_fast(cpu, mmu_idx)->table[tlb_index(cpu, mmu_idx, addr= )]; } =20 static void tlb_window_reset(CPUTLBDesc *desc, int64_t ns, @@ -292,7 +292,7 @@ static void tlb_flush_one_mmuidx_locked(CPUState *cpu, = int mmu_idx, int64_t now) { CPUTLBDesc *desc =3D &cpu->neg.tlb.d[mmu_idx]; - CPUTLBDescFast *fast =3D &cpu->neg.tlb.f[mmu_idx]; + CPUTLBDescFast *fast =3D cpu_tlb_fast(cpu, mmu_idx); =20 tlb_mmu_resize_locked(desc, fast, now); tlb_mmu_flush_locked(desc, fast); @@ -331,7 +331,7 @@ void tlb_init(CPUState *cpu) cpu->neg.tlb.c.dirty =3D 0; =20 for (i =3D 0; i < NB_MMU_MODES; i++) { - tlb_mmu_init(&cpu->neg.tlb.d[i], &cpu->neg.tlb.f[i], now); + tlb_mmu_init(&cpu->neg.tlb.d[i], cpu_tlb_fast(cpu, i), now); } } =20 @@ -342,7 +342,7 @@ void tlb_destroy(CPUState *cpu) qemu_spin_destroy(&cpu->neg.tlb.c.lock); for (i =3D 0; i < NB_MMU_MODES; i++) { CPUTLBDesc *desc =3D &cpu->neg.tlb.d[i]; - CPUTLBDescFast *fast =3D &cpu->neg.tlb.f[i]; + CPUTLBDescFast *fast =3D cpu_tlb_fast(cpu, i); =20 g_free(fast->table); g_free(desc->fulltlb); @@ -667,7 +667,7 @@ static void tlb_flush_range_locked(CPUState *cpu, int m= idx, unsigned bits) { CPUTLBDesc *d =3D &cpu->neg.tlb.d[midx]; - CPUTLBDescFast *f =3D &cpu->neg.tlb.f[midx]; + CPUTLBDescFast *f =3D cpu_tlb_fast(cpu, midx); vaddr mask =3D MAKE_64BIT_MASK(0, bits); =20 /* @@ -923,7 +923,7 @@ void tlb_reset_dirty(CPUState *cpu, uintptr_t start, ui= ntptr_t length) qemu_spin_lock(&cpu->neg.tlb.c.lock); for (mmu_idx =3D 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { CPUTLBDesc *desc =3D &cpu->neg.tlb.d[mmu_idx]; - CPUTLBDescFast *fast =3D &cpu->neg.tlb.f[mmu_idx]; + CPUTLBDescFast *fast =3D cpu_tlb_fast(cpu, mmu_idx); unsigned int n =3D tlb_n_entries(fast); unsigned int i; =20 @@ -1316,7 +1316,7 @@ static bool victim_tlb_hit(CPUState *cpu, size_t mmu_= idx, size_t index, =20 if (cmp =3D=3D page) { /* Found entry in victim tlb, swap tlb and iotlb. */ - CPUTLBEntry tmptlb, *tlb =3D &cpu->neg.tlb.f[mmu_idx].table[in= dex]; + CPUTLBEntry tmptlb, *tlb =3D &cpu_tlb_fast(cpu, mmu_idx)->tabl= e[index]; =20 qemu_spin_lock(&cpu->neg.tlb.c.lock); copy_tlb_helper_locked(&tmptlb, tlb); diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 3b088b7bd9..caf79c742d 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1668,7 +1668,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext= *s, HostAddress *h, ldst->oi =3D oi; ldst->addr_reg =3D addr_reg; =20 - /* Load cpu->neg.tlb.f[mmu_idx].{mask,table} into {tmp0,tmp1}. */ + /* Load CPUTLBDescFast.{mask,table} into {tmp0,tmp1}. */ QEMU_BUILD_BUG_ON(offsetof(CPUTLBDescFast, mask) !=3D 0); QEMU_BUILD_BUG_ON(offsetof(CPUTLBDescFast, table) !=3D 8); tcg_out_insn(s, 3314, LDP, TCG_REG_TMP0, TCG_REG_TMP1, TCG_AREG0, diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 836894b16a..4069508272 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1420,7 +1420,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext= *s, HostAddress *h, ldst->oi =3D oi; ldst->addr_reg =3D addr; =20 - /* Load cpu->neg.tlb.f[mmu_idx].{mask,table} into {r0,r1}. */ + /* Load CPUTLBDescFast.{mask,table} into {r0,r1}. */ QEMU_BUILD_BUG_ON(offsetof(CPUTLBDescFast, mask) !=3D 0); QEMU_BUILD_BUG_ON(offsetof(CPUTLBDescFast, table) !=3D 4); tcg_out_ldrd_8(s, COND_AL, TCG_REG_R0, TCG_AREG0, fast_off); --=20 2.43.0