From patchwork Fri Dec 20 16:15:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 852421 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp2146180wrq; Fri, 20 Dec 2024 08:20:30 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUrBxf9yrXK0OewB/5bGNqpjdN7yEFXQu2cTUCpBsDurl0FshXbeZj+EYfflOPGPPJxlWvi1g==@linaro.org X-Google-Smtp-Source: AGHT+IH4xHR8Q6ZzyDDZdd2a/OovQ1xpj0NIJRJDiqywPjsHwLNVATu1IUVABC/bon0nYQ6hpXUB X-Received: by 2002:a05:620a:240d:b0:7b6:eb12:d732 with SMTP id af79cd13be357-7b9ba83f593mr654344485a.61.1734711629926; Fri, 20 Dec 2024 08:20:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734711629; cv=none; d=google.com; s=arc-20240605; b=RIsmlXzWPFblCuKyb/0vpWdiRiaXNd+18z60qCYmjCZvC6mfdIWXJJOnZS7P2UTNwt lROzCNyoSikyY7Z1yoYV9D7mut4KfimtnW98tgbasYN4W+pu6ufEz8B9l8UlS/OBvwAY 1ciUo18FOhULuFZXan/qIujapR3nRiUC4yy7IbmfowAfRSstPPbNCwAqf9x5z0KQXRjX LYl8parZ8K7k9Ls9aM5PFDLnfF2vM0thz8C9FyjjWN4zjTlJIkWpV3hF6bk310rk5VV/ Mh1nSFY+vqzlIDAqehWWH19K//DCZPX2v28W0PRXK+5AhmsaKlQ2I1olWhTGseC9pZ+D DtnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zb712QFkXMyJHgZrNJU9p7a0+PEvQntNQaexSv2HpdI=; fh=qtn8prgQtzf5IzCNvLChUZDElvNECP6ej9YfjQeBz3I=; b=LrxpMguphu7CFkOUnVVeqygPSNODfQDKZTIWhtPYRv11lVZPiC7OYjltJWgp83vCwr gAV+ieYdeeQz4DXAc7fYRfWeLb3pH+91jbfCLDjzcMv5VikOO8k1uwCnmg/3WKx/OO6d hpSUZW0XB+0p9ZEMKTfn7BZM/5NHa3em9VhyFSIlTwI7riKYS85MhJuYZjKY4VFAmwu+ O+MMv6LvxdvLWXHDJwf7+7XsHdQt2rTL1WxCSnF7me6/t36HJmxSo10AUJnpE4gTGWO9 /nn8kjdtJj5pB/bkOknHXqFhf7NHmAu08o+BZ9SlThiJtDpAShgE+xzTSpa10lyf9aQ7 b+mw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lRoe73xI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac47a1f8si434577685a.251.2024.12.20.08.20.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Dec 2024 08:20:29 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lRoe73xI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é 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); -#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) == 0; -} -#endif +bool translator_is_same_page(const DisasContextBase *db, vaddr addr); #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, uint32_t cflags, } } +bool translator_is_same_page(const DisasContextBase *db, vaddr addr) +{ + return ((addr ^ db->pc_first) & TARGET_PAGE_MASK) == 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) } /* Check for the dest on the same page as the start of the TB. */ - return ((db->pc_first ^ dest) & TARGET_PAGE_MASK) == 0; + return translator_is_same_page(db, dest); } 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, DisasContext *s, int num_bytes) /* 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); } @@ -2226,7 +2226,7 @@ static void gen_jmp_rel(DisasContext *s, MemOp ot, int 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 = false; } @@ -3763,7 +3763,7 @@ static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) * chance to happen. */ dc->base.is_jmp = 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 = 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) /* Only the first insn within a TB is allowed to cross a page boundary. */ if (ctx->base.is_jmp == DISAS_NEXT) { - if (ctx->itrigger || !is_same_page(&ctx->base, ctx->base.pc_next)) { + if (ctx->itrigger || !translator_is_same_page(&ctx->base, ctx->base.pc_next)) { ctx->base.is_jmp = DISAS_TOO_MANY; } else { unsigned page_ofs = 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 = insn_len(next_insn); - 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 = 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 = translate_one(env, dc); if (dc->base.is_jmp == 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 = DISAS_TOO_MANY; } }