From nobody Tue Feb 10 23:36:03 2026 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1660684150; cv=none; d=zohomail.com; s=zohoarc; b=ModEgygEBYkLgctoXAYXagGQLQBBU9AlrJa/MPUVkB7WnVWPsoDg6aMW4sEJ9ulrusku/ehlTOMrGLikE2F1OKgJKvaFY2tPTJfuxjs/Th5UkemRLA8RKds3wI/bPoPi6lCcKEMQ2zeRisliKQqXT4jUd7dmungP1Z/Pimuc5vQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660684150; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XGYmwpgiZPY1AsTDknzkrjEzLYeuV4sGoEw7odttBvA=; b=lQX6nJMvMEmihogi87Ek/JxeOl6tbmAyPn3ydLV/YcozvfdEi+IoiZe6+McgVqUFvKt3YxhbUPgp+zmwSe6VXmdjpNFnFRisKRbmQfVkZgVpQT/slGSj6glVEumWzIlMTv4XC02srSX2vfyMxOLb3+0UplPEnCEmmRl6+nU1NWg= 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+importer2=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 1660684150498603.9985042852904; Tue, 16 Aug 2022 14:09:10 -0700 (PDT) Received: from localhost ([::1]:33254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oO3oD-0007CD-C6 for importer2@patchew.org; Tue, 16 Aug 2022 17:09:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oO3H7-00057c-7M for qemu-devel@nongnu.org; Tue, 16 Aug 2022 16:34:58 -0400 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]:36416) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oO3H1-0004WL-UP for qemu-devel@nongnu.org; Tue, 16 Aug 2022 16:34:56 -0400 Received: by mail-oi1-x233.google.com with SMTP id s199so13320253oie.3 for ; Tue, 16 Aug 2022 13:34:51 -0700 (PDT) Received: from stoup.. ([2605:ef80:80f6:61fa:9bc2:5095:d612:5e22]) by smtp.gmail.com with ESMTPSA id y23-20020a056870b01700b0010ef8ccde67sm2285220oae.13.2022.08.16.13.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 13:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=XGYmwpgiZPY1AsTDknzkrjEzLYeuV4sGoEw7odttBvA=; b=UnMscL2tGHKxQ8TdC8xytlcZW/r7PhcnXy3TItnrZ47TsrTywSvBINJs52001Zqgq8 iXEVGm3hy1Wpt9zLgfyEY9E9yCU4wQlALd9D98sB6lyK9lxw8PMuKE+zfYUbQFyilMxi IOrXGV6MQCo1jUm39K+9nv9gQvXz14aa40zy3SwAQX4m5qzeMh8UmoRdp4rWQ7fIT+le vMdpjMw0sdcz1xz40XVtLDShRKru6Vv1wNSbKwGjwg3Cz0sHQacu+U3rPA151E9hmUr5 6BM32PQU2xnP6rC29ml7MAntrAjfjl2npY/PMXunwp+d9E8f9cdItfLw0XIC6rHSynxA ISMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=XGYmwpgiZPY1AsTDknzkrjEzLYeuV4sGoEw7odttBvA=; b=LqfWxNa3zaG7/ZhgNj96/LUMpmtw4NwHD77ez/O7tfDTvdj56Wa4jq4O6lPwajXCoV 9IPN9+Bzd7LXVbSGaFzIe/1TKEU7eiK7NsqYmnk3zhexAyh2bhmNvKA0wOJhImadNjjt bnsK1/BSIQROsCPEc273dsKRJfPSJOI2AzMABFfGhVXvCVW8FrFmsmsHPhV8v9olEWuP sA3BBrAoNr+4soBpnFriqbT1YI8jx5QT51bWrfa1M1CRx27b+0CFKT/Vj2iKWkh5MEgA Wh7kTgrpUrjil2ifosT/7YFp/n/CiNUzoQORWnedyj00BaJ4zurX4xTGoco3bEJT0ioW ahHg== X-Gm-Message-State: ACgBeo29mE4ylK6LrXkHmEWKupw6y+2CCGq4w9Ewn5A06r3P3I/PFs1S 9J0suGLQ1bq9VEwAq0pgYFTxresYuyUUcw== X-Google-Smtp-Source: AA6agR6s97iDZIwbLXL0lTAIkThy/SaWhzJUMzNdpbk2b7z0VDZgeeU4slgUEHl9QFY0DUdmH5G9Hw== X-Received: by 2002:a05:6808:23ca:b0:344:be60:144d with SMTP id bq10-20020a05680823ca00b00344be60144dmr154235oib.38.1660682091126; Tue, 16 Aug 2022 13:34:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, alex.bennee@linaro.org, iii@linux.ibm.com Subject: [PATCH v2 21/33] include/hw/core: Create struct CPUJumpCache Date: Tue, 16 Aug 2022 15:33:48 -0500 Message-Id: <20220816203400.161187-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816203400.161187-1-richard.henderson@linaro.org> References: <20220816203400.161187-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::233; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x233.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1660684151942100001 Content-Type: text/plain; charset="utf-8" Wrap the bare TranslationBlock pointer into a structure. Signed-off-by: Richard Henderson --- include/hw/core/cpu.h | 8 ++++++-- accel/tcg/cpu-exec.c | 9 ++++++--- accel/tcg/cputlb.c | 2 +- accel/tcg/translate-all.c | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 500503da13..8edef14199 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -233,6 +233,10 @@ struct hvf_vcpu_state; #define TB_JMP_CACHE_BITS 12 #define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) =20 +typedef struct { + TranslationBlock *tb; +} CPUJumpCache; + /* work queue */ =20 /* The union type allows passing of 64 bit target pointers on 32 bit @@ -362,7 +366,7 @@ struct CPUState { IcountDecr *icount_decr_ptr; =20 /* Accessed in parallel; all accesses must be atomic */ - TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; + CPUJumpCache tb_jmp_cache[TB_JMP_CACHE_SIZE]; =20 struct GDBRegisterState *gdb_regs; int gdb_num_regs; @@ -453,7 +457,7 @@ static inline void cpu_tb_jmp_cache_clear(CPUState *cpu) unsigned int i; =20 for (i =3D 0; i < TB_JMP_CACHE_SIZE; i++) { - qatomic_set(&cpu->tb_jmp_cache[i], NULL); + qatomic_set(&cpu->tb_jmp_cache[i].tb, NULL); } } =20 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index b1fd962718..3f8e4bbbc8 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -243,7 +243,7 @@ static inline TranslationBlock *tb_lookup(CPUState *cpu= , target_ulong pc, tcg_debug_assert(!(cflags & CF_INVALID)); =20 hash =3D tb_jmp_cache_hash_func(pc); - tb =3D qatomic_rcu_read(&cpu->tb_jmp_cache[hash]); + tb =3D qatomic_rcu_read(&cpu->tb_jmp_cache[hash].tb); =20 if (likely(tb && tb->pc =3D=3D pc && @@ -257,7 +257,7 @@ static inline TranslationBlock *tb_lookup(CPUState *cpu= , target_ulong pc, if (tb =3D=3D NULL) { return NULL; } - qatomic_set(&cpu->tb_jmp_cache[hash], tb); + qatomic_set(&cpu->tb_jmp_cache[hash].tb, tb); return tb; } =20 @@ -978,6 +978,8 @@ int cpu_exec(CPUState *cpu) =20 tb =3D tb_lookup(cpu, pc, cs_base, flags, cflags); if (tb =3D=3D NULL) { + uint32_t h; + mmap_lock(); tb =3D tb_gen_code(cpu, pc, cs_base, flags, cflags); mmap_unlock(); @@ -985,7 +987,8 @@ int cpu_exec(CPUState *cpu) * We add the TB in the virtual pc hash table * for the fast lookup */ - qatomic_set(&cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)]= , tb); + h =3D tb_jmp_cache_hash_func(pc); + qatomic_set(&cpu->tb_jmp_cache[h].tb, tb); } =20 #ifndef CONFIG_USER_ONLY diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 8b81b07b79..a8afe1ab9f 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -103,7 +103,7 @@ static void tb_jmp_cache_clear_page(CPUState *cpu, targ= et_ulong page_addr) unsigned int i, i0 =3D tb_jmp_cache_hash_page(page_addr); =20 for (i =3D 0; i < TB_JMP_PAGE_SIZE; i++) { - qatomic_set(&cpu->tb_jmp_cache[i0 + i], NULL); + qatomic_set(&cpu->tb_jmp_cache[i0 + i].tb, NULL); } } =20 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 20f00f4335..c2745f14a6 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1187,8 +1187,8 @@ static void do_tb_phys_invalidate(TranslationBlock *t= b, bool rm_from_page_list) /* remove the TB from the hash list */ h =3D tb_jmp_cache_hash_func(tb->pc); CPU_FOREACH(cpu) { - if (qatomic_read(&cpu->tb_jmp_cache[h]) =3D=3D tb) { - qatomic_set(&cpu->tb_jmp_cache[h], NULL); + if (qatomic_read(&cpu->tb_jmp_cache[h].tb) =3D=3D tb) { + qatomic_set(&cpu->tb_jmp_cache[h].tb, NULL); } } =20 --=20 2.34.1