From nobody Tue Dec 24 12:50:24 2024 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=1734711629; cv=none; d=zohomail.com; s=zohoarc; b=LGg/+ysu+Mef9w6qJuz0qKCkVs1aWhUbDM3l0+3BB9oL3Zf632SOyB5JbBnLTvQ/KWHkjWGO6x5iUfdf5Vf3y16qrScQWv+Cb92SI85FwzX75fK3w3Ha7PLNA9VwMS7vX89gHC6Ars4DtsDlNujHcD8W3GLROOyItmz/sFSDdL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734711629; 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=zb712QFkXMyJHgZrNJU9p7a0+PEvQntNQaexSv2HpdI=; b=aEt+/24nPuLYXjvB/OIXDWCd1696laH7qRGEYyZvt+YaymKFxoWWVh2gaKOP/lnaCVbg2r3qZ8v4iOKe2EnsoPXYGIRVwcoEZkjWUDw+vY/q0Fi/gxs0XLfEWzTLIqU4IRzKmYek7GvB7jw1mYjD1AmnKLmKKQG62k0oHoDUwps= 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 1734711629904324.24403795826777; Fri, 20 Dec 2024 08:20:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOfjS-0005ga-GM; Fri, 20 Dec 2024 11:20:07 -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 1tOfjB-00059Q-7Y for qemu-devel@nongnu.org; Fri, 20 Dec 2024 11:19:50 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOfj9-0008JC-Bs for qemu-devel@nongnu.org; Fri, 20 Dec 2024 11:19:48 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-388cae9eb9fso1272342f8f.3 for ; Fri, 20 Dec 2024 08:19:46 -0800 (PST) Received: from localhost.localdomain ([78.196.4.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c847214sm4381767f8f.46.2024.12.20.08.19.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Dec 2024 08:19:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734711585; x=1735316385; 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=zb712QFkXMyJHgZrNJU9p7a0+PEvQntNQaexSv2HpdI=; b=lRoe73xI8DHMozFx1aDv5Xa1/Q099ipHIb0EcdPK8yY4tUb7BcFuJHTDuujZEQOAo1 f6ZTiDF5/2qXeqk9xvDACfrMO71VGVkRDoeeauVi+/b743xZ97MG2nPCdiXRTPU+ozPt A/CZfnb0sHVpd25Z1uIphWlh6mhx+SdZCHWx+2hCnENv7j8hy5+IRBO06/0VF0ie5Neo dHwYUnL5enRcMy4DwSFrobKOhc5g5sLGXRpRHmtYf75XuteMNNVJwdE2quZoO3rYq2hO FELX0ExQMKdO6S0WJ9LdnDPbg4/3pCfRgnL8nrruYM4LYo22caat21ySj129WwW/dgLH hBoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734711585; x=1735316385; 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=zb712QFkXMyJHgZrNJU9p7a0+PEvQntNQaexSv2HpdI=; b=hkmODOG/PCfHPTi0+GnHC1AkW9wvG2cEmLmWUiYQpIKOGotziGAiJnkGFq62JyrwTh sAxxfTdTxdmxzJKU7KCr8dVKcXytfL6w7DPvt8GMhn4qLz0Q4NWZhvAmGjhdmHSWVPxV hXOeL+ArOwgC7OOt8AslqW0RLDIRN1Ylby4e3oluKeaTR1GztQW5ogJ6yvtm1i9+5DTi pfPl7Zy/iWDpyXFOP3ulTRImlEcR2E6KiuvO4HoaCwfUsz68hdGbKrmXe6AcDXJ8CswQ C8D1aNgv8KGHpW0gd8CXiMsah9De1AHxoZiUxzO8qRVQnTda9K7AvH+0tbfOmoocxYHx 9wUQ== X-Gm-Message-State: AOJu0YzBxfIGMILIoPzET7VECKmHjChjHWOxGPBFSsxtQTrCvDSOZuSd 8rYg5mKMSFJRhQOYPv1TNgmG/CoeB/EskKEVbhMe1N00RuDAXlZhJY5BPbUSaElxi2YGudVbvil f X-Gm-Gg: ASbGncttEJkKy8KgNtUGE8m1FcUR4cJH7wuzKV8cl+JSsjx4iLbzlGit/mkebZM3RVs /tW+abulICsvhd+YjuPP4MnbWpvhTzrrNS3191v2jAsy+ZwBSpyiFT30dbXy99X+4Lv4Hh+q4Pc MdIWdJutvZW3VHM8wrOkvtM+WjTuNYpijqJODi0tqEr/3dq/W7x8KMrNHAquIUhm3Z69bfk7XSG Y843E/W33tQL7skWNAlFUffUCj6S+OCi0uFTcr5jjQ+cIHc8xOCeVYf63rHTN9WQLYFms3HpK0= X-Google-Smtp-Source: AGHT+IE8+2zwMUgwsM0oDS5BETlQG+MfVNhu19iXa6IvhASczAjr9OZeYXdKka+gKotCcHl2W+cQHA== X-Received: by 2002:adf:8b11:0:b0:38a:2628:2e90 with SMTP id ffacd0b85a97d-38a26282ed0mr225996f8f.2.1734711585499; Fri, 20 Dec 2024 08:19:45 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 51/59] accel/tcg: Un-inline translator_is_same_page() Date: Fri, 20 Dec 2024 17:15:42 +0100 Message-ID: <20241220161551.89317-52-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241220161551.89317-1-philmd@linaro.org> References: <20241220161551.89317-1-philmd@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=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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: 1734711631785116600 Remove the single target-specific definition used in "exec/translator.h" (TARGET_PAGE_MASK) by un-inlining is_same_page(). Rename the method as translator_is_same_page() and improve its documentation. Use it in translator_use_goto_tb(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20241218154145.71353-1-philmd@linaro.org> --- include/exec/translator.h | 15 +++++++-------- accel/tcg/translator.c | 7 ++++++- target/i386/tcg/translate.c | 6 +++--- target/riscv/translate.c | 4 ++-- target/s390x/tcg/translate.c | 4 ++-- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/include/exec/translator.h b/include/exec/translator.h index d8dcb77b5f4..41e2a41180f 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -267,16 +267,15 @@ bool translator_st(const DisasContextBase *db, void *= dest, */ size_t translator_st_len(const DisasContextBase *db); =20 -#ifdef COMPILING_PER_TARGET -/* - * Return whether addr is on the same page as where disassembly started. +/** + * translator_is_same_page + * @db: disassembly context + * @addr: virtual address within TB + * + * Return whether @addr is on the same page as where disassembly started. * Translators can use this to enforce the rule that only single-insn * translation blocks are allowed to cross page boundaries. */ -static inline bool is_same_page(const DisasContextBase *db, vaddr addr) -{ - return ((addr ^ db->pc_first) & TARGET_PAGE_MASK) =3D=3D 0; -} -#endif +bool translator_is_same_page(const DisasContextBase *db, vaddr addr); =20 #endif /* EXEC__TRANSLATOR_H */ diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index ce5eae4349e..ef1538b4fcd 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -104,6 +104,11 @@ static void gen_tb_end(const TranslationBlock *tb, uin= t32_t cflags, } } =20 +bool translator_is_same_page(const DisasContextBase *db, vaddr addr) +{ + return ((addr ^ db->pc_first) & TARGET_PAGE_MASK) =3D=3D 0; +} + bool translator_use_goto_tb(DisasContextBase *db, vaddr dest) { /* Suppress goto_tb if requested. */ @@ -112,7 +117,7 @@ bool translator_use_goto_tb(DisasContextBase *db, vaddr= dest) } =20 /* Check for the dest on the same page as the start of the TB. */ - return ((db->pc_first ^ dest) & TARGET_PAGE_MASK) =3D=3D 0; + return translator_is_same_page(db, dest); } =20 void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 57e83873934..903553dc88e 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -1512,7 +1512,7 @@ static uint64_t advance_pc(CPUX86State *env, DisasCon= text *s, int num_bytes) =20 /* This is a subsequent insn that crosses a page boundary. */ if (s->base.num_insns > 1 && - !is_same_page(&s->base, s->pc + num_bytes - 1)) { + !translator_is_same_page(&s->base, s->pc + num_bytes - 1)) { siglongjmp(s->jmpbuf, 2); } =20 @@ -2226,7 +2226,7 @@ static void gen_jmp_rel(DisasContext *s, MemOp ot, in= t diff, int tb_num) * no extra masking to apply (data16 branch in code32, see above), * then we have also proven that the addition does not wrap. */ - if (!use_goto_tb || !is_same_page(&s->base, new_pc)) { + if (!use_goto_tb || !translator_is_same_page(&s->base, new_pc)) { tcg_gen_andi_tl(cpu_eip, cpu_eip, mask); use_goto_tb =3D false; } @@ -3763,7 +3763,7 @@ static void i386_tr_translate_insn(DisasContextBase *= dcbase, CPUState *cpu) * chance to happen. */ dc->base.is_jmp =3D DISAS_EOB_NEXT; - } else if (!is_same_page(&dc->base, dc->base.pc_next)) { + } else if (!translator_is_same_page(&dc->base, dc->base.pc_next)) { dc->base.is_jmp =3D DISAS_TOO_MANY; } } diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 5fedde363f7..a76f67c5dd0 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1305,7 +1305,7 @@ static void riscv_tr_translate_insn(DisasContextBase = *dcbase, CPUState *cpu) =20 /* Only the first insn within a TB is allowed to cross a page boundary= . */ if (ctx->base.is_jmp =3D=3D DISAS_NEXT) { - if (ctx->itrigger || !is_same_page(&ctx->base, ctx->base.pc_next))= { + if (ctx->itrigger || !translator_is_same_page(&ctx->base, ctx->bas= e.pc_next)) { ctx->base.is_jmp =3D DISAS_TOO_MANY; } else { unsigned page_ofs =3D ctx->base.pc_next & ~TARGET_PAGE_MASK; @@ -1315,7 +1315,7 @@ static void riscv_tr_translate_insn(DisasContextBase = *dcbase, CPUState *cpu) translator_lduw(env, &ctx->base, ctx->base.pc_next); int len =3D insn_len(next_insn); =20 - if (!is_same_page(&ctx->base, ctx->base.pc_next + len - 1)= ) { + if (!translator_is_same_page(&ctx->base, ctx->base.pc_next= + len - 1)) { ctx->base.is_jmp =3D DISAS_TOO_MANY; } } diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index e78815c4f7f..81554f2ad9d 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -6423,8 +6423,8 @@ static void s390x_tr_translate_insn(DisasContextBase = *dcbase, CPUState *cs) dc->base.is_jmp =3D translate_one(env, dc); if (dc->base.is_jmp =3D=3D DISAS_NEXT) { if (dc->ex_value || - !is_same_page(dcbase, dc->base.pc_next) || - !is_same_page(dcbase, get_next_pc(env, dc, dc->base.pc_next)))= { + !translator_is_same_page(dcbase, dc->base.pc_next) || + !translator_is_same_page(dcbase, get_next_pc(env, dc, dc->base= .pc_next))) { dc->base.is_jmp =3D DISAS_TOO_MANY; } } --=20 2.47.1