From nobody Thu May 16 05:31:25 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=1607977766; cv=none; d=zohomail.com; s=zohoarc; b=GtUUeCXuRY+4HFg04tUiMTCMMmpkSUQ+buUSFSgLPtaseAMS9RJ2Mdhgi7CXJTZdJbJGRfp9UaHLvmNVlpHtw0v+UFsiUa8Dll3HYOw5GgtU6l2u3zh1oEljAocUj5Jo9Yip+Sq9H+FumpftBBaEY93x4f6PUjUbDw/fPj3Gd08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607977766; h=Content-Transfer-Encoding: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=0sMgt4Z0WrQXqhn3zEIbyMUGDzX3mT9jw9a9qSAx+tA=; b=J3WF5wyyGtmT33eftoHWk3Xbgto5dslKo9aydmLHYSgWCFVV34ACr9+kTHqfUEpGJgcBWSDrXHh0kGhkMZ53WxE3BN8StD5yh2ZNmL4Lf8zYDGy2KdFU3xRVHsL8lk+ZSSp+KOSYp06o03gQ9u5JKxYGN6vX2NQIiOtDGq2zJNQ= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607977766552655.3748003628351; Mon, 14 Dec 2020 12:29:26 -0800 (PST) Received: from localhost ([::1]:34642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooaN-00024G-Gq for importer@patchew.org; Mon, 14 Dec 2020 09:12:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooRm-0001Y9-8D for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:30 -0500 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:39284) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRd-0003tf-IQ for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:29 -0500 Received: by mail-ot1-x343.google.com with SMTP id d8so15771377otq.6 for ; Mon, 14 Dec 2020 06:03:19 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0sMgt4Z0WrQXqhn3zEIbyMUGDzX3mT9jw9a9qSAx+tA=; b=MxfCyiuLfFp8pXMYOZRypiU3ZlEQtSHHG9PZcJ+08XL/K8b9HyfW7IDRbV1zGGHEvo 9oBNAbrEPukelQ4fRAHejBytl01MTaYz5NXiSBAF59wkoQrQknpQihVFVfKIrngM0su8 boj+lPHxcBWigcP/dcJdRL6q2tItwaScM8PqvRYSJD/pEQywlnxMgJTkct+6zKIP2bCQ +l50ZRpGbfM7az1dsfA1zP6N5VO99dJ6NzvrqQSeK6TxqvO0csWQTJ7A9PB8e+Oy52oW E7DcfdQr8grt/NfBYG3iMx1CbeVNPPDZ4SCmfVJigoKJZ8tJe3RbRes+6pf96Jc2YuCp oAKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0sMgt4Z0WrQXqhn3zEIbyMUGDzX3mT9jw9a9qSAx+tA=; b=cubulGngXwzJS5c5cZjRvxxfnYe28OSoexzKQVZedxlRc8+ENRmUfVjbA2YLdxMxdE 0oc+ae8RHFNpG5/6uFcZvd5qYV32od5F/1zmBKGJ5i9zp+z9A2ee4W8JufUZ3uql70mf Bcaco+lzDFhe9M9BAVTSxgxF5od59nioCej7Ayx4zOBdM2SBMXDbttuShkBgcUJGCSdj zs7kvYGsuERNQ06OWwNKQZt7zVdMEHVWbiChKLTphNIiECf1Sb1vHuiRx6nZxkCRdjSf 4cuBAo4F5bSS6s0r/T9fPbhVo77wux6MI+txLHwg5Oe3/WTDt+rINScWIXPuEeiQVciD 9dFw== X-Gm-Message-State: AOAM531Cb0oE2xRN5cYO/F1HHiSpaEie5LSOWndXoKq8XcT6gQf8+ORG GZVw6qh7ZsuHK14+qiVUCS1q1AWyo9Ny77vS X-Google-Smtp-Source: ABdhPJzFSrCuZjEVOsl1LaCFngj6li7xOAVcAf0pNc0m9tlbobPeA4R27ZVFQOi72BAylwqaeh/99A== X-Received: by 2002:a9d:32b6:: with SMTP id u51mr18872273otb.119.1607954598082; Mon, 14 Dec 2020 06:03:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 01/43] tcg: Do not flush icache for interpreter Date: Mon, 14 Dec 2020 08:02:32 -0600 Message-Id: <20201214140314.18544-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::343; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x343.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" This is currently a no-op within tci/tcg-target.h, but is about to be moved to a more generic location. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- tcg/tcg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tcg/tcg.c b/tcg/tcg.c index 43c6cf8f52..3b3f366acd 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1077,7 +1077,9 @@ void tcg_prologue_init(TCGContext *s) #endif =20 buf1 =3D s->code_ptr; +#ifndef CONFIG_TCG_INTERPRETER flush_icache_range((uintptr_t)buf0, (uintptr_t)buf1); +#endif =20 /* Deduct the prologue from the buffer. */ prologue_size =3D tcg_current_code_size(s); @@ -4319,8 +4321,10 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) return -2; } =20 +#ifndef CONFIG_TCG_INTERPRETER /* flush instruction cache */ flush_icache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_ptr); +#endif =20 return tcg_current_code_size(s); } --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607972252; cv=none; d=zohomail.com; s=zohoarc; b=V6sVNg5I2UEALOEd75P83M75YCTJqScFbg3wCPieI2nmxzZq5WAJJ2bevhu5uACWqiLCkkl83UyArCVZlmHHaLHMedX9Dqa6uevfL8YdDvi169CZoAR4ERMnVtFR9AgSnsj3hPP3312vh6djhhBFC7cE5U3LgoX75BAJi6rYqlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607972252; h=Content-Transfer-Encoding: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=eOSyuirsXar+NqX//DtRTIYo0GnDDZiWnjXVEGBW7Sk=; b=nnECXAf1MrR3vBDTkx2GkzWKzz1AdDLs0MyvhAj7CWiz3dxBcrorCOxD3KnUP4njphWlZ722cQ+0RM5BQj7VMOrG/2cyZcYr8NXFbmXhHeAlAtuqujRSUWMsD4sZJnsdFbkfmPjxZBq1q6jPVWS/bQAiG2GGJzzFjR9yd6dZExg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607972252864843.7237576487207; Mon, 14 Dec 2020 10:57:32 -0800 (PST) Received: from localhost ([::1]:45842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooUm-0003RR-NA for importer@patchew.org; Mon, 14 Dec 2020 09:06:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooRi-0001WJ-O8 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:26 -0500 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]:40692) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRe-0003to-7U for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:25 -0500 Received: by mail-oi1-x241.google.com with SMTP id p126so19231068oif.7 for ; Mon, 14 Dec 2020 06:03:21 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=eOSyuirsXar+NqX//DtRTIYo0GnDDZiWnjXVEGBW7Sk=; b=A1CANqEFLIY4vWkipsGU4H9saAafv8nFQCXtlSKamdHh6GQxX77YAGMZwTxXHkpY6y VTCXvDliHkGgMfEON7gW/36y77V+LrH+m/DPG8p8/nJri1q+8NUndfmciLg15oVU0Q1h H4qhw5+Rti4xvKI26q4bJexHXrF1Koyd5FocDLNb1BCGuQk4ku1Gfjyc065duJjrjOXe k7JYrJFcoDyrfnlzx1qkGBBGm3httmhARPxNb16CnQbaeLP68ekmHEeehdYtYHc+LqxY DOrtLoNXINM359nn1RbRI04+xhRVVq+8PcmIAUUlL0ovgGDpb8aQYw5pYzRng51hsbcj f8gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eOSyuirsXar+NqX//DtRTIYo0GnDDZiWnjXVEGBW7Sk=; b=XQ4jZPwlcQv3/Vysz1ddTCwIhpAQXD6JcAiwbCFvylmaumxRpfijxsKJE1GVF2q6T7 u+QzRcu5wSsaj74cgRtu/wYH+j6Y0kMwJFr6IoCfrlCSH4RtXpfFGRwJaju+r/BmXXb7 rOXiWuzqR2AyEoh0nF0eJwK78u9r3TJ2MJ8tWPpWgZBQPgmUgoktu9uaaLJJOS0x2Nit JiUT4xCEa5FHCm8nohU/pUSGdlIlHJdii4xvNQd1J49Bd0/TW7ejCNUbqPuelWofZOYG BV9ytZ6/FTLLbto2lY7yUk2aPE6dlqnfa7VGWdZ3sQMiSs32FqyLe6VUteQQC/1e52N+ PuHw== X-Gm-Message-State: AOAM531UTbcNc2VVONqjWgQUp4QSYAHKiaD89crxHQrIGNZCajQBPWai QpS9wA6IqjEH24OLdIbk0pIQB3BAJ5HgiRWj X-Google-Smtp-Source: ABdhPJyqWFJqwDygL0f/zI5ahl+RlXtnamLDvjZGU748GHwAw/fGL7kHyBSsl/1p2yuxNHfDHCWINQ== X-Received: by 2002:aca:b943:: with SMTP id j64mr12318009oif.71.1607954600057; Mon, 14 Dec 2020 06:03:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 02/43] util: Extract flush_icache_range to cacheflush.c Date: Mon, 14 Dec 2020 08:02:33 -0600 Message-Id: <20201214140314.18544-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::241; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x241.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" This has been a tcg-specific function, but is also in use by hardware accelerators via physmem.c. This can cause link errors when tcg is disabled. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/cacheflush.h | 24 +++++++++++++ tcg/aarch64/tcg-target.h | 5 --- tcg/arm/tcg-target.h | 5 --- tcg/i386/tcg-target.h | 4 --- tcg/mips/tcg-target.h | 11 ------ tcg/ppc/tcg-target.h | 1 - tcg/riscv/tcg-target.h | 5 --- tcg/s390/tcg-target.h | 4 --- tcg/sparc/tcg-target.h | 8 ----- tcg/tci/tcg-target.h | 4 --- softmmu/physmem.c | 1 + tcg/tcg.c | 1 + util/cacheflush.c | 71 +++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 2 ++ tcg/ppc/tcg-target.c.inc | 22 ------------ util/meson.build | 2 +- 16 files changed, 100 insertions(+), 70 deletions(-) create mode 100644 include/qemu/cacheflush.h create mode 100644 util/cacheflush.c diff --git a/include/qemu/cacheflush.h b/include/qemu/cacheflush.h new file mode 100644 index 0000000000..58ae488491 --- /dev/null +++ b/include/qemu/cacheflush.h @@ -0,0 +1,24 @@ +/* + * Flush the host cpu caches. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_CACHEFLUSH_H +#define QEMU_CACHEFLUSH_H + +#if defined(__i386__) || defined(__x86_64__) || defined(__s390__) + +static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + /* icache is coherent and does not require flushing. */ +} + +#else + +void flush_icache_range(uintptr_t start, uintptr_t stop); + +#endif + +#endif /* QEMU_CACHEFLUSH_H */ diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 663dd0b95e..8a6b97598e 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -148,11 +148,6 @@ typedef enum { #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - __builtin___clear_cache((char *)start, (char *)stop); -} - void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); =20 #ifdef CONFIG_SOFTMMU diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 17e771374d..f1955ce4ac 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -134,11 +134,6 @@ enum { #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - __builtin___clear_cache((char *) start, (char *) stop); -} - /* not defined -- call should be eliminated at compile time */ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); =20 diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index abd4ac7fc0..cd067e0b30 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -206,10 +206,6 @@ extern bool have_avx2; #define TCG_TARGET_extract_i64_valid(ofs, len) \ (((ofs) =3D=3D 8 && (len) =3D=3D 8) || ((ofs) + (len)) =3D=3D 32) =20 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ -} - static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t = addr) { diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index c6b091d849..92c1d63da3 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -198,20 +198,9 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_HAS_ext16u_i64 0 /* andi rt, rs, 0xffff */ #endif =20 -#ifdef __OpenBSD__ -#include -#else -#include -#endif - #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - cacheflush ((void *)start, stop-start, ICACHE); -} - void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); =20 #ifdef CONFIG_SOFTMMU diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index be10363956..a509a19628 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -175,7 +175,6 @@ extern bool have_vsx; #define TCG_TARGET_HAS_bitsel_vec have_vsx #define TCG_TARGET_HAS_cmpsel_vec 0 =20 -void flush_icache_range(uintptr_t start, uintptr_t stop); void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); =20 #define TCG_TARGET_DEFAULT_MO (0) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 032439d806..c1bd52bb9a 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -159,11 +159,6 @@ typedef enum { #define TCG_TARGET_HAS_mulsh_i64 1 #endif =20 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - __builtin___clear_cache((char *)start, (char *)stop); -} - /* not defined -- call should be eliminated at compile time */ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); =20 diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index 63c8797bd3..b4feb2f55a 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -145,10 +145,6 @@ enum { TCG_AREG0 =3D TCG_REG_R10, }; =20 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ -} - static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t = addr) { diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index 633841ebf2..d8b0e32e2e 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -168,14 +168,6 @@ extern bool use_vis3_instructions; #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - uintptr_t p; - for (p =3D start & -8; p < ((stop + 7) & -8); p +=3D 8) { - __asm__ __volatile__("flush\t%0" : : "r" (p)); - } -} - void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); =20 #define TCG_TARGET_NEED_POOL_LABELS diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 8c1c1d265d..b84480f989 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -191,10 +191,6 @@ void tci_disas(uint8_t opc); =20 #define HAVE_TCG_QEMU_TB_EXEC =20 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ -} - /* We could notice __i386__ or __s390x__ and reduce the barriers depending on the host. But if you want performance, you use the normal backend. We prefer consistency across hosts on this. */ diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 3027747c03..36854f0cd0 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -22,6 +22,7 @@ #include "qapi/error.h" =20 #include "qemu/cutils.h" +#include "qemu/cacheflush.h" #include "cpu.h" #include "exec/exec-all.h" #include "exec/target_page.h" diff --git a/tcg/tcg.c b/tcg/tcg.c index 3b3f366acd..4b4cafe952 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -35,6 +35,7 @@ #include "qemu/host-utils.h" #include "qemu/qemu-print.h" #include "qemu/timer.h" +#include "qemu/cacheflush.h" =20 /* Note: the long term plan is to reduce the dependencies on the QEMU CPU definitions. Currently they are used for qemu_ld/st diff --git a/util/cacheflush.c b/util/cacheflush.c new file mode 100644 index 0000000000..2881832a38 --- /dev/null +++ b/util/cacheflush.c @@ -0,0 +1,71 @@ +/* + * Flush the host cpu caches. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/cacheflush.h" + + +#if defined(__i386__) || defined(__x86_64__) || defined(__s390__) + +/* Caches are coherent and do not require flushing; symbol inline. */ + +#elif defined(__mips__) + +#ifdef __OpenBSD__ +#include +#else +#include +#endif + +void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + cacheflush((void *)start, stop - start, ICACHE); +} + +#elif defined(__powerpc__) + +void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + uintptr_t p, start1, stop1; + size_t dsize =3D qemu_dcache_linesize; + size_t isize =3D qemu_icache_linesize; + + start1 =3D start & ~(dsize - 1); + stop1 =3D (stop + dsize - 1) & ~(dsize - 1); + for (p =3D start1; p < stop1; p +=3D dsize) { + asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); + } + asm volatile ("sync" : : : "memory"); + + start &=3D start & ~(isize - 1); + stop1 =3D (stop + isize - 1) & ~(isize - 1); + for (p =3D start1; p < stop1; p +=3D isize) { + asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); + } + asm volatile ("sync" : : : "memory"); + asm volatile ("isync" : : : "memory"); +} + +#elif defined(__sparc__) + +void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + uintptr_t p; + + for (p =3D start & -8; p < ((stop + 7) & -8); p +=3D 8) { + __asm__ __volatile__("flush\t%0" : : "r" (p)); + } +} + +#else + +void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + __builtin___clear_cache((char *)start, (char *)stop); +} + +#endif diff --git a/MAINTAINERS b/MAINTAINERS index d48a4e8a8b..2e23a93fec 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -119,6 +119,8 @@ F: softmmu/cpus.c F: cpus-common.c F: accel/tcg/ F: accel/stubs/tcg-stub.c +F: util/cacheinfo.c +F: util/cacheflush.c F: scripts/decodetree.py F: docs/devel/decodetree.rst F: include/exec/cpu*.h diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 18ee989f95..0d068ec8ab 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -3863,25 +3863,3 @@ void tcg_register_jit(void *buf, size_t buf_size) tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } #endif /* __ELF__ */ - -void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - uintptr_t p, start1, stop1; - size_t dsize =3D qemu_dcache_linesize; - size_t isize =3D qemu_icache_linesize; - - start1 =3D start & ~(dsize - 1); - stop1 =3D (stop + dsize - 1) & ~(dsize - 1); - for (p =3D start1; p < stop1; p +=3D dsize) { - asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); - } - asm volatile ("sync" : : : "memory"); - - start &=3D start & ~(isize - 1); - stop1 =3D (stop + isize - 1) & ~(isize - 1); - for (p =3D start1; p < stop1; p +=3D isize) { - asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); - } - asm volatile ("sync" : : : "memory"); - asm volatile ("isync" : : : "memory"); -} diff --git a/util/meson.build b/util/meson.build index f359af0d46..a3dfc0f966 100644 --- a/util/meson.build +++ b/util/meson.build @@ -21,7 +21,7 @@ util_ss.add(files('envlist.c', 'path.c', 'module.c')) util_ss.add(files('host-utils.c')) util_ss.add(files('bitmap.c', 'bitops.c')) util_ss.add(files('fifo8.c')) -util_ss.add(files('cacheinfo.c')) +util_ss.add(files('cacheinfo.c', 'cacheflush.c')) util_ss.add(files('error.c', 'qemu-error.c')) util_ss.add(files('qemu-print.c')) util_ss.add(files('id.c')) --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607979102; cv=none; d=zohomail.com; s=zohoarc; b=OSg09PmMJ314xihYLhcB1afMMBouAKFzyS7a28waUtnWaj87kZ3JBUKhWvyhcQ8lO2HYKfKjBYWI9PKoAJDa0wjmkxZTvSQ7mRa5fnIyyK11ZGSG1mWNuMJQRwYxlTEtUCgF4w+OdS2bgyCNiXRnzrgAiXHOkJP2rZjOjkhyABY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607979102; h=Content-Type: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=VBf9QskYdrzmXlYiy5KttGIoXCdMUZjZXJOehNVqkno=; b=UCIEmkBXrYT24bm4E0Hg/A+Ep28DMMQdLYIAL9DkzzRLcDqFdN2cRWyEDOxCPmrPbDU1xstJhrWHqtus7vzYS2D/xaxRp2/zylwGsVKaYVfglqTVTdao4Vzkd+MSqtFXMyzS5xPY+zbPnH46cQgXPALllUCgau05fTKz6pNFECQ= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607979102810220.89168865526585; Mon, 14 Dec 2020 12:51:42 -0800 (PST) Received: from localhost ([::1]:54104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooXD-0006pD-Od for importer@patchew.org; Mon, 14 Dec 2020 09:09:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooRj-0001WU-1h for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:27 -0500 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:37229) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRg-0003u2-5h for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:26 -0500 Received: by mail-oi1-x242.google.com with SMTP id l207so19265484oib.4 for ; Mon, 14 Dec 2020 06:03:23 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VBf9QskYdrzmXlYiy5KttGIoXCdMUZjZXJOehNVqkno=; b=lcqXOG6k+74/YmSo+a7htLjauAERA2Ae/NZ61odZo+wPSnM/NSHt8/i81TXKzvXTpo lg47+6A5DiPEsPvSfEfAA7/tXNLrPmFdYB5PdbpsN6wJ7msuTtWC5YcaqRDtf5UtrKK1 byWrN4nQT569JVe6SWVt73o4x4208an1htXuCjI0b2ltYIUSlLND4H3MdWnUCRd8RHYH a56yAu0Ey2CS7MWRc+4EZj3O1qmOax1T+tEIw0YduByyZCwgoFsys7cpPhFHe2PtgHj1 NdELjIPoarm8pZ27GdCSH/+ptC0u/jyGFnUS9DJ1z4aM6O45UnTYIn5LfPGwbXXXXufl NCtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VBf9QskYdrzmXlYiy5KttGIoXCdMUZjZXJOehNVqkno=; b=VHVEPWh0n6w/wZ46uXkIseoHbYaPxZrV23fV4niOKcNlYvvN9zQsKmzlGJlWLRZXFN WurjKQT/NSDXgJ0lACPgdtjbQvFSOBcladj9Vuyh2t9xxctZY+J82Jo4a+g0/yzpCc2d o842NtIS2u7u2bgdEGW3DybroQdzhroQ8/Aq9+tfzxxdkW0wK3wSjuCKbgmi71/bfHQc WUjKSxuFlwGLgvUR3oDjDeV4OH7nM64E621qowm6svsfgnfq/JQ+3pc0BzbbPhpngvxp l3UUAes4jP/+8Yh7c4rGT9lHUr8Eqs5jguBcjm3uR+3V+azMJ3g2SHkWS4RT+MFaXLv+ szYA== X-Gm-Message-State: AOAM532yEDp4G+IUM/5LaOr5pd50LCnp+UzsEAvtUBnd/kag9QYD7aki mEeuJr5DGWtJxM1KYSAv9vn67WoYXmJuazER X-Google-Smtp-Source: ABdhPJw3R1SwWcw/E1dzNReb8T4HGhIdjgoiG6dlZzc9fy4fFMFrW6t66lJfnESRFoqhOUe/k4QtCw== X-Received: by 2002:aca:3885:: with SMTP id f127mr12001938oia.104.1607954602158; Mon, 14 Dec 2020 06:03:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 03/43] util: Enhance flush_icache_range with separate data pointer Date: Mon, 14 Dec 2020 08:02:34 -0600 Message-Id: <20201214140314.18544-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-1-richard.henderson@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::242; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x242.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) We are shortly going to have a split rw/rx jit buffer. Depending on the host, we need to flush the dcache at the rw data pointer and flush the icache at the rx code pointer. For now, the two passed pointers are identical, so there is no effective change in behaviour. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- include/qemu/cacheflush.h | 15 ++++++++++++-- softmmu/physmem.c | 2 +- tcg/tcg.c | 6 ++++-- util/cacheflush.c | 38 +++++++++++++++++++++--------------- util/cacheinfo.c | 8 +++++--- tcg/aarch64/tcg-target.c.inc | 2 +- tcg/mips/tcg-target.c.inc | 2 +- tcg/ppc/tcg-target.c.inc | 4 ++-- tcg/sparc/tcg-target.c.inc | 4 ++-- 9 files changed, 51 insertions(+), 30 deletions(-) diff --git a/include/qemu/cacheflush.h b/include/qemu/cacheflush.h index 58ae488491..ae20bcda73 100644 --- a/include/qemu/cacheflush.h +++ b/include/qemu/cacheflush.h @@ -8,16 +8,27 @@ #ifndef QEMU_CACHEFLUSH_H #define QEMU_CACHEFLUSH_H =20 +/** + * flush_idcache_range: + * @rx: instruction address + * @rw: data address + * @len: length to flush + * + * Flush @len bytes of the data cache at @rw and the icache at @rx + * to bring them in sync. The two addresses may be different virtual + * mappings of the same physical page(s). + */ + #if defined(__i386__) || defined(__x86_64__) || defined(__s390__) =20 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t = len) { /* icache is coherent and does not require flushing. */ } =20 #else =20 -void flush_icache_range(uintptr_t start, uintptr_t stop); +void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len); =20 #endif =20 diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 36854f0cd0..7aa706b1e3 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -2947,7 +2947,7 @@ static inline MemTxResult address_space_write_rom_int= ernal(AddressSpace *as, invalidate_and_set_dirty(mr, addr1, l); break; case FLUSH_CACHE: - flush_icache_range((uintptr_t)ram_ptr, (uintptr_t)ram_ptr = + l); + flush_idcache_range((uintptr_t)ram_ptr, (uintptr_t)ram_ptr= , l); break; } } diff --git a/tcg/tcg.c b/tcg/tcg.c index 4b4cafe952..675334e844 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1079,7 +1079,8 @@ void tcg_prologue_init(TCGContext *s) =20 buf1 =3D s->code_ptr; #ifndef CONFIG_TCG_INTERPRETER - flush_icache_range((uintptr_t)buf0, (uintptr_t)buf1); + flush_idcache_range((uintptr_t)buf0, (uintptr_t)buf0, + tcg_ptr_byte_diff(buf1, buf0)); #endif =20 /* Deduct the prologue from the buffer. */ @@ -4324,7 +4325,8 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) =20 #ifndef CONFIG_TCG_INTERPRETER /* flush instruction cache */ - flush_icache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_ptr); + flush_idcache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_buf, + tcg_ptr_byte_diff(s->code_ptr, s->code_buf)); #endif =20 return tcg_current_code_size(s); diff --git a/util/cacheflush.c b/util/cacheflush.c index 2881832a38..92805efe49 100644 --- a/util/cacheflush.c +++ b/util/cacheflush.c @@ -21,29 +21,32 @@ #include #endif =20 -void flush_icache_range(uintptr_t start, uintptr_t stop) +void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { - cacheflush((void *)start, stop - start, ICACHE); + if (rx !=3D rw) { + cacheflush((void *)rw, len, DCACHE); + } + cacheflush((void *)rx, len, ICACHE); } =20 #elif defined(__powerpc__) =20 -void flush_icache_range(uintptr_t start, uintptr_t stop) +void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { - uintptr_t p, start1, stop1; + uintptr_t p, b, e; size_t dsize =3D qemu_dcache_linesize; size_t isize =3D qemu_icache_linesize; =20 - start1 =3D start & ~(dsize - 1); - stop1 =3D (stop + dsize - 1) & ~(dsize - 1); - for (p =3D start1; p < stop1; p +=3D dsize) { + b =3D rw & ~(dsize - 1); + e =3D (rw + len + dsize - 1) & ~(dsize - 1); + for (p =3D b; p < e; p +=3D dsize) { asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); } asm volatile ("sync" : : : "memory"); =20 - start &=3D start & ~(isize - 1); - stop1 =3D (stop + isize - 1) & ~(isize - 1); - for (p =3D start1; p < stop1; p +=3D isize) { + b =3D rx & ~(isize - 1); + e =3D (rx + len + isize - 1) & ~(isize - 1); + for (p =3D b; p < e; p +=3D isize) { asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); } asm volatile ("sync" : : : "memory"); @@ -52,20 +55,23 @@ void flush_icache_range(uintptr_t start, uintptr_t stop) =20 #elif defined(__sparc__) =20 -void flush_icache_range(uintptr_t start, uintptr_t stop) +void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { - uintptr_t p; - - for (p =3D start & -8; p < ((stop + 7) & -8); p +=3D 8) { + /* No additional data flush to the RW virtual address required. */ + uintptr_t p, end =3D (rx + len + 7) & -8; + for (p =3D rx & -8; p < end; p +=3D 8) { __asm__ __volatile__("flush\t%0" : : "r" (p)); } } =20 #else =20 -void flush_icache_range(uintptr_t start, uintptr_t stop) +void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { - __builtin___clear_cache((char *)start, (char *)stop); + if (rw !=3D rx) { + __builtin___clear_cache((char *)rw, (char *)rw + len); + } + __builtin___clear_cache((char *)rx, (char *)rx + len); } =20 #endif diff --git a/util/cacheinfo.c b/util/cacheinfo.c index 7804c186b6..b182f0b693 100644 --- a/util/cacheinfo.c +++ b/util/cacheinfo.c @@ -166,9 +166,11 @@ static void fallback_cache_info(int *isize, int *dsize) *isize =3D *dsize; } else { #if defined(_ARCH_PPC) - /* For PPC, we're going to use the icache size computed for - flush_icache_range. Which means that we must use the - architecture minimum. */ + /* + * For PPC, we're going to use the cache sizes computed for + * flush_idcache_range. Which means that we must use the + * architecture minimum. + */ *isize =3D *dsize =3D 16; #else /* Otherwise, 64 bytes is not uncommon. */ diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 26f71cb599..83af3108a4 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1363,7 +1363,7 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintp= tr_t jmp_addr, } pair =3D (uint64_t)i2 << 32 | i1; qatomic_set((uint64_t *)jmp_addr, pair); - flush_icache_range(jmp_addr, jmp_addr + 8); + flush_idcache_range(jmp_addr, jmp_addr, 8); } =20 static inline void tcg_out_goto_label(TCGContext *s, TCGLabel *l) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 41be574e89..c255ecb444 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2660,7 +2660,7 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintp= tr_t jmp_addr, uintptr_t addr) { qatomic_set((uint32_t *)jmp_addr, deposit32(OPC_J, 0, 26, addr >> 2)); - flush_icache_range(jmp_addr, jmp_addr + 4); + flush_idcache_range(jmp_addr, jmp_addr, 4); } =20 typedef struct { diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 0d068ec8ab..b756281042 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -1753,12 +1753,12 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uin= tptr_t jmp_addr, /* As per the enclosing if, this is ppc64. Avoid the _Static_asse= rt within qatomic_set that would fail to build a ppc32 host. */ qatomic_set__nocheck((uint64_t *)jmp_addr, pair); - flush_icache_range(jmp_addr, jmp_addr + 8); + flush_idcache_range(jmp_addr, jmp_addr, 8); } else { intptr_t diff =3D addr - jmp_addr; tcg_debug_assert(in_range_b(diff)); qatomic_set((uint32_t *)jmp_addr, B | (diff & 0x3fffffc)); - flush_icache_range(jmp_addr, jmp_addr + 4); + flush_idcache_range(jmp_addr, jmp_addr, 4); } } =20 diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 6775bd30fc..6e2d755f6a 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -1836,7 +1836,7 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintp= tr_t jmp_addr, if (!USE_REG_TB) { qatomic_set((uint32_t *)jmp_addr, deposit32(CALL, 0, 30, br_disp >> 2)); - flush_icache_range(jmp_addr, jmp_addr + 4); + flush_idcache_range(jmp_addr, jmp_addr, 4); return; } =20 @@ -1860,5 +1860,5 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintp= tr_t jmp_addr, } =20 qatomic_set((uint64_t *)jmp_addr, deposit64(i2, 32, 32, i1)); - flush_icache_range(jmp_addr, jmp_addr + 8); + flush_idcache_range(jmp_addr, jmp_addr, 8); } --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607954955; cv=none; d=zohomail.com; s=zohoarc; b=hPAJTjT67OaZxNNM9j9jE8TrECsAVpNm2qV48qrU3PCJIflp9kif0hnp0xrP+6qoKnb+Y0kMKoBmnCwa81uwMgjiIIic6l8kv0htGLBLILFpx8gM8JiKJdW/7LAcibdoy0kmeXhA+HbvtVuk5OHyzwUU/4H1+9iP0Q5KH0BTvmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607954955; 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=OCpAIDmNxfXuUcIom3vUf6VIYVS6wp4D0QytQgRfHqY=; b=kqTv1XVtuXXRJFXU1cuxAh2YsYNU+wBD5l/wjc9WAQluMJNhDMFcmdqe2joIZyzh8XC8ZA8yLGyXYThb5clZS9wuqi2IcTgf3AZT+1XetHWVCw+0vHSjQWipThxBn9wVAbxCf4Dpjh4GkO9iz9rRVMEp5StB+vZ2SyKOPU7Nwtk= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607954954770550.4105706813589; Mon, 14 Dec 2020 06:09:14 -0800 (PST) Received: from localhost ([::1]:54346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooXG-0006v0-H5 for importer@patchew.org; Mon, 14 Dec 2020 09:09:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooRk-0001XG-Ti for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:28 -0500 Received: from mail-oi1-x244.google.com ([2607:f8b0:4864:20::244]:36344) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRh-0003uM-SW for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:28 -0500 Received: by mail-oi1-x244.google.com with SMTP id 9so12096191oiq.3 for ; Mon, 14 Dec 2020 06:03:25 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OCpAIDmNxfXuUcIom3vUf6VIYVS6wp4D0QytQgRfHqY=; b=kbYbAaJTyoXLm02/V3NWvhS70MF5OGX2yo6AKpzAWLSLZm/5tXOJdQcT8AQ8Y+nKw8 vh7CxCRD8BKZKsjuyPiS3OIIJ7Vmo6tFlRgDg1W5XLtxX8wq9MZF8KfkZkvI9ZpWA+56 DoGFb/eEc1jzZWtJTk5c9aFHrET/QXFTUyb9EDPDii0vt6f6JUufbikz86nGsFWYoKD7 ciRcJ0vsK2YZr/33umYb/KNXh1QHlkRlvbs16XjBShR4sRdaAjtW+ZFQ6xthchPwI8hY b/AhO0khAt7YcGasX33stOCyeak8DElEK61PCBMvo952fKzgXl7d+7OWmzuYxZ0lyPJS NkWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OCpAIDmNxfXuUcIom3vUf6VIYVS6wp4D0QytQgRfHqY=; b=VCE1i+/9mrDJBUfqtfY0C25vsTrwJUROuVNZS5QU0Nk2f2oxEXoTYdH382zt6V/WbS aiyZfbEqSVbWb8YQvK+CHzFRjI8I/vO17S2aGqypuy1eUkwbFjgWks3kIgyrzUdrekro D4t9ggzKvJu3DTPDOze6VdV4Xqm/ytKh+lrw7A3t4yexvYJ5I8nV3c6lgxWDVNFLMs0r Gnq82dgwv32OhbmXMlmCMvvfGknQQHfaKSZmZwh1/A6KqFr1x1cdtB6290gFKn3xufrG 7e9xi8IVFGXRABN9zsS+0l5K1lxeDMfh3Z29tsF0wBlB/4jYWzHf4jgYuhTtTZllE+4c J1rg== X-Gm-Message-State: AOAM533EFFqFWZQddhJNRqxxcPQL2HVYwqHczhAW5lUxMu9ZSDzo7srG FIzUd3o1luxtMvF45hoo1m9mO+tB+Z9CioBt X-Google-Smtp-Source: ABdhPJwcAyNgVKxOSBpOqAQ40aT6CXjhpw76b0VcoqtNGrzzcLFmNqKq5u+mMpY94dYGJWVaUlbi1A== X-Received: by 2002:aca:afd0:: with SMTP id y199mr18221481oie.7.1607954604180; Mon, 14 Dec 2020 06:03:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 04/43] util: Specialize flush_idcache_range for aarch64 Date: Mon, 14 Dec 2020 08:02:35 -0600 Message-Id: <20201214140314.18544-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::244; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x244.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" For darwin, the CTR_EL0 register is not accessible, but there are system routines that we can use. For other hosts, copy the single pointer implementation from libgcc and modify it to support the double pointer interface we require. This halves the number of cache operations required when split-rwx is enabled. Cc: Joelle van Dyne Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- util/cacheflush.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/util/cacheflush.c b/util/cacheflush.c index 92805efe49..6a20723902 100644 --- a/util/cacheflush.c +++ b/util/cacheflush.c @@ -7,12 +7,81 @@ =20 #include "qemu/osdep.h" #include "qemu/cacheflush.h" +#include "qemu/bitops.h" =20 =20 #if defined(__i386__) || defined(__x86_64__) || defined(__s390__) =20 /* Caches are coherent and do not require flushing; symbol inline. */ =20 +#elif defined(__aarch64__) + +#ifdef CONFIG_DARWIN +/* Apple does not expose CTR_EL0, so we must use system interfaces. */ +extern void sys_icache_invalidate(void *start, size_t len); +extern void sys_dcache_flush(void *start, size_t len); +void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) +{ + sys_dcache_flush((void *)rw, len); + sys_icache_invalidate((void *)rx, len); +} +#else + +/* + * TODO: unify this with cacheinfo.c. + * We want to save the whole contents of CTR_EL0, so that we + * have more than the linesize, but also IDC and DIC. + */ +static unsigned int save_ctr_el0; +static void __attribute__((constructor)) init_ctr_el0(void) +{ + asm volatile("mrs\t%0, ctr_el0" : "=3Dr"(save_ctr_el0)); +} + +/* + * This is a copy of gcc's __aarch64_sync_cache_range, modified + * to fit this three-operand interface. + */ +void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) +{ + const unsigned CTR_IDC =3D 1u << 28; + const unsigned CTR_DIC =3D 1u << 29; + const unsigned int ctr_el0 =3D save_ctr_el0; + const uintptr_t icache_lsize =3D 4 << extract32(ctr_el0, 0, 4); + const uintptr_t dcache_lsize =3D 4 << extract32(ctr_el0, 16, 4); + uintptr_t p; + + /* + * If CTR_EL0.IDC is enabled, Data cache clean to the Point of Unifica= tion + * is not required for instruction to data coherence. + */ + if (!(ctr_el0 & CTR_IDC)) { + /* + * Loop over the address range, clearing one cache line at once. + * Data cache must be flushed to unification first to make sure + * the instruction cache fetches the updated data. + */ + for (p =3D rw & -dcache_lsize; p < rw + len; p +=3D dcache_lsize) { + asm volatile("dc\tcvau, %0" : : "r" (p) : "memory"); + } + asm volatile("dsb\tish" : : : "memory"); + } + + /* + * If CTR_EL0.DIC is enabled, Instruction cache cleaning to the Point + * of Unification is not required for instruction to data coherence. + */ + if (!(ctr_el0 & CTR_DIC)) { + for (p =3D rx & -icache_lsize; p < rx + len; p +=3D icache_lsize) { + asm volatile("ic\tivau, %0" : : "r"(p) : "memory"); + } + asm volatile ("dsb\tish" : : : "memory"); + } + + asm volatile("isb" : : : "memory"); +} +#endif /* CONFIG_DARWIN */ + #elif defined(__mips__) =20 #ifdef __OpenBSD__ --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607962284; cv=none; d=zohomail.com; s=zohoarc; b=ApRzf/ntWzujmQpcNCmOyCW59tUSraepjG40N8JkUiafauG8MWNhr0C8pZookPnhozj4ZBmmT0JeYlUv9SEMnIQvJdhIqpk851LUiqajhp4KuOuiDwyZL1LHg5u42zAR538Um8pnsYjUg5WaEPDM53SOa+BM8KdtGCQnzF0p5nM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607962284; h=Content-Type: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=e4GkJv76UBMIB3dzCCmxjxbYnphaAHyABGBMlwHa+9g=; b=ZHIRW4SP/d72jXHc+65cYPXFuJvZuGn4yZa85wlPYtmdP/54hXnnXtoIwU2hSqciYAsU5C3Qh3iT91T2FeH0f/G+z6WlCP8/VEWxYb5ft13F02x1vN2hNrqlYZa21JGzkCoNGV0p/rgHHt0zAz5CF/iWfOfXa5TASYDd2Yvuzv8= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607962284487278.232638618799; Mon, 14 Dec 2020 08:11:24 -0800 (PST) Received: from localhost ([::1]:45914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooUm-0003U2-Ih for importer@patchew.org; Mon, 14 Dec 2020 09:06:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooRm-0001Ys-O2 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:30 -0500 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:43488) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRk-0003up-Po for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:30 -0500 Received: by mail-ot1-x344.google.com with SMTP id q25so15756126otn.10 for ; Mon, 14 Dec 2020 06:03:28 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e4GkJv76UBMIB3dzCCmxjxbYnphaAHyABGBMlwHa+9g=; b=e6qb9pB8XU1J4St5tNl5X1Gk+/RxoTiVP3x8CX1fmEAvdXfOgUXxKjisvLENMopFag qJ1ZZybz+fuohhrOCYQAY5owdUp6b9QXvSSHYotKo7YcK8YU8zZUjROu0sLsSh6Hf54B h3SKTJF27hzSgf3YdGqP5yGBy+P7V1jwIBm6ATuP9ATc+tTpZYrTHKcaPLseG+zbH/zw OWOm+k4+A62gZcAI3Lwtrbirg7phgSIZ9dzetvXW70CcMDCzmOEqQHGm1/+wKdQlXi/A US/h9UlzKOvMc86vshcHtyU3PdjDxiOzVuah66sudjjO7puD7NoOIhd4gqKKojVK50vC imLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e4GkJv76UBMIB3dzCCmxjxbYnphaAHyABGBMlwHa+9g=; b=uMEq3yexGnJxIHaCtrCi93JyAo35shocb6QyH7vcZZLEWYB/TFq0ljgzuZ5Mu3IqiE Ot2T+JcLZqHiNw2VKw3ShsW3FPcN81HfZUBzEQMvNgdhlSfsmN4/kQpC7tuCxbJbc879 ZO9jIrmgZRDJP5GJzCZ+fjDGun/LjpHbunHobLyrsse8qEmMOKWfRgwZqWXOwL5fVBZD bApURtZ0meKq7R6jPoHoAnRFZodrqd3L9jMtFHyTfqpnBHDyzmVaUk4jyradvTYTZl/d VF90clmq7lbnG6iIJ8nFdDW8SAxTRysjcS2d4RiHxtycrNLGWnQp79HLR9TOOqF5gAhj YUxg== X-Gm-Message-State: AOAM5308QJeHLO4qmrx4l2VHCZgmcofNdmDMOkjVvZqxFv9uSrfW+nNw g65ouJSc9wmMLZPcaYZG1TSAvSQkcaFAlnkC X-Google-Smtp-Source: ABdhPJwkUvNX9m9kmTrnj4A2IDm/ErG7NPCxeTVYu9ZeI/gR2kORHGpCc42WcR80uptpEb5SKdUwhw== X-Received: by 2002:a05:6830:1e7a:: with SMTP id m26mr10520089otr.78.1607954605458; Mon, 14 Dec 2020 06:03:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 05/43] tcg: Move tcg prologue pointer out of TCGContext Date: Mon, 14 Dec 2020 08:02:36 -0600 Message-Id: <20201214140314.18544-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-1-richard.henderson@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::344; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x344.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) This value is constant across all thread-local copies of TCGContext, so we might as well move it out of thread-local storage. Use the correct function pointer type, and name the variable tcg_qemu_tb_exec, which means that we are able to remove the macro that does the casting. Replace HAVE_TCG_QEMU_TB_EXEC with CONFIG_TCG_INTERPRETER, as this is somewhat clearer in intent. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/tcg/tcg.h | 9 ++++----- tcg/tcg.c | 9 ++++++++- tcg/tci.c | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 8ff9dad4ef..9cc412f90c 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -621,7 +621,6 @@ struct TCGContext { here, because there's too much arithmetic throughout that relies on addition and subtraction working on bytes. Rely on the GCC extension that allows arithmetic on void*. */ - void *code_gen_prologue; void *code_gen_epilogue; void *code_gen_buffer; size_t code_gen_buffer_size; @@ -1222,11 +1221,11 @@ static inline unsigned get_mmuidx(TCGMemOpIdx oi) #define TB_EXIT_IDXMAX 1 #define TB_EXIT_REQUESTED 3 =20 -#ifdef HAVE_TCG_QEMU_TB_EXEC -uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr); +#ifdef CONFIG_TCG_INTERPRETER +uintptr_t tcg_qemu_tb_exec(CPUArchState *env, void *tb_ptr); #else -# define tcg_qemu_tb_exec(env, tb_ptr) \ - ((uintptr_t (*)(void *, void *))tcg_ctx->code_gen_prologue)(env, tb_pt= r) +typedef uintptr_t tcg_prologue_fn(CPUArchState *env, void *tb_ptr); +extern tcg_prologue_fn *tcg_qemu_tb_exec; #endif =20 void tcg_register_jit(void *buf, size_t buf_size); diff --git a/tcg/tcg.c b/tcg/tcg.c index 675334e844..67065c2ede 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -162,6 +162,10 @@ static TCGContext **tcg_ctxs; static unsigned int n_tcg_ctxs; TCGv_env cpu_env =3D 0; =20 +#ifndef CONFIG_TCG_INTERPRETER +tcg_prologue_fn *tcg_qemu_tb_exec; +#endif + struct tcg_region_tree { QemuMutex lock; GTree *tree; @@ -1055,7 +1059,10 @@ void tcg_prologue_init(TCGContext *s) s->code_ptr =3D buf0; s->code_buf =3D buf0; s->data_gen_ptr =3D NULL; - s->code_gen_prologue =3D buf0; + +#ifndef CONFIG_TCG_INTERPRETER + tcg_qemu_tb_exec =3D (tcg_prologue_fn *)buf0; +#endif =20 /* Compute a high-water mark, at which we voluntarily flush the buffer and start over. The size here is arbitrary, significantly larger diff --git a/tcg/tci.c b/tcg/tci.c index 82039fd163..d996eb7cf8 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -475,8 +475,9 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCG= Cond condition) #endif =20 /* Interpret pseudo code in tb. */ -uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr) +uintptr_t tcg_qemu_tb_exec(CPUArchState *env, void *v_tb_ptr) { + uint8_t *tb_ptr =3D v_tb_ptr; tcg_target_ulong regs[TCG_TARGET_NB_REGS]; long tcg_temps[CPU_TEMP_BUF_NLONGS]; uintptr_t sp_value =3D (uintptr_t)(tcg_temps + CPU_TEMP_BUF_NLONGS); --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607970484; cv=none; d=zohomail.com; s=zohoarc; b=DNc/kYn1hD4CwM9MAinGf3+ZCOXcKTuYF+6+55zHpQDcrlv44/mbyJnJ/QQfM65oKSGYWKGCdJBFcPoSnyRJ48hGxqbr/OjogbUYsKI+MmVmyU8axl2098bwGQr7gEGdIX1kh8bPOs1nWxp8nUR9qquUIRQAoKiPQzpFYNAqUfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607970484; h=Content-Transfer-Encoding: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=Caod8Myfn6UMAwpFdXVp68OknFB2PbyNlugc5dGMlp0=; b=BTr9QVULuoXQBCoG2JOIHtf2L0NN92hfxsQaULzPTSUwr+HDsikMDdyzUMLTy0q0w/7hKDcmycnNdViEUN7l34Mg6sWocP5dMYxsh4RkgCQ8n9ECV+Mnsta/Nogd2u9Uz4Eg1bxM1V63imQxjptAh+C5UNP7xQfyM5akwm+0lSc= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607970484683194.83193587607877; Mon, 14 Dec 2020 10:28:04 -0800 (PST) Received: from localhost ([::1]:34616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooaS-00023k-B7 for importer@patchew.org; Mon, 14 Dec 2020 09:12:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooRr-0001c8-TU for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:38 -0500 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]:38454) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRm-0003v7-1c for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:33 -0500 Received: by mail-oi1-x230.google.com with SMTP id x13so10199887oic.5 for ; Mon, 14 Dec 2020 06:03:29 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Caod8Myfn6UMAwpFdXVp68OknFB2PbyNlugc5dGMlp0=; b=dFl8rFP7/E7tj3pcsbeco9RnoOO0l61lu+nqPf8zVmz8Ey8QjTMuJp+KpEDfUw6wRa JljfO1gvQTSGlLaLmvNqil1DJqAg86UtS2Me0AEdfGJwnL9LLe9j5drpFz2Z/xWsK9Tr F5i273ykombSV1kdQzTKq5QPacEUnhpuWQMAsi8tEr1eb/cOC1EumcHHpEyC1GrKLH5R RgoJtLlR3GAY0U4Wn05tpxFUaUzJ+EQzKUTjfyTkeFxjW0AUiMI2ssvp/7TZPdKOrXf0 64w2U2UhSnLEoT7UkLrxjyTRLGoLPa1PhHQFhpmM2cKYV0uWpq+6jglWel8vKc0vvZ0D QHgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Caod8Myfn6UMAwpFdXVp68OknFB2PbyNlugc5dGMlp0=; b=PZEsPEmCzt6ROL3XFwpg5AW0m8ovLkeutodCiplWIaCqqUGPP7tvapkz9DeiryADiI KAveToN+WTlshS0pKzOXals7g5eqscGqxOftjw7dc2QeWVoElkx50br3uDQtGYyKCIIV NHzvKeYK9A2cRlMPdUX3lHD8lzUQ/C5D36ou09lWfQv3loSCGkFtOTubWGbC54xY/YsA JzeC+mEoYmiqBv48/qDGDwYhPguUxkTIx97JQp1Amg/WmOMefH7VXnuqgJv9j3UxVYy6 2FFpQXHXkaE2BKbBUO9OuVLWigWigX5oftwjzoUEDz5nU9gqJfCaxjjPxfFDEN8u8EFf MbVA== X-Gm-Message-State: AOAM533GWfVVp2RZSu5CyBDdUCz94RB4qrHw2fe/caFKCILQpSGkFffl zDqKhgOuT0rVFaJ0vnYw0LpMTtbNXcsNv78v X-Google-Smtp-Source: ABdhPJzz+H6EuR5j/xjgsNYJ5cYAqcF/Qpas37fO9NTT77Ov6ndow7dCo4h+LVkxz46gkzFzE/di6w== X-Received: by 2002:aca:504e:: with SMTP id e75mr18774915oib.170.1607954607056; Mon, 14 Dec 2020 06:03:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 06/43] tcg: Move tcg epilogue pointer out of TCGContext Date: Mon, 14 Dec 2020 08:02:37 -0600 Message-Id: <20201214140314.18544-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::230; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x230.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" This value is constant across all thread-local copies of TCGContext, so we might as well move it out of thread-local storage. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- include/tcg/tcg.h | 2 +- accel/tcg/tcg-runtime.c | 2 +- tcg/tcg.c | 3 ++- tcg/aarch64/tcg-target.c.inc | 4 ++-- tcg/arm/tcg-target.c.inc | 2 +- tcg/i386/tcg-target.c.inc | 4 ++-- tcg/mips/tcg-target.c.inc | 2 +- tcg/ppc/tcg-target.c.inc | 2 +- tcg/riscv/tcg-target.c.inc | 4 ++-- tcg/s390/tcg-target.c.inc | 4 ++-- tcg/sparc/tcg-target.c.inc | 2 +- 11 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 9cc412f90c..bb1e97b13b 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -621,7 +621,6 @@ struct TCGContext { here, because there's too much arithmetic throughout that relies on addition and subtraction working on bytes. Rely on the GCC extension that allows arithmetic on void*. */ - void *code_gen_epilogue; void *code_gen_buffer; size_t code_gen_buffer_size; void *code_gen_ptr; @@ -678,6 +677,7 @@ struct TCGContext { =20 extern TCGContext tcg_init_ctx; extern __thread TCGContext *tcg_ctx; +extern void *tcg_code_gen_epilogue; extern TCGv_env cpu_env; =20 static inline size_t temp_idx(TCGTemp *ts) diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c index 446465a09a..f85dfefeab 100644 --- a/accel/tcg/tcg-runtime.c +++ b/accel/tcg/tcg-runtime.c @@ -154,7 +154,7 @@ void *HELPER(lookup_tb_ptr)(CPUArchState *env) =20 tb =3D tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, curr_cflags()); if (tb =3D=3D NULL) { - return tcg_ctx->code_gen_epilogue; + return tcg_code_gen_epilogue; } qemu_log_mask_and_addr(CPU_LOG_EXEC, pc, "Chain %d: %p [" diff --git a/tcg/tcg.c b/tcg/tcg.c index 67065c2ede..588686617d 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -161,6 +161,7 @@ static int tcg_out_ldst_finalize(TCGContext *s); static TCGContext **tcg_ctxs; static unsigned int n_tcg_ctxs; TCGv_env cpu_env =3D 0; +void *tcg_code_gen_epilogue; =20 #ifndef CONFIG_TCG_INTERPRETER tcg_prologue_fn *tcg_qemu_tb_exec; @@ -1133,7 +1134,7 @@ void tcg_prologue_init(TCGContext *s) =20 /* Assert that goto_ptr is implemented completely. */ if (TCG_TARGET_HAS_goto_ptr) { - tcg_debug_assert(s->code_gen_epilogue !=3D NULL); + tcg_debug_assert(tcg_code_gen_epilogue !=3D NULL); } } =20 diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 83af3108a4..76f8ae48ad 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1873,7 +1873,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_exit_tb: /* Reuse the zeroing that exists for goto_ptr. */ if (a0 =3D=3D 0) { - tcg_out_goto_long(s, s->code_gen_epilogue); + tcg_out_goto_long(s, tcg_code_gen_epilogue); } else { tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_X0, a0); tcg_out_goto_long(s, tb_ret_addr); @@ -2894,7 +2894,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - s->code_gen_epilogue =3D s->code_ptr; + tcg_code_gen_epilogue =3D s->code_ptr; tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_X0, 0); =20 /* TB epilogue */ diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 62c37a954b..1e32bf42b8 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -2297,7 +2297,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - s->code_gen_epilogue =3D s->code_ptr; + tcg_code_gen_epilogue =3D s->code_ptr; tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R0, 0); tcg_out_epilogue(s); } diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index d8797ed398..424dd1cdcf 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -2267,7 +2267,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcod= e opc, case INDEX_op_exit_tb: /* Reuse the zeroing that exists for goto_ptr. */ if (a0 =3D=3D 0) { - tcg_out_jmp(s, s->code_gen_epilogue); + tcg_out_jmp(s, tcg_code_gen_epilogue); } else { tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_EAX, a0); tcg_out_jmp(s, tb_ret_addr); @@ -3825,7 +3825,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - s->code_gen_epilogue =3D s->code_ptr; + tcg_code_gen_epilogue =3D s->code_ptr; tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0); =20 /* TB epilogue */ diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index c255ecb444..f641105f9a 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2483,7 +2483,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - s->code_gen_epilogue =3D s->code_ptr; + tcg_code_gen_epilogue =3D s->code_ptr; tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_V0, TCG_REG_ZERO); =20 /* TB epilogue */ diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index b756281042..15d5c78798 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2341,7 +2341,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out32(s, BCCTR | BO_ALWAYS); =20 /* Epilogue */ - s->code_gen_epilogue =3D tb_ret_addr =3D s->code_ptr; + tcg_code_gen_epilogue =3D tb_ret_addr =3D s->code_ptr; =20 tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_REG_R1, FRAME_SIZE+LR_OFFS= ET); for (i =3D 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); ++i) { diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index d536f3ccc1..ab08af7457 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1288,7 +1288,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_exit_tb: /* Reuse the zeroing that exists for goto_ptr. */ if (a0 =3D=3D 0) { - tcg_out_call_int(s, s->code_gen_epilogue, true); + tcg_out_call_int(s, tcg_code_gen_epilogue, true); } else { tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A0, a0); tcg_out_call_int(s, tb_ret_addr, true); @@ -1822,7 +1822,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, tcg_target_call_iarg_regs[1= ], 0); =20 /* Return path for goto_ptr. Set return value to 0 */ - s->code_gen_epilogue =3D s->code_ptr; + tcg_code_gen_epilogue =3D s->code_ptr; tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_A0, TCG_REG_ZERO); =20 /* TB epilogue */ diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index c5e096449b..ac99ccea73 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -1756,7 +1756,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcod= e opc, /* Reuse the zeroing that exists for goto_ptr. */ a0 =3D args[0]; if (a0 =3D=3D 0) { - tgen_gotoi(s, S390_CC_ALWAYS, s->code_gen_epilogue); + tgen_gotoi(s, S390_CC_ALWAYS, tcg_code_gen_epilogue); } else { tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, a0); tgen_gotoi(s, S390_CC_ALWAYS, tb_ret_addr); @@ -2561,7 +2561,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - s->code_gen_epilogue =3D s->code_ptr; + tcg_code_gen_epilogue =3D s->code_ptr; tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, 0); =20 /* TB epilogue */ diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 6e2d755f6a..5b3bc91b05 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -1038,7 +1038,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_nop(s); =20 /* Epilogue for goto_ptr. */ - s->code_gen_epilogue =3D s->code_ptr; + tcg_code_gen_epilogue =3D s->code_ptr; tcg_out_arithi(s, TCG_REG_G0, TCG_REG_I7, 8, RETURN); /* delay slot */ tcg_out_movi_imm13(s, TCG_REG_O0, 0); --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607959803; cv=none; d=zohomail.com; s=zohoarc; b=gmx5sMtE02lEhNX1OlQwG0Nzhyc2XS9Cfy8kDGKaKxogN9OKxP77XKuDpG7UZZPatFP6gh8OxSG+QgY5R209fDYVojdT6Liph5RXh0kHXXIfdQF0GuCfq8kGHC5zilXpqpGzwWTp0G/Bo5/nkgruKgMIPCruYJOsxFhZP9s1wko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607959803; h=Content-Transfer-Encoding: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=kjsZwqo16wWQgyXnGfAD2sB/J/+jiHAWTHwjAIw7NfU=; b=l4I+caJyOLMcMyPfd1Qxj46Gowengg0Y5CwKgr9UgxLEwFVYSw+sv+gqRNtPlSK5pEQuc9/4jo2dOMaZ/uEuHR2D+IHjEMeVsLo860tFnMjWq8KDJixlaeRPR1RKodyh5DjaE6bimnInBrYm2MCRaUIHlJSM0NaW6R2oc0faAsA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607959802919964.5221271698273; Mon, 14 Dec 2020 07:30:02 -0800 (PST) Received: from localhost ([::1]:43034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koocU-0005Rq-LP for importer@patchew.org; Mon, 14 Dec 2020 09:14:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooRv-0001co-I0 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:40 -0500 Received: from mail-oi1-x244.google.com ([2607:f8b0:4864:20::244]:35830) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRl-0003v4-Me for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:36 -0500 Received: by mail-oi1-x244.google.com with SMTP id s2so19253529oij.2 for ; Mon, 14 Dec 2020 06:03:29 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kjsZwqo16wWQgyXnGfAD2sB/J/+jiHAWTHwjAIw7NfU=; b=Rxipfw7PIv+4c19FSYNbuI12v9kOpq8hg+/i3/lvLjjt+IWertoVtl/+e9NRN9sJNb FdjaOB/CCQ6Ym/xFM7Cr+rc9b0OTjH0Y04zZbYM4xmRGA6k2iBloEIzI2vz9NmnSm4DI ARyJmFIW7BU3kIyZSIThhyW9z7tqXCHneivv7u1Hc/d4ZW/3ihj338ElLxP384A2wqm7 uvuMLeU2CZLGundECkmoDBfhliabd5HrmuTSDBo2ABj9f0ms/SGvuEHgCVSw4duhJIwk hKbYXyedEzL8+JJgjEjVptpvv+iajNe2QN1atWqnQw0qarhl/zhhOhiMgclbl8qjadbQ D40A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kjsZwqo16wWQgyXnGfAD2sB/J/+jiHAWTHwjAIw7NfU=; b=t4NjxzJ3UL8coa9YqQG1iMipST75m/Fg320ZBk1eVPOuAMV+NjxEiFxvpDqlejqCrI Xy7FXpYOAi9RHp7EzbeIaOKfJeQivDjGtTvSh9RnU6P+c6CF53Q9WXscnbHEji2Xrdem QkTbCO23Kaz4qWQFrwM2i56Xbu7PpXYMATzDf7teq3HZum4vXgrdci+tWNNaJfDjdN0K FQYW0jHk4l+y5K7Csvf4bI3hYe4ucjpGAKe/Wp6k6n4qdFpNY3bIEiSckhYBVmKIElwz doVAzm3kkDR/niLVuymjOdJZgYi90rlpLX7EQ6gFY7GRF8hx/lcbXbYMbTUbdnY2eJgN U95A== X-Gm-Message-State: AOAM530Qadrf3C2foaoO0SkVUM6QUgjcXZT/4E3fRDv/edudbOLLHIOy 2pvgl+9/y2DgTcKfSDhO2MgKWwul6fnVj9tv X-Google-Smtp-Source: ABdhPJxlJzwoEhBUHkjrd77Z7ODMcm/BZ3XTmTQ/m1fRS6azZr0AH4RnVVdB+GJJfqNs8umizmpgTQ== X-Received: by 2002:aca:5253:: with SMTP id g80mr18112498oib.98.1607954608250; Mon, 14 Dec 2020 06:03:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 07/43] tcg: Add in_code_gen_buffer Date: Mon, 14 Dec 2020 08:02:38 -0600 Message-Id: <20201214140314.18544-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::244; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x244.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Create a function to determine if a pointer is within the buffer. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/tcg/tcg.h | 6 ++++++ accel/tcg/translate-all.c | 26 ++++++++------------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index bb1e97b13b..e4d0ace44b 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -680,6 +680,12 @@ extern __thread TCGContext *tcg_ctx; extern void *tcg_code_gen_epilogue; extern TCGv_env cpu_env; =20 +static inline bool in_code_gen_buffer(const void *p) +{ + const TCGContext *s =3D &tcg_init_ctx; + return (size_t)(p - s->code_gen_buffer) <=3D s->code_gen_buffer_size; +} + static inline size_t temp_idx(TCGTemp *ts) { ptrdiff_t n =3D ts - tcg_ctx->temps; diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 4572b4901f..744f97a717 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -392,27 +392,18 @@ void tb_destroy(TranslationBlock *tb) =20 bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) { - TranslationBlock *tb; - bool r =3D false; - uintptr_t check_offset; - - /* The host_pc has to be in the region of current code buffer. If - * it is not we will not be able to resolve it here. The two cases - * where host_pc will not be correct are: + /* + * The host_pc has to be in the region of the code buffer. + * If it is not we will not be able to resolve it here. + * The two cases where host_pc will not be correct are: * * - fault during translation (instruction fetch) * - fault from helper (not using GETPC() macro) * * Either way we need return early as we can't resolve it here. - * - * We are using unsigned arithmetic so if host_pc < - * tcg_init_ctx.code_gen_buffer check_offset will wrap to way - * above the code_gen_buffer_size */ - check_offset =3D host_pc - (uintptr_t) tcg_init_ctx.code_gen_buffer; - - if (check_offset < tcg_init_ctx.code_gen_buffer_size) { - tb =3D tcg_tb_lookup(host_pc); + if (in_code_gen_buffer((const void *)host_pc)) { + TranslationBlock *tb =3D tcg_tb_lookup(host_pc); if (tb) { cpu_restore_state_from_tb(cpu, tb, host_pc, will_exit); if (tb_cflags(tb) & CF_NOCACHE) { @@ -421,11 +412,10 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_= pc, bool will_exit) tcg_tb_remove(tb); tb_destroy(tb); } - r =3D true; + return true; } } - - return r; + return false; } =20 static void page_init(void) --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607978584; cv=none; d=zohomail.com; s=zohoarc; b=TYvjTqKrNqlNGj0oeWmrRYq1etaHaWQnQPuYnLS8i8V8pRvoiNrseZRAXo59EoorDr7tEwKgXBTQyly86xSfmlj2SUOY5zx3CUIA6MNdn40MIRQKC9wRFn/uOYnejW5//1F1q0nHVdbK5KefNc846cNpFwZNEU+hF/ymH1wnKpc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607978584; h=Content-Transfer-Encoding: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=QypuJA60qQZAogzP9afzyC3XdL/acRRoiwUGlGjqcCU=; b=XS9YQJgg8/mDAq6AYSnO+c1IB5nzJjKbJRp+F1+xIHXcDi4GOVpmIl0Yl8cWU0xYmfqxB6n3Yp8gPOhTxGhpzVQZPzPSkblY19VzTf5aaxIpr2iSYi1GHgPr/WkpZHPJDA0gK6uiG072lnNYBe61Emafd0dKYBPlcx8qWLy86WA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607978583931141.839129330545; Mon, 14 Dec 2020 12:43:03 -0800 (PST) Received: from localhost ([::1]:43368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koocZ-0005Zj-2h for importer@patchew.org; Mon, 14 Dec 2020 09:14:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooRx-0001dR-CX for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:41 -0500 Received: from mail-oo1-xc42.google.com ([2607:f8b0:4864:20::c42]:44876) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRp-0003vU-1V for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:41 -0500 Received: by mail-oo1-xc42.google.com with SMTP id j21so1360365oou.11 for ; Mon, 14 Dec 2020 06:03:31 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QypuJA60qQZAogzP9afzyC3XdL/acRRoiwUGlGjqcCU=; b=V+Xs3cu54ZLUe6q5DD0m+IY/zpJTy/de6kFSJpVbmH4PH+P2OQD4uRMmOm4/diHO5E Jyb6UbJVOshwl6xHF4H5ZwBuuMX+vHOasifAODaAvcWksci/Sruyw6idXltlvosvE9tH 4xPF+UNOJiVYuH2X/M6iGtCQDtVld6H9ZkNPd0AoezkEnCtM4qpBWGPb3UbEzZcAv09M 2aSpXVkCRkclyRViKUYPtliyO2SQbhrASoCdwPZsQYflB6soi8+deKOEJUzOQeqwQp+F QixeIvrH5ly0NdGwecn8CFkfxm6xWBML67C/qe/U+ntCpNRNX661IZUpi/cTdq8wC92C 4eBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QypuJA60qQZAogzP9afzyC3XdL/acRRoiwUGlGjqcCU=; b=JlPWFb4TG6HBertnS+YGfI4jUEgJ0jhn9xUV/jAGgiEbhO18OXpF8C/lTR1F6HhQU9 H97TXbH8R/jCCQLtjqxR3U9iKBCRsmW/k9UeF89pHEYnu9csrL/yaNkX/M5qmck+4oxL 5/FRs3Dz5pnsvCcxncgprwfIAqonNIl/O74pSssbrFADSVsTklu96WPWiWNin/KU1LPl ao7rAkKq+auX8xlz+6dByeJgQ12CrSZOKK9+zJcOP7kdBZrZVXWjbw/fZCrGuMMgsNsy yYeoKSm90SVArwXSvsWK7nKzGTNMkURXQj21AFWLI8QoOoGTGaTMB/9CeyN41qD0E3m2 QwVw== X-Gm-Message-State: AOAM5333lsS7sI7Azfbr5Ur/6fqJZ8YnhvW/DZTvTM5R37rU8S90peVe r8sXuLQhciLcO9i945erLf5KKUi+l1J9Q94+ X-Google-Smtp-Source: ABdhPJy1g0NzT9gqWi9pGZUWQgcBuu85KcyxmbekenMbevz9Yux4hi3xIhQMUrblBF1Zq2BhipETIA== X-Received: by 2002:a4a:d998:: with SMTP id k24mr16269014oou.23.1607954610154; Mon, 14 Dec 2020 06:03:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 08/43] tcg: Introduce tcg_splitwx_to_{rx,rw} Date: Mon, 14 Dec 2020 08:02:39 -0600 Message-Id: <20201214140314.18544-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::c42; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc42.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Add two helper functions, using a global variable to hold the displacement. The displacement is currently always 0, so no change in behaviour. Begin using the functions in tcg common code only. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- accel/tcg/tcg-runtime.h | 2 +- include/disas/disas.h | 2 +- include/exec/exec-all.h | 2 +- include/exec/log.h | 2 +- include/tcg/tcg.h | 26 ++++++++++++++---- accel/tcg/cpu-exec.c | 2 +- accel/tcg/tcg-runtime.c | 2 +- accel/tcg/translate-all.c | 33 +++++++++++------------ disas.c | 4 ++- tcg/tcg.c | 56 ++++++++++++++++++++++++++++++++++----- tcg/tci.c | 5 ++-- accel/tcg/trace-events | 2 +- tcg/tcg-pool.c.inc | 6 ++++- 13 files changed, 104 insertions(+), 40 deletions(-) diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h index 4eda24e63a..c276c8beb5 100644 --- a/accel/tcg/tcg-runtime.h +++ b/accel/tcg/tcg-runtime.h @@ -24,7 +24,7 @@ DEF_HELPER_FLAGS_1(clrsb_i64, TCG_CALL_NO_RWG_SE, i64, i6= 4) DEF_HELPER_FLAGS_1(ctpop_i32, TCG_CALL_NO_RWG_SE, i32, i32) DEF_HELPER_FLAGS_1(ctpop_i64, TCG_CALL_NO_RWG_SE, i64, i64) =20 -DEF_HELPER_FLAGS_1(lookup_tb_ptr, TCG_CALL_NO_WG_SE, ptr, env) +DEF_HELPER_FLAGS_1(lookup_tb_ptr, TCG_CALL_NO_WG_SE, cptr, env) =20 DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env) =20 diff --git a/include/disas/disas.h b/include/disas/disas.h index 36c33f6f19..d363e95ede 100644 --- a/include/disas/disas.h +++ b/include/disas/disas.h @@ -7,7 +7,7 @@ #include "cpu.h" =20 /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, void *code, unsigned long size); +void disas(FILE *out, const void *code, unsigned long size); void target_disas(FILE *out, CPUState *cpu, target_ulong code, target_ulong size); =20 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 94fe05daaa..d2325a5834 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -448,7 +448,7 @@ int probe_access_flags(CPUArchState *env, target_ulong = addr, * Note: the address of search data can be obtained by adding @size to @pt= r. */ struct tb_tc { - void *ptr; /* pointer to the translated code */ + const void *ptr; /* pointer to the translated code */ size_t size; }; =20 diff --git a/include/exec/log.h b/include/exec/log.h index e02fff5de1..3c7fa65ead 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -56,7 +56,7 @@ static inline void log_target_disas(CPUState *cpu, target= _ulong start, rcu_read_unlock(); } =20 -static inline void log_disas(void *code, unsigned long size) +static inline void log_disas(const void *code, unsigned long size) { QemuLogFile *logfile; rcu_read_lock(); diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index e4d0ace44b..249f83be72 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -678,6 +678,7 @@ struct TCGContext { extern TCGContext tcg_init_ctx; extern __thread TCGContext *tcg_ctx; extern void *tcg_code_gen_epilogue; +extern uintptr_t tcg_splitwx_diff; extern TCGv_env cpu_env; =20 static inline bool in_code_gen_buffer(const void *p) @@ -686,6 +687,21 @@ static inline bool in_code_gen_buffer(const void *p) return (size_t)(p - s->code_gen_buffer) <=3D s->code_gen_buffer_size; } =20 +#ifdef CONFIG_DEBUG_TCG +const void *tcg_splitwx_to_rx(void *rw); +void *tcg_splitwx_to_rw(const void *rx); +#else +static inline const void *tcg_splitwx_to_rx(void *rw) +{ + return rw ? rw + tcg_splitwx_diff : NULL; +} + +static inline void *tcg_splitwx_to_rw(const void *rx) +{ + return rx ? (void *)rx - tcg_splitwx_diff : NULL; +} +#endif + static inline size_t temp_idx(TCGTemp *ts) { ptrdiff_t n =3D ts - tcg_ctx->temps; @@ -1106,7 +1122,7 @@ static inline TCGLabel *arg_label(TCGArg i) * correct result. */ =20 -static inline ptrdiff_t tcg_ptr_byte_diff(void *a, void *b) +static inline ptrdiff_t tcg_ptr_byte_diff(const void *a, const void *b) { return a - b; } @@ -1120,9 +1136,9 @@ static inline ptrdiff_t tcg_ptr_byte_diff(void *a, vo= id *b) * to the destination address. */ =20 -static inline ptrdiff_t tcg_pcrel_diff(TCGContext *s, void *target) +static inline ptrdiff_t tcg_pcrel_diff(TCGContext *s, const void *target) { - return tcg_ptr_byte_diff(target, s->code_ptr); + return tcg_ptr_byte_diff(target, tcg_splitwx_to_rx(s->code_ptr)); } =20 /** @@ -1228,9 +1244,9 @@ static inline unsigned get_mmuidx(TCGMemOpIdx oi) #define TB_EXIT_REQUESTED 3 =20 #ifdef CONFIG_TCG_INTERPRETER -uintptr_t tcg_qemu_tb_exec(CPUArchState *env, void *tb_ptr); +uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const void *tb_ptr); #else -typedef uintptr_t tcg_prologue_fn(CPUArchState *env, void *tb_ptr); +typedef uintptr_t tcg_prologue_fn(CPUArchState *env, const void *tb_ptr); extern tcg_prologue_fn *tcg_qemu_tb_exec; #endif =20 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 58aea605d8..1e3cb570f6 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -150,7 +150,7 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cp= u, TranslationBlock *itb) uintptr_t ret; TranslationBlock *last_tb; int tb_exit; - uint8_t *tb_ptr =3D itb->tc.ptr; + const void *tb_ptr =3D itb->tc.ptr; =20 qemu_log_mask_and_addr(CPU_LOG_EXEC, itb->pc, "Trace %d: %p [" diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c index f85dfefeab..d736f4ff55 100644 --- a/accel/tcg/tcg-runtime.c +++ b/accel/tcg/tcg-runtime.c @@ -145,7 +145,7 @@ uint64_t HELPER(ctpop_i64)(uint64_t arg) return ctpop64(arg); } =20 -void *HELPER(lookup_tb_ptr)(CPUArchState *env) +const void *HELPER(lookup_tb_ptr)(CPUArchState *env) { CPUState *cpu =3D env_cpu(env); TranslationBlock *tb; diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 744f97a717..7b85ddacd2 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -269,9 +269,9 @@ static uint8_t *encode_sleb128(uint8_t *p, target_long = val) =20 /* Decode a signed leb128 sequence at *PP; increment *PP past the decoded value. Return the decoded value. */ -static target_long decode_sleb128(uint8_t **pp) +static target_long decode_sleb128(const uint8_t **pp) { - uint8_t *p =3D *pp; + const uint8_t *p =3D *pp; target_long val =3D 0; int byte, shift =3D 0; =20 @@ -342,7 +342,7 @@ static int cpu_restore_state_from_tb(CPUState *cpu, Tra= nslationBlock *tb, target_ulong data[TARGET_INSN_START_WORDS] =3D { tb->pc }; uintptr_t host_pc =3D (uintptr_t)tb->tc.ptr; CPUArchState *env =3D cpu->env_ptr; - uint8_t *p =3D tb->tc.ptr + tb->tc.size; + const uint8_t *p =3D tb->tc.ptr + tb->tc.size; int i, j, num_insns =3D tb->icount; #ifdef CONFIG_PROFILER TCGProfile *prof =3D &tcg_ctx->prof; @@ -393,7 +393,7 @@ void tb_destroy(TranslationBlock *tb) bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) { /* - * The host_pc has to be in the region of the code buffer. + * The host_pc has to be in the rx region of the code buffer. * If it is not we will not be able to resolve it here. * The two cases where host_pc will not be correct are: * @@ -402,7 +402,7 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc= , bool will_exit) * * Either way we need return early as we can't resolve it here. */ - if (in_code_gen_buffer((const void *)host_pc)) { + if (in_code_gen_buffer((const void *)(host_pc - tcg_splitwx_diff))) { TranslationBlock *tb =3D tcg_tb_lookup(host_pc); if (tb) { cpu_restore_state_from_tb(cpu, tb, host_pc, will_exit); @@ -1712,7 +1712,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } =20 gen_code_buf =3D tcg_ctx->code_gen_ptr; - tb->tc.ptr =3D gen_code_buf; + tb->tc.ptr =3D tcg_splitwx_to_rx(gen_code_buf); tb->pc =3D pc; tb->cs_base =3D cs_base; tb->flags =3D flags; @@ -1806,15 +1806,19 @@ TranslationBlock *tb_gen_code(CPUState *cpu, if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) && qemu_log_in_addr_range(tb->pc)) { FILE *logfile =3D qemu_log_lock(); - int code_size, data_size =3D 0; + int code_size, data_size; + const tcg_target_ulong *rx_data_gen_ptr; size_t chunk_start; int insn =3D 0; =20 if (tcg_ctx->data_gen_ptr) { - code_size =3D tcg_ctx->data_gen_ptr - tb->tc.ptr; + rx_data_gen_ptr =3D tcg_splitwx_to_rx(tcg_ctx->data_gen_ptr); + code_size =3D (const void *)rx_data_gen_ptr - tb->tc.ptr; data_size =3D gen_code_size - code_size; } else { + rx_data_gen_ptr =3D 0; code_size =3D gen_code_size; + data_size =3D 0; } =20 /* Dump header and the first instruction */ @@ -1849,16 +1853,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu, if (data_size) { int i; qemu_log(" data: [size=3D%d]\n", data_size); - for (i =3D 0; i < data_size; i +=3D sizeof(tcg_target_ulong)) { - if (sizeof(tcg_target_ulong) =3D=3D 8) { - qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n= ", - (uintptr_t)tcg_ctx->data_gen_ptr + i, - *(uint64_t *)(tcg_ctx->data_gen_ptr + i)); - } else { - qemu_log("0x%08" PRIxPTR ": .long 0x%08x\n", - (uintptr_t)tcg_ctx->data_gen_ptr + i, - *(uint32_t *)(tcg_ctx->data_gen_ptr + i)); - } + for (i =3D 0; i < data_size / sizeof(tcg_target_ulong); i++) { + qemu_log("0x%08" PRIxPTR ": .quad 0x%" TCG_PRIlx "\n", + (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i= ]); } } qemu_log("\n"); diff --git a/disas.c b/disas.c index 7c18d7d2a7..de1de7be94 100644 --- a/disas.c +++ b/disas.c @@ -299,8 +299,10 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_= t size) } =20 /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, void *code, unsigned long size) +void disas(FILE *out, const void *ccode, unsigned long size) { + /* TODO: Push constness through the disas backends. */ + void *code =3D (void *)ccode; uintptr_t pc; int count; CPUDebug s; diff --git a/tcg/tcg.c b/tcg/tcg.c index 588686617d..5bb1edb804 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -162,6 +162,7 @@ static TCGContext **tcg_ctxs; static unsigned int n_tcg_ctxs; TCGv_env cpu_env =3D 0; void *tcg_code_gen_epilogue; +uintptr_t tcg_splitwx_diff; =20 #ifndef CONFIG_TCG_INTERPRETER tcg_prologue_fn *tcg_qemu_tb_exec; @@ -406,8 +407,9 @@ static void tcg_region_trees_init(void) } } =20 -static struct tcg_region_tree *tc_ptr_to_region_tree(void *p) +static struct tcg_region_tree *tc_ptr_to_region_tree(const void *cp) { + void *p =3D tcg_splitwx_to_rw(cp); size_t region_idx; =20 if (p < region.start_aligned) { @@ -701,6 +703,7 @@ void tcg_region_init(void) size_t region_size; size_t n_regions; size_t i; + uintptr_t splitwx_diff; =20 n_regions =3D tcg_n_regions(); =20 @@ -731,6 +734,7 @@ void tcg_region_init(void) region.end -=3D page_size; =20 /* set guard pages */ + splitwx_diff =3D tcg_splitwx_diff; for (i =3D 0; i < region.n; i++) { void *start, *end; int rc; @@ -738,6 +742,10 @@ void tcg_region_init(void) tcg_region_bounds(i, &start, &end); rc =3D qemu_mprotect_none(end, page_size); g_assert(!rc); + if (splitwx_diff) { + rc =3D qemu_mprotect_none(end + splitwx_diff, page_size); + g_assert(!rc); + } } =20 tcg_region_trees_init(); @@ -752,6 +760,29 @@ void tcg_region_init(void) #endif } =20 +#ifdef CONFIG_DEBUG_TCG +const void *tcg_splitwx_to_rx(void *rw) +{ + /* Pass NULL pointers unchanged. */ + if (rw) { + g_assert(in_code_gen_buffer(rw)); + rw +=3D tcg_splitwx_diff; + } + return rw; +} + +void *tcg_splitwx_to_rw(const void *rx) +{ + /* Pass NULL pointers unchanged. */ + if (rx) { + rx -=3D tcg_splitwx_diff; + /* Assert that we end with a pointer in the rw region. */ + g_assert(in_code_gen_buffer(rx)); + } + return (void *)rx; +} +#endif /* CONFIG_DEBUG_TCG */ + static void alloc_tcg_plugin_context(TCGContext *s) { #ifdef CONFIG_PLUGIN @@ -1061,8 +1092,15 @@ void tcg_prologue_init(TCGContext *s) s->code_buf =3D buf0; s->data_gen_ptr =3D NULL; =20 + /* + * The region trees are not yet configured, but tcg_splitwx_to_rx + * needs the bounds for an assert. + */ + region.start =3D buf0; + region.end =3D buf0 + total_size; + #ifndef CONFIG_TCG_INTERPRETER - tcg_qemu_tb_exec =3D (tcg_prologue_fn *)buf0; + tcg_qemu_tb_exec =3D (tcg_prologue_fn *)tcg_splitwx_to_rx(buf0); #endif =20 /* Compute a high-water mark, at which we voluntarily flush the buffer @@ -1087,7 +1125,7 @@ void tcg_prologue_init(TCGContext *s) =20 buf1 =3D s->code_ptr; #ifndef CONFIG_TCG_INTERPRETER - flush_idcache_range((uintptr_t)buf0, (uintptr_t)buf0, + flush_idcache_range((uintptr_t)tcg_splitwx_to_rx(buf0), (uintptr_t)buf= 0, tcg_ptr_byte_diff(buf1, buf0)); #endif =20 @@ -4227,8 +4265,13 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) =20 tcg_reg_alloc_start(s); =20 - s->code_buf =3D tb->tc.ptr; - s->code_ptr =3D tb->tc.ptr; + /* + * Reset the buffer pointers when restarting after overflow. + * TODO: Move this into translate-all.c with the rest of the + * buffer management. Having only this done here is confusing. + */ + s->code_buf =3D tcg_splitwx_to_rw(tb->tc.ptr); + s->code_ptr =3D s->code_buf; =20 #ifdef TCG_TARGET_NEED_LDST_LABELS QSIMPLEQ_INIT(&s->ldst_labels); @@ -4333,7 +4376,8 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) =20 #ifndef CONFIG_TCG_INTERPRETER /* flush instruction cache */ - flush_idcache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_buf, + flush_idcache_range((uintptr_t)tcg_splitwx_to_rx(s->code_buf), + (uintptr_t)s->code_buf, tcg_ptr_byte_diff(s->code_ptr, s->code_buf)); #endif =20 diff --git a/tcg/tci.c b/tcg/tci.c index d996eb7cf8..262a2b39ce 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -475,9 +475,10 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TC= GCond condition) #endif =20 /* Interpret pseudo code in tb. */ -uintptr_t tcg_qemu_tb_exec(CPUArchState *env, void *v_tb_ptr) +uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const void *v_tb_ptr) { - uint8_t *tb_ptr =3D v_tb_ptr; + /* TODO: Propagate const through this file. */ + uint8_t *tb_ptr =3D (uint8_t *)v_tb_ptr; tcg_target_ulong regs[TCG_TARGET_NB_REGS]; long tcg_temps[CPU_TEMP_BUF_NLONGS]; uintptr_t sp_value =3D (uintptr_t)(tcg_temps + CPU_TEMP_BUF_NLONGS); diff --git a/accel/tcg/trace-events b/accel/tcg/trace-events index 385b9f749b..6eefb37f5d 100644 --- a/accel/tcg/trace-events +++ b/accel/tcg/trace-events @@ -7,4 +7,4 @@ exec_tb_nocache(void *tb, uintptr_t pc) "tb:%p pc=3D0x%"PRI= xPTR exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=3D0x%x" =20 # translate-all.c -translate_block(void *tb, uintptr_t pc, uint8_t *tb_code) "tb:%p, pc:0x%"P= RIxPTR", tb_code:%p" +translate_block(void *tb, uintptr_t pc, const void *tb_code) "tb:%p, pc:0x= %"PRIxPTR", tb_code:%p" diff --git a/tcg/tcg-pool.c.inc b/tcg/tcg-pool.c.inc index 82cbcc89bd..90c2e63b7f 100644 --- a/tcg/tcg-pool.c.inc +++ b/tcg/tcg-pool.c.inc @@ -140,6 +140,8 @@ static int tcg_out_pool_finalize(TCGContext *s) =20 for (; p !=3D NULL; p =3D p->next) { size_t size =3D sizeof(tcg_target_ulong) * p->nlong; + uintptr_t value; + if (!l || l->nlong !=3D p->nlong || memcmp(l->data, p->data, size)= ) { if (unlikely(a > s->code_gen_highwater)) { return -1; @@ -148,7 +150,9 @@ static int tcg_out_pool_finalize(TCGContext *s) a +=3D size; l =3D p; } - if (!patch_reloc(p->label, p->rtype, (intptr_t)a - size, p->addend= )) { + + value =3D (uintptr_t)tcg_splitwx_to_rx(a) - size; + if (!patch_reloc(p->label, p->rtype, value, p->addend)) { return -2; } } --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607975608; cv=none; d=zohomail.com; s=zohoarc; b=bxKLBl8JsBs8ChE3j1Njzej6h/eVPVg9scY+Niz5c7OF9NeoyPwtt0dr9JfYnE1siBmlhJnUOq6q9ZFtuF6xnRXsQN+x/HMWKJ3OpNqL9LQhpy5uK0b6+MN0LLGV/deVBxYL0LXlSp1kJ8tgb9fNe/DiBux+8PhD5+6K514hgTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607975608; h=Content-Transfer-Encoding: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=3VsbV4FnPPISc6ywNLv+k5MiXrPyQIckC3OGJZ+UW18=; b=KqzK2Kwtxdi5F23Qz09UcV7bd0NtCaH+EWXoWOhPPzwkMtaQSv6I4NsCF8Eip8eNRJ3IqFXjjrfhHueGbctHgjxVHmXMQ+GbXI01W/Si7exxToJmnHW2NimPXkeUvy0Hv6cwuzXpRWB4dKvxLW3Jbi4wuNrJVmMNH++qV47dyAI= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607975608319980.358753493264; Mon, 14 Dec 2020 11:53:28 -0800 (PST) Received: from localhost ([::1]:52106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koof5-0000md-Gw for importer@patchew.org; Mon, 14 Dec 2020 09:17:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooS5-0001gQ-EI for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:49 -0500 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:38987) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRq-0003ve-M0 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:49 -0500 Received: by mail-oi1-x242.google.com with SMTP id w124so16111412oia.6 for ; Mon, 14 Dec 2020 06:03:33 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3VsbV4FnPPISc6ywNLv+k5MiXrPyQIckC3OGJZ+UW18=; b=C8WBcWlQiJwDqBWuEqZFsN/Sm1XJSyiFWtu44gDCT8+WfsngplIGSReGBJC4BXD5ch juNrG7smvJmpCFP0kaLiIOkT973PUQSOhxuKJtFk28wI92LNurlgH6IRhVhvJz+EgnC6 Ae6FzHTDgQwNMCD0w12+Dcw2h8APIyrADkUahPblqQC5iFR7fDMS3XGJp75iag5xjpBN G7pUV8lajz9ssTp4l6/JBWFsGjjNmf8yG166XZ1dYVcTndBI7r5vGUv+rlESucRV2+bv 6VTPfl3kOcrWuP3qYBtSQ3ugYM9d2T3IhexscNrbCVGInMxeEq0KNcUIqVSEi+CwuGvy XGJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3VsbV4FnPPISc6ywNLv+k5MiXrPyQIckC3OGJZ+UW18=; b=FIz7KsXCUGbhaiD23G4rmY88EE9YNP1tyU8DSfQZifkcjEE6/ldB7YT8lrysHAIYey AS2O4C+l64RZgfzdmS3e6nV3NHQ9kBM76HE2Sz18UM54WcZWLMygxhtagJxzxOwmu9Jp 8itSStw4TB3Pe4tWikuqKXQoaN6Il2RzVbRXcnjuuj7FeIRO/zB9s9awycFvpO/eWXLB gisRyji296xVYChna+NtEFGzWMhYcdyoLyimfg4UnjahOS32uBSWbi2u1gxvMrUYmOj0 dJzeWhs3nhjDZ4+9xhGrNCBPactzz2X2+OSHoOd/dc5D1FO04xTi18nZs4Xj1nxKKdY8 6/CA== X-Gm-Message-State: AOAM533HDILKTgQ/vwdE/0OE+rN8vb989jQzgLSuHEswEiy1pE5Jxsyz g3Y2lpKdgjc/c6GtIr04D8f4GO5gt7lrxxQ0 X-Google-Smtp-Source: ABdhPJyu0X6mDiSie/5FVeS9kBHyGYvpTMKsj7T1ghENZ2IbwiYvzaUhiddfF8HwoDDgHWuahNeqKA== X-Received: by 2002:aca:5c08:: with SMTP id q8mr18484410oib.54.1607954612668; Mon, 14 Dec 2020 06:03:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 09/43] tcg: Adjust TCGLabel for const Date: Mon, 14 Dec 2020 08:02:40 -0600 Message-Id: <20201214140314.18544-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::242; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x242.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, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Change TCGLabel.u.value_ptr to const, and initialize it with tcg_splitwx_to_rx. Propagate const through tcg/host/ only as far as needed to avoid errors from the value_ptr change. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- include/tcg/tcg.h | 2 +- tcg/tcg.c | 2 +- tcg/aarch64/tcg-target.c.inc | 2 +- tcg/arm/tcg-target.c.inc | 2 +- tcg/mips/tcg-target.c.inc | 5 +++-- tcg/ppc/tcg-target.c.inc | 4 ++-- tcg/s390/tcg-target.c.inc | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 249f83be72..b2ba16ea8c 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -261,7 +261,7 @@ struct TCGLabel { unsigned refs : 16; union { uintptr_t value; - tcg_insn_unit *value_ptr; + const tcg_insn_unit *value_ptr; } u; QSIMPLEQ_HEAD(, TCGRelocation) relocs; QSIMPLEQ_ENTRY(TCGLabel) next; diff --git a/tcg/tcg.c b/tcg/tcg.c index 5bb1edb804..98cd42d311 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -306,7 +306,7 @@ static void tcg_out_label(TCGContext *s, TCGLabel *l, t= cg_insn_unit *ptr) { tcg_debug_assert(!l->has_value); l->has_value =3D 1; - l->u.value_ptr =3D ptr; + l->u.value_ptr =3D tcg_splitwx_to_rx(ptr); } =20 TCGLabel *gen_new_label(void) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 76f8ae48ad..96dc9f4d0b 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1306,7 +1306,7 @@ static void tcg_out_cmp(TCGContext *s, TCGType ext, T= CGReg a, } } =20 -static inline void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) +static void tcg_out_goto(TCGContext *s, const tcg_insn_unit *target) { ptrdiff_t offset =3D target - s->code_ptr; tcg_debug_assert(offset =3D=3D sextract64(offset, 0, 26)); diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 1e32bf42b8..f8f485d807 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1019,7 +1019,7 @@ static inline void tcg_out_st8(TCGContext *s, int con= d, * with the code buffer limited to 16MB we wouldn't need the long case. * But we also use it for the tail-call to the qemu_ld/st helpers, which d= oes. */ -static void tcg_out_goto(TCGContext *s, int cond, tcg_insn_unit *addr) +static void tcg_out_goto(TCGContext *s, int cond, const tcg_insn_unit *add= r) { intptr_t addri =3D (intptr_t)addr; ptrdiff_t disp =3D tcg_pcrel_diff(s, addr); diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index f641105f9a..a3f838fa51 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -144,7 +144,8 @@ static tcg_insn_unit *bswap32_addr; static tcg_insn_unit *bswap32u_addr; static tcg_insn_unit *bswap64_addr; =20 -static inline uint32_t reloc_pc16_val(tcg_insn_unit *pc, tcg_insn_unit *ta= rget) +static inline uint32_t reloc_pc16_val(tcg_insn_unit *pc, + const tcg_insn_unit *target) { /* Let the compiler perform the right-shift as part of the arithmetic.= */ ptrdiff_t disp =3D target - (pc + 1); @@ -152,7 +153,7 @@ static inline uint32_t reloc_pc16_val(tcg_insn_unit *pc= , tcg_insn_unit *target) return disp & 0xffff; } =20 -static inline void reloc_pc16(tcg_insn_unit *pc, tcg_insn_unit *target) +static inline void reloc_pc16(tcg_insn_unit *pc, const tcg_insn_unit *targ= et) { *pc =3D deposit32(*pc, 0, 16, reloc_pc16_val(pc, target)); } diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 15d5c78798..d108f01fec 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -184,7 +184,7 @@ static inline bool in_range_b(tcg_target_long target) return target =3D=3D sextract64(target, 0, 26); } =20 -static uint32_t reloc_pc24_val(tcg_insn_unit *pc, tcg_insn_unit *target) +static uint32_t reloc_pc24_val(tcg_insn_unit *pc, const tcg_insn_unit *tar= get) { ptrdiff_t disp =3D tcg_ptr_byte_diff(target, pc); tcg_debug_assert(in_range_b(disp)); @@ -201,7 +201,7 @@ static bool reloc_pc24(tcg_insn_unit *pc, tcg_insn_unit= *target) return false; } =20 -static uint16_t reloc_pc14_val(tcg_insn_unit *pc, tcg_insn_unit *target) +static uint16_t reloc_pc14_val(tcg_insn_unit *pc, const tcg_insn_unit *tar= get) { ptrdiff_t disp =3D tcg_ptr_byte_diff(target, pc); tcg_debug_assert(disp =3D=3D (int16_t) disp); diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index ac99ccea73..1b5c4f0ab0 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -1302,7 +1302,7 @@ static void tgen_extract(TCGContext *s, TCGReg dest, = TCGReg src, tcg_out_risbg(s, dest, src, 64 - len, 63, 64 - ofs, 1); } =20 -static void tgen_gotoi(TCGContext *s, int cc, tcg_insn_unit *dest) +static void tgen_gotoi(TCGContext *s, int cc, const tcg_insn_unit *dest) { ptrdiff_t off =3D dest - s->code_ptr; if (off =3D=3D (int16_t)off) { --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607977295; cv=none; d=zohomail.com; s=zohoarc; b=Ay2uXNs1t5hFXSQmdh8qK6SHY5azpWIJN7cj2B/Lg3GTRTHTcuiBnAKWAm1yZ6FG++guYfwnnmVOX1HMphiw9gpSU5rznT+xiw9de5oO/PdUQCVE96eVVRMMpOGMZG+QWE7Xbf68cTBASifRs9m3lU63v2vUqQRMw/XLzNxnabM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607977295; h=Content-Transfer-Encoding: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=rFFv7j1bplLn1/lsBPfcIJFb/QjuYaDySScnrY2Pn6Q=; b=ZNzfl7spfGuI9iAgdry2IMDVdHEJkGPQvbbJyYpC6cCH2K0ucqaR4Ue/9R9m17dZZ3VCAEJUnQOvzY5x1VmMVaFiwWWjZPb37uIG8WunkkSAvK2yI6PVX4qBleJfmEKWgp+XXmeDklflht7S37YYXNiDQ9vx0iZVTqxmgfN1GDU= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160797729503719.968612056824554; Mon, 14 Dec 2020 12:21:35 -0800 (PST) Received: from localhost ([::1]:55256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koooh-0005C8-Ln for importer@patchew.org; Mon, 14 Dec 2020 09:27:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooS8-0001lg-Ip for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:52 -0500 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]:36060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRs-0003vz-Qv for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:52 -0500 Received: by mail-oi1-x233.google.com with SMTP id 9so12096772oiq.3 for ; Mon, 14 Dec 2020 06:03:35 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=rFFv7j1bplLn1/lsBPfcIJFb/QjuYaDySScnrY2Pn6Q=; b=qsVOvGGIdiMhap+kfFPVNFsgbfR1OGpQdw4bjS92cN8tti7jyhqoj1n32mjyvGiV8j Gozf2UezOxH8sFtYWmxcP9PBKPI9m4gCiel32SygbKd2Te18bijY2BqB1IjsLat6UDbS dE3N/toZD+i7Mhwl8nlIuE9gnby4uhNRoIuKBqGckI+qLJT0Dm0/MQabpxssTI8pn/S4 sq2tvjWgN5PRLWUzKHUEaFAx4mfpkT6GJvmEUsXtPeSFdpLmHiJwXucnowFSIUMho7fs 2CKEuePn1tx624TdA5j10qnByGU+cVzYdkUuBH2BPBb3ghezZV0hBeHnM/xwS39qI9fb fB/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rFFv7j1bplLn1/lsBPfcIJFb/QjuYaDySScnrY2Pn6Q=; b=IQNA/M4D4aeuPTxyXqzS/p+QfdzciykabDWEw8MFbwfsggicpi8kFAu+uVhoFmVt8r pBxnDar7vBi18FwQ/moMMrop+gM3tNlKUaJ65Hft7knSqct5cuQF1jL79Arlx7oLkoeP B3mUXSTvQDb5whNbdCWrV9YLJ352oZxaBUnjoqHQKhDIUeXU1H5q/3rYovnvW9vB73O+ lWgdoYpigNzAtBq42KVP2bpvPveamIR8bFjI6QnqsC4WzE+NfTojpSwGKbhXMs0l11Av Gwjq0A4FVxpALZ2nUCPGXys5TDawkcM4aC4yogAyX7caDVhfuiAcPq1WcO/zvzP3Y0r9 0BSQ== X-Gm-Message-State: AOAM533tRHPUP+SbZPh36Vv52abbGFa/I/WhrAEaY6NxKtj0E6zVq6kL brLC56XZmPWJZYrN3ZmYvUz3tTFHarHPREcN X-Google-Smtp-Source: ABdhPJxECF94h7vBsmVqHbV2fQyKruekgbcHDM0YXSkE/LhQ5b9ZN1d05rSUiQyMbiFkvs13sB+BHA== X-Received: by 2002:aca:4ed3:: with SMTP id c202mr17406390oib.95.1607954614141; Mon, 14 Dec 2020 06:03:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 10/43] tcg: Adjust tcg_out_call for const Date: Mon, 14 Dec 2020 08:02:41 -0600 Message-Id: <20201214140314.18544-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" We must change all targets at once, since all must match the declaration in tcg.c. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/tcg.c | 2 +- tcg/aarch64/tcg-target.c.inc | 2 +- tcg/arm/tcg-target.c.inc | 2 +- tcg/i386/tcg-target.c.inc | 4 ++-- tcg/mips/tcg-target.c.inc | 6 +++--- tcg/ppc/tcg-target.c.inc | 8 ++++---- tcg/riscv/tcg-target.c.inc | 6 +++--- tcg/s390/tcg-target.c.inc | 2 +- tcg/sparc/tcg-target.c.inc | 4 ++-- tcg/tci/tcg-target.c.inc | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 98cd42d311..435b0f1662 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -149,7 +149,7 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCG= Reg arg, TCGReg arg1, intptr_t arg2); static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, TCGReg base, intptr_t ofs); -static void tcg_out_call(TCGContext *s, tcg_insn_unit *target); +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target); static int tcg_target_const_match(tcg_target_long val, TCGType type, const TCGArgConstraint *arg_ct); #ifdef TCG_TARGET_NEED_LDST_LABELS diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 96dc9f4d0b..6d8152c468 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1329,7 +1329,7 @@ static inline void tcg_out_callr(TCGContext *s, TCGRe= g reg) tcg_out_insn(s, 3207, BLR, reg); } =20 -static inline void tcg_out_call(TCGContext *s, tcg_insn_unit *target) +static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) { ptrdiff_t offset =3D target - s->code_ptr; if (offset =3D=3D sextract64(offset, 0, 26)) { diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index f8f485d807..a197e6bc45 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1033,7 +1033,7 @@ static void tcg_out_goto(TCGContext *s, int cond, con= st tcg_insn_unit *addr) =20 /* The call case is mostly used for helpers - so it's not unreasonable * for them to be beyond branch range */ -static void tcg_out_call(TCGContext *s, tcg_insn_unit *addr) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *addr) { intptr_t addri =3D (intptr_t)addr; ptrdiff_t disp =3D tcg_pcrel_diff(s, addr); diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 424dd1cdcf..095553ce28 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1591,7 +1591,7 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGR= eg dest, TCGReg arg1, } } =20 -static void tcg_out_branch(TCGContext *s, int call, tcg_insn_unit *dest) +static void tcg_out_branch(TCGContext *s, int call, const tcg_insn_unit *d= est) { intptr_t disp =3D tcg_pcrel_diff(s, dest) - 5; =20 @@ -1610,7 +1610,7 @@ static void tcg_out_branch(TCGContext *s, int call, t= cg_insn_unit *dest) } } =20 -static inline void tcg_out_call(TCGContext *s, tcg_insn_unit *dest) +static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) { tcg_out_branch(s, 1, dest); } diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index a3f838fa51..6d2c369a85 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -517,7 +517,7 @@ static void tcg_out_opc_sa64(TCGContext *s, MIPSInsn op= c1, MIPSInsn opc2, * Type jump. * Returns true if the branch was in range and the insn was emitted. */ -static bool tcg_out_opc_jmp(TCGContext *s, MIPSInsn opc, void *target) +static bool tcg_out_opc_jmp(TCGContext *s, MIPSInsn opc, const void *targe= t) { uintptr_t dest =3D (uintptr_t)target; uintptr_t from =3D (uintptr_t)s->code_ptr + 4; @@ -1080,7 +1080,7 @@ static void tcg_out_movcond(TCGContext *s, TCGCond co= nd, TCGReg ret, } } =20 -static void tcg_out_call_int(TCGContext *s, tcg_insn_unit *arg, bool tail) +static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool= tail) { /* Note that the ABI requires the called function's address to be loaded into T9, even if a direct branch is in range. */ @@ -1098,7 +1098,7 @@ static void tcg_out_call_int(TCGContext *s, tcg_insn_= unit *arg, bool tail) } } =20 -static void tcg_out_call(TCGContext *s, tcg_insn_unit *arg) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) { tcg_out_call_int(s, arg, false); tcg_out_nop(s); diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index d108f01fec..38dabe40c4 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -1106,7 +1106,7 @@ static void tcg_out_xori32(TCGContext *s, TCGReg dst,= TCGReg src, uint32_t c) tcg_out_zori32(s, dst, src, c, XORI, XORIS); } =20 -static void tcg_out_b(TCGContext *s, int mask, tcg_insn_unit *target) +static void tcg_out_b(TCGContext *s, int mask, const tcg_insn_unit *target) { ptrdiff_t disp =3D tcg_pcrel_diff(s, target); if (in_range_b(disp)) { @@ -1762,13 +1762,13 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uin= tptr_t jmp_addr, } } =20 -static void tcg_out_call(TCGContext *s, tcg_insn_unit *target) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) { #ifdef _CALL_AIX /* Look through the descriptor. If the branch is in range, and we don't have to spend too much effort on building the toc. */ - void *tgt =3D ((void **)target)[0]; - uintptr_t toc =3D ((uintptr_t *)target)[1]; + const void *tgt =3D ((const void * const *)target)[0]; + uintptr_t toc =3D ((const uintptr_t *)target)[1]; intptr_t diff =3D tcg_pcrel_diff(s, tgt); =20 if (in_range_b(diff) && toc =3D=3D (uint32_t)toc) { diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index ab08af7457..4416a93e1f 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -449,7 +449,7 @@ static bool reloc_jimm20(tcg_insn_unit *code_ptr, tcg_i= nsn_unit *target) return false; } =20 -static bool reloc_call(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_call(tcg_insn_unit *code_ptr, const tcg_insn_unit *targe= t) { intptr_t offset =3D (intptr_t)target - (intptr_t)code_ptr; int32_t lo =3D sextreg(offset, 0, 12); @@ -861,7 +861,7 @@ static inline void tcg_out_goto(TCGContext *s, tcg_insn= _unit *target) tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, offset); } =20 -static void tcg_out_call_int(TCGContext *s, tcg_insn_unit *arg, bool tail) +static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool= tail) { TCGReg link =3D tail ? TCG_REG_ZERO : TCG_REG_RA; ptrdiff_t offset =3D tcg_pcrel_diff(s, arg); @@ -888,7 +888,7 @@ static void tcg_out_call_int(TCGContext *s, tcg_insn_un= it *arg, bool tail) } } =20 -static void tcg_out_call(TCGContext *s, tcg_insn_unit *arg) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) { tcg_out_call_int(s, arg, false); } diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index 1b5c4f0ab0..37f4dc4cfd 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -1415,7 +1415,7 @@ static void tgen_brcond(TCGContext *s, TCGType type, = TCGCond c, tgen_branch(s, cc, l); } =20 -static void tcg_out_call(TCGContext *s, tcg_insn_unit *dest) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) { ptrdiff_t off =3D dest - s->code_ptr; if (off =3D=3D (int32_t)off) { diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 5b3bc91b05..1a40911660 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -840,7 +840,7 @@ static void tcg_out_addsub2_i64(TCGContext *s, TCGReg r= l, TCGReg rh, tcg_out_mov(s, TCG_TYPE_I64, rl, tmp); } =20 -static void tcg_out_call_nodelay(TCGContext *s, tcg_insn_unit *dest, +static void tcg_out_call_nodelay(TCGContext *s, const tcg_insn_unit *dest, bool in_prologue) { ptrdiff_t disp =3D tcg_pcrel_diff(s, dest); @@ -855,7 +855,7 @@ static void tcg_out_call_nodelay(TCGContext *s, tcg_ins= n_unit *dest, } } =20 -static void tcg_out_call(TCGContext *s, tcg_insn_unit *dest) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) { tcg_out_call_nodelay(s, dest, false); tcg_out_nop(s); diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index 231b9b1775..d5a4d9d37c 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -545,7 +545,7 @@ static void tcg_out_movi(TCGContext *s, TCGType type, old_code_ptr[1] =3D s->code_ptr - old_code_ptr; } =20 -static inline void tcg_out_call(TCGContext *s, tcg_insn_unit *arg) +static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) { uint8_t *old_code_ptr =3D s->code_ptr; tcg_out_op_t(s, INDEX_op_call); --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607979097; cv=none; d=zohomail.com; s=zohoarc; b=LkxTJHBw0fLT/i8UyIDMDo/s3Q9Gq2e8efPnzlkFcqcz6wWpGAWxnbCAyk8MunWrQU0iyrJ8+qtpsvL0ThOVFmQOSaZRqesNc5vSzJ52ogKtizQfyD3LqQmsPG+LOXyIG46eRCvxeXB82PvAeNkrDeGrrwN3jObi55xtnbgy3qg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607979097; h=Content-Transfer-Encoding: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=1GlVA1Mk+DCqrpNhETwdyV3r3sGUvkB6WjkwT6v+rmo=; b=TcinxBjIMC6weYNrBZk1+AsGBfL/XyOExhQZFLxSrxUGS2Xyz4/Yw2KcawSXj0EdLm+F+Nd+3gtw3FCK07fvFABKobwQoEh7TsfZb8F0JKW+lR12nsROCfm1MyVBHrmjGwfRyCPU1iFkhvLm1VDHknddMFAR/RwmNpVgkG1zntA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607979097219784.2839193814465; Mon, 14 Dec 2020 12:51:37 -0800 (PST) Received: from localhost ([::1]:60698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koohD-0004Es-5u for importer@patchew.org; Mon, 14 Dec 2020 09:19:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooS5-0001gO-By for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:49 -0500 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:33197) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRu-0003wC-WC for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:46 -0500 Received: by mail-oi1-x242.google.com with SMTP id d27so19254256oic.0 for ; Mon, 14 Dec 2020 06:03:37 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1GlVA1Mk+DCqrpNhETwdyV3r3sGUvkB6WjkwT6v+rmo=; b=ZGwRjpz7QcbqO4mg+sHOph4f3PrkXN4BA5aLVukHk1vJa5Wy3X8UhJAHJODIdG3xoS 095irJQobsRotwKCvzfKexIJm/xnRx9qm/ATk8KvDMmvmusDfMWuDEMFuADV9Ebx1J9N OB7mfb6kDP7fAFpYBKdSYSF0mjtEqEpgwJawIxdp7ojmhY9sXz8A9UG/YI2OP+ok+sVx VxAZjggl4bMZjjNpRY0ysJe9yjUoQmE9FkDpm7htAUmacrl0mDpemi1okBfNDVQOFyk4 OuFA02OBTjixxTXcmjFe2OXDJIC8/kCP3qYqMyKprPhrbiJC4f3NChcdSNPDFvv7w2WD T0VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1GlVA1Mk+DCqrpNhETwdyV3r3sGUvkB6WjkwT6v+rmo=; b=Mk4nkwOcOT4S6zv4B4GRJxFd7fNer2Xw3UDPPQnysmc0QIYwQpqlSSFSrs/zvgyBSL 9Om3/m74ctOuMZ3p7EXzLliwq2YVtPaAm0VuhZJbSItp0xo4wTA36pdBgxCq6TEeRDjc vCGIjoyjosRPYt94D/rexbILRKU7ZLlf+gjWH9kLHUfOfbKC2zgODUJCsz/TcaycNXvS s+3iq4DWvoO3JcCclA7up1i8I2366PJ1XaZkAWKLES76Q84IbRy0QBeVukgSwUCYC7eD GNWcsh9m5Dmfbg+Chex+zxLuPHEzGrsD3+ouFekpucSw+ur4C1xcR+G98ZCMxcpt9R7e QxXQ== X-Gm-Message-State: AOAM530zw15cNftTr7J0hXDKvV7v9UeT2ZhF8YJJa9eQy0lbYloVE1KP Lu1U/M4pWNUfq4YFhN/ekAj7LVq/GW7e4yBE X-Google-Smtp-Source: ABdhPJw2Ma87bS1Ecghxnq0WDUbroA7LqKiY9MULewZcacSuHQkvVvZj7YT8WVbkmKp9Mna3DiqNdg== X-Received: by 2002:aca:d506:: with SMTP id m6mr18167675oig.113.1607954615632; Mon, 14 Dec 2020 06:03:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 11/43] tcg: Adjust tcg_out_label for const Date: Mon, 14 Dec 2020 08:02:42 -0600 Message-Id: <20201214140314.18544-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::242; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x242.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Simplify the arguments to always use s->code_ptr instead of take it as an argument. That makes it easy to ensure that the value_ptr is always the rx version. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/tcg.c | 6 +++--- tcg/i386/tcg-target.c.inc | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 435b0f1662..d94d38cc28 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -302,11 +302,11 @@ static void tcg_out_reloc(TCGContext *s, tcg_insn_uni= t *code_ptr, int type, QSIMPLEQ_INSERT_TAIL(&l->relocs, r, next); } =20 -static void tcg_out_label(TCGContext *s, TCGLabel *l, tcg_insn_unit *ptr) +static void tcg_out_label(TCGContext *s, TCGLabel *l) { tcg_debug_assert(!l->has_value); l->has_value =3D 1; - l->u.value_ptr =3D tcg_splitwx_to_rx(ptr); + l->u.value_ptr =3D tcg_splitwx_to_rx(s->code_ptr); } =20 TCGLabel *gen_new_label(void) @@ -4325,7 +4325,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) break; case INDEX_op_set_label: tcg_reg_alloc_bb_end(s, s->reserved_regs); - tcg_out_label(s, arg_label(op->args[0]), s->code_ptr); + tcg_out_label(s, arg_label(op->args[0])); break; case INDEX_op_call: tcg_reg_alloc_call(s, op); diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 095553ce28..0ac1ef3d82 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1452,7 +1452,7 @@ static void tcg_out_brcond2(TCGContext *s, const TCGA= rg *args, default: tcg_abort(); } - tcg_out_label(s, label_next, s->code_ptr); + tcg_out_label(s, label_next); } #endif =20 @@ -1494,10 +1494,10 @@ static void tcg_out_setcond2(TCGContext *s, const T= CGArg *args, =20 tcg_out_movi(s, TCG_TYPE_I32, args[0], 0); tcg_out_jxx(s, JCC_JMP, label_over, 1); - tcg_out_label(s, label_true, s->code_ptr); + tcg_out_label(s, label_true); =20 tcg_out_movi(s, TCG_TYPE_I32, args[0], 1); - tcg_out_label(s, label_over, s->code_ptr); + tcg_out_label(s, label_over); } else { /* When the destination does not overlap one of the arguments, clear the destination first, jump if cond false, and emit an @@ -1511,7 +1511,7 @@ static void tcg_out_setcond2(TCGContext *s, const TCG= Arg *args, tcg_out_brcond2(s, new_args, const_args+1, 1); =20 tgen_arithi(s, ARITH_ADD, args[0], 1, 0); - tcg_out_label(s, label_over, s->code_ptr); + tcg_out_label(s, label_over); } } #endif @@ -1525,7 +1525,7 @@ static void tcg_out_cmov(TCGContext *s, TCGCond cond,= int rexw, TCGLabel *over =3D gen_new_label(); tcg_out_jxx(s, tcg_cond_to_jcc[tcg_invert_cond(cond)], over, 1); tcg_out_mov(s, TCG_TYPE_I32, dest, v1); - tcg_out_label(s, over, s->code_ptr); + tcg_out_label(s, over); } } =20 --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607956692; cv=none; d=zohomail.com; s=zohoarc; b=JbOuT0nYMu4RMHWPfpAYlGct2D5t4z1MwxV8u+3uxSPuPaqaOl2lJ6tO/1krMPCp/ikZY/HD+MQBmZ40/Kt1mcYc8txktgeL8McUKDGzlm9U6zMOYlekgtroJ2y3lX4/oAsXNcX4Yc6xbvBgL6O1COMFcmy2HsnF8SkOcqhsMh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607956692; h=Content-Transfer-Encoding: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=EeMew5wTlTMjBZ99xkYZl0TWaxQaxxbFks8B9K3f6rI=; b=YM9cxG9yZuBKxV+XZK3/huvUKhM5qJHWh2Gj75j5AQW+cXxPuclL9P8h7PJ0Yi4uP9UyjNCrb0rKKeSqkue5i9XYQJzvkEs4KUcJC2ntcY5C/enr6xZp6lDNrkbu95NycoaaTE0m00fQF7vbUzgPQcu9ai68ydUh54XZlG15vM0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607956691967359.34609520348545; Mon, 14 Dec 2020 06:38:11 -0800 (PST) Received: from localhost ([::1]:46310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooUq-0003ge-PS for importer@patchew.org; Mon, 14 Dec 2020 09:06:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooS6-0001gt-B5 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:50 -0500 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]:36138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRw-0003wK-1t for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:50 -0500 Received: by mail-ot1-x32b.google.com with SMTP id y24so15767770otk.3 for ; Mon, 14 Dec 2020 06:03:39 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=EeMew5wTlTMjBZ99xkYZl0TWaxQaxxbFks8B9K3f6rI=; b=djVNtLKcFhVmVu3WqN4puhv2rNoiOdwSv9Zs57+Z9xOwei5S9xNG8DdVv7UUqOhQuR OkrOUsBtf50PnHRM0S14Fq7/T8N7hhxOw4cHUvyOebaz2iUGW5qUYAhbTcNiQVDrao1o Ti8qntY7SKJ/yJOuPLvXvWFBD7MeojjBqGCp0pJuoFOB0DXd6GMsWUjDjIESWeZ/ezKn 2VNQQjEk6D+7fUyMGWrbvfIvjGip7HlprZxOTBqojnlZzHgkmeIEQooIryIDR1s+Hgcp sa/yiTv83vxeCO193HLXzvy4qUaViTAmXlCEnLl8azQzmfBj6WMI5XuIwbqxhfO+b1xi RokQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EeMew5wTlTMjBZ99xkYZl0TWaxQaxxbFks8B9K3f6rI=; b=bXqftMT4nSwXjya90BoYScrq6VEVpVTRakId23zrBHU6XgzPJY/hFQTJJf7Yd4MJb2 IOPwvpsR9MRmjjCmUYN0rwErnQzIBOWvFA1RKIq2p03cb3Vc0KnpYzrdO/O/y7LmfMMC k4MyBYRNGcKsQNXcoJEQuawY2ksGGESQ5rvBehIfS/FwfyH7VKpY3qh1CVve4u1eUkK4 OOEi/KEu9ubHODRCR+QiCrwjIXFtSCU5LGb14shaS1v2XjLMoLJvRgA/eXFtESc2ogjj S3vLebHAuwnk/W3p4oYTFAC9wZCjvSGVLZkXfAlclIZB/8Z48KrSKliGpgaueYvyxQQ4 F1IQ== X-Gm-Message-State: AOAM531T0Kr4e9/FLW8+Ohwq2mv6rlkDMvmUGTwKUbOdyNlQPUPcOYIO 2N55ov52BEw2CiQuF0pKi+4EdwolL3mRhSvq X-Google-Smtp-Source: ABdhPJyAfgXU4d+LYvlKyampcF6nfd3/tuCTXJRzB3A9lEGwZAQLC8gMeKrTyyb4uGrt8yATj8dpQQ== X-Received: by 2002:a05:6830:22eb:: with SMTP id t11mr20670646otc.114.1607954618083; Mon, 14 Dec 2020 06:03:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 12/43] tcg: Adjust tcg_register_jit for const Date: Mon, 14 Dec 2020 08:02:43 -0600 Message-Id: <20201214140314.18544-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::32b; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32b.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" We must change all targets at once, since all must match the declaration in tcg.c. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- include/tcg/tcg.h | 2 +- tcg/tcg.c | 10 +++++----- tcg/aarch64/tcg-target.c.inc | 2 +- tcg/arm/tcg-target.c.inc | 2 +- tcg/i386/tcg-target.c.inc | 2 +- tcg/mips/tcg-target.c.inc | 2 +- tcg/ppc/tcg-target.c.inc | 2 +- tcg/riscv/tcg-target.c.inc | 2 +- tcg/s390/tcg-target.c.inc | 2 +- tcg/sparc/tcg-target.c.inc | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index b2ba16ea8c..67d57695c2 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -1250,7 +1250,7 @@ typedef uintptr_t tcg_prologue_fn(CPUArchState *env, = const void *tb_ptr); extern tcg_prologue_fn *tcg_qemu_tb_exec; #endif =20 -void tcg_register_jit(void *buf, size_t buf_size); +void tcg_register_jit(const void *buf, size_t buf_size); =20 #if TCG_TARGET_MAYBE_vec /* Return zero if the tuple (opc, type, vece) is unsupportable; diff --git a/tcg/tcg.c b/tcg/tcg.c index d94d38cc28..5f585c2ed2 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -97,7 +97,7 @@ typedef struct QEMU_PACKED { DebugFrameFDEHeader fde; } DebugFrameHeader; =20 -static void tcg_register_jit_int(void *buf, size_t size, +static void tcg_register_jit_int(const void *buf, size_t size, const void *debug_frame, size_t debug_frame_size) __attribute__((unused)); @@ -1137,7 +1137,7 @@ void tcg_prologue_init(TCGContext *s) total_size -=3D prologue_size; s->code_gen_buffer_size =3D total_size; =20 - tcg_register_jit(s->code_gen_buffer, total_size); + tcg_register_jit(tcg_splitwx_to_rx(s->code_gen_buffer), total_size); =20 #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) { @@ -4507,7 +4507,7 @@ static int find_string(const char *strtab, const char= *str) } } =20 -static void tcg_register_jit_int(void *buf_ptr, size_t buf_size, +static void tcg_register_jit_int(const void *buf_ptr, size_t buf_size, const void *debug_frame, size_t debug_frame_size) { @@ -4709,13 +4709,13 @@ static void tcg_register_jit_int(void *buf_ptr, siz= e_t buf_size, /* No support for the feature. Provide the entry point expected by exec.c, and implement the internal function we declared earlier. */ =20 -static void tcg_register_jit_int(void *buf, size_t size, +static void tcg_register_jit_int(const void *buf, size_t size, const void *debug_frame, size_t debug_frame_size) { } =20 -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { } #endif /* ELF_HOST_MACHINE */ diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 6d8152c468..9ace859db3 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -2964,7 +2964,7 @@ static const DebugFrame debug_frame =3D { } }; =20 -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index a197e6bc45..9b9400f164 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -2353,7 +2353,7 @@ static const DebugFrame debug_frame =3D { } }; =20 -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 0ac1ef3d82..7f74c77d7f 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -3998,7 +3998,7 @@ static const DebugFrame debug_frame =3D { #endif =20 #if defined(ELF_HOST_MACHINE) -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 6d2c369a85..e9c8c24741 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2703,7 +2703,7 @@ static const DebugFrame debug_frame =3D { } }; =20 -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 38dabe40c4..a0a5bac13f 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -3847,7 +3847,7 @@ static DebugFrame debug_frame =3D { } }; =20 -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { uint8_t *p =3D &debug_frame.fde_reg_ofs[3]; int i; diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 4416a93e1f..025e3cd0bb 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1907,7 +1907,7 @@ static const DebugFrame debug_frame =3D { } }; =20 -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index 37f4dc4cfd..1444914428 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -2620,7 +2620,7 @@ static const DebugFrame debug_frame =3D { } }; =20 -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 1a40911660..4c81d5f1c2 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -1816,7 +1816,7 @@ static const DebugFrame debug_frame =3D { .fde_ret_save =3D { 9, 15, 31 }, /* DW_CFA_register o7, i7 */ }; =20 -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607977252; cv=none; d=zohomail.com; s=zohoarc; b=LJU4gBxvTS0dFvIYHVJ9mBPfFArYbCf7YZoEkCnkMZ9gPaDJxkRKk2dqJ0cP9T2vhPH5vHKpR8N0oi7BzVciFjDS8d4SMbKjtdJhzI99ViTt/SPyHz4+xXrriuHc1qtpMLZZ4n7jELhQ6TkeHkj0OhDuuq38NZdAX1af5NphPs8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607977252; h=Content-Transfer-Encoding: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=xqRZhjxDlTittJJCkvFwWLoeMjn4/7xpY5jGL/CdFJM=; b=UfDf3OC97XPJzE++1npoPCZtWdQM4Xcmd/QROc5H4LTZWqXIz3YkEe4+zc+BdKin5cJuhawpc2XLsbSnkNjdXcWJyUZi643posDsAzxQaleuVrm/Pk1JHzoQrvrRFIhHTZd4OAHZppiAI9wxVASEKLTI9tdFfJkfRD4RImroJW4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607977252186344.21650619424975; Mon, 14 Dec 2020 12:20:52 -0800 (PST) Received: from localhost ([::1]:48100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koomH-0002Ce-Mt for importer@patchew.org; Mon, 14 Dec 2020 09:24:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooS7-0001ip-56 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:51 -0500 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:41951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooRz-0003wd-Al for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:50 -0500 Received: by mail-ot1-x344.google.com with SMTP id x13so15781544oto.8 for ; Mon, 14 Dec 2020 06:03:41 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xqRZhjxDlTittJJCkvFwWLoeMjn4/7xpY5jGL/CdFJM=; b=OFJq9mJBqeVgIv4legjF86Tg2dk5LuX82d9UIgEIwk4V6uOZ2PHa4yqfGab6xu53Qy Z+6zzoUx3oQLHphkaXFU0VgwJ6xmkU26LT7M1Y6SwtvRTFBz8MhU5iWFNCmAfYMjnshR 4MdxLlmbBa7eBMdJHjdb/ZDmG6+Vd5ChPlSxDcETd68plNRXIm7Ed9jyUmf3abOW4DF8 ykajoLfB2mASGvM+Dh207OGoFJ0h6TOrAxWA71pH4MU63/CkdfQ10NDaNRHmxRfl3o9A C9/e2u1SbDaWrJwviGXATgxF3oPYzrIR4oUolf9tCnhWlEBUaOIUdcuOs6LBGLBBcG06 HnlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xqRZhjxDlTittJJCkvFwWLoeMjn4/7xpY5jGL/CdFJM=; b=kLA1+d30q5QQqRvIeYy9t066D6PMpyh0R7UBMTb2UQK0XATvadD9tf7x8AY/dO6DAH oE3P9ZomnRwqzttTyXKgW3qArh11zuAOF7yTqs7WyGZWN483xEhAhjeXYyfJG6kAPnPX isgTr4gfDlRks+slNBWAkdbWikKGFKiY5nnvgxVQVXkiH6PL0yMHFZ7w/q81OryfddZo 7ZfUpo8gIU7DWJJWqFXKPTP4bOJ0rjxon3o6fua3ytqtvHrP00TbpEKNvILBH0l8ywUJ LtQBRERKu5dilM6vs29nzYDZqFaom967rtDRCOGikaMYGw5dnnFrxkq4kCJHXP4hLmfi qyjA== X-Gm-Message-State: AOAM53387Q7OfV3cJlsqxnzhrK8uP+DkdCOdGRh/ExbnAxemXb7EZ680 Kep8iUe5+/9+/Zjjy57sY8sPtkkyFiRbTbBq X-Google-Smtp-Source: ABdhPJx7PXjJGZ/xymQ42wHEwpvVCnRjw/QCjJJtgpKrVq+bMy+HEpEo7/Oncsi/mOCY7rUyJOlAJQ== X-Received: by 2002:a05:6830:1252:: with SMTP id s18mr19627153otp.4.1607954619688; Mon, 14 Dec 2020 06:03:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 13/43] tcg: Adjust tb_target_set_jmp_target for split-wx Date: Mon, 14 Dec 2020 08:02:44 -0600 Message-Id: <20201214140314.18544-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::344; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x344.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Pass both rx and rw addresses to tb_target_set_jmp_target. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- tcg/aarch64/tcg-target.h | 2 +- tcg/arm/tcg-target.h | 2 +- tcg/i386/tcg-target.h | 6 +++--- tcg/mips/tcg-target.h | 2 +- tcg/ppc/tcg-target.h | 2 +- tcg/riscv/tcg-target.h | 2 +- tcg/s390/tcg-target.h | 8 ++++---- tcg/sparc/tcg-target.h | 2 +- tcg/tci/tcg-target.h | 6 +++--- accel/tcg/cpu-exec.c | 4 +++- tcg/aarch64/tcg-target.c.inc | 12 ++++++------ tcg/mips/tcg-target.c.inc | 8 ++++---- tcg/ppc/tcg-target.c.inc | 16 ++++++++-------- tcg/sparc/tcg-target.c.inc | 14 +++++++------- 14 files changed, 44 insertions(+), 42 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 8a6b97598e..6ba248f447 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -148,7 +148,7 @@ typedef enum { #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 #ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index f1955ce4ac..6ca4537ca6 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -135,7 +135,7 @@ enum { #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 /* not defined -- call should be eliminated at compile time */ -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 #ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index cd067e0b30..0dcaed7fe6 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -206,11 +206,11 @@ extern bool have_avx2; #define TCG_TARGET_extract_i64_valid(ofs, len) \ (((ofs) =3D=3D 8 && (len) =3D=3D 8) || ((ofs) + (len)) =3D=3D 32) =20 -static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, - uintptr_t jmp_addr, uintptr_t = addr) +static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jm= p_rx, + uintptr_t jmp_rw, uintptr_t ad= dr) { /* patch the branch destination */ - qatomic_set((int32_t *)jmp_addr, addr - (jmp_addr + 4)); + qatomic_set((int32_t *)jmp_rw, addr - (jmp_rx + 4)); /* no need to flush icache explicitly */ } =20 diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 92c1d63da3..d23baf7cda 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -201,7 +201,7 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 #ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index a509a19628..c41d10142b 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -175,7 +175,7 @@ extern bool have_vsx; #define TCG_TARGET_HAS_bitsel_vec have_vsx #define TCG_TARGET_HAS_cmpsel_vec 0 =20 -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index c1bd52bb9a..3d0745c70c 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -160,7 +160,7 @@ typedef enum { #endif =20 /* not defined -- call should be eliminated at compile time */ -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 #define TCG_TARGET_DEFAULT_MO (0) =20 diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index b4feb2f55a..3750952598 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -145,12 +145,12 @@ enum { TCG_AREG0 =3D TCG_REG_R10, }; =20 -static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, - uintptr_t jmp_addr, uintptr_t = addr) +static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jm= p_rx, + uintptr_t jmp_rw, uintptr_t ad= dr) { /* patch the branch destination */ - intptr_t disp =3D addr - (jmp_addr - 2); - qatomic_set((int32_t *)jmp_addr, disp / 2); + intptr_t disp =3D addr - (jmp_rx - 2); + qatomic_set((int32_t *)jmp_rw, disp / 2); /* no need to flush icache explicitly */ } =20 diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index d8b0e32e2e..9c15c91d39 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -168,7 +168,7 @@ extern bool use_vis3_instructions; #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 #define TCG_TARGET_NEED_POOL_LABELS =20 diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index b84480f989..fcec2e70db 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -198,11 +198,11 @@ void tci_disas(uint8_t opc); =20 #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 -static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, - uintptr_t jmp_addr, uintptr_t = addr) +static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jm= p_rx, + uintptr_t jmp_rw, uintptr_t ad= dr) { /* patch the branch destination */ - qatomic_set((int32_t *)jmp_addr, addr - (jmp_addr + 4)); + qatomic_set((int32_t *)jmp_rw, addr - (jmp_rx + 4)); /* no need to flush icache explicitly */ } =20 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 1e3cb570f6..272d596e0c 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -354,7 +354,9 @@ void tb_set_jmp_target(TranslationBlock *tb, int n, uin= tptr_t addr) if (TCG_TARGET_HAS_direct_jump) { uintptr_t offset =3D tb->jmp_target_arg[n]; uintptr_t tc_ptr =3D (uintptr_t)tb->tc.ptr; - tb_target_set_jmp_target(tc_ptr, tc_ptr + offset, addr); + uintptr_t jmp_rx =3D tc_ptr + offset; + uintptr_t jmp_rw =3D jmp_rx - tcg_splitwx_diff; + tb_target_set_jmp_target(tc_ptr, jmp_rx, jmp_rw, addr); } else { tb->jmp_target_arg[n] =3D addr; } diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 9ace859db3..fea784cf75 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1340,21 +1340,21 @@ static inline void tcg_out_call(TCGContext *s, cons= t tcg_insn_unit *target) } } =20 -void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, - uintptr_t addr) +void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { tcg_insn_unit i1, i2; TCGType rt =3D TCG_TYPE_I64; TCGReg rd =3D TCG_REG_TMP; uint64_t pair; =20 - ptrdiff_t offset =3D addr - jmp_addr; + ptrdiff_t offset =3D addr - jmp_rx; =20 if (offset =3D=3D sextract64(offset, 0, 26)) { i1 =3D I3206_B | ((offset >> 2) & 0x3ffffff); i2 =3D NOP; } else { - offset =3D (addr >> 12) - (jmp_addr >> 12); + offset =3D (addr >> 12) - (jmp_rx >> 12); =20 /* patch ADRP */ i1 =3D I3406_ADRP | (offset & 3) << 29 | (offset & 0x1ffffc) << (5= - 2) | rd; @@ -1362,8 +1362,8 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintp= tr_t jmp_addr, i2 =3D I3401_ADDI | rt << 31 | (addr & 0xfff) << 10 | rd << 5 | rd; } pair =3D (uint64_t)i2 << 32 | i1; - qatomic_set((uint64_t *)jmp_addr, pair); - flush_idcache_range(jmp_addr, jmp_addr, 8); + qatomic_set((uint64_t *)jmp_rw, pair); + flush_idcache_range(jmp_rx, jmp_rw, 8); } =20 static inline void tcg_out_goto_label(TCGContext *s, TCGLabel *l) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index e9c8c24741..52638e920c 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2657,11 +2657,11 @@ static void tcg_target_init(TCGContext *s) tcg_regset_set_reg(s->reserved_regs, TCG_REG_GP); /* global pointer = */ } =20 -void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, - uintptr_t addr) +void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { - qatomic_set((uint32_t *)jmp_addr, deposit32(OPC_J, 0, 26, addr >> 2)); - flush_idcache_range(jmp_addr, jmp_addr, 4); + qatomic_set((uint32_t *)jmp_rw, deposit32(OPC_J, 0, 26, addr >> 2)); + flush_idcache_range(jmp_rx, jmp_rw, 4); } =20 typedef struct { diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index a0a5bac13f..0eb9c4ebe2 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -1722,13 +1722,13 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) tcg_out32(s, insn); } =20 -void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, - uintptr_t addr) +void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { if (TCG_TARGET_REG_BITS =3D=3D 64) { tcg_insn_unit i1, i2; intptr_t tb_diff =3D addr - tc_ptr; - intptr_t br_diff =3D addr - (jmp_addr + 4); + intptr_t br_diff =3D addr - (jmp_rx + 4); uint64_t pair; =20 /* This does not exercise the range of the branch, but we do @@ -1752,13 +1752,13 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uin= tptr_t jmp_addr, =20 /* As per the enclosing if, this is ppc64. Avoid the _Static_asse= rt within qatomic_set that would fail to build a ppc32 host. */ - qatomic_set__nocheck((uint64_t *)jmp_addr, pair); - flush_idcache_range(jmp_addr, jmp_addr, 8); + qatomic_set__nocheck((uint64_t *)jmp_rw, pair); + flush_idcache_range(jmp_rx, jmp_rw, 8); } else { - intptr_t diff =3D addr - jmp_addr; + intptr_t diff =3D addr - jmp_rx; tcg_debug_assert(in_range_b(diff)); - qatomic_set((uint32_t *)jmp_addr, B | (diff & 0x3fffffc)); - flush_idcache_range(jmp_addr, jmp_addr, 4); + qatomic_set((uint32_t *)jmp_rw, B | (diff & 0x3fffffc)); + flush_idcache_range(jmp_rx, jmp_rw, 4); } } =20 diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 4c81d5f1c2..d599ae27b5 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -1821,11 +1821,11 @@ void tcg_register_jit(const void *buf, size_t buf_s= ize) tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } =20 -void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, - uintptr_t addr) +void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { intptr_t tb_disp =3D addr - tc_ptr; - intptr_t br_disp =3D addr - jmp_addr; + intptr_t br_disp =3D addr - jmp_rx; tcg_insn_unit i1, i2; =20 /* We can reach the entire address space for ILP32. @@ -1834,9 +1834,9 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintp= tr_t jmp_addr, tcg_debug_assert(br_disp =3D=3D (int32_t)br_disp); =20 if (!USE_REG_TB) { - qatomic_set((uint32_t *)jmp_addr, + qatomic_set((uint32_t *)jmp_rw, deposit32(CALL, 0, 30, br_disp >> 2)); - flush_idcache_range(jmp_addr, jmp_addr, 4); + flush_idcache_range(jmp_rx, jmp_rw, 4); return; } =20 @@ -1859,6 +1859,6 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintp= tr_t jmp_addr, | INSN_IMM13((tb_disp & 0x3ff) | -0x400)); } =20 - qatomic_set((uint64_t *)jmp_addr, deposit64(i2, 32, 32, i1)); - flush_idcache_range(jmp_addr, jmp_addr, 8); + qatomic_set((uint64_t *)jmp_rw, deposit64(i2, 32, 32, i1)); + flush_idcache_range(jmp_rx, jmp_rw, 8); } --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607977283; cv=none; d=zohomail.com; s=zohoarc; b=gafxjHeLFOFJpDvrrxXQwPpgI3vqDifcGSXfN3Q9O7yB4iuE11TacywghNyX9aE812Q0WycvtmMIYZPwge2HmsXLOs7n3uYr9ddfOCBpq9kXkyWEy7Xc0lbtOuWHGGdFIYZKCCbdCnUytYfuO2x0AYG2bDnH36pyhjctD7Mj570= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607977283; h=Content-Transfer-Encoding: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=wpyFYYIqvE4n/WbNDVjRAK3hdmdxC+OlWEmANDViNo4=; b=Bmyq0v/xy7nhYyhLFfm+mEutnq/SQ3N41e31y6pvg4UWA6Fbeneuida/wnB3G59P7PDNlXhA/jWBM1p3wUpg+Sj3FwxBE4+mDRIUzxEIG4BrmguWpAbHM6X7NduTLjN0pWrfyBIW68g3XbweWT+37hSvpF+M6WFmVcxg3vjbaHw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607977283525393.764100137583; Mon, 14 Dec 2020 12:21:23 -0800 (PST) Received: from localhost ([::1]:39638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koojb-0007CT-Np for importer@patchew.org; Mon, 14 Dec 2020 09:21:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooS6-0001i5-Pr for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:50 -0500 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:38035) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooS0-0003wj-Nc for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:50 -0500 Received: by mail-ot1-x342.google.com with SMTP id j20so11291430otq.5 for ; Mon, 14 Dec 2020 06:03:42 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=wpyFYYIqvE4n/WbNDVjRAK3hdmdxC+OlWEmANDViNo4=; b=VkU03tSWItRpfgvhXANOuGjh4Q6ZTyR5M12Iymcf5H6wAhZ/jgN//5LW8UKC07+T/i HdCNm3ULtW8MfdxjhDeV6zlGs4kS+LyZ/oSMmm4uVkZCYCbmn+j22XpYoGWtzqdIdkOr RUzkExWYX5BYjgXFW17F0ldGwPSkKM+KkczAd2mpYNEVLpeetZJjG4A8i4N9wnq5B/Ai qWB8sylb4KTes6LVAMvWQG6lBn7PLy3acQE+H9kHCoYvUajpUULdQ1QQDZWmndjZGfUJ WM++BpVSItbEQv37BKeFchtpNB3V0tdjjDQ+YlIewiv90MELmDdMxaTWRUsCyzlPSyFH hqlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wpyFYYIqvE4n/WbNDVjRAK3hdmdxC+OlWEmANDViNo4=; b=VVAWvR+R8rm0gRqk7d+FT9oQ1O2MFUZ0nTm6O1ADNmqo5BivaZnr8clKoQWAquoPJz H3l5fi7wTdl67lk2xBM5e5ZlEmYmeQ5d3gk0AJcvr5fCRGopKobRLwbVJ9ZvgemSHTNK 8cXM9UIQ/OWxeK8dUqRAYXSBK5ojZ9fendBNcF+SsaXgFCcwAWyMmCQfrTTsLAVg76TP w/hMQXGhb+5sfg+S+50Me3ejHfE8FeQgT6Yt6bLJ2N4v4lWWsrpLKJhmY7lnf6wWsZoD fwHoAUnIPJOuekRy4UWQ0l/VUloQW36KXQBWy4TO4fT6/sab44iNhJfwrCed/rCbW4xN q9iw== X-Gm-Message-State: AOAM533eWoRye4XOCVF8WkNN8fGw8jFynFhuM31IvmnrmLRjIG6YEE09 42W7IRvpQ2S/Udv+YMgKMWwIjqRhFOLMUj9d X-Google-Smtp-Source: ABdhPJwZ8I+PgcVa3xG6A8gYc1TAHbqM9eximVN9yfC57SshVW0Cl5MbbpgMWRcAUWiwViDuLngw/w== X-Received: by 2002:a9d:6208:: with SMTP id g8mr20178728otj.165.1607954621672; Mon, 14 Dec 2020 06:03:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 14/43] tcg: Make DisasContextBase.tb const Date: Mon, 14 Dec 2020 08:02:45 -0600 Message-Id: <20201214140314.18544-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::342; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x342.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" There is nothing within the translators that ought to be changing the TranslationBlock data, so make it const. This does not actually use the read-only copy of the data structure that exists within the rx region. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/exec/gen-icount.h | 4 ++-- include/exec/translator.h | 2 +- include/tcg/tcg-op.h | 2 +- accel/tcg/translator.c | 4 ++-- target/arm/translate-a64.c | 2 +- tcg/tcg-op.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index 822c43cfd3..aa4b44354a 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -32,7 +32,7 @@ static inline void gen_io_end(void) tcg_temp_free_i32(tmp); } =20 -static inline void gen_tb_start(TranslationBlock *tb) +static inline void gen_tb_start(const TranslationBlock *tb) { TCGv_i32 count, imm; =20 @@ -71,7 +71,7 @@ static inline void gen_tb_start(TranslationBlock *tb) tcg_temp_free_i32(count); } =20 -static inline void gen_tb_end(TranslationBlock *tb, int num_insns) +static inline void gen_tb_end(const TranslationBlock *tb, int num_insns) { if (tb_cflags(tb) & CF_USE_ICOUNT) { /* Update the num_insn immediate parameter now that we know diff --git a/include/exec/translator.h b/include/exec/translator.h index 638e1529c5..24232ead41 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -67,7 +67,7 @@ typedef enum DisasJumpType { * Architecture-agnostic disassembly context. */ typedef struct DisasContextBase { - TranslationBlock *tb; + const TranslationBlock *tb; target_ulong pc_first; target_ulong pc_next; DisasJumpType is_jmp; diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index 5abf17fecc..cbe39a3b95 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -805,7 +805,7 @@ static inline void tcg_gen_insn_start(target_ulong pc, = target_ulong a1, * be NULL and @idx should be 0. Otherwise, @tb should be valid and * @idx should be one of the TB_EXIT_ values. */ -void tcg_gen_exit_tb(TranslationBlock *tb, unsigned idx); +void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx); =20 /** * tcg_gen_goto_tb() - output goto_tb TCG operation diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index fb1e19c585..a49a794065 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -133,8 +133,8 @@ void translator_loop(const TranslatorOps *ops, DisasCon= textBase *db, } =20 /* The disas_log hook may use these values rather than recompute. */ - db->tb->size =3D db->pc_next - db->pc_first; - db->tb->icount =3D db->num_insns; + tb->size =3D db->pc_next - db->pc_first; + tb->icount =3D db->num_insns; =20 #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 2e3fdfdf6b..ef63edfc68 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -410,7 +410,7 @@ static inline bool use_goto_tb(DisasContext *s, int n, = uint64_t dest) =20 static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) { - TranslationBlock *tb; + const TranslationBlock *tb; =20 tb =3D s->base.tb; if (use_goto_tb(s, n, dest)) { diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 4b8a473fad..e3dc0cb4cb 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2664,7 +2664,7 @@ void tcg_gen_extr32_i64(TCGv_i64 lo, TCGv_i64 hi, TCG= v_i64 arg) =20 /* QEMU specific operations. */ =20 -void tcg_gen_exit_tb(TranslationBlock *tb, unsigned idx) +void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx) { uintptr_t val =3D (uintptr_t)tb + idx; =20 --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607959298; cv=none; d=zohomail.com; s=zohoarc; b=B8V6q2FIckqTQQI9uybjQzlH6kWNgXQURmR8YNJCG+JpsIZqmkWcSp8dqnkB9oiLXOWkJE2cK5XVR5Jdehai9hCAgfUV+L8SdR+L6fGvn11272LqkRA1OJpqYKvR+eieDwtlPpxhN9C3QWcNqkBxUyogU2W9bSzMZTC93WkZ/FI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607959298; h=Content-Transfer-Encoding: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=L3KSYgTID8lxe/3Pvx+7FaZP4H7EiUhUFytfizdwcH0=; b=aPH6OhUeoGvPptklimO1yamMj2iR+e2lkD2u5kBtnE4tMp9N+5GESfmLLH9E/o+nttAfmAmrCbg1CrWAsbSG2WB2tzsK+mjF1eRT7Wjh6f8gh+KV92syAHr4Rv269buGHewqFenu9ViSY3KwzUUmDdsVu+iftxh+L4ncU2b0Un8= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607959296374796.6973037393125; Mon, 14 Dec 2020 07:21:36 -0800 (PST) Received: from localhost ([::1]:54838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooXQ-00078O-Am for importer@patchew.org; Mon, 14 Dec 2020 09:09:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooS9-0001oZ-SF for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:53 -0500 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]:45029) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooS2-0003wp-Iq for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:53 -0500 Received: by mail-oi1-x229.google.com with SMTP id d189so19219491oig.11 for ; Mon, 14 Dec 2020 06:03:44 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=L3KSYgTID8lxe/3Pvx+7FaZP4H7EiUhUFytfizdwcH0=; b=kny7zWOyTubFzfS0qNfyZ6isMrBq9KTm+Ze783DOfsU6vLQnLriGlFnRydWxKvu3TA 54DcSFPwR+CXR3lqgM8Kyk3qbE+6E1E7USxdZseWou/HteTVy5LsQGf8OEuwhWQoGPKB tlBragw7EXMA3vSnOQy83qWQDWtR5covvNP3EO/81mp9HJuTq44+Fc168tkCQQqygE5l KmBpTo9cmypKMHK9mSY3Fgy3F5yfnI9cTDxPq/VMaEBRblsiO7XSXK5cfgKY83ymI8Dm 1MHy5FuKxHdTqSYglt3UeSvIYu6HogGNE9DfHy9C+qrPUIVfGxDmnE/feQRBWjMdjDRA XRfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L3KSYgTID8lxe/3Pvx+7FaZP4H7EiUhUFytfizdwcH0=; b=KhwYcltGmaNEgwJXd7fWrsVtwZ9nNgyPTEEJCXpp1kG0K1aCgUHWjSZPr6Y9kpA6OX ggOPj3CSrxx7zq8Bz03Co5+ab4x56L7RG/g2j2zQfalMDoPhFzm0HR0NEf9lkpB7shB8 OgIVzhcZG+2zYbRrkfC6NjNFsM1bBzeFf5nEyj09lXhNIW4mBkrZaCvpDV770LeaeX+q Ni/lSMa6t74AsAW58rH/iBe10GhBkoaY/fjWX/52S2QqVcXVP96DRUxf7bt7giDE3Sbh yHH5JrdHyfcMsgni+d/LbixUbw69jDFiN0KY4iVjDOi/9UQwsNtujGrSoXIqK5huZuRs STQw== X-Gm-Message-State: AOAM531MfFoAJ1gpQ2oqQ/GVtPbIBOIdyByxwboxEzhaBh1D02MVACeG oyu9vaWEKEiYmFx65Ws8r6kTti8GyB1m2rOt X-Google-Smtp-Source: ABdhPJzUL5xAnUVx0zvB5JuNszeAWjb0WFrSTyeO4gEpk2h1VoZdLQPe9t2RSJuf3TSxG80niEXeRw== X-Received: by 2002:aca:bd0b:: with SMTP id n11mr17593332oif.11.1607954623745; Mon, 14 Dec 2020 06:03:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 15/43] tcg: Make tb arg to synchronize_from_tb const Date: Mon, 14 Dec 2020 08:02:46 -0600 Message-Id: <20201214140314.18544-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::229; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x229.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" There is nothing within the translators that ought to be changing the TranslationBlock data, so make it const. This does not actually use the read-only copy of the data structure that exists within the rx region. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/core/cpu.h | 3 ++- target/arm/cpu.c | 3 ++- target/avr/cpu.c | 3 ++- target/hppa/cpu.c | 3 ++- target/i386/cpu.c | 3 ++- target/microblaze/cpu.c | 3 ++- target/mips/cpu.c | 3 ++- target/riscv/cpu.c | 3 ++- target/rx/cpu.c | 3 ++- target/sh4/cpu.c | 3 ++- target/sparc/cpu.c | 3 ++- target/tricore/cpu.c | 2 +- 12 files changed, 23 insertions(+), 12 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 3d92c967ff..44c336a96a 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -189,7 +189,8 @@ struct CPUClass { void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list, Error **errp); void (*set_pc)(CPUState *cpu, vaddr value); - void (*synchronize_from_tb)(CPUState *cpu, struct TranslationBlock *tb= ); + void (*synchronize_from_tb)(CPUState *cpu, + const struct TranslationBlock *tb); bool (*tlb_fill)(CPUState *cpu, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index d6188f6566..62e319eb6a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -54,7 +54,8 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) } } =20 -static void arm_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void arm_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 5d9c4ad5bf..6f3d5a9e4a 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -41,7 +41,8 @@ static bool avr_cpu_has_work(CPUState *cs) && cpu_interrupts_enabled(env); } =20 -static void avr_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void avr_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { AVRCPU *cpu =3D AVR_CPU(cs); CPUAVRState *env =3D &cpu->env; diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 71b6aca45d..e28f047d10 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -35,7 +35,8 @@ static void hppa_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.iaoq_b =3D value + 4; } =20 -static void hppa_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *t= b) +static void hppa_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { HPPACPU *cpu =3D HPPA_CPU(cs); =20 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6c11feeb92..258b0d6148 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7047,7 +7047,8 @@ static void x86_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.eip =3D value; } =20 -static void x86_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void x86_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { X86CPU *cpu =3D X86_CPU(cs); =20 diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 9b2482159d..c8e754cfb1 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -83,7 +83,8 @@ static void mb_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.iflags =3D 0; } =20 -static void mb_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void mb_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(cs); =20 diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 76d50b00b4..79eee215cf 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -44,7 +44,8 @@ static void mips_cpu_set_pc(CPUState *cs, vaddr value) } } =20 -static void mips_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *t= b) +static void mips_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { MIPSCPU *cpu =3D MIPS_CPU(cs); CPUMIPSState *env =3D &cpu->env; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6a0264fc6b..1b2f40de47 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -285,7 +285,8 @@ static void riscv_cpu_set_pc(CPUState *cs, vaddr value) env->pc =3D value; } =20 -static void riscv_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *= tb) +static void riscv_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 23ee17a701..2bb14144a7 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -33,7 +33,8 @@ static void rx_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc =3D value; } =20 -static void rx_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void rx_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { RXCPU *cpu =3D RX_CPU(cs); =20 diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 3c68021c56..1e0f05a15b 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -34,7 +34,8 @@ static void superh_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc =3D value; } =20 -static void superh_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock = *tb) +static void superh_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { SuperHCPU *cpu =3D SUPERH_CPU(cs); =20 diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 701e794eac..57db14548c 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -691,7 +691,8 @@ static void sparc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.npc =3D value + 4; } =20 -static void sparc_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *= tb) +static void sparc_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { SPARCCPU *cpu =3D SPARC_CPU(cs); =20 diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 2f2e5b029f..4bff1d4718 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -42,7 +42,7 @@ static void tricore_cpu_set_pc(CPUState *cs, vaddr value) } =20 static void tricore_cpu_synchronize_from_tb(CPUState *cs, - TranslationBlock *tb) + const TranslationBlock *tb) { TriCoreCPU *cpu =3D TRICORE_CPU(cs); CPUTriCoreState *env =3D &cpu->env; --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607968023; cv=none; d=zohomail.com; s=zohoarc; b=FesAwTSZVATJmFvNnFAbzZK5BrrzkRNO2od2TqGRLUgKyEKR6ihei85ihedctwqYUuZOKwqQUkEgWJUua9J2W5KJbb2QzorqipfSHEEALzeNhNd5GSB4q1p6n5tdKjSb6D20QLtF2LO02pHfZN16pJUCzgfEsqjtjNqVQsUMzQA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607968023; h=Content-Transfer-Encoding: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=8YnkrBigavL+C33hr6dUiCjy8qumFXs3cayqbgFA/m8=; b=nFlifRz9j91g+D49nK2sAVE4CFZIliieSRyyI/7qC2OW8GjhOPDNzrYl24UfWtXrvaZfMaiHmYqlTaU/NNWq0wuVqLSsAqGIxzqWu54B3B3YaNv2OJreytMQnThXzkT5t7gYM01FOZBz+YrrskBHymRp5HO0soOfXjJjj8GHPcE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607968023226429.8710692544962; Mon, 14 Dec 2020 09:47:03 -0800 (PST) Received: from localhost ([::1]:51514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooeu-0000YB-Ge for importer@patchew.org; Mon, 14 Dec 2020 09:17:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooS8-0001kk-0U for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:52 -0500 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:35831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooS4-0003wu-JM for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:51 -0500 Received: by mail-oi1-x242.google.com with SMTP id s2so19254654oij.2 for ; Mon, 14 Dec 2020 06:03:46 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=8YnkrBigavL+C33hr6dUiCjy8qumFXs3cayqbgFA/m8=; b=CT+yeYsnvginptyE3WVoVo0SHwqFa5whSBzHw86hEMbC6c02hUKxrQVR6942Rkv+F8 mkOCEf+zWLQjE+wOmCV+s4qLZrnKC/y+JTdD8j2RHTE2JnxT1RGWFeWmDdKzW/kX3zj9 OaDRbIpMa7YWLorgkRAOg/0B171aSuuXDkeARKHTU6Iqt7pbXn9zrhbJGq/rlb7P4S+Z II2msth3+unFt5XXu4YDhBPe6hfp5TaeNgVosK+BeXA/MX6HzFeuqxZSy2OzCZ9lDyxA yWu2hHmAG2Ah/3dE2YIhsj8mrZJBd+AJsx7l3ApVJlEeGGbC+eHVSitgO9/K6vw7MYx2 FNZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8YnkrBigavL+C33hr6dUiCjy8qumFXs3cayqbgFA/m8=; b=OV47ODbKfBQdmM/vaOf5fNR/hvrvNZqTa2+ZT1SfD00mWSo6a+xl7bdHZRpR2GXd26 kt1Tz2Ed2T6cEuQ2sCk62J8V0B4Qm553XENWdTL26eY2wnrTySTNPx6722SoKlch0Mg7 GOQGUqOw+j87uvGHJLS00Wk0lZMjlhoJhqJvRWlRxfG7vNMjBxZHCxTduKg+JeW+txCw MeUAOYXgJvkWGGhoCwul1/4epjrY8DO+leKfZP/kuvp+Ec4BbXQhS2mXKNMkM5L1pH0R Ej/EkUjk0eHpTUWEKTXOI8xEgl82RtM1h1eE4TIp8FYEhyy30/aqxBWECh7T2PbrRf5F R7aQ== X-Gm-Message-State: AOAM531qsdHoQhNL04SpAYq9OMeperU3R1Pks3I8EMwpZ4GpL9C8NQ7X lFGSBitx+BOPSWp2wysL+G0BmxQasUvAma3i X-Google-Smtp-Source: ABdhPJzH3M5GIdyviBLiLZTlCXiOvMLH2YHG/KqI6Y0EZ4rcelR06OOcCT5MRZaeL5+EJON5KzAIMg== X-Received: by 2002:aca:4fd6:: with SMTP id d205mr17790207oib.34.1607954625529; Mon, 14 Dec 2020 06:03:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 16/43] tcg: Use Error with alloc_code_gen_buffer Date: Mon, 14 Dec 2020 08:02:47 -0600 Message-Id: <20201214140314.18544-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::242; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x242.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Report better error messages than just "could not allocate". Let alloc_code_gen_buffer set ctx->code_gen_buffer_size and ctx->code_gen_buffer, and simply return bool. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- accel/tcg/translate-all.c | 60 ++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 7b85ddacd2..2824b3e387 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -59,6 +59,7 @@ #include "sysemu/cpus.h" #include "sysemu/cpu-timers.h" #include "sysemu/tcg.h" +#include "qapi/error.h" =20 /* #define DEBUG_TB_INVALIDATE */ /* #define DEBUG_TB_FLUSH */ @@ -963,7 +964,7 @@ static void page_lock_pair(PageDesc **ret_p1, tb_page_a= ddr_t phys1, (DEFAULT_CODE_GEN_BUFFER_SIZE_1 < MAX_CODE_GEN_BUFFER_SIZE \ ? DEFAULT_CODE_GEN_BUFFER_SIZE_1 : MAX_CODE_GEN_BUFFER_SIZE) =20 -static inline size_t size_code_gen_buffer(size_t tb_size) +static size_t size_code_gen_buffer(size_t tb_size) { /* Size the buffer. */ if (tb_size =3D=3D 0) { @@ -1014,7 +1015,7 @@ static inline void *split_cross_256mb(void *buf1, siz= e_t size1) static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE] __attribute__((aligned(CODE_GEN_ALIGN))); =20 -static inline void *alloc_code_gen_buffer(void) +static bool alloc_code_gen_buffer(size_t tb_size, Error **errp) { void *buf =3D static_code_gen_buffer; void *end =3D static_code_gen_buffer + sizeof(static_code_gen_buffer); @@ -1027,9 +1028,8 @@ static inline void *alloc_code_gen_buffer(void) size =3D end - buf; =20 /* Honor a command-line option limiting the size of the buffer. */ - if (size > tcg_ctx->code_gen_buffer_size) { - size =3D QEMU_ALIGN_DOWN(tcg_ctx->code_gen_buffer_size, - qemu_real_host_page_size); + if (size > tb_size) { + size =3D QEMU_ALIGN_DOWN(tb_size, qemu_real_host_page_size); } tcg_ctx->code_gen_buffer_size =3D size; =20 @@ -1041,31 +1041,43 @@ static inline void *alloc_code_gen_buffer(void) #endif =20 if (qemu_mprotect_rwx(buf, size)) { - abort(); + error_setg_errno(errp, errno, "mprotect of jit buffer"); + return false; } qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE); =20 - return buf; + tcg_ctx->code_gen_buffer =3D buf; + return true; } #elif defined(_WIN32) -static inline void *alloc_code_gen_buffer(void) +static bool alloc_code_gen_buffer(size_t size, Error **errp) { - size_t size =3D tcg_ctx->code_gen_buffer_size; - return VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, - PAGE_EXECUTE_READWRITE); + void *buf =3D VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, + PAGE_EXECUTE_READWRITE); + if (buf =3D=3D NULL) { + error_setg_win32(errp, GetLastError(), + "allocate %zu bytes for jit buffer", size); + return false; + } + + tcg_ctx->code_gen_buffer =3D buf; + tcg_ctx->code_gen_buffer_size =3D size; + return true; } #else -static inline void *alloc_code_gen_buffer(void) +static bool alloc_code_gen_buffer(size_t size, Error **errp) { int prot =3D PROT_WRITE | PROT_READ | PROT_EXEC; int flags =3D MAP_PRIVATE | MAP_ANONYMOUS; - size_t size =3D tcg_ctx->code_gen_buffer_size; void *buf; =20 buf =3D mmap(NULL, size, prot, flags, -1, 0); if (buf =3D=3D MAP_FAILED) { - return NULL; + error_setg_errno(errp, errno, + "allocate %zu bytes for jit buffer", size); + return false; } + tcg_ctx->code_gen_buffer_size =3D size; =20 #ifdef __mips__ if (cross_256mb(buf, size)) { @@ -1104,20 +1116,11 @@ static inline void *alloc_code_gen_buffer(void) /* Request large pages for the buffer. */ qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE); =20 - return buf; + tcg_ctx->code_gen_buffer =3D buf; + return true; } #endif /* USE_STATIC_CODE_GEN_BUFFER, WIN32, POSIX */ =20 -static inline void code_gen_alloc(size_t tb_size) -{ - tcg_ctx->code_gen_buffer_size =3D size_code_gen_buffer(tb_size); - tcg_ctx->code_gen_buffer =3D alloc_code_gen_buffer(); - if (tcg_ctx->code_gen_buffer =3D=3D NULL) { - fprintf(stderr, "Could not allocate dynamic translator buffer\n"); - exit(1); - } -} - static bool tb_cmp(const void *ap, const void *bp) { const TranslationBlock *a =3D ap; @@ -1144,11 +1147,16 @@ static void tb_htable_init(void) size. */ void tcg_exec_init(unsigned long tb_size) { + bool ok; + tcg_allowed =3D true; cpu_gen_init(); page_init(); tb_htable_init(); - code_gen_alloc(tb_size); + + ok =3D alloc_code_gen_buffer(size_code_gen_buffer(tb_size), &error_fat= al); + assert(ok); + #if defined(CONFIG_SOFTMMU) /* There's no guest base to take into account, so go ahead and initialize the prologue now. */ --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607975807; cv=none; d=zohomail.com; s=zohoarc; b=Pp97ag/Of6t7UZMCHHjD1XlkD311ryLw7YKeiClVuJNT73ro5HzeRRBMlGcE1VYTpt4eOFXK2ra5e5aIhFtknPOBz7PPbLa7tju0TexyrdPjvFk4US9le7erB0xzc7p2AS/8H+zLCmrGJiEuDdDwar6FZt46lWtwcjQctBkJ6Og= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607975807; h=Content-Transfer-Encoding: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=yJVJ7UYmMW4FjJF/lEzZ9AF4DC4CJTVYJENroIAg6mE=; b=katpF8GZJ+ORSwDB8fZzwTqoBQWaVt6c0zkP93ZVuX5BKHVqro3jL/zVG+otYjh293KZGgwhboXTUbfv4mZtkznY2qt/aVIUVqLFlYpu7Bq/0CEUEgBrgfh8PPGATqKxekQL7N+UnBRRUTOPhibPSwUoFascjwEDrcGiNS/tIRc= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607975807006242.23567391405118; Mon, 14 Dec 2020 11:56:47 -0800 (PST) Received: from localhost ([::1]:33456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koor3-0007lE-VX for importer@patchew.org; Mon, 14 Dec 2020 09:29:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSC-0001tZ-7p for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:56 -0500 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]:35831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooS5-0003x2-4R for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:55 -0500 Received: by mail-oi1-x241.google.com with SMTP id s2so19254751oij.2 for ; Mon, 14 Dec 2020 06:03:47 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yJVJ7UYmMW4FjJF/lEzZ9AF4DC4CJTVYJENroIAg6mE=; b=bN+5eSc/MwQS0xfwvOXHp5qNNqrKeiM4DfSg7c0Lv4AkiL5gjb+kzlyRnbCpU3msiJ L4hCx9OZDaAziZ4p/V2oIRpzaNrDr/KgZHHDnX1PCQvPnmEjMT1TdAit7oPDfAJsASgd 0LH8ak/R9Oj/1NMTi2yFgjzCMR36zG+8PDc3m6u0AhEngwMEeMqKjvF/1VpWrHxcK7k2 5m8eUvAMz4lAlA9kx4JunjaNSPBNOK2Z+rkmHOPS3LpVJC8WNPshT3pGvvR7hpAaYKTT tZzSzXQsVK4a1Kft4ElUMNZPvyM8PB3XaGuVSeJITBP/3VCdk9oyb9yH5Gr83D584Ndi 3s8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yJVJ7UYmMW4FjJF/lEzZ9AF4DC4CJTVYJENroIAg6mE=; b=Sd5dV0SKixf82la0fTQDqzSSv8m267ovdelDb9T4MHf2iq34khhIb9af0HuFk+6lil gMpx8TEbbj/QK1IXe43ucpX9Z7XIjmHCn+6mZ/vQ/4dMv1sOp9QfmzELc6E7dD1INWY+ 07b7fCCSXwq+G2OjN+t+dO4qDqWlHkHdswWg44VCIbpdKX/RJ4apHc4aZWJZx2Rzb8yG Z7abRu77mYxzc4t/KujJlUQEh/QVciP2CfmUzfnm4QquHSRkn/FBeDs0Jxv7CVwOKwwY P2SfRTnU7hg5eXkHhd/NoEkfcG7h5CClBYOtEfJXbg9O+FkwkGjq/f8PBHy1AR8RRBNE YcPQ== X-Gm-Message-State: AOAM530zkIaw1XY/FoHrAQAoNAEIfsaiXVIFD1TDbT2BKFtcMk+2prfE 2jgqYvqmRlkLEIKOvu9FPZtF8AML/kQIvL0E X-Google-Smtp-Source: ABdhPJyuzaJjnkHrRaaBcI4zlWFtaTwpJ1iEkZ1bcMw08DQtXSkFmQJiXlKU3lCN7F61xdG0i20/Dw== X-Received: by 2002:aca:3151:: with SMTP id x78mr13741788oix.39.1607954626665; Mon, 14 Dec 2020 06:03:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 17/43] tcg: Add --accel tcg,split-wx property Date: Mon, 14 Dec 2020 08:02:48 -0600 Message-Id: <20201214140314.18544-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::241; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x241.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, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Plumb the value through to alloc_code_gen_buffer. This is not supported by any os or tcg backend, so for now enabling it will result in an error. Signed-off-by: Richard Henderson --- include/sysemu/tcg.h | 3 ++- tcg/aarch64/tcg-target.h | 1 + tcg/arm/tcg-target.h | 1 + tcg/i386/tcg-target.h | 1 + tcg/mips/tcg-target.h | 1 + tcg/ppc/tcg-target.h | 1 + tcg/riscv/tcg-target.h | 1 + tcg/s390/tcg-target.h | 1 + tcg/sparc/tcg-target.h | 1 + tcg/tci/tcg-target.h | 1 + accel/tcg/tcg-all.c | 26 +++++++++++++++++++++++++- accel/tcg/translate-all.c | 35 +++++++++++++++++++++++++++-------- bsd-user/main.c | 2 +- linux-user/main.c | 2 +- 14 files changed, 65 insertions(+), 12 deletions(-) diff --git a/include/sysemu/tcg.h b/include/sysemu/tcg.h index d9d3ca8559..00349fb18a 100644 --- a/include/sysemu/tcg.h +++ b/include/sysemu/tcg.h @@ -8,7 +8,8 @@ #ifndef SYSEMU_TCG_H #define SYSEMU_TCG_H =20 -void tcg_exec_init(unsigned long tb_size); +void tcg_exec_init(unsigned long tb_size, int splitwx); + #ifdef CONFIG_TCG extern bool tcg_allowed; #define tcg_enabled() (tcg_allowed) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 6ba248f447..92aefc32d3 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -154,5 +154,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 =20 #endif /* AARCH64_TCG_TARGET_H */ diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 6ca4537ca6..7e04755428 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -141,5 +141,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 =20 #endif diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 0dcaed7fe6..04eefbfb90 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -231,5 +231,6 @@ static inline void tb_target_set_jmp_target(uintptr_t t= c_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 =20 #endif diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index d23baf7cda..d6dff897bf 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -200,6 +200,7 @@ extern bool use_mips32r2_instructions; =20 #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 +#define TCG_TARGET_SUPPORT_MIRROR 0 =20 void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index c41d10142b..8fc2672bf0 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -184,5 +184,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 =20 #endif diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 3d0745c70c..785fe37f9b 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -170,5 +170,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS =20 #define TCG_TARGET_HAS_MEMORY_BSWAP 0 +#define TCG_TARGET_SUPPORT_MIRROR 0 =20 #endif diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index 3750952598..fed3329e51 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -158,5 +158,6 @@ static inline void tb_target_set_jmp_target(uintptr_t t= c_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 =20 #endif diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index 9c15c91d39..21e7e2f56f 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -171,5 +171,6 @@ extern bool use_vis3_instructions; void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 =20 #endif diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index fcec2e70db..768153fd02 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -197,6 +197,7 @@ void tci_disas(uint8_t opc); #define TCG_TARGET_DEFAULT_MO (0) =20 #define TCG_TARGET_HAS_MEMORY_BSWAP 1 +#define TCG_TARGET_SUPPORT_MIRROR 0 =20 static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jm= p_rx, uintptr_t jmp_rw, uintptr_t ad= dr) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 1ac0b76515..2eea8c32ee 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -38,6 +38,7 @@ struct TCGState { AccelState parent_obj; =20 bool mttcg_enabled; + int splitwx_enabled; unsigned long tb_size; }; typedef struct TCGState TCGState; @@ -94,6 +95,13 @@ static void tcg_accel_instance_init(Object *obj) TCGState *s =3D TCG_STATE(obj); =20 s->mttcg_enabled =3D default_mttcg_enabled(); + + /* If debugging enabled, default "auto on", otherwise off. */ +#ifdef CONFIG_DEBUG_TCG + s->splitwx_enabled =3D -1; +#else + s->splitwx_enabled =3D 0; +#endif } =20 bool mttcg_enabled; @@ -102,7 +110,7 @@ static int tcg_init(MachineState *ms) { TCGState *s =3D TCG_STATE(current_accel()); =20 - tcg_exec_init(s->tb_size * 1024 * 1024); + tcg_exec_init(s->tb_size * 1024 * 1024, s->splitwx_enabled); mttcg_enabled =3D s->mttcg_enabled; =20 /* @@ -179,6 +187,18 @@ static void tcg_set_tb_size(Object *obj, Visitor *v, s->tb_size =3D value; } =20 +static bool tcg_get_splitwx(Object *obj, Error **errp) +{ + TCGState *s =3D TCG_STATE(obj); + return s->splitwx_enabled; +} + +static void tcg_set_splitwx(Object *obj, bool value, Error **errp) +{ + TCGState *s =3D TCG_STATE(obj); + s->splitwx_enabled =3D value; +} + static void tcg_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac =3D ACCEL_CLASS(oc); @@ -196,6 +216,10 @@ static void tcg_accel_class_init(ObjectClass *oc, void= *data) object_class_property_set_description(oc, "tb-size", "TCG translation block cache size"); =20 + object_class_property_add_bool(oc, "split-wx", + tcg_get_splitwx, tcg_set_splitwx); + object_class_property_set_description(oc, "split-wx", + "Map jit pages into separate RW and RX regions"); } =20 static const TypeInfo tcg_accel_type =3D { diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 2824b3e387..a29cb4a42e 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1015,13 +1015,19 @@ static inline void *split_cross_256mb(void *buf1, s= ize_t size1) static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE] __attribute__((aligned(CODE_GEN_ALIGN))); =20 -static bool alloc_code_gen_buffer(size_t tb_size, Error **errp) +static bool alloc_code_gen_buffer(size_t tb_size, int splitwx, Error **err= p) { - void *buf =3D static_code_gen_buffer; - void *end =3D static_code_gen_buffer + sizeof(static_code_gen_buffer); + void *buf, *end; size_t size; =20 + if (splitwx > 0) { + error_setg(errp, "jit split-wx not supported"); + return false; + } + /* page-align the beginning and end of the buffer */ + buf =3D static_code_gen_buffer; + end =3D static_code_gen_buffer + sizeof(static_code_gen_buffer); buf =3D QEMU_ALIGN_PTR_UP(buf, qemu_real_host_page_size); end =3D QEMU_ALIGN_PTR_DOWN(end, qemu_real_host_page_size); =20 @@ -1050,9 +1056,16 @@ static bool alloc_code_gen_buffer(size_t tb_size, Er= ror **errp) return true; } #elif defined(_WIN32) -static bool alloc_code_gen_buffer(size_t size, Error **errp) +static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) { - void *buf =3D VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, + void *buf; + + if (splitwx > 0) { + error_setg(errp, "jit split-wx not supported"); + return false; + } + + buf =3D VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (buf =3D=3D NULL) { error_setg_win32(errp, GetLastError(), @@ -1065,12 +1078,17 @@ static bool alloc_code_gen_buffer(size_t size, Erro= r **errp) return true; } #else -static bool alloc_code_gen_buffer(size_t size, Error **errp) +static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) { int prot =3D PROT_WRITE | PROT_READ | PROT_EXEC; int flags =3D MAP_PRIVATE | MAP_ANONYMOUS; void *buf; =20 + if (splitwx > 0) { + error_setg(errp, "jit split-wx not supported"); + return false; + } + buf =3D mmap(NULL, size, prot, flags, -1, 0); if (buf =3D=3D MAP_FAILED) { error_setg_errno(errp, errno, @@ -1145,7 +1163,7 @@ static void tb_htable_init(void) /* Must be called before using the QEMU cpus. 'tb_size' is the size (in bytes) allocated to the translation buffer. Zero means default size. */ -void tcg_exec_init(unsigned long tb_size) +void tcg_exec_init(unsigned long tb_size, int splitwx) { bool ok; =20 @@ -1154,7 +1172,8 @@ void tcg_exec_init(unsigned long tb_size) page_init(); tb_htable_init(); =20 - ok =3D alloc_code_gen_buffer(size_code_gen_buffer(tb_size), &error_fat= al); + ok =3D alloc_code_gen_buffer(size_code_gen_buffer(tb_size), + splitwx, &error_fatal); assert(ok); =20 #if defined(CONFIG_SOFTMMU) diff --git a/bsd-user/main.c b/bsd-user/main.c index 0a918e8f74..086351fc6f 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -908,7 +908,7 @@ int main(int argc, char **argv) } =20 /* init tcg before creating CPUs and to get qemu_host_page_size */ - tcg_exec_init(0); + tcg_exec_init(0, false); =20 cpu_type =3D parse_cpu_option(cpu_model); cpu =3D cpu_create(cpu_type); diff --git a/linux-user/main.c b/linux-user/main.c index 24d1eb73ad..5ff8100770 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -703,7 +703,7 @@ int main(int argc, char **argv, char **envp) cpu_type =3D parse_cpu_option(cpu_model); =20 /* init tcg before creating CPUs and to get qemu_host_page_size */ - tcg_exec_init(0); + tcg_exec_init(0, false); =20 cpu =3D cpu_create(cpu_type); env =3D cpu->env_ptr; --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607957971; cv=none; d=zohomail.com; s=zohoarc; b=C1c+9ubWrcoqKT5ieH7M5KIfYXqPUcJuKndO6iAMWl4k9nnSq5e/L3aJtxHx3pKXUd+WUsUkNVKEGhiOPrZn7xFtCuk160BkGX9AB7lAe4aQxmJ+LW6LZWi22u9dIOG9EZqON2PELEuypyKGyrmFTbqI3+dh1Hp617t1Xl060fU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607957971; h=Content-Transfer-Encoding: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=QxiqvQ209wXHxoJuZyW/ayX9Rmszqy3dKezpaxev5Pc=; b=NoCXCU8Td9mTwGIuYg7FlprA0joHIo46z1e/otuxq03mqJ1L/rTVlADWQ0RvktMK0AFZ6fey9jkStQc6iwEZIdpvReP9yNtpzTPzBaFzZSxW9nXayxcHucAfaSNtGLxj1/XgTYiQqte1BBUc10Jcy1Yh7p86y85EsfhXYVUc9yY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607957971912349.23355828010165; Mon, 14 Dec 2020 06:59:31 -0800 (PST) Received: from localhost ([::1]:59956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooh6-0003wy-UP for importer@patchew.org; Mon, 14 Dec 2020 09:19:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooS9-0001oG-Lz for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:53 -0500 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:36395) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooS5-0003x8-Vq for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:53 -0500 Received: by mail-ot1-x342.google.com with SMTP id y24so15768326otk.3 for ; Mon, 14 Dec 2020 06:03:49 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QxiqvQ209wXHxoJuZyW/ayX9Rmszqy3dKezpaxev5Pc=; b=q+eUyja2nllJDD6BeT4HYX1+kVRwBFT1LDi0GAvRYWrYlZ+P/AELr+2iXTzQuv6W9X vd2mxuAB1vz3din0cQIPEYn475V9Fw0R7wa2oow1mcIOQkqLgvdOzxexSpCTNvur+0q+ L7tkKzpRyciu4+uQfLedQ7E6qhAAqKZhloN10omU7HIs+jEIUrl9Go4Njs/D2BQVEP9G XqWOBgXNZFvr2QXeNRfiUW/uXQu3ECBS/yE9pvBubWhGMU5iRqI0ZR6lvd4JNZ97wHbE Dv/Mtqk4swhkOFOGjp+vf9TyqmCEM3QfviwtxxjTxOWEC5iHGVrLmfvGfNRC6QwRVa3U cTRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QxiqvQ209wXHxoJuZyW/ayX9Rmszqy3dKezpaxev5Pc=; b=UMJ0f9qSoJ1B66uDaZaX/62Le1q7qJ3mGM+vh4733C1J8Jygv+MqSNL6UhwOqWtKTO U4RooKunlM4q9zYmS8SQaeTQdpzpiDKP4kqQbnH2H37YZAc8IIOc23RtnsyUMZCxGdxS DuoqD3XVV05jjJshDJXE2uxa66Nxl9+y+FbhlFSE4DnedNfEEtO9sT/8YGh/ouXVHwXv prR9Ib5UA63jG4/qUmXSN8l3vKtNoC1/D5jzjKslwzHQMmUTCwzOeUzYLVZWc/kkSwNG BNdYkMWrrED3qPr5NGYKYPhXtFOX8YCwsT3wS0gsm/xVqAVJmvGYL1zqAGNxjALonf/A 5mcA== X-Gm-Message-State: AOAM532uoDu34kSfUl9BBbp17zdwaMVNnotVoYlvnhNsSMt0tkiodzLb 9I11wBNY5JjS4OEDQB7QEx2L6E3yRfz+y1Z6 X-Google-Smtp-Source: ABdhPJw7RdT4uSEwnj3dvnV6Wd5w5RhBa7ik6iCKU8kqgvp5n5S+IBQCF/mX/QGOnT1VvMRCC1XKIw== X-Received: by 2002:a9d:6414:: with SMTP id h20mr19425547otl.28.1607954628088; Mon, 14 Dec 2020 06:03:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 18/43] accel/tcg: Support split-wx for linux with memfd Date: Mon, 14 Dec 2020 08:02:49 -0600 Message-Id: <20201214140314.18544-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::342; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x342.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" We cannot use a real temp file, because we would need to find a filesystem that does not have noexec enabled. However, a memfd is not associated with any filesystem. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- accel/tcg/translate-all.c | 84 +++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 8 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index a29cb4a42e..1931e65365 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1078,17 +1078,11 @@ static bool alloc_code_gen_buffer(size_t size, int = splitwx, Error **errp) return true; } #else -static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) +static bool alloc_code_gen_buffer_anon(size_t size, int prot, + int flags, Error **errp) { - int prot =3D PROT_WRITE | PROT_READ | PROT_EXEC; - int flags =3D MAP_PRIVATE | MAP_ANONYMOUS; void *buf; =20 - if (splitwx > 0) { - error_setg(errp, "jit split-wx not supported"); - return false; - } - buf =3D mmap(NULL, size, prot, flags, -1, 0); if (buf =3D=3D MAP_FAILED) { error_setg_errno(errp, errno, @@ -1137,6 +1131,80 @@ static bool alloc_code_gen_buffer(size_t size, int s= plitwx, Error **errp) tcg_ctx->code_gen_buffer =3D buf; return true; } + +#ifdef CONFIG_POSIX +#include "qemu/memfd.h" + +static bool alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp) +{ + void *buf_rw, *buf_rx; + int fd =3D -1; + + buf_rw =3D qemu_memfd_alloc("tcg-jit", size, 0, &fd, errp); + if (buf_rw =3D=3D NULL) { + return false; + } + + buf_rx =3D mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0); + if (buf_rx =3D=3D MAP_FAILED) { + error_setg_errno(errp, errno, + "failed to map shared memory for execute"); + munmap(buf_rw, size); + close(fd); + return false; + } + close(fd); + + tcg_ctx->code_gen_buffer =3D buf_rw; + tcg_ctx->code_gen_buffer_size =3D size; + tcg_splitwx_diff =3D buf_rx - buf_rw; + + /* Request large pages for the buffer and the splitwx. */ + qemu_madvise(buf_rw, size, QEMU_MADV_HUGEPAGE); + qemu_madvise(buf_rx, size, QEMU_MADV_HUGEPAGE); + return true; +} +#endif /* CONFIG_POSIX */ + +static bool alloc_code_gen_buffer_splitwx(size_t size, Error **errp) +{ + if (TCG_TARGET_SUPPORT_MIRROR) { +#ifdef CONFIG_POSIX + return alloc_code_gen_buffer_splitwx_memfd(size, errp); +#endif + } + error_setg(errp, "jit split-wx not supported"); + return false; +} + +static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) +{ + ERRP_GUARD(); + int prot, flags; + + if (splitwx) { + if (alloc_code_gen_buffer_splitwx(size, errp)) { + return true; + } + /* + * If splitwx force-on (1), fail; + * if splitwx default-on (-1), fall through to splitwx off. + */ + if (splitwx > 0) { + return false; + } + error_free_or_abort(errp); + } + + prot =3D PROT_READ | PROT_WRITE | PROT_EXEC; + flags =3D MAP_PRIVATE | MAP_ANONYMOUS; +#ifdef CONFIG_TCG_INTERPRETER + /* The tcg interpreter does not need execute permission. */ + prot =3D PROT_READ | PROT_WRITE; +#endif + + return alloc_code_gen_buffer_anon(size, prot, flags, errp); +} #endif /* USE_STATIC_CODE_GEN_BUFFER, WIN32, POSIX */ =20 static bool tb_cmp(const void *ap, const void *bp) --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607955162; cv=none; d=zohomail.com; s=zohoarc; b=ULworb9AWLcPoVzz9yXW7qxqb3qkw2YsLh7jx4YlhQd5Xnn8YU2oXRRLIN2THda0aGDX8VabKFWOAooTUwET9NpJd4nwlCS4DUr8wZdG0WcxU2gg5Ip3TcyS6Lczm+YV8vgY/e0T87wQkSSGFrxucK+GDtK6JsoQYt1uk1Xewpg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607955162; 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=ymGaL1EBSCPIcfDoxvwITy+pJqgcYkV9uyyni3CD1Bk=; b=EoalIP2cT9ly26wUvV4B3g2iTQy7qON53sILGT5sJtpX20WAmPtsDVURUkxqiAw+E1sY8G/qC7mgYHH1Yp0gnGuNQcvmyP291bKAmO88MwiJIj8S91+rNP5DMSArqHJtIheqgXSo+09S2egR8OuMy5julDCE3xCMr4pPaJz/N/M= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607955162068894.3911067349313; Mon, 14 Dec 2020 06:12:42 -0800 (PST) Received: from localhost ([::1]:34972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooac-0002CO-UA for importer@patchew.org; Mon, 14 Dec 2020 09:12:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSA-0001pJ-8P for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:54 -0500 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]:41561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooS8-0003xQ-6n for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:53 -0500 Received: by mail-oi1-x241.google.com with SMTP id 15so19240603oix.8 for ; Mon, 14 Dec 2020 06:03:50 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ymGaL1EBSCPIcfDoxvwITy+pJqgcYkV9uyyni3CD1Bk=; b=HARW748hdlNXi7hvkDwarWVJml0h8sdonvyvZjbTxaVlmbICF7hgl4Ivwuz7MeHBEt uNXEIwnbioG2OQ7Qx+psBQ0IXPi8jB+BOJ6qoJpC1jAJ3LZ0TGtMF/SMuiMos3iQsiOU O6Nt26sMAWNQ8wcttMO7zFEjWBRpi41ALaCt4cXNsg+ceJ4nMSDVZ/M1ZTmqTg3fivQv BMgmrwRaSX9cx0WSS5dxWJSQHqdLFSyUQ21yjLdLED/QVii3xPe4CQNRANc4Q5sPppmU yVeIj06Zmf88ZTnuKcZ72ef8sH/9Vq3BO1/aLxtQemSTpjcdq2k7fHDAOvCENjwoJoXX zvgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ymGaL1EBSCPIcfDoxvwITy+pJqgcYkV9uyyni3CD1Bk=; b=cwh2JNmLEy04c5WdFysvtqBIEQHBS0a7lF/+TyMY+eAF8EICVkXqSdwPbW+BjKwY7f bsmRvzH+6zCgRiOub6gnnq6qciq/GkSV8fz9qWUEAlKJPz1rDTCbYVBzm5AgCyBNzsmR IAh9cR7UoS6Nkr2vRBA1BhH8ahHaIVpsWBhSeeMyqDeLAr5I4RVcbqRVjcrY3ln2T5FH UljXU7H+XcLF19fdExWuNlgoAMWsXfkkEz+DAJmfFHcrRC/GFQ6/rig8A3zTIozlvWr/ qJk/PpSgvbFxMgcjSrYL2uql/1ryPDz+/ttqrTV00m+2maIE1VOd7LG44UpWqusnfhc3 7f9A== X-Gm-Message-State: AOAM533XqfcUos8uMIdXv6/psftiyHbbp/lHlAF2PJBdwU+EkGxLSa+b 5a3F33cuh1tAHY9DKkcK6Wfj3FWjfUcbr81B X-Google-Smtp-Source: ABdhPJzH9pvZi7G8w9m/y3rfWLogH1apEoyjLTZdNFojxB2HKHu8oQLtQoY8hEn+rHBp621JUjDHhQ== X-Received: by 2002:aca:538c:: with SMTP id h134mr19014639oib.44.1607954629758; Mon, 14 Dec 2020 06:03:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 19/43] accel/tcg: Support split-wx for darwin/iOS with vm_remap Date: Mon, 14 Dec 2020 08:02:50 -0600 Message-Id: <20201214140314.18544-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::241; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x241.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Cribbed from code posted by Joelle van Dyne , and rearranged to a cleaner structure. Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 1931e65365..17df6c94fa 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1166,9 +1166,71 @@ static bool alloc_code_gen_buffer_splitwx_memfd(size= _t size, Error **errp) } #endif /* CONFIG_POSIX */ =20 +#ifdef CONFIG_DARWIN +#include + +extern kern_return_t mach_vm_remap(vm_map_t target_task, + mach_vm_address_t *target_address, + mach_vm_size_t size, + mach_vm_offset_t mask, + int flags, + vm_map_t src_task, + mach_vm_address_t src_address, + boolean_t copy, + vm_prot_t *cur_protection, + vm_prot_t *max_protection, + vm_inherit_t inheritance); + +static bool alloc_code_gen_buffer_splitwx_vmremap(size_t size, Error **err= p) +{ + kern_return_t ret; + mach_vm_address_t buf_rw, buf_rx; + vm_prot_t cur_prot, max_prot; + + /* Map the read-write portion via normal anon memory. */ + if (!alloc_code_gen_buffer_anon(size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, errp)) { + return false; + } + + buf_rw =3D (mach_vm_address_t)tcg_ctx->code_gen_buffer; + buf_rx =3D 0; + ret =3D mach_vm_remap(mach_task_self(), + &buf_rx, + size, + 0, + VM_FLAGS_ANYWHERE, + mach_task_self(), + buf_rw, + false, + &cur_prot, + &max_prot, + VM_INHERIT_NONE); + if (ret !=3D KERN_SUCCESS) { + /* TODO: Convert "ret" to a human readable error message. */ + error_setg(errp, "vm_remap for jit splitwx failed"); + munmap((void *)buf_rw, size); + return false; + } + + if (mprotect((void *)buf_rx, size, PROT_READ | PROT_EXEC) !=3D 0) { + error_setg_errno(errp, errno, "mprotect for jit splitwx"); + munmap((void *)buf_rx, size); + munmap((void *)buf_rw, size); + return false; + } + + tcg_splitwx_diff =3D buf_rx - buf_rw; + return true; +} +#endif /* CONFIG_DARWIN */ + static bool alloc_code_gen_buffer_splitwx(size_t size, Error **errp) { if (TCG_TARGET_SUPPORT_MIRROR) { +#ifdef CONFIG_DARWIN + return alloc_code_gen_buffer_splitwx_vmremap(size, errp); +#endif #ifdef CONFIG_POSIX return alloc_code_gen_buffer_splitwx_memfd(size, errp); #endif @@ -1201,6 +1263,9 @@ static bool alloc_code_gen_buffer(size_t size, int sp= litwx, Error **errp) #ifdef CONFIG_TCG_INTERPRETER /* The tcg interpreter does not need execute permission. */ prot =3D PROT_READ | PROT_WRITE; +#elif defined(CONFIG_DARWIN) + /* Applicable to both iOS and macOS (Apple Silicon). */ + flags |=3D MAP_JIT; #endif =20 return alloc_code_gen_buffer_anon(size, prot, flags, errp); --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607977758; cv=none; d=zohomail.com; s=zohoarc; b=doq0QrMs03ehdVmAYq5JEN0Tw+9BOPqHKKIFUed5u+dqpSiU/u0vn0y/hUzP1oSR52JnMwc6+1qI/7vJIg65A5QV3ruf4r7cK2woDOO+IRCKdNZQ1T1HPD9rhDJmijjhVAf4MWij4QjG9zt1ohUdENaVMqRlecV0Vg/O0d4xkzs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607977758; h=Content-Transfer-Encoding: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=PE5zDJYupwBF6LFLJEA3Vgnp30HPDgVW1boJkF7byFo=; b=k1ZXOVERbG3iQoOZJOqibTfau58KltJZYUmmgME9UFaX/PDRodhURsfds4GTtW7GhTKWRM+3ARoYiK7ymM2jAdq3hVmMEO7RWzziYDp4U7IhqCW6Xh5gS1E6rDcziDnILuORdjfEUSpusLLTGKoUHcpgy6/cvgfRZB2lVfLc4gA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607977758460883.8663587422913; Mon, 14 Dec 2020 12:29:18 -0800 (PST) Received: from localhost ([::1]:39442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koojR-00077h-Rn for importer@patchew.org; Mon, 14 Dec 2020 09:21:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSB-0001rz-DU for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:55 -0500 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]:37238) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooS8-0003xm-KX for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:55 -0500 Received: by mail-ot1-x32b.google.com with SMTP id o11so15760047ote.4 for ; Mon, 14 Dec 2020 06:03:52 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PE5zDJYupwBF6LFLJEA3Vgnp30HPDgVW1boJkF7byFo=; b=Wa68fek1X12CUOK+gMbuQ/TFhZrtUUcTu8d13SdLArDPFpOF1WN/DYYHl5gh7GnM+3 Ju03VB+HMsG3HFp4ewb2i3EghKpKBc38fIMRlmAXROHvCLjREmErTKNZsFLhWEtG9Yxd 38+N1chOFLuQrmwnDdnfUzvY36+tzY+4NcXUpJf1fbRpcOq6VdY6J3tPOjU4wN6w301Y caLyzOm58Yz+J2SZbJCy4kmnoKOwllel0uhrutrT9k36Brmd4R9uxk8KZ8ym82POd7vW liySuTRPLhKyzNXlC3yavgAsfFNdDhG/NX2t/I4pT/zzaiJ197lmWDOBFxtaLBQNGwDz kNKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PE5zDJYupwBF6LFLJEA3Vgnp30HPDgVW1boJkF7byFo=; b=gXjJsiHKOuLx/MzegPxFlw8ESvsT+02WDV9sH7ZF25NSOk3m76b/lafCd123wLUPM9 ahgjVvH2jGLjIDQdvJD3FTQSMUf9aFy4BQB58I6Ni64bGLAn4RfRjGTfsWAaVFwC64F+ coH5ZoR8E8XhZCoguctQCYIRw2YrO9viW4Z7Vkm8n6Lq0LNvXBt4aBWLrRmyokhAyaSI GYClnBt8Zm893wWMgi8HhBGVXS0uPb9f5gYRqRI6g2sZyIbQJBv0BbbUP96GOuX78zPm bGkCtcppHcip7+tciFI1Tm06YmxarDCdqh6CrOSKHsoOjUhX+3HNrHDPQrPrIcXZbDEC CPhQ== X-Gm-Message-State: AOAM5317K02LMsTtiobDijD3zWmUX5VH7Zmei787Co5lZtCnceIOo6w8 Voe3E27G2evjfrI1Kia5rRB16K8bAT4captk X-Google-Smtp-Source: ABdhPJzDyfJTTk46nOXZllp+EIetReafEfZXcot+0UQP9yaB71ffODP7o4Yaj/M8p1f1i06SVNci4w== X-Received: by 2002:a05:6830:114e:: with SMTP id x14mr19411679otq.253.1607954630753; Mon, 14 Dec 2020 06:03:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 20/43] tcg: Return the TB pointer from the rx region from exit_tb Date: Mon, 14 Dec 2020 08:02:51 -0600 Message-Id: <20201214140314.18544-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::32b; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32b.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" This produces a small pc-relative displacement within the generated code to the TB structure that preceeds it. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- accel/tcg/cpu-exec.c | 35 ++++++++++++++++++++++------------- tcg/tcg-op.c | 13 ++++++++++++- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 272d596e0c..8df0a1782e 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -144,12 +144,13 @@ static void init_delay_params(SyncClocks *sc, const C= PUState *cpu) #endif /* CONFIG USER ONLY */ =20 /* Execute a TB, and fix up the CPU state afterwards if necessary */ -static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock= *itb) +static inline TranslationBlock *cpu_tb_exec(CPUState *cpu, + TranslationBlock *itb, + int *tb_exit) { CPUArchState *env =3D cpu->env_ptr; uintptr_t ret; TranslationBlock *last_tb; - int tb_exit; const void *tb_ptr =3D itb->tc.ptr; =20 qemu_log_mask_and_addr(CPU_LOG_EXEC, itb->pc, @@ -177,11 +178,20 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *= cpu, TranslationBlock *itb) =20 ret =3D tcg_qemu_tb_exec(env, tb_ptr); cpu->can_do_io =3D 1; - last_tb =3D (TranslationBlock *)(ret & ~TB_EXIT_MASK); - tb_exit =3D ret & TB_EXIT_MASK; - trace_exec_tb_exit(last_tb, tb_exit); + /* + * TODO: Delay swapping back to the read-write region of the TB + * until we actually need to modify the TB. The read-only copy, + * coming from the rx region, shares the same host TLB entry as + * the code that executed the exit_tb opcode that arrived here. + * If we insist on touching both the RX and the RW pages, we + * double the host TLB pressure. + */ + last_tb =3D tcg_splitwx_to_rw((void *)(ret & ~TB_EXIT_MASK)); + *tb_exit =3D ret & TB_EXIT_MASK; =20 - if (tb_exit > TB_EXIT_IDX1) { + trace_exec_tb_exit(last_tb, *tb_exit); + + if (*tb_exit > TB_EXIT_IDX1) { /* We didn't start executing this TB (eg because the instruction * counter hit zero); we must restore the guest PC to the address * of the start of the TB. @@ -199,7 +209,7 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cp= u, TranslationBlock *itb) cc->set_pc(cpu, last_tb->pc); } } - return ret; + return last_tb; } =20 #ifndef CONFIG_USER_ONLY @@ -210,6 +220,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cyc= les, { TranslationBlock *tb; uint32_t cflags =3D curr_cflags() | CF_NOCACHE; + int tb_exit; =20 if (ignore_icount) { cflags &=3D ~CF_USE_ICOUNT; @@ -227,7 +238,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cyc= les, =20 /* execute the generated code */ trace_exec_tb_nocache(tb, tb->pc); - cpu_tb_exec(cpu, tb); + cpu_tb_exec(cpu, tb, &tb_exit); =20 mmap_lock(); tb_phys_invalidate(tb, -1); @@ -244,6 +255,7 @@ void cpu_exec_step_atomic(CPUState *cpu) uint32_t flags; uint32_t cflags =3D 1; uint32_t cf_mask =3D cflags & CF_HASH_MASK; + int tb_exit; =20 if (sigsetjmp(cpu->jmp_env, 0) =3D=3D 0) { start_exclusive(); @@ -260,7 +272,7 @@ void cpu_exec_step_atomic(CPUState *cpu) cc->cpu_exec_enter(cpu); /* execute the generated code */ trace_exec_tb(tb, pc); - cpu_tb_exec(cpu, tb); + cpu_tb_exec(cpu, tb, &tb_exit); cc->cpu_exec_exit(cpu); } else { /* @@ -653,13 +665,10 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, TranslationBlock **last_tb, int *tb_ex= it) { - uintptr_t ret; int32_t insns_left; =20 trace_exec_tb(tb, tb->pc); - ret =3D cpu_tb_exec(cpu, tb); - tb =3D (TranslationBlock *)(ret & ~TB_EXIT_MASK); - *tb_exit =3D ret & TB_EXIT_MASK; + tb =3D cpu_tb_exec(cpu, tb, tb_exit); if (*tb_exit !=3D TB_EXIT_REQUESTED) { *last_tb =3D tb; return; diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index e3dc0cb4cb..56bb8db040 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2666,7 +2666,18 @@ void tcg_gen_extr32_i64(TCGv_i64 lo, TCGv_i64 hi, TC= Gv_i64 arg) =20 void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx) { - uintptr_t val =3D (uintptr_t)tb + idx; + /* + * Let the jit code return the read-only version of the + * TranslationBlock, so that we minimize the pc-relative + * distance of the address of the exit_tb code to TB. + * This will improve utilization of pc-relative address loads. + * + * TODO: Move this to translator_loop, so that all const + * TranslationBlock pointers refer to read-only memory. + * This requires coordination with targets that do not use + * the translator_loop. + */ + uintptr_t val =3D (uintptr_t)tcg_splitwx_to_rx((void *)tb) + idx; =20 if (tb =3D=3D NULL) { tcg_debug_assert(idx =3D=3D 0); --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607975798; cv=none; d=zohomail.com; s=zohoarc; b=NsNGQpDhyGVZzIIochruPASKFNsBwXlZv2cOYTEgml6OmGSNgV+w0hNt/1su6nPDhAOvQZ0jKHKw+dwRIHpBBZWcaQHrMuTmRgHQKF7d4uU8o9gKbZU1cLgNqagZ4DFrwFv9mGj9hzfpHJvaBgIPtyFfGyS/hZZUwbTudlVxAbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607975798; h=Content-Transfer-Encoding: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=OGI5CxyxTF/dbCInhRa9B5Chz/cSyqz69O9vDa9Oxg0=; b=lVTken35mwUylAEVx1XejG7qH+9CqzejvCQklN4gxe6QnyiW8izWaotCMsnHPSzCNvQiSvfrJjRdehzawm1yf1aY3yDPXkY21ssvOOoXSmkEIK3YELMWXghDGsQ9z8PH81o28vUV9bJDrvfYwWQCcUyxHrGGpZJAjWI3Vi5yBAg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607975798739566.6547761573324; Mon, 14 Dec 2020 11:56:38 -0800 (PST) Received: from localhost ([::1]:43346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koocY-0005ZG-3U for importer@patchew.org; Mon, 14 Dec 2020 09:14:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSD-0001wY-Gu for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:57 -0500 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]:46382) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSA-0003y2-3F for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:57 -0500 Received: by mail-ot1-x335.google.com with SMTP id w3so15756601otp.13 for ; Mon, 14 Dec 2020 06:03:53 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OGI5CxyxTF/dbCInhRa9B5Chz/cSyqz69O9vDa9Oxg0=; b=Im0tD85RfrABwMbtbZuAW+HmJYIhfmG5hwgKaCx7ru9svTTOnwu9tFAFC6QF9clAag Im3czpcSd5p/vv0JE4PuoVmr8gOBUG27HbXBHTZPaj0yhFbvgunS0wDau7A/MeTwxjJU ihBx4SH53TqLZvfGAquOI7UjVkgDql/fIOW7DmvIJ7d73jbBdh5u0AwJ5HM31+PfEnOb rnYuU8C8ogpaD97WaBtQjXJ4KbBuCAXaA2SJp2TXcNl9pRFkSaOdLwb5YahhYJJeZzw4 onsKOTPnJnzBLg3CF+32DwVpOHISBsHpL0qtKJmkdpS219y1VCSYfQJ9iWb8RZxjZRvc ieaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OGI5CxyxTF/dbCInhRa9B5Chz/cSyqz69O9vDa9Oxg0=; b=M0vpiAAfjkbgfD7DEUNhcv/bm6PdQcPbiY1MnJi5WzvsTYEPPV/64d/R5dkJBdokyd c9RdfLJB+5+8FEMy3WKcJnpc6FHVSUU2gQ2G6RJjWPYm2EPq4jB+fUhS8GlCrUTm9Ycl yFw2KO922RFfEjQmauT4RCYMmTXrQodZhAuGO3Qqs2nSJbc2PF7kDu1yjFRGktpoQV4m QF9tgBuxG8Kfz4HTH8bXVnJWJ3Bl663wnNSVat1JC3Q9fMTeV/owp9mq3jcWouWAil8D Dw8qEKilRrKL9hLuLaryJ30/b5qKihvtUTOtw5+0iRHk68o6t3uuTKgH159NQK8ooq62 /nmg== X-Gm-Message-State: AOAM53326l0Iz3TECkEBuC9Xli4XomVrZnjm/mmYjCppHfIMXZIuwdIS 0RC8k8yp5fCrDpY1y1tQzxAX4EnLDyjN7Zch X-Google-Smtp-Source: ABdhPJyzFW++ByXz910YOuLT+ULApO9ml6ebzivzmn4AxGmgd1L/MH4+siv6GW9BakP3FH22Ak+Haw== X-Received: by 2002:a05:6830:2371:: with SMTP id r17mr20042064oth.236.1607954632463; Mon, 14 Dec 2020 06:03:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 21/43] tcg/i386: Support split-wx code generation Date: Mon, 14 Dec 2020 08:02:52 -0600 Message-Id: <20201214140314.18544-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::335; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x335.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- tcg/i386/tcg-target.h | 2 +- tcg/i386/tcg-target.c.inc | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 04eefbfb90..2e57e95ac2 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -231,6 +231,6 @@ static inline void tb_target_set_jmp_target(uintptr_t t= c_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 7f74c77d7f..23c7a8a383 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -165,7 +165,7 @@ static bool have_lzcnt; # define have_lzcnt 0 #endif =20 -static tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *tb_ret_addr; =20 static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) @@ -173,7 +173,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int ty= pe, value +=3D addend; switch(type) { case R_386_PC32: - value -=3D (uintptr_t)code_ptr; + value -=3D (uintptr_t)tcg_splitwx_to_rx(code_ptr); if (value !=3D (int32_t)value) { return false; } @@ -182,7 +182,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int ty= pe, tcg_patch32(code_ptr, value); break; case R_386_PC8: - value -=3D (uintptr_t)code_ptr; + value -=3D (uintptr_t)tcg_splitwx_to_rx(code_ptr); if (value !=3D (int8_t)value) { return false; } @@ -1006,7 +1006,7 @@ static void tcg_out_movi(TCGContext *s, TCGType type, } =20 /* Try a 7 byte pc-relative lea before the 10 byte movq. */ - diff =3D arg - ((uintptr_t)s->code_ptr + 7); + diff =3D tcg_pcrel_diff(s, (const void *)arg) - 7; if (diff =3D=3D (int32_t)diff) { tcg_out_opc(s, OPC_LEA | P_REXW, ret, 0, 0); tcg_out8(s, (LOWREGMASK(ret) << 3) | 5); @@ -1615,7 +1615,7 @@ static inline void tcg_out_call(TCGContext *s, const = tcg_insn_unit *dest) tcg_out_branch(s, 1, dest); } =20 -static void tcg_out_jmp(TCGContext *s, tcg_insn_unit *dest) +static void tcg_out_jmp(TCGContext *s, const tcg_insn_unit *dest) { tcg_out_branch(s, 0, dest); } @@ -1786,7 +1786,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool i= s_ld, bool is_64, label->datahi_reg =3D datahi; label->addrlo_reg =3D addrlo; label->addrhi_reg =3D addrhi; - label->raddr =3D raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr[0]; if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) { label->label_ptr[1] =3D label_ptr[1]; @@ -2280,7 +2281,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcod= e opc, /* jump displacement must be aligned for atomic patching; * see if we need to add extra nops before jump */ - gap =3D tcg_pcrel_diff(s, QEMU_ALIGN_PTR_UP(s->code_ptr + 1, 4= )); + gap =3D QEMU_ALIGN_PTR_UP(s->code_ptr + 1, 4) - s->code_ptr; if (gap !=3D 1) { tcg_out_nopn(s, gap - 1); } @@ -3825,11 +3826,12 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - tcg_code_gen_epilogue =3D s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0); =20 /* TB epilogue */ - tb_ret_addr =3D s->code_ptr; + tb_ret_addr =3D tcg_splitwx_to_rx(s->code_ptr); =20 tcg_out_addi(s, TCG_REG_CALL_STACK, stack_addend); =20 --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607977764; cv=none; d=zohomail.com; s=zohoarc; b=MjRPRc0HXJMZF06pisWr4w9tCdBzREzAASN02CxaPsxngVuiTXoaYT3fP3mKMv1Jk64115sY6T6380R9a3pt/6ygdwZqLWqWRQUR4u5mdbilbbdrYxG/4RpKmdO4gaV8GJDkcnPJJhdKxVQVcSMRFS9HUfFdLKOUCsQG6DJnyOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607977764; h=Content-Transfer-Encoding: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=YKIoLTi5ySgzCVvhycZMdw7nP6Jv58IFUwkqltF23wU=; b=Walpu8yN9xr3A0Qn/asMpAHSVj1omkhhS7++w3GyrGmujBhi9Aqew3FZmm0wbJWln0sYv3gyjmaBWfHkJf/vVBy84gMATjygzVuWMTAXw356f5MORFbJeRqZXX8gcfnAZBMxzG5+jSGgiLkEKkeQLBNX7GLOdH4z/H3im2SmZk8= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607977764340681.4210269755567; Mon, 14 Dec 2020 12:29:24 -0800 (PST) Received: from localhost ([::1]:40236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kootN-0002AO-Mf for importer@patchew.org; Mon, 14 Dec 2020 09:32:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSE-0001yI-Cm for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:58 -0500 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]:46011) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSB-0003yG-Sn for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:03:58 -0500 Received: by mail-ot1-x32b.google.com with SMTP id h18so15762807otq.12 for ; Mon, 14 Dec 2020 06:03:55 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=YKIoLTi5ySgzCVvhycZMdw7nP6Jv58IFUwkqltF23wU=; b=NWB61TiIZFqsBWSTFRTlWr8p0DDqLOVuvdA0LBRrcL12HTHdURYadXRUDBCbYcPmYd MMGxNLPDpgDAAicWJXM0/G5IE+7sEhcWivp0xZxVm7rjm2pasD2nUt0x5aCASMK5Ifa4 cLMwk/rNeyymqOJjwcyW1KyTBaddD/9BG8b9fKM0yL6X2a1QRexgXzXex6DlZBs+u2yA /Cv1qFXRGAdtaWMbKOzu8arXMvW5Q68LwjoC9oaB4QwcfdP8a0Mkc52ZQqhWGGQMBL4V VzLdBGw2pdCmexnDKSeSVkOaKoo8wsk32bt2BoClNgp8IWABn/JsyEIPYxCZqd2nu6Jd /98g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YKIoLTi5ySgzCVvhycZMdw7nP6Jv58IFUwkqltF23wU=; b=SSU68Ujfi2ktZwntvvTlxfsxMF2mJMDqZkntv26aAPNKOmMDYM9kthAE2W6ICIpgD1 u8FCnB5P+eZmphhr8J/eQ9bGfBH3nIhdFmNPEJad0OO5ItQoJvBXxuXj3Q1Xvg38977F x90lPeGyPxUU7Ezo/OF1RR0qV/xIMknUh4N9lPRzZWEnRR+StC+XHctBJCw1n/As422p Odu8g08UJrHhXxpUgGYRP8UP6anyNi1CY5KcLM53TBX2tzOMG68QpItEtFT1CSwv6x/A IppKzLvgsIEiCg6yI7kNMNJKvQtjMHOayn07mb+tLyWY+SHoWa6ZUfTXmsr6unDYGp6x er2Q== X-Gm-Message-State: AOAM532ucEQyC2LsAeTm2kgerohcSlAI5rQQU4CLujRaB0XKLFr2Tu1R nMzjCtEeUxsheZUOr15leMcmcZjiCxlzdWZ1 X-Google-Smtp-Source: ABdhPJxLU6Ww1hWfsg9WyxiRFzvKFyys8iVoZFMTMfE5OCcENzeJ65qXXXEAIGX5xDYOrCUVtPrfpA== X-Received: by 2002:a9d:32b6:: with SMTP id u51mr18875591otb.119.1607954634157; Mon, 14 Dec 2020 06:03:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 22/43] tcg/aarch64: Use B not BL for tcg_out_goto_long Date: Mon, 14 Dec 2020 08:02:53 -0600 Message-Id: <20201214140314.18544-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::32b; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32b.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" A typo generated a branch-and-link insn instead of plain branch. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- tcg/aarch64/tcg-target.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index fea784cf75..bd888bc66d 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1317,7 +1317,7 @@ static inline void tcg_out_goto_long(TCGContext *s, t= cg_insn_unit *target) { ptrdiff_t offset =3D target - s->code_ptr; if (offset =3D=3D sextract64(offset, 0, 26)) { - tcg_out_insn(s, 3206, BL, offset); + tcg_out_insn(s, 3206, B, offset); } else { tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, (intptr_t)target); tcg_out_insn(s, 3207, BR, TCG_REG_TMP); --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607975613; cv=none; d=zohomail.com; s=zohoarc; b=njtfWHOSUTlrAefDfaxMaLcZv4eTexa4mJpN/1dSEZt6eJFjS+AF4ZAHZVyYgJje1Pry0Zqt3muZwWSb7hCV+9+aehKCpVnacGwiqu448vs7PfxlF60xvxai/MFZIwkTZ2DOvb3Vb6MZp05WINLnJFHeSWBhKsNCM1NNrykJ9LM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607975613; h=Content-Transfer-Encoding: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=qjl1QspWlOuJ+/D2vJaBwH05ftTGSnNZLxwMR0hFvkY=; b=TkQEu1V7yAQj8g+53/iNyREvJJWvuG5fiuMS6pMFvAKkEr/5xFL62C0w4bJ/OgznUEK+IMFOVslgvVyhLzpvdUhww39qXEwASaOtVl8KqwlmtYngaHDKgQcK/h1zfx26l0K059XKhFrSmJ4kjMQJIseIKcV5quJkUGKvcWM8sqQ= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607975613113604.0621755724044; Mon, 14 Dec 2020 11:53:33 -0800 (PST) Received: from localhost ([::1]:45756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koolf-0001GQ-LK for importer@patchew.org; Mon, 14 Dec 2020 09:24:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSK-00022f-Vg for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:06 -0500 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]:43702) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSC-0003yU-V2 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:04 -0500 Received: by mail-ot1-x332.google.com with SMTP id q25so15757684otn.10 for ; Mon, 14 Dec 2020 06:03:56 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=qjl1QspWlOuJ+/D2vJaBwH05ftTGSnNZLxwMR0hFvkY=; b=SLG3pl8IrZCFnHBWTynRUCZ/XUTpjh33loomHFobBr/dKZecLe9eRfjVTkU4nSAri5 Rx4MIH6nk32+XtF2JWOr9QjwuxBSJUhwjfiMbYGSur67vg5Ao0Sr+OcMuwQLjZkF6RyK 1niFAXyI5KBQiwr5rDjhZVS3/hhN8vD0g53+P/GqBMoesngxfuGAGXCKyvdQZ26msP76 og6P0JOHblU/u9sgAJLEDqGGJCBLAl4D5EYSQDnDBv3ZHnoSmyJZRWxNrerIGC1stEUD 7Gr4G07HxkjWzFI9yKFTmVP5rpoW7QAO99O3N/tAcPCU2/hmGQeHx12Uk+VQeWZ0cv2I Fmwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qjl1QspWlOuJ+/D2vJaBwH05ftTGSnNZLxwMR0hFvkY=; b=n8Eib7HmA7xCIkMI3a4tFCFwt1M8mtHM/f5jax0ta6m1u7mUe1pIjxpHsde0eyZbN0 rGi2s8kSiTNC4Ab5X4W5I+I0jePQX+Z+paIeSZGXcSq5XQ7WO6xdpMs5YPHhPFBumD/T O6pKQ1b0SCqw0tVjEkENuHhqv1BDzTJUq3o8viGHnNUrakHPC163LN3aawfZvC1rukHF +TWHcdQbTazAYnRmgz30VcMsLOxx8EvKlR5+l+kmpl9Hz2Ee8KC8vTg4lz2I8s/itHVS +dZXaHFksu7YPxkTbe3T1bCTk8B49FcPp2ZOnrZE56nICwHnwJCHemrg/AGecBy9g4g2 vQMg== X-Gm-Message-State: AOAM532QslUimtRnTW/EWc5RX+30ivtbjWVIOrzeJguvCoZGYhheGUbR 2RB4+uTO5/6iD9XwFUxRoWXswMrc84cEk415 X-Google-Smtp-Source: ABdhPJwVgxSePPjpBVCbG4t3AQ7NlANOCQ40eeRwQOOl8uo0dPLqH3LIVq6/kEybGo+7WZgvwyhE5A== X-Received: by 2002:a9d:4793:: with SMTP id b19mr19292987otf.193.1607954635444; Mon, 14 Dec 2020 06:03:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 23/43] tcg/aarch64: Support split-wx code generation Date: Mon, 14 Dec 2020 08:02:54 -0600 Message-Id: <20201214140314.18544-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::332; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x332.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- tcg/aarch64/tcg-target.h | 2 +- tcg/aarch64/tcg-target.c.inc | 57 ++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 92aefc32d3..81778e3a9c 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -154,6 +154,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif /* AARCH64_TCG_TARGET_H */ diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index bd888bc66d..2e33162c03 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -78,38 +78,42 @@ static const int tcg_target_call_oarg_regs[1] =3D { #define TCG_REG_GUEST_BASE TCG_REG_X28 #endif =20 -static inline bool reloc_pc26(tcg_insn_unit *code_ptr, tcg_insn_unit *targ= et) +static bool reloc_pc26(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset =3D target - code_ptr; + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset =3D target - src_rx; + if (offset =3D=3D sextract64(offset, 0, 26)) { /* read instruction, mask away previous PC_REL26 parameter content= s, set the proper offset, then write back the instruction. */ - *code_ptr =3D deposit32(*code_ptr, 0, 26, offset); + *src_rw =3D deposit32(*src_rw, 0, 26, offset); return true; } return false; } =20 -static inline bool reloc_pc19(tcg_insn_unit *code_ptr, tcg_insn_unit *targ= et) +static bool reloc_pc19(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset =3D target - code_ptr; + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset =3D target - src_rx; + if (offset =3D=3D sextract64(offset, 0, 19)) { - *code_ptr =3D deposit32(*code_ptr, 5, 19, offset); + *src_rw =3D deposit32(*src_rw, 5, 19, offset); return true; } return false; } =20 -static inline bool patch_reloc(tcg_insn_unit *code_ptr, int type, - intptr_t value, intptr_t addend) +static bool patch_reloc(tcg_insn_unit *code_ptr, int type, + intptr_t value, intptr_t addend) { tcg_debug_assert(addend =3D=3D 0); switch (type) { case R_AARCH64_JUMP26: case R_AARCH64_CALL26: - return reloc_pc26(code_ptr, (tcg_insn_unit *)value); + return reloc_pc26(code_ptr, (const tcg_insn_unit *)value); case R_AARCH64_CONDBR19: - return reloc_pc19(code_ptr, (tcg_insn_unit *)value); + return reloc_pc19(code_ptr, (const tcg_insn_unit *)value); default: g_assert_not_reached(); } @@ -1050,12 +1054,13 @@ static void tcg_out_movi(TCGContext *s, TCGType typ= e, TCGReg rd, /* Look for host pointer values within 4G of the PC. This happens often when loading pointers to QEMU's own data structures. */ if (type =3D=3D TCG_TYPE_I64) { - tcg_target_long disp =3D value - (intptr_t)s->code_ptr; + intptr_t src_rx =3D (intptr_t)tcg_splitwx_to_rx(s->code_ptr); + tcg_target_long disp =3D value - src_rx; if (disp =3D=3D sextract64(disp, 0, 21)) { tcg_out_insn(s, 3406, ADR, rd, disp); return; } - disp =3D (value >> 12) - ((intptr_t)s->code_ptr >> 12); + disp =3D (value >> 12) - (src_rx >> 12); if (disp =3D=3D sextract64(disp, 0, 21)) { tcg_out_insn(s, 3406, ADRP, rd, disp); if (value & 0xfff) { @@ -1308,14 +1313,14 @@ static void tcg_out_cmp(TCGContext *s, TCGType ext,= TCGReg a, =20 static void tcg_out_goto(TCGContext *s, const tcg_insn_unit *target) { - ptrdiff_t offset =3D target - s->code_ptr; + ptrdiff_t offset =3D tcg_pcrel_diff(s, target) >> 2; tcg_debug_assert(offset =3D=3D sextract64(offset, 0, 26)); tcg_out_insn(s, 3206, B, offset); } =20 -static inline void tcg_out_goto_long(TCGContext *s, tcg_insn_unit *target) +static void tcg_out_goto_long(TCGContext *s, const tcg_insn_unit *target) { - ptrdiff_t offset =3D target - s->code_ptr; + ptrdiff_t offset =3D tcg_pcrel_diff(s, target) >> 2; if (offset =3D=3D sextract64(offset, 0, 26)) { tcg_out_insn(s, 3206, B, offset); } else { @@ -1329,9 +1334,9 @@ static inline void tcg_out_callr(TCGContext *s, TCGRe= g reg) tcg_out_insn(s, 3207, BLR, reg); } =20 -static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) { - ptrdiff_t offset =3D target - s->code_ptr; + ptrdiff_t offset =3D tcg_pcrel_diff(s, target) >> 2; if (offset =3D=3D sextract64(offset, 0, 26)) { tcg_out_insn(s, 3206, BL, offset); } else { @@ -1393,7 +1398,7 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext= , TCGCond c, TCGArg a, tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); offset =3D tcg_in32(s) >> 5; } else { - offset =3D l->u.value_ptr - s->code_ptr; + offset =3D tcg_pcrel_diff(s, l->u.value_ptr) >> 2; tcg_debug_assert(offset =3D=3D sextract64(offset, 0, 19)); } =20 @@ -1568,7 +1573,7 @@ static void * const qemu_st_helpers[16] =3D { [MO_BEQ] =3D helper_be_stq_mmu, }; =20 -static inline void tcg_out_adr(TCGContext *s, TCGReg rd, void *target) +static inline void tcg_out_adr(TCGContext *s, TCGReg rd, const void *targe= t) { ptrdiff_t offset =3D tcg_pcrel_diff(s, target); tcg_debug_assert(offset =3D=3D sextract64(offset, 0, 21)); @@ -1581,7 +1586,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) MemOp opc =3D get_memop(oi); MemOp size =3D opc & MO_SIZE; =20 - if (!reloc_pc19(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc19(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } =20 @@ -1606,7 +1611,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) MemOp opc =3D get_memop(oi); MemOp size =3D opc & MO_SIZE; =20 - if (!reloc_pc19(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc19(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } =20 @@ -1631,7 +1636,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool i= s_ld, TCGMemOpIdx oi, label->type =3D ext; label->datalo_reg =3D data_reg; label->addrlo_reg =3D addr_reg; - label->raddr =3D raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr; } =20 @@ -1849,7 +1855,7 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg dat= a_reg, TCGReg addr_reg, #endif /* CONFIG_SOFTMMU */ } =20 -static tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *tb_ret_addr; =20 static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg args[TCG_MAX_OP_ARGS], @@ -2894,11 +2900,12 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - tcg_code_gen_epilogue =3D s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_X0, 0); =20 /* TB epilogue */ - tb_ret_addr =3D s->code_ptr; + tb_ret_addr =3D tcg_splitwx_to_rx(s->code_ptr); =20 /* Remove TCG locals stack space. */ tcg_out_insn(s, 3401, ADDI, TCG_TYPE_I64, TCG_REG_SP, TCG_REG_SP, --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607956712; cv=none; d=zohomail.com; s=zohoarc; b=W2yoPlj2wuFd0K6cO34in2z1hjiQqLz+9Gvp0B1fReFyAqYLpqpzBHtn5e2y1cnFM8RyuOrfSQZln13ptmXpHnEqI6MG6UL5Q1K9m0+OTN2UAxqEKIAn/LwlFJlVhraVk/qyUvf8tK8aGBf1G4Nv9Vr0rEb4qs3eK3A0QvrO3nA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607956712; h=Content-Transfer-Encoding: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=GhRqALWf9y48BIzmwb6ec/JDv3hDJBRmMXBLeIk5tow=; b=WKhgE6fvzNZbamBsLZ8jaT4G9SV+nqcd8BHpOpjnoUpmlrLOBrffnqkof58WVRgTNmkDvVOEfTs9IxN03wnoXdkwr+TYkP1RhSOKLsLKreVu51dkuJoH/4qPuzP7QuMmtfiK/gviPDssGmCiwDhX3VWX4L8a26UKHZMmWz1YvZg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160795671204790.48214111054426; Mon, 14 Dec 2020 06:38:32 -0800 (PST) Received: from localhost ([::1]:51752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koof0-0000ds-CC for importer@patchew.org; Mon, 14 Dec 2020 09:17:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSH-00020n-9w for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:02 -0500 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:45607) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSE-0003zo-49 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:01 -0500 Received: by mail-ot1-x341.google.com with SMTP id h18so15762949otq.12 for ; Mon, 14 Dec 2020 06:03:57 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=GhRqALWf9y48BIzmwb6ec/JDv3hDJBRmMXBLeIk5tow=; b=Gh0oVxRD6W5bvguomgwjsjrN3rlaY4gSvqOyMvbVVdG6cptTBYiauKyY8OlPPX6Gm6 gWSQG8rJ+Z1tNqVnJD8U4fO3xbIEkTBjaENpZEc6BQLcN3a/IWuA3ZJIrEFKyfL6AsYs SnHFXOBEvV2xnIW77vw88nLo7pLBagpHH5mreRPnqzJnUs2o9Lw1zWN3KcpOKO0zPP+z L2ue18Gm6uHzjB6lXGxLsnJ/qpkQR/dv0UbNg2hC08XQtf/Sk3yWD2tyjnSKWCqdXc3b JAWHG8/7DWcJpNFifRa8NlZeB8JvLit1cy2BYxp87YF0JqenYYuMBpGl7hyYluPPA2ID ST3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GhRqALWf9y48BIzmwb6ec/JDv3hDJBRmMXBLeIk5tow=; b=aOvXR5acs8SwwnB8MYuOez1zRqvqNomz1Srdzcut6qnjzIgp0i891mvGUpfbmGvA+m kN6hD4t/kfPqZ5l4J+082KYiVi/O6Gu4KV6VaX94jd/6ll6fN77me6o3Kwdv8CHBC8ZE XJ1wFy4k7m3dls3FJuMrj1YMVWUdPLd4vuNXJmFqM5+KOBY9lIiJd0fLXRwP9lkfGKLJ TPuBk20HBEdev8/zojbPi6Szy17795D3n+GffqEed8zb5gdvH8Bq3pN/9OtflTi+yIae 4KHo2HybK+f6MJwOGg3aS9hkegx67JItCOXStZ3vNvyE3Sr4sDGxCSZb+gfLrK/6pjWt UjXg== X-Gm-Message-State: AOAM532ClWQtAYC7CNC4M3h4Grz9i+MdzFQQoXJZC8uZhOyFdHZtmdn6 Vnf78u/gjwY1c5OKOpm7JDnWgLPQLPAje/cB X-Google-Smtp-Source: ABdhPJz+Nnya842Wj+nFl0Yko9e9x0wCAFroEWFy1Wyvtc+JIheZVHiQ6jejz/XICl43uAyGmJ+fUg== X-Received: by 2002:a05:6830:1e7a:: with SMTP id m26mr10522980otr.78.1607954636517; Mon, 14 Dec 2020 06:03:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 24/43] disas: Push const down through host disasassembly Date: Mon, 14 Dec 2020 08:02:55 -0600 Message-Id: <20201214140314.18544-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::341; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x341.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/disas/dis-asm.h | 4 ++-- disas.c | 4 +--- disas/capstone.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h index 2164762b46..d1133a4e04 100644 --- a/include/disas/dis-asm.h +++ b/include/disas/dis-asm.h @@ -358,7 +358,7 @@ typedef struct disassemble_info { (bfd_vma addr, struct disassemble_info * info); =20 /* These are for buffer_read_memory. */ - bfd_byte *buffer; + const bfd_byte *buffer; bfd_vma buffer_vma; int buffer_length; =20 @@ -462,7 +462,7 @@ int print_insn_rx(bfd_vma, disassemble_info *); =20 #ifdef CONFIG_CAPSTONE bool cap_disas_target(disassemble_info *info, uint64_t pc, size_t size); -bool cap_disas_host(disassemble_info *info, void *code, size_t size); +bool cap_disas_host(disassemble_info *info, const void *code, size_t size); bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count); bool cap_disas_plugin(disassemble_info *info, uint64_t pc, size_t size); #else diff --git a/disas.c b/disas.c index de1de7be94..a61f95b580 100644 --- a/disas.c +++ b/disas.c @@ -299,10 +299,8 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_= t size) } =20 /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, const void *ccode, unsigned long size) +void disas(FILE *out, const void *code, unsigned long size) { - /* TODO: Push constness through the disas backends. */ - void *code =3D (void *)ccode; uintptr_t pc; int count; CPUDebug s; diff --git a/disas/capstone.c b/disas/capstone.c index 7462c0e305..20bc8f9669 100644 --- a/disas/capstone.c +++ b/disas/capstone.c @@ -229,7 +229,7 @@ bool cap_disas_target(disassemble_info *info, uint64_t = pc, size_t size) } =20 /* Disassemble SIZE bytes at CODE for the host. */ -bool cap_disas_host(disassemble_info *info, void *code, size_t size) +bool cap_disas_host(disassemble_info *info, const void *code, size_t size) { csh handle; const uint8_t *cbuf; --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607954954; cv=none; d=zohomail.com; s=zohoarc; b=a/EYftWxdT6X28RdH9m8TO2PTcL+Oswg1f8bI1QwXez3sJV/oblHgFdfM6y0ZfAExEFQDKu6pAU9HLkA9gZr6KfhL3oiv06jXG+eQo0XXiL6YCWSFneuV62T6U9+bjl1FwAJvyLRS9NwovsCWpNil/hoWVA/SGA/30/4xn7taSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607954954; h=Content-Transfer-Encoding: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=oktQi4LY/JF34qnZTuyLsQ8kBIo/j/CH/m+PcKBIxn4=; b=fyo+SNM1iy17HkT8VfloKvG/piH2yxyvj3rI7Xe1niXUCdOeOp2cRFSiDxOZe7qhbMe/bCbqXKI33M1kZOcCqVLoR+LV+TUTTwdwMt1mTNPc4r7LQUfI3QhGvXDzzAteb/SAFFJVmn6ePHxdBQYepmQ1GHo23Pgn9+5e6pt86JA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607954954499606.8647551136432; Mon, 14 Dec 2020 06:09:14 -0800 (PST) Received: from localhost ([::1]:54440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooXG-0006x1-TX for importer@patchew.org; Mon, 14 Dec 2020 09:09:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSJ-00021P-1o for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:04 -0500 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:45610) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSF-0003zy-B3 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:02 -0500 Received: by mail-ot1-x344.google.com with SMTP id h18so15763016otq.12 for ; Mon, 14 Dec 2020 06:03:58 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=oktQi4LY/JF34qnZTuyLsQ8kBIo/j/CH/m+PcKBIxn4=; b=dxrkOMX44qCCZXcVcTLwnlHXdWM2LL2FjgYLWWhz+7tSXA7BCZtc7rkm+E+aBSv0Kw SJZ0Yy4XA+68dddn7gfgVynxilQxTw+6/5em/rKnHbCPIegLr6VVdLyJJj+xE4zze43W 6o5+nH8gPQuToXOlAu/vZbfqXOfuELh0hdmeCshJjJyvQ88QoHxA47VWYXsrzxsOtr73 bvs0VHezwmgUixwdHocZ2j2PmV8ax7KaUJI1484lSnB8Ba9VHfrUSYhfAyN3wL+oKH/P Q1EdnusmEzBX8fs6Z0FtDeajCsZqVl9QxrHbrKwuMkw6u/GNCKvX9nM9Ryu8bS4pPdFQ m9QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oktQi4LY/JF34qnZTuyLsQ8kBIo/j/CH/m+PcKBIxn4=; b=Niyu0nBpf4LZaN6ek23vRO8SscB1m3VsL2FrzZkyt+S4j2VaLVm1xaxGEgw7+yb6zl WOkkZh/o1+oil7gvSu1/JPaZ6IxcjaFqZTd9RJdD+vo7KQ2LUnWse0pI45zqZ+LIO2Bp grcDtE7cOnD7bPC3TiCHyhb/dRpxsHqpEiUQc/mJ1j5dd2WAZSqw59Do48qxdAnOta8i TUGg1fuqneAtEele21cNF/n49FGsFQpyqFOmx2wixNOWzdkTd1vT/RDxMc8qwr4O2zJv rLxBQDC9mwgGaRAZNNmRSiZsR3dcpqbsCgIfLrLid6uOHdEc7eFmpVC6rHBGJgn+wvnZ zwYw== X-Gm-Message-State: AOAM531G8+pxTcdAPbZvfDgtioNIRpinC8STaSpU5NAoGOETX91CxwYN tfE/2IC5Y+U8FdROjeRbgr1NJLP6L6v5PB7x X-Google-Smtp-Source: ABdhPJyy5bFKoi+4u5sAbYhzjRU1blmQBlwKu3jSG2d7MRS9buDfId86MtOzLvlnGn5PXR5nr9NEzw== X-Received: by 2002:a9d:7b53:: with SMTP id f19mr19945110oto.93.1607954637892; Mon, 14 Dec 2020 06:03:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 25/43] tcg/tci: Push const down through bytecode reading Date: Mon, 14 Dec 2020 08:02:56 -0600 Message-Id: <20201214140314.18544-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::344; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x344.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- tcg/tci.c | 60 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/tcg/tci.c b/tcg/tci.c index 262a2b39ce..388c1dbee8 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -163,34 +163,34 @@ static uint64_t tci_uint64(uint32_t high, uint32_t lo= w) #endif =20 /* Read constant (native size) from bytecode. */ -static tcg_target_ulong tci_read_i(uint8_t **tb_ptr) +static tcg_target_ulong tci_read_i(const uint8_t **tb_ptr) { - tcg_target_ulong value =3D *(tcg_target_ulong *)(*tb_ptr); + tcg_target_ulong value =3D *(const tcg_target_ulong *)(*tb_ptr); *tb_ptr +=3D sizeof(value); return value; } =20 /* Read unsigned constant (32 bit) from bytecode. */ -static uint32_t tci_read_i32(uint8_t **tb_ptr) +static uint32_t tci_read_i32(const uint8_t **tb_ptr) { - uint32_t value =3D *(uint32_t *)(*tb_ptr); + uint32_t value =3D *(const uint32_t *)(*tb_ptr); *tb_ptr +=3D sizeof(value); return value; } =20 /* Read signed constant (32 bit) from bytecode. */ -static int32_t tci_read_s32(uint8_t **tb_ptr) +static int32_t tci_read_s32(const uint8_t **tb_ptr) { - int32_t value =3D *(int32_t *)(*tb_ptr); + int32_t value =3D *(const int32_t *)(*tb_ptr); *tb_ptr +=3D sizeof(value); return value; } =20 #if TCG_TARGET_REG_BITS =3D=3D 64 /* Read constant (64 bit) from bytecode. */ -static uint64_t tci_read_i64(uint8_t **tb_ptr) +static uint64_t tci_read_i64(const uint8_t **tb_ptr) { - uint64_t value =3D *(uint64_t *)(*tb_ptr); + uint64_t value =3D *(const uint64_t *)(*tb_ptr); *tb_ptr +=3D sizeof(value); return value; } @@ -198,7 +198,7 @@ static uint64_t tci_read_i64(uint8_t **tb_ptr) =20 /* Read indexed register (native size) from bytecode. */ static tcg_target_ulong -tci_read_r(const tcg_target_ulong *regs, uint8_t **tb_ptr) +tci_read_r(const tcg_target_ulong *regs, const uint8_t **tb_ptr) { tcg_target_ulong value =3D tci_read_reg(regs, **tb_ptr); *tb_ptr +=3D 1; @@ -206,7 +206,7 @@ tci_read_r(const tcg_target_ulong *regs, uint8_t **tb_p= tr) } =20 /* Read indexed register (8 bit) from bytecode. */ -static uint8_t tci_read_r8(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint8_t tci_read_r8(const tcg_target_ulong *regs, const uint8_t **t= b_ptr) { uint8_t value =3D tci_read_reg8(regs, **tb_ptr); *tb_ptr +=3D 1; @@ -215,7 +215,7 @@ static uint8_t tci_read_r8(const tcg_target_ulong *regs= , uint8_t **tb_ptr) =20 #if TCG_TARGET_HAS_ext8s_i32 || TCG_TARGET_HAS_ext8s_i64 /* Read indexed register (8 bit signed) from bytecode. */ -static int8_t tci_read_r8s(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static int8_t tci_read_r8s(const tcg_target_ulong *regs, const uint8_t **t= b_ptr) { int8_t value =3D tci_read_reg8s(regs, **tb_ptr); *tb_ptr +=3D 1; @@ -224,7 +224,8 @@ static int8_t tci_read_r8s(const tcg_target_ulong *regs= , uint8_t **tb_ptr) #endif =20 /* Read indexed register (16 bit) from bytecode. */ -static uint16_t tci_read_r16(const tcg_target_ulong *regs, uint8_t **tb_pt= r) +static uint16_t tci_read_r16(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint16_t value =3D tci_read_reg16(regs, **tb_ptr); *tb_ptr +=3D 1; @@ -233,7 +234,8 @@ static uint16_t tci_read_r16(const tcg_target_ulong *re= gs, uint8_t **tb_ptr) =20 #if TCG_TARGET_HAS_ext16s_i32 || TCG_TARGET_HAS_ext16s_i64 /* Read indexed register (16 bit signed) from bytecode. */ -static int16_t tci_read_r16s(const tcg_target_ulong *regs, uint8_t **tb_pt= r) +static int16_t tci_read_r16s(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { int16_t value =3D tci_read_reg16s(regs, **tb_ptr); *tb_ptr +=3D 1; @@ -242,7 +244,8 @@ static int16_t tci_read_r16s(const tcg_target_ulong *re= gs, uint8_t **tb_ptr) #endif =20 /* Read indexed register (32 bit) from bytecode. */ -static uint32_t tci_read_r32(const tcg_target_ulong *regs, uint8_t **tb_pt= r) +static uint32_t tci_read_r32(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint32_t value =3D tci_read_reg32(regs, **tb_ptr); *tb_ptr +=3D 1; @@ -251,14 +254,16 @@ static uint32_t tci_read_r32(const tcg_target_ulong *= regs, uint8_t **tb_ptr) =20 #if TCG_TARGET_REG_BITS =3D=3D 32 /* Read two indexed registers (2 * 32 bit) from bytecode. */ -static uint64_t tci_read_r64(const tcg_target_ulong *regs, uint8_t **tb_pt= r) +static uint64_t tci_read_r64(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint32_t low =3D tci_read_r32(regs, tb_ptr); return tci_uint64(tci_read_r32(regs, tb_ptr), low); } #elif TCG_TARGET_REG_BITS =3D=3D 64 /* Read indexed register (32 bit signed) from bytecode. */ -static int32_t tci_read_r32s(const tcg_target_ulong *regs, uint8_t **tb_pt= r) +static int32_t tci_read_r32s(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { int32_t value =3D tci_read_reg32s(regs, **tb_ptr); *tb_ptr +=3D 1; @@ -266,7 +271,8 @@ static int32_t tci_read_r32s(const tcg_target_ulong *re= gs, uint8_t **tb_ptr) } =20 /* Read indexed register (64 bit) from bytecode. */ -static uint64_t tci_read_r64(const tcg_target_ulong *regs, uint8_t **tb_pt= r) +static uint64_t tci_read_r64(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint64_t value =3D tci_read_reg64(regs, **tb_ptr); *tb_ptr +=3D 1; @@ -276,7 +282,7 @@ static uint64_t tci_read_r64(const tcg_target_ulong *re= gs, uint8_t **tb_ptr) =20 /* Read indexed register(s) with target address from bytecode. */ static target_ulong -tci_read_ulong(const tcg_target_ulong *regs, uint8_t **tb_ptr) +tci_read_ulong(const tcg_target_ulong *regs, const uint8_t **tb_ptr) { target_ulong taddr =3D tci_read_r(regs, tb_ptr); #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS @@ -287,7 +293,7 @@ tci_read_ulong(const tcg_target_ulong *regs, uint8_t **= tb_ptr) =20 /* Read indexed register or constant (native size) from bytecode. */ static tcg_target_ulong -tci_read_ri(const tcg_target_ulong *regs, uint8_t **tb_ptr) +tci_read_ri(const tcg_target_ulong *regs, const uint8_t **tb_ptr) { tcg_target_ulong value; TCGReg r =3D **tb_ptr; @@ -301,7 +307,8 @@ tci_read_ri(const tcg_target_ulong *regs, uint8_t **tb_= ptr) } =20 /* Read indexed register or constant (32 bit) from bytecode. */ -static uint32_t tci_read_ri32(const tcg_target_ulong *regs, uint8_t **tb_p= tr) +static uint32_t tci_read_ri32(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint32_t value; TCGReg r =3D **tb_ptr; @@ -316,14 +323,16 @@ static uint32_t tci_read_ri32(const tcg_target_ulong = *regs, uint8_t **tb_ptr) =20 #if TCG_TARGET_REG_BITS =3D=3D 32 /* Read two indexed registers or constants (2 * 32 bit) from bytecode. */ -static uint64_t tci_read_ri64(const tcg_target_ulong *regs, uint8_t **tb_p= tr) +static uint64_t tci_read_ri64(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint32_t low =3D tci_read_ri32(regs, tb_ptr); return tci_uint64(tci_read_ri32(regs, tb_ptr), low); } #elif TCG_TARGET_REG_BITS =3D=3D 64 /* Read indexed register or constant (64 bit) from bytecode. */ -static uint64_t tci_read_ri64(const tcg_target_ulong *regs, uint8_t **tb_p= tr) +static uint64_t tci_read_ri64(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint64_t value; TCGReg r =3D **tb_ptr; @@ -337,7 +346,7 @@ static uint64_t tci_read_ri64(const tcg_target_ulong *r= egs, uint8_t **tb_ptr) } #endif =20 -static tcg_target_ulong tci_read_label(uint8_t **tb_ptr) +static tcg_target_ulong tci_read_label(const uint8_t **tb_ptr) { tcg_target_ulong label =3D tci_read_i(tb_ptr); tci_assert(label !=3D 0); @@ -477,8 +486,7 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCG= Cond condition) /* Interpret pseudo code in tb. */ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const void *v_tb_ptr) { - /* TODO: Propagate const through this file. */ - uint8_t *tb_ptr =3D (uint8_t *)v_tb_ptr; + const uint8_t *tb_ptr =3D v_tb_ptr; tcg_target_ulong regs[TCG_TARGET_NB_REGS]; long tcg_temps[CPU_TEMP_BUF_NLONGS]; uintptr_t sp_value =3D (uintptr_t)(tcg_temps + CPU_TEMP_BUF_NLONGS); @@ -492,7 +500,7 @@ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const voi= d *v_tb_ptr) TCGOpcode opc =3D tb_ptr[0]; #if defined(CONFIG_DEBUG_TCG) && !defined(NDEBUG) uint8_t op_size =3D tb_ptr[1]; - uint8_t *old_code_ptr =3D tb_ptr; + const uint8_t *old_code_ptr =3D tb_ptr; #endif tcg_target_ulong t0; tcg_target_ulong t1; --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607967994; cv=none; d=zohomail.com; s=zohoarc; b=b11u/w7D81moFqz3GIG1AG+ogHWS0zfdIvYNgz352/mRUJSX6rFXSwq3pa5vnjK0M/ygBkQqssOPX1bi+rOIJltT29xa3V7X0vkpGtfmCesLAEneXyn2UYMP6d88ygMzBlMcsbZWWl4pQ/pE0xiTX58UFrb5QWjlH41dCyXEqCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607967994; h=Content-Transfer-Encoding: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=UM21CD1mNWN7mJCqUB/udHXRZq9uSUYW+rGuZNQcpWU=; b=XigeNhRmwnGSCYBZhb5xWMxcBlzNkAOLiUvYm+jc4vEbwyXr3h9galqtjmX00EJ4Zwt8wgmU88SjnFYNNmUxOR+OBBHbwJXhAWJIs7tVdcTQBCP9F8Pz5vG+lVi3GvikKcb4wjhD5rziakyvuVxELtVx8oDjmrv7sunGfd6KrYg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16079679942754.900806338293478; Mon, 14 Dec 2020 09:46:34 -0800 (PST) Received: from localhost ([::1]:52752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koonu-00045S-0Y for importer@patchew.org; Mon, 14 Dec 2020 09:26:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSO-000242-4q for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:08 -0500 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:40048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSG-000406-Vz for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:07 -0500 Received: by mail-ot1-x342.google.com with SMTP id j12so15758533ota.7 for ; Mon, 14 Dec 2020 06:04:00 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UM21CD1mNWN7mJCqUB/udHXRZq9uSUYW+rGuZNQcpWU=; b=mmYnb0iurTs3YTRolqgx0ntpwaogURR1wm85OK6tz3yxSeYjRy3WeK+sOWvQbCCRke CZ+dIANJHXj2NDAvLNYLaPMWR9bO58cujfI6i6DmAk2lfrhkVuvw1o+w0JoNBYK6TpPW JmWqo33aM4ioC9y9Fsl3+mPHm2UjFFFGSQxPL2kZJd3yFEclGNM4RGlqzMcEPDlx7pMD 0owaT0Oe+nfZWFYjBJql3Ii4q1pa0oS/eRpimU/M17v+Zjcx0A70GaXx/dFnXEHU9xUp Km8PBHLQVn05oPSWxHEyGPgKf8SOA3lMI9nPwowglZZS3dkG2BH/cllaCbSxCl79wEfW md+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UM21CD1mNWN7mJCqUB/udHXRZq9uSUYW+rGuZNQcpWU=; b=XJRv9vnCozvO3v/kT3BLH93VQ4cQeeIqsosabL4iNvl+V4SJOBY5JrZNTcFWjk1XKF 3sje16Rw/QmRjzkpK90eWFjVkYUNUqqOewyg6O0PHchzmHUJ9QuRCYKgHoKm4p7rf9vj C6xUJzH9l2Mu/Lemh/7DGhhL61YiEP81ooWTwJqnoyn4J7Bj3x1bU72RRBYw8MQz3rPj GYNW5FrutVm3z1x2BZ+tRjOnp6VTp5htMsBNb6EjhWAlJLVHS2rmtgX0tMxe/7GDDl/X HcRMChzNHPQsH+tqgQTM+yTg8kPspZQPeMUlU716P0dvN3F5urKxhmjklOjUKO5/5qVT EVhQ== X-Gm-Message-State: AOAM530CFk8A9e3Wc8OfwMH0rVd9lunmyqsho2aijH0QEXNhA1XdEa64 vZhdo92EyBiQFb0GqLwoCjl/40I23+MAGDew X-Google-Smtp-Source: ABdhPJwAgWPT3ctTc6HKMYguxAxRogT/zguOKavelLPMMXuXOcpQcVDhUFgXlVE2p1xA1Q7RULSDtw== X-Received: by 2002:a9d:650a:: with SMTP id i10mr8081997otl.341.1607954639138; Mon, 14 Dec 2020 06:03:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 26/43] tcg: Introduce tcg_tbrel_diff Date: Mon, 14 Dec 2020 08:02:57 -0600 Message-Id: <20201214140314.18544-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::342; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x342.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- include/tcg/tcg.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 67d57695c2..90ec7c1445 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -1141,6 +1141,19 @@ static inline ptrdiff_t tcg_pcrel_diff(TCGContext *s= , const void *target) return tcg_ptr_byte_diff(target, tcg_splitwx_to_rx(s->code_ptr)); } =20 +/** + * tcg_tbrel_diff + * @s: the tcg context + * @target: address of the target + * + * Produce a difference, from the beginning of the current TB code + * to the destination address. + */ +static inline ptrdiff_t tcg_tbrel_diff(TCGContext *s, const void *target) +{ + return tcg_ptr_byte_diff(target, tcg_splitwx_to_rx(s->code_buf)); +} + /** * tcg_current_code_size * @s: the tcg context --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607977376; cv=none; d=zohomail.com; s=zohoarc; b=Af2SaWYX+mmVea6x/op5PUgUHvp90xv/4VzYwLLnYr5IEmgMnUSCTtxyKyji316efIZsWyk1n3jI3cPOlfsmfEB5tXgZiKUM5sfmK8f6Vi3xNPBsMW4/CjLTLhKRyX/29FaJhV5sUnjqlF4cZni6e2oUbTDk8K4+wo3BQ9cvUvA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607977376; h=Content-Transfer-Encoding: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=qay0jNTmpyZq4ULzg3vkr0em7pJVaOqPAuzaBx5paoU=; b=E0UjnlUSfvTxntvNEUizkqGpQXvJQUeMsWAddtuwR8x2pn84+fuveh4yok0U8VkLRMEdEZ1Fz4VNxYWXI03JucgmO+eHxc6DITbyv215i0bRkoiLevd1lluJmpSF1NTXl4Tbxu0qC4S3y+BhQCcmNiVUXw65j93u9DlQ6oQG1G4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607977376204505.5717816933153; Mon, 14 Dec 2020 12:22:56 -0800 (PST) Received: from localhost ([::1]:37398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koos2-0000w4-UI for importer@patchew.org; Mon, 14 Dec 2020 09:30:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSQ-00025A-Fc for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:10 -0500 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:36396) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSJ-00040O-JX for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:10 -0500 Received: by mail-ot1-x341.google.com with SMTP id y24so15769075otk.3 for ; Mon, 14 Dec 2020 06:04:03 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.03.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:03:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=qay0jNTmpyZq4ULzg3vkr0em7pJVaOqPAuzaBx5paoU=; b=WMMeYOtDU8uzl4qt7ittcULDkhk+Y1yLVe88v/iPk2PRM/V93OZqFdkmJp/UfQ0Ew4 SIAOal4s4KViJQJSdQapwPTppkKQ7cBvw7busMhGqSjLmojDCPP885L+YIh+WOpj2gfN tPdPHHEZ09Rn88KSzcaVwgFmvDGO4+MaoASGoawjQIh4o4iV0suQeeYEQnwK/QZ8C2/w CcrAhPQ5SMyeltzVRscr7Nz/2VyvxYlNt1ZbQiOp5AgfDyIftsvYHvcUJYsq5p7m7Cva 7GncAj4C5W3GZvAHX1C+3J7MGkSno1vi7eMulxMIjK1Gt+NZCEjT2v1VG7qJX5Qkn4OQ 1h5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qay0jNTmpyZq4ULzg3vkr0em7pJVaOqPAuzaBx5paoU=; b=T4uXUy0QCyhESv7MWDd0gjcQ6JHNYNYqm0SMglv+zP+3AO/avKADSqTt5V2/o+jsgS QEKmKYes0nJkTZI2s793xzlLR2TKLoT+ge3YouDjlJaNyycJvVbBAnq1vE3UlDzJ78uP qkhEs5Nlm/JRCa80Xxj3DvbmhF303ylSuQa510PHf2Gx5F4sWalfxwIAAQGyalEz5g76 5FywXFNeAqRaMtl9os66KnDDPNk4dEsBCNoE0U0vTAGKez6z8ASqgPYpPSIV6jsHXSAG HJGXv1O7SyHe7i+isFMtpzgyu4po4Snih560+M/Ep2TtX8q98SvtVXC1tmdSG4TWTAIH oufw== X-Gm-Message-State: AOAM530tHQlleAgQX40TizqnssEZVr4EHvTWxz6FIPIgk8APhO6HxFBb 3Qjk3uBItXGPN2iLmOIZ7Yc+dge+SecDQqBX X-Google-Smtp-Source: ABdhPJwHSECkDAS2CfLByriAu1E4R3J2PGF+Z1r06WZaIZnyMEzED5OgAo6YCmKyR65KaCaV3IpaRA== X-Received: by 2002:a05:6830:107:: with SMTP id i7mr19290608otp.247.1607954641060; Mon, 14 Dec 2020 06:04:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 27/43] tcg/ppc: Use tcg_tbrel_diff Date: Mon, 14 Dec 2020 08:02:58 -0600 Message-Id: <20201214140314.18544-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::341; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x341.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Use tcg_tbrel_diff when we need a displacement to a label, and with a NULL argument when we need the normalizing addend. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 0eb9c4ebe2..ed7a201578 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -837,7 +837,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType typ= e, TCGReg ret, } =20 /* Load addresses within the TB with one insn. */ - tb_diff =3D arg - (intptr_t)s->code_gen_ptr; + tb_diff =3D tcg_tbrel_diff(s, (void *)arg); if (!in_prologue && USE_REG_TB && tb_diff =3D=3D (int16_t)tb_diff) { tcg_out32(s, ADDI | TAI(ret, TCG_REG_TB, tb_diff)); return; @@ -890,7 +890,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType typ= e, TCGReg ret, /* Use the constant pool, if possible. */ if (!in_prologue && USE_REG_TB) { new_pool_label(s, arg, R_PPC_ADDR16, s->code_ptr, - -(intptr_t)s->code_gen_ptr); + tcg_tbrel_diff(s, NULL)); tcg_out32(s, LD | TAI(ret, TCG_REG_TB, 0)); return; } @@ -940,7 +940,7 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType typ= e, TCGReg ret, */ if (USE_REG_TB) { rel =3D R_PPC_ADDR16; - add =3D -(intptr_t)s->code_gen_ptr; + add =3D tcg_tbrel_diff(s, NULL); } else { rel =3D R_PPC_ADDR32; add =3D 0; --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607956480; cv=none; d=zohomail.com; s=zohoarc; b=EQXVmc8aFsrpH7CrW4igt9hGrtshPkFwuCTL81mdNMyx5uxZYFks9yRP8OOv6UL536vE2hxEX97PggDmVP2Q4WyShmTInu1DdOdAyi+idtuCbIkbPQn6GNaHwMSC51xpUXrgf6fARyKoygAIB+vcY7DYYTMrkVRPcSrN2Zpir0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607956480; h=Content-Transfer-Encoding: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=ASquR/6BxZoSVQzDtOnOXOHE8jLTrkcyVCDT0iJkP14=; b=It8lYd4GRIVyJRBWp6bFYisXfsTyqhexKxgRSPpzzkdUuQGO/aLxw1U1o0dKP1teSCG86QCqyPDWDe19ghvJdpTQmyhAl47dZnfJvO97SlQxtCO4zr6idru776theQx8YI3cAkPJ1ahV4cPbaTFOMDImOz3RxvHUm42bMZnwhzo= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607956480575663.3504653839592; Mon, 14 Dec 2020 06:34:40 -0800 (PST) Received: from localhost ([::1]:46464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koovt-0004kB-Ut for importer@patchew.org; Mon, 14 Dec 2020 09:34:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSM-00023I-T9 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:07 -0500 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]:38644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSJ-00040Q-NR for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:06 -0500 Received: by mail-oi1-x241.google.com with SMTP id x13so10201779oic.5 for ; Mon, 14 Dec 2020 06:04:03 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ASquR/6BxZoSVQzDtOnOXOHE8jLTrkcyVCDT0iJkP14=; b=z705s80xqeVHMS/roiSeYfSVBMXOb5PsaWRKja4n3jV+4KdUCzM1N9QYfp9RoNliAM Eqrp+iXQcpHaUAeVAeN4DmWlp6IBdbLPiUy2tVe/25XOdstrCMbhTVu6IcHrpKXakSc+ Wq3YbNtNVNF3+ejrfb76ivL7wn93zVAr8gVRj2jAtKFRiJScKEt0PEtx0g5MyHtpnITY 3LmpkeUzc6j6IE5Y1J+w0nNnOS5rmzHvOxzdIWtqSBJa8T6HPGQo40dhw6djJRGhd9Kg EjuMNXpVfGwwwx2tSriQ1Kq1EWvQ8CSHOpEUYZJGsii5wJ0QZZrUAgzoBO31wlhsBNIe cEsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ASquR/6BxZoSVQzDtOnOXOHE8jLTrkcyVCDT0iJkP14=; b=IyWAXAmNQq5co6EhTFuNYyPuLO2k8IYNYkSv4/yjko0sxfipdfXzETwPr6pWw1nPdM F8XnRNRkPskMattlo60P3FJQmD8GX26SGwKhTrBr3pBTP2nqTxiCdwbVDocNcaiHbwV8 kinfcOQo0OJITyC6JLxgB4AOp9HbZG7b6vxtf9b4vghSfja1LUpDHiRg5tN5X1rqxJ5r AWgleLxVuboD2T3OzUmZ+iunK6HFL2tPSzXjmdN4lQaWdwjzO5jmRLO6BS5VwnEeczO9 T8ydYhg10z0e44M3FZ6OplPaWMLJ7gjh5CmN5y/AhCVn5UnfguLB9aRvO1bkqDMskug6 A//g== X-Gm-Message-State: AOAM532CXMRtwhkfhjMY/SlqyFmhcxf6GfIHjv8KMCawJ/vvsLMtCVlr KtG7YWY0swz++CmDYWdeCPnYIMLkfFUgaxtQ X-Google-Smtp-Source: ABdhPJz1Q2EvrbhtXWrTYAc2IOH+t9aqRflMEVvDlqpus66kTPsVO94ZP1QXLQrOeyD7e3fJwsxSUg== X-Received: by 2002:aca:504e:: with SMTP id e75mr18777947oib.170.1607954642255; Mon, 14 Dec 2020 06:04:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 28/43] tcg/ppc: Use tcg_out_mem_long to reset TCG_REG_TB Date: Mon, 14 Dec 2020 08:02:59 -0600 Message-Id: <20201214140314.18544-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::241; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x241.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" The maximum TB code gen size is UINT16_MAX, which the current code does not support. Use our utility function to optimally add an arbitrary constant. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index ed7a201578..1f8a446b90 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2392,9 +2392,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, = const TCGArg *args, set_jmp_reset_offset(s, args[0]); if (USE_REG_TB) { /* For the unlinked case, need to reset TCG_REG_TB. */ - c =3D -tcg_current_code_size(s); - assert(c =3D=3D (int16_t)c); - tcg_out32(s, ADDI | TAI(TCG_REG_TB, TCG_REG_TB, c)); + tcg_out_mem_long(s, ADDI, ADD, TCG_REG_TB, TCG_REG_TB, + -tcg_current_code_size(s)); } break; case INDEX_op_goto_ptr: --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607977452; cv=none; d=zohomail.com; s=zohoarc; b=S0ra1q6W6u4T195yszYTsqxWHoBclLIkjaCRjiiolzfaEsJC9sY1SdDDZEHa6kjGRICh455mcyX21jHOYjRaiV+W3aTYsyx5HhcxkBZGEo69YkUYWlAQzaW/nVBNf5jz6N3MmyZvq3V6sLSyfoqe/NOO9+jGqZOiEcmwxjeuJiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607977452; h=Content-Transfer-Encoding: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=etR78lk9NSenLd9LAIcHz8gvX9UzEYAUELnLLKVO9+E=; b=RYtu9nwt+kuV3oPDHpQrVgEVZ2H1jVUjSo4tSgii+juGshwFP4yFZaCN3ml4gnIW0E0eonRoHyN112qv8Qfc22uivAl3K3Voas+aax1oOkBi2UvY/0coURmLX63N721tb9vsDYeL9P2cHeVJJPBYtevI0QpF46opn9dHWGiGZ4Q= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607977452197220.6185869692399; Mon, 14 Dec 2020 12:24:12 -0800 (PST) Received: from localhost ([::1]:59152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooqC-0006kQ-KT for importer@patchew.org; Mon, 14 Dec 2020 09:28:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSO-00024g-Mj for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:10 -0500 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:42597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSM-00040Y-Ga for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:08 -0500 Received: by mail-oi1-x242.google.com with SMTP id l200so19211265oig.9 for ; Mon, 14 Dec 2020 06:04:04 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=etR78lk9NSenLd9LAIcHz8gvX9UzEYAUELnLLKVO9+E=; b=hi8HltkAdRDsqlVzkN6O4522QDVqOJqdg1wJpy2WIF2ioy3bFl7id4JCmHDan2Bbvq JDFzk0dPjF6Xy9tLqnBY9PQVag1RI/xI7yOiwgrSDD+WnNxpLc59mZ+7vpaF6JYvcE6H wQsBNdk8mvTXWfV0EKsk6oVbYAMiSxq/9Q0DYD/87th7y+rhmeXNFM/my6Zmiv0HwrhD rD8SG2OkY28LUVfUdvc1wyd8VmS4ZjY47ATwz2o0FdDLWWCmX4JUuRevDyGCH6WXz+2Z 2eAYbJNRn3GIVqiRboyXoFUA3Dl3SLnvDH8Aar+YuLS3ype46AiYozJDBCDNf04+OBNi JYEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=etR78lk9NSenLd9LAIcHz8gvX9UzEYAUELnLLKVO9+E=; b=L0jJqCYb6nNw+HwaXXzvNX4GEmsLvkfPhwWIScKfy2x5+uiBTKRYw1QKmP3+Vg/ZgM PZLqYF0e+urigJmEy4t5/AtNCq9iORKkpUpmEjZNYB7VrrCOKsi5urEchkVS7I5Jncc2 MsmvxKrCdOPwsQCfN9M7Y9ZZVFH94hrprN/Yx8uChuNlkymxcqf3tUlBgK6awupZvhuA 4fSTJZkZZiz8GAlmt6jGJM4HeXsB/Z8wn+Z0/R12/Qr7tFDehXwyfDagwSoGD+bqQnpL rbyFXI+AtOTsIcpzfGW8MAs3lp0RfKO/lJfWnJ62EURMj2kAuXw9SmhIXS4FaWzpgA2W v91A== X-Gm-Message-State: AOAM530cTaEtGtBfmlx/RZXqb2N8tY/f7BoamtpTnT6TgAsfJ1k46Z53 9IGakhZekrtnvkO5wpUXYtFcQEKtTwtO5QaF X-Google-Smtp-Source: ABdhPJxeFSvYtFytobEkrZJnbs3rQjwYRsMDx6mVlYFQAEuiB78BFJYQimyx9PecUB4c8wEnaNYYqg== X-Received: by 2002:aca:410:: with SMTP id 16mr18326899oie.97.1607954643859; Mon, 14 Dec 2020 06:04:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 29/43] tcg/ppc: Support split-wx code generation Date: Mon, 14 Dec 2020 08:03:00 -0600 Message-Id: <20201214140314.18544-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::242; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x242.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.h | 2 +- tcg/ppc/tcg-target.c.inc | 53 +++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 8fc2672bf0..b3361b8abc 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -184,6 +184,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 1f8a446b90..33b5915005 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -62,8 +62,6 @@ #define TCG_CT_CONST_MONE 0x2000 #define TCG_CT_CONST_WSZ 0x4000 =20 -static tcg_insn_unit *tb_ret_addr; - TCGPowerISA have_isa; static bool have_isel; bool have_altivec; @@ -184,35 +182,41 @@ static inline bool in_range_b(tcg_target_long target) return target =3D=3D sextract64(target, 0, 26); } =20 -static uint32_t reloc_pc24_val(tcg_insn_unit *pc, const tcg_insn_unit *tar= get) +static uint32_t reloc_pc24_val(const tcg_insn_unit *pc, + const tcg_insn_unit *target) { ptrdiff_t disp =3D tcg_ptr_byte_diff(target, pc); tcg_debug_assert(in_range_b(disp)); return disp & 0x3fffffc; } =20 -static bool reloc_pc24(tcg_insn_unit *pc, tcg_insn_unit *target) +static bool reloc_pc24(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t disp =3D tcg_ptr_byte_diff(target, pc); + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t disp =3D tcg_ptr_byte_diff(target, src_rx); + if (in_range_b(disp)) { - *pc =3D (*pc & ~0x3fffffc) | (disp & 0x3fffffc); + *src_rw =3D (*src_rw & ~0x3fffffc) | (disp & 0x3fffffc); return true; } return false; } =20 -static uint16_t reloc_pc14_val(tcg_insn_unit *pc, const tcg_insn_unit *tar= get) +static uint16_t reloc_pc14_val(const tcg_insn_unit *pc, + const tcg_insn_unit *target) { ptrdiff_t disp =3D tcg_ptr_byte_diff(target, pc); tcg_debug_assert(disp =3D=3D (int16_t) disp); return disp & 0xfffc; } =20 -static bool reloc_pc14(tcg_insn_unit *pc, tcg_insn_unit *target) +static bool reloc_pc14(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t disp =3D tcg_ptr_byte_diff(target, pc); + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t disp =3D tcg_ptr_byte_diff(target, src_rx); + if (disp =3D=3D (int16_t) disp) { - *pc =3D (*pc & ~0xfffc) | (disp & 0xfffc); + *src_rw =3D (*src_rw & ~0xfffc) | (disp & 0xfffc); return true; } return false; @@ -673,12 +677,12 @@ static const uint32_t tcg_to_isel[] =3D { static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { - tcg_insn_unit *target; + const tcg_insn_unit *target; int16_t lo; int32_t hi; =20 value +=3D addend; - target =3D (tcg_insn_unit *)value; + target =3D (const tcg_insn_unit *)value; =20 switch (type) { case R_PPC_REL14: @@ -1544,7 +1548,7 @@ static void tcg_out_setcond(TCGContext *s, TCGType ty= pe, TCGCond cond, static void tcg_out_bc(TCGContext *s, int bc, TCGLabel *l) { if (l->has_value) { - bc |=3D reloc_pc14_val(s->code_ptr, l->u.value_ptr); + bc |=3D reloc_pc14_val(tcg_splitwx_to_rx(s->code_ptr), l->u.value_= ptr); } else { tcg_out_reloc(s, s->code_ptr, R_PPC_REL14, l, 0); } @@ -1997,7 +2001,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool i= s_ld, TCGMemOpIdx oi, label->datahi_reg =3D datahi_reg; label->addrlo_reg =3D addrlo_reg; label->addrhi_reg =3D addrhi_reg; - label->raddr =3D raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D lptr; } =20 @@ -2007,7 +2012,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) MemOp opc =3D get_memop(oi); TCGReg hi, lo, arg =3D TCG_REG_R3; =20 - if (!reloc_pc14(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc14(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } =20 @@ -2055,7 +2060,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) MemOp s_bits =3D opc & MO_SIZE; TCGReg hi, lo, arg =3D TCG_REG_R3; =20 - if (!reloc_pc14(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc14(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } =20 @@ -2306,10 +2311,10 @@ static void tcg_target_qemu_prologue(TCGContext *s) int i; =20 #ifdef _CALL_AIX - void **desc =3D (void **)s->code_ptr; - desc[0] =3D desc + 2; /* entry point */ - desc[1] =3D 0; /* environment pointer */ - s->code_ptr =3D (void *)(desc + 2); /* skip over descriptor */ + const void **desc =3D (const void **)s->code_ptr; + desc[0] =3D tcg_splitwx_to_rx(desc + 2); /* entry point */ + desc[1] =3D 0; /* environment pointer */ + s->code_ptr =3D (void *)(desc + 2); /* skip over descriptor */ #endif =20 tcg_set_frame(s, TCG_REG_CALL_STACK, REG_SAVE_BOT - CPU_TEMP_BUF_SIZE, @@ -2341,7 +2346,8 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out32(s, BCCTR | BO_ALWAYS); =20 /* Epilogue */ - tcg_code_gen_epilogue =3D tb_ret_addr =3D s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); =20 tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_REG_R1, FRAME_SIZE+LR_OFFS= ET); for (i =3D 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); ++i) { @@ -2362,7 +2368,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, = const TCGArg *args, switch (opc) { case INDEX_op_exit_tb: tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R3, args[0]); - tcg_out_b(s, 0, tb_ret_addr); + tcg_out_b(s, 0, tcg_code_gen_epilogue); break; case INDEX_op_goto_tb: if (s->tb_jmp_insn_offset) { @@ -2410,7 +2416,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, = const TCGArg *args, uint32_t insn =3D B; =20 if (l->has_value) { - insn |=3D reloc_pc24_val(s->code_ptr, l->u.value_ptr); + insn |=3D reloc_pc24_val(tcg_splitwx_to_rx(s->code_ptr), + l->u.value_ptr); } else { tcg_out_reloc(s, s->code_ptr, R_PPC_REL24, l, 0); } --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607967856; cv=none; d=zohomail.com; s=zohoarc; b=LOAN7xDXBG5rMgQ/Em10e/QiVHYY2dTtl1CeazfsiTwQLEZbhen9qQnY/hIKyBUTtOSQKpGu0xzircOJM0/IqN6SnyJ6VQR2VI+E/HcmdoEXcccWO5rud+3jJmyHf4eNMEIzXRoHVJeOioScbyXehTwLKyJhWAFG8UIWyCTG0gA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607967856; h=Content-Transfer-Encoding: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=mZ7Cv5t9pDHcLwkTAHUkGoZLzbW+EIVJw5j5xRLRZ3w=; b=QQbz6FZugaT4aqR+pcHfrFqxwsuqVDYc0Wut1o8qJWOX1nQ0W43hibWdhC7jrRrbfmOOQfuwlsyaZZU5KENIcxXs3+iJccv+5h3dgzmicroVelsQ0vQXWk0wSU9Y8bXO7EAxcO6AEfjqs+xnxtsW1saDWi+WutW4UmfcP4aVjLM= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607967855267643.1974384018837; Mon, 14 Dec 2020 09:44:15 -0800 (PST) Received: from localhost ([::1]:60290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooh9-000458-MR for importer@patchew.org; Mon, 14 Dec 2020 09:19:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSS-00026G-E0 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:12 -0500 Received: from mail-oi1-x244.google.com ([2607:f8b0:4864:20::244]:43597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSN-00040k-OP for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:12 -0500 Received: by mail-oi1-x244.google.com with SMTP id q25so19223073oij.10 for ; Mon, 14 Dec 2020 06:04:06 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=mZ7Cv5t9pDHcLwkTAHUkGoZLzbW+EIVJw5j5xRLRZ3w=; b=llWe3wZt78bposQlakYx4jKASaeOxfGJ3Bv8D+GtjqYFn2n5Q9U5qjtYDEsvUsA+WZ Rfj5WcNvylazl1uwXt66xcx0O1/RUSmCl++TMKZD9lAkhJWDsbLf4vwvVP0jr1G7I9Db VEI5sIYDXEGBEGdVwY9OTqbdA2l9R+V5SUEB3LVhb0g9fbpgHnp4km1wfy23L1i10FRZ g7y8pz5A3pwdENvN/7+wGrbB5GTTXwhUJO4cMnpLRkTdQE+yANpPXCAnsBwhRPYaMmkS UNJxqLUO5l3oPTLLc9bmWqesU1Rw7zfgLpaiOo+sRe7W7YW0a0b03DP1zRryWyq+Ivg2 /YMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mZ7Cv5t9pDHcLwkTAHUkGoZLzbW+EIVJw5j5xRLRZ3w=; b=TJN23gjzGHWO16JOIRg5IECm3nYTOYxLAt/5jzBKlflQYiyDWs61BtNec/JeDj58PO x7lin07AZjBC4uQjHiHwcPu0wkbezwAiLEV7Q3y9ntwt58IP77TCwjOsv4jFCJo2LqUT aMSF4ddMP103jyyBAv0F6OG/kWM1ERQdrHuRWbyt3BBWySfCeHxQ5gGtEvjDw2GJghCZ a4eeLWddbtkfbNU4DPtuzScHosesjW+lZe2q54IfvlK/xTw5MfGb9vmiVLwFWAXKFFrl E7QLMrCr35IlKxer9J2tpdp6TZVvyeoYJgw1KonQ7lZFq+3HQIJbWAhxUPKGfqhm3DaI 4SRw== X-Gm-Message-State: AOAM531VWdML0R8Piku3FGZyqhYjGjnClAahFCmHd3VOghiy60ljUzR9 WjaqnZtPvQxsEo244ITN3ytkqjskI4MLle/M X-Google-Smtp-Source: ABdhPJzrfcyGzIOh42bNxpess4VOE5mgRlx4ueEygasxsjsl9t/JDW7or8Qchjv4Bto9exgdFvaAIQ== X-Received: by 2002:aca:47c2:: with SMTP id u185mr17970978oia.56.1607954645344; Mon, 14 Dec 2020 06:04:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 30/43] tcg/sparc: Use tcg_tbrel_diff Date: Mon, 14 Dec 2020 08:03:01 -0600 Message-Id: <20201214140314.18544-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::244; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x244.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index d599ae27b5..8f04fdf981 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -440,7 +440,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType typ= e, TCGReg ret, =20 /* A 13-bit constant relative to the TB. */ if (!in_prologue && USE_REG_TB) { - test =3D arg - (uintptr_t)s->code_gen_ptr; + test =3D tcg_tbrel_diff(s, (void *)arg); if (check_fit_ptr(test, 13)) { tcg_out_arithi(s, ret, TCG_REG_TB, test, ARITH_ADD); return; @@ -537,15 +537,15 @@ static inline bool tcg_out_sti(TCGContext *s, TCGType= type, TCGArg val, return false; } =20 -static void tcg_out_ld_ptr(TCGContext *s, TCGReg ret, uintptr_t arg) +static void tcg_out_ld_ptr(TCGContext *s, TCGReg ret, const void *arg) { - intptr_t diff =3D arg - (uintptr_t)s->code_gen_ptr; + intptr_t diff =3D tcg_tbrel_diff(s, arg); if (USE_REG_TB && check_fit_ptr(diff, 13)) { tcg_out_ld(s, TCG_TYPE_PTR, ret, TCG_REG_TB, diff); return; } - tcg_out_movi(s, TCG_TYPE_PTR, ret, arg & ~0x3ff); - tcg_out_ld(s, TCG_TYPE_PTR, ret, ret, arg & 0x3ff); + tcg_out_movi(s, TCG_TYPE_PTR, ret, (uintptr_t)arg & ~0x3ff); + tcg_out_ld(s, TCG_TYPE_PTR, ret, ret, (uintptr_t)arg & 0x3ff); } =20 static inline void tcg_out_sety(TCGContext *s, TCGReg rs) @@ -1313,7 +1313,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_movi_imm13(s, TCG_REG_O0, a0); break; } else if (USE_REG_TB) { - intptr_t tb_diff =3D a0 - (uintptr_t)s->code_gen_ptr; + intptr_t tb_diff =3D tcg_tbrel_diff(s, (void *)a0); if (check_fit_ptr(tb_diff, 13)) { tcg_out_arithi(s, TCG_REG_G0, TCG_REG_I7, 8, RETURN); /* Note that TCG_REG_TB has been unwound to O1. */ @@ -1345,8 +1345,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, } } else { /* indirect jump method */ - tcg_out_ld_ptr(s, TCG_REG_TB, - (uintptr_t)(s->tb_jmp_target_addr + a0)); + tcg_out_ld_ptr(s, TCG_REG_TB, s->tb_jmp_target_addr + a0); tcg_out_arithi(s, TCG_REG_G0, TCG_REG_TB, 0, JMPL); tcg_out_nop(s); } --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607959756; cv=none; d=zohomail.com; s=zohoarc; b=LiL2I0xwi8r14eFUHjXdPQjJ0xDvFKXwTaV/5AWSbKAfZwZmoX9G+f/Iw5nEHQO6lmD3sCFOvOA2N+st9ASmrJir2u++93smygEhHyzmOLruwluyZh1SEyp3i41+ODOd+77lujz/DE56qRiwjcCtePMo+PdFqSyB+y60cC80ws0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607959756; h=Content-Transfer-Encoding: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=5mvFKOnWShEy7XopvqpBj0eW6OOFV8aAjUBBwextvEA=; b=Yd4e/5LZdKQsx+WcrDjrAdQeaei7AozhF63Yz7axRBy5MvvztDy6hQWsww1IIxwtctnQWL8cJ0THE7f18qQaIiFeUnvORCPs+BamwBtyCZVb/STTM3os1ZxkGJNsSCILyvY0o5mW0LrdakGbmQKkkSyj1xtyDPAHlXEUIiMHAf0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607959756385721.2019320149967; Mon, 14 Dec 2020 07:29:16 -0800 (PST) Received: from localhost ([::1]:34510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooaQ-00020g-Me for importer@patchew.org; Mon, 14 Dec 2020 09:12:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooST-00028g-9T for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:13 -0500 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]:42841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSO-000413-Br for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:12 -0500 Received: by mail-oi1-x236.google.com with SMTP id l200so19211465oig.9 for ; Mon, 14 Dec 2020 06:04:07 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5mvFKOnWShEy7XopvqpBj0eW6OOFV8aAjUBBwextvEA=; b=CfyeYFV8SdC7hbLv4LvDFNzS81tkpl+g4l+8/Lwig2OIvyrcMIKj4R+d1QGJAywpwH 0qXY4hyPWuN3wYj2MYkD48YwO+Eegws3QN4uCOEY/3TDgcXbvYQ4Z3ak1GqRvjfWLPK5 ymY61fZuE716ATT2TKfPvTc2gBm6yHs2Dfpof4/Vhv/vySAej28/0UrlnzvoOKSbGegW U2sIn5TdugofVSVeVd0g2N7AZsdEhKdyzFcLrxzL0wkZYm7pYCQP60mDv+7IOfhc4exq 17FVmoG7xNF9L3TZiDAIavDqp/qrW7qfGANRdgz0MXw2xli4y4TPtVTGXK1uEKX6vW6e 5pxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5mvFKOnWShEy7XopvqpBj0eW6OOFV8aAjUBBwextvEA=; b=Tm0Cmm/bSBpRcKmJATLZM3FezxaIntB8Jl4SE9ifjQ0kVA2Yt9a++5MNuEtuV5wOd6 J8tYSYJWB5rF8F736D4DfbE7HkyEBpgqDIE+8svfwPoAwRVskfKTGbTZEn96iTA7DZro aztvCAF5fIVxcZ/hQN99mopiEPhwzzJS3l/PdswLbUV4Y+p3t9A/xSSQPqg7p5mxn9Cm zsZViEWzMlsxSl39cIw4bP5OWMnPX2WjE+O/e334XPrKLMn+TKL4CDQbOYsYttPNmXgK 50YZzx1EF1MTwT+Eqz+7BN4wdu+QL5pfWzBpkdDkEQnfd4Pt3XOOxx9NfeH7TFI7TkTS 6Tkw== X-Gm-Message-State: AOAM531NSQ8qe4pryAxAtjj37kVo+xdJnFTE8RU+4MEFxzf2qIJ434GH oPaElDD/Pz+CBhg1JjEbo8EScnSnAmEwVldI X-Google-Smtp-Source: ABdhPJxVw138CBf5HXorjU4QHUTj+TdOjWhp3c5umivmQXdL/gGXtxlQtkdmmN4rs1nZGtTh9C38qw== X-Received: by 2002:aca:d842:: with SMTP id p63mr18468904oig.139.1607954646961; Mon, 14 Dec 2020 06:04:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 31/43] tcg/sparc: Support split-wx code generation Date: Mon, 14 Dec 2020 08:03:02 -0600 Message-Id: <20201214140314.18544-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::236; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x236.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.h | 2 +- tcg/sparc/tcg-target.c.inc | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index 21e7e2f56f..54b9da9aeb 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -171,6 +171,6 @@ extern bool use_vis3_instructions; void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 8f04fdf981..182124b96c 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -291,14 +291,15 @@ static inline int check_fit_i32(int32_t val, unsigned= int bits) # define check_fit_ptr check_fit_i32 #endif =20 -static bool patch_reloc(tcg_insn_unit *code_ptr, int type, +static bool patch_reloc(tcg_insn_unit *src_rw, int type, intptr_t value, intptr_t addend) { - uint32_t insn =3D *code_ptr; + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + uint32_t insn =3D *src_rw; intptr_t pcrel; =20 value +=3D addend; - pcrel =3D tcg_ptr_byte_diff((tcg_insn_unit *)value, code_ptr); + pcrel =3D tcg_ptr_byte_diff((tcg_insn_unit *)value, src_rx); =20 switch (type) { case R_SPARC_WDISP16: @@ -315,7 +316,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int ty= pe, g_assert_not_reached(); } =20 - *code_ptr =3D insn; + *src_rw =3D insn; return true; } =20 @@ -868,8 +869,8 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) } =20 #ifdef CONFIG_SOFTMMU -static tcg_insn_unit *qemu_ld_trampoline[16]; -static tcg_insn_unit *qemu_st_trampoline[16]; +static const tcg_insn_unit *qemu_ld_trampoline[16]; +static const tcg_insn_unit *qemu_st_trampoline[16]; =20 static void emit_extend(TCGContext *s, TCGReg r, int op) { @@ -930,7 +931,7 @@ static void build_trampolines(TCGContext *s) while ((uintptr_t)s->code_ptr & 15) { tcg_out_nop(s); } - qemu_ld_trampoline[i] =3D s->code_ptr; + qemu_ld_trampoline[i] =3D tcg_splitwx_to_rx(s->code_ptr); =20 if (SPARC64 || TARGET_LONG_BITS =3D=3D 32) { ra =3D TCG_REG_O3; @@ -958,7 +959,7 @@ static void build_trampolines(TCGContext *s) while ((uintptr_t)s->code_ptr & 15) { tcg_out_nop(s); } - qemu_st_trampoline[i] =3D s->code_ptr; + qemu_st_trampoline[i] =3D tcg_splitwx_to_rx(s->code_ptr); =20 if (SPARC64) { emit_extend(s, TCG_REG_O2, i); @@ -1038,7 +1039,8 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_nop(s); =20 /* Epilogue for goto_ptr. */ - tcg_code_gen_epilogue =3D s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_arithi(s, TCG_REG_G0, TCG_REG_I7, 8, RETURN); /* delay slot */ tcg_out_movi_imm13(s, TCG_REG_O0, 0); @@ -1163,7 +1165,7 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg dat= a, TCGReg addr, #ifdef CONFIG_SOFTMMU unsigned memi =3D get_mmuidx(oi); TCGReg addrz, param; - tcg_insn_unit *func; + const tcg_insn_unit *func; tcg_insn_unit *label_ptr; =20 addrz =3D tcg_out_tlb_load(s, addr, memi, memop, @@ -1245,7 +1247,7 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg dat= a, TCGReg addr, #ifdef CONFIG_SOFTMMU unsigned memi =3D get_mmuidx(oi); TCGReg addrz, param; - tcg_insn_unit *func; + const tcg_insn_unit *func; tcg_insn_unit *label_ptr; =20 addrz =3D tcg_out_tlb_load(s, addr, memi, memop, --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607979057; cv=none; d=zohomail.com; s=zohoarc; b=U3ZyZdTHrdve4JQVhE7cbMCoR6h2qnhrP6MOVNz1earnAAI4lEeW2oU04H124F177B1N0oxm2wRTVxXL6pI99NDfHVtJeNd29TClJI0u9TKGy43d+diGj4AT/BEoU6j81WHckhtxWqqc3d9C+UImCmFxR9tJl/KR6TtkyUBYlxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607979057; h=Content-Transfer-Encoding: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=wkypnopb5BzPYlv4jtMpd96OEpFhEMM9GKjZQ7ld/TU=; b=A8qgatXaB/CyUTbrJ3TzZWpZWfnby7A1VL3Quwx7AUEx7oDEgdTLeTJo7XydIJF3EYBIQ8B3bmDAla3BhZhPFj+wT7b7q4dO9Nhh+3mO/vWh7UI5IBdxgb5oQ7hGTVu3Nez7lFMyR93CJoQYUeYnur+Nnhcg7XHw/IYlMfHlw+Y= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607979057326897.1831793105476; Mon, 14 Dec 2020 12:50:57 -0800 (PST) Received: from localhost ([::1]:54044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooyK-0007vq-D6 for importer@patchew.org; Mon, 14 Dec 2020 09:37:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSU-0002AZ-0m for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:14 -0500 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]:41564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSS-00041I-2U for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:13 -0500 Received: by mail-oi1-x241.google.com with SMTP id 15so19241709oix.8 for ; Mon, 14 Dec 2020 06:04:10 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=wkypnopb5BzPYlv4jtMpd96OEpFhEMM9GKjZQ7ld/TU=; b=OFkbbUcGudf0byED37KQrQQ+2t7+REliUnnk+wpcPSRsLUucGWJTd+E0iMkvEgUH43 wmcztRjHZjapXoT6tjVzhfavQIr75HX/572pB6gkkOtDl2D7jy9u+nQi0pidbhVjRXcX pdQV+wtiANcu99RPqGikT2n5FaxasaE8pEQBD5bSPL66aXS4n1O2+V8YD4RYWIKVBaLy nWl5AEv2gDDSz/Gz2zjV/+6DnWKQvLDK7j8lJtCp8A1tHdxs1C7CT2yAEac3hIlAxWpv BqqwTfzmCiPHN48hCr86KrMWQ9q8MPt7XUYgcdsiuxSAO9N8KUjSwn7HGLKnE4SiPETS jYtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wkypnopb5BzPYlv4jtMpd96OEpFhEMM9GKjZQ7ld/TU=; b=qDcMpqMbtWwXJSxmGS+g7CGAIrw5GQDLKFO0OUVv2HBzhbPtrB3v8l6meZ/VBQ+NT+ lR7uiOGLNQCx8uT1ggOsnW1KSoL1G32gMYjJJv0k2N3HmSUwxy0q0watAJsbQfIO+AFO mBGrGzwhBTAPv024YY9ECO/lNvbBymtnPkslFdrnb3DciUgwcZ3qv2h4/PhxT55Q1ymV f0+ZaP1Yy8nrmXaZjRahSkUS4wisQ1QYopUgoV5EqRulqTdj0k4tLeFv85FU23rY5+ju wq4CJYZ3LrvzqaazswYLsgPDCcziPQcFzSNP8LMGFv0KEoM7A+uUyjlytxdpB3b/wbJf CE1w== X-Gm-Message-State: AOAM533Z2MRmOqBhu2nZfY+603JPV+aV8dYTdlBmrt/OhAXclIZQP8WQ PczdCpjwIaYvbc7xb3BsAWB2jvTx5Bh3TrPw X-Google-Smtp-Source: ABdhPJxFl7t0EN4XSa3BWrDlNOAK5GABOZbVWdSfolh8n4Q2h6+p5jAhaNS8YvAkzyJ0vtKUcQkXpA== X-Received: by 2002:aca:4ed3:: with SMTP id c202mr17409395oib.95.1607954649252; Mon, 14 Dec 2020 06:04:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 32/43] tcg/s390: Use tcg_tbrel_diff Date: Mon, 14 Dec 2020 08:03:03 -0600 Message-Id: <20201214140314.18544-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::241; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x241.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Use tcg_tbrel_diff when we need a displacement to a label, and with a NULL argument when we need the normalizing addend. Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.c.inc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index 1444914428..e4c61fc014 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -630,7 +630,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType typ= e, TCGReg ret, return; } } else if (USE_REG_TB && !in_prologue) { - ptrdiff_t off =3D sval - (uintptr_t)s->code_gen_ptr; + ptrdiff_t off =3D tcg_tbrel_diff(s, (void *)sval); if (off =3D=3D sextract64(off, 0, 20)) { /* This is certain to be an address within TB, and therefore OFF will be negative; don't try RX_LA. */ @@ -655,7 +655,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType typ= e, TCGReg ret, } else if (USE_REG_TB && !in_prologue) { tcg_out_insn(s, RXY, LG, ret, TCG_REG_TB, TCG_REG_NONE, 0); new_pool_label(s, sval, R_390_20, s->code_ptr - 2, - -(intptr_t)s->code_gen_ptr); + tcg_tbrel_diff(s, NULL)); } else { TCGReg base =3D ret ? ret : TCG_TMP0; tcg_out_insn(s, RIL, LARL, base, 0); @@ -746,7 +746,7 @@ static void tcg_out_ld_abs(TCGContext *s, TCGType type,= TCGReg dest, void *abs) } } if (USE_REG_TB) { - ptrdiff_t disp =3D abs - (void *)s->code_gen_ptr; + ptrdiff_t disp =3D tcg_tbrel_diff(s, abs); if (disp =3D=3D sextract64(disp, 0, 20)) { tcg_out_ld(s, type, dest, TCG_REG_TB, disp); return; @@ -956,7 +956,7 @@ static void tgen_andi(TCGContext *s, TCGType type, TCGR= eg dest, uint64_t val) if (!maybe_out_small_movi(s, type, TCG_TMP0, val)) { tcg_out_insn(s, RXY, NG, dest, TCG_REG_TB, TCG_REG_NONE, 0); new_pool_label(s, val & valid, R_390_20, s->code_ptr - 2, - -(intptr_t)s->code_gen_ptr); + tcg_tbrel_diff(s, NULL)); return; } } else { @@ -1015,7 +1015,7 @@ static void tgen_ori(TCGContext *s, TCGType type, TCG= Reg dest, uint64_t val) } else if (USE_REG_TB) { tcg_out_insn(s, RXY, OG, dest, TCG_REG_TB, TCG_REG_NONE, 0); new_pool_label(s, val, R_390_20, s->code_ptr - 2, - -(intptr_t)s->code_gen_ptr); + tcg_tbrel_diff(s, NULL)); } else { /* Perform the OR via sequential modifications to the high and low parts. Do this via recursion to handle 16-bit vs 32-bit @@ -1050,7 +1050,7 @@ static void tgen_xori(TCGContext *s, TCGType type, TC= GReg dest, uint64_t val) } else if (USE_REG_TB) { tcg_out_insn(s, RXY, XG, dest, TCG_REG_TB, TCG_REG_NONE, 0); new_pool_label(s, val, R_390_20, s->code_ptr - 2, - -(intptr_t)s->code_gen_ptr); + tcg_tbrel_diff(s, NULL)); } else { /* Perform the xor by parts. */ tcg_debug_assert(s390_facilities & FACILITY_EXT_IMM); @@ -1108,12 +1108,12 @@ static int tgen_cmp(TCGContext *s, TCGType type, TC= GCond c, TCGReg r1, op =3D (is_unsigned ? RXY_CLY : RXY_CY); tcg_out_insn_RXY(s, op, r1, TCG_REG_TB, TCG_REG_NONE, 0); new_pool_label(s, (uint32_t)c2, R_390_20, s->code_ptr - 2, - 4 - (intptr_t)s->code_gen_ptr); + 4 - tcg_tbrel_diff(s, NULL)); } else { op =3D (is_unsigned ? RXY_CLG : RXY_CG); tcg_out_insn_RXY(s, op, r1, TCG_REG_TB, TCG_REG_NONE, 0); new_pool_label(s, c2, R_390_20, s->code_ptr - 2, - -(intptr_t)s->code_gen_ptr); + tcg_tbrel_diff(s, NULL)); } goto exit; } else { --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607956728; cv=none; d=zohomail.com; s=zohoarc; b=ZWZNEs+EVvVw7wTGX8/JqB4ZFQKr4D92yTef9VrVez0DlHA1W+VML7C/Bh30CqMb0DmvGiACxMgnkUiaKzTSbAgOickPdRelzF+IdUR9db+xfqJGtB5+85HTs3dwIcwB7Xb7IpcHlolgT1dvUQMVn5BUYDnMC6uSByVfqOKPH74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607956728; h=Content-Transfer-Encoding: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=dcqt/mgICWsadeLmqExwcaSBKbyWpQDlM1YBo4lkUJg=; b=gKIIpriGb8cYKrrnxa2H5+qK4vJgdV+UuHqPT4B92OktwpJTiJRrVSaYvyzFe7yr/fkqhxNmK/EaxP6bbFwFpcRuEjiYsv1fgEdVpirFDNq538xoIpYHLmRH1gISri4f5bZKSUCVSNlgufi+sOIi0TWi5/IOeqtwDol2hN/7D1M= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607956728627349.9584209664872; Mon, 14 Dec 2020 06:38:48 -0800 (PST) Received: from localhost ([::1]:58220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koozv-0001E0-9h for importer@patchew.org; Mon, 14 Dec 2020 09:38:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSW-0002Cd-G5 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:16 -0500 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]:37246) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooST-00041Y-CE for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:16 -0500 Received: by mail-ot1-x32f.google.com with SMTP id o11so15761185ote.4 for ; Mon, 14 Dec 2020 06:04:12 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=dcqt/mgICWsadeLmqExwcaSBKbyWpQDlM1YBo4lkUJg=; b=J4FKI4XMRd4ABAhc5MJyYcLxavVS3WHMVb6OH/mMWIiANkq3xuinVVDrc6FvvSl4bk gzYjXqqfHX+oLcfiG7NkbpFA85QWCuNsbpUz4W3F/4eAu5uV5BPvOC7IwlVhfJloz1C+ vI7utpER9W70wIG0f66BiV295akeSI5M3aJAZo4g9YTh6N1YIioJREdWGhGUjcPOuaAh kNZlS3FgMtu2UOQq+6Cc75DFSmXd/XHB62SGfPMit02B3PmR3Xob9o5/C17+IByMNVNg 8UG8xbIiK6f/dmHrB10g+H0RzP09T44cLwVzLxLJAJtAjlY/DSS2w+l830JMKHU86hS5 i5Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dcqt/mgICWsadeLmqExwcaSBKbyWpQDlM1YBo4lkUJg=; b=kPXJYySnXlQLP0FX9ZcidZSe/eq0SXiTTCu1l/JKbB4SPsT2G9GcdodA4Rmq2aqdhI w4GrqYbTChNq2gVCKjVcf3uhpFfzQ503MhYMz0PtTiBlar8s8hj6DsQs8RV5NwdwgnVw pHZ69bJY62edfTs2/zO5mEUh8AGnWutz6qYC6WmThXxPuUTCOVfzwpGjAU5uRNjigyiT 428aWWA6FG6MKuu0nfBzLII3MIbgwGZisKZ5iLv/IfLk6bR6jl1uo4p+a2v+tS7ortX8 FW846RcebGS+9v1wSyqUZXGUOloqRqlnuaL/plUyVt2eHcPaJPndYctXTDnnjyreNkjC PIMg== X-Gm-Message-State: AOAM532y1WJPip6VfEqTcZGRp5E9tJg2iytsuemSIU5D9GMB+y4u1cSn 4gbt4fXHd0zTCzvjAqPPnTcY0UFoPWLHutZK X-Google-Smtp-Source: ABdhPJxgUyazVI8wF3nnkSzbyLn96zMk8HAKF1+ApNzSMbNBfxgp9OooJa2KJ/2bShm6ml25idLC3w== X-Received: by 2002:a05:6830:1f5a:: with SMTP id u26mr19803982oth.250.1607954651751; Mon, 14 Dec 2020 06:04:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 33/43] tcg/s390: Support split-wx code generation Date: Mon, 14 Dec 2020 08:03:04 -0600 Message-Id: <20201214140314.18544-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::32f; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32f.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.h | 2 +- tcg/s390/tcg-target.c.inc | 69 +++++++++++++++++---------------------- 2 files changed, 31 insertions(+), 40 deletions(-) diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index fed3329e51..fc65f42650 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -158,6 +158,6 @@ static inline void tb_target_set_jmp_target(uintptr_t t= c_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index e4c61fc014..582a8ef941 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -363,36 +363,37 @@ static void * const qemu_st_helpers[16] =3D { }; #endif =20 -static tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *tb_ret_addr; uint64_t s390_facilities; =20 -static bool patch_reloc(tcg_insn_unit *code_ptr, int type, +static bool patch_reloc(tcg_insn_unit *src_rw, int type, intptr_t value, intptr_t addend) { + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); intptr_t pcrel2; uint32_t old; =20 value +=3D addend; - pcrel2 =3D (tcg_insn_unit *)value - code_ptr; + pcrel2 =3D (tcg_insn_unit *)value - src_rx; =20 switch (type) { case R_390_PC16DBL: if (pcrel2 =3D=3D (int16_t)pcrel2) { - tcg_patch16(code_ptr, pcrel2); + tcg_patch16(src_rw, pcrel2); return true; } break; case R_390_PC32DBL: if (pcrel2 =3D=3D (int32_t)pcrel2) { - tcg_patch32(code_ptr, pcrel2); + tcg_patch32(src_rw, pcrel2); return true; } break; case R_390_20: if (value =3D=3D sextract64(value, 0, 20)) { - old =3D *(uint32_t *)code_ptr & 0xf00000ff; + old =3D *(uint32_t *)src_rw & 0xf00000ff; old |=3D ((value & 0xfff) << 16) | ((value & 0xff000) >> 4); - tcg_patch32(code_ptr, old); + tcg_patch32(src_rw, old); return true; } break; @@ -730,7 +731,8 @@ static inline bool tcg_out_sti(TCGContext *s, TCGType t= ype, TCGArg val, } =20 /* load data from an absolute host address */ -static void tcg_out_ld_abs(TCGContext *s, TCGType type, TCGReg dest, void = *abs) +static void tcg_out_ld_abs(TCGContext *s, TCGType type, + TCGReg dest, const void *abs) { intptr_t addr =3D (intptr_t)abs; =20 @@ -1304,7 +1306,7 @@ static void tgen_extract(TCGContext *s, TCGReg dest, = TCGReg src, =20 static void tgen_gotoi(TCGContext *s, int cc, const tcg_insn_unit *dest) { - ptrdiff_t off =3D dest - s->code_ptr; + ptrdiff_t off =3D tcg_pcrel_diff(s, dest) >> 1; if (off =3D=3D (int16_t)off) { tcg_out_insn(s, RI, BRC, cc, off); } else if (off =3D=3D (int32_t)off) { @@ -1333,34 +1335,18 @@ static void tgen_branch(TCGContext *s, int cc, TCGL= abel *l) static void tgen_compare_branch(TCGContext *s, S390Opcode opc, int cc, TCGReg r1, TCGReg r2, TCGLabel *l) { - intptr_t off =3D 0; - - if (l->has_value) { - off =3D l->u.value_ptr - s->code_ptr; - tcg_debug_assert(off =3D=3D (int16_t)off); - } else { - tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); - } - + tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); tcg_out16(s, (opc & 0xff00) | (r1 << 4) | r2); - tcg_out16(s, off); + tcg_out16(s, 0); tcg_out16(s, cc << 12 | (opc & 0xff)); } =20 static void tgen_compare_imm_branch(TCGContext *s, S390Opcode opc, int cc, TCGReg r1, int i2, TCGLabel *l) { - tcg_target_long off =3D 0; - - if (l->has_value) { - off =3D l->u.value_ptr - s->code_ptr; - tcg_debug_assert(off =3D=3D (int16_t)off); - } else { - tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); - } - + tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); tcg_out16(s, (opc & 0xff00) | (r1 << 4) | cc); - tcg_out16(s, off); + tcg_out16(s, 0); tcg_out16(s, (i2 << 8) | (opc & 0xff)); } =20 @@ -1417,7 +1403,7 @@ static void tgen_brcond(TCGContext *s, TCGType type, = TCGCond c, =20 static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) { - ptrdiff_t off =3D dest - s->code_ptr; + ptrdiff_t off =3D tcg_pcrel_diff(s, dest) >> 1; if (off =3D=3D (int32_t)off) { tcg_out_insn(s, RIL, BRASL, TCG_REG_R14, off); } else { @@ -1601,7 +1587,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool i= s_ld, TCGMemOpIdx oi, label->oi =3D oi; label->datalo_reg =3D data; label->addrlo_reg =3D addr; - label->raddr =3D raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr; } =20 @@ -1613,7 +1600,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) MemOp opc =3D get_memop(oi); =20 if (!patch_reloc(lb->label_ptr[0], R_390_PC16DBL, - (intptr_t)s->code_ptr, 2)) { + (intptr_t)tcg_splitwx_to_rx(s->code_ptr), 2)) { return false; } =20 @@ -1638,7 +1625,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) MemOp opc =3D get_memop(oi); =20 if (!patch_reloc(lb->label_ptr[0], R_390_PC16DBL, - (intptr_t)s->code_ptr, 2)) { + (intptr_t)tcg_splitwx_to_rx(s->code_ptr), 2)) { return false; } =20 @@ -1766,7 +1753,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcod= e opc, case INDEX_op_goto_tb: a0 =3D args[0]; if (s->tb_jmp_insn_offset) { - /* branch displacement must be aligned for atomic patching; + /* + * branch displacement must be aligned for atomic patching; * see if we need to add extra nop before branch */ if (!QEMU_PTR_IS_ALIGNED(s->code_ptr + 1, 4)) { @@ -1779,7 +1767,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcod= e opc, } else { /* load address stored at s->tb_jmp_target_addr + a0 */ tcg_out_ld_abs(s, TCG_TYPE_PTR, TCG_REG_TB, - s->tb_jmp_target_addr + a0); + tcg_splitwx_to_rx(s->tb_jmp_target_addr + a0)); /* and go there */ tcg_out_insn(s, RR, BCR, S390_CC_ALWAYS, TCG_REG_TB); } @@ -1789,8 +1777,10 @@ static inline void tcg_out_op(TCGContext *s, TCGOpco= de opc, TCG_REG_TB to the beginning of this TB. */ if (USE_REG_TB) { int ofs =3D -tcg_current_code_size(s); - assert(ofs =3D=3D (int16_t)ofs); - tcg_out_insn(s, RI, AGHI, TCG_REG_TB, ofs); + /* All TB are restricted to 64KiB by unwind info. */ + tcg_debug_assert(ofs =3D=3D sextract64(ofs, 0, 20)); + tcg_out_insn(s, RXY, LAY, TCG_REG_TB, + TCG_REG_TB, TCG_REG_NONE, ofs); } break; =20 @@ -2561,11 +2551,12 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - tcg_code_gen_epilogue =3D s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, 0); =20 /* TB epilogue */ - tb_ret_addr =3D s->code_ptr; + tb_ret_addr =3D tcg_splitwx_to_rx(s->code_ptr); =20 /* lmg %r6,%r15,fs+48(%r15) (restore registers) */ tcg_out_insn(s, RXY, LMG, TCG_REG_R6, TCG_REG_R15, TCG_REG_R15, --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607977331; cv=none; d=zohomail.com; s=zohoarc; b=LwbYQ9yXzVLpwV/6zTjOr0aaa2PfTvTNkbMNJ/j1kWtPpaU6Kceo47fy29z+pGE4ni4SAJ0N7f9D6zLixAQinp6UmpqCASA7UCDFfmbZ6XEWMf6nPgMhd4s1hj+By3UWbEEvGj0W9mrvPaIK0NitlE7iyafs5UbPtHH1xT4acW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607977331; h=Content-Transfer-Encoding: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=cOhvs0ghq8muGX3iEeRtFXrjJiLy3u5yfl5gf+ftseU=; b=BRPMLFDcoeY5bv8fjXVgCM+AJVQaN0+aRyesRwOgrSh/74qdlCJETQyoQRgDzhunz58VppBhNDxIzBM+DbNos/3A6vfcm6em3RzckDpklkh+eZ858485I14ceuszQvg+fbesxAiOiocHJH2MgOiDL9AhXmdZarIOm/qMSeGpfiI= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607977331343216.61099509894063; Mon, 14 Dec 2020 12:22:11 -0800 (PST) Received: from localhost ([::1]:59918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooh4-0003wC-W6 for importer@patchew.org; Mon, 14 Dec 2020 09:19:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSl-0002N1-1O for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:34 -0500 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:34397) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSU-00041n-Rv for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:28 -0500 Received: by mail-ot1-x342.google.com with SMTP id a109so15759084otc.1 for ; Mon, 14 Dec 2020 06:04:14 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cOhvs0ghq8muGX3iEeRtFXrjJiLy3u5yfl5gf+ftseU=; b=DugRX87tAwJ4ZhsF0NikzXI95oQ+vkzCv0IZKKaZ4bg5+6CE77GhX6d0bNAXrF54rN vjNAtuiTOwogrGWJ3pCCMe1u6QfLgp84xJWZec8V7Ar/Y82u/vAjafPMqZIsBWxosfLq RS8BiUPLf1ZxoSMJInnjlONnDl6sDVDmZGUgqkvlm0KU/uHcuTrluUMRNPQsFCiIJbVC ke2lLcow6+je8a1fPERTEKxXRSNHZw+kRWXmddVegM6ZvEcsCFf8KTKdO4+Gtm9IaWJu Wdb9xBj7IzPYctOC0U90hm53vC5FqjVSagud5coW3d3d6k2qAuJ+woeHqIqvT6/H9Eyx SkGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cOhvs0ghq8muGX3iEeRtFXrjJiLy3u5yfl5gf+ftseU=; b=XkbZylWrHXT4Y0ZU6J1MM0nXiwoOVjkuvmsWYKmK7cfSK/b3x6esJiWO6rS/M/MLrR LbQ2RPO7u2RVquCxWbovwC0Ntf4VS0k11BNTFaGiJEi+UQ5+oMg7x88qA9oYf0A09v6R vaHRW0UBYoP2/WfZKNapoRCxgiPh1Op7YkrAtWQYUhgLo2E/813tRNcSQSFnRKY2C3VH NjEXsjX9jg3KRug6jTVEIfuNGLQFE5HnVPHky9lqV86+oG92I/f9mzUCR09R87QZWjzg 1LQt3jTmLfJ0mKXbj2sOscMqK8C80RdA6OMS0gugjnXYrmBp7BzFxhcivS0Rsze9dJT3 lEcw== X-Gm-Message-State: AOAM531s6Uy5z7yPFLmJXXsVAvZtc8SqvJ9xrQh3+Y5f1r97iEG4h4mv SvxdiIiSXDG9uTImX9ALPv5PQ0lhy5HVoHE3 X-Google-Smtp-Source: ABdhPJwA7oAmiBCc0RdQIQDO2R8l5+MS1juEINyYIFPlBkC1/PXAqSQzM53BFS9xdvNc1jgjuf0h2A== X-Received: by 2002:a05:6830:1bef:: with SMTP id k15mr11273698otb.303.1607954653170; Mon, 14 Dec 2020 06:04:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 34/43] tcg/riscv: Fix branch range checks Date: Mon, 14 Dec 2020 08:03:05 -0600 Message-Id: <20201214140314.18544-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::342; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x342.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" The offset even checks were folded into the range check incorrectly. By offsetting by 1, and not decrementing the width, we silently allowed out of range branches. Assert that the offset is always even instead. Move tcg_out_goto down into the CONFIG_SOFTMMU block so that it is not unused. Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis --- tcg/riscv/tcg-target.c.inc | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 025e3cd0bb..195c3eff03 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -429,7 +429,8 @@ static bool reloc_sbimm12(tcg_insn_unit *code_ptr, tcg_= insn_unit *target) { intptr_t offset =3D (intptr_t)target - (intptr_t)code_ptr; =20 - if (offset =3D=3D sextreg(offset, 1, 12) << 1) { + tcg_debug_assert((offset & 1) =3D=3D 0); + if (offset =3D=3D sextreg(offset, 0, 12)) { code_ptr[0] |=3D encode_sbimm12(offset); return true; } @@ -441,7 +442,8 @@ static bool reloc_jimm20(tcg_insn_unit *code_ptr, tcg_i= nsn_unit *target) { intptr_t offset =3D (intptr_t)target - (intptr_t)code_ptr; =20 - if (offset =3D=3D sextreg(offset, 1, 20) << 1) { + tcg_debug_assert((offset & 1) =3D=3D 0); + if (offset =3D=3D sextreg(offset, 0, 20)) { code_ptr[0] |=3D encode_ujimm20(offset); return true; } @@ -854,28 +856,21 @@ static void tcg_out_setcond2(TCGContext *s, TCGCond c= ond, TCGReg ret, g_assert_not_reached(); } =20 -static inline void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) -{ - ptrdiff_t offset =3D tcg_pcrel_diff(s, target); - tcg_debug_assert(offset =3D=3D sextreg(offset, 1, 20) << 1); - tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, offset); -} - static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool= tail) { TCGReg link =3D tail ? TCG_REG_ZERO : TCG_REG_RA; ptrdiff_t offset =3D tcg_pcrel_diff(s, arg); int ret; =20 - if (offset =3D=3D sextreg(offset, 1, 20) << 1) { + tcg_debug_assert((offset & 1) =3D=3D 0); + if (offset =3D=3D sextreg(offset, 0, 20)) { /* short jump: -2097150 to 2097152 */ tcg_out_opc_jump(s, OPC_JAL, link, offset); - } else if (TCG_TARGET_REG_BITS =3D=3D 32 || - offset =3D=3D sextreg(offset, 1, 31) << 1) { + } else if (TCG_TARGET_REG_BITS =3D=3D 32 || offset =3D=3D (int32_t)off= set) { /* long jump: -2147483646 to 2147483648 */ tcg_out_opc_upper(s, OPC_AUIPC, TCG_REG_TMP0, 0); tcg_out_opc_imm(s, OPC_JALR, link, TCG_REG_TMP0, 0); - ret =3D reloc_call(s->code_ptr - 2, arg);\ + ret =3D reloc_call(s->code_ptr - 2, arg); tcg_debug_assert(ret =3D=3D true); } else if (TCG_TARGET_REG_BITS =3D=3D 64) { /* far jump: 64-bit */ @@ -962,6 +957,13 @@ QEMU_BUILD_BUG_ON(TCG_TARGET_REG_BITS < TARGET_LONG_BI= TS); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) > 0); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -(1 << 11)); =20 +static void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) +{ + tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, 0); + bool ok =3D reloc_jimm20(s->code_ptr - 1, target); + tcg_debug_assert(ok); +} + static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl, TCGReg addrh, TCGMemOpIdx oi, tcg_insn_unit **label_ptr, bool is_load) --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607956418; cv=none; d=zohomail.com; s=zohoarc; b=lPtxIkxjRcPxxmNBK+HN6eDtHR+6QhKoJPvOLTPKh5staDEl1++r8jWksMLBJno77dZqd787LPkKOUl8UegVUQI+Ol39qu2EPseuu8hQXaaExAGonXPkUzcNIu4PjcCXhVCG3K1JdI1jGXvox0DHlPNRVQMbdrA1K1R92tQknuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607956418; h=Content-Transfer-Encoding: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=LiVRLDdLRLwNh3EAfOwsqGZsrXFOtm3LiOx00UdIraE=; b=mhLojGAOM+vWFwZzaYiEzQbej/S/xmo/cr9kk31wW1rraqOYE96M0j9iUFfEa80vHay5phVyrpm9jU3sNyZeET9EUVQ4b42wWQXrepTxzhrrzQLkv/6n+xR2AR6VennNw4bMU/G1i8MUIGYZE0lSjotJ0XfZAG/c8yuvKd0P2Z4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607956418039529.5813921533628; Mon, 14 Dec 2020 06:33:38 -0800 (PST) Received: from localhost ([::1]:43870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koout-0003g3-2p for importer@patchew.org; Mon, 14 Dec 2020 09:33:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSY-0002GA-6J for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:18 -0500 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:46731) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSW-00041t-AS for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:17 -0500 Received: by mail-ot1-x341.google.com with SMTP id w3so15757739otp.13 for ; Mon, 14 Dec 2020 06:04:15 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=LiVRLDdLRLwNh3EAfOwsqGZsrXFOtm3LiOx00UdIraE=; b=Yp539SXcv2vVYvEqOD/L8Yr9KE2L4Jm69B9GJKrh46zdLmup4HJoKxVfdE3Plhty2F mBaxZ3T2MDEL4U82om742B7cz6Efc9DVDscPrRLdPO9eGtmpVFmiqlKIX/luT7SYQynR vXq/fIpYm6knq4uG0Bl7mZVPIKcmFReRRJp2LxQ9yu1d+4qxLzrEuQepW9Bd7eh/vf9T JT2z7+xGiQxFnNP9OYhpmdlJVtYrOLKPQxozO0ZuEzEy3Wr5EBG2HBwKctAtTOZ5oNKI Qc4S/Rr3nm8HOXJY0C4pNmd7PtfHXLtRVT8br/LSzm/fnjpcUE687RCnybQfimHsGXch 8WRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LiVRLDdLRLwNh3EAfOwsqGZsrXFOtm3LiOx00UdIraE=; b=fbPBMbZZaKg2IiJl/QeQPfJlMIomgSAmFLNTJMBN9wEJ8RhioOxe7qu2pHxrNnWmkx cm8oEE7fOlIk+SAewiAhsOT2qzbskXCk0+FL/RQnHcWrP/ojEXF1mxc8knX4EdvRwiBV 4xTsvwGv60024kKojPzWpcFlFFKvokzPtJcpt7w5K+J4slKVdOcBgbBsfITTMzxTCZE9 /8VxhAg4QN9fxbjwRIJbJ/jEY3dPkZ7EZ20y2GKsNdBzT/xaCA+3L2nNu+mm2rDWJ6h9 cOUdaENJDqnjbgrThUwyspYegDNdim7vZwpmP9QK9zKcJDO+Eue3NsazJg9c6ohIW7O0 qYUA== X-Gm-Message-State: AOAM531ki6mmSN+vQoJJQIz0W/5iJoFmX3zuq9oXTyhc4e3eDTYY8d8s QRzjEnPrxH4K58LPoF6v8phoJ5FdDbmZiGMH X-Google-Smtp-Source: ABdhPJxdGTN8exexdmu/vaVbNUxQDCmGy89jVn8j8d4Ned7ZXkfN1k8BzQ4boWtLtrtEYdjUF+6SrA== X-Received: by 2002:a9d:4b81:: with SMTP id k1mr19980131otf.371.1607954654859; Mon, 14 Dec 2020 06:04:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 35/43] tcg/riscv: Remove branch-over-branch fallback Date: Mon, 14 Dec 2020 08:03:06 -0600 Message-Id: <20201214140314.18544-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::341; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x341.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Since 7ecd02a06f8, we are prepared to re-start code generation with a smaller TB if a relocation is out of range. We no longer need to leave a nop in the stream Just In Case. Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis --- tcg/riscv/tcg-target.c.inc | 56 ++++---------------------------------- 1 file changed, 6 insertions(+), 50 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 195c3eff03..02beb86977 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -469,43 +469,16 @@ static bool reloc_call(tcg_insn_unit *code_ptr, const= tcg_insn_unit *target) static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { - uint32_t insn =3D *code_ptr; - intptr_t diff; - bool short_jmp; - tcg_debug_assert(addend =3D=3D 0); - switch (type) { case R_RISCV_BRANCH: - diff =3D value - (uintptr_t)code_ptr; - short_jmp =3D diff =3D=3D sextreg(diff, 0, 12); - if (short_jmp) { - return reloc_sbimm12(code_ptr, (tcg_insn_unit *)value); - } else { - /* Invert the condition */ - insn =3D insn ^ (1 << 12); - /* Clear the offset */ - insn &=3D 0x01fff07f; - /* Set the offset to the PC + 8 */ - insn |=3D encode_sbimm12(8); - - /* Move forward */ - code_ptr[0] =3D insn; - - /* Overwrite the NOP with jal x0,value */ - diff =3D value - (uintptr_t)(code_ptr + 1); - insn =3D encode_uj(OPC_JAL, TCG_REG_ZERO, diff); - code_ptr[1] =3D insn; - - return true; - } - break; + return reloc_sbimm12(code_ptr, (tcg_insn_unit *)value); case R_RISCV_JAL: return reloc_jimm20(code_ptr, (tcg_insn_unit *)value); case R_RISCV_CALL: return reloc_call(code_ptr, (tcg_insn_unit *)value); default: - tcg_abort(); + g_assert_not_reached(); } } =20 @@ -779,21 +752,8 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond= , TCGReg arg1, arg2 =3D t; } =20 - if (l->has_value) { - intptr_t diff =3D tcg_pcrel_diff(s, l->u.value_ptr); - if (diff =3D=3D sextreg(diff, 0, 12)) { - tcg_out_opc_branch(s, op, arg1, arg2, diff); - } else { - /* Invert the conditional branch. */ - tcg_out_opc_branch(s, op ^ (1 << 12), arg1, arg2, 8); - tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, diff - 4); - } - } else { - tcg_out_reloc(s, s->code_ptr, R_RISCV_BRANCH, l, 0); - tcg_out_opc_branch(s, op, arg1, arg2, 0); - /* NOP to allow patching later */ - tcg_out_opc_imm(s, OPC_ADDI, TCG_REG_ZERO, TCG_REG_ZERO, 0); - } + tcg_out_reloc(s, s->code_ptr, R_RISCV_BRANCH, l, 0); + tcg_out_opc_branch(s, op, arg1, arg2, 0); } =20 static void tcg_out_setcond(TCGContext *s, TCGCond cond, TCGReg ret, @@ -1009,8 +969,6 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg add= rl, /* Compare masked address with the TLB entry. */ label_ptr[0] =3D s->code_ptr; tcg_out_opc_branch(s, OPC_BNE, TCG_REG_TMP0, TCG_REG_TMP1, 0); - /* NOP to allow patching later */ - tcg_out_opc_imm(s, OPC_ADDI, TCG_REG_ZERO, TCG_REG_ZERO, 0); =20 /* TLB Hit - translate address using addend. */ if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { @@ -1054,8 +1012,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *l) } =20 /* resolve label address */ - if (!patch_reloc(l->label_ptr[0], R_RISCV_BRANCH, - (intptr_t) s->code_ptr, 0)) { + if (!reloc_sbimm12(l->label_ptr[0], s->code_ptr)) { return false; } =20 @@ -1089,8 +1046,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *l) } =20 /* resolve label address */ - if (!patch_reloc(l->label_ptr[0], R_RISCV_BRANCH, - (intptr_t) s->code_ptr, 0)) { + if (!reloc_sbimm12(l->label_ptr[0], s->code_ptr)) { return false; } =20 --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607959780; cv=none; d=zohomail.com; s=zohoarc; b=iXkXPZqVdCcm4z4fP+owlNQVFqONDltU1SIJkpZrE90gVZkRKbY1cw/vVwbCXdmheOAl/WCuLIpG8rewV1CHaQnYbqte1MfuU9sLiRdSbCVxJbofl5hek7YoDd+tUzvT/l3iPAOWPxIyIXPvANnYKpYLBVYzMBsma2aKOzpIy6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607959780; h=Content-Transfer-Encoding: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=nfuYW3YpACxe1tM8rVcQkTfXfB+YXnTp2x/9NWOzn0g=; b=F6Zo8cihUX3ANGMJvbrs1i35w3i3l6L1qSU4HnUTiRzxIKRoD11ugsej4IvGPOTllKaUeQw2FsKFbXEsUTEJYvIy7USgtmLlAzLfNl9e5wjPEZN1b3P/r0N9c6dHTlJfz5kULglyVDVWvh9w0xeCm4S9cCfO/Fk4ypYV8K0wv8I= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607959780276907.159328854805; Mon, 14 Dec 2020 07:29:40 -0800 (PST) Received: from localhost ([::1]:43100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koocV-0005TQ-DW for importer@patchew.org; Mon, 14 Dec 2020 09:14:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSb-0002KV-An for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:21 -0500 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:43598) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSZ-000428-Cd for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:21 -0500 Received: by mail-oi1-x242.google.com with SMTP id q25so19223739oij.10 for ; Mon, 14 Dec 2020 06:04:19 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=nfuYW3YpACxe1tM8rVcQkTfXfB+YXnTp2x/9NWOzn0g=; b=A76XEIwXqBmCPnF9C0ryNK2y+rVs1T/kyfDaRlggqLhLuYR0KFSYeIe9kj3JRnVriZ BRcae0dV66ai0t2cv0j+RYuIGHPJ+K9FR8JBU9SVNDMGFo8QJ9QB1Nho4idkE9RUhD3/ XuqY+tgVh1NFHgunOXfFcgZ6+APV210HZVKyabeft+ac15iOqI/rMVwSyaokcg2QayMg k/xr5q7EEQSDKSlJX2mCu8TCw2vgWw8X6hEuySdOBgoux4vPNMA3coo1uLdoMf4XIwuR Ll/Fke9S9wZGb58JFjYFJwSyKqaW+18GHGKU1yN4+J04HymA+xS53uDcPmDSkXdH94bw sk+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nfuYW3YpACxe1tM8rVcQkTfXfB+YXnTp2x/9NWOzn0g=; b=i7yTTMuUi2KM+KhwQmpkh/WIkAdT5kkxFVFBxi5eMXYxGypTtP4FHkH8JhX6fMqACm sRTWLUy/vUbVy5bsc1ylNre+6js7TN6hIth4/eW8/woLh1iKXSYYahCcjiyEJ45x7AZA JT8AvqLF7VL4WEeyIZxX9q9jjVA75/RTmiVd8Pdr8aEOmlg6qO4pMn4Dxmz7ZH2ayqwN gJ6QGSD1o7QfEjAyA+UCUCkQEZH9poPUcc11m2OrhvUcq8wF77/rNK3UINQZ+GMS4tuC NTKKg9XD/PrPWvpcDWX8ZtJzHJih0o+7AeXa5phNhac/tk5ywQnMaYddJaaxLuDewmZ+ leMQ== X-Gm-Message-State: AOAM530h9+ggQqWDqEpR2t07WtHe4RSKug3xv9RMDcvqF2Ezwx/M355y +c2J/GdhdMd5aLuhg6ilcqx3kV61j/8lgY4y X-Google-Smtp-Source: ABdhPJwO/tF1GiYFYZ9AGbjoOXngKZJucYXizEXe8DnaAgA3cTgSHD09ZlxYRwlODQi2wJfU1yLfcQ== X-Received: by 2002:aca:5ec2:: with SMTP id s185mr18350727oib.33.1607954657662; Mon, 14 Dec 2020 06:04:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 36/43] tcg/riscv: Support split-wx code generation Date: Mon, 14 Dec 2020 08:03:07 -0600 Message-Id: <20201214140314.18544-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::242; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x242.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis --- tcg/riscv/tcg-target.h | 2 +- tcg/riscv/tcg-target.c.inc | 41 +++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 785fe37f9b..60b6a1a3fc 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -170,6 +170,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS =20 #define TCG_TARGET_HAS_MEMORY_BSWAP 0 -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 02beb86977..5c1e0f8fc1 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -425,41 +425,44 @@ static void tcg_out_nop_fill(tcg_insn_unit *p, int co= unt) * Relocations */ =20 -static bool reloc_sbimm12(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_sbimm12(tcg_insn_unit *src_rw, const tcg_insn_unit *targ= et) { - intptr_t offset =3D (intptr_t)target - (intptr_t)code_ptr; + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + intptr_t offset =3D (intptr_t)target - (intptr_t)src_rx; =20 tcg_debug_assert((offset & 1) =3D=3D 0); if (offset =3D=3D sextreg(offset, 0, 12)) { - code_ptr[0] |=3D encode_sbimm12(offset); + *src_rw |=3D encode_sbimm12(offset); return true; } =20 return false; } =20 -static bool reloc_jimm20(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_jimm20(tcg_insn_unit *src_rw, const tcg_insn_unit *targe= t) { - intptr_t offset =3D (intptr_t)target - (intptr_t)code_ptr; + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + intptr_t offset =3D (intptr_t)target - (intptr_t)src_rx; =20 tcg_debug_assert((offset & 1) =3D=3D 0); if (offset =3D=3D sextreg(offset, 0, 20)) { - code_ptr[0] |=3D encode_ujimm20(offset); + *src_rw |=3D encode_ujimm20(offset); return true; } =20 return false; } =20 -static bool reloc_call(tcg_insn_unit *code_ptr, const tcg_insn_unit *targe= t) +static bool reloc_call(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - intptr_t offset =3D (intptr_t)target - (intptr_t)code_ptr; + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + intptr_t offset =3D (intptr_t)target - (intptr_t)src_rx; int32_t lo =3D sextreg(offset, 0, 12); int32_t hi =3D offset - lo; =20 if (offset =3D=3D hi + lo) { - code_ptr[0] |=3D encode_uimm20(hi); - code_ptr[1] |=3D encode_imm12(lo); + src_rw[0] |=3D encode_uimm20(hi); + src_rw[1] |=3D encode_imm12(lo); return true; } =20 @@ -532,7 +535,7 @@ static void tcg_out_movi(TCGContext *s, TCGType type, T= CGReg rd, if (tmp =3D=3D (int32_t)tmp) { tcg_out_opc_upper(s, OPC_AUIPC, rd, 0); tcg_out_opc_imm(s, OPC_ADDI, rd, rd, 0); - ret =3D reloc_call(s->code_ptr - 2, (tcg_insn_unit *)val); + ret =3D reloc_call(s->code_ptr - 2, (const tcg_insn_unit *)val); tcg_debug_assert(ret =3D=3D true); return; } @@ -917,7 +920,7 @@ QEMU_BUILD_BUG_ON(TCG_TARGET_REG_BITS < TARGET_LONG_BIT= S); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) > 0); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -(1 << 11)); =20 -static void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) +static void tcg_out_goto(TCGContext *s, const tcg_insn_unit *target) { tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, 0); bool ok =3D reloc_jimm20(s->code_ptr - 1, target); @@ -993,7 +996,8 @@ static void add_qemu_ldst_label(TCGContext *s, int is_l= d, TCGMemOpIdx oi, label->datahi_reg =3D datahi; label->addrlo_reg =3D addrlo; label->addrhi_reg =3D addrhi; - label->raddr =3D raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr[0]; } =20 @@ -1012,7 +1016,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *l) } =20 /* resolve label address */ - if (!reloc_sbimm12(l->label_ptr[0], s->code_ptr)) { + if (!reloc_sbimm12(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } =20 @@ -1046,7 +1050,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *l) } =20 /* resolve label address */ - if (!reloc_sbimm12(l->label_ptr[0], s->code_ptr)) { + if (!reloc_sbimm12(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } =20 @@ -1232,7 +1236,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is_64) #endif } =20 -static tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *tb_ret_addr; =20 static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, const int *const_args) @@ -1780,11 +1784,12 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, tcg_target_call_iarg_regs[1= ], 0); =20 /* Return path for goto_ptr. Set return value to 0 */ - tcg_code_gen_epilogue =3D s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_A0, TCG_REG_ZERO); =20 /* TB epilogue */ - tb_ret_addr =3D s->code_ptr; + tb_ret_addr =3D tcg_splitwx_to_rx(s->code_ptr); for (i =3D 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); i++) { tcg_out_ld(s, TCG_TYPE_REG, tcg_target_callee_save_regs[i], TCG_REG_SP, SAVE_OFS + i * REG_SIZE); --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607977562; cv=none; d=zohomail.com; s=zohoarc; b=k1jS66nWEFpAcaim9hgz2A2V7rk9CH0/q0OP+Sl0sEEOPgwYm9mu1LW3Ny9GotuYxevnltSll5N/6b10wecGyldsPo87zMDu19JbxAzRVB2m+UAKrx0o8V7muRvhzLiW/ZHG1MKXbouIW+pf8lnzDYVd1TRf2jutVJVlzWt4xhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607977562; h=Content-Transfer-Encoding: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=vrSqwZKXMyaSyRVRtm4Hh+vS+LTe1orOUMFlnbJhADM=; b=WuUOPZbK9++koz54oOAzn+OrMn36UCe6suAJbunj83/hE3eTxQLztmNFlKbChrfILfESvLbWasCpkJ1Jm9CQnSc+QkhdxDfjgFcVZwHKsj9Ew0hnch7qno829BTlsIWKC2bcsh36lidLxZnQN3dyq6Npt5wm24bY+/FONMeVlhg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607977562843373.8691512788629; Mon, 14 Dec 2020 12:26:02 -0800 (PST) Received: from localhost ([::1]:34100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kop2X-00035i-1J for importer@patchew.org; Mon, 14 Dec 2020 09:41:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSd-0002MG-KS for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:27 -0500 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:46734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSb-00042E-RA for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:23 -0500 Received: by mail-ot1-x344.google.com with SMTP id w3so15757999otp.13 for ; Mon, 14 Dec 2020 06:04:21 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vrSqwZKXMyaSyRVRtm4Hh+vS+LTe1orOUMFlnbJhADM=; b=ZTrJ9csEkHzMvHpyiiud4BUrYZ8IFUysHkcvYdfcPv6AEQ6OApcrNueWmkVau6kIZY xes6h0iIoU4cNLvZ00ZD4O+IRsufw1SdxdJbJjg7E6yFbPj4HD2Igcff9D8iDNEUkdo3 wnycvVfQkWGilSlgSobzcRjy0obqGGu6z/kr1yMqZQd7p1MYgjoZcnzEg8dHDjnklOHz C03thYH/sGhTXgPDT5oSdwfMunP+ukjTT0xTnUgWVn9zGJuIS30YKqETOwHlGmjOMp9k zRtnbHPlZg2tzcg9WVF8/fnHpdxYd13xGNJVbRPPMOX+GSH+67ybadW6XyCFQQ6Aa6ti gm9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vrSqwZKXMyaSyRVRtm4Hh+vS+LTe1orOUMFlnbJhADM=; b=O9+nbakkG82a56CdabecWoF4Qxa9VBw82jg7F1gV2MW7AwFV/Vo+7439zOg2VUQ0lS hEx0znfQ/4AjnCteF5FEkSvlN/FyVLGWnv34wcw4Oyg5OYwf/vvlHaepuzE6lTVINill uvVfSkLiUd+uD0welFwbW81Qh7D4i6yo9VjfuvMsgT2Cqx2XDqZx7aQMwp1mQ13XdVlo i+vsf+Z0ikapW8DPl30nFONWSMGFPpcHhZDKJtUuEfxPJcgXnOHO63fgrWNQBpNUABZQ GYTv3O9fFh36LZUP1YvY9iwE3J2cNfV8euB1UL/q6A5qLFYlydyyqd5KtGuDhPwYHfJT 7mtg== X-Gm-Message-State: AOAM5323PNXEXcVBC024EIZAdGUReAtlmivKnJc+TLFCbPCRSdTk4+t6 jB2TOTmXYgnwp0HXoqkS7hK8dhMQ+fk9vAGJ X-Google-Smtp-Source: ABdhPJxAzA6SZTTeebkG7Gc7VkjdZ5b0/65qge62qL0BNmo+GR3mhiDS20U8g88MXvj3fhosppwaGg== X-Received: by 2002:a9d:508:: with SMTP id 8mr19943863otw.338.1607954660242; Mon, 14 Dec 2020 06:04:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 37/43] accel/tcg: Add mips support to alloc_code_gen_buffer_splitwx_memfd Date: Mon, 14 Dec 2020 08:03:08 -0600 Message-Id: <20201214140314.18544-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::344; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x344.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Re-use the 256MiB region handling from alloc_code_gen_buffer_anon, and replace that with the shared file mapping. Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 46 ++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 17df6c94fa..b49aaf1026 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1137,24 +1137,40 @@ static bool alloc_code_gen_buffer_anon(size_t size,= int prot, =20 static bool alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp) { - void *buf_rw, *buf_rx; + void *buf_rw =3D NULL, *buf_rx =3D MAP_FAILED; int fd =3D -1; =20 +#ifdef __mips__ + /* Find space for the RX mapping, vs the 256MiB regions. */ + if (!alloc_code_gen_buffer_anon(size, PROT_NONE, + MAP_PRIVATE | MAP_ANONYMOUS | + MAP_NORESERVE, errp)) { + return false; + } + /* The size of the mapping may have been adjusted. */ + size =3D tcg_ctx->code_gen_buffer_size; + buf_rx =3D tcg_ctx->code_gen_buffer; +#endif + buf_rw =3D qemu_memfd_alloc("tcg-jit", size, 0, &fd, errp); if (buf_rw =3D=3D NULL) { - return false; + goto fail; } =20 +#ifdef __mips__ + void *tmp =3D mmap(buf_rx, size, PROT_READ | PROT_EXEC, + MAP_SHARED | MAP_FIXED, fd, 0); + if (tmp !=3D buf_rx) { + goto fail_rx; + } +#else buf_rx =3D mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0); if (buf_rx =3D=3D MAP_FAILED) { - error_setg_errno(errp, errno, - "failed to map shared memory for execute"); - munmap(buf_rw, size); - close(fd); - return false; + goto fail_rx; } - close(fd); +#endif =20 + close(fd); tcg_ctx->code_gen_buffer =3D buf_rw; tcg_ctx->code_gen_buffer_size =3D size; tcg_splitwx_diff =3D buf_rx - buf_rw; @@ -1163,6 +1179,20 @@ static bool alloc_code_gen_buffer_splitwx_memfd(size= _t size, Error **errp) qemu_madvise(buf_rw, size, QEMU_MADV_HUGEPAGE); qemu_madvise(buf_rx, size, QEMU_MADV_HUGEPAGE); return true; + + fail_rx: + error_setg_errno(errp, errno, "failed to map shared memory for execute= "); + fail: + if (buf_rx !=3D MAP_FAILED) { + munmap(buf_rx, size); + } + if (buf_rw) { + munmap(buf_rw, size); + } + if (fd >=3D 0) { + close(fd); + } + return false; } #endif /* CONFIG_POSIX */ =20 --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607972226; cv=none; d=zohomail.com; s=zohoarc; b=XLtDvwLF50j9zicb1Kc9qcOTdNAU0G+dGKHA4j+AT81POQwFL2QCrs54mUeBxM/H7orYjPnky0nO42Xr19kUZg0Y6dOvG3cB+gOwE7lIpMyP6KeuIhw+uEAYPq26JbdKGT0GiCzuerXZa4hndvChavswB/0gpeXcmNocnpg0PMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607972226; h=Content-Transfer-Encoding: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=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=A5kx3gyZukvg7r2GpucfphIEAYJeLouddjj4yFmKplHCZMyPThlKUSk8//G4NF+cJ01onlkn1Acv9jFdAfFRHYiUyCKt3jDqTAGR5KePM+Eba8g86ACpDAELj2SzMUot23TAss43z9LLaQaRpxs8c0a58txSdU3Ipp0ECMesy0I= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607972226068924.916899892346; Mon, 14 Dec 2020 10:57:06 -0800 (PST) Received: from localhost ([::1]:51548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooey-0000Yz-GF for importer@patchew.org; Mon, 14 Dec 2020 09:17:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSh-0002MP-Dj for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:27 -0500 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:38651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSd-00042Q-KE for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:27 -0500 Received: by mail-oi1-x242.google.com with SMTP id x13so10203090oic.5 for ; Mon, 14 Dec 2020 06:04:23 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=MZYjn4RB697EkkCaK4MQzT7k9JoSojr0sQdClHXHo1uJxLAaw31NWGGo/V9sHmS1sz 4IwRIfypPeEBr901puW0Rz7oWEei/u18kvMfXxfLbucsbSLlX8wHDLhm5gYntCIb3NFQ iZ5oBudFy/5dlys23+fE50nc+ZPr8yKC2qsJNjSrZNaPuFmYdGblB6pziopVnf2YhzEW MGM7UxZsvGwFh1rGDT5SvBi4bh7ej8Fp8lvoJ5rpKFZLa/zw0ohenxuKQoXRZGByMoy0 ncDZePvchnK6GqhKjgWqAhJXTE3xs7rB88aDKm0zUGFRjBJu3a9fDM++0fBSTXAH0ijJ dkCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=Y0Yz9OKDQ03IshXNj4z48/G0PrkKdbq9C5wB/lxlA2UeuKU33nGQcZp1LrpqmtcGTL JLLnRPt7lUjH5PW79vLilu78YjKzvwVNnRqgp8T/s2GOS16nM4IczTCtuWHcgdlUD9Ug elsUZViCbWEzvnHQD1r0xiVHTNSuB6PHdI5q8o26FqubimSLNLuFd4Yg+bIdr3abA6lL /ZZAFSaHzjMb3ElLJco9dIVysZArZY5AA5rE2s0shblJFDkrEVgQEcaIjNl/xq0mARGV 4jRA+uFT2oZ2vtXtB+/ChAzVEdAZYoZZskcMYVvymgCChsCTqp3Q14Yzw5KSRH7gQDW8 PG0g== X-Gm-Message-State: AOAM530SnGZ5YKQ95K6CMYvufCH5M/2k3zhUPNL6Z/s6QGs1qNJ7gLUP DYRo3TWmUCJ8W32p5o5txL4tJ+QFqe1ZQWd1 X-Google-Smtp-Source: ABdhPJyBe42f3kN2Zb103V6SYk9tu6DhcJ8qJsAfEz84x6MwObHoQYIQyDWIlwqX7O1lycoJRHlrbA== X-Received: by 2002:aca:51d8:: with SMTP id f207mr10129136oib.20.1607954662058; Mon, 14 Dec 2020 06:04:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 38/43] tcg/mips: Do not assert on relocation overflow Date: Mon, 14 Dec 2020 08:03:09 -0600 Message-Id: <20201214140314.18544-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::242; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x242.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" This target was not updated with 7ecd02a06f8, and so did not allow re-compilation with relocation overflow. Remove reloc_26 and reloc_26_val as unused. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 53 ++++++++++++++------------------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 52638e920c..37faf1356c 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -144,29 +144,15 @@ static tcg_insn_unit *bswap32_addr; static tcg_insn_unit *bswap32u_addr; static tcg_insn_unit *bswap64_addr; =20 -static inline uint32_t reloc_pc16_val(tcg_insn_unit *pc, - const tcg_insn_unit *target) +static bool reloc_pc16(tcg_insn_unit *pc, const tcg_insn_unit *target) { /* Let the compiler perform the right-shift as part of the arithmetic.= */ ptrdiff_t disp =3D target - (pc + 1); - tcg_debug_assert(disp =3D=3D (int16_t)disp); - return disp & 0xffff; -} - -static inline void reloc_pc16(tcg_insn_unit *pc, const tcg_insn_unit *targ= et) -{ - *pc =3D deposit32(*pc, 0, 16, reloc_pc16_val(pc, target)); -} - -static inline uint32_t reloc_26_val(tcg_insn_unit *pc, tcg_insn_unit *targ= et) -{ - tcg_debug_assert((((uintptr_t)pc ^ (uintptr_t)target) & 0xf0000000) = =3D=3D 0); - return ((uintptr_t)target >> 2) & 0x3ffffff; -} - -static inline void reloc_26(tcg_insn_unit *pc, tcg_insn_unit *target) -{ - *pc =3D deposit32(*pc, 0, 26, reloc_26_val(pc, target)); + if (disp =3D=3D (int16_t)disp) { + *pc =3D deposit32(*pc, 0, 16, disp); + return true; + } + return false; } =20 static bool patch_reloc(tcg_insn_unit *code_ptr, int type, @@ -174,8 +160,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int ty= pe, { tcg_debug_assert(type =3D=3D R_MIPS_PC16); tcg_debug_assert(addend =3D=3D 0); - reloc_pc16(code_ptr, (tcg_insn_unit *)value); - return true; + return reloc_pc16(code_ptr, (const tcg_insn_unit *)value); } =20 #define TCG_CT_CONST_ZERO 0x100 @@ -925,11 +910,7 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond= , TCGReg arg1, } =20 tcg_out_opc_br(s, b_opc, arg1, arg2); - if (l->has_value) { - reloc_pc16(s->code_ptr - 1, l->u.value_ptr); - } else { - tcg_out_reloc(s, s->code_ptr - 1, R_MIPS_PC16, l, 0); - } + tcg_out_reloc(s, s->code_ptr - 1, R_MIPS_PC16, l, 0); tcg_out_nop(s); } =20 @@ -1316,9 +1297,10 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s,= TCGLabelQemuLdst *l) int i; =20 /* resolve label address */ - reloc_pc16(l->label_ptr[0], s->code_ptr); - if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { - reloc_pc16(l->label_ptr[1], s->code_ptr); + if (!reloc_pc16(l->label_ptr[0], s->code_ptr) + || (TCG_TARGET_REG_BITS < TARGET_LONG_BITS + && !reloc_pc16(l->label_ptr[1], s->code_ptr))) { + return false; } =20 i =3D 1; @@ -1346,7 +1328,9 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *l) } =20 tcg_out_opc_br(s, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO); - reloc_pc16(s->code_ptr - 1, l->raddr); + if (!reloc_pc16(s->code_ptr - 1, l->raddr)) { + return false; + } =20 /* delay slot */ if (TCG_TARGET_REG_BITS =3D=3D 64 && l->type =3D=3D TCG_TYPE_I32) { @@ -1366,9 +1350,10 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s,= TCGLabelQemuLdst *l) int i; =20 /* resolve label address */ - reloc_pc16(l->label_ptr[0], s->code_ptr); - if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { - reloc_pc16(l->label_ptr[1], s->code_ptr); + if (!reloc_pc16(l->label_ptr[0], s->code_ptr) + || (TCG_TARGET_REG_BITS < TARGET_LONG_BITS + && !reloc_pc16(l->label_ptr[1], s->code_ptr))) { + return false; } =20 i =3D 1; --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607967817; cv=none; d=zohomail.com; s=zohoarc; b=OpVSDwmlsplttU5EEI9elJ+luXMAf1OqdRheA/MwZEEwv75F9kOt2aUOXQ6u0Xzw2K6kWXAytynAF8+HbcQao/T6KSgTjQY3ckQIsz3R/KZgWhfHIRg4KljYTig8UA2z3xwmVhIGiLK08H4N1oY8rzUgdtWaoMeW7puW7HimnDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607967817; h=Content-Transfer-Encoding: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=7XP/q5eBCNmpZFQJA85me1/1KiBm/v6kAiLB9c+2Pvs=; b=LgDsiOIn+GbDlF+9htGytcbhLUkDAiuLTZB3vZ092DD4P21zf/+rORDlAXTLWuO6MEpVUrlfsUCipI+IUVXpnMFYfbOAFCYpy5v6TRGADe4uuV9Y6GfwOy0r8RHw1EpTnNy6O5ll5IcPlxH3nAPtsz8KxF1TaRdOdb9lRgClElM= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607967817713451.0753468166454; Mon, 14 Dec 2020 09:43:37 -0800 (PST) Received: from localhost ([::1]:39656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kop59-0005Uj-5p for importer@patchew.org; Mon, 14 Dec 2020 09:44:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSo-0002PB-SQ for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:36 -0500 Received: from mail-oi1-x244.google.com ([2607:f8b0:4864:20::244]:38654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSi-00042i-Ui for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:34 -0500 Received: by mail-oi1-x244.google.com with SMTP id x13so10203383oic.5 for ; Mon, 14 Dec 2020 06:04:27 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7XP/q5eBCNmpZFQJA85me1/1KiBm/v6kAiLB9c+2Pvs=; b=GiV7gcv3XKDbVZGsX0vvXKovQKYimffbuvzUyTEJmK+5o6eLq0wwgUT42Mqqdr9JFB qQ/Q3pwlsWe7v+W2/TgzVs9+LzZ9jGLXpMU38fNeLcj/OZEHfix6/3xgj4eAQZkfCJKm sG0aZeKIfxUjppzPRvtIhWLDsiM+f9vIp73MMAmgdj75Fu/mxNhCOtLYUTDn546u23qv Nxib5/v6p0jxYmM3DW1JSdCMO4dub43aIdBjicX/CEfAzz7enRk0eC4PfuNf5qRG373Q 606/IiOk3t0JIIp/QM/Y3kLa1pcaelC01lXt/d/NqZaoWddCKlIN03oyfSBcLhQ2UBkI bX6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7XP/q5eBCNmpZFQJA85me1/1KiBm/v6kAiLB9c+2Pvs=; b=XmK5nMuIWknQu2tVTsQkkNxDGoW87VnnVzsd4CmT9gjeph5GCBXmrrM7MuJWanLMET 6Z3amzPqTOM0wtf0T7tKeEb0nsmog8NRLjkcy/flvbWWiauU1h89xNjypLghQu8Xcl4W TQIs8V1+x2uGHcVt6K1sliwNc5KB+l2D6/UOOLbQcnEV69TAlJmsAX/Opa+dI2Nl6RTv 9PmCJYqCGr3GB7182BTNE9Z+9l8GCQpZZnzgV+IIDNm5JUe0oJ5WLzqmDpZ5/pJTmPkb r/ClWNWU+Ce/Gqz8rKOUjERgLcwliBCnVq+IFo72x9XQJccQnXZUF8KA18T3lCTYSgRg lV+A== X-Gm-Message-State: AOAM5325yMwUbkmQ3/87qFwXsJXyxT+kaM3CT7bu3881uGTVTOpsZDu/ P3u/DVXioKIRTNlhYxsRmwmJzd+TEB9n7gma X-Google-Smtp-Source: ABdhPJyhsM+kbCO+mNElsTKw9KD6cimKojW+9EJ/uePcwi7FZiBaV3Ag8QP9xotoJRg/Qruziwcfwg== X-Received: by 2002:aca:bd0b:: with SMTP id n11mr17596790oif.11.1607954664570; Mon, 14 Dec 2020 06:04:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 39/43] tcg/mips: Support split-wx code generation Date: Mon, 14 Dec 2020 08:03:10 -0600 Message-Id: <20201214140314.18544-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::244; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x244.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.h | 2 +- tcg/mips/tcg-target.c.inc | 43 ++++++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index d6dff897bf..c200ac02ea 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -200,7 +200,7 @@ extern bool use_mips32r2_instructions; =20 #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 =20 void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 37faf1356c..a2201bd1dd 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -139,17 +139,18 @@ static const TCGReg tcg_target_call_oarg_regs[2] =3D { TCG_REG_V1 }; =20 -static tcg_insn_unit *tb_ret_addr; -static tcg_insn_unit *bswap32_addr; -static tcg_insn_unit *bswap32u_addr; -static tcg_insn_unit *bswap64_addr; +static const tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *bswap32_addr; +static const tcg_insn_unit *bswap32u_addr; +static const tcg_insn_unit *bswap64_addr; =20 -static bool reloc_pc16(tcg_insn_unit *pc, const tcg_insn_unit *target) +static bool reloc_pc16(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { /* Let the compiler perform the right-shift as part of the arithmetic.= */ - ptrdiff_t disp =3D target - (pc + 1); + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t disp =3D target - (src_rx + 1); if (disp =3D=3D (int16_t)disp) { - *pc =3D deposit32(*pc, 0, 16, disp); + *src_rw =3D deposit32(*src_rw, 0, 16, disp); return true; } return false; @@ -505,7 +506,7 @@ static void tcg_out_opc_sa64(TCGContext *s, MIPSInsn op= c1, MIPSInsn opc2, static bool tcg_out_opc_jmp(TCGContext *s, MIPSInsn opc, const void *targe= t) { uintptr_t dest =3D (uintptr_t)target; - uintptr_t from =3D (uintptr_t)s->code_ptr + 4; + uintptr_t from =3D (uintptr_t)tcg_splitwx_to_rx(s->code_ptr) + 4; int32_t inst; =20 /* The pc-region branch happens within the 256MB region of @@ -617,7 +618,7 @@ static inline void tcg_out_bswap16s(TCGContext *s, TCGR= eg ret, TCGReg arg) } } =20 -static void tcg_out_bswap_subr(TCGContext *s, tcg_insn_unit *sub) +static void tcg_out_bswap_subr(TCGContext *s, const tcg_insn_unit *sub) { bool ok =3D tcg_out_opc_jmp(s, OPC_JAL, sub); tcg_debug_assert(ok); @@ -1282,7 +1283,8 @@ static void add_qemu_ldst_label(TCGContext *s, int is= _ld, TCGMemOpIdx oi, label->datahi_reg =3D datahi; label->addrlo_reg =3D addrlo; label->addrhi_reg =3D addrhi; - label->raddr =3D raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr[0]; if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { label->label_ptr[1] =3D label_ptr[1]; @@ -1291,15 +1293,16 @@ static void add_qemu_ldst_label(TCGContext *s, int = is_ld, TCGMemOpIdx oi, =20 static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) { + const tcg_insn_unit *tgt_rx =3D tcg_splitwx_to_rx(s->code_ptr); TCGMemOpIdx oi =3D l->oi; MemOp opc =3D get_memop(oi); TCGReg v0; int i; =20 /* resolve label address */ - if (!reloc_pc16(l->label_ptr[0], s->code_ptr) + if (!reloc_pc16(l->label_ptr[0], tgt_rx) || (TCG_TARGET_REG_BITS < TARGET_LONG_BITS - && !reloc_pc16(l->label_ptr[1], s->code_ptr))) { + && !reloc_pc16(l->label_ptr[1], tgt_rx))) { return false; } =20 @@ -1344,15 +1347,16 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s= , TCGLabelQemuLdst *l) =20 static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) { + const tcg_insn_unit *tgt_rx =3D tcg_splitwx_to_rx(s->code_ptr); TCGMemOpIdx oi =3D l->oi; MemOp opc =3D get_memop(oi); MemOp s_bits =3D opc & MO_SIZE; int i; =20 /* resolve label address */ - if (!reloc_pc16(l->label_ptr[0], s->code_ptr) + if (!reloc_pc16(l->label_ptr[0], tgt_rx) || (TCG_TARGET_REG_BITS < TARGET_LONG_BITS - && !reloc_pc16(l->label_ptr[1], s->code_ptr))) { + && !reloc_pc16(l->label_ptr[1], tgt_rx))) { return false; } =20 @@ -2469,11 +2473,12 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - tcg_code_gen_epilogue =3D s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_V0, TCG_REG_ZERO); =20 /* TB epilogue */ - tb_ret_addr =3D s->code_ptr; + tb_ret_addr =3D tcg_splitwx_to_rx(s->code_ptr); for (i =3D 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); i++) { tcg_out_ld(s, TCG_TYPE_REG, tcg_target_callee_save_regs[i], TCG_REG_SP, SAVE_OFS + i * REG_SIZE); @@ -2493,7 +2498,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) /* * bswap32 -- 32-bit swap (signed result for mips64). a0 =3D abcd. */ - bswap32_addr =3D align_code_ptr(s); + bswap32_addr =3D tcg_splitwx_to_rx(align_code_ptr(s)); /* t3 =3D (ssss)d000 */ tcg_out_opc_sa(s, OPC_SLL, TCG_TMP3, TCG_TMP0, 24); /* t1 =3D 000a */ @@ -2521,7 +2526,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) /* * bswap32u -- unsigned 32-bit swap. a0 =3D ....abcd. */ - bswap32u_addr =3D align_code_ptr(s); + bswap32u_addr =3D tcg_splitwx_to_rx(align_code_ptr(s)); /* t1 =3D (0000)000d */ tcg_out_opc_imm(s, OPC_ANDI, TCG_TMP1, TCG_TMP0, 0xff); /* t3 =3D 000a */ @@ -2547,7 +2552,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) /* * bswap64 -- 64-bit swap. a0 =3D abcdefgh */ - bswap64_addr =3D align_code_ptr(s); + bswap64_addr =3D tcg_splitwx_to_rx(align_code_ptr(s)); /* t3 =3D h0000000 */ tcg_out_dsll(s, TCG_TMP3, TCG_TMP0, 56); /* t1 =3D 0000000a */ --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607956559; cv=none; d=zohomail.com; s=zohoarc; b=YdD+mCdJv4tLvKWmb/GdMET/pD/Vr+iZgkpXngN6UPTAo2nJZLF9ZmNGc3+6wSOwA3nKsAULBpwV9ecrpUuWOC3UGDtSSenP8otYVINyDWBOWsCk/Kfj2K81dIdm5pZI+SR81mEa0Ms11elxgoy8ykdyZbsPsFFDNH5Ud+LuXX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607956559; h=Content-Transfer-Encoding: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=746olrr4Rbmh5ZNHTyxNWXv98LGv+Z4R3bTpMGSCzAU=; b=V2jlDDk0kuRy2/L63Qkmu+fTH51BUHJd8mK7oZ2UpOY34T++MlLbWChMEYMeYlJDECm/IceU8O7bXbeEVARcoJiKt0GGSTXv8vq0TlR14PS7BIOtgcBTh8Be5EfxzSb7B+rIcARpGgW5jQf2E5XlDK2iU4edguPxi+e6da+5l7U= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607956558651343.93738346817895; Mon, 14 Dec 2020 06:35:58 -0800 (PST) Received: from localhost ([::1]:50172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koox9-0006FV-QQ for importer@patchew.org; Mon, 14 Dec 2020 09:35:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSo-0002Of-QN for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:36 -0500 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]:43369) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSi-00042b-Ux for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:33 -0500 Received: by mail-oi1-x22d.google.com with SMTP id q25so19224231oij.10 for ; Mon, 14 Dec 2020 06:04:27 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=746olrr4Rbmh5ZNHTyxNWXv98LGv+Z4R3bTpMGSCzAU=; b=uFZRB6fhRQLL2WjlERqxS89DDU2VB1i6SpxbhnNfpJSUbVjF15neCQnxjKJL/ZmmpD UNnJQLftPwHY7zBF0nYwVTXZ4YCTsu1S8fculEHhko9pOFuU+krou8jIw7/f7oxMfv9D dDizvbO0PzETicr7JG36vSM6vsgNQls+NEInoF+jy+XQ1EjYNdKL0PoV800zC+c1MV66 rCw91dJlzvigG3hCQGP7+eGTXxICQjrPCtKp1eUL1Qi7fC0X+naoeQ4OJ6eOXwFhRCOF dyQ88jvsdsSPkWL3GU7vUCOS4kPPmJ7BdVEEzuyDr93D2vGyKYBFE3/e1njtMEalpX+M j4Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=746olrr4Rbmh5ZNHTyxNWXv98LGv+Z4R3bTpMGSCzAU=; b=kMMRqfXDtaM2H7s2y53UyTQNOcxNN91UtHi6X5jqkgJq0FOS/VJ7t9sv3r/CCpLfr5 e16YkFz9Aohy+4Ezl6NjMBa0XE5884Ck4b1WwNNGRDqw7Ub3FjnpCdZcG19sS5x9p+1X yCBQkwdXCBgDYVPxwHML337yPHx5KFnzXdFYgn2vholhzs6JWfEEqcxo/YDKCUApl7O/ 3oyvlmWp8vnUh0bIMRqjbHyeTu4njFHXaum5k81VQVUEanlxM+cxfXaaxkt0u/0Otanu DmGKRBJ9QgEPeP/QcuuVbSlOVpUpm3K1X2Kh8nzPRtbrpczL3DjIvlLGPnDWpM7D14IC 4/qw== X-Gm-Message-State: AOAM531Rq1k4oqVlkLRbM9AVKuvj8hSztIQIYeZxp8uVRVSYI8lKq29i QLwz/e+VfwYPGMW8w91Qky1L48+w6LgLtpuj X-Google-Smtp-Source: ABdhPJy70QeOUCFvIRJIkR2uMJrCSyMwXVLGOG2yyzQNY47Uxe1Wy4pl94QDiDhjKUgJjfvfyVEHSw== X-Received: by 2002:aca:4b16:: with SMTP id y22mr18186707oia.148.1607954665966; Mon, 14 Dec 2020 06:04:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 40/43] tcg/arm: Support split-wx code generation Date: Mon, 14 Dec 2020 08:03:11 -0600 Message-Id: <20201214140314.18544-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::22d; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22d.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.h | 2 +- tcg/arm/tcg-target.c.inc | 37 +++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 7e04755428..856d6dd4b0 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -141,6 +141,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 9b9400f164..3d2717aeb0 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -187,29 +187,32 @@ static const uint8_t tcg_cond_to_arm_cond[] =3D { [TCG_COND_GTU] =3D COND_HI, }; =20 -static inline bool reloc_pc24(tcg_insn_unit *code_ptr, tcg_insn_unit *targ= et) +static bool reloc_pc24(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset =3D (tcg_ptr_byte_diff(target, code_ptr) - 8) >> 2; + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset =3D (tcg_ptr_byte_diff(target, src_rx) - 8) >> 2; + if (offset =3D=3D sextract32(offset, 0, 24)) { - *code_ptr =3D (*code_ptr & ~0xffffff) | (offset & 0xffffff); + *src_rw =3D deposit32(*src_rw, 0, 24, offset); return true; } return false; } =20 -static inline bool reloc_pc13(tcg_insn_unit *code_ptr, tcg_insn_unit *targ= et) +static bool reloc_pc13(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset =3D tcg_ptr_byte_diff(target, code_ptr) - 8; + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset =3D tcg_ptr_byte_diff(target, src_rx) - 8; =20 if (offset >=3D -0xfff && offset <=3D 0xfff) { - tcg_insn_unit insn =3D *code_ptr; + tcg_insn_unit insn =3D *src_rw; bool u =3D (offset >=3D 0); if (!u) { offset =3D -offset; } insn =3D deposit32(insn, 23, 1, u); insn =3D deposit32(insn, 0, 12, offset); - *code_ptr =3D insn; + *src_rw =3D insn; return true; } return false; @@ -221,9 +224,9 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int ty= pe, tcg_debug_assert(addend =3D=3D 0); =20 if (type =3D=3D R_ARM_PC24) { - return reloc_pc24(code_ptr, (tcg_insn_unit *)value); + return reloc_pc24(code_ptr, (const tcg_insn_unit *)value); } else if (type =3D=3D R_ARM_PC13) { - return reloc_pc13(code_ptr, (tcg_insn_unit *)value); + return reloc_pc13(code_ptr, (const tcg_insn_unit *)value); } else { g_assert_not_reached(); } @@ -617,7 +620,7 @@ static void tcg_out_movi32(TCGContext *s, int cond, int= rd, uint32_t arg) =20 /* Check for a pc-relative address. This will usually be the TB, or within the TB, which is immediately before the code block. */ - diff =3D arg - ((intptr_t)s->code_ptr + 8); + diff =3D tcg_pcrel_diff(s, (void *)arg) - 8; if (diff >=3D 0) { rot =3D encode_imm(diff); if (rot >=3D 0) { @@ -1337,7 +1340,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool i= s_ld, TCGMemOpIdx oi, label->datahi_reg =3D datahi; label->addrlo_reg =3D addrlo; label->addrhi_reg =3D addrhi; - label->raddr =3D raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr; } =20 @@ -1348,7 +1352,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) MemOp opc =3D get_memop(oi); void *func; =20 - if (!reloc_pc24(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc24(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } =20 @@ -1411,7 +1415,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) TCGMemOpIdx oi =3D lb->oi; MemOp opc =3D get_memop(oi); =20 - if (!reloc_pc24(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc24(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } =20 @@ -1762,8 +1766,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcod= e opc, TCGReg base =3D TCG_REG_PC; =20 tcg_debug_assert(s->tb_jmp_insn_offset =3D=3D 0); - ptr =3D (intptr_t)(s->tb_jmp_target_addr + args[0]); - dif =3D ptr - ((intptr_t)s->code_ptr + 8); + ptr =3D (intptr_t)tcg_splitwx_to_rx(s->tb_jmp_target_addr + ar= gs[0]); + dif =3D tcg_pcrel_diff(s, (void *)ptr) - 8; dil =3D sextract32(dif, 0, 12); if (dif !=3D dil) { /* The TB is close, but outside the 12 bits addressable by @@ -2297,7 +2301,8 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - tcg_code_gen_epilogue =3D s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R0, 0); tcg_out_epilogue(s); } --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607977757; cv=none; d=zohomail.com; s=zohoarc; b=SpONe/bm6ga2Ul+ODBv96B077V3OmpVzyZ6BZIWM/NBe2cJPaI8/+SRavPfk2O5m6mHT8dlhBMpFBzloAjUsfua5USCNEtbv6XX4p8SgkuXzFk1CGLjJP9O/3gScC97wMasrsqnH26S1BEH1gXio2fnpiIJja/ZugyPkvZk1bF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607977757; h=Content-Transfer-Encoding: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=qmq9iNdZ5Znmtjd43X4+7pjV8Eyd2wTluaWBrB9Hxcc=; b=LVLP7jHMoYvMzhfIIMXjILzpWV7Q1O0ufGHmh//WA3LvMuV+7+2CYXQhEPo6tBFHFObPZcQlYHcoAFKpfcyv0DoERoGFHglHjpnHs6f/C5kPv+O1cGlS2m/RMmTM6VDe5zE663wJizla/h60UViw5LCE2WLVr1E7m//6KLeIrH4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607977757287191.56682668097073; Mon, 14 Dec 2020 12:29:17 -0800 (PST) Received: from localhost ([::1]:39294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koojR-000748-PQ for importer@patchew.org; Mon, 14 Dec 2020 09:21:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSq-0002PT-H3 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:36 -0500 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:36401) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSi-00042k-V5 for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:36 -0500 Received: by mail-ot1-x342.google.com with SMTP id y24so15770402otk.3 for ; Mon, 14 Dec 2020 06:04:28 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=qmq9iNdZ5Znmtjd43X4+7pjV8Eyd2wTluaWBrB9Hxcc=; b=wrfKBOPk42nl7EGDvaTngLTkJGwLFS0ny14wmNVmozEwoHzsxVohowSf1P2oFaiw6x CD+vpQOZC2jv08GhFSPQzar3l/vWssIN4i8WNEPzEL6QZYewa/kRQ0tYlHJ1cQKYUhtE MOVujRv2LUNpIQbb8DXc8oCJya55IAVK/Ait09sVcGDPoB4i9nKs7icfacliBuAwFfwL lhhskTIMUbVaL0xcZ8WgUL+fKkZQrLbWD2TZW+CsFpY77Pm3IUgXPbSELSIQ8KYGhD6V DBo5VVbg28RuNu+3p55PKm3S99XyjqzSMbc3iM2fE5Yyp93m0z/4wkArN0X8j+F4vwCm Z5Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qmq9iNdZ5Znmtjd43X4+7pjV8Eyd2wTluaWBrB9Hxcc=; b=CK0GiWvjHPT+uqx9gPeWgzNW/I89CU3FqGMWNx5iVkh+/xkOSihLZG6iyEOJC+Zsmo f0CrWBo5f/bAac07f8A7z1HSQTYnyTJPCICFr5lvRwXwSQV13w/MQDbK8oYx7M3gI7TX XqsAKAFPw0gfS+3wx8Sh/qtQCWXMKb0bXOAsAuM5mBePhyYKIWW0lCw4Yzi6DrldvoVn ultiD0/+98n0Z2ibheqZo9geiM74ydhI1eqw/s8NHncS7xGpByIBT2LAJviZplERsng5 SQqLWj+BAgiczOot1bP7LMXpxHTK5yBgFWChLbXtz7JphEEl775fYtSqzoaZeok4fT1Q 7+SQ== X-Gm-Message-State: AOAM531QfM/b0JLiafCJ/kDlJCP6x/V5Fu8BWfg8eB1gfdqtQze++Og3 GxXpTNJguXSSkgfATMrpOqIKun7Rs7ddedDN X-Google-Smtp-Source: ABdhPJybbVaE1rhAmHgbBCg06x4Xp/4C4jXc2q7iprqT0dUSxMea2Ck7J/amh4UsR6+sJIwqvdtVpg== X-Received: by 2002:a05:6830:2371:: with SMTP id r17mr20045312oth.236.1607954667070; Mon, 14 Dec 2020 06:04:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 41/43] tcg: Remove TCG_TARGET_SUPPORT_MIRROR Date: Mon, 14 Dec 2020 08:03:12 -0600 Message-Id: <20201214140314.18544-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::342; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x342.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Now that all native tcg hosts support splitwx, remove the define. Replace the one use with a test for CONFIG_TCG_INTERPRETER. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- tcg/aarch64/tcg-target.h | 1 - tcg/arm/tcg-target.h | 1 - tcg/i386/tcg-target.h | 1 - tcg/mips/tcg-target.h | 1 - tcg/ppc/tcg-target.h | 1 - tcg/riscv/tcg-target.h | 1 - tcg/s390/tcg-target.h | 1 - tcg/sparc/tcg-target.h | 1 - tcg/tci/tcg-target.h | 1 - accel/tcg/translate-all.c | 16 +++++++++------- 10 files changed, 9 insertions(+), 16 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 81778e3a9c..6ba248f447 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -154,6 +154,5 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif /* AARCH64_TCG_TARGET_H */ diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 856d6dd4b0..6ca4537ca6 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -141,6 +141,5 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 2e57e95ac2..0dcaed7fe6 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -231,6 +231,5 @@ static inline void tb_target_set_jmp_target(uintptr_t t= c_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index c200ac02ea..d23baf7cda 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -200,7 +200,6 @@ extern bool use_mips32r2_instructions; =20 #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -#define TCG_TARGET_SUPPORT_MIRROR 1 =20 void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index b3361b8abc..c41d10142b 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -184,6 +184,5 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 60b6a1a3fc..3d0745c70c 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -170,6 +170,5 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS =20 #define TCG_TARGET_HAS_MEMORY_BSWAP 0 -#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index fc65f42650..3750952598 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -158,6 +158,5 @@ static inline void tb_target_set_jmp_target(uintptr_t t= c_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index 54b9da9aeb..9c15c91d39 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -171,6 +171,5 @@ extern bool use_vis3_instructions; void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 768153fd02..fcec2e70db 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -197,7 +197,6 @@ void tci_disas(uint8_t opc); #define TCG_TARGET_DEFAULT_MO (0) =20 #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -#define TCG_TARGET_SUPPORT_MIRROR 0 =20 static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jm= p_rx, uintptr_t jmp_rw, uintptr_t ad= dr) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index b49aaf1026..21a20fed42 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1132,6 +1132,7 @@ static bool alloc_code_gen_buffer_anon(size_t size, i= nt prot, return true; } =20 +#ifndef CONFIG_TCG_INTERPRETER #ifdef CONFIG_POSIX #include "qemu/memfd.h" =20 @@ -1254,17 +1255,18 @@ static bool alloc_code_gen_buffer_splitwx_vmremap(s= ize_t size, Error **errp) return true; } #endif /* CONFIG_DARWIN */ +#endif /* CONFIG_TCG_INTERPRETER */ =20 static bool alloc_code_gen_buffer_splitwx(size_t size, Error **errp) { - if (TCG_TARGET_SUPPORT_MIRROR) { -#ifdef CONFIG_DARWIN - return alloc_code_gen_buffer_splitwx_vmremap(size, errp); +#ifndef CONFIG_TCG_INTERPRETER +# ifdef CONFIG_DARWIN + return alloc_code_gen_buffer_splitwx_vmremap(size, errp); +# endif +# ifdef CONFIG_POSIX + return alloc_code_gen_buffer_splitwx_memfd(size, errp); +# endif #endif -#ifdef CONFIG_POSIX - return alloc_code_gen_buffer_splitwx_memfd(size, errp); -#endif - } error_setg(errp, "jit split-wx not supported"); return false; } --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607975616; cv=none; d=zohomail.com; s=zohoarc; b=CXjSUnBXKuhZvb4K5WabKKlW8Dg5GH1uVGIvVw/FU8423npXsOQMVy2Xtzd/RxSH/O17MvabRJuycmlw9ShuwbBBxfMA18vtSGBmn1YRSs5O+1KMHaWdjYIp3jzuGfKtVL3qQmZDL6gT3fxQQ4rTpYddTKgLFW3ZYeRUKOMzM6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607975616; h=Content-Transfer-Encoding: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=sfLvztrUGFMGQ8L1kj5P/IO1L5kK/jJ3mfS34ntrWYs=; b=OqlPQWaPgHukn7V4imqsR9ulQOPHHsMxcYq0Aapr5rwrfWKidJ9L7WfhAUWz547lk7Ap4JYA9MRFR2BRz6I3Gd3wEKZcLno8O03i13MWtPEL7cxARLzSBjrbInPylC0f9jhPwGxenjNvnbhOXvfroQ7cRaOyLZ5YD9DnQyMB80w= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607975616285118.31702789838289; Mon, 14 Dec 2020 11:53:36 -0800 (PST) Received: from localhost ([::1]:45710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koolf-0001FK-7l for importer@patchew.org; Mon, 14 Dec 2020 09:24:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSu-0002R2-Ks for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:40 -0500 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:38042) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSm-000435-Pb for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:40 -0500 Received: by mail-ot1-x344.google.com with SMTP id j20so11294054otq.5 for ; Mon, 14 Dec 2020 06:04:31 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sfLvztrUGFMGQ8L1kj5P/IO1L5kK/jJ3mfS34ntrWYs=; b=WE1gXhnPDhPcBB8fXdCFdzQrDVflrN1VY718B8CdqyNSOQwD0dIp0vFPccFrmondEd Pg8Hw1H+zja4jEPoxMrUiBI7UGIhiFL9FAh1c90D8Cre2+8qUSpYg9D/7YFdSXFhPFNs 9FDpFG36kWyDRR32zHG6lxmMtQqN6/3I4O/pFSr3UAaRpEmTC2FuyylTTbtC2z7yLCQA OHMlEwnXVwNLEdf4ndhDfD9CzaYfh5iiLwzdUdeGyAJpocaI1mh88xtj+HTTvg+z3t4T ZO6MqHrVIu5IXGJXv+t2sPUqH160Bjs5LTvPWdsuNxQqRhg5OaBtyGCTwuk8OI+31JNA KUfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sfLvztrUGFMGQ8L1kj5P/IO1L5kK/jJ3mfS34ntrWYs=; b=rwXsArdXghCzLVCj9fPLZAbBqKCEAeTy85oF28ZcfP8hsWI8CWx+lkqR4dqijfHBCp apuFKOPywqG+wGAbuLWT6a5TKCb77E99hziAXMTTTga04wFHtvrkDXPS6gwCbhDA+s3J vVafA+mWPCiy8Deb9OCRJjDU3G9lVEF6bhOqGv62KkyCvGq3FJjEIdbrzRFEF+cOP+32 imHI37pflTgA6S4urjWiwM9Jw5qgoG9orN8MjexaaWbT01Ca4srqPELrxDSqpMkp+1ln EsSOxiV7WqWYjDSRrPTLqMU3UxaUXsOexxdQhbgPaC/pU7rarJexLlPkYKfv8uX1l320 dtLA== X-Gm-Message-State: AOAM533rHfLipRVxN4Q7UbgGtg4VriMXNvMSnJUYcXx4JxO89VBBGt4+ 2x5NGvOuWh2IXBb2Mm0ju4X4u67CN0wutlgE X-Google-Smtp-Source: ABdhPJzIgdVBgwea11+9niaYTPbXS28IbvBXAqZkH+AC3N7URd+tKRMq0XGO/rRFF/OOaIUl2PCecg== X-Received: by 2002:a9d:5549:: with SMTP id h9mr18936328oti.230.1607954669275; Mon, 14 Dec 2020 06:04:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 42/43] tcg: Constify tcg_code_gen_epilogue Date: Mon, 14 Dec 2020 08:03:13 -0600 Message-Id: <20201214140314.18544-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::344; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x344.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, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Now that all native tcg hosts support splitwx, make this pointer const. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- include/tcg/tcg.h | 2 +- tcg/tcg.c | 2 +- tcg/aarch64/tcg-target.c.inc | 3 +-- tcg/arm/tcg-target.c.inc | 3 +-- tcg/i386/tcg-target.c.inc | 3 +-- tcg/mips/tcg-target.c.inc | 3 +-- tcg/ppc/tcg-target.c.inc | 3 +-- tcg/riscv/tcg-target.c.inc | 3 +-- tcg/s390/tcg-target.c.inc | 3 +-- tcg/sparc/tcg-target.c.inc | 3 +-- 10 files changed, 10 insertions(+), 18 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 90ec7c1445..477919aeb6 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -677,7 +677,7 @@ struct TCGContext { =20 extern TCGContext tcg_init_ctx; extern __thread TCGContext *tcg_ctx; -extern void *tcg_code_gen_epilogue; +extern const void *tcg_code_gen_epilogue; extern uintptr_t tcg_splitwx_diff; extern TCGv_env cpu_env; =20 diff --git a/tcg/tcg.c b/tcg/tcg.c index 5f585c2ed2..d961ebcecb 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -161,7 +161,7 @@ static int tcg_out_ldst_finalize(TCGContext *s); static TCGContext **tcg_ctxs; static unsigned int n_tcg_ctxs; TCGv_env cpu_env =3D 0; -void *tcg_code_gen_epilogue; +const void *tcg_code_gen_epilogue; uintptr_t tcg_splitwx_diff; =20 #ifndef CONFIG_TCG_INTERPRETER diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 2e33162c03..0b7eb09a27 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -2900,8 +2900,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue =3D tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_X0, 0); =20 /* TB epilogue */ diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 3d2717aeb0..d6cb19ca9f 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -2301,8 +2301,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue =3D tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R0, 0); tcg_out_epilogue(s); } diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 23c7a8a383..be57d2330a 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -3826,8 +3826,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue =3D tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0); =20 /* TB epilogue */ diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index a2201bd1dd..18fd474593 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2473,8 +2473,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue =3D tcg_splitwx_to_rx(s->code_ptr); tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_V0, TCG_REG_ZERO); =20 /* TB epilogue */ diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 33b5915005..5f191c03d9 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2346,8 +2346,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out32(s, BCCTR | BO_ALWAYS); =20 /* Epilogue */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue =3D tcg_splitwx_to_rx(s->code_ptr); =20 tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_REG_R1, FRAME_SIZE+LR_OFFS= ET); for (i =3D 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); ++i) { diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 5c1e0f8fc1..7b4ee4a084 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1784,8 +1784,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, tcg_target_call_iarg_regs[1= ], 0); =20 /* Return path for goto_ptr. Set return value to 0 */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue =3D tcg_splitwx_to_rx(s->code_ptr); tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_A0, TCG_REG_ZERO); =20 /* TB epilogue */ diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index 582a8ef941..b3660ffedf 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -2551,8 +2551,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue =3D tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, 0); =20 /* TB epilogue */ diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 182124b96c..922ae96481 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -1039,8 +1039,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_nop(s); =20 /* Epilogue for goto_ptr. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue =3D tcg_splitwx_to_rx(s->code_ptr); tcg_out_arithi(s, TCG_REG_G0, TCG_REG_I7, 8, RETURN); /* delay slot */ tcg_out_movi_imm13(s, TCG_REG_O0, 0); --=20 2.25.1 From nobody Thu May 16 05:31:25 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=1607956672; cv=none; d=zohomail.com; s=zohoarc; b=VI8xaA+nJSWYXdNQ6PfRIpjCX8NqWYB+/MLAsv8aKkE4MZySGxXhFoOhqP1CTuFCmtob1pKkpmdjfYP9UlkTfjhgZY/J5vaY1EHocz+UCdqiYugjxc/bXcSZ0H1L064Ppgl75d1vnkb7dXgBD8Nu/qxcZ3HOO/G7I4qJQGLvfM4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607956672; h=Content-Transfer-Encoding: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=N6wN/s3cc8J4fe6ZTQ6/bUXQAJNTNrqoJE7CR9wrYBA=; b=ARAiD73DVZzz9gxPK796GE+aCgWEunSuxmm/G4Ar0FDzfndtAtNase03S8cqQ3B1WaCwhRVx3RCYSlMxJFfTWeE4joHkaizjmaIjwhUgABvun3KLB8fO+sBTXLXJ74Q8bw38lfHJJ1kT1IL0j5gp2jh6qd3i9Botj/yUsUVJibI= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607956672238174.3732360278176; Mon, 14 Dec 2020 06:37:52 -0800 (PST) Received: from localhost ([::1]:56496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kooyy-0000WS-Gc for importer@patchew.org; Mon, 14 Dec 2020 09:37:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSs-0002QS-Ne for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:40 -0500 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:36402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSn-00043C-ID for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:38 -0500 Received: by mail-ot1-x343.google.com with SMTP id y24so15770627otk.3 for ; Mon, 14 Dec 2020 06:04:32 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=N6wN/s3cc8J4fe6ZTQ6/bUXQAJNTNrqoJE7CR9wrYBA=; b=DxdpOyKK+fQ9MRgOQGqF0E3STQVbxynzSWtPvMTyR4uxI5lQ3zx0SO9TsurGtVTWxC 7PgqfXe4binBgLhGHYnZ5StzVaP+g5nIiG/EYlVbGVF+QtqgmyTYGuggRMtRO95wUMUP AREzof4HVihkkURKqcEAqVuUPzO83+5+yHEbcBFFpOamq9wD5vkcwhp6z9so1liHGTwh 7Q/uElTU4qanluRZUIdQ8fXgrb6KDx2NAPC9eSmCmtNkF3B2GAw/neBiM7i1j5tiUS1S gwW49JHyrFTRre1eeCdbhpJW8jA7g/ADMYvAJ/FAQFMAo89/uG7bRUP5ZwzcBKqlDXAD 6AsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N6wN/s3cc8J4fe6ZTQ6/bUXQAJNTNrqoJE7CR9wrYBA=; b=D3Z5xZnuWP+2XhCM5VcRteoNhL6ta9OFUXVUcGKWOW8tKLMOD6S8TXAPSvoNgYrx9T l17MeGy/30ARd5/1TOe0sT9ZpynOYNavmsVCqDpozKE6Xow/b4TA5voPINXEbi6Bma2Y u6LTR5adNl1PK6a8s1BlVVDpZqX5Nj8HnAVtnDG+E662up08N7ThaexmAx4RIrsGT0Ft z4mPN8rwVNjK0paWFMcVE5leEvuyPPcI09CsQC4VhHkwLuIrbCcSs4NdPUO2gPVQHOkM fFC65cWQPDlxZkg0MYzu2sJkV3iCce34gl+2hZ19bh7/Wt1t4J2hOgcvnmcBPmp3a3BF sO7Q== X-Gm-Message-State: AOAM530NsA9SVsi5mw9fYSUZ/6gtQTsCSeDftk/WCvOv40gngufGINoj xoFG8iqs7DG6AGzXVACUm+/4F7b9nrWc1sx1 X-Google-Smtp-Source: ABdhPJxTP8Wbp2bF4SEWUeGK0ONCTgQnaT7AXo+2zb98X2vjN3v+10ZUm/PKq01NotDJBP+QgXIjLA== X-Received: by 2002:a05:6830:22eb:: with SMTP id t11mr20675595otc.114.1607954670432; Mon, 14 Dec 2020 06:04:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 43/43] tcg: Constify TCGLabelQemuLdst.raddr Date: Mon, 14 Dec 2020 08:03:14 -0600 Message-Id: <20201214140314.18544-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-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::343; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x343.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.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Now that all native tcg hosts support splitwx, make this pointer const. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- tcg/aarch64/tcg-target.c.inc | 3 +-- tcg/arm/tcg-target.c.inc | 3 +-- tcg/i386/tcg-target.c.inc | 3 +-- tcg/mips/tcg-target.c.inc | 3 +-- tcg/ppc/tcg-target.c.inc | 3 +-- tcg/riscv/tcg-target.c.inc | 3 +-- tcg/s390/tcg-target.c.inc | 3 +-- tcg/tcg-ldst.c.inc | 2 +- 8 files changed, 8 insertions(+), 15 deletions(-) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 0b7eb09a27..ab199b143f 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1636,8 +1636,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool i= s_ld, TCGMemOpIdx oi, label->type =3D ext; label->datalo_reg =3D data_reg; label->addrlo_reg =3D addr_reg; - /* TODO: Cast goes away when all hosts converted */ - label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); + label->raddr =3D tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr; } =20 diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index d6cb19ca9f..0fd1126454 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1340,8 +1340,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool i= s_ld, TCGMemOpIdx oi, label->datahi_reg =3D datahi; label->addrlo_reg =3D addrlo; label->addrhi_reg =3D addrhi; - /* TODO: Cast goes away when all hosts converted */ - label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); + label->raddr =3D tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr; } =20 diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index be57d2330a..18a3af53bb 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1786,8 +1786,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool i= s_ld, bool is_64, label->datahi_reg =3D datahi; label->addrlo_reg =3D addrlo; label->addrhi_reg =3D addrhi; - /* TODO: Cast goes away when all hosts converted */ - label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); + label->raddr =3D tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr[0]; if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) { label->label_ptr[1] =3D label_ptr[1]; diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 18fd474593..add157f6c3 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1283,8 +1283,7 @@ static void add_qemu_ldst_label(TCGContext *s, int is= _ld, TCGMemOpIdx oi, label->datahi_reg =3D datahi; label->addrlo_reg =3D addrlo; label->addrhi_reg =3D addrhi; - /* TODO: Cast goes away when all hosts converted */ - label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); + label->raddr =3D tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr[0]; if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { label->label_ptr[1] =3D label_ptr[1]; diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 5f191c03d9..19a4a12f15 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2001,8 +2001,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool i= s_ld, TCGMemOpIdx oi, label->datahi_reg =3D datahi_reg; label->addrlo_reg =3D addrlo_reg; label->addrhi_reg =3D addrhi_reg; - /* TODO: Cast goes away when all hosts converted */ - label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); + label->raddr =3D tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D lptr; } =20 diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 7b4ee4a084..f48a028dac 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -996,8 +996,7 @@ static void add_qemu_ldst_label(TCGContext *s, int is_l= d, TCGMemOpIdx oi, label->datahi_reg =3D datahi; label->addrlo_reg =3D addrlo; label->addrhi_reg =3D addrhi; - /* TODO: Cast goes away when all hosts converted */ - label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); + label->raddr =3D tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr[0]; } =20 diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index b3660ffedf..d7ef079055 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -1587,8 +1587,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool i= s_ld, TCGMemOpIdx oi, label->oi =3D oi; label->datalo_reg =3D data; label->addrlo_reg =3D addr; - /* TODO: Cast goes away when all hosts converted */ - label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); + label->raddr =3D tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr; } =20 diff --git a/tcg/tcg-ldst.c.inc b/tcg/tcg-ldst.c.inc index 05f9b3ccd6..c3ce88e69d 100644 --- a/tcg/tcg-ldst.c.inc +++ b/tcg/tcg-ldst.c.inc @@ -28,7 +28,7 @@ typedef struct TCGLabelQemuLdst { TCGReg addrhi_reg; /* reg index for high word of guest virtual ad= dr */ TCGReg datalo_reg; /* reg index for low word to be loaded or stor= ed */ TCGReg datahi_reg; /* reg index for high word to be loaded or sto= red */ - tcg_insn_unit *raddr; /* gen code addr of the next IR of qemu_ld/st = IR */ + const tcg_insn_unit *raddr; /* addr of the next IR of qemu_ld/st IR = */ tcg_insn_unit *label_ptr[2]; /* label pointers to be updated */ QSIMPLEQ_ENTRY(TCGLabelQemuLdst) next; } TCGLabelQemuLdst; --=20 2.25.1