From nobody Wed Jun 26 08:00:55 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=1610050919; cv=none; d=zohomail.com; s=zohoarc; b=Iso6i5ElWjkkTMSeJb+/nibiiAmJaDLGUJ06Y6B/rcwfvyRS9lGrNVqDEUFi1GwS1Por3KOUJWD1pnozoil9G9vEj90QVKaPstFg4prHoNrxN6PdU4gbhP8Fbq4YrMk9ecOy3WFdYBpxBn8Z3LAmleBjdvIkyDWxEYJqqmsk+HE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610050919; 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=pzbu+QPuB679ppIoaOkuQ2FKi4FxaEhDCtC4QBl00dw=; b=NUfSUpYqpnucd1LD6tv5d1gAg5q/pewZLVVzgN++64ROmOosqUVpgPdbhdzvt3JGwWdFwnfmvt3ClnXBMFbuS9LFSHOM9ke/wbAPtA1i0utahKH/8zd+rgwsNRcxAefjcsWBsOjc5ovnj2/y55X3SzqApx90juIYqifhW4uLgXM= 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 161005091982267.45334295754844; Thu, 7 Jan 2021 12:21:59 -0800 (PST) Received: from localhost ([::1]:33230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbnC-0007Cr-Mi for importer@patchew.org; Thu, 07 Jan 2021 15:21:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbgP-0000Yf-IB for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:14:57 -0500 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:40975) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgO-0001MU-37 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:14:57 -0500 Received: by mail-pf1-x42f.google.com with SMTP id q20so1281563pfu.8 for ; Thu, 07 Jan 2021 12:14:55 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:14:53 -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=pzbu+QPuB679ppIoaOkuQ2FKi4FxaEhDCtC4QBl00dw=; b=udoZJtvYcBWNKXUJd+vhh7jaZKtOtltKaBtxuHUM4G/eYB7ZEVVoNEY9i+r9T/sh8s yCSso2igULau4xcYztMHmrLjwCr9AAvTHrxZpSjA5BjhiC/VFeJMilAnFIpdVS11/eHj cHn5+TfC8qiv+bH6TMOo/zDgI7pgt5pJc19bylUjBkBfnK9iBye7VowJ0UrcJybVqTLL WFWspdRZmsJoS2x5/3vdY9zdQ5xEGkuKoWycMHmGQdE7iKQlTBW6RRgBp3Ye17ghYkyB mOSFpVJ9TNjSDkhqgmJ5Sddcvh4ZQoQzEaLHk7MmB8WTqa0QabMz/ylbY31qJ8FQRwyz YXHQ== 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=pzbu+QPuB679ppIoaOkuQ2FKi4FxaEhDCtC4QBl00dw=; b=GJ3eKn8vhPN1k5BNILB3MVbAFZnNpuTE/BJWL8hEZN/CeKzUGhRf2pi51HWCBoLHdw fxNQa5DfCfM8dlVGlkUKVZBgKTidU8RvoP0NOKDmMqHGLSDXABBc1fADGyYJbdp0Pard JEs7lFkg1sX0esZbtB6JgqOAGw2hP64bToMMxk6KQC9o8y1KZ1gwTUd/fWASGzEAHANV wN+cri5+yRXcd8Hf9oUP9womn2D/MO8l0AtPZtAwKIavZ/1BJteIRaYBFjFJhf4eRzqt haRuh+KOU0iiXkSE0dHIFrjVSPOEeVFiRUHFkVM+gryDrVkbGJ+bZX7bSkMsEgggAvwu nIcg== X-Gm-Message-State: AOAM533P7sGIyrAfDL9c+PosiVqfbInCJpzmJ3Y91KG01/oSeeiexQIy CWsEeAdi1aPSr6LwGOGk4I4lJDqyfSpFeQ== X-Google-Smtp-Source: ABdhPJxaCgwyZMHH9psMK7dyaoUpnGvuE5A6lN7VvlzGKvBlLE253T8O85/FOJdRCueVYeJnJJPRXA== X-Received: by 2002:a62:384b:0:b029:19d:a5c6:d76 with SMTP id f72-20020a62384b0000b029019da5c60d76mr453568pfa.16.1610050494226; Thu, 07 Jan 2021 12:14:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 01/47] linux-user: Conditionalize TUNSETVNETLE Date: Thu, 7 Jan 2021 10:14:02 -1000 Message-Id: <20210107201448.1152301-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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: peter.maydell@linaro.org, Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) This fixes the build for older ppc64 kernel headers. Fixes: 6addf06a3c4 Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/ioctls.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 661b5daa9f..7193c3b226 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -748,8 +748,10 @@ IOCTL(TUNSETQUEUE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_short_ifreq))) IOCTL(TUNSETIFINDEX , IOC_W, MK_PTR(TYPE_INT)) /* TUNGETFILTER is not supported: see TUNATTACHFILTER. */ +#ifdef TUNSETVNETLE IOCTL(TUNSETVNETLE, IOC_W, MK_PTR(TYPE_INT)) IOCTL(TUNGETVNETLE, IOC_R, MK_PTR(TYPE_INT)) +#endif #ifdef TUNSETVNETBE IOCTL(TUNSETVNETBE, IOC_W, MK_PTR(TYPE_INT)) IOCTL(TUNGETVNETBE, IOC_R, MK_PTR(TYPE_INT)) --=20 2.25.1 From nobody Wed Jun 26 08:00:55 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=1610050681; cv=none; d=zohomail.com; s=zohoarc; b=JHzABVF6CnQqWJflIPc31u6YSN+Qeu0O91cj4CvLQ4HlB0dA44iEvWkdu54jJQrA3AMD2bQtXxzLWFIS1EaJp4m4WYz95mtepylyE8pUQFS1RvMDWuWYqANu6WtwGUyF/MH2AlJ3+DL6B1iRGGTxjDKArEUW40jkrsR3JER0AoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610050681; 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=Bf5p3FouUPwrNDxVcRENcW6lpJP3fGRWqNfTxuoxyGQ=; b=XLkl3+owsrLXCXOJ/A8fURAE+3roQMbrH8MuauK1EBJ9cF0RrPZ3npMdwyUWFR2tHQk8cR8NWt7x7dP055deHbflTRlDkuewh7KKEg7G2OfftmGBRePkyAy2tPHRNGOEPEkcAy2VUom0o/PBMHBrhrkXtcpEYw1+BQfjrSpJZAQ= 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 161005068162814.21006717201999; Thu, 7 Jan 2021 12:18:01 -0800 (PST) Received: from localhost ([::1]:50372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbjM-0002YA-AE for importer@patchew.org; Thu, 07 Jan 2021 15:18:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbgR-0000b8-H7 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:14:59 -0500 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:40209) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgP-0001NT-JS for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:14:59 -0500 Received: by mail-pg1-x52e.google.com with SMTP id 15so5733415pgx.7 for ; Thu, 07 Jan 2021 12:14:57 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:14:55 -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=Bf5p3FouUPwrNDxVcRENcW6lpJP3fGRWqNfTxuoxyGQ=; b=hq9xyY73AB0hM2poVKZRZVxIjKkCozqt1lSsV2XFtUl1Wr/EF4VybggAGIw5mYSpC8 kaWrTS9cJOIPfnQBoxyTXssJ7zXZPuopa4likuWkVHqGHd8iwqgaoh8E4NqzbUNiON+B 2OzXAP4RXcJgPnT/62jOuMztvk3hes3L5DNMD7OVeTiclU6K2xXPTTGezI0Qt7C6Vnwg fQvWBv4H5kW466gMjmhn0cNOVsQV/9eQO02gJrcRDoRLL3fQAqpN63I+ZUQmjr0RIjjB fC2GF7rMFPztHgvDUG6SKQKmG8uqAeJSSM9Q7i7NQXiAzMW77SOzNJDRPB/S3UjA+VJJ iybg== 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=Bf5p3FouUPwrNDxVcRENcW6lpJP3fGRWqNfTxuoxyGQ=; b=SagebPzK77qg0h6Wig8OAEM0dhdoB2rpXldtjx3iQAvqjlAZ282vGcC2MqmSGltYST Dq6/YmBaZwssDJ+FT8KCQ6Z4QwUkxDKeEA2uYCjP7WABdwxc6vbVX/tEYk9fYkKga+Uh fLne0MWAe01GalKTsYttNSGZIk7L5UkzPiQmr/70RQ1u5R4+vL1BIyIviWoURI2zk0Y1 OeIXSvOxsycEy5hUrXG93ZucH6Yk2idDa6np3v0b1UZ3ezWVLEZBE/vDleucrUVlrSdV hPNipn3yAOx+N5krBl8f3feKtocxmvNYRNfqAJ7VZ1A7uznoMyGcllDk0dtcC7mWIj0A 0FeQ== X-Gm-Message-State: AOAM530xSuFRGs1BTsnrxzUGED+X4eUDI9Ve+jzXQ72YAaUbP0jUqMO7 PjwdEJYqwPp9n2kGxUT0CQK0S5rxtyAiIg== X-Google-Smtp-Source: ABdhPJxZqoPjnKaqHlke6yWId70lnoAGmJHeQNK5NU2J+jrq4Ql2QzBfw9rZXckwURQ1kxB5EBuobg== X-Received: by 2002:a05:6a00:ac5:b029:19d:97c2:d3a7 with SMTP id c5-20020a056a000ac5b029019d97c2d3a7mr392438pfl.61.1610050495904; Thu, 07 Jan 2021 12:14:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 02/47] tcg/i386: Adjust TCG_TARGET_HAS_MEMORY_BSWAP Date: Thu, 7 Jan 2021 10:14:03 -1000 Message-Id: <20210107201448.1152301-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Always true when movbe is available, otherwise leave this to generic code. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 3 +- tcg/i386/tcg-target.c.inc | 119 ++++++++++++++------------------------ 2 files changed, 47 insertions(+), 75 deletions(-) diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index cd067e0b30..b1ada9777a 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -101,6 +101,7 @@ extern bool have_bmi1; extern bool have_popcnt; extern bool have_avx1; extern bool have_avx2; +extern bool have_movbe; =20 /* optional instructions */ #define TCG_TARGET_HAS_div2_i32 1 @@ -225,7 +226,7 @@ static inline void tb_target_set_jmp_target(uintptr_t t= c_ptr, =20 #define TCG_TARGET_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD) =20 -#define TCG_TARGET_HAS_MEMORY_BSWAP 1 +#define TCG_TARGET_HAS_MEMORY_BSWAP have_movbe =20 #ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index d8797ed398..01588cdcb4 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -154,13 +154,12 @@ bool have_bmi1; bool have_popcnt; bool have_avx1; bool have_avx2; +bool have_movbe; =20 #ifdef CONFIG_CPUID_H -static bool have_movbe; static bool have_bmi2; static bool have_lzcnt; #else -# define have_movbe 0 # define have_bmi2 0 # define have_lzcnt 0 #endif @@ -1986,13 +1985,14 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, T= CGReg datalo, TCGReg datahi, TCGReg base, int index, intptr_t ofs, int seg, bool is64, MemOp memop) { - const MemOp real_bswap =3D memop & MO_BSWAP; - MemOp bswap =3D real_bswap; + bool use_movbe =3D false; int rexw =3D is64 * P_REXW; int movop =3D OPC_MOVL_GvEv; =20 - if (have_movbe && real_bswap) { - bswap =3D 0; + /* Do big-endian loads with movbe. */ + if (memop & MO_BSWAP) { + tcg_debug_assert(have_movbe); + use_movbe =3D true; movop =3D OPC_MOVBE_GyMy; } =20 @@ -2006,23 +2006,28 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, T= CGReg datalo, TCGReg datahi, base, index, 0, ofs); break; case MO_UW: - tcg_out_modrm_sib_offset(s, OPC_MOVZWL + seg, datalo, - base, index, 0, ofs); - if (real_bswap) { - tcg_out_rolw_8(s, datalo); - } - break; - case MO_SW: - if (real_bswap) { - if (have_movbe) { + if (use_movbe) { + /* There is no extending movbe; only low 16-bits are modified.= */ + if (datalo !=3D base && datalo !=3D index) { + /* XOR breaks dependency chains. */ + tgen_arithr(s, ARITH_XOR, datalo, datalo); tcg_out_modrm_sib_offset(s, OPC_MOVBE_GyMy + P_DATA16 + se= g, datalo, base, index, 0, ofs); } else { - tcg_out_modrm_sib_offset(s, OPC_MOVZWL + seg, datalo, - base, index, 0, ofs); - tcg_out_rolw_8(s, datalo); + tcg_out_modrm_sib_offset(s, OPC_MOVBE_GyMy + P_DATA16 + se= g, + datalo, base, index, 0, ofs); + tcg_out_ext16u(s, datalo, datalo); } - tcg_out_modrm(s, OPC_MOVSWL + rexw, datalo, datalo); + } else { + tcg_out_modrm_sib_offset(s, OPC_MOVZWL + seg, datalo, + base, index, 0, ofs); + } + break; + case MO_SW: + if (use_movbe) { + tcg_out_modrm_sib_offset(s, OPC_MOVBE_GyMy + P_DATA16 + seg, + datalo, base, index, 0, ofs); + tcg_out_ext16s(s, datalo, datalo, rexw); } else { tcg_out_modrm_sib_offset(s, OPC_MOVSWL + rexw + seg, datalo, base, index, 0, ofs); @@ -2030,18 +2035,12 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, T= CGReg datalo, TCGReg datahi, break; case MO_UL: tcg_out_modrm_sib_offset(s, movop + seg, datalo, base, index, 0, o= fs); - if (bswap) { - tcg_out_bswap32(s, datalo); - } break; #if TCG_TARGET_REG_BITS =3D=3D 64 case MO_SL: - if (real_bswap) { - tcg_out_modrm_sib_offset(s, movop + seg, datalo, + if (use_movbe) { + tcg_out_modrm_sib_offset(s, OPC_MOVBE_GyMy + seg, datalo, base, index, 0, ofs); - if (bswap) { - tcg_out_bswap32(s, datalo); - } tcg_out_ext32s(s, datalo, datalo); } else { tcg_out_modrm_sib_offset(s, OPC_MOVSLQ + seg, datalo, @@ -2053,12 +2052,9 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TC= GReg datalo, TCGReg datahi, if (TCG_TARGET_REG_BITS =3D=3D 64) { tcg_out_modrm_sib_offset(s, movop + P_REXW + seg, datalo, base, index, 0, ofs); - if (bswap) { - tcg_out_bswap64(s, datalo); - } } else { - if (real_bswap) { - int t =3D datalo; + if (use_movbe) { + TCGReg t =3D datalo; datalo =3D datahi; datahi =3D t; } @@ -2073,14 +2069,10 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, T= CGReg datalo, TCGReg datahi, tcg_out_modrm_sib_offset(s, movop + seg, datalo, base, index, 0, ofs); } - if (bswap) { - tcg_out_bswap32(s, datalo); - tcg_out_bswap32(s, datahi); - } } break; default: - tcg_abort(); + g_assert_not_reached(); } } =20 @@ -2128,24 +2120,27 @@ static void tcg_out_qemu_st_direct(TCGContext *s, T= CGReg datalo, TCGReg datahi, TCGReg base, int index, intptr_t ofs, int seg, MemOp memop) { - /* ??? Ideally we wouldn't need a scratch register. For user-only, - we could perform the bswap twice to restore the original value - instead of moving to the scratch. But as it is, the L constraint - means that TCG_REG_L0 is definitely free here. */ const TCGReg scratch =3D TCG_REG_L0; - const MemOp real_bswap =3D memop & MO_BSWAP; - MemOp bswap =3D real_bswap; + bool use_movbe =3D false; int movop =3D OPC_MOVL_EvGv; =20 - if (have_movbe && real_bswap) { - bswap =3D 0; + /* + * Do big-endian stores with movbe or softmmu. + * User-only without movbe will have its swapping done generically. + */ + if (memop & MO_BSWAP) { + tcg_debug_assert(have_movbe); + use_movbe =3D true; movop =3D OPC_MOVBE_MyGy; } =20 switch (memop & MO_SIZE) { case MO_8: - /* In 32-bit mode, 8-bit stores can only happen from [abcd]x. - Use the scratch register if necessary. */ + /* + * In 32-bit mode, 8-bit stores can only happen from [abcd]x. + * TODO: Adjust constraints such that this is is forced, + * then we won't need a scratch at all for user-only. + */ if (TCG_TARGET_REG_BITS =3D=3D 32 && datalo >=3D 4) { tcg_out_mov(s, TCG_TYPE_I32, scratch, datalo); datalo =3D scratch; @@ -2154,43 +2149,19 @@ static void tcg_out_qemu_st_direct(TCGContext *s, T= CGReg datalo, TCGReg datahi, datalo, base, index, 0, ofs); break; case MO_16: - if (bswap) { - tcg_out_mov(s, TCG_TYPE_I32, scratch, datalo); - tcg_out_rolw_8(s, scratch); - datalo =3D scratch; - } tcg_out_modrm_sib_offset(s, movop + P_DATA16 + seg, datalo, base, index, 0, ofs); break; case MO_32: - if (bswap) { - tcg_out_mov(s, TCG_TYPE_I32, scratch, datalo); - tcg_out_bswap32(s, scratch); - datalo =3D scratch; - } tcg_out_modrm_sib_offset(s, movop + seg, datalo, base, index, 0, o= fs); break; case MO_64: if (TCG_TARGET_REG_BITS =3D=3D 64) { - if (bswap) { - tcg_out_mov(s, TCG_TYPE_I64, scratch, datalo); - tcg_out_bswap64(s, scratch); - datalo =3D scratch; - } tcg_out_modrm_sib_offset(s, movop + P_REXW + seg, datalo, base, index, 0, ofs); - } else if (bswap) { - tcg_out_mov(s, TCG_TYPE_I32, scratch, datahi); - tcg_out_bswap32(s, scratch); - tcg_out_modrm_sib_offset(s, OPC_MOVL_EvGv + seg, scratch, - base, index, 0, ofs); - tcg_out_mov(s, TCG_TYPE_I32, scratch, datalo); - tcg_out_bswap32(s, scratch); - tcg_out_modrm_sib_offset(s, OPC_MOVL_EvGv + seg, scratch, - base, index, 0, ofs + 4); } else { - if (real_bswap) { - int t =3D datalo; + if (use_movbe) { + TCGReg t =3D datalo; datalo =3D datahi; datahi =3D t; } @@ -2201,7 +2172,7 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCG= Reg datalo, TCGReg datahi, } break; default: - tcg_abort(); + g_assert_not_reached(); } } =20 --=20 2.25.1 From nobody Wed Jun 26 08:00:55 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=1610050684; cv=none; d=zohomail.com; s=zohoarc; b=O40BA3bsYXI/WLuljZonPUBKBso2+J5owW6phIV/5DecOB4faTXgBCl9Yxntwh6LL3bDKFpg3ruk+RLWPvclluvqDIFcDYzct4lievhGWi+uAI+NSy0eRiq7ESrYkP2BokXoHvjpyBiSxKN17gmPLszWYDUMcizTUP0vU0xWg5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610050684; 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=7cOc/EO426UcFq+Ds2TZQxNrDdGfPnqOjFWRfHCKoV4=; b=buQBwBgfZOq9IyObPe6TthqSpYj4exCPWy0dlJ9BxTbMs1M+2z3tK3HRcg09sjGUNnaWmSEO9smjCSWg/LzzznUF7TV/NpahNVm5zisNQ+pecPmo/7JVDi51uAXEtZEyT4TjTcoo2hyDXq0aibAlg6AkbOUJhCSIorzJ+0l7GTk= 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 16100506843691010.4164324083179; Thu, 7 Jan 2021 12:18:04 -0800 (PST) Received: from localhost ([::1]:50638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbjP-0002eT-3D for importer@patchew.org; Thu, 07 Jan 2021 15:18:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbgT-0000e4-LK for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:01 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:33844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgR-0001OR-G3 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:01 -0500 Received: by mail-pj1-x102b.google.com with SMTP id n3so4519308pjm.1 for ; Thu, 07 Jan 2021 12:14:59 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.14.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:14:57 -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=7cOc/EO426UcFq+Ds2TZQxNrDdGfPnqOjFWRfHCKoV4=; b=u/Ao3UOqU1FVOC33ZsbV7ldA4r761erIKxVFUH1/eSM20KWZrDE5ReX3L8wJxBz+iU s1o5tO57KqGonFQ6/SWsNsEcqbIm5hMRIw/ajXo0uVRqsK8CGl/pBJpbISC0A3PnPka1 BsRsh6dQr6LEB94+7YwdXI1Ej3NNCcZfbvtqpaKe0fkjfyXKVZq0hW/53lEFqkwezBdM 8Rxt5YBnqi7spYb5Zz4WFOcG9lqMKBq2ZaD5OdBLL6YVlLXnWDQqhhFhBniuBYs/gY23 7lRU2mIUc2VpwCJwLmlMKApOeXwL6rbBg9lC29C8Hq52P0n7vH3p7zbH8NjTUNo/hPTF T6JQ== 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=7cOc/EO426UcFq+Ds2TZQxNrDdGfPnqOjFWRfHCKoV4=; b=g7ScK1L+nUSmR5MX7z8kVV/JymQ4oZeRmQBbdAr14qFdDaqmBCRY6BBx/Assgf7HxX yWRmfbuGD9hKoY85ywLvde5UIz7fKcueUBbHRBeL8nCxnO9Z84hUhurcy7PooPk90ed3 BedefzE90NYARYExNOi44Xi8iEe9/M/MvAlto3HZh+jrS5tTVeK+ONEFN7nr1cSfqOAo ol8gRPnCxtmss2oQh6a6iEjX/DDTIScOny4+D1fLkoArrCBNBytd4+QLn16FZZ6re2Cs 3ZA6+egTogybyRaYxZfbaCKxEtC81ZdAB2joRO3Cgp++WEPIDTQrw+hQEbzCR/zt/fsJ RN8g== X-Gm-Message-State: AOAM533o6Opwzjvb/73eU4sxpHvhqf6rY8sdlAlBpD7SyTizzHCBnsQL y8C7VKJ25/bNhaKUuMF+pU/yvOPEVkU9bw== X-Google-Smtp-Source: ABdhPJzkhXGX4iwvOnL6VceIZioJOiA7Fm3FEyPU7mNAXD4T1lM+hyvN1yH1jC9QhGH8KfZmFYpqDA== X-Received: by 2002:a17:90a:bf05:: with SMTP id c5mr163357pjs.95.1610050497641; Thu, 07 Jan 2021 12:14:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 03/47] tcg: Introduce INDEX_op_qemu_st8_i32 Date: Thu, 7 Jan 2021 10:14:04 -1000 Message-Id: <20210107201448.1152301-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Enable this on i386 to restrict the set of input registers for an 8-bit store, as required by the architecture. This removes the last use of scratch registers for user-only mode. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/tcg/tcg-opc.h | 5 +++++ tcg/aarch64/tcg-target.h | 1 + tcg/arm/tcg-target.h | 1 + tcg/i386/tcg-target.h | 3 +++ 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 + tcg/optimize.c | 1 + tcg/tcg-op.c | 6 +++++- tcg/tcg.c | 4 ++++ tcg/i386/tcg-target.c.inc | 29 ++++++++++++++++++----------- tcg/README | 5 +++++ 15 files changed, 49 insertions(+), 12 deletions(-) diff --git a/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index 67092e82c6..70a76646c4 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -211,6 +211,11 @@ DEF(qemu_ld_i64, DATA64_ARGS, TLADDR_ARGS, 1, DEF(qemu_st_i64, 0, TLADDR_ARGS + DATA64_ARGS, 1, TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS | TCG_OPF_64BIT) =20 +/* Only used by i386 to cope with stupid register constraints. */ +DEF(qemu_st8_i32, 0, TLADDR_ARGS + 1, 1, + TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS | + IMPL(TCG_TARGET_HAS_qemu_st8_i32)) + /* Host vector support. */ =20 #define IMPLVEC TCG_OPF_VECTOR | IMPL(TCG_TARGET_MAYBE_vec) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 8a6b97598e..108a1fa969 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -88,6 +88,7 @@ typedef enum { #define TCG_TARGET_HAS_extrl_i64_i32 0 #define TCG_TARGET_HAS_extrh_i64_i32 0 #define TCG_TARGET_HAS_goto_ptr 1 +#define TCG_TARGET_HAS_qemu_st8_i32 0 =20 #define TCG_TARGET_HAS_div_i64 1 #define TCG_TARGET_HAS_rem_i64 1 diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index f1955ce4ac..1e18fefd0e 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -126,6 +126,7 @@ extern bool use_idiv_instructions; #define TCG_TARGET_HAS_rem_i32 0 #define TCG_TARGET_HAS_goto_ptr 1 #define TCG_TARGET_HAS_direct_jump 0 +#define TCG_TARGET_HAS_qemu_st8_i32 0 =20 enum { TCG_AREG0 =3D TCG_REG_R6, diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index b1ada9777a..f3836a4d0c 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -172,6 +172,9 @@ extern bool have_movbe; #define TCG_TARGET_HAS_muls2_i64 1 #define TCG_TARGET_HAS_muluh_i64 0 #define TCG_TARGET_HAS_mulsh_i64 0 +#define TCG_TARGET_HAS_qemu_st8_i32 0 +#else +#define TCG_TARGET_HAS_qemu_st8_i32 1 #endif =20 /* We do not support older SSE systems, only beginning with AVX1. */ diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 92c1d63da3..624248b81e 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -169,6 +169,7 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_HAS_clz_i32 use_mips32r2_instructions #define TCG_TARGET_HAS_ctz_i32 0 #define TCG_TARGET_HAS_ctpop_i32 0 +#define TCG_TARGET_HAS_qemu_st8_i32 0 =20 #if TCG_TARGET_REG_BITS =3D=3D 64 #define TCG_TARGET_HAS_movcond_i64 use_movnz_instructions diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index a509a19628..301173c97e 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -108,6 +108,7 @@ extern bool have_vsx; #define TCG_TARGET_HAS_mulsh_i32 1 #define TCG_TARGET_HAS_goto_ptr 1 #define TCG_TARGET_HAS_direct_jump 1 +#define TCG_TARGET_HAS_qemu_st8_i32 0 =20 #if TCG_TARGET_REG_BITS =3D=3D 64 #define TCG_TARGET_HAS_add2_i32 0 diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index c1bd52bb9a..888288d54c 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -119,6 +119,7 @@ typedef enum { #define TCG_TARGET_HAS_direct_jump 0 #define TCG_TARGET_HAS_brcond2 1 #define TCG_TARGET_HAS_setcond2 1 +#define TCG_TARGET_HAS_qemu_st8_i32 0 =20 #if TCG_TARGET_REG_BITS =3D=3D 64 #define TCG_TARGET_HAS_movcond_i64 0 diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index b4feb2f55a..69576f4a9a 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -97,6 +97,7 @@ extern uint64_t s390_facilities; #define TCG_TARGET_HAS_extrh_i64_i32 0 #define TCG_TARGET_HAS_goto_ptr 1 #define TCG_TARGET_HAS_direct_jump (s390_facilities & FACILITY_GEN_INST= _EXT) +#define TCG_TARGET_HAS_qemu_st8_i32 0 =20 #define TCG_TARGET_HAS_div2_i64 1 #define TCG_TARGET_HAS_rot_i64 1 diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index d8b0e32e2e..9dce305253 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -126,6 +126,7 @@ extern bool use_vis3_instructions; #define TCG_TARGET_HAS_mulsh_i32 0 #define TCG_TARGET_HAS_goto_ptr 1 #define TCG_TARGET_HAS_direct_jump 1 +#define TCG_TARGET_HAS_qemu_st8_i32 0 =20 #define TCG_TARGET_HAS_extrl_i64_i32 1 #define TCG_TARGET_HAS_extrh_i64_i32 1 diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index b84480f989..e8277caee2 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -88,6 +88,7 @@ #define TCG_TARGET_HAS_mulsh_i32 0 #define TCG_TARGET_HAS_goto_ptr 0 #define TCG_TARGET_HAS_direct_jump 1 +#define TCG_TARGET_HAS_qemu_st8_i32 0 =20 #if TCG_TARGET_REG_BITS =3D=3D 64 #define TCG_TARGET_HAS_extrl_i64_i32 0 diff --git a/tcg/optimize.c b/tcg/optimize.c index 7ca71de956..1fb42eb2a9 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1541,6 +1541,7 @@ void tcg_optimize(TCGContext *s) case INDEX_op_qemu_ld_i32: case INDEX_op_qemu_ld_i64: case INDEX_op_qemu_st_i32: + case INDEX_op_qemu_st8_i32: case INDEX_op_qemu_st_i64: case INDEX_op_call: /* Opcodes that touch guest memory stop the optimization. = */ diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 4b8a473fad..af7ce91ffa 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2883,7 +2883,11 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TC= GArg idx, MemOp memop) } =20 addr =3D plugin_prep_mem_callbacks(addr); - gen_ldst_i32(INDEX_op_qemu_st_i32, val, addr, memop, idx); + if (TCG_TARGET_HAS_qemu_st8_i32 && (memop & MO_SIZE) =3D=3D MO_8) { + gen_ldst_i32(INDEX_op_qemu_st8_i32, val, addr, memop, idx); + } else { + gen_ldst_i32(INDEX_op_qemu_st_i32, val, addr, memop, idx); + } plugin_gen_mem_callbacks(addr, info); =20 if (swap) { diff --git a/tcg/tcg.c b/tcg/tcg.c index ebb9466ffc..95aacc8597 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1427,6 +1427,9 @@ bool tcg_op_supported(TCGOpcode op) case INDEX_op_qemu_st_i64: return true; =20 + case INDEX_op_qemu_st8_i32: + return TCG_TARGET_HAS_qemu_st8_i32; + case INDEX_op_goto_ptr: return TCG_TARGET_HAS_goto_ptr; =20 @@ -2087,6 +2090,7 @@ static void tcg_dump_ops(TCGContext *s, bool have_pre= fs) break; case INDEX_op_qemu_ld_i32: case INDEX_op_qemu_st_i32: + case INDEX_op_qemu_st8_i32: case INDEX_op_qemu_ld_i64: case INDEX_op_qemu_st_i64: { diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 01588cdcb4..f8e9a24e3b 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -245,11 +245,21 @@ static const char *target_parse_constraint(TCGArgCons= traint *ct, ct->regs |=3D ALL_VECTOR_REGS; break; =20 - /* qemu_ld/st address constraint */ case 'L': + /* qemu_ld/st data+address constraint */ ct->regs =3D TCG_TARGET_REG_BITS =3D=3D 64 ? 0xffff : 0xff; +#ifdef CONFIG_SOFTMMU tcg_regset_reset_reg(ct->regs, TCG_REG_L0); tcg_regset_reset_reg(ct->regs, TCG_REG_L1); +#endif + break; + case 's': + /* qemu_st8_i32 data constraint */ + ct->regs =3D 0xf; +#ifdef CONFIG_SOFTMMU + tcg_regset_reset_reg(ct->regs, TCG_REG_L0); + tcg_regset_reset_reg(ct->regs, TCG_REG_L1); +#endif break; =20 case 'e': @@ -2120,7 +2130,6 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCG= Reg datalo, TCGReg datahi, TCGReg base, int index, intptr_t ofs, int seg, MemOp memop) { - const TCGReg scratch =3D TCG_REG_L0; bool use_movbe =3D false; int movop =3D OPC_MOVL_EvGv; =20 @@ -2136,15 +2145,8 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TC= GReg datalo, TCGReg datahi, =20 switch (memop & MO_SIZE) { case MO_8: - /* - * In 32-bit mode, 8-bit stores can only happen from [abcd]x. - * TODO: Adjust constraints such that this is is forced, - * then we won't need a scratch at all for user-only. - */ - if (TCG_TARGET_REG_BITS =3D=3D 32 && datalo >=3D 4) { - tcg_out_mov(s, TCG_TYPE_I32, scratch, datalo); - datalo =3D scratch; - } + /* This is handled with constraints on INDEX_op_qemu_st8_i32. */ + tcg_debug_assert(TCG_TARGET_REG_BITS =3D=3D 64 || datalo < 4); tcg_out_modrm_sib_offset(s, OPC_MOVB_EvGv + P_REXB_R + seg, datalo, base, index, 0, ofs); break; @@ -2491,6 +2493,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcod= e opc, tcg_out_qemu_ld(s, args, 1); break; case INDEX_op_qemu_st_i32: + case INDEX_op_qemu_st8_i32: tcg_out_qemu_st(s, args, 0); break; case INDEX_op_qemu_st_i64: @@ -2949,9 +2952,11 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOp= code op) static const TCGTargetOpDef r_0_ci =3D { .args_ct_str =3D { "r", "0", = "ci" } }; static const TCGTargetOpDef r_L =3D { .args_ct_str =3D { "r", "L" } }; static const TCGTargetOpDef L_L =3D { .args_ct_str =3D { "L", "L" } }; + static const TCGTargetOpDef s_L =3D { .args_ct_str =3D { "s", "L" } }; static const TCGTargetOpDef r_L_L =3D { .args_ct_str =3D { "r", "L", "= L" } }; static const TCGTargetOpDef r_r_L =3D { .args_ct_str =3D { "r", "r", "= L" } }; static const TCGTargetOpDef L_L_L =3D { .args_ct_str =3D { "L", "L", "= L" } }; + static const TCGTargetOpDef s_L_L =3D { .args_ct_str =3D { "s", "L", "= L" } }; static const TCGTargetOpDef r_r_L_L =3D { .args_ct_str =3D { "r", "r", "L", "L" } }; static const TCGTargetOpDef L_L_L_L @@ -3145,6 +3150,8 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpc= ode op) return TARGET_LONG_BITS <=3D TCG_TARGET_REG_BITS ? &r_L : &r_L_L; case INDEX_op_qemu_st_i32: return TARGET_LONG_BITS <=3D TCG_TARGET_REG_BITS ? &L_L : &L_L_L; + case INDEX_op_qemu_st8_i32: + return TARGET_LONG_BITS <=3D TCG_TARGET_REG_BITS ? &s_L : &s_L_L; case INDEX_op_qemu_ld_i64: return (TCG_TARGET_REG_BITS =3D=3D 64 ? &r_L : TARGET_LONG_BITS <=3D TCG_TARGET_REG_BITS ? &r_r_L diff --git a/tcg/README b/tcg/README index 2f051e5c97..0cf9e2727c 100644 --- a/tcg/README +++ b/tcg/README @@ -502,6 +502,7 @@ goto_ptr opcode, emitting this op is equivalent to emit= ting exit_tb(0). =20 * qemu_ld_i32/i64 t0, t1, flags, memidx * qemu_st_i32/i64 t0, t1, flags, memidx +* qemu_st8_i32 t0, t1, flags, memidx =20 Load data at the guest address t1 into t0, or store data in t0 at guest address t1. The _i32/_i64 size applies to the size of the input/output @@ -518,6 +519,10 @@ of the memory access. For a 32-bit host, qemu_ld/st_i64 is guaranteed to only be used with a 64-bit memory access specified in flags. =20 +For i386, qemu_st8_i32 is exactly like qemu_st_i32, except the size of +the memory operation is known to be 8-bit. This allows the backend to +provide a different set of register constraints. + ********* Host vector operations =20 All of the vector ops have two parameters, TCGOP_VECL & TCGOP_VECE. --=20 2.25.1 From nobody Wed Jun 26 08:00:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1610051068; cv=none; d=zohomail.com; s=zohoarc; b=GifM6cGkBpe+xRq+i0mCkGlsPiwN+MLdXGKq5GYLxmMyrslL8v8qUGEr+uswn0cighf5D0+mZeFNB4k8rnp3ENmJpy2EZGP8tlybPSWbFpy31VxXql8pGH8MWzSMhnbGCGUCpTbsLspQZj2XTGx7sXGt3SuzSKRKqAPh7Ml1Vyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051068; 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=Gg9A/5gaDVuEyHmllR9pFxKENnKvr5cIesU49SidzlU=; b=kDniyX4+pFqbMIz2Dl10qNei4vKXvGbIYUdDQ7vv93IGaWoypjruWiv/hTrsPI9FAdwn7f4Cc5G3kEvqGEHHVjum+PHO26fMFZfR93JXwryLqJE+S3mywc+sUoDknXdRGJ3ZaxMLyNbBHuTWPx3BaatqAdvpMsJOQbzysAqcAhQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 161005106860361.33066019035891; Thu, 7 Jan 2021 12:24:28 -0800 (PST) Received: from localhost ([::1]:41706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbpb-0002La-HR for importer@patchew.org; Thu, 07 Jan 2021 15:24:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbgU-0000g0-UT for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:02 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:37746) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgT-0001Od-6Z for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:02 -0500 Received: by mail-pj1-x1029.google.com with SMTP id b5so4476505pjk.2 for ; Thu, 07 Jan 2021 12:15:00 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:14:59 -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=Gg9A/5gaDVuEyHmllR9pFxKENnKvr5cIesU49SidzlU=; b=Lq/HYIf4bCUFFNsQkQ4KVw9BXj/yaBtX0AiHl5q+MY1iqWMZ7bukq4RVWPqX4K+Al6 5246Jju6ROSPErq0Qr9cBWIWlFOGp7+8m8uaVqGyZZmh4jwLJsYvAm3lAs7qmYVsvcAL F7wovWAHjFGPj4LQP5BT/N/y78HQBBlWDLVd0EEs36x9Es3nUnAK61EL7v2+XZiXuvdq 53KaZcw31YZws6PHcnZtD/ygXLi+nv6vlCciYL8aUsvCrivuGJfdhl9Y8/pbEB2VWtdD kZwJTrH28QJp33kvCDeUhH5NX7FFWYA8DY/IGqTg1RovH9/6EXcsVBS/f6/KiMHwGoBM VE0Q== 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=Gg9A/5gaDVuEyHmllR9pFxKENnKvr5cIesU49SidzlU=; b=hw1jnMrFQcwnlr1VgcZzDz/NOOK4qczkvAbRIUkyuHiZIZk5it06N/OiAN/+p6tnPu tufsQr0emmeXUXF6AcRApQvT+gPpAhLGoPWQiICIoV7shssNtg8UzIPV7n0xwK3wbScZ xpqr9+SRWiHeH3dRSa/EDobA5nHeTKGOH0OK5ylQXZkg/MzbH47QNIRH0Vp8ho0tIEQm ouJGC7YgN1/YSIlA3ICSJg7m3C6x+ZTY9py397gxnfxyhkAbE2RWHJac1FYArmUCoDit 3taUiYQV0C3CCyDwzrUV/6TO7bqyijbgLtmSIMG3+ii0Wqnp39o7HSpRYlFOkPNf/R0I FR2g== X-Gm-Message-State: AOAM533Pz8tIE7Z3JaWUEwmalumlYgPcvS1Uv/ZxdgcclOGDh3UaqUpC LRzE61jTSWOHkLbMZ05IK629gCaJMXrrig== X-Google-Smtp-Source: ABdhPJx60EqaK8KnBJjO/TxpR/zeXW+cN0oelnSfmGmTcS6S8tABXWxmOofxHfHSRQxnuELvw5cXpw== X-Received: by 2002:a17:90a:6a48:: with SMTP id d8mr186484pjm.130.1610050499682; Thu, 07 Jan 2021 12:14:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 04/47] util/oslib-win32: Use _aligned_malloc for qemu_try_memalign Date: Thu, 7 Jan 2021 10:14:05 -1000 Message-Id: <20210107201448.1152301-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Weil Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We do not need or want to be allocating page sized quanta. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Weil Message-Id: <20201018164836.1149452-1-richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- util/oslib-win32.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 01787df74c..8adc651259 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -39,6 +39,7 @@ #include "trace.h" #include "qemu/sockets.h" #include "qemu/cutils.h" +#include =20 /* this must come after including "trace.h" */ #include @@ -56,10 +57,8 @@ void *qemu_try_memalign(size_t alignment, size_t size) { void *ptr; =20 - if (!size) { - abort(); - } - ptr =3D VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); + g_assert(size !=3D 0); + ptr =3D _aligned_malloc(alignment, size); trace_qemu_memalign(alignment, size, ptr); return ptr; } @@ -93,9 +92,7 @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *align, b= ool shared) void qemu_vfree(void *ptr) { trace_qemu_vfree(ptr); - if (ptr) { - VirtualFree(ptr, 0, MEM_RELEASE); - } + _aligned_free(ptr); } =20 void qemu_anon_ram_free(void *ptr, size_t size) --=20 2.25.1 From nobody Wed Jun 26 08:00:55 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=1610050848; cv=none; d=zohomail.com; s=zohoarc; b=K1SG3nWPpxkJVzyosdeYvQZ4kNgCqFybMYLKciO93F0UnUR0/fZWAnud7br8aZ0Fip9lMz4fLEhN0XvNBv5hgimFsKLhRCO2dx+SRO6vywzivnv6HOCdK7vCJAXxwHEbWcv45q0QeiHHJWeS66gKGv+EzCUnvQJrBr4UuxW8gJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610050848; 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=xH5M81fqmCpdca/RUuW2bG6ZjrHw1rwqh2ryuVvV5yk=; b=m3foE0z8KTX8qM3i2cX1SRciyd8AgHBrwQFVQBi4cY4X8eDQKodfU+Wfs1TffShguHiC7oO1pRl3YqyNHlKgSp1qM27yK+9GwoiCkHAoYGEKZmNIVQhb1K9UWQRx3YdUXkO2yyQqpzJ1SNHMUp1PRxKkrRkMlsvAokNpZT+LMnQ= 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 161005084803088.07907849072353; Thu, 7 Jan 2021 12:20:48 -0800 (PST) Received: from localhost ([::1]:58982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbm2-00068V-Kb for importer@patchew.org; Thu, 07 Jan 2021 15:20:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbgW-0000jF-H5 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:04 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:40910) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgU-0001Qi-UO for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:04 -0500 Received: by mail-pj1-x1031.google.com with SMTP id m5so4467984pjv.5 for ; Thu, 07 Jan 2021 12:15:02 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.14.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:00 -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=xH5M81fqmCpdca/RUuW2bG6ZjrHw1rwqh2ryuVvV5yk=; b=nxaC4v5mmXyq6tRE8d5NwGy98JWw2mJ5gXYnsl6aw8PfFfJ9sTnDCkagqayhlrahWd tr9E5PC0HezJzGSlLNci45zpIDS85kkJqJ9pydYa+5Vj/HCn718NiP5Y8JLWlUqbZP2P i619tocgrpbqb3HcaUN3r+AoUwFHGM9Q0ae1JWFjiw3hzFs9xZ1SUcYFVOS1//ubc5Wq /6nSrTGSIrwAgKPOUQ66E6ess//xuZaRWL7BgxyfvUxXYCv1poNjW6AxECtH9vcgNsEh MI3NxEYzBrPOhZguE38J+IakWaxK1Hg+7SNrWqArvgkONABgW9QRR/nMP6fIF06qVrsE unJg== 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=xH5M81fqmCpdca/RUuW2bG6ZjrHw1rwqh2ryuVvV5yk=; b=a0KqTUkDqMkFZYoSsiD74jvz2I4ywVnXEUS2q3DXArCjP0XsfpaBVeKWf6NTfhJwHK Q3ffHw/YaRxXbiLGV+GB86CkHVJcVV0uTvi+9Q3qjhOUTWNGFXaG4bGItq0Mkbbw9Mz0 Ba0mFzzeX6SE+cvIaS7Wep1NUXSM5F++l1vhBp+EWrBFArIgeDMz2OC+eEhK3YmhD+za N6T8nGyZ/JfHYTW5YNIPm5EkDLYSbMmdlo/ka8XupKHkKgBgsXdvpMRHWqX92DOBwJ/f PPfy98blMAas6ihRkqS5daEmND8Ub7tEVw5wbV6wUe52DqbjK9/g1pmZ7GJVTOJ159Lr Pypg== X-Gm-Message-State: AOAM533m74tNyI7v2nChxzyFDv7a0hUgryZ9Ok3bmpeZ8RsMY4uqk+T2 aw9eGSf0duezD3qHOwIfN7z9tdqUctbiWw== X-Google-Smtp-Source: ABdhPJzckuSVnICGxXx+fZfW96mY5g9WXqy3eYmNX+JXoGJjUQRNV7s9bMBXKaOqhexfiDHiXwH1xw== X-Received: by 2002:a17:90a:b296:: with SMTP id c22mr195827pjr.142.1610050501369; Thu, 07 Jan 2021 12:15:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 05/47] util/oslib: Assert qemu_try_memalign() alignment is a power of 2 Date: Thu, 7 Jan 2021 10:14:06 -1000 Message-Id: <20210107201448.1152301-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 qemu_try_memalign() expects a power of 2 alignment: - posix_memalign(3): The address of the allocated memory will be a multiple of alignment, which must be a power of two and a multiple of sizeof(void *). - _aligned_malloc() The alignment value, which must be an integer power of 2. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20201021173803.2619054-3-philmd@redhat.com> Signed-off-by: Richard Henderson --- util/oslib-posix.c | 2 ++ util/oslib-win32.c | 1 + 2 files changed, 3 insertions(+) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index f1e2801b11..359c52df12 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -201,6 +201,8 @@ void *qemu_try_memalign(size_t alignment, size_t size) =20 if (alignment < sizeof(void*)) { alignment =3D sizeof(void*); + } else { + g_assert(is_power_of_2(alignment)); } =20 #if defined(CONFIG_POSIX_MEMALIGN) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 8adc651259..e6f83e10ed 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -58,6 +58,7 @@ void *qemu_try_memalign(size_t alignment, size_t size) void *ptr; =20 g_assert(size !=3D 0); + g_assert(is_power_of_2(alignment)); ptr =3D _aligned_malloc(alignment, size); trace_qemu_memalign(alignment, size, ptr); return ptr; --=20 2.25.1 From nobody Wed Jun 26 08:00:55 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=1610050860; cv=none; d=zohomail.com; s=zohoarc; b=bUzNQqsB5RHysogok9+6MDV9YbblJioknQ15pY+AUoZunFO6pJ6uCsOxwIH7ecglvbVddaL7xp8VMcJbGHFEBd4R5sK1XQtkh36d91DUXB4C50R8yJV5cWftRCu2YzaMGT0xC/OWz0vRflvy1oW3ikmbmTAdMrjWP46SOwe+244= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610050860; 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=gV4erddw36/IIPMNTq7/TG+v9uQaJ4h6PGeY7YFnJXE=; b=JMQKuLM9Q6LOiG14x1a74aHGV7mqCZnLbAiRgfIoohiOxcreH24Zzkdz1kY6t1jm4y93tfwhcY1S68guaJ2ytdEwb48VMOCE8AEUPZhkE1wK34ByCA+zwI/t63gdwjk7oqP6TGLl8XEw/1PMT1MW5QGR6HRY6Al6WK5rYfzt7Lw= 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 1610050860677670.1239361015308; Thu, 7 Jan 2021 12:21:00 -0800 (PST) Received: from localhost ([::1]:59342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbmF-0006H1-Db for importer@patchew.org; Thu, 07 Jan 2021 15:20:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbgY-0000nv-O2 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:06 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:44492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgX-0001Qv-3u for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:06 -0500 Received: by mail-pl1-x62a.google.com with SMTP id r4so4138876pls.11 for ; Thu, 07 Jan 2021 12:15:04 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:02 -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=gV4erddw36/IIPMNTq7/TG+v9uQaJ4h6PGeY7YFnJXE=; b=MGdg3hW9mpqrANmVNloy8K1Y7iwoqp0r2s1vS9+Vri0F3szG0BMbplepxxRQJ5QcmZ lM6sBiblhbM2+Jn5ChYMW/G6OcyIxoUOB9JVuLcKDd9kyptWJhsjHnRSaTJhAlZ4Sm22 hUWjIyv6Qnno4Gu2YIyS6XfB/655ZMMd2O2bkVhSjKAI4Vvreik/FRi7DLfyQV3peAQ/ dDrF5kG7n02oNiC+uEhGV7cODwLuYXkrsBVCiYhq+kg4IABfDjN1xDONweIatlIybK/x ooJy3vq8waBEzEK7OwLZSH+tcbgMlaWVsKXnP3GIA/OuSHhbVjjPOsh3TYyImhFIgDPb lxGA== 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=gV4erddw36/IIPMNTq7/TG+v9uQaJ4h6PGeY7YFnJXE=; b=Mdr4sz4wQ5KnjKCQZxv2fxRTXMMp49Adfix5ofRC2XTqjxx2pYdK8zypR86r1GJz1A 1fJ1gaSI0YbRhuURlXc9/EjjCxnJ/3VVkEF89p5laCp9eNyVDz+a7XvTJFmlquPYniZS wDfgm6X4XhZ736kgHnU2BYCd1OhWZiNw5Y8/9xlsDrx18QAihoq5NBaaO+9Nqd9p4/Y+ YdTKBYUbg0AuaRmkNtu1zru8qrUEFP9zv4NPYCoktKeratGZJSOrlGTl7QdDlMn3jVqb y7Q/UOWscoSHp7MY5V9GBo91lXAJUhxmpiHx7+JatadKB5d/ZLQuTO3X7sskro4u0kBB UTTQ== X-Gm-Message-State: AOAM531JIuhvgPN64v1LeS9ZRtI474xDgkOAs+Cn89BGspXjkauxxDEw tvm+8oKzQNmUJzrOfVERgO5kUxn+lB1BjA== X-Google-Smtp-Source: ABdhPJxDzOInBRVXBtQAiBXXHHt9Ls7m+d6W+HiybxW2Vt4v6d9n+ejjV483PV5uE+Qdt9Vq/KjfVQ== X-Received: by 2002:a17:90b:46ca:: with SMTP id jx10mr183218pjb.208.1610050503123; Thu, 07 Jan 2021 12:15:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 06/47] tcg: Do not flush icache for interpreter Date: Thu, 7 Jan 2021 10:14:07 -1000 Message-Id: <20210107201448.1152301-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: peter.maydell@linaro.org, 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" This is currently a no-op within tci/tcg-target.h, but is about to be moved to a more generic location. Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- tcg/tcg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tcg/tcg.c b/tcg/tcg.c index 95aacc8597..9bdc450196 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1078,7 +1078,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); @@ -4324,8 +4326,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 Wed Jun 26 08:00:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1610051022; cv=none; d=zohomail.com; s=zohoarc; b=HzkfKPxipk2ViPaFiFttYCnkduTXGSW1OuaNfBtJuI/6EUNauivh9XMTp4PuOyz6u9J8je1vZWwkNzsbtDsGmVEx3nLHEtI/3g3NLKnuNtXFhmnyaxpxKgrbjQ7k2XvICyDPe1Brm7w08yihW3D+lXkXXnw4hQbsPYbkQFCFHWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051022; 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=48z+GqlaobtZlttO/+L7peMtbYaAP6yESc8MWoNMMuc=; b=M1cyB90JoNUcdT76FHXKClgq3+b2U5aEBq1TQR4xLPDvpvCQ+uqrbXd+ImEdkSOM7md/MLlSA3CNJ5hppKAcODDZB/TEwXBzPmddH4kD8lybGpqypXdwAp9oJhkuHiUNc2BW5BHvdNfHPjFje4JIClQ01HvgUQQpfPov8JFH0Dw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 161005102199543.32131915666935; Thu, 7 Jan 2021 12:23:41 -0800 (PST) Received: from localhost ([::1]:39412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbop-0001NT-FT for importer@patchew.org; Thu, 07 Jan 2021 15:23:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbga-0000sQ-Te for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:08 -0500 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:35169) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgY-0001Rp-QZ for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:08 -0500 Received: by mail-pg1-x533.google.com with SMTP id n7so5756993pgg.2 for ; Thu, 07 Jan 2021 12:15:06 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:04 -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=48z+GqlaobtZlttO/+L7peMtbYaAP6yESc8MWoNMMuc=; b=I78dbytRXYvJ6Njh94mxv/VfHQmkQCHMvNYIyFsDzi4Kt0BSwX67O7xavuiKVuC5ho vhG2bAQ+BaLr33xb9cHw3iv+C1O4nc9N1UEH/QC+7Cw1JLQlyaGNUuROTM9/sIx164mB 1A6cynxmq8p6hE+0CD/LCZjZm102tCSjAmW5wV/Jiw+C0KbBlr1EQM18ciz8NAP4AoHb jEKnYgnFK871JAj4UhbWXVX7dbCCMcwl9LHZ11YMQEPb5tcjdP7Sqcn3iaDZUX4Ddkpr n3CV/MA380r9R9v/dokah+dNwcW1VTZEojXRjkxN48yAvq0pgBSL2zRHbaIp9pEKtkbQ YHoA== 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=48z+GqlaobtZlttO/+L7peMtbYaAP6yESc8MWoNMMuc=; b=fbJGnIowKKMJgdrq3hiWUIcs+RuSC7PTRPi3kQthIyYxQUBUelakWRknJXQCm65hUI WdkUx6jmMJaUze3kfQHAiKysF/VtvLcoJhLaEReQ3VjR+wYIGXYh0uFINciWNQ9sQ8sl NjIYB+ZqSAXb5qZlgo+uz4OeK3sTuTfVpACURy4UdG9O222ydl/o/ZIXF/365vnS3t7i A3L0luEH3HKZu+BT699w0pkLc9ckybunGPc/NeZYG+SEtlhGhbL4PRgdJp/4khLJf6Xj QScUJ8Ex4StyYwNc5crMV2mJuyZRfWxS73taBYenPUF4FonZhlTjZp7ZP38m3EECpipL K/HQ== X-Gm-Message-State: AOAM5334t837hTaOLdG6xQ0V9beaycHZKdBvstUeCFbCahVtU+SNATrq y2mLBOsApTimUhCCVaxZkddrTnwqVCDF9A== X-Google-Smtp-Source: ABdhPJwi3LT4IUzZoiC6DUGUS4uv198M6Q38jazqKbPcjvIMMzFm+PzhHMkexu0hdal0vGo5mzm9Gw== X-Received: by 2002:aa7:8104:0:b029:1ae:684f:d140 with SMTP id b4-20020aa781040000b02901ae684fd140mr337939pfi.62.1610050505129; Thu, 07 Jan 2021 12:15:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 07/47] util: Enhance flush_icache_range with separate data pointer Date: Thu, 7 Jan 2021 10:14:08 -1000 Message-Id: <20210107201448.1152301-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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: peter.maydell@linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Joelle van Dyne Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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: Joelle van Dyne Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- 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 8b9ffc41c2..6301f4f0a5 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -2946,7 +2946,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 9bdc450196..759a41d848 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. */ @@ -4328,7 +4329,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 Wed Jun 26 08:00:55 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=1610051204; cv=none; d=zohomail.com; s=zohoarc; b=P5JUxXNIaFoF8+qzqrmTl/875o/SPmX/A80u47chHxZ6eTF3fTffpzTjHVGPd6ZGSShVcdJcNAK+wbudN0MCGtf0GPIxInNZauRtfAvTinJArvf6jBdem8KSYqAQE0veV9K18g/I0Dj9e+E7o9UOac3pP9LGIBe4TelT/vJ4yBk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051204; 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=NqDvAjSsLSimLcFmAjOdfLypVhA8Qg70u4hgiCmTSw4=; b=cx53G7fTBFfGmcKFLBSddGeppHe6Ip3HAbe28AWY7/nwJ8hVcHzOxEFBRVk+5yB4VqRTNOLNT0LqlMn35OImha6wk+0HCE3ZDcetN4+f+d2FiHwDTFTqmnv1a9qPDr76XbtsLe4XoDq+uYzwXoDk7XTFYzurgVne4Mata8hsK8A= 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 1610051204334634.9451234617883; Thu, 7 Jan 2021 12:26:44 -0800 (PST) Received: from localhost ([::1]:50222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbrn-0005rf-2u for importer@patchew.org; Thu, 07 Jan 2021 15:26:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbgc-0000uQ-44 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:10 -0500 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:46469) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbga-0001SC-Eo for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:09 -0500 Received: by mail-pf1-x434.google.com with SMTP id s21so4541125pfu.13 for ; Thu, 07 Jan 2021 12:15:08 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:06 -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=NqDvAjSsLSimLcFmAjOdfLypVhA8Qg70u4hgiCmTSw4=; b=Stwg9jZiJZR6PaT3mLXbZ7e8lNdMsgDMfIJMf7yEEWTdcMWl2GX0WT/r27zgrhnQlE D5QcgHcYBuQ+OKZjmSZtMebWb1TtQxdbDcjVtvKnfpnMgP6gpCco3OdNxvVsDlG9iLQC rGXOBUe+6EidJkYTa8vR9Hi+1uj5HGyM6S2s4plsggYjp8dyShTdQyq+NAjqUO4rlMPA FczWvUZP8yffFQKiuMn+A7mNQlW8u9BAPokoQchGGYFvLuMFV3oAAKQKB0S0KtOkaFZ1 UMDWtr6TZ7PILejev9YfGT6DPM/xwk2tWHkeRGVVeNBpwqkdzYZE3Z8+WNkqEc7L/Pie +fMQ== 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=NqDvAjSsLSimLcFmAjOdfLypVhA8Qg70u4hgiCmTSw4=; b=htViOjd+pORgeDoaUFKULB5z7mbmC7KaxuxCvnuGEUL0Fz6VvBZSe3H4UCNzKDuIGi 52HhZGNcU5H8eLi/Z6a2GSjPCph2fZg+McWZdYoqEoCJcfCL9IpB8awq68ATwHvhJ79l 8zA6IJbvYXOmfdZC2SiwYJLzlurFhnz3I8zs4S+/zqOBd26ObyTsjU8H3dSMTiEwzUL/ jNe92PL7o4bNQLE6CR84YqYxj2xr/UNAcMTjwWZcVzXAjKe8RvBo02cSY/GzjyPDxCuj 11K/zp27NEX4wg+ZZnLjV1qW0shvlvPpgQT8yuyiSzUwgUr5u9UpsJwd0sfKCgD/kDfH yczw== X-Gm-Message-State: AOAM531rLlg6j1C54kr22f4at8XvMsYxQzrMp6jjlWID39G5WBWg6Bpm FEUMVW6enTjIbrRJpSAD58QSPn7tTf+KVw== X-Google-Smtp-Source: ABdhPJz+Q2VZY/2H2OmkIuG4q9/7A7vidnxfDAoHZM18RN9i++37qk3wzxZXEowtzAQpp3a4nncViQ== X-Received: by 2002:a63:2f05:: with SMTP id v5mr3495674pgv.3.1610050506879; Thu, 07 Jan 2021 12:15:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 08/47] util: Specialize flush_idcache_range for aarch64 Date: Thu, 7 Jan 2021 10:14:09 -1000 Message-Id: <20210107201448.1152301-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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: peter.maydell@linaro.org, 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. Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- 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 Wed Jun 26 08:00:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1610051158; cv=none; d=zohomail.com; s=zohoarc; b=n6UtS3wLR5OCgZrMAKGfLA2ugqNYwxiQaHoHWPy8K/sEtmMcdkCd3HquQiObHJA9DiIpGUUXR8oku1XAOQwLIHi32by4JkeklrSuqmqZsO8vOIj+9Fo7BhOHqVj/2cYBmUSmuB5Smrv/3UWpP2ZmUasZt1BW7zXv7oqtuFu55cA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051158; 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=cwIe7ehFV7zcthsYPXS8JZ/YxLeGaqAzHfZida8viS0=; b=GdSPssL/acuJtSR27pT6bBT2F/ERUtzVuV1yANWb4nJflM4f1TkKCgat/btk37HmCAADBZiowwLL5WUHnpUQ7QmFjtU2sxkj9YJS4AChtqX8MdxcvH6+xgEO+aT5JRqEwQu1WmKNpdF6UBxObgEcR31mU/SKqjULhlKWrBMLV24= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1610051158758942.1094498182952; Thu, 7 Jan 2021 12:25:58 -0800 (PST) Received: from localhost ([::1]:48020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbr3-0004ta-EE for importer@patchew.org; Thu, 07 Jan 2021 15:25:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbge-0000ye-PB for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:12 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:39748) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgc-0001T8-Es for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:12 -0500 Received: by mail-pj1-x102c.google.com with SMTP id u4so2765720pjn.4 for ; Thu, 07 Jan 2021 12:15:09 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:08 -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=cwIe7ehFV7zcthsYPXS8JZ/YxLeGaqAzHfZida8viS0=; b=BB4dVPFlsC8jiyq2dUGboLfeL+get6+FqSXYbV8Vp981IzDYotCf04i3gMKDuCCKg0 OSZoQyY0Gk5Drfbo4sAW40I/rDwOY1xSu5R3tYX+rawbfPsBcloIHkrHAe+eMl+5qTWf cAz4PIed9GXExURqY+Gw2CMg0FX6EARJkxR74rtdPJsYoFhTC+0Yls+pLW2MMzAHibdb NUT0JuaDeaEhQ8KnvwoT6Jve6HE1FXPAeJMb0szxbvmjo0U4L2TlaRwvejMSyEdcALpu VfiZkYovLVgZGp6hzIcCS3e91QLTHINEu1JILprfTeinTSgCv5G3WavXMZaTXaFc9R/0 Zv/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:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cwIe7ehFV7zcthsYPXS8JZ/YxLeGaqAzHfZida8viS0=; b=XwI8MWAZfOWR6fvM4Wv/l0zSZsHsXtz4ZUdTqpx0Om+k2AOKJASeF+bqUtqlzwLk9I RGTGGG3KyaSZAAduWFQSpw76v2FbzYdjeHaqNPBfw1HxI0L+UbNveC55kxKBlUvFDytc zgnzMVUyQ3RGLPOg4WbYNvsIuX8jN0UZ0Kt3zOz/ZJ/zsp1npiIWCwOQugJlmYlUWziX Dquf7izhu5xpXBE6w3O7OxcdGMHWP8vUHxmJLViCCAQcwsdxYpwJ4zZRnH3hDsZtBJlm LBGmnGVnuEHm49lhu93l8jfmtTNCiwKho1IcKEsL6uDaQA3qMPmFozyJvH9mc4tsgpsM ufMg== X-Gm-Message-State: AOAM5313g6sdy3EgWwDVUJOpGeeFZZMTyA6WQahMx2OMaIR3wN7Pt0iy wDUGhaVZnI/UwoIdRn/VjJTu2J1twDHOLw== X-Google-Smtp-Source: ABdhPJyLPSz5Q9Hg64pB5QFqaruCep+bNTGI4h9sg9dKb9ogzbQV0EX7utuGEx+Ie5nOgcFPVV7H7g== X-Received: by 2002:a17:902:6b02:b029:da:c6c0:d650 with SMTP id o2-20020a1709026b02b02900dac6c0d650mr490444plk.74.1610050508781; Thu, 07 Jan 2021 12:15:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 09/47] tcg: Move tcg prologue pointer out of TCGContext Date: Thu, 7 Jan 2021 10:14:10 -1000 Message-Id: <20210107201448.1152301-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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: peter.maydell@linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Joelle van Dyne , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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: Joelle van Dyne Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 9 ++++----- tcg/tcg.c | 9 ++++++++- tcg/tci.c | 4 ++-- 3 files changed, 14 insertions(+), 8 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 759a41d848..b686cc9ba8 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 5d97b7c71c..cf0440445d 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -481,9 +481,9 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCG= Cond condition) * One possible operation in the pseudo code is a call to binary code. * Therefore, disable CFI checks in the interpreter function */ -QEMU_DISABLE_CFI -uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr) +uintptr_t QEMU_DISABLE_CFI 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 Wed Jun 26 08:00:55 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=1610051348; cv=none; d=zohomail.com; s=zohoarc; b=Rim00440G00QUwMeehwVKmoOtLBMhgy1a/6KnqIV07jFht2NrgvmI6Lpwf1vsGnywaU3rHG5QsC4LS/Lpzo+jXHQm2fkec+XW8RdETxE3Qkpi8r405tUPNotpIn2bxwNTOqbbmFz4MPdGkjyT9rh+ZDM38Y80qyxESQrWdCHjig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051348; 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=2Cs9+y1G+pu19qlVm3AK/YYBuG9IZ09f226BO4KIS2I=; b=MB7iQNglkAbDfiZ2/eimo36YokqtXT1WJWKrEREk/L1ds9Sn1DXOMBwkHk7O8Z14NBx44UNJsmQcHreIv1WMP9mi9HJrHEXAqyTnORwt0hcnsMcLxU6E7iLLhoxm3Lq0V5VGSZcBQPIMUA5iivVK4S7HkJKtzW4wBDED45AooDs= 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 1610051348898949.0863847684749; Thu, 7 Jan 2021 12:29:08 -0800 (PST) Received: from localhost ([::1]:58882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbu7-000142-Ke for importer@patchew.org; Thu, 07 Jan 2021 15:29:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbgq-00013I-F5 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:28 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:36984) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbge-0001U6-5U for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:22 -0500 Received: by mail-pl1-x629.google.com with SMTP id be12so4158924plb.4 for ; Thu, 07 Jan 2021 12:15:11 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:09 -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=2Cs9+y1G+pu19qlVm3AK/YYBuG9IZ09f226BO4KIS2I=; b=vbejh20I7llYwlCOxUIUawJETV0LrkEF20VdCtAv7GiLyzWSgtaMCgdw1BIDKYs27/ aac2OQQZxNnWdgqlI0gc42adoAYwLmV321J255FreMLyPzDn5P/28A4eQC68U10TfFpd ihpttZaRrD3o9wyJXm/QLHBAMyrln7NRpTuG/YCunNGFTnw8moWGu/324GbopMGcUYz7 1ZSAmjdcYJETEX9YKsqVceVqQJXTK4DdwK2elFn3t+oOYGJAOgbEZ2Kd7Jm6VRhi+KYA lkl4/BxIN9I25hMJCNy2xI9qoZrelieskS8Bi8GNTnZryBF3/CdIJrZMayMRcxi7WzI0 +EwA== 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=2Cs9+y1G+pu19qlVm3AK/YYBuG9IZ09f226BO4KIS2I=; b=ccsVcmtpwDHsTzxEJmJOHMLffB/Y4WNV4igd4+NtJ9Wyhzfd1lfT+yoh+P4iBBDyyY PdJNjISztSODQePBZUlPw8RvdbsUjCGbUVB4yi98rRudyJQ2ZaBwgIZA6xFjs6vm1EAU +0OA1EU2YEg2H3Gkb4nPcIkKpoReta2/0rYzsNvHhSDjSioMPP+emtnxL1fG96P/iah9 kqHjzzNFPPGVJpGJwl7LVjESMYX5tDjvgwJByzmLHAX7HyYvk6ULzGxZrFlyQnQSmXV2 q9BunPZlfXr4qygBA8sRrDPcBiLMi2PC1TEajKFJ973mTLkAaBVud3JcDJvQgNMODweX gxYw== X-Gm-Message-State: AOAM533y7nMTbGNyZySwrrJkKF2757eg7aREkrJ4OEK6Pi65ah6OqlNT y93BirwZ7TOutu/xpCrqqkzQKWpgZNGDJA== X-Google-Smtp-Source: ABdhPJw3tAIHbHssXfKbmzNS6zaZssPku5QcnVm2HKKOqzmVOGwzGPIaPeYXTswDxygxFMl23LmvOg== X-Received: by 2002:a17:902:6542:b029:dc:2fe8:e0c4 with SMTP id d2-20020a1709026542b02900dc2fe8e0c4mr522766pln.84.1610050510477; Thu, 07 Jan 2021 12:15:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 10/47] tcg: Move tcg epilogue pointer out of TCGContext Date: Thu, 7 Jan 2021 10:14:11 -1000 Message-Id: <20210107201448.1152301-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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: peter.maydell@linaro.org, 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" This value is constant across all thread-local copies of TCGContext, so we might as well move it out of thread-local storage. Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- 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 b686cc9ba8..12f598cc18 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 f8e9a24e3b..ee3a27069d 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -2240,7 +2240,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); @@ -3803,7 +3803,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 4089e29cd9..25df85b33a 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 Wed Jun 26 08:00:55 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=1610051299; cv=none; d=zohomail.com; s=zohoarc; b=coTtBsLZz3ZPnKeTWvrVAlNv+CXXYH2ld1L3tFf9kMVFmd9cUGo4I27nyttlMwUKddoAS+g0Fg45Yu0WOlk5z9m5e4EY9/+OqCcMOC2Jrf2s04Bnz/D+cqanP8W+UR0BFBmX0CjHGuPa7yOW39up/b+vQATpLD6QtkFqMxye1Co= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051299; 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=9ERcwQ1o1WQCtk37LfWcrGwhEwI+ExpBZ4567jVnbB8=; b=Kuzmnv0BvNPl+DVFJFSFAOV/bWBlHZv9l/0tFTBxZ01QwD0g5XJaFYgSaLQGiIQUOnKw89vwYTGv9hBpVMLEjKftpKLe6L8m+dUosQC89rh3kec8iZiLxWpqOAkvDwxM+Z2GkYyvMizYX96mGU6lTReqUy9ntrw0DhzIkysdCLE= 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 1610051299340732.6256690832777; Thu, 7 Jan 2021 12:28:19 -0800 (PST) Received: from localhost ([::1]:56588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbtK-000063-4n for importer@patchew.org; Thu, 07 Jan 2021 15:28:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbgz-00018o-SF for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:33 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:35531) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgi-0001UQ-JT for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:29 -0500 Received: by mail-pl1-x633.google.com with SMTP id g3so4170103plp.2 for ; Thu, 07 Jan 2021 12:15:13 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:11 -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=9ERcwQ1o1WQCtk37LfWcrGwhEwI+ExpBZ4567jVnbB8=; b=koyIZqoBQWXXGphDxv9A1v7hB4X6F300OVwcEYLBHLbChdyP8qBIAW/3Q360Kr7YQu 8hMC1MB9VvuZM8OPPLaAgy8tkpaEX9MxC9YkvlHxoE+qLm5cH7IiKvu4j6Qkil7Qr0s0 0H8589l97rPKA1cGAFAf3LRLEkHMV2FqOaL/7DT+cl6b36ktZ1UcEaCX7pirYgcyzN4l rjiUqxbRzNqasgPa3rgCy4V6YwZ16GyCYZjiT+HUlMsfCHTOon/AsSK4fivCPx7nsHuy iD6W8I0cr33F6HRWRz/M7Lzr22RmOiyV+v+RP2vScAurBU0QJtfB1blTInqc30zUVgrR Na+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:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9ERcwQ1o1WQCtk37LfWcrGwhEwI+ExpBZ4567jVnbB8=; b=Jq5Dl6z+ZQFGy4ZKNDyIbSAegiFL0zkmExswQ9Wo9isa1d0YuA366Diz1a9An0JR51 ONcial9BClBFpAvxbdXw8QjiL/TxiMJN3OOypvt1JpjK/eCDxrMRpCzwZZW8w+QYCKcn VvbqrjhDtvHWjzQTIx2bS29bQt4aI1oP0ydijOEWdITDgRmoZstfhLH6FmoFsHz4h48d fe63enrinbCkVpSnQckx6bxrZNHtyNmrcOMx2lrWXk60Hx0hkBfHLE116gyZlMoHLV6l VFkV3yfZHIh+wrs6a9x4DqtfPh/9TM/W/SH5mnQoJUxFwrQoNTdCSac83WFcQ/lgH1mV eaGw== X-Gm-Message-State: AOAM5302DsFhpuq95eTRDp/RujvJMsDIDEm6K4/LB5GssrzRjSTOFtkb gCK14RUHBttKcv8c5+lfGXNSY3FWDiPRPw== X-Google-Smtp-Source: ABdhPJwKzFG0EJNr2/4sXB5JX7r6ko2Vh/YooA2hhcFSCjck1Zf8wTEoo99Ys0fzTMJS+ej1oXm5og== X-Received: by 2002:a17:90a:5b:: with SMTP id 27mr154834pjb.207.1610050512311; Thu, 07 Jan 2021 12:15:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 11/47] tcg: Add in_code_gen_buffer Date: Thu, 7 Jan 2021 10:14:12 -1000 Message-Id: <20210107201448.1152301-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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=unavailable 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: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Create a function to determine if a pointer is within the buffer. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 11 +++++++++++ accel/tcg/translate-all.c | 26 ++++++++------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index bb1e97b13b..ef571b6f3e 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -680,6 +680,17 @@ 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; + /* + * Much like it is valid to have a pointer to the byte past the + * end of an array (so long as you don't dereference it), allow + * a pointer to the byte past the end of the code gen buffer. + */ + 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 a1803a1026..3f9e25fa0c 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 Wed Jun 26 08:00:55 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=1610051549; cv=none; d=zohomail.com; s=zohoarc; b=ZgWF4EQexlFAlAzfIMDhq+1hDDRZZhHtOv2j82qyIBfExKnjDk7VdM0YAKiVUbI3GIW0oCfbUjH+8OgKboLxkA4Kqpx8/W7m83VElU9ieGA1r+77cNQ6mtrfNWxVJdPq8pWy4HcrnZaXOpkn71C4kg6T7s86ZxufeNXQ5vneDfo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051549; 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=J5TmU4gbar1MXIri3MdIsFToppdmZPje42GiCM2xGSI=; b=ByARDvCEAqqIUHySx1bjhyeycNglqoXPcz3GzYTKsT+OT5OBGuemtgkYrwrL5TJKD4xq3PMgC+twckqNF8hHakNL1HkAXWaTx/gepoItIaCkAlTPWlHBKFhuNTA+nFRhUv6/MxHlnANSQ0u3duiFXh6xrbWxoCPFTxNAo3FR3SA= 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 1610051549842556.5589018330427; Thu, 7 Jan 2021 12:32:29 -0800 (PST) Received: from localhost ([::1]:39286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbxK-0004j1-M4 for importer@patchew.org; Thu, 07 Jan 2021 15:32:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbgz-00018p-TI for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:33 -0500 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:55099) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgo-0001Un-HG for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:30 -0500 Received: by mail-pj1-x1035.google.com with SMTP id f14so2102979pju.4 for ; Thu, 07 Jan 2021 12:15:15 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:13 -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=J5TmU4gbar1MXIri3MdIsFToppdmZPje42GiCM2xGSI=; b=FJuFk4iULqZ6jAUxCKh7RkPvBqBLQIVD0CJ2LS25PYZXdRONBou7ckXgNxsHrRlDgG oWx/KOQqcZW96mbbeFlFlD+IOjGmgjjIoxrZZR4bu3qvZc3DxTXrKnq9eeLrdgKcuknR gWIaehmtEZiIOajKH3o1vlqiz/4Ck/db+xvwfCNROfe9QXb/6/AYGkU/0rffPlkT0Mz6 iS0Zq5nk/MxhHbeKuYtKEE98cj21J5cNHpF6cXrbwk9GdlWH+l0/BdLewSmMFVPjzQuA J6iyql6AUeO3gxX3hs88LoWZwdrAxUYnvFOUZ6oRk6W0Aqia3nPAcD8+grt6k/S+Kv9G a5dg== 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=J5TmU4gbar1MXIri3MdIsFToppdmZPje42GiCM2xGSI=; b=tV7X2l8KtYU+iv67Dr96wkU1ijbBXBuMGOLm+UCoc0RQZTXZrIJKx7rcF8he+eGsG3 DjbIaHzaxxM5jg6G/us+FfSw9L3VfKjujCrGwb3fW8mUJhksdPJ83z+31icAAz0DgsTI cMghNQH2u0xAohwXGkMHsm6H/J8gCV7hua0oQ4TMAtNGAmwR4KKdDBOXDhsRILrkaro3 QHPX7f/1AsVrehuPgHWHjxkkBuxHodPEHgKwjZRRYAV0/Y3DtwoFK1q7evhT85MPlezZ wVygLrhYsqlhGN7RdlxcJQHlYFh95Y35gtchag5LwUN+sCTy5Iw2ltxvo5kdVJhK5HOk rFPQ== X-Gm-Message-State: AOAM530SSrUombHPCceyXvw4FKGOaaO9BeXQrQ4NHJsstcOr72rCs0ii p6avdaEg8YfR26A2jX9qjTc9UtEuyCrQMQ== X-Google-Smtp-Source: ABdhPJwPRq3Bky1E78/VW/UpqW3YCUhhjnHvOcn0PH9jD2mZpGHQXrFIWeQgaFWiKU5Bh+9GM0qX+Q== X-Received: by 2002:a17:902:ea94:b029:da:a547:b6a6 with SMTP id x20-20020a170902ea94b02900daa547b6a6mr520330plb.78.1610050514136; Thu, 07 Jan 2021 12:15:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 12/47] tcg: Introduce tcg_splitwx_to_{rx,rw} Date: Thu, 7 Jan 2021 10:14:13 -1000 Message-Id: <20210107201448.1152301-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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: peter.maydell@linaro.org, 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" 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. Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- 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 | 6 +++-- tcg/tcg-pool.c.inc | 6 ++++- accel/tcg/trace-events | 2 +- 13 files changed, 105 insertions(+), 40 deletions(-) diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h index 2e36d6eb0c..91a5b7e85f 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 fab573da06..2e5b4bba48 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 ef571b6f3e..b769e868bc 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) @@ -691,6 +692,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; @@ -1111,7 +1127,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; } @@ -1125,9 +1141,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 /** @@ -1233,9 +1249,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 fa325bb3d8..f9344db283 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -161,7 +161,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 3f9e25fa0c..c0a3c60e1e 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 12f598cc18..7bf441979d 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 @@ -4231,8 +4269,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); @@ -4337,7 +4380,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 cf0440445d..017887bbc9 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -481,9 +481,11 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TC= GCond condition) * One possible operation in the pseudo code is a call to binary code. * Therefore, disable CFI checks in the interpreter function */ -uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, void *v_tb_= ptr) +uintptr_t QEMU_DISABLE_CFI 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/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; } } 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" --=20 2.25.1 From nobody Wed Jun 26 08:00:55 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=1610051027; cv=none; d=zohomail.com; s=zohoarc; b=O0YGRtkeWcXVKrtUdvG61fATHQlXIQNlzjti6EZ1Mt/AGlL6l4HrpmH/Y1c7OKB1P+44p+FwHyMGPx/si1sOs+5XA6lIBx2oVJFtAx3rxyNbUSoJTVxN28Yqk+gzm6xajIzAgc7EHhAuwk4yUJeIx/9ns4qpmieLAdNi5qHce88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051027; 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=yHpWBji5XIjin1o+94tFD6CTmKluj6DDVpJFH1M81zM=; b=BRJhiiJu8j4eC/XUDH1Julvxk22/svHwVJUBuk+qoY3SPFpGwDx6ykWF+0uisTLEcrGwjjaOztsw9f+Urga7vD5k3hkHbLykTTYg4MXp8ZVgb/+glFM64jvlr/sqx7I2/LJIfuSuP/rils5XHjDQnvAUXX7rXuScYotwxv9xVVY= 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 1610051027322649.9826409872261; Thu, 7 Jan 2021 12:23:47 -0800 (PST) Received: from localhost ([::1]:39732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbow-0001V6-56 for importer@patchew.org; Thu, 07 Jan 2021 15:23:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbgw-00017M-96 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:33 -0500 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:35542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgm-0001VB-9H for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:26 -0500 Received: by mail-pf1-x434.google.com with SMTP id c79so4568120pfc.2 for ; Thu, 07 Jan 2021 12:15:16 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:15 -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=yHpWBji5XIjin1o+94tFD6CTmKluj6DDVpJFH1M81zM=; b=P5DOXmM1mnEfORNJDTYzyWWej81LEumEDrNnQv+1j/mEglTGQOoG3pmTerVB//E/go PkMoedUcksFx+j2igBCnlhD1obvMDbTXw/I4HevxqlQasPSCyTHP8oC++9GQKyzfRRYe goO6bhXdjnf2eFjUuZSAfXbHcgA0Ic6swPCHATyjLXvUbumOlsxjDLjVW2JriQ/Dmqy5 UC3iqs9X32OLzYD2t9CR4zSv859SkySDssTAPzwccmewH7M1fD6/VbrLSlRPCR1BraxT Q8HFaPUcIDr5rG48VO7zUNqo92TpD3oQShK2R5IfH80m6UW2JyQaniJZteFKfCCneA8Y 7zQw== 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=yHpWBji5XIjin1o+94tFD6CTmKluj6DDVpJFH1M81zM=; b=EC4qg5b5B7CT3ioPrYiSnY6aX6skUc7LAEYJ9drg3t/0GhG+d7RmDAPEpcME6FfJNR FXQ164sZJxmnVJ1zjvqtYbEPi+Nc4ZVg51MH0JH/AcInlshCcjWdprtx1jxTOu3auIvx moVwIb8HqWZNRIb/rwMDbNnfRwsvxjwS7JXsMNd0qpP7Qhgj+ixX3y7qnKsBWiJZcG+w SY8aD5FBeFOllOovo/IDYSMy9AuJtTN3DKHNTnV5o5+u1HiBOeeyRoMKcE7IGSWxu4VX SortWkVzMKy1hsv38+P7hORUc9FWFXIGxqwzk9n9PzevbQmFTMxcERbkmbCnoKC56eX6 JvdA== X-Gm-Message-State: AOAM531Rcss+qQuAIon2leaNtHSldygMQegBjx5g+8gyhKcs1srkFVV9 w0k/wIV68/rgOjt4MyrB/o+Qd8QjJsoWGQ== X-Google-Smtp-Source: ABdhPJyEFsmXi3fF9ZeTiSOzCO8qVSuvEVCH0oS/Unzxuqc532yvExpysJpKId6JSMdJeX4Gc6bniA== X-Received: by 2002:a63:f608:: with SMTP id m8mr3439872pgh.11.1610050515842; Thu, 07 Jan 2021 12:15:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 13/47] tcg: Adjust TCGLabel for const Date: Thu, 7 Jan 2021 10:14:14 -1000 Message-Id: <20210107201448.1152301-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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: peter.maydell@linaro.org, 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" 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. Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- 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 b769e868bc..e9af279738 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 7bf441979d..325e439cb7 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 Wed Jun 26 08:00:55 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=1610051736; cv=none; d=zohomail.com; s=zohoarc; b=j5siWuA6FfJRKwZ0alEYBKoh08Frs9jHRrCGfpaXesQ/avl8TgWCgY5xe06aRtvGkcgEld8lf11nhtfUi7pRDA2KTxtq67rYbDcckbp8s+DjwYhTlnPIhJAO1CVnD7wmHH47451l6E+leLt4aByFBu4hoRvWCLDu061TIJbN5Og= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051736; 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=72zHjmApxurokrOqBQhkIhZjtudzzH1TIj1EwkLb0WU=; b=Yl6PqSwwx0Osvr1ziBDRf5zKzIaFDI3mhX/YYnivxmDlS5B085LO/TOeaXOIB6mPqD7YYedciN++NqGsdH1QyNZYi+1zS781WHFN2z7fks/HayElZfdg2vMYpCFK8W7LyzbMMPbJWcuAhFzEuQvWHCqZDWrBzWmW3rWd/z6+se8= 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 1610051736257721.1404944551963; Thu, 7 Jan 2021 12:35:36 -0800 (PST) Received: from localhost ([::1]:47812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc0N-0008Pr-3p for importer@patchew.org; Thu, 07 Jan 2021 15:35:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh0-00019z-Dt for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:34 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:35523) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgo-0001X2-HB for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:34 -0500 Received: by mail-pl1-x62a.google.com with SMTP id g3so4170347plp.2 for ; Thu, 07 Jan 2021 12:15:18 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:17 -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=72zHjmApxurokrOqBQhkIhZjtudzzH1TIj1EwkLb0WU=; b=eKWYSr1I3HyuMxoTg7wayBStq1qF90b0P31DfebR+DAmppTszXqkQNst/5QlTooS8V UI7FcgF6+XOcCdVftnWj8GTZ367W+i4ipC03iWWrxJk/Gkes6bDKTrNUAZEuLvXEg0oi M1+zSUUmVzqYId2FXlRot51mwn9lFhNu0Ue1RQaeh0SDiDF9Qfl4dZwT3og5/3v7kd/G jHLNQ4MSsbHC7bOJycCfxw2Mv0Ddtd1p8mdG7j7i3IZxlR6Gu2hqLE3jNMF5zMCVRzEr /ljTe4C5YMet8hWq5JUOIpfIDHJ3du54alO3zLJ2px4aZI9Z38xcBBNpMaMH8iq+NLgD OKWA== 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=72zHjmApxurokrOqBQhkIhZjtudzzH1TIj1EwkLb0WU=; b=Sd80CRz6nhyKnr5ztgLQJ3/CnTTxeHo76Z0tfoeEjpNN4aeCBthQzWwTnBg3XhE2kO fzUQRlQo31Tt0jB7IrodKbPhEOFRuhKfO37pFdPqsyfjwFoYDUmer17Y702+m6W9wJTb MMXN4CpFeMAbFlvyAtSulqYAgCsmRCXu1VG8cvfyd17REDFlEdtUjyHTkqEkUFE5ylX9 6EQghxiEG/oqJhrQZATp0J2lSZSGiLXEGa+8sQTwe+ciUz6ir2H8OMHPPqD5Wz93lpcf nBdgNW8kLpL8bwwMHc7ijwIEN+8zXZvaVC3d7w9bTriu3Qh9Lvh5xwpERg/i3AhYo16P vBOA== X-Gm-Message-State: AOAM532VPRuVLrMJks+kKz1T3w9ZB6FrCqF3A7L58QVvQInsN5o+SpOw npHQ9OVnF1zwISCx8PhQqsYyXYQ1NpAXwA== X-Google-Smtp-Source: ABdhPJxdPsKakm21Lvc3aMqE8Q+QMT3I65VdGe8zzbmw8lXBIyO1AgoI9U73uREg5r4+7uHrmwottA== X-Received: by 2002:a17:902:7e42:b029:dc:f98:44e2 with SMTP id a2-20020a1709027e42b02900dc0f9844e2mr487095pln.49.1610050517584; Thu, 07 Jan 2021 12:15:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 14/47] tcg: Adjust tcg_out_call for const Date: Thu, 7 Jan 2021 10:14:15 -1000 Message-Id: <20210107201448.1152301-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: peter.maydell@linaro.org, Joelle van Dyne , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) We must change all targets at once, since all must match the declaration in tcg.c. Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- 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 325e439cb7..a34d2e5bb7 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 ee3a27069d..9e4053f4e7 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1600,7 +1600,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 @@ -1619,7 +1619,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 25df85b33a..90588ca2a3 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 Wed Jun 26 08:00:55 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=1610051497; cv=none; d=zohomail.com; s=zohoarc; b=m6wl8UvThRbY1hgqgqNIkrVkgx4aANIwKRvax5aTVLPpopL73MOKdpwfrLoyLtcCWJ4mQ0zPqPzHNR6szQrX5rwCNTbY+JwfAglQ8Q99oI91t6agj4eQg5kRphemhnNnBTlPLBroDO2UfmuR+n6S7sN0FD5t9gGaxDGXkhVOs4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051497; 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=NQliFXXfgB1CXPoiBmFHUeq1S6nzHe9RcOFk3sVmuPo=; b=W92JhqLfQM1ANBe5a+oWoYoWYyj7IIJdryyPRrKC/IJ2jMYVfAXugsX8vnsOf5sHAEACgmxG8Nc5YsusQDA+xPsjuIO1yjmHvhdvJGHhMTk7ohu3T4MOsCpVVqT+sjWpwZ9tadEAGdVu55Y13WuBno4b3Jg/lZ87fe7vkyEyr5g= 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 1610051497612822.025647079668; Thu, 7 Jan 2021 12:31:37 -0800 (PST) Received: from localhost ([::1]:36926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbwW-0003kL-HG for importer@patchew.org; Thu, 07 Jan 2021 15:31:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh0-0001AJ-IX for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:34 -0500 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:35161) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgo-0001Xk-HK for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:34 -0500 Received: by mail-pg1-x529.google.com with SMTP id n7so5757597pgg.2 for ; Thu, 07 Jan 2021 12:15:20 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:18 -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=NQliFXXfgB1CXPoiBmFHUeq1S6nzHe9RcOFk3sVmuPo=; b=RYPyOcCcx9wrq9L4pSwI50ot5Mx+BJ3BQy10hscCx/iUwX96nO7QHCreRfKSrQ6Dig bqkCb2VPiEcVNc3vKpz3wFHl+uJBHWZQvPCYEPgcjtgDS7ECJITxf2p3Xydv2CCLWG4R wlnwLCPV4Jh/Hjah4v3y1hrfF92u8FMbWrUdGdoi3+R+ziEehvklMUsAhApE7cvTj7T/ 3PGgG4JI/KOY8ak3Dkt3Vd4T/vo8iMK1Jcoxa2obJYEPpUvFPYi2mwQmasNO/qw8KZXz hTnaoaPIZgY3n93RjHX5ifyq7dn+vZLxUaYoYpmKhm9u5599BuVQNvFyWdCiZIRrzWHh Dpmw== 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=NQliFXXfgB1CXPoiBmFHUeq1S6nzHe9RcOFk3sVmuPo=; b=bFY3+p9t6Lbs2we7Q7z1pqVkRdXiJJlyzkdZVFW2mta2PWo051rseMxEUfx3JojlWD aTvqGsRS2y/vZ7DE8+bAtbA+5+iQRZdO2XPB3vmRmmQIj+HCU5jqnu5G+wI2lKOgElhb +Y/6lGAMbFbPECivSBRjaw/Vlx0efb8JJTWGZrxjm8SrlZQ+8GSTE//tPvvSrYe2EYFL P4irjqr3aJAGmm4ng4dr516EKylva3a4s6madT8RsZBm9pQEIG4BRFJXW02deGqYafsw kNd1vrhhKGmIJYTsKVeEkruwitZAbLnYXqDcUXWhb+pmh8GRzhv0iAE3U404yHxSOrby lSrQ== X-Gm-Message-State: AOAM532p6HT1vHHCGQoQoFlnXOFlk5YEYuRhzlYHIOq008Ll8ctfzLoN D8w0btg0L+1XJjpwSy6Fb4kwgmB9SXGZeA== X-Google-Smtp-Source: ABdhPJySf3LUGf/2eg+OcxqGNV5cgo1r2JA/kNLHWYs+5fXPPxRnupIMjEhXZoA576jh7PFrDUyArA== X-Received: by 2002:a62:1dd5:0:b029:19d:fc87:5f45 with SMTP id d204-20020a621dd50000b029019dfc875f45mr307607pfd.63.1610050519407; Thu, 07 Jan 2021 12:15:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 15/47] tcg: Adjust tcg_out_label for const Date: Thu, 7 Jan 2021 10:14:16 -1000 Message-Id: <20210107201448.1152301-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.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: peter.maydell@linaro.org, Joelle van Dyne , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) 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. Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- 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 a34d2e5bb7..898c4bd1b6 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) @@ -4329,7 +4329,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 9e4053f4e7..197e3006c8 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1461,7 +1461,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 @@ -1503,10 +1503,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 @@ -1520,7 +1520,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 @@ -1534,7 +1534,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 Wed Jun 26 08:00:55 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=1610050857; cv=none; d=zohomail.com; s=zohoarc; b=nps7II3roXww0uxN6MlLWX8k+pmY9kfZdS39MTF03bbXDAowthQ0x4JQt7mtWOR3r+DFsF0Z5q2FcKUAy5WdjrTcmUyOD2r0lnzTgQR4P1ElkcPVFXIdp+6pMo4GiZENbI42NP46bD1g322Egk+7AgYRfjCvShSkfsjs/kd/VR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610050857; 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=rtXLHEnFm6PYImUKUfsTMRutoZrBjCY0hpS4NqovFSw=; b=UerL7t1RMjmAB7a8TCRh8AlJw6zGQYbFMvSfD9za/lofMOv9HhuXxcpI3b+Qf7D8vp+ykB/EGFPgo/vjPCNyfyavCg9h3muLOjNsG75+marf0VLUKUUnGoJgYKTn4rLzwLWRTPPVHltoau0Lr4+ougC8s5vwfEvHWJb1IfLo5bI= 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 1610050857215583.8816111929029; Thu, 7 Jan 2021 12:20:57 -0800 (PST) Received: from localhost ([::1]:59204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbmA-0006Di-34 for importer@patchew.org; Thu, 07 Jan 2021 15:20:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh0-0001BG-Vo for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:35 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:51490) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgq-0001Zh-1S for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:34 -0500 Received: by mail-pj1-x1033.google.com with SMTP id z12so2113424pjn.1 for ; Thu, 07 Jan 2021 12:15:22 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:20 -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=rtXLHEnFm6PYImUKUfsTMRutoZrBjCY0hpS4NqovFSw=; b=IDQ37mg04ipoga/gdigKisakv9sEGUi1r0LS5oym5igu9gMjZBcDAIeSXFC4U1jnwI KvbSVeqdS+K4/dwRwt/laxGe8n+8dLO2Izj9lI4hkEgay5TBI0KUzBqkDbbqGTyF+hOj 9rMinCylZAd/6MYHPoLbU2TB7KKXBfHdwmHlYxPaG0FPRbxGV2SykgM+WXZanfskCJy7 sUcH28sTSDA9tfYaxeUGU6rneAWrbouL7WS2xfz7TN1u9m4RHZSI+4Jea6KrhGxdLjQH 6jDEGP1nhF/39eVM8qkZXnRgqaTOz5pmoIzkPs7lMIXU3TwzvqAhbXaR/IXaCnF7fQA4 V1hg== 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=rtXLHEnFm6PYImUKUfsTMRutoZrBjCY0hpS4NqovFSw=; b=n9kw/9S9vAdBMd1+K85EfK+wc+1YOkKmJWnUI6/yZIjHK2b5P7TS1Gv1ehRVAyE1o3 I58PDdZr0ljC4Gx5ZGWhqcHQjl/XOabzzW9NK+GBYWMyFb3wRzU8Na+v5Qz1cVGxLp9e /57w7ZWCDJCU++K9OyNl9Y7BnsC6NBrpo+hzc3UO0r7YI2hQYWr3mBKp5SljNLdob7r9 NZSR13z2/OKAlXg/Am7JI9+vnAasjNr39KDn38LC2pLGQpEvAF/K745YUN4BLngY5KGP JdGH554Y0ZY2eGUKeUbanGvYucjv2TeqFuX+24+2ea58uKhGATjgUnTu9kj+FV/4auWQ fI3A== X-Gm-Message-State: AOAM530+Bv0MH75vXl4pNzF+RwaxN+u9UprZZUyrrzkoYqc2H6Ad7kGk 3a3ANfTrbJYoscswWUd07oVt3Ty7G0i0zw== X-Google-Smtp-Source: ABdhPJyojZmuv/pVny1PfM/PxZ576qJm8S5Tc1pVVFVqDL5fth40oFwrims2jevKiMCS1yXFHreFPQ== X-Received: by 2002:a17:90a:1c02:: with SMTP id s2mr186707pjs.212.1610050521080; Thu, 07 Jan 2021 12:15:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 16/47] tcg: Adjust tcg_register_jit for const Date: Thu, 7 Jan 2021 10:14:17 -1000 Message-Id: <20210107201448.1152301-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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: peter.maydell@linaro.org, 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" We must change all targets at once, since all must match the declaration in tcg.c. Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- 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 e9af279738..e744a1ce02 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -1255,7 +1255,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 898c4bd1b6..f278772512 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)) { @@ -4511,7 +4511,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) { @@ -4713,13 +4713,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 197e3006c8..d272975ff1 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -3976,7 +3976,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 90588ca2a3..0518595742 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 Wed Jun 26 08:00:55 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=1610051161; cv=none; d=zohomail.com; s=zohoarc; b=PXoIRUNEJtEFsMQR4SjDmvg16zZUFuWdm1pjjZBCg0AzuDJV8rIHzCpjimGzetIe5c8bDY8r5ZJjUT4F9xnMBMm852bqeRXnKeBGi9zMwhKxT1RqRZjalOqXUyiKROlgTyb7vCYwMjYYNDIo9xTrjgegvlzUe5WWVDkolQEqn6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051161; 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=YV1yh0Eq/5w1u4soV5qGlyOgc8f67f4AiD1fJJACFJM=; b=WXuJUijWDXtaJd9hCwSgHwvkeontLjp0qFDKJQ6E7kwGHcMq5bAhyqhGW2W4j6eyNQ4sZa9vsTdWjdZD1FbgH9zriv8LNJbw8GHYXYUEac3I5uk6MSQ8LAs4ToSM821aJ3O8Gb75YlAtSZhHYg8dtrDNHcttFtwbS0ySQ+G1FXU= 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 1610051160991767.0122747321199; Thu, 7 Jan 2021 12:26:00 -0800 (PST) Received: from localhost ([::1]:48290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbr5-00050S-LX for importer@patchew.org; Thu, 07 Jan 2021 15:25:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh2-0001Ee-E8 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:36 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:45823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgs-0001ac-Rx for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:36 -0500 Received: by mail-pg1-x536.google.com with SMTP id v19so5712447pgj.12 for ; Thu, 07 Jan 2021 12:15:23 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:22 -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=YV1yh0Eq/5w1u4soV5qGlyOgc8f67f4AiD1fJJACFJM=; b=gLohlE4OxOErbf7R1yvbWODC2K+4xotpZmmYnTZ5+ZD8ZUh7JAwIlMxr0dJXXkxnw3 ScrzpK+byVG3rLzeziCkhCcCTBEStxJheLKSZzo+7Hj+0ywNsIXZAA4zj/pCbnojjPSL rtQPHFSYvDCjqsDwLWXJnIxftyTfQ9z8o9znuWrcjUS6ulrRc5Z5prpBxoBZiGxIO+ZU C+0i0gcJhu9GFjACfrII6P+ksB3aQOeEbNf1r9SnKxfHZz4WfXaHFtpUhAGAIPphcPRV CHC8zIqEjScI7SVgj4BU3mk21U9+nWQkU7/t4JzzShEsHONwbS4DGNkCnI++bovyNh0q xiTQ== 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=YV1yh0Eq/5w1u4soV5qGlyOgc8f67f4AiD1fJJACFJM=; b=q2GCFmxCiNDcAQCTCUX4wBuIPArm396vOxSuAaOvuSutH40V+duWi29w8EdQuR5zrX /x7epykhhfej8L0C2Vs8qhC0coczGvEC8siRWsyO/RW5fDf1VctKowp5gtzVXlJdkqrG IXEuWOoVVdFIZkmKdMIN8/dkxEuOqR7lTkuWHA5vqg9LeJAR+R7+BFcRmtBB//sx3I87 ORfLHB7ppAX4pig7v+BJOUWQTjAtdcEx2CUIjUwn8twMVdAC1aRtV0WAh8NzMeaToZ1y Olw3HLUOeOp0sIzpnf1MJrZk/Kc1J663aYoqv+7+KrjWSKL4Ot4yJqs+Oiv+k7sjzJ9x rElQ== X-Gm-Message-State: AOAM532Loj5ngi/pbh3wm7TzZcEte3rUza5Cw54PEjDqR8TjCxeuEE4w uGfeiEpn4Nrr1I0CYWm0oXkwEUpFNhGjPw== X-Google-Smtp-Source: ABdhPJxMbd2cJ0Al7LuPqeRnrllSoQOHyaPnxZkqCSX60/y51d5VW7v5nqSBsVTD4YQnjxVLhxfJsw== X-Received: by 2002:a62:2606:0:b029:1a5:a755:5568 with SMTP id m6-20020a6226060000b02901a5a7555568mr222079pfm.65.1610050522672; Thu, 07 Jan 2021 12:15:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 17/47] tcg: Adjust tb_target_set_jmp_target for split-wx Date: Thu, 7 Jan 2021 10:14:18 -1000 Message-Id: <20210107201448.1152301-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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: peter.maydell@linaro.org, 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" Pass both rx and rw addresses to tb_target_set_jmp_target. Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- 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 108a1fa969..5ec30dba25 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -149,7 +149,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 1e18fefd0e..8d1fee6327 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -136,7 +136,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 f3836a4d0c..b693d3692d 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -210,11 +210,11 @@ extern bool have_movbe; #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 624248b81e..c2c32fb38f 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -202,7 +202,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 301173c97e..d1339afc66 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -176,7 +176,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 888288d54c..727c8df418 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -161,7 +161,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 69576f4a9a..641464eea4 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -146,12 +146,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 9dce305253..95ab9af955 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -169,7 +169,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 e8277caee2..bb784e018e 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -199,11 +199,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 f9344db283..29294f2804 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -382,7 +382,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 Wed Jun 26 08:00:55 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=1610051313; cv=none; d=zohomail.com; s=zohoarc; b=nG2zphu00AWwkAyNEkUl/CGmvt+6jFvdL7druJ+Yp4QPcUEKxWlTjDAocxjkUkJVtGP8RyQd5lOsp+mxRNJJg/bnhPtPesnUOEvdqFSep/KXjzdUUikzs9de7LO+PJqwBZLFLzKFyIUgnHPitzpEOrgE+TKwBjNOephNpCVBoMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051313; 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=E8w1jAPv5ZMwC9hUfY2h/aIQICFcgu6SGeTKeYT6t3w=; b=b9a2mlf1rVaSkwzVqjyuj4PKWN/ABHJb/3fVHyNe+dXKIoV9TJ7fKNCyUxuR4//t3yhKS6bYNQ2OKTRlidRpNnjERyl6n8gvGgd+rBmv8b/NOoPkR5a8ck4WBKT3sFJ+Zl8VbXgFg6XTUFmgQYseBZZlO3nlcbn4QR84kFOkv58= 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 16100513131367.0752199236764; Thu, 7 Jan 2021 12:28:33 -0800 (PST) Received: from localhost ([::1]:56936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbtY-0000Ed-1r for importer@patchew.org; Thu, 07 Jan 2021 15:28:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh3-0001GT-5Z for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:37 -0500 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:33791) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgs-0001b7-RS for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:36 -0500 Received: by mail-pg1-x534.google.com with SMTP id n25so5759130pgb.0 for ; Thu, 07 Jan 2021 12:15:25 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15: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=E8w1jAPv5ZMwC9hUfY2h/aIQICFcgu6SGeTKeYT6t3w=; b=XUwSh5CDfgJyOtXyayoEkPrl9/O2hNhd+PghLTD6EvUpCZKC+HKExv3TeH0GkZSDsQ KyD+PSnaHNtxeozLpQ02nIjGutRaWEMQNJjnsR8HhVw7uqrucRXLmDCICvNAvRn+k5/G bu125UgukkFMVo0QLMk+2viGB/WFv64UJA7OFr8i4zv1BfJgLfUma7lwWLkIW93dY+yl q4P+uWrY29wqriMWntqhcc4wvsCjKeSiw+/ojxuGDev+DaAzRDnqLca4gKf94JKa0wYf EYVuzjhcTn7gSalvEJdb8bFxovlbDy2Bxx/0Q9WrcEgMqYaTYUlzwXEK6k19zwHfXZ70 Fhgg== 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=E8w1jAPv5ZMwC9hUfY2h/aIQICFcgu6SGeTKeYT6t3w=; b=q1yERoUTGxeu23R/4IxX+fcn5xpTN3wn7tdVOB7lAWQiD4mPaBUw+6y1wuCZsCyx6C 5PyOVyQhDnbCr2yJAWCfK5a0TXiKyjCvU7miUVMrQND4HbCeCdYTDEHu1R1Ll2HfZMKB gcRF0QPgHEj2sFMrq6K1DSn72aDL51WlWoKZgYAw3MMy7aRfQFw3HLAR3Ff34SVcdETo FyoGZh7ZuUldOBZOsxPf5tI+sVEJponBbXzZjR5awN0s8qkyhjeM08vsRf4T34tMKwIC 559ZTcVuFreuTUlLBSpIS6+I00v67zHN1ypeS3JKKo0LFnJuhNgBkFDrNKRI1dfpENE0 cKzA== X-Gm-Message-State: AOAM5315SdpYOv2KWcfE12JMlwz6YHJ1xeZKKUAY7aV86FAI4G346Lpz n6BhHdEyF9jegMWMW0rx2FsHAVvi9fkfgw== X-Google-Smtp-Source: ABdhPJy+R/rku41N4BRKD6n1kJ441YDo13ae65/gyGBxBFf9UF3hysySlHekogokeHTTsBOuT8BYRg== X-Received: by 2002:a63:ca10:: with SMTP id n16mr3477869pgi.105.1610050524480; Thu, 07 Jan 2021 12:15:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 18/47] tcg: Make DisasContextBase.tb const Date: Thu, 7 Jan 2021 10:14:19 -1000 Message-Id: <20210107201448.1152301-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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: peter.maydell@linaro.org, Joelle van Dyne , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) 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. Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- 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 5b3bdacc39..901b19f32a 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 af7ce91ffa..19fa8e4691 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 Wed Jun 26 08:00:55 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=1610051675; cv=none; d=zohomail.com; s=zohoarc; b=eYZ0WgdIxMe+SN2QZQX+8biRpLgBR69A69iWIVMoK81qQFYFQW6WzhpQSqJ1QwD181LIs4L+Df8oDL/JOUvGzrq78s3g9a4PuN9Uh7cLbli7zkRGjDYIn5kxmKUXPY/WbMIUVGaXLQzAUvNMcPghPSS2aGSGuC/qizIk16DvOSE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051675; 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=sunWAzJe6zr/hqJZSTqg1lWjV1jgJ2mUk5ECH6sRN4M=; b=Sose1Pw+OWp3dAOLaJmWn474YLpJ//aDxppf7SMn/ForCNbB0SPTE7dXgIvjKoKAzFlm5kfddGc8S/czOhiZsB7Wh41bVZngymV0BUlAtuO2WqIlokc5D1nWvafA2Sq5ALU1rW4Hu2gkUn8tFyfnjW7b6+JpNiZPB9c04CpD+Ww= 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 1610051675385107.92156490572211; Thu, 7 Jan 2021 12:34:35 -0800 (PST) Received: from localhost ([::1]:45492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbzO-0007OI-65 for importer@patchew.org; Thu, 07 Jan 2021 15:34:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh4-0001IY-0t for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:38 -0500 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:41267) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgw-0001bJ-2t for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:37 -0500 Received: by mail-pg1-x52d.google.com with SMTP id i7so5737434pgc.8 for ; Thu, 07 Jan 2021 12:15:27 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:25 -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=sunWAzJe6zr/hqJZSTqg1lWjV1jgJ2mUk5ECH6sRN4M=; b=iitJNpPuhaJ0ssYJeY1LJoV89EvPxw1kVYf5nY6bkhW4iBH0GHrqlvPhJif8c6LE60 lctvRvN7rOyVrEGjvVH1r+zJr4+bblgCXj4qGZxky9Xf0cdSVqlgwxW02GJxjexXe9bh 5g9voPDnS/RXBbPLuQn+qEbEkpPWM1APFsjawlxWpncgzsKdznDWzvb3eu8kJ+4FvoFt jXVMexxRtTLnGjiX95dFim+qCbSaEI2W6c6OajqmZ1RidbMu4MY6WpcrUJ+blLBrJcYJ ZsC+w3UZq5lyHW3Wv0XpRhc+kLKLjFMn9qLqtVSGhkJkh6zHVf4lPiIAsksf9z5Dwahs 0H1w== 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=sunWAzJe6zr/hqJZSTqg1lWjV1jgJ2mUk5ECH6sRN4M=; b=jNto3z7+MTUN2I2LXbbS8Axcu+FK3UqaWjRxQyaY6cYLmV9OxiPVUYEjOHDQI57i4E h6GSwlfMbr2SeTnqKFuf6oTTVklhgJwGgi/GLoIowdwwixPjh/Z58bOSUDwB9I33ovqO J12qb9Ai0q3Vz7e/y2fDQSBsPjSSeLCK4Te8fgfA+8awneRkRXiKgSJXPj6ie/FRm+Th no1KA0C05kmrFQwkN9+SHmqqoBAjg6jDjUywVz1DtBdDFMCC9VX9yAoJYr7j5SB0TwJ3 gD87bfqON7k3H/WzHN0I/HtyGyTLh3rYlYL3EzbIlFWV4JwAWAmYOSTI+mkH7JNmw/X6 8RqA== X-Gm-Message-State: AOAM533Mf1JK7iaejfDkriFaT6Svd2HkGbokAZ7qwS+mp80DB7aUinVp mYF7O7jxWjZt2BJo5yqAK+H6jCFlL3TutQ== X-Google-Smtp-Source: ABdhPJw5JQi7o6qiggZCRoFfeiN/bGkyRKMIh4B4PMXBt2Osp9YuyGp/4c8FhYf6t6hk+v5c/p/4Ew== X-Received: by 2002:a65:5209:: with SMTP id o9mr3519430pgp.34.1610050526255; Thu, 07 Jan 2021 12:15:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 19/47] tcg: Make tb arg to synchronize_from_tb const Date: Thu, 7 Jan 2021 10:14:20 -1000 Message-Id: <20210107201448.1152301-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.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: peter.maydell@linaro.org, Joelle van Dyne , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) 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. Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/hw/core/cpu.h | 3 ++- target/arm/cpu.c | 3 ++- target/avr/cpu.c | 3 ++- target/hppa/cpu.c | 3 ++- target/i386/tcg/tcg-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 8e7552910d..140fa32a5e 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/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index 628dd29fe7..4fa013720e 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -49,7 +49,8 @@ static void x86_cpu_exec_exit(CPUState *cs) env->eflags =3D cpu_compute_eflags(env); } =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 2283214c87..b2864d67d7 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -47,7 +47,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 254cd83f8b..8227d7aea9 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -314,7 +314,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 d8a8bb1dda..6f14e370ed 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 Wed Jun 26 08:00:55 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=1610051078; cv=none; d=zohomail.com; s=zohoarc; b=ceWwR/vvWDP24ETAjJzJtaVLd/xwQd92qZdXEuzNoQF62C0nR4N+odPdCULIzIGBGuJokJh3j98dbMBjRFYC4mXc8Ia6QKhkxjt/LyRBxiLmxGwaaPuTZq0bCtnZs65VhiL9vUzGLqIO+KL3dFB8nuEo1MoAt+3j+PciexgYACk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051078; 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=auqKLTOetMiwuISH+Sbvjoz4fFA/rmImExKpLxb7FCc=; b=YOmoJfEi3+pMtx+4wBgw8gSLaPDvGt6vWjig2dFyRL0OZ45e9hqJwxDX8Ay2szz5RDJY67lriZNTsDznbgw3MCR7ZuLA5jD+MraQbdaKGcOW6XVtMCAm9rOv9oI5rO5lb72tdCBwU8xIgWwxMq9teaZHIlSMP4MoI7Kn83HaMFQ= 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 1610051078823628.85306945632; Thu, 7 Jan 2021 12:24:38 -0800 (PST) Received: from localhost ([::1]:42686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbpl-0002jg-Nj for importer@patchew.org; Thu, 07 Jan 2021 15:24:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh4-0001KI-LW for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:38 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:33979) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgz-0001bS-Lp for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:38 -0500 Received: by mail-pl1-x636.google.com with SMTP id t6so4170219plq.1 for ; Thu, 07 Jan 2021 12:15:29 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:27 -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=auqKLTOetMiwuISH+Sbvjoz4fFA/rmImExKpLxb7FCc=; b=eyd1B8QHv9BROyCIBnmHeHwuS5bMspQYRDiYxRzFjJOZ0PrF5uL4QDK8qR+WQKhIY/ NQPVCy56wa/U3t/y1NWf8uVmFny87zi5ov/sOQ01PjrATxZqezJhD9UvLOSikDDUrPmm spDkVY0Ozraca7zMAeG9tTFrRO10PfjSvR+MXpSqNmYrukePU6lOSN1qs7I9DFgHH4lX 5cBcf4aQoqa6fLvKJHUofIINGQLItIf/SBkP0aSo3QfnBGOd9mKUdC5D8Lme7K8Ulm/i oDuWJ0H54Ij/Qj9us1h6GjXNynFjnnF1x+1e+hyZrmh0ovMRD2FX4WDH0ChF03hfYU0P balg== 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=auqKLTOetMiwuISH+Sbvjoz4fFA/rmImExKpLxb7FCc=; b=tLFa6V8PM5XtDC53OCJHCk67khk4IkSygcc4pTUDH9qoOFNn58y2ApXTdil9TMc8P7 YvEhfWox1JO8VChogJNCqDIADWIzMQIp/YobiIW4dfLn/1gMN3cqVIEMgL0nIVMA10BY YuJTmIPeBBKoXyTcY85nlD/TrNwHsr+8Qv37pDplaQ1uShV30GxSy+Vh7xuOrAV//BpK 5YPGfFMPMwtyDBFcD4cz7FibPYF+KOHwLxrZodwrJNCahTgy5oMbK/bZGuE0MkBCX6z6 05ZvFskPLZU7K9OLPRAFhaCuLYF+PrB6Bmd61loLIharXqaKLKTMlOddAyqNRjdvZO2l kEgQ== X-Gm-Message-State: AOAM5328JGLfop41zv/SnpNGxm0M+DOAgoqKjoYnFxoABqFkJCu3mNG2 4MRTQljZLvhA+6vuVe11amGIXU13x/DRYA== X-Google-Smtp-Source: ABdhPJxJHr76QiPl7SKpc1T7UjD9y3AAs27QxvRF3ApJBjeP5RYdqbPUOPR8/RC7FHk6VjU82a2eHQ== X-Received: by 2002:a17:902:b493:b029:dc:3e1d:4dda with SMTP id y19-20020a170902b493b02900dc3e1d4ddamr505176plr.48.1610050528011; Thu, 07 Jan 2021 12:15:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 20/47] tcg: Use Error with alloc_code_gen_buffer Date: Thu, 7 Jan 2021 10:14:21 -1000 Message-Id: <20210107201448.1152301-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: peter.maydell@linaro.org, Joelle van Dyne , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) 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. Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- 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 c0a3c60e1e..ae87b2342a 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 Wed Jun 26 08:00:55 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=1610051858; cv=none; d=zohomail.com; s=zohoarc; b=Aou7bU5Rn83VTQS3xX7i3Lj9Rf5ebfTvWAy3NZ1/rx8sTd4px3f4DxHnOpyJifw/VUXFmfw7Xr7W0boiVqTMLUoOhQ8j814vR4qL1VLsj3ltE5SVvi5yH+CRqtTWu/TSEcoY3kzvsmyEx/wfx/Eu9PQpf6uzePzDGvWo7tNKds4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051858; 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=dGlZPd213ho7eFFAEefoLVUOrWZ73GHGavbamQj32Xo=; b=Mp7TXEmglJ4pnFf2EhWRCqzm09U0lVgrwjbp07qzdnu6jUDDKfdmnO4PKd+9Cjkfxm6bENLASGWtJo4zcQBjFtYwELndN7gN8rg/wH8KAmXBBevOlRUKyKAMps+GGLP5Bj8rOdIt9Erx7AmAKjluG8om+0SX++kui538fv6qtYE= 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 1610051858261399.66539790551326; Thu, 7 Jan 2021 12:37:38 -0800 (PST) Received: from localhost ([::1]:56392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc2L-0003oH-0y for importer@patchew.org; Thu, 07 Jan 2021 15:37:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh4-0001JS-CC for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:38 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:52558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgz-0001bi-Le for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:38 -0500 Received: by mail-pj1-x1033.google.com with SMTP id v1so2109799pjr.2 for ; Thu, 07 Jan 2021 12:15:30 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:29 -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=dGlZPd213ho7eFFAEefoLVUOrWZ73GHGavbamQj32Xo=; b=Wp4g6ip2NOV6RkWJOmQqQ1x3UWMP4EgVVK+Dk17QWF/ND4dhepZuH/Svx7fVXosSfi Kzov5RAKCrC22uJ8OWaxPwOTZ7znFJIRta65HcPw0KC/s4AAxT+zv3occ7NKsPC+AyNi FX8RQFhrQWaA+DE1T2T6hNhlOeZyvjg9XBMWFJN2T/sKugOxxxE0MGKMRCuxTW4E6VW6 RixqvwUix1VmxAqAXQDt4g0juG99OoMNztbpp/ehEZ8/IW1/jYHwiz0ARn1jpIdUtlJq yDSkM8hoInOqob7p1olpEVUcCPLyh7we8OPhooB5mEOYqtsFgeq80QLCQ2ekaN2mdSBu fx5g== 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=dGlZPd213ho7eFFAEefoLVUOrWZ73GHGavbamQj32Xo=; b=Zytd+t6KeNoG/JKdJlQeUhtSWfJ/ks+R3/VCi6eMQhcBs3IgrEXWjj6G5Br34Rpqd1 kmXerim0uHW1FUXrCgDXszsghFFF/Sl6SSmjj1KcPlhAWOK9T1kO3AwHrh9F2XZIWFOb 68No7scTFV32r/GX9t34pk72DmrPavBz4YcTL8wEBU9msiCzDeDTGl0f/oTGTg8aNgHo GpL5b3QLHj4KwER6RiaXmTMs91suYEnMqs+IFZiMIQKBABrhi/YMKG9zmNMHcoBcF3Pl mi521fZ4aCePI/kV4drSMxqbIIqFoIukEoLtp/5tkvmKqseSRX5cVDNninU+VnPN8jTz GzFA== X-Gm-Message-State: AOAM531dx+vmvc3ng3E2I7a2JT/aD/GaYoZC88VgvJc54tH83e5ng5uO 02FV7+miqKpsAVs6U0m2x3a61BizFF6d9Q== X-Google-Smtp-Source: ABdhPJx6myXRZcG+23K8NYAooqXw7/TUNXNrjkZVmEY10B7NSY99Mw/tRK2D90BiBDbmAclznxk3gg== X-Received: by 2002:a17:90a:df13:: with SMTP id gp19mr153939pjb.235.1610050529575; Thu, 07 Jan 2021 12:15:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 21/47] tcg: Add --accel tcg,split-wx property Date: Thu, 7 Jan 2021 10:14:22 -1000 Message-Id: <20210107201448.1152301-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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: peter.maydell@linaro.org, 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" 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. Reviewed-by: Joelle van Dyne 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 +- qemu-options.hx | 7 +++++++ 15 files changed, 72 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 5ec30dba25..23bf87db3d 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -155,5 +155,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 8d1fee6327..494837d128 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -142,5 +142,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 b693d3692d..73aa45a665 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -235,5 +235,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 c2c32fb38f..fbfe775fb4 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -201,6 +201,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 d1339afc66..ba61a31b3e 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -185,5 +185,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 727c8df418..6263af4dd1 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -171,5 +171,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 641464eea4..b8f4296e4b 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -159,5 +159,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 95ab9af955..6f6cefaa15 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -172,5 +172,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 bb784e018e..d8c78d1dc7 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -198,6 +198,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 ae87b2342a..022f9c743d 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 9c700c6234..65163e1396 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -909,7 +909,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 750a01118f..bb4e55e8fc 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -701,7 +701,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; diff --git a/qemu-options.hx b/qemu-options.hx index 459c916d3d..1698a0c751 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -115,6 +115,7 @@ DEF("accel", HAS_ARG, QEMU_OPTION_accel, " igd-passthru=3Don|off (enable Xen integrated Intel gr= aphics passthrough, default=3Doff)\n" " kernel-irqchip=3Don|off|split controls accelerated ir= qchip support (default=3Don)\n" " kvm-shadow-mem=3Dsize of KVM shadow MMU in bytes\n" + " split-wx=3Don|off (enable TCG split w^x mapping)\n" " tb-size=3Dn (TCG translation block cache size)\n" " thread=3Dsingle|multi (enable multi-threaded TCG)\n",= QEMU_ARCH_ALL) SRST @@ -140,6 +141,12 @@ SRST ``kvm-shadow-mem=3Dsize`` Defines the size of the KVM shadow MMU. =20 + ``split-wx=3Don|off`` + Controls the use of split w^x mapping for the TCG code generation + buffer. Some operating systems require this to be enabled, and in + such a case this will default on. On other operating systems, this + will default off, but one may enable this for testing or debugging. + ``tb-size=3Dn`` Controls the size (in MiB) of the TCG translation block cache. =20 --=20 2.25.1 From nobody Wed Jun 26 08:00:55 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=1610051818; cv=none; d=zohomail.com; s=zohoarc; b=j9L62HUEiCsD22rFVBFCIDLl936r5s3/QhdlvDwbTlYiSAj/YF3xdUwlKkt3q/92kEBXLSR+FSJwNy+46v6AP5GEzaYq8jlGfBJr6ysd8JwnnAAPYsD5+Js7v7de35+ItIkWHvVFWGj7XGzsTDowAG+mMjqKKnj/N/TSmKBo3Q0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051818; 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=Dbx3vswVkUZktM/v/IchbClKMtfRLLh1m8Fm+DK5izs=; b=J8aN/vxYgbD3I4CmxS1tyr/p4LxdeKWyubPd4Bdn5ya1S9uBdC9hxPkFEMhWbKOEbkoDhjCW3cnKVDgv43oBEAXNrV0RQQzUN8zM5IaVy/2Jo38BkeJWxS6qv0A2j+g9OzcD9P4JuHYfye+wXEee3xAcUWrzsBSYywwUCN5kyek= 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 1610051818732741.8114480727787; Thu, 7 Jan 2021 12:36:58 -0800 (PST) Received: from localhost ([::1]:54034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc1h-0002nS-Dp for importer@patchew.org; Thu, 07 Jan 2021 15:36:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh7-0001Q2-3y for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:41 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:36985) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbgz-0001bq-Lh for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:40 -0500 Received: by mail-pl1-x629.google.com with SMTP id be12so4159725plb.4 for ; Thu, 07 Jan 2021 12:15:32 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:30 -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=Dbx3vswVkUZktM/v/IchbClKMtfRLLh1m8Fm+DK5izs=; b=WHuhgjVD7K/qBQT1i19Ra0pb8ysajPuLehee4KKjmRupK7+BtBsG+OIk3jVNtnSFQG 0QQCAp9je59hjYkMGH8cKwFhicT2KI2vwD+KaU+o9eNPaKLYlN+E1KaF3VSXYL16OYxo FabPkA8q/lv3GzIatlOR+gYaJ0xyd4+37Gd7sjtfEvujksUxYeU6Tr0DW8BIVSMgeDTl fXlBVBy20nD/DhCSwxeE0d+FT/mbhwmBUR+DZga0Qj7ochSsofQl4DixqW9+ctOwJslM WpzNbjsULDhoudz43JDhd4dDOxa8lATegPG+vr4ehFYikBSfZ+ABSLjQwzEfW2WoLAsZ 0dJQ== 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=Dbx3vswVkUZktM/v/IchbClKMtfRLLh1m8Fm+DK5izs=; b=JlNRXNQIxAzOzF7C6h/6FnKs4mKXsrdHMeWAf3qTqEWrt6RNCqCyeyv2mzXUxcT4K8 sXbPsTaQfsnEVmG6SKiqvBMk5Y0rx69gydmtCsngX4kFKDufidl+8Yi0PhhMZoEmSWHI pITlG3fQw+g9PaGqvduxhup1JFIvDoBs7BASylaYoyFUyq0pCzO0rLe9vyDnv0vzVIUX VrOUJ1QDt00DlW/82ijuSaEsN01yW5tAmG+TXeVgc37tYxFNqI4ssS4H/HvkSx+JIfhB 2bR1Gur5gC5CXiI5sUfnkMWCuQUjei/mbxptlGceRqek2aH7cqRZ9C6nueMh7QImxT1t Dh6g== X-Gm-Message-State: AOAM533zGCWWmg+1Dmvpm6PltVnAcRu/zHj70R/gv3VUIjSv6qhNwYn1 /2bnZi+NLOOGgTtGRhFNG4r2crmp9K6Xrg== X-Google-Smtp-Source: ABdhPJyTghBJfl5WvsH17L6f9L7i+2s0O+8zCA117R/E15d2Fy1+fFTMi9zP63n6jECKLjdM/Hj8QA== X-Received: by 2002:a17:90a:9f47:: with SMTP id q7mr175132pjv.93.1610050531183; Thu, 07 Jan 2021 12:15:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 22/47] accel/tcg: Support split-wx for linux with memfd Date: Thu, 7 Jan 2021 10:14:23 -1000 Message-Id: <20210107201448.1152301-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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: peter.maydell@linaro.org, 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" 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. Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- 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 022f9c743d..3b6804578d 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 Wed Jun 26 08:00:55 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=1610051679; cv=none; d=zohomail.com; s=zohoarc; b=cKUDIDmEfG7hKyh18XcxRPcj+mwJuvldyiq2wzHOYyaW2VlepVZWxvkxGmRyObE/kPFZOPXJq0KTw+J4Y/nzcolK/ozLjv+k95WU/dhhU0YFlKnFOBGSeuXMRh82n+IO7e2QA/NUR2tHQYz+RL9V/Q7C9xVIBn8HkOARmt5n8G4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051679; 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=qgYqS6tOZzMDkyU6hbsvYTQLjO0dALugPDUkQ7apIPE=; b=lw2eee1HUrK3Xi1OWuMKn96jZHYk++J1FcqfqCELrSYdzBOVcxh7EBseczGMXhg7So7K/YZ/CUIPOpuI+Kr0EVkovSXGpAF/EBknwRYvBddv84kmMxAzfdrNBvApIrscqATfBQkoowW5rVOfleBeTuM5jl4JYhGk0h7nwCadjOg= 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 1610051679852406.33035553167747; Thu, 7 Jan 2021 12:34:39 -0800 (PST) Received: from localhost ([::1]:45578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbzS-0007QY-PQ for importer@patchew.org; Thu, 07 Jan 2021 15:34:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh6-0001Pb-Mw for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:41 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:46958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbh0-0001d7-FG for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:40 -0500 Received: by mail-pl1-x62b.google.com with SMTP id v3so4137894plz.13 for ; Thu, 07 Jan 2021 12:15:34 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:32 -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=qgYqS6tOZzMDkyU6hbsvYTQLjO0dALugPDUkQ7apIPE=; b=XdIvH3/67mjY96bfvCKMUT7RJPb6di9MwRX9V0XaIgj5Ii64zgTg0qotlcZhQiVeul FAjjrHBdPfiOjieHjzel31gLxzyQABM7gX4XR1VAUpeuEcl8Mx3pHjDbyw7fCez/ZGQz 5qPgPDR2yIiZegeny2GXbuOFOuH2QG9CPkSn4QD/hSkp9NblGq9FoBQL8iBh7M0AlCOf zmll1vNw8WM5TQ6sGKxE+CReo+6rXDk2Xo7GEL0+lUaA/LKdDF4xuXfF63ACSMvD8+UC ULpS7Pv/lz8xWMx7cokRd709U5il2Krp3SKspLOfnPL5dmiyXSjpNGK5TnfxjgE7r61g KQlw== 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=qgYqS6tOZzMDkyU6hbsvYTQLjO0dALugPDUkQ7apIPE=; b=Y1gAZ4d40g6OCNgdX+EH7iQO73MJkWytKJuaqOV+AR3qLrbEYdix8rBBlba85ZWm53 XGapKyQ6b6mL2cMCg8sU7y2jxHBNZUE4AFJayIvQ/GSHETpZdOYUH704MPbpC/2jvL0T V8WVOgIPB8E4C85qhqBoD95s6tj2N3KLBF6YvQehsvS+480nr9iMGeZex/dSzILEc243 8YrO/3cZ3dHngzdg27maceoRQuGaklu2wG0SaS2BQUg6hhHYpHmggdQDWc8SBD4vB5ow x0Kmlo/GXKLuKEb6e54bgx2T6acRe6d0PzGSckgvpWDHvYKrpJEvrVqEl8Xdpr7I6KE6 UM+g== X-Gm-Message-State: AOAM532yBhbHiByuoRHysOPezo12E/QHsF6NugX5HJgjxDeKkScnGi0K 4Mn0+8Gi1TL/qsEwXLOkxSV8a61iP7ZFlQ== X-Google-Smtp-Source: ABdhPJyfvaEwJ7vKsyCX/Xw/iZpSm2xECBymAS4boMrxszyFqpjkG4oblwa29rIZMWexEpdkwVwLMQ== X-Received: by 2002:a17:90a:f683:: with SMTP id cl3mr194601pjb.136.1610050532842; Thu, 07 Jan 2021 12:15:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 23/47] accel/tcg: Support split-wx for darwin/iOS with vm_remap Date: Thu, 7 Jan 2021 10:14:24 -1000 Message-Id: <20210107201448.1152301-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: peter.maydell@linaro.org, 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 | 67 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 3b6804578d..c37718db4d 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,11 @@ static bool alloc_code_gen_buffer(size_t size, int s= plitwx, 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). */ + if (!splitwx) { + flags |=3D MAP_JIT; + } #endif =20 return alloc_code_gen_buffer_anon(size, prot, flags, errp); --=20 2.25.1 From nobody Wed Jun 26 08:00:55 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=1610051500; cv=none; d=zohomail.com; s=zohoarc; b=Vh9B9vxQB9YkTHIiq1b+QbCXMPhVjUU4ALy/FWlaM3vqbXVr1hAMq6IJDcQw3RGrD22E2M+pksh222hiCtjbDKFthzzu/rx6kWuGkt7AQlMqsCQPJPtedIn57W3OuI5zt9CNcjaFbBtdT1osXdati39yM2nvlqTTXCdEs9BQR2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051500; 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=mXWHgXR1rPfUzE1DKblo9sXuzDnTJrCai9FRrekni9s=; b=D7vR/zGAdwk+8i9OmLDrhwVsUHu7VUblUs6G7q3TNXKcmsomO3IwR6BlXkbDngJHtlvJusnyFYxHYJmzBISITSq+VfUnoV2sDLsfLTRbQGJn92MSs9GsN31EslUhDt9f0/edCgSKHLxogU83QeB4p1XsQAgoHl4PArzd8Tnxj8Q= 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 1610051500895549.8157664861473; Thu, 7 Jan 2021 12:31:40 -0800 (PST) Received: from localhost ([::1]:37258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbwZ-0003sZ-QO for importer@patchew.org; Thu, 07 Jan 2021 15:31:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh5-0001My-Ni for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:39 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:35542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbh2-0001eM-4e for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:39 -0500 Received: by mail-pf1-x432.google.com with SMTP id c79so4568731pfc.2 for ; Thu, 07 Jan 2021 12:15:35 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:33 -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=mXWHgXR1rPfUzE1DKblo9sXuzDnTJrCai9FRrekni9s=; b=EErs6906kvld8FM8W274jv0PmgycNKG2n94Mqx0krDWl3v8y+s2ZEfDcRoY9ezom3u Vk9sWAsLYJJFpRraWe5T6NKaqhYm171VhSWTWxyNBllJxeVyeKgWwnSziLiX3tSnMN7L /LNDWQ2DNTXaI6n1b9aXAI++ZjhuVxUHxujhTer3N+wimu5QvVTVLKQ+T558yAnMA9R0 EHItjM/1YDmHC7f7XNgb/6zLaljXhOr66N6zjEH64/OwsyW+Zx/nuoPgvoCkpnYlNJMQ o4E1vLQON4RanQ0G6bTs9A3v+Ku9d6CKWWC39fAVe04D59BnhIdJjENQY0nIoeQUEfyR GjJw== 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=mXWHgXR1rPfUzE1DKblo9sXuzDnTJrCai9FRrekni9s=; b=ImeSKLXji7iZHw9ooml1P10vHfCNiVqXajSFFZA+GHRtyKdYYU7nCSzdfgIeAkPKlt DKDAtlUFNsie5p/y4F/CDpS9deJA9MwcystRFRjCKAGZP/crmgVdm8W9nQH//WvGvUsa Z1n8yfLD2miz4VhQLD95wLcd5yV1xEfDbX2hqASerpZNrNj00SQnyPTtUwwF/10b5Gq/ 8RTaVtlHp81faKmgYM6L7zZhz9D1n8s8wxbvLRG/VRoWDmTaevhoDnyv7Y4v835/tYpI u+WpsZNlXi/5OBU77vVTeV5D5LOd5zWPb/AIvfHsNiYmedSMPN+K4D8xqY3oKs13SAhU nNLg== X-Gm-Message-State: AOAM530/DEy8iYjel/6FfPaQOM9MXlqp11MDABG8iVVDhlv5uLF5dyeI MfFImEdHAzZyXlP7ZXcNLDj+nCg9xmOK/Q== X-Google-Smtp-Source: ABdhPJx09j8DsP27X/tJBBgKgKuXZxLF/w4wyZP9WsY3aHyfz3QMxAFqzRsrnj+M8vYwsqbf48EWUw== X-Received: by 2002:a62:8fca:0:b029:1a9:39bc:ed37 with SMTP id n193-20020a628fca0000b02901a939bced37mr310446pfd.61.1610050534445; Thu, 07 Jan 2021 12:15:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 24/47] tcg: Return the TB pointer from the rx region from exit_tb Date: Thu, 7 Jan 2021 10:14:25 -1000 Message-Id: <20210107201448.1152301-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.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: peter.maydell@linaro.org, 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" This produces a small pc-relative displacement within the generated code to the TB structure that preceeds it. Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 35 +++++++++++++++++++++-------------- tcg/tcg-op.c | 13 ++++++++++++- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 29294f2804..e0df9b6a1d 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -154,13 +154,12 @@ static void init_delay_params(SyncClocks *sc, const C= PUState *cpu) * TCG is not considered a security-sensitive part of QEMU so this does not * affect the impact of CFI in environment with high security requirements */ -QEMU_DISABLE_CFI -static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock= *itb) +static inline TranslationBlock * QEMU_DISABLE_CFI +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, @@ -188,11 +187,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. @@ -210,7 +218,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 @@ -221,6 +229,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; @@ -238,7 +247,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); @@ -272,6 +281,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(); @@ -288,7 +298,7 @@ void cpu_exec_step_atomic(CPUState *cpu) 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); cpu_exec_exit(cpu); } else { /* @@ -684,13 +694,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 19fa8e4691..0374b5d56d 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 Wed Jun 26 08:00:55 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=1610051973; cv=none; d=zohomail.com; s=zohoarc; b=iSakIODIkXsUssN8IrjlUwR+q+VQpIEV4UgyIg6fY0buMJb+0t0npv+6rsqm/c8Ke0cB0nawtqZaYwvmHWSso0VuGc3TwGLfO13GL8GFJ/JAs/UKyM3SS7XuVlYK85FUxJ4k68LRRkvuO4WsjXSt3KSWDbyMja+RagmgWHK6kiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051973; 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=5vS8wJ/iNPyRl3pgmKuFkCd5a4WmbW3WD3BdbgSErfg=; b=jSUYOEBLJYUVT/+iCJMgjv7QbYf6L4ZEqRtiMB2voLQJIEETST7ZZyodKdkjpKNAeHbdowNAbt92BgF6qBZwLANvJtqLQTDhPVnMM76OtsTAqRbS8NGX/p2FYlYU3Y95rdhJYfv4R5H6X3YhO/nuY4EV0YVj5/GbzlDlVuplTR4= 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 1610051973498442.32421234762603; Thu, 7 Jan 2021 12:39:33 -0800 (PST) Received: from localhost ([::1]:35240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc4A-0006r5-Dc for importer@patchew.org; Thu, 07 Jan 2021 15:39:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh6-0001Nt-61 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:40 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:36164) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbh3-0001ea-N4 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:39 -0500 Received: by mail-pl1-x636.google.com with SMTP id j1so4165206pld.3 for ; Thu, 07 Jan 2021 12:15:37 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:35 -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=5vS8wJ/iNPyRl3pgmKuFkCd5a4WmbW3WD3BdbgSErfg=; b=iSfwg+owDfwgoLHj9v6crVpM3LXFewuxozctCyLg4vC2uir/Hq/Usk4vPtb+rWo2Pe SNCpU7i+3CIWHu9Klt/bYvSog0vTI/C0Ga0zKAcqwIDv9QfummrgyKYPuQsI8ldFZZUK JouM+Y0JDVTXCNpfERVSGTgXikP5pes5q6h8JYlfd3bMCzHZYGgPlg1VFgme9qzUG2vH RrRnCnehw941d06ad0CCYqPH84BPWxT6PZ9orCqSOpuQqgGLAThWZ5F1bsqc+bE3oYtw w6xdIpzKHv1qZB2iswqQoH9mcrWOx2QircArcU7/XrXFJX+/eFV2m6IgBQf5av8GOqI/ kdxA== 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=5vS8wJ/iNPyRl3pgmKuFkCd5a4WmbW3WD3BdbgSErfg=; b=ks7LklHnouKO1MwNC/qyv9z/HvuHihZGu0qKHa9R1JO5NLeih4F37pEcvE+mgWqbYN eHrlhqfn0fy0uSzlevHZYQO5SVoDhfg+/492AmfFuEO/t8+uMC0SmJkgcU1E1dhFy7qC k02Y4wbpiuwC5xj+/IMtsMleU6mJqoWyRHmLIbgJpe5tBd0XWwVkKtBtvo8mjXC06hnF EK8uQ4nuTThimQOnk3Bnp8Enx0n/hDWlpCxexpO0fztF8uzunnx4YXt7s29nnHkrWOMr 2GD0kuAlrJqH2Blq5BEH3wPXTezgz/LMaEwvmKJMzQ2h8cegTG6EoltNUUcV1lZIkKgL 9LMQ== X-Gm-Message-State: AOAM533YG9JEHxkS4IkcMoSaauQJlmCSuPkkZ5V55UW37AYi2/PWFZXa H5vDBOC00vbglVqS/P7hs8pBy4omUvgq+Q== X-Google-Smtp-Source: ABdhPJwOl7yu98TJM+J/xcumW2DeoF8OIYumqjGJJiR3FQSlplZp0dDZ2kgrPmSlxRTHx/OmHldWTg== X-Received: by 2002:a17:902:854b:b029:db:c725:edcd with SMTP id d11-20020a170902854bb02900dbc725edcdmr534548plo.64.1610050536144; Thu, 07 Jan 2021 12:15:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 25/47] tcg/i386: Support split-wx code generation Date: Thu, 7 Jan 2021 10:14:26 -1000 Message-Id: <20210107201448.1152301-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: peter.maydell@linaro.org, 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" Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- 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 73aa45a665..cb1b138b66 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -235,6 +235,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 d272975ff1..34bf0b9a35 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -164,7 +164,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) @@ -172,7 +172,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; } @@ -181,7 +181,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; } @@ -1015,7 +1015,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); @@ -1624,7 +1624,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); } @@ -1795,7 +1795,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]; @@ -2253,7 +2254,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); } @@ -3803,11 +3804,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 Wed Jun 26 08:00:55 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=1610052125; cv=none; d=zohomail.com; s=zohoarc; b=dI+YbnCrxG4bQOMm7VpHc/Nwvtm5HWEtjF8ClvXqo9x4CDm1+Y6+R1x+3ryb4b9Y7+By//8CMB4ea59cdv+4y8DcY24zSV1zEZo+bTBZXFoGoOa9xGOmTUVgf9srJzj6nxuH5vBBUyRQ1iHQ0CRT6DHIv9SdIFjCkoVLcY6Ik7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052125; 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=8LKGM21omgiw4s8pLH3F/GfWnbD4CM5oKLWF8kPN/DI=; b=TM1jPZEoKFCB6q28PVaDB/vXHZaKME68A7EaX3UE5H9vftCroX2NIaWjxkxxkbvE8hPBUGlsrM+oGYo/CdpwPIBIO1Rq41BsNc52MTsUnC60LZXs3Agr7ycE5mUxeoo/3bs1SYIEIO36Bv4ZRz2oIaYNrC3PO2/6klCuAHUmkIM= 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 1610052125571948.2927458257013; Thu, 7 Jan 2021 12:42:05 -0800 (PST) Received: from localhost ([::1]:42502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc6e-0001af-At for importer@patchew.org; Thu, 07 Jan 2021 15:42:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbh8-0001SF-Ns for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:42 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:33849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbh5-0001ex-Ds for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:42 -0500 Received: by mail-pj1-x102f.google.com with SMTP id n3so4520168pjm.1 for ; Thu, 07 Jan 2021 12:15:38 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:37 -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=8LKGM21omgiw4s8pLH3F/GfWnbD4CM5oKLWF8kPN/DI=; b=w+Cadi1KQHdDgjJRX2UQLdOmf4ewiBf6v7wCbXmfCui05ngrBnB8LNRf26DbtlR9yd u7Paz5g/ujm/3vvLui1nS1E0gifbvPr9zXrF/fzSwEtbpgqzy/Xr6slpDfSBah8a9Hwq doh3KCSGvMHlxrrSbC4QVVEyRSDN38xLOzulc32UJuNpARNLRuwlCoaINTZfJ6lZpYCf eKUZZpZCo5HerXjPpjUt1rRuTAXzWSIatfrR53hr5eej0EL5RQG7UvybxgMQXvC/9xoH L6GIt5veRINjF/8eyNnq+MmHLBOb+wTv90OGQhnnoJ0zEg3os/PZH1UaIlNPM3rbF55p lGRw== 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=8LKGM21omgiw4s8pLH3F/GfWnbD4CM5oKLWF8kPN/DI=; b=WodLDqw4d7OCOqH4xYSfgH0bi3HSULmXfabVYkBZ09EqHkmpssNeAPmueYF9ZuG8RD isEcg9rRYfDTjgYQogjj9+EXXfDLaiGTHN0IkSpo/Og4u74jMxh+qRuYt6SWk3H73cLT QoyhkKfXkpt0MNM5CapkHC8fZOvT3Bv7nbo1JgyNbybxXAzbU8UzPbLKlilQD5Uq1uIK PxRQgJ+2/GcmrhulWkeOdWn6rOINf3okSEgtBuW1jCIYH26ehcagmLQw6c9DwyMaCyGv PLdi9L/cpQnYgUhVEl9LUEfR6D3eqMA3NmQcs8Q/42ylVzyqKDKNSaJjqROoRJ73ks4F uDkg== X-Gm-Message-State: AOAM532+nKxsi6Rbqq/DjsWmX6f73z0FS5oxBLAL3ARckXmQ/W2mynf/ WDjApvZ2XzEPiNQLkb0JST6sGfy8BbMwvg== X-Google-Smtp-Source: ABdhPJwIbZWWZyLPFGL7mGZEmGtzppdnIS/WVca8ew3qTrDOW8BvGVSNHsHxIq3k/Z4+D8KMqva7Lw== X-Received: by 2002:a17:90b:360c:: with SMTP id ml12mr212479pjb.36.1610050537856; Thu, 07 Jan 2021 12:15:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 26/47] tcg/aarch64: Use B not BL for tcg_out_goto_long Date: Thu, 7 Jan 2021 10:14:27 -1000 Message-Id: <20210107201448.1152301-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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: peter.maydell@linaro.org, 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" A typo generated a branch-and-link insn instead of plain branch. Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- 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 Wed Jun 26 08:00:55 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=1610052302; cv=none; d=zohomail.com; s=zohoarc; b=W/kJlWBSa5bz/pHUXpGSipunGAfaeDWNZQd5qp2fq6rZp8ytPXwuL3YKDnNC5qO7P2n5EdpRvsVXGGMi80pJcF698s8cMqWAt2/4f3igQARsKrJlwQFhSj5eNqInk83gaGBogwzsRfsolWX5md6Y/tUZa0qsqrCtWLCZwtGFSxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052302; 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=T8AfGj+HO8ldfN1QyJhTtl82SWRrf2P8eJp7eJUkZZU=; b=KnmqAPlvFcCeHQfMRjg0k2/pVFU48ssfx58QTpyRRC836178EqEL/NG0jliDZuPfjSOOgFJn45Ag6cpF4i0evHPX+mec4NpQEtNMJi/Eg12lMdvQsk2wu7rpvv3tVsc2vctKUiBiLnQrqOFAl0bvRCBUZNx9qQYduivjrW39Wlc= 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 1610052302850242.68427983119398; Thu, 7 Jan 2021 12:45:02 -0800 (PST) Received: from localhost ([::1]:49206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc9S-0004U2-P8 for importer@patchew.org; Thu, 07 Jan 2021 15:44:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhF-0001UD-0N for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:56 -0500 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:41274) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbh7-0001g2-OC for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:48 -0500 Received: by mail-pg1-x533.google.com with SMTP id i7so5738086pgc.8 for ; Thu, 07 Jan 2021 12:15:41 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:39 -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=T8AfGj+HO8ldfN1QyJhTtl82SWRrf2P8eJp7eJUkZZU=; b=QjgmX7zq2eFiWPxY9sHRinmktZNMMoCl9FwfnzOKXria7lfTZz3jGJyMJaQRg0JIf8 ojlWXjD7FECKxnoTFMs8/1kAPHhrKw6c02v55Em09GjOzxfQ595TELOLZeHf1wcBEQsH UFwoHU2H5lQb53YxD5/6GGDjILuQY4keQi1cbpJw0aFZJWdwjxlG/FS4ZTEMv204qms3 0VL/BgvFIUzvK7Kuc+fc827tmEeWzMhcLpfUnC9j2SXdHjthE8hsLV2y77X4PaZT1e6O jKOu2khGCaiHdOCQu+bSU8RCa2fv/Bqj6VPaj23xw3hRJNL2xZHDpl6u61gQqyYMofpG 7hPA== 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=T8AfGj+HO8ldfN1QyJhTtl82SWRrf2P8eJp7eJUkZZU=; b=fj8OE12z16B0MuW5XvHMPEaWXtznGndgR0jh5aa/HIP15YbiqBBphO2TpVaenQoGdj +IZXkoMXofPSB8WlEOBUB6kssojG2X7mT0+jypu6BkgDL1gXtAfcgeUY91wwHdqpTMrK ZhR63a0NS3JG5xEWD+mt+3e2Dnkj5w3hcOtaYIgJc3QNXt62jFWGCE/fiBHWH8Zpkpkd EywYCDOPQ8qoRWTGB+pcDnS4kbojLG8DJl6yJ9F5KZ2nxgW24xwiAwmv12pRptxLgctd iELRd7TmOCdH2pZIqLjhba+tGf2C0j8Yr+/Zk+u/zaIRLjeISsYOtfghXGybJRlVhahM OQdA== X-Gm-Message-State: AOAM530As9QttoUBxo7Vm/L/cX2yw7sne2QfL/OUfT1BP/kPaLiQfEox PnN8BqHnbS08msq/cW0yO5euzn0PsFj/UA== X-Google-Smtp-Source: ABdhPJxyEZS9R+yK71TQ4UUkXtE1BjRzDDYFBb1sDImastdBPWFN05Zl6zC6rb6tuGhD+edbVgBwyw== X-Received: by 2002:aa7:9f1d:0:b029:1ad:2aaa:c1e3 with SMTP id g29-20020aa79f1d0000b02901ad2aaac1e3mr299722pfr.75.1610050539567; Thu, 07 Jan 2021 12:15:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 27/47] tcg/aarch64: Support split-wx code generation Date: Thu, 7 Jan 2021 10:14:28 -1000 Message-Id: <20210107201448.1152301-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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: peter.maydell@linaro.org, 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" Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- 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 23bf87db3d..079828ea71 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -155,6 +155,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 Wed Jun 26 08:00:55 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=1610052459; cv=none; d=zohomail.com; s=zohoarc; b=Jqm+trO4NxwjZM4HHO044SMdgAtJ3sxOs054FQBdpg0iMru/kSXFT3sIGA5P166jI7T2Jz6kiobnfkurcz96fiTtH4dgxSoSntPVUK5NqwvtryenuiaInoy6o3e0cCgBsaM9lBhTh1PwFHRc/xM4dhC8pyFRjbkxViJGJo3y2u0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052459; 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=MOmUYS+2+okyDd2n7XwYqRe+eURAl58gvEsSNOVb+48=; b=QbBTISYTn1JMEi+ieNuDR4TzJA0QKJ4YdxcPWjiy4CJRuw7IdN4wPJEpeI7AaKt/mjGldymRtuXsrBTXiqvDLTSyTa0bUdtV700W3ivs+O0pj6APpHFaiLoyGO8/CIWznQ0B5VVloDP9gBm3Fy1wgX+zcPKsROMU/7XTLHpbEmY= 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 1610052459720936.7048588325038; Thu, 7 Jan 2021 12:47:39 -0800 (PST) Received: from localhost ([::1]:55940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxcC2-0007Wz-IJ for importer@patchew.org; Thu, 07 Jan 2021 15:47:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhK-0001Uj-TR for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:02 -0500 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:39493) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbh9-0001gB-6r for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:53 -0500 Received: by mail-pg1-x530.google.com with SMTP id 30so5744002pgr.6 for ; Thu, 07 Jan 2021 12:15:42 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:41 -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=MOmUYS+2+okyDd2n7XwYqRe+eURAl58gvEsSNOVb+48=; b=TchH5REwXL7vOanvz6c8rxbFqQITTdLtJSQ+wyLl3u1q4NGr26m2wYZi4wxA/MGELH rw3d4t8c7j7P+V99LpbsllyGBSz/bRfbxaEhhey4q/iAwNMFjZ+LLdkEh++fgI+P/D/t yewlJ3zjvoq6uovGnZfJYd0QZ/WGkdjsgE6gFp0qTPxc4KhnuYkG7WBV1FD88SgWV0Jg mCBerGM/j3yl2TVp3hpkjVFl0hAlb9yU8v3hN5VHhlOEXPy39p2biEVBjhCbJz/g14/3 y4ZXRVsj3rARY8XELosCvAsFCS+RLyNJwnxqFF9w6MC6k2EmcLjiRacKihvH53lBr+Bm cQ9A== 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=MOmUYS+2+okyDd2n7XwYqRe+eURAl58gvEsSNOVb+48=; b=UioZuIqLvJe6a2D8nixd0lt4HVWgGTi5rVk8iQlgk+gUvCpdLgqiu5HbIrFO9KYiFb 6lGZAqzU5gMBTiZYHA84Q2wIBfi2XPmIG/GXYSbmXtOS1yUyhiPYPFwo0nj4eOQFIZFn K64qu3Sr/r63EyqixXl/OpBDD65Ao0c6sl9+f5XXxn0VKWnwmnOP9yXEUZw9G/aQrxEz snXY1P2W6Z4pGzMyc8AvvrjKFRKB8lDg9lElRFE4yzA2J0MlHoD1xFBIPAHF67dKvfNm nn3mV4R+edxaFq5fpYiw0YNWMNtl6t3aMezvwqxV8gJeXs8h05++fuUdwAM9AB7B7qPU aPIQ== X-Gm-Message-State: AOAM531CDtd8gTO2gCBYmyFqpPk99ZMWFUOP4uYasPYcnuw2z/A3dK2h uL0SouNlwd7wjBjZHcWDzpaMtFYXsVNrAQ== X-Google-Smtp-Source: ABdhPJxnC6lOGWrVkm337UE5m0opoFIpMOyhVMV+IApSd7mHEXtL5DgYFVdg/y2jTQVeswm7SpUh4A== X-Received: by 2002:aa7:8f35:0:b029:19b:1258:ec5d with SMTP id y21-20020aa78f350000b029019b1258ec5dmr3611580pfr.9.1610050541620; Thu, 07 Jan 2021 12:15:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 28/47] disas: Push const down through host disassembly Date: Thu, 7 Jan 2021 10:14:29 -1000 Message-Id: <20210107201448.1152301-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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=unavailable 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: peter.maydell@linaro.org, Joelle van Dyne , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- 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 Wed Jun 26 08:00:55 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=1610051944; cv=none; d=zohomail.com; s=zohoarc; b=KRIFh3k2rO3gHogLhDe2cE8NlF4/+IkhV3kGD9u2QdpCgIqiMQa3A5lClU/5hccOUniXWdCE1uZMCvGQ/xzcge0eSRg4q/CJeb+O3PmxQPAJ7+HFEkMm4bd8Rej77IAvLlbDQQQYJCwKSRyJUEz+SOa9J/RyK7L/R52464peWTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051944; 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=AJQYK8LKfTzhiujiEv/x9kE4WE8MnmVirj6n1IdQE8k=; b=MoYWM2ibALoXJYKPb6lz4kVBaL7ic/7p6nziAQwWRQDBF4kTFZi+Agx3NrVPXZ5tn3UQRLfsvdPt/CIHtA6+qp8Jo5Tk5RcCPsLmARt1JZx8+2pbpxQNfbq3FVj5BTEQEPlkFSj5Fzqdp4DtS3I4+f16zogFqTO4gntRCdaoGho= 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 1610051944421918.4683712348199; Thu, 7 Jan 2021 12:39:04 -0800 (PST) Received: from localhost ([::1]:33480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc3j-000680-BN for importer@patchew.org; Thu, 07 Jan 2021 15:39:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhS-0001W3-CE for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:03 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:43439) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhC-0001gK-Rt for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:02 -0500 Received: by mail-pl1-x62f.google.com with SMTP id x12so4144643plr.10 for ; Thu, 07 Jan 2021 12:15:44 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:42 -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=AJQYK8LKfTzhiujiEv/x9kE4WE8MnmVirj6n1IdQE8k=; b=oYgkaGUj4DjWATq4agAPN/g3www0/eM2cvpGQwrMS1lA/4HgQtcWZeCIeq9moiiM5M 7YLWWYgu+15H6akT9Sl3ZNTv8a2CVrYdPR1ajgmrgbYNlBNmeFl54n3ADKQWbL3qk6/s 2cszoqGLKEZUHLpYTrvWx4m2WmBuX+UMvd7bkUW5toNei4L+OqTO3/TMNWVm0xDH1dIP JcMw5xeAONYSDDmviZ9I8jO/5/+4W/YDMytyPA0CIsUTGtBTYaG0T9NDQbkUjypE1j3g oLP+7usT/JLu1Y7PGgsxhUfLdR8oQExqcxR9nsZmUgG8PdNBaKVxYa0m7+sTUVylcYvM WWFg== 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=AJQYK8LKfTzhiujiEv/x9kE4WE8MnmVirj6n1IdQE8k=; b=UJDHFUev13RnsywUZB9uOTSgtD3LcyDBQzdAy23u2j0M1fri3xMHlGhQErvP3GF9Yc YGmvgyY/82rthc+9/oaJsBYSJTL8AD3pW9yUNDEDenW/M9W89GAl7/LfeZobj7sRQdcO zzqJVvLNW9XOpjidCuCsLsiP95dPRGjBvaZ0hejeJhvFYTucnXcvK7KDT0jFqvvwgYNR qQhbL0EGKZN2Y6MVV/AbfXWrqYa00Mpi0UUc1Pg3Lfg9j5QhKeayvgq8lEBtzqznTKii oAyp+FatM+GhHUOrDOcF9pJCKU/Ebl5CADKban/xHKLHDRs0tgTFen8XqrQ1jM4J9xL/ DrQQ== X-Gm-Message-State: AOAM531t0G2AF8gHxSQtknidy5r53hTBR2E1dE5o+QoUEn41LjH0oLP8 Ar/pqAr9z6CsxbTmCiWVloCimSCMm7zlJw== X-Google-Smtp-Source: ABdhPJwSz3Xvma7woDFVlMzgr+5v1jPSavsreVqKKlzyEbW+t19r/6HTcc26A7K8A9/elMVJr6urcw== X-Received: by 2002:a17:90a:1057:: with SMTP id y23mr166356pjd.97.1610050543339; Thu, 07 Jan 2021 12:15:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 29/47] tcg/tci: Push const down through bytecode reading Date: Thu, 7 Jan 2021 10:14:30 -1000 Message-Id: <20210107201448.1152301-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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: peter.maydell@linaro.org, Joelle van Dyne , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/tci.c | 60 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/tcg/tci.c b/tcg/tci.c index 017887bbc9..2bcc4409be 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -164,34 +164,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; } @@ -199,7 +199,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; @@ -207,7 +207,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; @@ -216,7 +216,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; @@ -225,7 +225,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; @@ -234,7 +235,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; @@ -243,7 +245,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; @@ -252,14 +255,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; @@ -267,7 +272,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; @@ -277,7 +283,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 @@ -288,7 +294,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; @@ -302,7 +308,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; @@ -317,14 +324,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; @@ -338,7 +347,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); @@ -484,8 +493,7 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCG= Cond condition) uintptr_t QEMU_DISABLE_CFI 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); @@ -499,7 +507,7 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchStat= e *env, 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 Wed Jun 26 08:00:55 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=1610051818; cv=none; d=zohomail.com; s=zohoarc; b=HJs+9dz38fJaVrWmeTS7tcBz5McINEV+iIKRr3vkhH5rd4BVWOxBRXyJ5XNytM0CqOiYsKx7A8CT3xbSPzDDDFQwRX/JtQiuyXTykqJQbvjMbMuouifLottXqXLjbLYp/msFLF8CZKoRoTpHf4yHMHM0LvNfvYRj8RcRkuYkRzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051818; 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=1C9DAauAp7ESr+w+Jngt35D1tFX2Zjw12yc74O3Eyt0=; b=PSKkYL1T1zXpCrwW4qovqjtxwoPK8HytoCTzkfPu1gwalg1ekDGhsRuxI08ZChKVowXUW37ueVCNRMgNex/PI5SyMz0YNLamHEZ5TMySSQLVs5qtNMTmymDCNbuqZChRCz+XXXtJgLzplLSOSj6hDenIV7R5X84CzVNxv7P/wRo= 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 1610051818249654.1605292216362; Thu, 7 Jan 2021 12:36:58 -0800 (PST) Received: from localhost ([::1]:53974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc1g-0002m4-Vo for importer@patchew.org; Thu, 07 Jan 2021 15:36:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhR-0001VO-1z for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:02 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:44498) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhE-0001gO-Re for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:15:54 -0500 Received: by mail-pl1-x62e.google.com with SMTP id r4so4140502pls.11 for ; Thu, 07 Jan 2021 12:15:46 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:44 -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=1C9DAauAp7ESr+w+Jngt35D1tFX2Zjw12yc74O3Eyt0=; b=JbL+zwzBpEjWHm+q88jSzggyZVvivBjFJ4/DPrh79pZb9YeyFjDH2fnWiHiihqYgT3 Grjye7O7ZEG9ofQh9kQvCK5DScFl2u5BNtDgfLfUkCQ63xVA+Uqc1Lcx62kuv0TLg4Uj Z2m9i7RKtHEkTPU2L5bTcIqabSr1PnmptOGt/fJQPDJyTxG5x3zvkDcdErCvvnSEddVu rLD3k8QooflCltJKbxIMDpx096bMi3FYdXuAxwZxR7lRlm0eLUDrfBOcnosmjFkNLOrA YmxYtuIEf2InBggn2lZ5yxjCxkDr6WeNVNzPQ0bqCIKnhQzdX2fL2wbdzMOhrkHzAXr0 /7UA== 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=1C9DAauAp7ESr+w+Jngt35D1tFX2Zjw12yc74O3Eyt0=; b=KzT/xrpHTDtdX5IbqkvfVQyKEm9VwQ8Fn6Egvk3UD1waNNe3we5f2Vic1QI4/Ks627 f7P+CHNKw6PAnuYLE84kbBLoOFV/2Q8f5CjoGsNu9N6j+9BnBN4xkVLXrcL7+pdvmJjF a2FLII6img21srlyCl+5Suh7IuEpk0aIljraeHCslkcCUTr1w65J8QsZREAsjJ55zDvm UmIiV0FgM82cSocK1Ov+UjvVgEsueIH7dUh+NK7/kgBi/CYZYztmIJj7Y56hA97B0Wsb biFlgv6GblPExZtuEbejA01jkzuHj9yBWtffmrEWXp9/44n7MnkqAvgDXtHQ1r2APFYz l5xA== X-Gm-Message-State: AOAM530Lfqi6SMQ5+2RhrMnBdC1l20DopNvM/xWaUKe88Mjh8CfuoOoF OML+wxcbXxA6tr7VUieEwwPQHMu1G7FcQQ== X-Google-Smtp-Source: ABdhPJwfb5u8UMtoi/pN5pEW32Yz4eLUqcN4JCZ8OQgzVEYnHmepQXrfKxFYZzDr63PwLRxu9FnVHw== X-Received: by 2002:a17:90a:bf05:: with SMTP id c5mr166021pjs.95.1610050544925; Thu, 07 Jan 2021 12:15:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 30/47] tcg: Introduce tcg_tbrel_diff Date: Thu, 7 Jan 2021 10:14:31 -1000 Message-Id: <20210107201448.1152301-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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: peter.maydell@linaro.org, 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" Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index e744a1ce02..e6fce9a049 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -1146,6 +1146,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 Wed Jun 26 08:00:55 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=1610051943; cv=none; d=zohomail.com; s=zohoarc; b=Cu3RAVZM9kFu4e3Gn8LzgJieMfps6eHw7WmDmzgum8TAkIbg0rauxZJJNeTrEXLqlgwUNsnUdQPf53GbixANgYzf2jx77auQplYeVipp8KDlTFUImPYCfqlltITKIjn+FPFQw102qtWrj9SzIIgz3oqsNclfSaO0uiKgEsQlLqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051943; 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=qay0jNTmpyZq4ULzg3vkr0em7pJVaOqPAuzaBx5paoU=; b=A6lJZYV7KVAxpy/qVHUq3qnQwCjD3nugIf9gpT2WbE0CQebJbh94EG9qHsRNyYVFVdcGjjPEegrSR8WfZoVw5tqOz3iofSqSQX3BqEi5WnNMel/8R/kAExZTpxM25wShsdSaNp4aH0WlqpXxbRxveEu9r8J4l1zhWVGZz9oZZrA= 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 1610051943760257.91776949604764; Thu, 7 Jan 2021 12:39:03 -0800 (PST) Received: from localhost ([::1]:33436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc3i-00066z-MQ for importer@patchew.org; Thu, 07 Jan 2021 15:39:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhW-0001XU-4a for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:06 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:40025) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhE-0001gT-Rr for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:03 -0500 Received: by mail-pl1-x630.google.com with SMTP id q4so4154306plr.7 for ; Thu, 07 Jan 2021 12:15:47 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:46 -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=qay0jNTmpyZq4ULzg3vkr0em7pJVaOqPAuzaBx5paoU=; b=j4k7cODbUlVvQ57DiYLgTqp2bcvpN+C+0KnuW8UCb+C/svfe3m9L7eyoWteQYQySZ1 2rv8KXr2nxCirPDDrM1leGwtgTlQ6e0UQfbFDH5dtu1yLtyVww7hwMK0ksNaGcIVBije 0GrNjHLwVJSNKuMj2N0KMvBB/jky0xygnccjx2cbSSfEH34yrS2zGvMiGUAk+ZiXwpyw qxc85AijBIVDUOf/BehJs39QnmrGqCA9+rKZTAAeV3ipM3gYGnjJD8Ho+/rgTExKheg/ 0vSRmOxlj5N4UHCmTYrkcyNe/nG4QMspPI22kaYHUCRgUswnDGLMoh3amtKR5uIQqRUU Jv3A== 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=qay0jNTmpyZq4ULzg3vkr0em7pJVaOqPAuzaBx5paoU=; b=bpEAHK8+BL3hpT3Z1DwIfKNoA9/+D/e5ZaRn1TuWcu11mUXiHNER+6GVORjTYqzNwO qiL7j18ZI4S2wnqho/uyvAyrMV24v1xtQr88nrfDbxg1ZpCncQIN7LtpaKkF/Zq7WWR2 8iYLwY5/N0i5vIeEihkLK+bF2lYQH5z9VUM3DYxJPV+IOQForKURxJNCwRyeeboKmnMo tmEfIqvvgMTJduzqSUG+ojuZ7H3Txm/z05AgTJgMpGmJF0OVNOC2TXAx/Gb3KtgnoEKq Drw1zBoUNqw+qM+HzRAyojQsOWPlYrP5xtd/O4tul4fl2jqXMoMmxhg9j7E7DpZUIBMW ipQg== X-Gm-Message-State: AOAM531p3MUyyGoiEpeX8TmQesKWnODGLvrUtyfEUQ9Pm21EV/8q/cAm wgcD404M+C2djpDm6D4JyfXjbqa/rnPIlQ== X-Google-Smtp-Source: ABdhPJzb+Ji2n0vbVBnAATMic2zp687AwxbAT6KlNVhqM6Q3pFmPXrklLTRlTEEBNc9g8RSUtVsx5Q== X-Received: by 2002:a17:90a:e60d:: with SMTP id j13mr211559pjy.52.1610050546543; Thu, 07 Jan 2021 12:15:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 31/47] tcg/ppc: Use tcg_tbrel_diff Date: Thu, 7 Jan 2021 10:14:32 -1000 Message-Id: <20210107201448.1152301-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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=unavailable 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: peter.maydell@linaro.org 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 Wed Jun 26 08:00:55 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=1610052269; cv=none; d=zohomail.com; s=zohoarc; b=JcEKq5PRY4bG+T39d/IssRxebgv+2rJbE/K7xXXkaEzV7VNiMQteje1GITE9yg1rEjrNO/qdhdcCLBSvyVLSC/7wskHG9ULBHA0+yI0f7VGcPJwWWfJlYxCmXqML1+Oa2e2Gd00ZASdDjvUmG9WIjCqGFh9q9xf7VYYDvAmcpmY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052269; 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=ASquR/6BxZoSVQzDtOnOXOHE8jLTrkcyVCDT0iJkP14=; b=OpW+5FvW2+/VhhRm66JeQ+BpL1DX3AjXTQhZFk8t9Q9hsaseqgqbUFcADCdoUE5IJ/X+6THLBAYPTjXnlgE3xGXpYiySU6PCzUTiLg9RafgCaLzZ2mQrIJ3sGT3LLGuG/iMrUvR3jRU3NZXVXwB653yC+PTXzZZmlC2v237sPXk= 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 1610052269987126.31808386130467; Thu, 7 Jan 2021 12:44:29 -0800 (PST) Received: from localhost ([::1]:47280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc8w-0003gG-Tn for importer@patchew.org; Thu, 07 Jan 2021 15:44:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhW-0001XT-4z for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:06 -0500 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:37749) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhH-0001gX-VI for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:04 -0500 Received: by mail-pj1-x102a.google.com with SMTP id b5so4478212pjk.2 for ; Thu, 07 Jan 2021 12:15:49 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:47 -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=ASquR/6BxZoSVQzDtOnOXOHE8jLTrkcyVCDT0iJkP14=; b=hKm8O3voMxOeTDRXQ1qGghTB1XF7uPK1sETisjiocPsdJOW/mlyaPxQAjoHnXrdaQW wH1agmPELIJlv5iI6211+jidbPHmZ78NRZ6VI5gKGzJnLm6s1F7EB+U/Ziw7Or+t1o64 D3AGNrgLCpavHZzCfw369Sz3aLueRKM74KCF+dYEpahANX4UfPJIjQgl45DIR7hXV50z iXAy2wcPJ/d0+xHuG9Lpw84D7Hvb2A+T+NpHdJcnejnnLRtb09Nv31EQmXCZUfZ1uRwM Y88JX4NBw5nB2X7i04c5WUr3Y+iq2TYYWryi41fCtCwRAm70hymWS8z5yDSNGTHz/G7Y M+QA== 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=ASquR/6BxZoSVQzDtOnOXOHE8jLTrkcyVCDT0iJkP14=; b=E3781D5m7RaAGEvpQmvW6kCuTnUWaIzHxHb08WMfaKKF8x3mBUxrB5BRNDSxJyIsyb QQYRZVmqEwzlpKltXY8HYwVUPRawOv0QyAjqT93+Pd+o9zYspqU0eOb0S/hyTXuN+eBg 0PDxNSMY24PhY2Vq4fI7ByzqXB+gnO2lQsjRfmWwmpnl3w18UsK4TMWhFLwISfQ/F4Mp rrgD8Yb4rZcoaNE3hpI0ulWctTRdCwlVIlqq0tniOpODQbEbZ1lpAVQNQyVrwhziMM9a 0j3SiarBCdSSEXLZ5G963Z9hboZDxTAgKd1AwcCu7UEQiqUml1M21p8dNxPXLaPJraSf 51Fw== X-Gm-Message-State: AOAM533nE2+j2esPOJvnDff83Xz839yy/VON15KhmDZzp9Qcc/lwPeFy 4cLPteEpdrkkoNcrTjMkAXoQdbatE791NA== X-Google-Smtp-Source: ABdhPJzwvk2pNvxsS15ib+toX4dRbRHrsp9nBDvSj01k3rvO8X4fQs6IK6rV6/TmRHf20TeYWRSOcw== X-Received: by 2002:a17:90b:4014:: with SMTP id ie20mr162657pjb.95.1610050548146; Thu, 07 Jan 2021 12:15:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 32/47] tcg/ppc: Use tcg_out_mem_long to reset TCG_REG_TB Date: Thu, 7 Jan 2021 10:14:33 -1000 Message-Id: <20210107201448.1152301-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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=unavailable 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: peter.maydell@linaro.org 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 Wed Jun 26 08:00:55 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=1610052096; cv=none; d=zohomail.com; s=zohoarc; b=DVANoMVZaUwoHE0QaXU4GhZi+4/1bfJaHz0VvICfMhunSzzpheqLOs/h7m8vmQG+5TwUe9t9tFfvL65zc2M7lS0zNu4eqQykqj1xsrNmyoSz7fm74i+GQD2LjpuhvAp9unnLA1rWy8ASIyANehxYfZ7ioI+tLFu+MEBosWB9ZWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052096; 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=k1dwR6fbig20YHFioF/qNG9UvMMCDYRmx+wuQtP3btg=; b=YmV6GUs9NpF6pdGeMeiAqeu0e1VpR2nVdShWa8eF0BwGtsZKkXn47k0pXvvrGgLtkP+IOPaAqDHd2qwjPJBoR/Q44PxUa36VABwUBA2sK+vrAcDB9ZYnVLgxlzA9bOSQN6wfKatcDP9jWKOLgZzbcTYRrVm1dF3Zzm2MCvidVu8= 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 1610052096012342.1011153744445; Thu, 7 Jan 2021 12:41:36 -0800 (PST) Received: from localhost ([::1]:40260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc6A-0000XP-NW for importer@patchew.org; Thu, 07 Jan 2021 15:41:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhW-0001XW-6C for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:06 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:46463) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhK-0001gl-M5 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:04 -0500 Received: by mail-pf1-x42a.google.com with SMTP id s21so4542628pfu.13 for ; Thu, 07 Jan 2021 12:15:50 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15: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=k1dwR6fbig20YHFioF/qNG9UvMMCDYRmx+wuQtP3btg=; b=b8IumhFD+MCFSROFb8x2QpWGxPCeg4Mm564kQqlDxC/X3AMjx/gBnefr4OuLYYzjg1 uPTdiVgfn1wwoMquiw40BvAQXF7jJfhs1dyskeFkKxZ+zNnp7vySXqu4rQ2zE5bVtCnv mX4Ok8jbvoFH713ZblNrs08NYl4BSl3pzyWGMGW7vR71bwitk+09LUylRzktAJZ5Fq7/ I7J9qVp5DwkLf6hljSbuCg2Gx64MTKAdaAAeSrkNhvwugWaQZ+ghsB+lIbSzCb5ZtFgb Q9ayutXstX7DnZToXEdwwWG2UoSqTYUscFwkFIogQJl7mtVMyrNFGZFN0nz7VMRK9pWQ JZMw== 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=k1dwR6fbig20YHFioF/qNG9UvMMCDYRmx+wuQtP3btg=; b=eWzs5pCHjyT21lMfgl++n/izo07bedJGL6kQGYKlTF2DJme56neBwkr/m12BtvcCa0 84chVpY7ry0runs0/fyOQ9JjcMrO8eV0CRhDXtaz5YWLtFHKoLAzKE+OPRCI3d9loSGX MQKTkriR78lvFOv/EcK3nkV1zEknlMOUYZ+IWbvLkWWlEaJjffV3GROXktNgsENqySYJ gddI/3A4oWyr0iqchxSbqFwylr6fyIbw8723PqI4eW6+pEkn99GCH1U0S7GF6iPHGPdy NspFfsBJgfAO1YudAR3zUOf8qptYqekD7+KYV9/RXZ3Cxr45X3IAugzqhkZwUvNuQ+H6 du1Q== X-Gm-Message-State: AOAM531A6wKqTO/oA0IRzR/YID4ejWqorCDaUEOSSSzt/Rj+N8Tewk4K srzmLQzOZl4DIS2BDCcCImWHPqGAT7BxQA== X-Google-Smtp-Source: ABdhPJyJDxx/ZBp9ck8bCLb15Ze+1/0Rmt0mBQ/hIgjenI8aE7M3f291n3rxFtw5H/KAJGRGfmhhCg== X-Received: by 2002:aa7:963c:0:b029:19d:dcd3:b2ae with SMTP id r28-20020aa7963c0000b029019ddcd3b2aemr335344pfg.76.1610050549633; Thu, 07 Jan 2021 12:15:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 33/47] tcg/ppc: Support split-wx code generation Date: Thu, 7 Jan 2021 10:14:34 -1000 Message-Id: <20210107201448.1152301-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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=unavailable 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: peter.maydell@linaro.org 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 ba61a31b3e..ec51f474a7 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -185,6 +185,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 Wed Jun 26 08:00:55 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=1610051272; cv=none; d=zohomail.com; s=zohoarc; b=j+EWtFQtWiB/ivVfkL7KN7gin26OAVGirzZ9SQGccTpqIJLfnsDxhZzYLQE2dztwfKD/ANesR2LczepKpBB21uP5VLwPLD6bNi+3unYcUBfIqYXKUzpd3zcAgDeo3hULpATeGlbUieJX/CI+obU01G74awSPzSErBBsLMRuTt/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051272; 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=mZ7Cv5t9pDHcLwkTAHUkGoZLzbW+EIVJw5j5xRLRZ3w=; b=XNs6mYHPk27yY9b7Kswfm7iYZfXBdYe+7L/RT/Bkan5vZIzbVxqq3HuZ6q5jZO0Uohsa+jl6dsnSxel3iK6BPXVNYO/nngy25GEdZvqvCRnFV+EZMFRqseoJFRXvVWVE2wkpdoRjvMOkNLpSJ0A9YsQRUNtf3UTc+FyYiHirFyM= 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 1610051272201413.8021107459532; Thu, 7 Jan 2021 12:27:52 -0800 (PST) Received: from localhost ([::1]:54234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbss-0007aG-Vu for importer@patchew.org; Thu, 07 Jan 2021 15:27:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhW-0001XV-5h for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:06 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:38855) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhK-0001gq-2j for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:02 -0500 Received: by mail-pg1-x536.google.com with SMTP id q7so3833688pgm.5 for ; Thu, 07 Jan 2021 12:15:52 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:50 -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=mZ7Cv5t9pDHcLwkTAHUkGoZLzbW+EIVJw5j5xRLRZ3w=; b=Rr7zdVBKld8yeDdRDoelwDknALAaiBZl2FT9IIgShFkR5o0tdcBV6/eIvn++b6DaMp iGplZVlFqruHqZlo3EcVCrzYTh69d8pFwhqYYaOxC+v6JWc3/ofRuX5cHNgDJuk7I6pN Wz2OpQOP1cDkCAbQRasOcwMTQ7ToZA/o2Rz+2aIYv3EHHmdIaKy3jDXTObVQcTuZ259S 0OKukH+UZrj0fbTVhIi1H+qc0kjuwljbpb9Wt/PwfyVSDJia28/JVFnk95v2KJjVeKwK 15YSd1TNX94mMvv0F8PalZMqNOVftr/opPeTyrf5MngFO7HU/P524fhW4gYhXaXwctPQ sETw== 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=mZ7Cv5t9pDHcLwkTAHUkGoZLzbW+EIVJw5j5xRLRZ3w=; b=rFsVhphMwqu1pflJO5OcShggbpP54xBHnd8A55zbyIgnP3lxNXIoMykWnO/fvAeOdU ac24I5gxHaCUU+DMBRTkWAST+CmQ7pnblNLie2lECo6qu2dupWAyaLV/q9EAKoUA/zAO 4Wa3EM2D5zjQDJ+x58fmxRiUuqmFf6BlD4BfSo8ILfxnOzmsngNoHynYAWHi71frrBOi NIfSrGkxGly9m1cDmgGSwX9x1XUc9SBnJWqE/MYZcVQ1TDno8O9FNqtrhhGFNEALoQcH XhWZdxAHSZKxeQ1anGaVHj09bd5xwJVQ2+ABaSvMUnIq28Gr29WefZ37KqSuFFgiBqPN zGCA== X-Gm-Message-State: AOAM5306OODYEGydei3oG9H+1diyaSJonxQfeTCNkSD2fPjcu3lqJwl3 A8WgNM2czK4I0mDxGjA4ZbToiGkxzupkKQ== X-Google-Smtp-Source: ABdhPJyb/IPP26i4eHv7UNaHwvyetgpSf1N8Li+FADwaSI6NW96xNjm5O/+gofnrU3x/k63IUpdleQ== X-Received: by 2002:a63:520e:: with SMTP id g14mr3430556pgb.378.1610050551080; Thu, 07 Jan 2021 12:15:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 34/47] tcg/sparc: Use tcg_tbrel_diff Date: Thu, 7 Jan 2021 10:14:35 -1000 Message-Id: <20210107201448.1152301-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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: peter.maydell@linaro.org 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 Wed Jun 26 08:00:55 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=1610052094; cv=none; d=zohomail.com; s=zohoarc; b=ISKHKsnsirB9o7IePsaY/wPuM0FBXQAavY/EGGGS/ABMax5XNonJSe0nhs4sHkF75tRmh533RYxGZr9AYAmpuzn/5ICvHN4n0OEV0pyZwlWM61ih6cp+RfTbS8fWxvFsZtGq6W7Jdb4FspWsa8/uskKf/z0CYGq0V6qL6roqV7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052094; 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=CTx1bMRPoVCbR9ZXrYADDGmrgIOCMd4LcuRPi7m2xvc=; b=jJRGAk6gC9xRiG5JHiozqm4+KYAcp8D5rXSUvU81LOlYsfW2B5lILgvlIgyXStR3rccZcePcmcqKRSYQqU0WOzKFMAiWOZqvgmOv42PAahZLAz8FCbLYcgGeG9xevg/KW0oahr3GIodVe8F9VnXU51CUAv2tc6RYecR9+G8je9E= 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 1610052094289412.18867670994575; Thu, 7 Jan 2021 12:41:34 -0800 (PST) Received: from localhost ([::1]:40088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc69-0000SN-0o for importer@patchew.org; Thu, 07 Jan 2021 15:41:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhW-0001Xa-7J for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:06 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:32771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhK-0001hg-Mw for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:05 -0500 Received: by mail-pg1-x536.google.com with SMTP id n25so5760342pgb.0 for ; Thu, 07 Jan 2021 12:15:53 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:51 -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=CTx1bMRPoVCbR9ZXrYADDGmrgIOCMd4LcuRPi7m2xvc=; b=eEzHqFkNXxQK3AZfGsvtETijjXQyuPxAH3CzL/wwMbdj+HHms8zgEZhXBSXFbvX/9y jJaEdnY5/OiNTSmiHTMw9wY3rtTyhpN3/ZYwF1cqF9sfExSibFe8KfLcF1OsB5wyd4cO Xn+NY0+z3EzYHt7TcUQBNxe9JBOtm7p0Zn7EyVoGmrT1YWJHQnMs/C9vFDyavAOidd5G Ql5I7qG61J9OPHS0O9vnm2i62uHqld43wDptt9m6RflBmTWUMj95DdJ20ClB8+Hav49n k/H7XeqrppGWHdU63NWH8ILDfZIAfqcGWCAbJMyVsPF+1941SSQGq65VJbiBHo/1oHRE TgNA== 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=CTx1bMRPoVCbR9ZXrYADDGmrgIOCMd4LcuRPi7m2xvc=; b=QrfATgQVuJKGC42uZOAsPTlS2b7kOQhKSemiMMwHM+WW0UC7zDsOEpjNmBjgfs1VrV aqE5Ivd86envPreOsz5DcSif0VceVi+6M4xl8fbizuwFS1qYug3a/g6Aphs6ys41MXtn uLBo06L7TsEs46Y164WDeg8ikMwnWHzd5Iozs1Djx8645Jo1knCE0jJq5Y9WseuxcV9v 3850gedwWAszgz+uQh/u5038eMvNnRthpCRo4Z1B8L0uZanflnk9uuQZ0Y74S+gjLuTa G0NTRQEjfVqC54Fv1qGKiMp7lhT4wuIndOmb70DDX5JrLmxkonAii6HWGSTXsN98uJQI n9oQ== X-Gm-Message-State: AOAM533i/VfqtZVChvq8CT8jsCLGmEGQwo5wdp1VgRyd7aZVO9dckmD4 mJwEJCnjrdAXMqErsQlBkt645BIVjBP7KA== X-Google-Smtp-Source: ABdhPJyfPVCClPx2RVOaDXeqWlaMpO9QmDns3pM8Cs1ekk2Hg0dJu+maItziFx4d7TMohmPQigPYJw== X-Received: by 2002:aa7:868e:0:b029:19e:3ac9:f622 with SMTP id d14-20020aa7868e0000b029019e3ac9f622mr408508pfo.37.1610050552477; Thu, 07 Jan 2021 12:15:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 35/47] tcg/sparc: Support split-wx code generation Date: Thu, 7 Jan 2021 10:14:36 -1000 Message-Id: <20210107201448.1152301-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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: peter.maydell@linaro.org 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 6f6cefaa15..6426e24f17 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -172,6 +172,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 Wed Jun 26 08:00:55 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=1610052598; cv=none; d=zohomail.com; s=zohoarc; b=KmExAo3HCfh1GdDX18JPlZ1INbvVhfWcJ4YALtXrvIDiW6i/jR7vhnmtfes8/OBhS/mreAe4V2pXhsDL4jXdwLePk8qaTyOL8sO9BS1O9BQkPYCs2Nty42rC296lE1xJRvwJaCaZe3C8ai1vdEJneFd4hUmAbMuVseIQeZqunxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052598; 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=wkypnopb5BzPYlv4jtMpd96OEpFhEMM9GKjZQ7ld/TU=; b=GImZqD2lhUxIQAQeGqBlfzPp9DpRQD1FRlKjAfnp7BETYrQsYFlWSxkEVYVjkiW7rCqUx+slXlQpPK3nNP15DWxxyHYYgTSkU8BlJv9NdAfAjFp8QwCWvPLW33MllS6/Dze1MtFfJ5j57gck94Z/4msjbEL5Q05mx8lAOGKIbzY= 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 1610052598936785.8921199130641; Thu, 7 Jan 2021 12:49:58 -0800 (PST) Received: from localhost ([::1]:35456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxcEH-0002Oa-RS for importer@patchew.org; Thu, 07 Jan 2021 15:49:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhY-0001Ya-1t for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:09 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:45814) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhS-0001ht-2Y for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:06 -0500 Received: by mail-pg1-x52a.google.com with SMTP id v19so5713810pgj.12 for ; Thu, 07 Jan 2021 12:15:55 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:53 -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=wkypnopb5BzPYlv4jtMpd96OEpFhEMM9GKjZQ7ld/TU=; b=WSQ1vjMfcFSEiFwD2ilBFyUMOxZMGrRhVjafLy8ZGx+qy72Mchrfm/WUWVn8R98UsW lwes/MpfVJnWrENSTZX47IGvC678x0++PJpzZbMpYFa0dR4EJLXxWKLMkDIUsnazFFnx 3RGyelxFzD+QBkN7kFIws01jnrgt0eJls0cAczmj0Sh0R1QyDTcjyuLKlnUHYhpoTvYG UbdD9f9ZvbxlwNsqjbHZdIYWBSgJd0A+T0CRMOMA8Viue9GEukluvaOuhGv3Eg1sIPrD gDsLElrJtl64bm0FEsSFYSs1727DBYi/dbk6ol8DRn8TQxNmGwXCSi6TcMib/E4rI4U1 HTmw== 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=wkypnopb5BzPYlv4jtMpd96OEpFhEMM9GKjZQ7ld/TU=; b=KSFDGJuJuzAJXFa6NS/JOwNLAPSlOdhH59aM0z6DF1nSRmPYOdd3qYR+wUKlRMCXGE MrkOVZ4zGVEIgZRuRCtkDV3bb42uvNw9eczDOFOK28z6VewqUS6E+mX4QTVNg4yY6kCJ p1pYbqtgCKfNnD9XAhmnUKdAKGe1TN1fStc783P2HOYye7YtdAAC/9NEGX/8vdNbdvIo JXsP7K6kLl8oMfSo6FtkqG1DKNBXmXN2QRyEiEjc+Ki68l/lzZCdi5mCwi7GN5U7k6jX xYIA8bVANtyU6cOI+qVgjf8QM26duniTf8MPSl40itJhkCi6c52E15KzP63LYkxW/KG3 vL4w== X-Gm-Message-State: AOAM5306g6btZ4y/lzLtao82bZsq1hSTNIw0XsHJm1ycyqKp5HGFFf8A S08nG6avXOJiQ01VUgf0cG0/R5AWBIgojA== X-Google-Smtp-Source: ABdhPJy6NghMJS5atYhHL1V6+4/bQAKmhNmIOYLgDLGVyxD26honS2Q/15XKEKy5ju/B4Ra1F8H++Q== X-Received: by 2002:a62:38cf:0:b029:19e:41ac:526b with SMTP id f198-20020a6238cf0000b029019e41ac526bmr375454pfa.0.1610050554032; Thu, 07 Jan 2021 12:15:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 36/47] tcg/s390: Use tcg_tbrel_diff Date: Thu, 7 Jan 2021 10:14:37 -1000 Message-Id: <20210107201448.1152301-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.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: peter.maydell@linaro.org 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 Wed Jun 26 08:00:55 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=1610052751; cv=none; d=zohomail.com; s=zohoarc; b=C7iUyv/FKMtd94TldVBkzMmy4UtzCmFy9b2dzbCSH6dUSiOeZiExKnDgQQKyo1Uc1R6FN4LVdgkJg1t/KEUgMgC8g6ZTXVYF3QnRM+b7rj9LvKGqkH+6fsckyu80/nXomC8bcetAguEnP33kOufr0BT7vMNbf1+X3kijMEuDxFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052751; 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=XwAGDhPsMBTlCDYICLuTcDF1WAEZQ1i2iAFKQ493O/8=; b=kjarty/9iSEGevItM65vwxmfQNxaZbCsBvGGgXfkcWHq191FvN6pUi1301ugejW19eBIduMTfQNkAJTbObt5Uiz8YC1DT148M3jLGu3lh5wvCZtpBfFomjUEiaooscIWQ6qSVfqgETp+w5A80Frq5DpvRBgCWss6m8ghK8ffelE= 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 1610052751906477.47858181288996; Thu, 7 Jan 2021 12:52:31 -0800 (PST) Received: from localhost ([::1]:42130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxcGk-0005GO-LS for importer@patchew.org; Thu, 07 Jan 2021 15:52:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhZ-0001ZH-S1 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:13 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:36633) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhS-0001i8-35 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:07 -0500 Received: by mail-pj1-x1033.google.com with SMTP id l23so4484646pjg.1 for ; Thu, 07 Jan 2021 12:15:56 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:55 -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=XwAGDhPsMBTlCDYICLuTcDF1WAEZQ1i2iAFKQ493O/8=; b=O2UId8To7KkQyHjJydNFaX+TqaoN1AGOZY9/Q7F3cZUxKk1JoF+3HK+u0vDam2Z65t IYeW5Z2YvTk/EocTkJiZYlqNIzJZxEFf/o8gDUFWKEUg6SJrLmnK3a2hzsGlnVWPQ8IV oh4mAyJcR7Fpn1vb4fLU5m4xG/E2d70B6hdt1J6JQq9vaJ4IcYDc6c53ypIM2ve6lGNA Ufu1HDXmi14TUlESMfvksMkTIB2YVmDFB35xePa5ZG0UvoGq8scMBQbgUoan4PsnEoh6 YO3ZDZpAX3dfDdWeacufiZV1GJSQlFncSzTyEj10BKB3vAadg+5YpvLA8BMux3FNmSeJ IK0w== 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=XwAGDhPsMBTlCDYICLuTcDF1WAEZQ1i2iAFKQ493O/8=; b=GMqCjQD/h6NGt4ZcP79uZQQ+0ybzYs+IgdbX26NKDtzox57MIcIeuvZa1W6sEtUP2p tSeQ0QFkjAQN+Iceb1nBN2/XTdyrxKU7zeogP0Xo2BMv3kgkTy8OndFS0UwTu3RIzhMa EEHSW2mOB5O6hesMA6iyP+5kb86EmTi0soBYHMEJhv9n9fovDkwNBcFRfCopBl7L6qol MPlC5uSn+ynG99dycn6+LO1X3Z4ROFdh0iVqvoTwqD6ya4RMwKvUS23SC/rZlKFBt/Us dxhOg229b83ARPVRgmYujftAGq3ynwDylo8QwTpWOGLoA4YMg/x69ukkEwrdfBiIcHwB FUUQ== X-Gm-Message-State: AOAM530Tp0iIkD1RHl/ypuA7QdZO005g1vTZQFcAMeZdWbzCJz/fjKva D9QZEXyJcuGPHPDzs6DqSDv6FnrW9K08Bw== X-Google-Smtp-Source: ABdhPJxI2vCjKsHX/eFS+Vf4LJqIZ4nD1BocEvJZEEoQ9lRea6wvRI4adE8eothWZ7VTXFUt0vrDRA== X-Received: by 2002:a17:90b:46ca:: with SMTP id jx10mr186269pjb.208.1610050555660; Thu, 07 Jan 2021 12:15:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 37/47] tcg/s390: Support split-wx code generation Date: Thu, 7 Jan 2021 10:14:38 -1000 Message-Id: <20210107201448.1152301-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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: peter.maydell@linaro.org 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 b8f4296e4b..4edcb06044 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -159,6 +159,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 Wed Jun 26 08:00:55 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=1610052868; cv=none; d=zohomail.com; s=zohoarc; b=j2VThLV4wwN3WTc090ahj/fAh1mWF2LYBLQc/xV1hpyMQxC6V1irxwcSRcxc0WL3fxLNRznLmw/1DcMXXeCpxrpzm3flPTdUDsNSga5pbk1f89s1CFE67az2A8J0K6qg4tsmSmgNPPDeyy/JtUwcbPQNm1gja9TsEVhve53JGpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052868; 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=sam4hUV/EzcXgGAJgfUtLyaqNJNq9uqdrP2iGsKVsYI=; b=QkgUUpE0VgWhz/t0QkhnGGucDW0tRVGBIIQMj9x4dz4sr4+pM3OxDYJQHM5+7ze3H55FX2tyzoyyj8dTaRkgbNL1Wwr1ip0EDcvbuP99Lff9sdSWRbUkGeITPC2/F8MiFHSY+N1Ma9PnGJax9+aEL5dw5mAq43BODoRmoX8+Sig= 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 1610052868463495.6251672450825; Thu, 7 Jan 2021 12:54:28 -0800 (PST) Received: from localhost ([::1]:48824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxcId-000883-4T for importer@patchew.org; Thu, 07 Jan 2021 15:54:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhd-0001Zo-JG for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:13 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:40874) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhS-0001iI-3N for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:09 -0500 Received: by mail-pf1-x436.google.com with SMTP id x126so4565703pfc.7 for ; Thu, 07 Jan 2021 12:15:58 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:56 -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=sam4hUV/EzcXgGAJgfUtLyaqNJNq9uqdrP2iGsKVsYI=; b=skTYE0F0Zg0fkMENp0zyuOx4fQsQUWNTzohnhTFE2u7AJcuBh7LPDLKLcodru9eS8Q 4GSgjCc2HWTH23ntldSaXFoWKd8b/3N/dSZNdOe7/iJ9jlDNXqkBdduSsdlWeb5ZJp5i 8qhUq4CKWqd3eflJKAQYUV+dLia3PLAVkGYYE3GObE9Fzzx9bvtAU+IEmtgqv7tQaKOT /GjhqeY+elo7u4wng/jUJSE8pAmfq2WdP+YdHk4WvYNMK8bHyQqfyZwwRnvRu9d7pu7Z aPgcpnxaZO/3UjGZqP8wU3Md0IKZlGKH4tcDOIvZ8BJcgr9dPClOf/14mXrabXOMLjrs cBRg== 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=sam4hUV/EzcXgGAJgfUtLyaqNJNq9uqdrP2iGsKVsYI=; b=J16QI1MRghbp4epx/55IVu9uqvGh1+vrpCisTMCxR91QzUyhwCdssk7iloRL0ZNBfT CvwP2RNrn0Hp4WOaMfofoZfyxXwy28qELWAbuL19ELjjLAyCvOl51Y4g+YA0kcJNM0zV OxqBrFlVNnnsRI6PdcerpV5ZnPd80aqcJM5wUiONa/yrdfOQlgfZR+EB2+QTPAyBMiRb Y1Ddbje3uYtkxW3LAuHlyQR5zF3vLDJ9CGzCvr97LpNLQeRHE1HJMt2wcfU9pDgIXhmQ 5eLwL9rNLir4Fbhkep2Z8pKCw8T6QTo88RqjVN8z3ywn2rfgbcx2S80kaC5Vd05dbCok SIZw== X-Gm-Message-State: AOAM530NyfXvut/Q4tO/D731ZlygXi9rhwLWvG8eau4Hx3LGcPWoA8nu J9b+OX/65u7IH6DhHxHzYdXhuz45MfECzA== X-Google-Smtp-Source: ABdhPJyHfVqP5mDdD7Qn+o+/qsGe4kA11rd9f1i8Wn7xQjYcDOmcFSzRgtbkrWZX6usZUIfOvZZI+A== X-Received: by 2002:a62:33c5:0:b029:1a1:c2f2:d771 with SMTP id z188-20020a6233c50000b02901a1c2f2d771mr3644961pfz.29.1610050557258; Thu, 07 Jan 2021 12:15:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 38/47] tcg/riscv: Fix branch range checks Date: Thu, 7 Jan 2021 10:14:39 -1000 Message-Id: <20210107201448.1152301-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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: peter.maydell@linaro.org, Alistair Francis 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. Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- 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 0518595742..5b4c500a4b 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 Wed Jun 26 08:00:55 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=1610052400; cv=none; d=zohomail.com; s=zohoarc; b=PO04u7+AqEIzLYYjkeUJDSBAP9tJz0GP10C16njBIC6TqYpw+NguHnlkN2xyXlydsjurYMvpSOSMYYqrIn2+j+tw/jnUQzfauN8TpxhmpFWEAp7K+vcDj9QHvD1W2gDqp8MfB3xm0gtHff8B7fmrI+g46FjgnRlvYAgWLSomFwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052400; 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=2ceeCrB5ObxXqiOq+gfMl3DKYMpwFGb7NLNLd4oEq1k=; b=BiUbIXBBli9D8Pg+gpzmml4N47sxrKC2gierOK4L7FfsNnfqFBTD9NAM4UJbKY03+YCoTPjvPbqDLnJV5XsQw1WAHacIRgRLBWEH5wH5DuywqpofkFsqmSjVAJSFxBWq7bgfmEqai8r7zMgyv/I8A8jHWJ++eEISYhXX400iuYI= 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 1610052400600420.523739737553; Thu, 7 Jan 2021 12:46:40 -0800 (PST) Received: from localhost ([::1]:53934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxcB5-0006Zv-Fb for importer@patchew.org; Thu, 07 Jan 2021 15:46:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhe-0001b2-57 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:14 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:46965) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhS-0001iV-2e for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:13 -0500 Received: by mail-pl1-x631.google.com with SMTP id v3so4138888plz.13 for ; Thu, 07 Jan 2021 12:16:00 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:58 -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=2ceeCrB5ObxXqiOq+gfMl3DKYMpwFGb7NLNLd4oEq1k=; b=N9pVmwDPAMYoZqD5ZPzkVozef2ojVxu9BXFUW37mllgJzk67+mNgrak/E+kkK60dKe 3ACTl+yUDpAvxRJwHgMgpMjmlW5DNy7qK6AFe3Y5xSQdWwYQcTAHT3sLtCVxJgdVZtfE PK2P6+VRAK8Um7oT05RrROJtCBK6kVmCzd7+xYng68rCXvpG9+bY5lLNaCsBexbFOz+L p4XhDWinsAYP04TZyppmPuqjpoBHnihtlgE8Fs2w+g3pIY1xuV6obnahvpL9ohdAp5BO wktlvrHNlXlWBWI7b5d2Epto5Keqa7unMZijQuT0S6YQYzvfYi3gEWaFSG8nlWuGlQqQ 7kBg== 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=2ceeCrB5ObxXqiOq+gfMl3DKYMpwFGb7NLNLd4oEq1k=; b=p6HGIudI5cSUfZT+8xRVdkl76AGDmjnFTxCxYju1iY4m6+G+VjHmyjkB1lkdOb9Gzh 7K5qx8gzkqjmIwSyEbrO30znBVIhTZmGQk9FQ9f6ro3LHKGb467Qj/jS7HIsCZzzOdwE qWpe1x7iwMRa9/S5ELMysEeGD7rCaZ3a65vNUzoAabY+ldhmgRLC7x9RiBzepgsRHqig sBudEWxfaPBdUq8/ZT6LCdkqmtkvmWcBfY7jxBh+6E/01g19g+AjfS8uAbeMDukO6kCZ ZJJTpW4Ea82zMPpNExdurqpqM0fUg3v/mAok6P0eZpSgQnu2O//OgUQOOwLcNJZKpSoL Rl9Q== X-Gm-Message-State: AOAM530OTfMe1/LMfFmKo5LA2WXokjpTvlwKbep2s9kHsww4Ky6QI+E/ xogJT10gcwDpXtMcYXTJYyLJt/s7B6XjRQ== X-Google-Smtp-Source: ABdhPJw8MlPkf/Eix6+OxuySqV6ggPIe2HAtDIMdY28YVZPNyMVKkGIpnHmJ0n1NMJpp2m/8LJgDkg== X-Received: by 2002:a17:90a:bb8c:: with SMTP id v12mr150074pjr.227.1610050558802; Thu, 07 Jan 2021 12:15:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 39/47] tcg/riscv: Remove branch-over-branch fallback Date: Thu, 7 Jan 2021 10:14:40 -1000 Message-Id: <20210107201448.1152301-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: peter.maydell@linaro.org, Alistair Francis 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. Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- 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 5b4c500a4b..34bee9c5a7 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 Wed Jun 26 08:00:55 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=1610052575; cv=none; d=zohomail.com; s=zohoarc; b=KF54v51uPcGu82qnSgsCJAiddxKW0gSWJele7qsxaupGyx1U4QL27duF0H2nyi7dYcZR3/rv0SgmK5FCZPt5oLbFF/TtEKa2VADyQDL5no4HCdQhQyIwWBGWjVHEWtKaUsR3dSPER3RpVAj+UYU9k34C1uCyXU+lZ40fzwqjfU8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052575; 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=Q/5vpDX6rjCPgvb/9YU60IegGHSAx+QWhFDunev+ydE=; b=lROZrn68PYG1bbMQx5ncFTEj8O8AuZTxMLbq/1m09sEITfAZhsQHrjVZg1RZlVjjhtBI5JmoAB5AeiNN8Qs3RWUTMh9/jhuJQOcNDTuCkBKeLcH2XFpMARadiJpVDaRsoPex2StodYN7ADTP2KxR6QeDKH9Zem35AnVGM4fkVWk= 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 161005257593123.446051300282534; Thu, 7 Jan 2021 12:49:35 -0800 (PST) Received: from localhost ([::1]:33276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxcDu-0001UA-S9 for importer@patchew.org; Thu, 07 Jan 2021 15:49:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhe-0001d6-Sd for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:14 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:39500) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhS-0001ic-3z for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:14 -0500 Received: by mail-pl1-x634.google.com with SMTP id x18so4158380pln.6 for ; Thu, 07 Jan 2021 12:16:01 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:15:59 -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=Q/5vpDX6rjCPgvb/9YU60IegGHSAx+QWhFDunev+ydE=; b=tKhqSTfGfXj1R5xZMCAVCyQHiTprj/thhPCFx2AVuCjyGFUfdzWY7q2NW2KPZPvQzR 9imiTToHRf8h92ifJgYFFzdtJ9BCNw5ZHRS8aK5lvWM7WJxdI5Lwtgsg6mGzro3eWwGc xDbC0UzHJDIV21miEy43sdQDHpgy7GyU2KxRh4Pxs1K6sdzJt2JaUdcraUnv0dXgqUWC 65HZv16EApekEAQEh6UlyyARb7lFOxU1F52ZYbIH/gXDKsfu1Ne2YhP11kgv+ODEH8DV WsaQobfNkYH5rjGwV2uFyerJhoaZbvwT+qWzhTK/hG9R+DkHRXLDgiTcEi+acES7z4ei YQoA== 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=Q/5vpDX6rjCPgvb/9YU60IegGHSAx+QWhFDunev+ydE=; b=LsmVnxwm2nFBWP4Lpl2qwRSA0gluinAqRtJfCfG9uPhsqfXuG2gdrP655UG9gpVteQ jWgQ6ESJ7smiUWE6L8Hk2kw+E5Ze9Dc1zLZx6RZues8j82Ef+ecFCUELAc82AdRVskPt e0ks3EZuQceiureteA4v+A5MaS7TlvAqxfOeEFxkZOZu+49k1SabZThAJ1mrlyfz+LxC 2nHkAFzgnDR78pqtjcfnXkziI53VZ7tmGsX83nVU1va8kIM2CNDizU74wytY7GhhswWQ 3/nMXWzOqeqd97PrB+zyJ3p3hlMXBjM4zEBTeoUZgYdxt5YD7BGM3cS9Ju5FuZUt3t0O L3QQ== X-Gm-Message-State: AOAM532mH1ZHLYhaCO5yrhyTiHUdIDMEfcK8wyq+MNAeIodZ2+DYpey1 YJ/oN7jir2IhyuqAYQWyZM8syS4N0ZDSxQ== X-Google-Smtp-Source: ABdhPJwlBBcCfhDQrNIQ2eQ9ecTj7oqDpM3u9shwjcwOCq27zLLNWumDsyV9g2brEl/w0QTP1Egp9g== X-Received: by 2002:a17:90a:fe8e:: with SMTP id co14mr167459pjb.105.1610050560467; Thu, 07 Jan 2021 12:16:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 40/47] tcg/riscv: Support split-wx code generation Date: Thu, 7 Jan 2021 10:14:41 -1000 Message-Id: <20210107201448.1152301-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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: peter.maydell@linaro.org, Alistair Francis 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" Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- 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 6263af4dd1..c50ecf4dab 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -171,6 +171,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 34bee9c5a7..4d595b01d6 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 Wed Jun 26 08:00:55 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=1610053111; cv=none; d=zohomail.com; s=zohoarc; b=CPviCIYhca5Rs8MXo62DVV+Ck392gvhLRuS5iG5naKUybdG+m6dqH582Kin9mj+nWmHFpyaBD+JdIYb3g49odk5/DblQMooe7Jn7u4r6CtICvzitW18X+mbpAfodgIG3U7Ts+MgPKH8HtFLpEIDe0myECzyeoHMnx71QXuDKEtQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610053111; 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=LaTXN69dgwbs1ISFkqvlbDLmQMLsIvhLpgwyriKzsQg=; b=hI4NC1coN9tVEM8/CFilga50pXONI+WZmg/ClCrDpvb443WD9pvGNUXjQCjaDIHGfgbru3LvLdZLqbxUZ61om/v12TGytOUy1jh6PKDH77AA0NMFwJ5k1yNSig8Uqs67SLluJGPzb8G1ob+NAFR3urhtlBe/kA4mNIvoCs/l7M0= 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 1610053111038337.45330028850435; Thu, 7 Jan 2021 12:58:31 -0800 (PST) Received: from localhost ([::1]:59554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxcMX-0004Pj-Ba for importer@patchew.org; Thu, 07 Jan 2021 15:58:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhe-0001cO-Jz for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:14 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:40029) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhV-0001ik-1L for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:14 -0500 Received: by mail-pl1-x633.google.com with SMTP id q4so4154865plr.7 for ; Thu, 07 Jan 2021 12:16:03 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:16:01 -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=LaTXN69dgwbs1ISFkqvlbDLmQMLsIvhLpgwyriKzsQg=; b=oTLAhLjuLOaoGuw+0B9oPUa/NCe7gzFOOztzsrY+8L6Y3bSh18DfzIqLxvi9wSSNym cJtBVpMZG2QeMAv9YF9XuYzFQ5MBmEKKZaXMrZjV9gW8244Em1zY31V8ywpk3MZtsW/5 7jdro5/ZTm9bZUvUbNuWM9zW3oXsr7Nkvi/9vX38rleiR+WybzHErxNPWhuJuaTTFFXW W9GYv7DJOyDh0FcnzVs2nt+NTmJoLju7ORZkP4J+gZCBAGFVwUGbkzrebguA7zqq3TSd RwWMSy+W+Q3ZYMmdYREXmRHRoJ9yjb16CTKjPOYGupIo7OYPQXrUuxtp1h633BxOWZIW nFFA== 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=LaTXN69dgwbs1ISFkqvlbDLmQMLsIvhLpgwyriKzsQg=; b=Jlrjd86XWBlPpQtgA+yXdw5W8OAG0UGFbv6b0+yO/Qo5Hou2mGzjuDDK++H/QfstKJ L3kxfXRv84OHUFVfClZu4q0bYeNpaAz2MEfiZcL4m0Dvr8yrJOjXhM8nop0PqeoDDPyc mlDU4zh3N/C3i0JqqW0tKpK55BMuEdUKhkH6iO80LD1Nu38wRajnW4uE8mOjf7weyDfs bojU635ROWIaLhI/Uo8orawXsG2u0zfiWgTk4ITS96UySbfRpRdkG4bRCDNrD2XkocsN DiMR3SO1CBypOKzI2uw/WH5HP4ENJVJq9wLDfGDdESooPJKEaaKcgam8snFNd/G57GpA 6/2A== X-Gm-Message-State: AOAM533lzCghHPkCCYldI+vuftHLv1/18g/Wes8NyfAtWpWuRLJ2Egsb RsRGuN2+yrYdBrJOf9M0o9mt8W7WATw9bQ== X-Google-Smtp-Source: ABdhPJzei2RvjwRqB/w4ntYffX7Oah+LVq8Ic22wo2OhsxHZmkzOSa0OPt7MquhIAcQM6ohwe/HazA== X-Received: by 2002:a17:90a:2e83:: with SMTP id r3mr192934pjd.112.1610050562097; Thu, 07 Jan 2021 12:16:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 41/47] accel/tcg: Add mips support to alloc_code_gen_buffer_splitwx_memfd Date: Thu, 7 Jan 2021 10:14:42 -1000 Message-Id: <20210107201448.1152301-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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: peter.maydell@linaro.org 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 c37718db4d..02e1b05c42 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 Wed Jun 26 08:00:55 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=1610052950; cv=none; d=zohomail.com; s=zohoarc; b=e2hUsflStw6rkobuOUEcpMvrA3/hPR0M3c+Q3Z9t0SjpYyKWlurYnjl2WpGGPBbV7oYnbaUlslW4Huwd6yAaUfJPWnNuo1gXxYkfemqCNT5x/FRmF3S7V/hD0Hyz1bEJ0KmpPRgs2t2xww9yhQvC2H4dmpsL/NStTNTcokF6R4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052950; 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=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=Mq93hqooqi9QfIAb3KVx7LBHIYuznX/bRhPiKrOE0vvlXzCA1nkP9ttObjGLX1HzCvBdQ2hjXvt5aGSIvoeYkpMGv1psueX98I8OOw3MDBcatuhBxytfgwDp4Nn4XP9oH0ufFMuHCC97z6zuawjD8G71P8MdspPPWM/kvuEJoAM= 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 1610052950092336.79148375391594; Thu, 7 Jan 2021 12:55:50 -0800 (PST) Received: from localhost ([::1]:55118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxcJx-0002Iv-1t for importer@patchew.org; Thu, 07 Jan 2021 15:55:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhe-0001b0-0u for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:14 -0500 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:43387) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhV-0001jc-Rx for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:13 -0500 Received: by mail-pg1-x532.google.com with SMTP id n10so5718444pgl.10 for ; Thu, 07 Jan 2021 12:16:05 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.16.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:16:03 -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=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=OdBATOSBTvLV6fipseieAicFSrcGArr85XzCqxEUByg9/g2Qs59ApU3wz1yplUW5x1 F1EdYjNOtw1KVPuRzSuBAdjOF8bbsQUTKQarMKk0vMjsdsnbVGdrobr/Lg85S4NbpOWO hdvHspBuBh/OqY9hlDuC6LhjDFe96FtP0J40gvX+sid+ks7jHShtq0Fb1fJaquR1TR01 5immbhK4jib+G+RPU0B2AhNL491mKSyWREOojpSv4izipNpm/A7cvLbvPkdtXvUPxtBa x8s5S0fEkIf9F8sTkSe9qFvyGjG2gk6uOMLYOoIoHzJ9v+cwO/H8Fh9llFo9cPLumwZm B+Ew== 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=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=LT8qQvShpqqOKFpjJC9OIxCNkD0vlsjGN95JALmGnwynvmDTEkI7E1XCjXh3XPbtVX DBqYwEAFlQ1bpm0w6uA55zFMSwqfBnoMVPeq6qde+JHh8MeLwRDJrib+qUfuxgbA+7lF wfHjU2CL6nTAu/W5NQJeKUjJSaSc3UQaBZ5qntuLbmjkuRssvaugXDgn44RUBrX1mBxA YyfFn14a8laebCif34gkteFz3ARtJW9Awv2nMbGbbYZDjBF8sa2MFw7fJLy9fVkbOp75 b9ajD/6PQGfHiK9c2XAY+wJExWlynRiLlfnITz1pUKNRxtQ/aDb9n4NQMlNh+dJDG+D4 j3UA== X-Gm-Message-State: AOAM533bmbqhL26Gg2zcoQQzHt4/1tT3Qaia4l1zw8CY6hkwbP/GRGBk +Oe38G/RE7w0d/zEuBEu4t9aJabBmwrImw== X-Google-Smtp-Source: ABdhPJzdEJIiNThUZNCgNhiS4eHWzjooEn+LZIc2Ie+68MUi8vG2wzmOg0Gkl0gvrTaG3TnVfF5mHQ== X-Received: by 2002:aa7:9d81:0:b029:19d:ca64:3c62 with SMTP id f1-20020aa79d810000b029019dca643c62mr3671495pfq.16.1610050563850; Thu, 07 Jan 2021 12:16:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 42/47] tcg/mips: Do not assert on relocation overflow Date: Thu, 7 Jan 2021 10:14:43 -1000 Message-Id: <20210107201448.1152301-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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: peter.maydell@linaro.org 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 Wed Jun 26 08:00:55 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=1610052707; cv=none; d=zohomail.com; s=zohoarc; b=S3puscpnqI55Ayp1hRoADFKM7KAbiFrgCJMtUBRzbis/aSvqzin8axmrt7XFMxr+yfe+U4Yl54wvPJX9pVO9LaesdQpJdqFcNxYo/cJpY/fpsJT/zY/YOOIvBcrPAxj3QgmvrstVkDjFnjH9w1E3NsxRr2g009EkMLODB1D2VdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052707; 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=GB4LwLk5ad1S19/6qn6+Wto2rSdhDANrw5dxSbGlL68=; b=jItlPEKdtPMN7HE83zAB9BDkjLkwnHg8M58beAz6rPUbeyYYNhjKNdRB+Tjm/xNqvJ+bxzQzF8rg9KohQwxnczQYiFFCig0W9jIp0ltmKTtR5NoNYIkFIOxJRzyZ7iXz4/mgJ9V2wZ76RpV0AEOFd57Z+m8WnSUAJ034zAgF1us= 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 1610052707268298.8773559869261; Thu, 7 Jan 2021 12:51:47 -0800 (PST) Received: from localhost ([::1]:40000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxcG1-0004LK-SR for importer@patchew.org; Thu, 07 Jan 2021 15:51:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhg-0001hB-SL for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:16 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:39492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhX-0001k4-Q2 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:16 -0500 Received: by mail-pl1-x62b.google.com with SMTP id x18so4158588pln.6 for ; Thu, 07 Jan 2021 12:16:06 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.16.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:16:04 -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=GB4LwLk5ad1S19/6qn6+Wto2rSdhDANrw5dxSbGlL68=; b=KLBq6tLqzv5/dN7fVIqKv1wafYzXQihHSbEXcJhlJyuB7Je5C0troHxVqEMaYNunm2 4i4aUa5YIP+l/E/xbfwc3HkIRtxuFylSAp5FZovxDgE5pSDJCdL69tdOcv7y97Qpmp7n FHd0aEU6m8k+TMwUaRDVpTIVcTV5aVLphgrlpWEYhGFZMNxMXmr/FbEEQMW87Tq4pIOW Znx5kg/5TsW5QYFy5998nuoh2HXS4KJ1AyRWMOh7pkYjAQRRqfLjmpASGccLoYz0bxPb eQg8PsWdZoamunYEN8uELvTwgqwUTdX9lknq5giKbaEwOu1B3kajgM76VnuTC652m3F+ zGKw== 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=GB4LwLk5ad1S19/6qn6+Wto2rSdhDANrw5dxSbGlL68=; b=od4aiHskanLhMbE0VkThtLEr4zdQQGlqa+vfV1Be5pw/84pqTrImYU5QNgHjtbTnyd 1KwXwlu0RX5HsjpTyE0rSXfbSCMszKdLtgwp7tuvDCoZG0x7sQyhq2zhIySZcACX7PRt Wvjs5x2xEDF9pRZATwxaZEzGVxrlTYu9qIMcD7Hrrmn9v/QIwXq1CTmjBffFD0qTj1Ou G0axchalgwx3v4eyvIPXV16zDwtsqmqT/IRD8TqJ/Ozunyk9Fp5cWCPrv/eVJ3AylZIJ UOFgAWrM7di9FGN7Mq5GqwZISCa3NakmrLq7cawdrLSk+hFNTVWnnXw4lufnF7HiN9ah lDxg== X-Gm-Message-State: AOAM531LWQmp7ks1t7fAxNf6D1IeIasJOAL9gAuw7XpA74+nkyavvDvJ JrT7yMQUj/a5KFktSnqX/umdPSWtAsIwLg== X-Google-Smtp-Source: ABdhPJwpzbveobBXBgdcoDwt6xYgciZsuQDrZkWqTSlkHwCFfjUuZLrBi0u0fbH8H8OIEeEA/xuCZg== X-Received: by 2002:a17:90a:430f:: with SMTP id q15mr182395pjg.218.1610050565310; Thu, 07 Jan 2021 12:16:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 43/47] tcg/mips: Support split-wx code generation Date: Thu, 7 Jan 2021 10:14:44 -1000 Message-Id: <20210107201448.1152301-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: peter.maydell@linaro.org 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 fbfe775fb4..ed5c347374 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -201,7 +201,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 Wed Jun 26 08:00:55 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=1610051450; cv=none; d=zohomail.com; s=zohoarc; b=T1OAf+0kNmj/Pn7sruDdZ8mHdZs3TOEuq4pt2724ePmTd2dlhqq4dYvRsDbHjSbQ/VfqCxkASUEYqCnb03wgqAk2rgFAzQlRx6uS3UF+ctT4asPtYHMIiMZtybqlRH0veqsu/1WxDvg3uQtXXnVcP1Ent67U1ExmcV+7TyRwmvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051450; 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=RjsLWt3F7DefhddvmyHDtzHbHX1tk83XD8LIVsXHpX8=; b=lZmX7mV3IKIiXRMyNYydVosBRojDnJKclIoi5Pt2c1D9PP/t2/D4ZwaiZClVmaMK04bFOsLtRNsplW9jUl6W/RwExyNLDCqXK/AkLO9pEJnrJi+VoFPT/E5O7zQOPQf5LN1RuFUWtcUNVkVAqBf1lw0lOKv6AgkI2efBFLVfM0E= 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 1610051450488695.9557907666621; Thu, 7 Jan 2021 12:30:50 -0800 (PST) Received: from localhost ([::1]:34648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbvl-0002hR-7Q for importer@patchew.org; Thu, 07 Jan 2021 15:30:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhf-0001eH-B6 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:15 -0500 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:46469) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhY-0001kR-H4 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:15 -0500 Received: by mail-pf1-x42f.google.com with SMTP id s21so4543276pfu.13 for ; Thu, 07 Jan 2021 12:16:07 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:16:06 -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=RjsLWt3F7DefhddvmyHDtzHbHX1tk83XD8LIVsXHpX8=; b=iF/sgumtKrFBoMum+1BTX8MfSxdhPBVAFyQ1gC9Nu0vyHnFOAfzi3yADxfZbga4ASM 3LbOo3vVVNa3z1wwT024XvW4EuP4J922DsAksluRgF2FUD+ykHmXe0XrY92JYEMmn1cz 8z5K+00U+8ETEHdjohWUU5Z4l7K1YXxJUKDUm/6i9lJneYPalgQvXqRyfN2I7UsCsS4H TQ9nwrI7DQy4CroO+AjwwiclfspBopZmCIJRqAuXeSr+iT98F3xxg5bgMx0KlCCwvQK7 vFJ57+sHN9e99MXPAO0CLmhOoGsqcICK+2al0PQJjbDPsETcbvVnv65wNiFBLQwQVl9X DYuA== 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=RjsLWt3F7DefhddvmyHDtzHbHX1tk83XD8LIVsXHpX8=; b=iUHo7glrXlijLzRqPCgPJeeBsfCfsWtQLxl+LlaNBEQUDOdNEF3cFXLeS+8AFDHI91 VIW5EIL4f3U74Pd4gHwGoZ4qmHDhQ7Y/ufgK4uy5D32sWs1x2TXwfOjn32pRhiBXdT2U tCv3thjVRohcIbn/AxalPRtqmHYVvmrrQiTwkAnzmxsAuvki4KibgOveOA7cM+LXXs+q GqTb085EgJ6qniq4qYqoF1ghdmj0Jsak7DHP4UBG1zYq5pwHjSpDCK2Et/bAPnF0u1HP 3sfSbIUqe6TivN0VCPnD0MvcmYKLYaV1W4FLey7bpNnvd+390shi4f1cjeTfYvOoXpmN Kwqw== X-Gm-Message-State: AOAM532WI9Mj8YcP3YLB9xd5mOo7V7ui5IZcrVOPNkVZmfnnOm7OUul3 KpF3YH4cmbLUcwQ4iaMK0PeCCISaThc8xg== X-Google-Smtp-Source: ABdhPJx1QPGFI9JMUgiAUHB5ZAZkBBMcW4w8sHGr2PsMZknvTJu2FYiAVKiqvygWt1EiZ8M2hbY/rg== X-Received: by 2002:a62:fc86:0:b029:19d:9943:c843 with SMTP id e128-20020a62fc860000b029019d9943c843mr390171pfh.71.1610050566710; Thu, 07 Jan 2021 12:16:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 44/47] tcg/arm: Support split-wx code generation Date: Thu, 7 Jan 2021 10:14:45 -1000 Message-Id: <20210107201448.1152301-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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: peter.maydell@linaro.org 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 494837d128..fdf75ba93f 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -142,6 +142,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 Wed Jun 26 08:00:55 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=1610051610; cv=none; d=zohomail.com; s=zohoarc; b=NxV+2vaFWBIpuaCUberbqBWBilZ7gNf26LvQYv81Hcg/9uCwitl1Ob5GpvkHR2EAe86KPO20j+CV+tJo1+XjoVOr3/eLiA434tZokwWLXfC2rO5WsSPOhOoE1+CpR3AmtMZfkLr632WJg2tYL9RGS/bvzDW55Bt0B8+Hvxom5bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051610; 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=gCTNNZGR2Nv/YxZ5iu2Rwl94cKut5s9Wts7t2uaTEAo=; b=EXX25DefY47Z1cJMqrz5JMNCS6DtQ+kwqFYMn/75zyYciJUT3zV7qn3WvKDWsVImWfWHj5o5vSVvgTKd0vT6WjgUcjAUYm8vH3fL8+9n5w0mNfpTN1Pkdp1Fbb2F/bq4gJ8JOPUSoiCRD4lmZ7IeP1VKAHB+rgTobB/pyFH/ykY= 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 1610051610678852.4106423078169; Thu, 7 Jan 2021 12:33:30 -0800 (PST) Received: from localhost ([::1]:42986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbyL-0006It-I8 for importer@patchew.org; Thu, 07 Jan 2021 15:33:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhg-0001fu-CT for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:16 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:52554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhc-0001lC-Lv for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:16 -0500 Received: by mail-pj1-x102d.google.com with SMTP id v1so2111162pjr.2 for ; Thu, 07 Jan 2021 12:16:09 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.16.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:16:07 -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=gCTNNZGR2Nv/YxZ5iu2Rwl94cKut5s9Wts7t2uaTEAo=; b=Jnruojja2wwFBxlXpPKxeytFNIhlxz/oniKPV+L01BoJi5bN+zj26WlNzK02SBcIH4 X5QpDcPsR/R1DjQ8W+1VbPmlK25VkGJBORbp9QECcoT+TuetO1Bgq8Gtie80pVJ5wn17 CWcUItQc4PD/BbVFYvKS+qIDDGEDSlsClwQO/nHXCPsbxXrugWrs+eqV4womzlvrlipk bCa15GjUyOQnFwlfPhpE2ArxxAPVBqvmRMCcQlK4dW2JFxc3XvWXFarEXeQ+92GgyGkw GKfBMLJMZHPXnjax0iMucjKCXLAiy2mq7Ndm6T/Kd7zvfQs1zzEV20iGb+vKxlAp3rfB OGSw== 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=gCTNNZGR2Nv/YxZ5iu2Rwl94cKut5s9Wts7t2uaTEAo=; b=dV7CEneU0eobNLVx/4kHoWK05UMWxn+Ir3BntYk2sm/hxKBuwKzb/CtLskBfOPJUgj hX6eMRaShyozh6YXzVTWJs0hjaQlO23aTbImzPbM2BPx6QmbJyf/NLQZQfZXH8QQHYD2 L3t0AeoW25nHMnfbPvEliq2rP1hoPVc6AHmwDHg92GfPeQJo8d5aC78JhzNUflXLid9f rjQEwHBgnzPGsmuXif7ggvkM9URFHkzRB0NmIR80UUzDaOnN+O9JsHKp7pmXvUEfu7Rm dAmkJqD/D1njtlwlVpgorq14Sf13zdk7/hyCLqsJ41/JjmWUM26dANoLmZcWD+Ss3t6g mVRA== X-Gm-Message-State: AOAM532NW9Oa19McN1QzxNr2PBnHQ/72PxIg0N3VJvSwELFeeEhc6sZ6 DDUvTbT2d7/VntB/W+1AD/e/j60u+t7ZZg== X-Google-Smtp-Source: ABdhPJxx+8x9oCJPC0CDbQzp34CZ0Lqa9Xsjf7uG9dZmAJMzoKNkDeEBcbdznYy41dKxTS0f43nC7Q== X-Received: by 2002:a17:90a:d307:: with SMTP id p7mr186629pju.214.1610050568448; Thu, 07 Jan 2021 12:16:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 45/47] tcg: Remove TCG_TARGET_SUPPORT_MIRROR Date: Thu, 7 Jan 2021 10:14:46 -1000 Message-Id: <20210107201448.1152301-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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: peter.maydell@linaro.org, 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" Now that all native tcg hosts support splitwx, remove the define. Replace the one use with a test for CONFIG_TCG_INTERPRETER. Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- 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 079828ea71..5ec30dba25 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -155,6 +155,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 fdf75ba93f..8d1fee6327 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -142,6 +142,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 cb1b138b66..b693d3692d 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -235,6 +235,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 ed5c347374..c2c32fb38f 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -201,7 +201,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 ec51f474a7..d1339afc66 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -185,6 +185,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 c50ecf4dab..727c8df418 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -171,6 +171,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 4edcb06044..641464eea4 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -159,6 +159,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 6426e24f17..95ab9af955 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -172,6 +172,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 d8c78d1dc7..bb784e018e 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -198,7 +198,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 02e1b05c42..e9de6ff9dd 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 Wed Jun 26 08:00:55 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=1610052413; cv=none; d=zohomail.com; s=zohoarc; b=i1vQX4AgqBLq5Tugd26siZdzykML+KPnyV2OuFXHZbtXQj0h3TX78ySuabYkryn+0FzPrQpIT9+YHL8AMU2FOW64HMtvZtBgQp2IXa6kkuC6WEfNazGni7ciL+8jQbqH1GUk1D4Bq3zKdUrAzi5xYpcc3iUuQ1Gf/uWnH8KZYro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052413; 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=yALInwLxUcce803tCT4lAV5xpKuz7Pin21e+mkRa55M=; b=Flmdi6Oh+35xmDiTjoSiKvhzvP1dbTgKGVDH47sLEZq1K/pWj8GDIXmifcxZJqWyGHlxEIz/m7c/Zg1kQuaG/lMDShtO1VqbnEQO3aMPcZMqjKtPxTuSS3mh2Nh+Y0L25kFVsr27Lo8Xi6gv9sY1gV8+QsUheDtcqDi77JBD5ig= 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 1610052413004231.5902612444246; Thu, 7 Jan 2021 12:46:53 -0800 (PST) Received: from localhost ([::1]:54342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxcBH-0006l1-V5 for importer@patchew.org; Thu, 07 Jan 2021 15:46:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhh-0001jc-OC for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:17 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:36989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhd-0001n6-Nx for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:17 -0500 Received: by mail-pl1-x62b.google.com with SMTP id be12so4161213plb.4 for ; Thu, 07 Jan 2021 12:16:11 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.16.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:16:09 -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=yALInwLxUcce803tCT4lAV5xpKuz7Pin21e+mkRa55M=; b=aDwsMHMktT72oGoroFNVDM0so4cZ2i5lxR9kPt39eA0z+pRaXObZvyR3teZFafg93H WntDLjyFbZpMrqOzoj2teZUFf7NRX0tfdG8b3puvjWaLszhR+5MpttBq5TYkympP1r1p ZQT8FlzEoOGwQQtHIlRHJFbelI+LEKys4xuY9VkUrsycXNXog56Oc543/fDSOA9GS/93 NXcQ1RUxpTIQ96+JrQXqBekNhnWc8+MfvnR8rHCuUBFAEhHQB4t8Iffps3x5+HijD1YG 8LmGlqz7wY+GbSUYg7q6PtWULa9sxOdzxmuZsma/kLrIXdKC4elr3ZfsSvlWyvB6Q2+I hf5w== 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=yALInwLxUcce803tCT4lAV5xpKuz7Pin21e+mkRa55M=; b=LCe82vI2oqqZ6fj9qIhuQBYXya+5i1H2W89Ytmc3pvF2QaS94dfRApm3MG3XRobUAn JKcJdJUfWCq04oOfFyI+Hz9lWzppiUXSFJ4dbj5YO3q1UV7KbSGWB2seYK6oWDSCfdW8 Gh64BJ5z/1ziBXuR6dNRv19/tfoKEj+uruQO4hG0xtpO4509RFaRM8MRZgvuwCoDFCJO T2QIy2P5YTlPR5qojAjc6aevkpyqE/hbr65Y5P9SWV3OsTfk0ksz/PSh/mSriNrIgOZ2 r/eriPxYduJt8yNWO2cUcTJbSJESSM/pFQhVIqqSc1ibW/emC5E27IxhrlHdRbl6QQX8 A5ow== X-Gm-Message-State: AOAM533jZq8ZxEbCIl6IdEaxB9r/KxhIVVJBo6H3LueRoI3Ee3XXoGEC cf3ejo5h2MfI+OcEFsyd/agqfyta6Knw/g== X-Google-Smtp-Source: ABdhPJwNqYZ0iKuatTabk3V81leQWiEGTAibjunHLm+iESJBhiKFPw+4ecvJFtgBjPv0GjoAxM1PgA== X-Received: by 2002:a17:90b:ec2:: with SMTP id gz2mr166288pjb.143.1610050570186; Thu, 07 Jan 2021 12:16:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 46/47] tcg: Constify tcg_code_gen_epilogue Date: Thu, 7 Jan 2021 10:14:47 -1000 Message-Id: <20210107201448.1152301-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: peter.maydell@linaro.org, Joelle van Dyne , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Now that all native tcg hosts support splitwx, make this pointer const. Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- 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 e6fce9a049..95fe5604eb 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 f278772512..472bf1755b 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 34bf0b9a35..91400d575c 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -3804,8 +3804,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 4d595b01d6..c76dc9f9ca 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 Wed Jun 26 08:00:55 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=1610052271; cv=none; d=zohomail.com; s=zohoarc; b=al9nCbLeu5Jxj1QYZIzqa4JfL5u0qCx4YiCa4egTaK4tzDcaXo4tucu+Tz692IvpiYdIurhyB69Hv0cXvLm5wQoLwwZt7+I4vVYzRygJujr9cw4fLsKkSa0IFo39f0bTnGnnTfjURFTFwORe49MzrPkCaAdxRMc2rFxEWwt/Iio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610052271; 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=/axlOMlK9mP+17efpjcCMV26tl84bU61W0fMNh0sRdI=; b=YKeLu9yuMTKOq7iU46Rr2PrO2YYDVVnjq1s65IO0XM3mUHXNIR0MelaymVgDCADHFPYwWsBQsKVFeiKd1ljwaJOoDo+8cYTse+QZ5IHrWPmQINMj/xhPqyXbR97ThGR8wtLQgiSz1wEo0MtBcn/Et7SkVOhCVSinLMvND7V1VpE= 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 1610052271789269.88880680790555; Thu, 7 Jan 2021 12:44:31 -0800 (PST) Received: from localhost ([::1]:47542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxc90-0003n7-Nv for importer@patchew.org; Thu, 07 Jan 2021 15:44:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhf-0001fT-Pw for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:16 -0500 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:46473) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhd-0001nk-Mw for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:15 -0500 Received: by mail-pf1-x433.google.com with SMTP id s21so4543457pfu.13 for ; Thu, 07 Jan 2021 12:16:13 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:16:11 -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=/axlOMlK9mP+17efpjcCMV26tl84bU61W0fMNh0sRdI=; b=Mvlb87Ax8F1pSxrYId/kf8csdowCkIiQ7FVPeo2DOX5HpaxtWP3G/vRT2SN/uEN4D7 XgKtln3HncNPkltdkVomAdWVK+/rRIwQSJqkaNtagVBsaw9b+E5v6/YUhqH/8e5a1PDs d2VBq5DsCMdJOD5WNXddSlqhtoiwOnluEy2VZcUP/gcTlCR+CFNiXnWnWbfly2CWeIHU fIg5pulSgGs0seIHDhRM4nt7n9s4fvq/OMm88uAIdGJkFlqwO3udeGcFVuTAW9mYJBQR UKuwUaADdgN6nOTNNHJdW2C7rWWKDOmVSGCRPRDBPBWnqInFyaXS73VaaZnsuVmwD/OU Osig== 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=/axlOMlK9mP+17efpjcCMV26tl84bU61W0fMNh0sRdI=; b=eevCAkRkfS6c5jn8fLKhfnsIN5Ny/w2bXj5wY4ny/22qzFhl6UVjRwTj+VBj9nOOjb 8R5H4S/9M7/CRqNnXPpshjH1JzDkt0PBnQg2Q4uGYOBDjdAwAANERcUYfuZnYPcpWkb5 H7I3a76ENvT8J6nA5fwlvQXgLIczazWm+6ZKFoQ11BYrfSoWvgr7L1YN40tmr/rKkrtn Fq1dySuznsAEHvwsMZQ+E1k3A2PQpZlWTpGx4JtVzrMx2qbY9599L+wvMSMP4fM0VghQ 0h1o4NHJ6ZrN1WK6MIT5t+oWow4r7URomMZ1c8GaNCtOaC423qhwbjmVRXcD/bLZAtzm AbYg== X-Gm-Message-State: AOAM530kVn8HG1mBZR1Lc7n3ywkP4kq4xZBINObVbNx04AA3XfVSC34c 7hls3RhktS/yLQlI1vz5YdxTu7oZnHHD+A== X-Google-Smtp-Source: ABdhPJwMAjCY5wI7fLpbpJq3KudYM+q8VeDSuosH5/u4sYbbuKSOU82kpHsP8yDx4JkuKJuXg+bL5w== X-Received: by 2002:a05:6a00:a88:b029:19e:4ba8:bbe4 with SMTP id b8-20020a056a000a88b029019e4ba8bbe4mr3675085pfl.41.1610050571831; Thu, 07 Jan 2021 12:16:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 47/47] tcg: Constify TCGLabelQemuLdst.raddr Date: Thu, 7 Jan 2021 10:14:48 -1000 Message-Id: <20210107201448.1152301-48-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-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::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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: peter.maydell@linaro.org, Joelle van Dyne , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Now that all native tcg hosts support splitwx, make this pointer const. Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- 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 91400d575c..46e856f442 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1795,8 +1795,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 c76dc9f9ca..c60b91ba58 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