From patchwork Tue Jan 5 17:19:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356893 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp311567ejs; Tue, 5 Jan 2021 09:38:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6zmi3W2UzaYIfOpVxL3E0kqWgmdpyAdenjJn90x9XGA0uMMY8ax6/Xven2YIZtsyJb/Sj X-Received: by 2002:a25:ade2:: with SMTP id d34mr709874ybe.15.1609868318178; Tue, 05 Jan 2021 09:38:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868318; cv=none; d=google.com; s=arc-20160816; b=d87/hzGBx6k0343nMX5RyBrWG8E6xI0qogkEasC9ig7oktxGq4F7gSuDePfaCZxpzz vp0sZtPiDMPxJTIGIQyIhx7mgn7Q0GryKY7tNBqbYHx56wCGwH6PMAdQgPZrDUP4f49W Z+ULkWiLgvloU0hP7vXRbkSp+jfEJcZvVfC62Q+dIoe2Xriqv8BG4/8aGbtJJEnY2k2m QO8ts5Gx9Dn/l6MrqIVdSSeUUydbueg11hfrdse8JMn0k5zplUg2UZKaAoAcH3XeRdMj kSGJNaeIfdxC4LH6b1q7heunWmIPstrGMwnUpqL5xBFdKNOjoGiuJqMS/5eSb26+QjLU b9Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=kNa3juN30sBbMGsW4bu1mvrrXIbWt9bpEcnE51uKtNA=; b=RTGBL1zRfvYz/0AUb5vkpS+kQ4Nn+cZ+DnrAx24XOD8IO+2QXoG1LOr4RyYnr8VZ63 idJE3TudSj/ezeI2B5dxJTqyrJMlh/1wqPwe1Q6ibG6xQGvLGMgOAHdh9bzABZKt/b6r noJzTAKr/Grabf37FZCqrZbtkN18U1FL6ablbM7gyoTGkhYn/HXzroXo+i6fGyn5srJ8 o1Q2RDswRPXmcp4TCQ+jMs7LpeCkvbrmH+uCzbjMck/tfW5tDj8w8ltBQ2XPLSK6sLpL 0Yq+tWnC395KD/aKVfTFM7Uy1UWGcEbwxtzhz6YNklo6P/hEJQR3b5NUo0+AYvFR233u RQcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cftMLHpd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t29si522787ybt.474.2021.01.05.09.38.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:38:38 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cftMLHpd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqI1-0000AN-KW for patch@linaro.org; Tue, 05 Jan 2021 12:38:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq09-0002Fo-9M for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:09 -0500 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:45955) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq01-0006Qi-Jq for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:07 -0500 Received: by mail-pg1-x533.google.com with SMTP id v19so255043pgj.12 for ; Tue, 05 Jan 2021 09:20: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=kNa3juN30sBbMGsW4bu1mvrrXIbWt9bpEcnE51uKtNA=; b=cftMLHpdS9X6G84jy/FqciZTdu1cuomAirdWqNYDhwQL+3acq975VoZFlitNBRglQ5 mn/eLmW57v2WoLmJfQY/jQkEOvQUqky3X0pLDzb/NAz1MayZ+WJTK/799D4+p6e54XtR 4EZt/bnf++jFL4R4Mzb5qxJsZjo6f01dudYinjwPdWCIrfUEhyfpeQkfoa2b4B91/TL8 cNpZVBGyfH2a+AZvtmqgLxuAG/m8aNYb2fvNtt3lybsTVQDduiNeh0Q7eeMi4KtUPfcG 6JPubMhV70qmIVdbz+HWa1xnZ/U2olMeiV/m+KNF1D6J2ufeDYWDuwglCJlo2HvuJFs5 5pXQ== 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=kNa3juN30sBbMGsW4bu1mvrrXIbWt9bpEcnE51uKtNA=; b=W6pcoAegUySeYxm9j1/As0I5czXbPFB5aSOdO411M+F2LZMsxbUgwKMfR1evSvAyyp R6F0N7gzNApwglZLQoO5q+HfI0/+R0zc6fpSf8jVl8FXy0QOpDr6rZ0t/lRQD9NONLjN ZdWGyeX/v7qkAc4OqYHfv9kytlRAOYumJgtgklSXkvWT0e/sYfuyAloGIDTl9yDjjn+n beufOL2ENyb3Ugooj51lMESe4r3jsegTzcn05hFl+o9C64BIBQf/9IMqG9r1Kd118XcS J5edy9r8hou/ZzhQLS2A/fyPmmfWVBQkJLMtyo8QAgGefOtLWro8hfqhvu0cz+2DeTU6 Rjdg== X-Gm-Message-State: AOAM532VzQ4TIt6SL6vBDJ5Lpo7F9wKjTYHfa2LnChbOgDXIjXLbzyCk qGI0o537yR9npUB/f5FW+bUlYR2n3lE5BQ== X-Received: by 2002:a62:b415:0:b029:1a6:8b06:68f4 with SMTP id h21-20020a62b4150000b02901a68b0668f4mr193965pfn.43.1609867199868; Tue, 05 Jan 2021 09:19: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 u12sm2010pfh.98.2021.01.05.09.19.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:19:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 01/43] tcg: Do not flush icache for interpreter Date: Tue, 5 Jan 2021 07:19:08 -1000 Message-Id: <20210105171950.415486-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(+) -- 2.25.1 diff --git a/tcg/tcg.c b/tcg/tcg.c index 829d4296e0..df2857dc88 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1077,7 +1077,9 @@ void tcg_prologue_init(TCGContext *s) #endif buf1 = s->code_ptr; +#ifndef CONFIG_TCG_INTERPRETER flush_icache_range((uintptr_t)buf0, (uintptr_t)buf1); +#endif /* Deduct the prologue from the buffer. */ prologue_size = tcg_current_code_size(s); @@ -4323,8 +4325,10 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) return -2; } +#ifndef CONFIG_TCG_INTERPRETER /* flush instruction cache */ flush_icache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_ptr); +#endif return tcg_current_code_size(s); } From patchwork Tue Jan 5 17:19:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356882 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp303563ejs; Tue, 5 Jan 2021 09:26:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8m31+ZcNJtv0jayglkuG1VkqOFK3OQM4E9zfa0nlFjfp+4MsOTszKDQhJUd1l1NeEoT+s X-Received: by 2002:a5b:3c8:: with SMTP id t8mr617512ybp.19.1609867599165; Tue, 05 Jan 2021 09:26:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609867599; cv=none; d=google.com; s=arc-20160816; b=fuM7wmqZLjbbLhyXzCYdX2JPLx/HbWuqtYIeL6spGSDdnEsKwdg+R2p3N1WnMYiFAY l5Ez9yL5w/a9gvQEeX5IEK4arb8WieLinr+C1fuadjwo5FR09iCNMBdsCGjfQ0f4aRiu EDsGjLAjBhwebG4n98Hf1uaABCNdD1hepaZNSZS2/y734FqbazBXb1pgMmumehXtteaG AdKF79wDGEStqZ2UhUk11VvX/b1AookIQ7dCzGg7FIN3v9KMrtJ4v/mUGwd9/WtfAZkg NZ5Y4UYYXQKC0/GNQVexopFdcaWk+EsYUh0vvB4pXv9PYpt2o58N1r/JpfK/ASKKzK6B z0Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=COs7EFurKzdEkJGVYLhpSUwSiXcrdUCH71QLYE3G/IY=; b=oCjLTbtk8DIXvxeyXtKQQj/NeEE0soiEuHGFo4JYPtKq939x+yMvIFNcnyRgmIiBGf 35xcxGWzqIeWJMKzUvOSbD4uAXZUtMdvyAgOUXF7+sporghkhxnuS94ysl7D6QUzTZZh 5I1eZb2hyzZYf/YOHBYke//6kby4e95Xjg/EZmDvtLtUWPbxOXPWlomGoRZEBu6XVsDM /v4j98ZHu8L9GQtcXqGF4VNt5FKULL82rWDmubzAZZzgGnQdMl4vz78CrLiQCEuaxH5a yQ39RXq0mfb2t9RGY9CXZudns7JkenqTE4TPEcepAzr/CSB6ghbjNuHomKOtVOa1moK6 iiIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="o/DHP8nA"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x36si473582ybd.122.2021.01.05.09.26.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:26:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="o/DHP8nA"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwq6Q-0002Mj-Ef for patch@linaro.org; Tue, 05 Jan 2021 12:26:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0A-0002Gi-GG for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:10 -0500 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:42655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq04-0006Qt-AT for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:09 -0500 Received: by mail-pg1-x531.google.com with SMTP id g15so270403pgu.9 for ; Tue, 05 Jan 2021 09:20: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=COs7EFurKzdEkJGVYLhpSUwSiXcrdUCH71QLYE3G/IY=; b=o/DHP8nA3c0qaJHuVflNt0hD/a0l2DAfXC5Uz3392oapIv7eUM/5mqcJKG797HWXDV QPTGuIll0CUKrhAQueq7Uuohprb8VDtNYKFqJSzYgkGjrInavFyT1S7faulZr3fE619K aBCjPlbsCh8u5kRYrtOcrcK2LvNLaaLsT93wUvWkPYEFlNxTnxTsj/UmJ9Yo6UcuUZas B5p/Xd5KAKGoyW9p3eA6Jxmw0YC2TMI8ScgmfGn9LbMsPxg1doM2+nmC8nNvSai2Kcad vHc7jdhMksuogtp3rF06kAdUkfxaVz/+LOc2ukvle9gttdzfSN4oDWa02UtACYxr2Ny8 wOlg== 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=COs7EFurKzdEkJGVYLhpSUwSiXcrdUCH71QLYE3G/IY=; b=FadbUOKEPMeY35gNXughF5ON1EvnN/F8kcJ2wV6w6De2YPl5h8fjExMgQtFNsEQYmi 2v9XoRxEGr9/04odHMGKwI3vKOGdUKm1OB4wRlvPNOA/tAXAMcLVvM5nFNLD5bDdy6RE Z+AxKUomO98eInYjGSZJNNxB5+7m0PNGrgO+37g6ITGiIkS/3ADwxffwp9bWzMwQnjIA To9nRKC+S4IMulgtFOvNj4RJ4PbRTFx0va5+g27A3IHRkk4qS0pVLA43Hrycpzs22PMe qkRhvGa7OoxwIXBjRFOfmwaipcVqxevdOfmf0OmV6uDGjT+SWr6cnHE+/pDm2U5yOOkr LbPA== X-Gm-Message-State: AOAM532Uk4F8shFkmUoZjBBAH7W1E9cBzhXBQgLtHp+KMAKmzXD0ReKL +Pc1sU8G9RNEwfdAfIfCNiQHZa8X5XnKug== X-Received: by 2002:a62:184e:0:b029:19e:c636:17f9 with SMTP id 75-20020a62184e0000b029019ec63617f9mr442575pfy.23.1609867201483; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 02/43] util: Extract flush_icache_range to cacheflush.c Date: Tue, 5 Jan 2021 07:19:09 -1000 Message-Id: <20210105171950.415486-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This has been a tcg-specific function, but is also in use by hardware accelerators via physmem.c. This can cause link errors when tcg is disabled. Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/qemu/cacheflush.h | 24 +++++++++++++ tcg/aarch64/tcg-target.h | 5 --- tcg/arm/tcg-target.h | 5 --- tcg/i386/tcg-target.h | 4 --- tcg/mips/tcg-target.h | 11 ------ tcg/ppc/tcg-target.h | 1 - tcg/riscv/tcg-target.h | 5 --- tcg/s390/tcg-target.h | 4 --- tcg/sparc/tcg-target.h | 8 ----- tcg/tci/tcg-target.h | 4 --- softmmu/physmem.c | 1 + tcg/tcg.c | 1 + util/cacheflush.c | 71 +++++++++++++++++++++++++++++++++++++++ tcg/ppc/tcg-target.c.inc | 22 ------------ MAINTAINERS | 2 ++ util/meson.build | 2 +- 16 files changed, 100 insertions(+), 70 deletions(-) create mode 100644 include/qemu/cacheflush.h create mode 100644 util/cacheflush.c -- 2.25.1 diff --git a/include/qemu/cacheflush.h b/include/qemu/cacheflush.h new file mode 100644 index 0000000000..58ae488491 --- /dev/null +++ b/include/qemu/cacheflush.h @@ -0,0 +1,24 @@ +/* + * Flush the host cpu caches. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_CACHEFLUSH_H +#define QEMU_CACHEFLUSH_H + +#if defined(__i386__) || defined(__x86_64__) || defined(__s390__) + +static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + /* icache is coherent and does not require flushing. */ +} + +#else + +void flush_icache_range(uintptr_t start, uintptr_t stop); + +#endif + +#endif /* QEMU_CACHEFLUSH_H */ diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index d1159d80c6..108a1fa969 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -149,11 +149,6 @@ typedef enum { #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - __builtin___clear_cache((char *)start, (char *)stop); -} - void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); #ifdef CONFIG_SOFTMMU diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 1e132afa75..1e18fefd0e 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -135,11 +135,6 @@ enum { #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - __builtin___clear_cache((char *) start, (char *) stop); -} - /* not defined -- call should be eliminated at compile time */ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index abe8636f0d..f3836a4d0c 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -210,10 +210,6 @@ extern bool have_movbe; #define TCG_TARGET_extract_i64_valid(ofs, len) \ (((ofs) == 8 && (len) == 8) || ((ofs) + (len)) == 32) -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ -} - static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index b04c12d317..624248b81e 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -199,20 +199,9 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_HAS_ext16u_i64 0 /* andi rt, rs, 0xffff */ #endif -#ifdef __OpenBSD__ -#include -#else -#include -#endif - #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - cacheflush ((void *)start, stop-start, ICACHE); -} - void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); #ifdef CONFIG_SOFTMMU diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 7ff46b3d6d..301173c97e 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -176,7 +176,6 @@ extern bool have_vsx; #define TCG_TARGET_HAS_bitsel_vec have_vsx #define TCG_TARGET_HAS_cmpsel_vec 0 -void flush_icache_range(uintptr_t start, uintptr_t stop); void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_DEFAULT_MO (0) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index ccda7b83c4..888288d54c 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -160,11 +160,6 @@ typedef enum { #define TCG_TARGET_HAS_mulsh_i64 1 #endif -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - __builtin___clear_cache((char *)start, (char *)stop); -} - /* not defined -- call should be eliminated at compile time */ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index 7e7396caf2..69576f4a9a 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -146,10 +146,6 @@ enum { TCG_AREG0 = TCG_REG_R10, }; -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ -} - static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index f2989b3b45..9dce305253 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -169,14 +169,6 @@ extern bool use_vis3_instructions; #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - uintptr_t p; - for (p = start & -8; p < ((stop + 7) & -8); p += 8) { - __asm__ __volatile__("flush\t%0" : : "r" (p)); - } -} - void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 7192d5319e..e8277caee2 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -192,10 +192,6 @@ void tci_disas(uint8_t opc); #define HAVE_TCG_QEMU_TB_EXEC -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ -} - /* We could notice __i386__ or __s390x__ and reduce the barriers depending on the host. But if you want performance, you use the normal backend. We prefer consistency across hosts on this. */ diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 2cd1de4a2c..c595266b9f 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -22,6 +22,7 @@ #include "qapi/error.h" #include "qemu/cutils.h" +#include "qemu/cacheflush.h" #include "cpu.h" #include "exec/exec-all.h" #include "exec/target_page.h" diff --git a/tcg/tcg.c b/tcg/tcg.c index df2857dc88..9bdc450196 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -35,6 +35,7 @@ #include "qemu/host-utils.h" #include "qemu/qemu-print.h" #include "qemu/timer.h" +#include "qemu/cacheflush.h" /* Note: the long term plan is to reduce the dependencies on the QEMU CPU definitions. Currently they are used for qemu_ld/st diff --git a/util/cacheflush.c b/util/cacheflush.c new file mode 100644 index 0000000000..2881832a38 --- /dev/null +++ b/util/cacheflush.c @@ -0,0 +1,71 @@ +/* + * Flush the host cpu caches. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/cacheflush.h" + + +#if defined(__i386__) || defined(__x86_64__) || defined(__s390__) + +/* Caches are coherent and do not require flushing; symbol inline. */ + +#elif defined(__mips__) + +#ifdef __OpenBSD__ +#include +#else +#include +#endif + +void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + cacheflush((void *)start, stop - start, ICACHE); +} + +#elif defined(__powerpc__) + +void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + uintptr_t p, start1, stop1; + size_t dsize = qemu_dcache_linesize; + size_t isize = qemu_icache_linesize; + + start1 = start & ~(dsize - 1); + stop1 = (stop + dsize - 1) & ~(dsize - 1); + for (p = start1; p < stop1; p += dsize) { + asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); + } + asm volatile ("sync" : : : "memory"); + + start &= start & ~(isize - 1); + stop1 = (stop + isize - 1) & ~(isize - 1); + for (p = start1; p < stop1; p += isize) { + asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); + } + asm volatile ("sync" : : : "memory"); + asm volatile ("isync" : : : "memory"); +} + +#elif defined(__sparc__) + +void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + uintptr_t p; + + for (p = start & -8; p < ((stop + 7) & -8); p += 8) { + __asm__ __volatile__("flush\t%0" : : "r" (p)); + } +} + +#else + +void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + __builtin___clear_cache((char *)start, (char *)stop); +} + +#endif diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 18ee989f95..0d068ec8ab 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -3863,25 +3863,3 @@ void tcg_register_jit(void *buf, size_t buf_size) tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } #endif /* __ELF__ */ - -void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - uintptr_t p, start1, stop1; - size_t dsize = qemu_dcache_linesize; - size_t isize = qemu_icache_linesize; - - start1 = start & ~(dsize - 1); - stop1 = (stop + dsize - 1) & ~(dsize - 1); - for (p = start1; p < stop1; p += dsize) { - asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); - } - asm volatile ("sync" : : : "memory"); - - start &= start & ~(isize - 1); - stop1 = (stop + isize - 1) & ~(isize - 1); - for (p = start1; p < stop1; p += isize) { - asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); - } - asm volatile ("sync" : : : "memory"); - asm volatile ("isync" : : : "memory"); -} diff --git a/MAINTAINERS b/MAINTAINERS index 42fedf91e7..478bea667c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -119,6 +119,8 @@ F: softmmu/cpus.c F: cpus-common.c F: accel/tcg/ F: accel/stubs/tcg-stub.c +F: util/cacheinfo.c +F: util/cacheflush.c F: scripts/decodetree.py F: docs/devel/decodetree.rst F: include/exec/cpu*.h diff --git a/util/meson.build b/util/meson.build index f359af0d46..a3dfc0f966 100644 --- a/util/meson.build +++ b/util/meson.build @@ -21,7 +21,7 @@ util_ss.add(files('envlist.c', 'path.c', 'module.c')) util_ss.add(files('host-utils.c')) util_ss.add(files('bitmap.c', 'bitops.c')) util_ss.add(files('fifo8.c')) -util_ss.add(files('cacheinfo.c')) +util_ss.add(files('cacheinfo.c', 'cacheflush.c')) util_ss.add(files('error.c', 'qemu-error.c')) util_ss.add(files('qemu-print.c')) util_ss.add(files('id.c')) From patchwork Tue Jan 5 17:19:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356880 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp299653ejs; Tue, 5 Jan 2021 09:20:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdEFgtYy/X+S7G+aLRSOJMYFBVwYSXfSaHLHDwqHRI+XeMeCNkDYo9TL/Ck7fGHvNyWgBl X-Received: by 2002:a5b:eca:: with SMTP id a10mr569312ybs.447.1609867259575; Tue, 05 Jan 2021 09:20:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609867259; cv=none; d=google.com; s=arc-20160816; b=v8RSZTrcLwWv5RRIsT9Uvlunea8kF/JVvhHMXTuPSsJScKAetjdPtvUib1LzR7UMtj iN9qvyNt28344vBJ+sqh5ykRLXFLh5MOp9qhs9CvU9BnazoDsPSr6IzYDo2JT22S3Bfd yWbSwAxBihDC1W5fbOth2xFVv5cIdbIXipwETqBl7fk+Y/dWQvLfgo7F9d99flcq92f3 uRub4TGblTntDYwFDyk5QedYdBtzWOYUmXWqpSm+XRjOjuPWy1Chlb+ED2KdsI8Qe1lT 0CWKhF3csdZsZConNPRTvMwizYVEmsIAQXKAm+aW5ebkOIxxMixNax5I/TU40BaXtyZ/ /l7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=UW2e0M7l/Z+9/S5/2AeOh4O7fYeLa2EeE8+auV1ifcI=; b=G469b6gKxXndm7UEOdSClRLhvKnC0OeQTZgHHRugL0RFqAb0S+UbIGvEHpqtqPVbej YBs9XVqtxkSi+gdODXTdQ+Y70i1odG+dEnqeLCJuZfCVLaE5f63+b6cEuT4EbJT7iQIR e6ypvXeoyWYZHagoQ1JH1DXtAMP+c6fiCdTW9Ib4GtmoKgUtRxsCMlTH7G9DP9U4M077 pnEK1LtgMoJCvUv/ZXd2U3lwRxg8JOY3JcN3pu/m8vh/8W7lgaozJcZv1zxDjxP+sqY0 /dq7PbupePFXg+esBFr4XIDAA/x9JqoSixNls7TvnNJStupaj7IlRTJwUgDQRUJ/xbSn Q4eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QeU9pMqY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 7si397319ybe.391.2021.01.05.09.20.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:20:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QeU9pMqY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwq0w-0002IH-Tl for patch@linaro.org; Tue, 05 Jan 2021 12:20:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0A-0002Gu-JI for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:11 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:36033) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq05-0006R4-2B for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:10 -0500 Received: by mail-pg1-x536.google.com with SMTP id c132so289680pga.3 for ; Tue, 05 Jan 2021 09:20: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=UW2e0M7l/Z+9/S5/2AeOh4O7fYeLa2EeE8+auV1ifcI=; b=QeU9pMqYzKWIjYye6txzX68aMiCCNsvzcwWxQ212iIBKJE3ImGnqCfDWlEY+te6XoD P1j1gQTKNFTlOyVE1jCvBgRaFjVxfCtL5A73idaimpz4hAJi8NjMSTmRFDWX+ntw8jJf Nt8pgu75b2v/7smlNoC0Wom5PupNPCQ8YnuyFka3zdi0D/MZLVQ2fNdjN9aD6ytPqTyk /Z56q3GNAYjJtaEw2VmCPxvwrx1iDsCdk2GtrRROjlXxNBLlCrvsk7HmJq69G7LNvo58 KWh+ALp10Y24VIF8/gokTeDq+g2nSzIxyWafdy32+G5r6Mpo7XwvZZqF9syjGCl2NYR8 ttlg== 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=UW2e0M7l/Z+9/S5/2AeOh4O7fYeLa2EeE8+auV1ifcI=; b=jD3oWFedSOTpNnWBPfMnJz+Zc0j5wvqzxsL0umyBK/oIB7yGLF7oJETcnm2ptRyYWu So+iaDmRQZtMsRx/xev2SjyuM9FfyvaVWUmF9nMrKwC9BP37/gyTpc8VD6Qme4xpnNAR b9kBgkm1Z+/hUX9MVCh7HZu4oNQOTRSA/vzq//tViZXOokEoQNCXZCrETmYzYWl2lv8k WfMJ74Hc3VsUzr2IZCR/gVpRzdENLor+m66YARLRH84Fxu34UNEqg0QAxUBs9J04CaGo v2nrE/EDTn3x1LA0EC+iWslpLKneTa1FKMpceOeHbhJfy9lrIb3clD/jy8bfFCGQYmbf mv5w== X-Gm-Message-State: AOAM531RArlsYAGWKFRHSfGEMqS8RnYG2PA38X8YqFmVZJ+ZDvcDtwYV D1XcddS7oLVK68wxRBpsh1HGpjNKpgihNQ== X-Received: by 2002:a63:4644:: with SMTP id v4mr348156pgk.440.1609867203213; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 03/43] util: Enhance flush_icache_range with separate data pointer Date: Tue, 5 Jan 2021 07:19:10 -1000 Message-Id: <20210105171950.415486-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: =?utf-8?q?Alex_Benn=C3=A9e?= , Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée 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(-) -- 2.25.1 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 +/** + * 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__) -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. */ } #else -void flush_icache_range(uintptr_t start, uintptr_t stop); +void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len); #endif diff --git a/softmmu/physmem.c b/softmmu/physmem.c index c595266b9f..e9d205f63e 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -2947,7 +2947,7 @@ static inline MemTxResult address_space_write_rom_internal(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) buf1 = 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 /* Deduct the prologue from the buffer. */ @@ -4328,7 +4329,8 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) #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 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 -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 != rw) { + cacheflush((void *)rw, len, DCACHE); + } + cacheflush((void *)rx, len, ICACHE); } #elif defined(__powerpc__) -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 = qemu_dcache_linesize; size_t isize = qemu_icache_linesize; - start1 = start & ~(dsize - 1); - stop1 = (stop + dsize - 1) & ~(dsize - 1); - for (p = start1; p < stop1; p += dsize) { + b = rw & ~(dsize - 1); + e = (rw + len + dsize - 1) & ~(dsize - 1); + for (p = b; p < e; p += dsize) { asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); } asm volatile ("sync" : : : "memory"); - start &= start & ~(isize - 1); - stop1 = (stop + isize - 1) & ~(isize - 1); - for (p = start1; p < stop1; p += isize) { + b = rx & ~(isize - 1); + e = (rx + len + isize - 1) & ~(isize - 1); + for (p = b; p < e; p += 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) #elif defined(__sparc__) -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 = start & -8; p < ((stop + 7) & -8); p += 8) { + /* No additional data flush to the RW virtual address required. */ + uintptr_t p, end = (rx + len + 7) & -8; + for (p = rx & -8; p < end; p += 8) { __asm__ __volatile__("flush\t%0" : : "r" (p)); } } #else -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 != rx) { + __builtin___clear_cache((char *)rw, (char *)rw + len); + } + __builtin___clear_cache((char *)rx, (char *)rx + len); } #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 = *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 = *dsize = 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, uintptr_t jmp_addr, } pair = (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); } 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, uintptr_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); } 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, uintptr_t jmp_addr, /* As per the enclosing if, this is ppc64. Avoid the _Static_assert 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 = 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); } } 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, uintptr_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; } @@ -1860,5 +1860,5 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, } 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); } From patchwork Tue Jan 5 17:19:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356905 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp187626jai; Tue, 5 Jan 2021 09:45:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdJt2mLyXN0/5G2Pqa7AlNvPykesZZWsQSNJJixPUY3fG7kz7Vv28GniUESz3AphN/8Qv6 X-Received: by 2002:a25:250b:: with SMTP id l11mr849288ybl.196.1609868710300; Tue, 05 Jan 2021 09:45:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868710; cv=none; d=google.com; s=arc-20160816; b=dsu0mDfHwsYAXr1wTYpH0sluODuDttZst5p1my0Zp/kUHPls8dbKr8LqJydv5jWSRi 0b4/d1k8lLviW87Utxvl1AZrpmfYr7h1ma2x1uf7ZqKXzX0dEf0MyGdZgcktvpvyuzN8 vRNaAz1+0xtQfe0Sosyy7hqSDnlWIR0PZkIIXtpkEZgjdNj2TRRul6JnzPvFQFt4iAzG mT9+446v/IV2l8d5TNUIoA/bIWDpBeLS12LhkRzz8+zijMC5NIRNe7HfScOgzP+T8tLe vcieMLjXwPCVrXLyKvVMBIMb3s5dIRSo6JmPV8LF/YpTVAnSpcXKH+hIqbWelQ3pJUNF hGaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=NqDvAjSsLSimLcFmAjOdfLypVhA8Qg70u4hgiCmTSw4=; b=C2dhOygABZYJoKAMB88kTKVu4B8syTNs5xeYFL6Zdu+pQ4IbDCK8KsNtG4ckXp0S/M JnayhBBdInJReFfkSWUzlQhr+GrBNqRXq7/3MbqGEvUWKCz20YbcS//TCWv+cVCyrC2D iU2pLiY/Rol6xDf894LamuJPSFoj4kM3O1asz0GcyIiqo/iuAIoAiIAPHQaXaVP2gHUg 9Al+ggSj+bUeQtciq+MZboldCEjUFYnmsnhrDfnd5VV3MHrUrjdHIPngniSELjEAHOtm lbkK/9VVlO0JA+0XvZZEfunYDVcMotyb4nHQvemj4cY7vH3ZccIbte/SwzwaqBN+5nJi Ra6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="x/ESSped"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h13si507827ybq.232.2021.01.05.09.45.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:45:10 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="x/ESSped"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqOL-0002C7-QS for patch@linaro.org; Tue, 05 Jan 2021 12:45:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0H-0002Is-4V for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:17 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:45543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq07-0006RI-A3 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:12 -0500 Received: by mail-pf1-x436.google.com with SMTP id q22so101296pfk.12 for ; Tue, 05 Jan 2021 09:20:05 -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=x/ESSpedXBeFlnRFsPIKceBYtW9mD5NB57qPwmlqel24EloiJsL9LBAaaxslOKF7/k m8ETtSHJqF55iMCeFbx5uSrmOCsdH1lS+AgBws4JYEZTSTjTYpcmMFFLdoI4DB0sJhGd wbpoPjUF6gzCtoqNrHb4lOZSnJd1kPw0ajNTyJocxBVtZfXs+HZqrAKB16o1J7uQZeD+ 8AxR9pFh2LkI0f2UYvehpfRMC7nvQ5qFXBc1IeLo+HSFXrmuCgDx0sLOCamFl/PNvkBr kMZE1zsExc0dz7gvCNUwjz3JFxV52rNtPlbPnJI1a0Ha+6yazlb7xZS54Y4KQUMtCamQ C6LA== 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=N0byVBZZce/dmBJY5EAKResj2o984SNbkcKqtZhUy+3y4PCd3/vHNnpLy1Xo6Fr9UO JSa8YHTxAmNyhY2ocDHTb84bn+vo7pUhMaYF1Xzn2YbqMZcvzaheEwsirl8Y8dKxiVid hac849ns1jQOADkgTVFePH+uJu2fYHM5GPnNRjOew3/+LIznE0SUvYkcL2phUMTIe42k P0ny7KN6EwKaTIeFpxD8fGWFAnDXdphp0VOZjx9aLIfQKuTjZpg78ZumELaY2NZH7Oja illDMs3R2lOXMsgX2+5L3RroAjD1A7WbkkivBXcptM6f35d7K6Gy1r6pCiIZ1HoD3SfL M9uA== X-Gm-Message-State: AOAM5322sjAVJ3NWfrxkBT4nIAq7IPvcThxs8G22WEF8gyM9fDZsGCMP xJhWFJ9/p6ZZ0M3HsW32g8ksq128UNy1Gw== X-Received: by 2002:a63:4d59:: with SMTP id n25mr362531pgl.122.1609867204698; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 04/43] util: Specialize flush_idcache_range for aarch64 Date: Tue, 5 Jan 2021 07:19:11 -1000 Message-Id: <20210105171950.415486-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(+) -- 2.25.1 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 @@ #include "qemu/osdep.h" #include "qemu/cacheflush.h" +#include "qemu/bitops.h" #if defined(__i386__) || defined(__x86_64__) || defined(__s390__) /* Caches are coherent and do not require flushing; symbol inline. */ +#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" : "=r"(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 = 1u << 28; + const unsigned CTR_DIC = 1u << 29; + const unsigned int ctr_el0 = save_ctr_el0; + const uintptr_t icache_lsize = 4 << extract32(ctr_el0, 0, 4); + const uintptr_t dcache_lsize = 4 << extract32(ctr_el0, 16, 4); + uintptr_t p; + + /* + * If CTR_EL0.IDC is enabled, Data cache clean to the Point of Unification + * 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 = rw & -dcache_lsize; p < rw + len; p += 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 = rx & -icache_lsize; p < rx + len; p += 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__) #ifdef __OpenBSD__ From patchwork Tue Jan 5 17:19:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356900 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp186172jai; Tue, 5 Jan 2021 09:43:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjG8Okjs5kua34NPlx2SuYUclQeMZnFoBxODNzwHJN4sU9BEpxy+Yx/o5tpIkW+8043l/e X-Received: by 2002:a5b:908:: with SMTP id a8mr820462ybq.11.1609868588178; Tue, 05 Jan 2021 09:43:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868588; cv=none; d=google.com; s=arc-20160816; b=tqleqVsoUxiVeiMeQNFHXbMSSIt+GlqEdAKmZoHxjAmVhMk3Fh+qAzEikaT9BOKMDz GoKxsoSBmTGYpsx8dHbebgancp63q3HB0hw0E8hhKpN5x6FCFGfZoo9B/AIFy9Q6fDRv bTjzP7s8JIGZqfDwpedtE3Mv7/QCEal4Dgbx2h/VAS3uG1VJdQ3YUBOtXARDNI1yneQB RO0jfx9V/BqegoG3wsE570qkFG0sNa6mJippNZeSJo0vwWn0N/pevEXZ1cHhK7ZjYyHQ hyi5mtuUlr5v36Y750vehLif4gd9tObO+Yt7LvPiPvxo9NfCMM7ui5rtGr0HRPOPAzdK QsiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mbF8LIbJA/srkkxrRGCDeXCnJ4tQUbtm6VJdqasFFJw=; b=xN7U0GWPQe+vBTF5dhKk2zib9zA/tR/0hjNi/VgpOKzyNLve5rIyC0VIrcn6Tr3Ncs y6kC0vIIHS2e4/VLwk+SoB3+0t17aR++QM2Yj+JQvT1wVCSfrjDFG3pKttfW91h0XjTX 1Dm1nGMBSHtitY+wJ0Iw20Tn2RJeLDvcSM4wmh0qomoMqvMt68ctm3vJ73fAZLxZ6Pl7 6Ljb7rSMVinQTndFLyf1K5H8LeQFMzCMITDWzifZuw5AMqvlrTLPTd3PgYOZfuIdvv29 VitWMcjzfPTSlPPdhdkPYrEQM4aAhMMfQks+jR3PU27WU/GEBMtdTI9xiSClPcd9RFXd 4rPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WVxRkvkE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j7si415115ybt.380.2021.01.05.09.43.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:43:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WVxRkvkE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqMN-0007CS-JO for patch@linaro.org; Tue, 05 Jan 2021 12:43:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0C-0002HJ-4m for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:12 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:39027) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq08-0006RS-Mb for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:11 -0500 Received: by mail-pj1-x1033.google.com with SMTP id hk16so14008pjb.4 for ; Tue, 05 Jan 2021 09:20: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=mbF8LIbJA/srkkxrRGCDeXCnJ4tQUbtm6VJdqasFFJw=; b=WVxRkvkEGvR0qY76Ju005kH4wDsMZ9OQ2Vx2WXLLv9cEnERuyRKwUff5sJYaDfAv53 eYxe8KUUgYuGYRhKkYumPAqLqHDGgldWkBc10xA0uFE1RaYvgjdS6dFwKoIAHBguJ6aX tPw1Dy0W2/c711y6l9aJ7Xc0+O41JhgI4YndsHx7RF1M+zCSHe1QkJFfrFPuIfb/N1QN NHrEL6l+cr8jA6tXpuYAZmIvIrMh3JOhJJsIqr3ZyMFkjFXR6b4MMXIuzrKyxd9CZkkF ibdE2gH7bpB4i/bIzCLws0RgfO/BXfWmX0y+LrrBjpiayi9igZWghXygjfnlatnM9fUM TSmg== 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=mbF8LIbJA/srkkxrRGCDeXCnJ4tQUbtm6VJdqasFFJw=; b=O7DOJAnJxyIzFLOMRTIALmjsgrYG+xQQFqVWhigjEw4ftXDJ406heoC2GW8syQVbiN 3nG3QDhT1zlBI7SQrQJEYA4HPjTsrwLjddDiVxdmMfdwmtiLNIzidzD1ShDwy+G3JnUe FndEt076XIRnSKR1UY0JFB2vV9iNGrYqYN4d+otuYEVZjlEQgE9QvaZnGJg5z4k24AZr 3gYsE6nnGdGppX98gVMQBwH8s6suhPYU6t4gu8VapIed8s/ftgpCiytOYMfd6aJlEQU5 UAEeYrs5wF5t1hBd1bgk2gEacRgf/pOozmUI32vV4V0qRau8Ea/wJjx3Q6h1v2jSjkWP pwvA== X-Gm-Message-State: AOAM532eF/Vs9KB8TbQkhaWeYMaHMTaSeE9ZphJPbXN6Y/owQEyvkEdp 9R5L0sUpjGbgyQTNeo4ZD4x6WOz66WCDsg== X-Received: by 2002:a17:90b:346:: with SMTP id fh6mr214455pjb.225.1609867206392; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 05/43] tcg: Move tcg prologue pointer out of TCGContext Date: Tue, 5 Jan 2021 07:19:12 -1000 Message-Id: <20210105171950.415486-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: =?utf-8?q?Alex_Benn=C3=A9e?= , Joelle van Dyne , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 9 ++++----- tcg/tcg.c | 9 ++++++++- tcg/tci.c | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) -- 2.25.1 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 -#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_ptr) +typedef uintptr_t tcg_prologue_fn(CPUArchState *env, void *tb_ptr); +extern tcg_prologue_fn *tcg_qemu_tb_exec; #endif 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 = 0; +#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 = buf0; s->code_buf = buf0; s->data_gen_ptr = NULL; - s->code_gen_prologue = buf0; + +#ifndef CONFIG_TCG_INTERPRETER + tcg_qemu_tb_exec = (tcg_prologue_fn *)buf0; +#endif /* Compute a high-water mark, at which we voluntarily flush the buffer and start over. The size here is arbitrary, significantly larger diff --git a/tcg/tci.c b/tcg/tci.c index 82039fd163..d996eb7cf8 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -475,8 +475,9 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) #endif /* Interpret pseudo code in tb. */ -uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr) +uintptr_t tcg_qemu_tb_exec(CPUArchState *env, void *v_tb_ptr) { + uint8_t *tb_ptr = v_tb_ptr; tcg_target_ulong regs[TCG_TARGET_NB_REGS]; long tcg_temps[CPU_TEMP_BUF_NLONGS]; uintptr_t sp_value = (uintptr_t)(tcg_temps + CPU_TEMP_BUF_NLONGS); From patchwork Tue Jan 5 17:19:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356886 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp305730ejs; Tue, 5 Jan 2021 09:30:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJylqlWCf66ViR8V9pzUllTc4tiPiSJMpHXLmvIv0pz4G3kT7EmppiyE4VqElRNWv48h0TOu X-Received: by 2002:a25:94b:: with SMTP id u11mr706217ybm.518.1609867804838; Tue, 05 Jan 2021 09:30:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609867804; cv=none; d=google.com; s=arc-20160816; b=JrBK+AMlmmznAazigkLkEAsJQS/gyIPO/gJ0kOBNpqDuMvzl9BbV1Si3FmYavKNI02 3lIbfBQHM4Xy4GRGjGW/u+kOEtIkG8LwfzbC2RSxSxMo7XpAgeO38+lo72xr63O5NEFC uF8SJ6DrjVcsIpsjqXQUrGfa8kl8f9+OXSfYimN3Nmk1Cgsvc1cLsUfAeQ8Fa4T7VqNI D9QPnt1JPHt7yQfBEdukSoyoGcin+Hr/M9xZRBWhiVkVhkAd1a62yST+/d5Tc2whgSWl LStZUuHkrtl9sfFUqzGAw+bDDL//ho7hSF8VX9aoX8sCXRI46+Qo3tfc6NOw+zwvbsDQ GVGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=2Cs9+y1G+pu19qlVm3AK/YYBuG9IZ09f226BO4KIS2I=; b=RJBvkuMwsgNkp1SF5rYQgkpHjcRmhIceTU1JEGweyApUJ5FUzqYvKeH/BQcCLnlkv6 LiDcObknefn4+W2jWzYK9TTamw4RQpj92AhQ2z5kEVCdGr/yX6n29FmcCwjjjyXYWMAK 6qn8RQS3wzspFJvIR07+oJzVuc86QrDxybRSFLJ43oUf004tSkV9SA8t3uHR7ACfMoLl UngnJTxrJ+MOEVozCd3sre1Vf/zFvHTXULl4YWU0f5yBVVNIqEe9yI4OMKCOhn2ZDQEo /uoVwMimA48lFpXevYPxyozfZuGYsOPjS9ogDaq8lm/QtzXQ9lPfkgqFk5yoGc+mdSyw iVgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BPqwgePz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q82si484864ybc.334.2021.01.05.09.30.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:30:04 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BPqwgePz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwq9k-00074Q-4h for patch@linaro.org; Tue, 05 Jan 2021 12:30:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0K-0002Jr-50 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:21 -0500 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:37040) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0A-0006Rn-CA for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:19 -0500 Received: by mail-pj1-x102a.google.com with SMTP id b5so20383pjk.2 for ; Tue, 05 Jan 2021 09:20: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=BPqwgePzDXweeZiuYWbGaM6f5rq4jmFWYreJhlD6RwzTVpRsLpG6HVypAk6uDrBZSk haWW/D1VCklB2eBaiONqcbf11zowAGBPN7nenNi/DKF+HzUVcScVUxtvPGRt9JWthD/5 66SATgb+aYSqHrGMmRP0BqISJJhoqP3mRXf8iVliUuOcN0tN6PugYvOnIk+F3WciAq76 hcBpPjmi0Ylp7j7vEIhTGmzoT6da7xvWuAuSCC0VOufHVV0zDPa33aN2jcrPWapbH8mQ S0/I0U0bY9TONN7ykqhmxVGTwlGQhNLRNY1Dbfv//A3wNd0jBroxXwPf86WSChwH/Lfk VyGA== 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=fmnZ9iOloJ4Ic+hDKHUyC1dS8JNxZC6192iTuiP4FjBkGYeQ6XucAC5ySxVtV8DwU9 1fuh8uKIXVfPCOPrjNodsoumgQR5mElByFrx3Xl643MSdnWVPsw56nVFOlXkuVBz7ciH 50xzJUYt87ymVb4uEZevc4i4d/rV/6+tVbMxqnnDsCIz1AVar596jAgVFeOY6O2JiyB0 Ko6WDLQAwSdWn6oYSzoMYkKYIo54a+/zgUSsrWpdqbI5vZp6aYgPgM4jW7LdWVs5o4O5 Q7w3BBp2deSN6Q44exYrLX+NBpu+Vaapbc5mP0E8ApFzc6Ko3Z79CjXMxvp/XAyKZYn3 E6Wg== X-Gm-Message-State: AOAM532cXon9IKsdBP4bZ/naevhYvaZaqJ+Krwq4jA4g0G4/QX5TcFE1 OfTR/lLhtLLApGxFcHVszXv6cln/p98cIQ== X-Received: by 2002:a17:902:8bcc:b029:dc:45d9:f8b2 with SMTP id r12-20020a1709028bccb02900dc45d9f8b2mr550889plo.62.1609867207933; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 06/43] tcg: Move tcg epilogue pointer out of TCGContext Date: Tue, 5 Jan 2021 07:19:13 -1000 Message-Id: <20210105171950.415486-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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 { extern TCGContext tcg_init_ctx; extern __thread TCGContext *tcg_ctx; +extern void *tcg_code_gen_epilogue; extern TCGv_env cpu_env; 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) tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, curr_cflags()); if (tb == 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 = 0; +void *tcg_code_gen_epilogue; #ifndef CONFIG_TCG_INTERPRETER tcg_prologue_fn *tcg_qemu_tb_exec; @@ -1133,7 +1134,7 @@ void tcg_prologue_init(TCGContext *s) /* Assert that goto_ptr is implemented completely. */ if (TCG_TARGET_HAS_goto_ptr) { - tcg_debug_assert(s->code_gen_epilogue != NULL); + tcg_debug_assert(tcg_code_gen_epilogue != NULL); } } 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 == 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 = s->code_ptr; + tcg_code_gen_epilogue = s->code_ptr; tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_X0, 0); /* 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 = s->code_ptr; + tcg_code_gen_epilogue = 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, TCGOpcode opc, case INDEX_op_exit_tb: /* Reuse the zeroing that exists for goto_ptr. */ if (a0 == 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 = s->code_ptr; + tcg_code_gen_epilogue = s->code_ptr; tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0); /* 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 = s->code_ptr; + tcg_code_gen_epilogue = s->code_ptr; tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_V0, TCG_REG_ZERO); /* 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); /* Epilogue */ - s->code_gen_epilogue = tb_ret_addr = s->code_ptr; + tcg_code_gen_epilogue = tb_ret_addr = s->code_ptr; tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_REG_R1, FRAME_SIZE+LR_OFFSET); for (i = 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 == 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); /* Return path for goto_ptr. Set return value to 0 */ - s->code_gen_epilogue = s->code_ptr; + tcg_code_gen_epilogue = s->code_ptr; tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_A0, TCG_REG_ZERO); /* 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, TCGOpcode opc, /* Reuse the zeroing that exists for goto_ptr. */ a0 = args[0]; if (a0 == 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 = s->code_ptr; + tcg_code_gen_epilogue = s->code_ptr; tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, 0); /* 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); /* Epilogue for goto_ptr. */ - s->code_gen_epilogue = s->code_ptr; + tcg_code_gen_epilogue = 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); From patchwork Tue Jan 5 17:19:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356884 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp303768ejs; Tue, 5 Jan 2021 09:27:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0V9ywWFKK/wk10HJQGwyORqrFHCIhsHJlHeoq7r26LrimGwHftECu+eC5nC/A71BnqBCP X-Received: by 2002:a25:b341:: with SMTP id k1mr659070ybg.37.1609867621017; Tue, 05 Jan 2021 09:27:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609867621; cv=none; d=google.com; s=arc-20160816; b=zgnhzx/5/il5JcC8c+E11pvT6uMd1OfmyAAqljNAiD4ynR+iPgUghArIb7S0jkPTPU X5nd20tMD2epCvUtdzWv8UG0iZS5Afzebqc20loGkFxsqf4oTwwekDRE+FmV5iB8jdaT GbZcIpUv5gF6Y4gDAJkJFbmszNgygVd6eCTXejXXc73ueCGE7qX1BM3HIW2IaBAn+YGj xmoFSksMnrCpS3Wh2qzV1IEZTtVPfEhvFOa0p/zw6JzJsk21vKssC9xs+NqPtH2mWgFE 8Jj18PdT1OAP6+TUjeiPXKB9axeZE5WaygIWkbAAjsTO52sWyGw1p5RNBAqEKR2mV5rN W8Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=wFm6MDTFivie1E/Xe2P9hEcJO2tCRms/0WVX0C0Bj2Q=; b=BXuAbyl4yypEik/g6OOjN5mqNE96bAnzUIblyE1+37hXzLKwH5zOv2kCNQwavtSF+m XT1xR5CCyr3wXyJkSw/+kPaTZYpffhKyI3lvjle9Re3vWGO3a5F3jTN+mtHcNjSqbY9P 1ugen7CMEfBU16T5mwlzgjzfoW+3MtYgJOnO9M8QMCnhMWCwAQH3ydtEI13ktWk8v1SD Asem96gS4SaOr2/s4GnNlEBSljfE/h5/IKBdFfF7oPMlaMsHiOQ+ryQKj7Zd8tJextcI Nj0mAuJlDh5b8zRhMja3bAGCkioUA7a+yIDHTQrw7WZUnIZE1MyNhTXj1CpOCG01KviP aS8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jw4rWHdV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p13si463799ybl.262.2021.01.05.09.27.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:27:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jw4rWHdV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwq6m-0003JQ-Cj for patch@linaro.org; Tue, 05 Jan 2021 12:27:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0K-0002Ji-3M for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:20 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:34009) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0B-0006SG-7W for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:16 -0500 Received: by mail-pl1-x636.google.com with SMTP id t6so73951plq.1 for ; Tue, 05 Jan 2021 09:20:10 -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=wFm6MDTFivie1E/Xe2P9hEcJO2tCRms/0WVX0C0Bj2Q=; b=jw4rWHdVAEZZcIaU+Pb4omEybixJ04qc/T7/Q+tatFUsguJ51Wd8Dcwi0BGJqh3NLh JgflBzJU2DnkhPYJFVmsgzNZR5SVw0SLlS0boF0vypgut8KZpfxlzS7ntbt6vgOU+Jbt c54OHl6ZoceJWZAHDpJ6iIERzIewCe3Dmqql7Ywa9AfUatozAfSPOdL7Vjy2aT1zqTE8 hDO3RnH7wisKg3dTGJ974ypMIOLikTapnycWkYLbFhQo0A/7KJZy6cuFXACY7sGlafTt MkbzJP6Q2+wc5S/D05j1jBFBtATxEdRjgIGQQymXfGgEsHV6sEQG6OTrLwcN5gx18hL+ puAg== 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=wFm6MDTFivie1E/Xe2P9hEcJO2tCRms/0WVX0C0Bj2Q=; b=WgXWXx1iRGQ72CpVb5pjb0u+gNmNKjfdi/ND7kIUYitslvz4EGnj8Aahjsz2q7xiqE 78OYH1QKL3m7Bby2NqeZ+B6Tifs3Vz3VctgUPWjXQcU005Bvh3+6Nd03ypP2ocarkx/x DX59/HVLKpQkdeiJaV6LeLH19LEgogpf+bL4qENOssbOWBZWekYoUdeAVbWthZPSmyoo 66M1A8k54+KPPNYD3CR1n/+OhfialnSQh819/7FGXMktqWzFvyTZcTzbOmncSUyDX3h7 1oh/3LBt/ebfrENZgBaT45umV7Sa+gKZOg4KEiDNPvhapu2y7D7+bpZXOs9OUq4mZ4d6 QecA== X-Gm-Message-State: AOAM530WJ4N2wUOtGc0/Zt9s83/kpFTNFyMGlgcbnWzMJaWwf8sSSwhr LM3MhA6QBl+33TaFU8uapeBdWPDtZS4p/A== X-Received: by 2002:a17:90b:4394:: with SMTP id in20mr300466pjb.34.1609867209396; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 07/43] tcg: Add in_code_gen_buffer Date: Tue, 5 Jan 2021 07:19:14 -1000 Message-Id: <20210105171950.415486-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create a function to determine if a pointer is within the buffer. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 11 +++++++++++ accel/tcg/translate-all.c | 26 ++++++++------------------ 2 files changed, 19 insertions(+), 18 deletions(-) -- 2.25.1 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; +static inline bool in_code_gen_buffer(const void *p) +{ + const TCGContext *s = &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) <= s->code_gen_buffer_size; +} + static inline size_t temp_idx(TCGTemp *ts) { ptrdiff_t n = ts - tcg_ctx->temps; diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index b7d50a73d4..9f5879b63f 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -392,27 +392,18 @@ void tb_destroy(TranslationBlock *tb) bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) { - TranslationBlock *tb; - bool r = 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 = host_pc - (uintptr_t) tcg_init_ctx.code_gen_buffer; - - if (check_offset < tcg_init_ctx.code_gen_buffer_size) { - tb = tcg_tb_lookup(host_pc); + if (in_code_gen_buffer((const void *)host_pc)) { + TranslationBlock *tb = 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 = true; + return true; } } - - return r; + return false; } static void page_init(void) From patchwork Tue Jan 5 17:19:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356908 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp189757jai; Tue, 5 Jan 2021 09:48:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZuyLUFAtIn7+05bfp5AhaY34G0cF39W7bbVMqjhR8BVTFFg0AyKrF459cBT30V8dpzDQP X-Received: by 2002:a5b:4c3:: with SMTP id u3mr741150ybp.261.1609868893447; Tue, 05 Jan 2021 09:48:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868893; cv=none; d=google.com; s=arc-20160816; b=sqggseGW6VwQgDhrYb5DN8ccx/XXfX1C5Pd/uvEMi99XuNl+AL5NwpP+bIZdM8Wv/b Mon1ageSBhuJHUq4VzUQlpE0oEOBfA/+SOJbJiP7CdVvPDKPuJ6L5+C8GwAVD0mTOsuF WU0ThKzBDXNbGKhSEHZXc8foHRmpKG7umZtFN0ldMhRJHC9l49vb3g6IFuL7k688ccTL g6uWSeu7j9fKgql1xaGCwMoINd8XCnVwDbU43B25vE5w7cAb+2n6cQwIcgsa7EYcyP7b RmCTAQopLuK/hlD00fOf5SWvfJV5lysr57VuqWqDgVlhCJTIPS7chtX14nzinTrtBQ4i w6sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=WOv0DhjzP/B7La9rWc03ge4Cn12SIZcALeoyhKgugW0=; b=f3k/vRKC/rYfNRPoqicY5R++VuRxG6TXsn4dmg5u/C9fnrYGBTYNWL3ossw/6D+tt4 +e6Y8ZRc6K7PqiLPJnljYHDAP2zjnZbeLaEpbkIPvudbktK5uPADoxQ72cU8l/RenY+8 /TpQUeXZlGDgn8TcCjIQO+qgrdsr446El/22rzLvPgnX2sp5KVtV/64pc+aWz8FzCdIo VHuif1V9fyN6Br3PZxiu0Is4zwLWGZlV5ObMR76sOsHSKsgopQKCcDk2ZWLFo95EuSdb rpF/43ljdS9vEimpa/rQdzzMwS/V1EIqIGUg9dWCywlxZKiKyLG+9lG4zFwPNCLVyn0y egsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bddzTZls; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p71si524647yba.284.2021.01.05.09.48.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:48:13 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bddzTZls; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqRI-0005rN-R0 for patch@linaro.org; Tue, 05 Jan 2021 12:48:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0P-0002LN-VH for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:26 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:53553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0G-0006Si-2F for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:23 -0500 Received: by mail-pj1-x1032.google.com with SMTP id iq13so16020pjb.3 for ; Tue, 05 Jan 2021 09:20:12 -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=WOv0DhjzP/B7La9rWc03ge4Cn12SIZcALeoyhKgugW0=; b=bddzTZls8/NOZGX6+HM4yK/WY+k+OtOEWXPmKjJk/zXWz6RwI/IDMwlaah6iTNiHou f99xd9W0K/RbWCIiCQabDr00FZdVllRo9638dPFi3wimCTwJ/BzJYGWAlBfNFew+8YcU 5l0xw9GAjTJ298ntMKI2QOgEpdQe30MzmAdJoBDDLQq1bh8c5hcQYBJE2dtEhqjUb5q+ Kc7JWky5HHD462s1y4+/WbwxsE/1XOZsrbx+qQTsIdKCQT8NKMGaVlGg6Iu6h9Qz4Jii 0IzzivhuEoszC+KljVLPzpaXYPcdtnmHlWZFMLJry+pJ98oEBJLAZVU6yP/SeFvsoeeX XLog== 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=WOv0DhjzP/B7La9rWc03ge4Cn12SIZcALeoyhKgugW0=; b=CfuMTHsS1ChUpIQbkV/g7pyhyH/mLl3yI//4zgmHbii7t2uUUVvr9FFdDAZR9/+soe e5bFVlxOF+fUd8ii80Vt8U9IZat3w7oucJ2oFh2zD4Itqrszp3yMqqHJwfcd9pvVx+pj ObmyEvj96Plrunq7cnyRfvu0O5cG8YHhAkXQalNK5vXBxY4VjgsuVeuuB8ejduN/Q9DZ 2NW/X7tCyZLYv0mRRyPRtUO+O/fU2T1Snr9fH3Yl4u1XNKnVsMoqSMktdWhYMb82LSeu 3wS/gVVLbNoJemqYydt2PYo1J8orwE6g9uNwem9o9S7ECrv/Py6m1CKIMMb+NLX0cgwM 1AiA== X-Gm-Message-State: AOAM532fieaQSP+NIkPLNRdEqzQnXKQs+6Z/NEyrIUgA+96p3nUurWAG pWmmzXE9EtxcPFJzQJu/MJlI1FAyEbL8CA== X-Received: by 2002:a17:90b:78d:: with SMTP id l13mr255747pjz.51.1609867211249; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 08/43] tcg: Introduce tcg_splitwx_to_{rx,rw} Date: Tue, 5 Jan 2021 07:19:15 -1000 Message-Id: <20210105171950.415486-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 | 5 ++-- tcg/tcg-pool.c.inc | 6 ++++- accel/tcg/trace-events | 2 +- 13 files changed, 104 insertions(+), 40 deletions(-) -- 2.25.1 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, i64) 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) -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) DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env) 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" /* 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); 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 @ptr. */ struct tb_tc { - void *ptr; /* pointer to the translated code */ + const void *ptr; /* pointer to the translated code */ size_t size; }; 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(); } -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; 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) <= s->code_gen_buffer_size; } +#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 = ts - tcg_ctx->temps; @@ -1111,7 +1127,7 @@ static inline TCGLabel *arg_label(TCGArg i) * correct result. */ -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, void *b) * to the destination address. */ -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)); } /** @@ -1233,9 +1249,9 @@ static inline unsigned get_mmuidx(TCGMemOpIdx oi) #define TB_EXIT_REQUESTED 3 #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 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 8689c54499..e01045f66c 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -150,7 +150,7 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) uintptr_t ret; TranslationBlock *last_tb; int tb_exit; - uint8_t *tb_ptr = itb->tc.ptr; + const void *tb_ptr = itb->tc.ptr; 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); } -void *HELPER(lookup_tb_ptr)(CPUArchState *env) +const void *HELPER(lookup_tb_ptr)(CPUArchState *env) { CPUState *cpu = env_cpu(env); TranslationBlock *tb; diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 9f5879b63f..224821943b 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) /* 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 = *pp; + const uint8_t *p = *pp; target_long val = 0; int byte, shift = 0; @@ -342,7 +342,7 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, target_ulong data[TARGET_INSN_START_WORDS] = { tb->pc }; uintptr_t host_pc = (uintptr_t)tb->tc.ptr; CPUArchState *env = cpu->env_ptr; - uint8_t *p = tb->tc.ptr + tb->tc.size; + const uint8_t *p = tb->tc.ptr + tb->tc.size; int i, j, num_insns = tb->icount; #ifdef CONFIG_PROFILER TCGProfile *prof = &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 = 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, } gen_code_buf = tcg_ctx->code_gen_ptr; - tb->tc.ptr = gen_code_buf; + tb->tc.ptr = tcg_splitwx_to_rx(gen_code_buf); tb->pc = pc; tb->cs_base = cs_base; tb->flags = 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 = qemu_log_lock(); - int code_size, data_size = 0; + int code_size, data_size; + const tcg_target_ulong *rx_data_gen_ptr; size_t chunk_start; int insn = 0; if (tcg_ctx->data_gen_ptr) { - code_size = tcg_ctx->data_gen_ptr - tb->tc.ptr; + rx_data_gen_ptr = tcg_splitwx_to_rx(tcg_ctx->data_gen_ptr); + code_size = (const void *)rx_data_gen_ptr - tb->tc.ptr; data_size = gen_code_size - code_size; } else { + rx_data_gen_ptr = 0; code_size = gen_code_size; + data_size = 0; } /* 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=%d]\n", data_size); - for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { - if (sizeof(tcg_target_ulong) == 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 = 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) } /* 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 = (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 = 0; void *tcg_code_gen_epilogue; +uintptr_t tcg_splitwx_diff; #ifndef CONFIG_TCG_INTERPRETER tcg_prologue_fn *tcg_qemu_tb_exec; @@ -406,8 +407,9 @@ static void tcg_region_trees_init(void) } } -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 = tcg_splitwx_to_rw(cp); size_t region_idx; 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; n_regions = tcg_n_regions(); @@ -731,6 +734,7 @@ void tcg_region_init(void) region.end -= page_size; /* set guard pages */ + splitwx_diff = tcg_splitwx_diff; for (i = 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 = qemu_mprotect_none(end, page_size); g_assert(!rc); + if (splitwx_diff) { + rc = qemu_mprotect_none(end + splitwx_diff, page_size); + g_assert(!rc); + } } tcg_region_trees_init(); @@ -752,6 +760,29 @@ void tcg_region_init(void) #endif } +#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 += tcg_splitwx_diff; + } + return rw; +} + +void *tcg_splitwx_to_rw(const void *rx) +{ + /* Pass NULL pointers unchanged. */ + if (rx) { + rx -= 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 = buf0; s->data_gen_ptr = NULL; + /* + * The region trees are not yet configured, but tcg_splitwx_to_rx + * needs the bounds for an assert. + */ + region.start = buf0; + region.end = buf0 + total_size; + #ifndef CONFIG_TCG_INTERPRETER - tcg_qemu_tb_exec = (tcg_prologue_fn *)buf0; + tcg_qemu_tb_exec = (tcg_prologue_fn *)tcg_splitwx_to_rx(buf0); #endif /* Compute a high-water mark, at which we voluntarily flush the buffer @@ -1087,7 +1125,7 @@ void tcg_prologue_init(TCGContext *s) buf1 = 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)buf0, tcg_ptr_byte_diff(buf1, buf0)); #endif @@ -4231,8 +4269,13 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) tcg_reg_alloc_start(s); - s->code_buf = tb->tc.ptr; - s->code_ptr = 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 = tcg_splitwx_to_rw(tb->tc.ptr); + s->code_ptr = s->code_buf; #ifdef TCG_TARGET_NEED_LDST_LABELS QSIMPLEQ_INIT(&s->ldst_labels); @@ -4337,7 +4380,8 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) #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 diff --git a/tcg/tci.c b/tcg/tci.c index d996eb7cf8..262a2b39ce 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -475,9 +475,10 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) #endif /* Interpret pseudo code in tb. */ -uintptr_t tcg_qemu_tb_exec(CPUArchState *env, void *v_tb_ptr) +uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const void *v_tb_ptr) { - uint8_t *tb_ptr = v_tb_ptr; + /* TODO: Propagate const through this file. */ + uint8_t *tb_ptr = (uint8_t *)v_tb_ptr; tcg_target_ulong regs[TCG_TARGET_NB_REGS]; long tcg_temps[CPU_TEMP_BUF_NLONGS]; uintptr_t sp_value = (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) for (; p != NULL; p = p->next) { size_t size = sizeof(tcg_target_ulong) * p->nlong; + uintptr_t value; + if (!l || l->nlong != 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 += size; l = p; } - if (!patch_reloc(p->label, p->rtype, (intptr_t)a - size, p->addend)) { + + value = (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=0x%"PRIxPTR exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=0x%x" # translate-all.c -translate_block(void *tb, uintptr_t pc, uint8_t *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p" +translate_block(void *tb, uintptr_t pc, const void *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p" From patchwork Tue Jan 5 17:19:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356913 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp192429jai; Tue, 5 Jan 2021 09:52:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5E5/eTtdEa9w7TV2c5guS2MoaLmcPXio81r3QaXrX8cB5oLbLgufB/ANLhq3Z8I57Rwik X-Received: by 2002:a25:428c:: with SMTP id p134mr843329yba.354.1609869155816; Tue, 05 Jan 2021 09:52:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609869155; cv=none; d=google.com; s=arc-20160816; b=FgzCl7gpdv9SX78wmc91oHK4wGglejDQ+FuL5RaLNl3ndhGfO0+1qQwhQqYnRJixPV hnfZMzpVXwGSAJblCF9RR1hsQn5fur+P0QPgAbijrNMoPkLdeRuQfxuApwFTlHLVn5cO ixTBzWcRhtWx2CgRAcQjODmWMd55B4pccZiGn6ouBPEoVaizfr3NjMXOlsMihTRsfLIe n5G9U+6r4DbiFPbuqr3SgZpC0t+IWeVH+2d7hJ6Mvm9Fr9qFhmclNXpNn/95HSuNUjS8 ifLNgGhKwNxeffHZmzV5IQgru0QyuBMR/+UWTHdXO6q7czXwuN4A+FFaYNpouWfA/rDr 3KhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=yHpWBji5XIjin1o+94tFD6CTmKluj6DDVpJFH1M81zM=; b=tRfPOumoXw0MBe2VVNd3j0eh7czFDgZM1pLDS8YNTZYaPrSbJ757kWMBWf7N8HyAND Ij7xJWwz0MmLmdBhlZ5znCzUmdRSBb4VhBrXrJr1RM3PA+tZcSdd57I244hVPR9nUkDp uUwdyuPxHrkW41QORXvVIKazdKSUOwVTKnLXdpgz0e8+qihLBLoScrJ0pg7W/5MRmIVj 73e/DxsPK8xq5lLyhZA6PGFy5M0popMdbTAQsSHjQaLTbc43k0cywJiJK5GzDdBWk5im 2zqqVZvNcQ6DFrovjD6HkIYes9HEjX0T0Zi6hlXH40exYgfcEO5R88zzzobzjEJNOe+U arVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tRkynvK0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w131si484960ybg.302.2021.01.05.09.52.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:52:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tRkynvK0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqVX-0004RK-4G for patch@linaro.org; Tue, 05 Jan 2021 12:52:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0S-0002Mo-MH for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:30 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:47017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0I-0006T4-33 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:28 -0500 Received: by mail-pl1-x630.google.com with SMTP id v3so37871plz.13 for ; Tue, 05 Jan 2021 09:20:14 -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=tRkynvK0gMEUTVwcQFPkTQ0+nn92LsFakrs+F1z4MpwWFGwGnUeZClogoT01xjtdvC R3MEnB2gfLELgMbgioH47n6xmxYtDJ1NDVc92twm+Q16Ap9B1dPFSq5u/uC8DtEiXWS4 Kk0btifDCRjlxO3y4XKV7WirHLcTKfuRIJTKwzynw8hko6y2MADhpEjotnuU39gSpl9r f9/VWv5W7ut1IdyxkZ4YsgmJi3F+5x7J9r91sw8Uebzh7EjATT+UR/u66ZoYQw3idWBB N+ST1FU1PgSMMeer+vD1wKnlr3QG/m9Y0EvshKAgPB7jtyf2tT2DlAgzpy8sjAG2i+mQ Cc7w== 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=oPj/CYLOdxHGbAftiuXx3CvRoh6LfOmwTs3bVHVQy09dbiKH+W94Eh3KaBFhh9G1eN QtDJGr3ggmq/EXjaqaSDpY5qIAkuyIuW0+X/J134/d4KLhCxy6heH4gLwHe43PNkcnLs ltOkHhCx6+1ExBb95kpG5osn2x2gqetOc4wDvibWr64jT7hu06myV5JgOh8FJobuSc8+ zh+mJ05FUexbLdOQkIZVPBcI2SYeH45c2kYbWPXCHJvOkHxOJRr9PVwu8ohWKI067BZE /EVLGp6o4jX9sLHFkqYEBO8C6y7FXRdRmjRLOOQFOFO53QGdnzFREoOeUpLIvbHlvg8X 8j/Q== X-Gm-Message-State: AOAM533It7MeY29Fw1qF3yjSniJOFKF5t9G41lXg3he1ZaO25YjNV1K4 mX1yD7zMQKaWUlXOoSlJa8Sj1Ua7LuzALQ== X-Received: by 2002:a17:902:a388:b029:da:bad:ed3 with SMTP id x8-20020a170902a388b02900da0bad0ed3mr539512pla.76.1609867212998; Tue, 05 Jan 2021 09:20:12 -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 u12sm2010pfh.98.2021.01.05.09.20.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 09/43] tcg: Adjust TCGLabel for const Date: Tue, 5 Jan 2021 07:19:16 -1000 Message-Id: <20210105171950.415486-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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, tcg_insn_unit *ptr) { tcg_debug_assert(!l->has_value); l->has_value = 1; - l->u.value_ptr = ptr; + l->u.value_ptr = tcg_splitwx_to_rx(ptr); } 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, TCGReg a, } } -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 = target - s->code_ptr; tcg_debug_assert(offset == 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 cond, * 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 does. */ -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 *addr) { intptr_t addri = (intptr_t)addr; ptrdiff_t disp = 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; -static inline uint32_t reloc_pc16_val(tcg_insn_unit *pc, tcg_insn_unit *target) +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 = 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; } -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 *target) { *pc = 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 == sextract64(target, 0, 26); } -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 *target) { ptrdiff_t disp = 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; } -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 *target) { ptrdiff_t disp = tcg_ptr_byte_diff(target, pc); tcg_debug_assert(disp == (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); } -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 = dest - s->code_ptr; if (off == (int16_t)off) { From patchwork Tue Jan 5 17:19:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356909 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp189883jai; Tue, 5 Jan 2021 09:48:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYRWTwoGKiJi41yTt+uEj2GRWjypVf+0a0+1vxt3B34voOuOM9CFZjqw8SVFDZBEXcO9el X-Received: by 2002:a25:2317:: with SMTP id j23mr914309ybj.388.1609868906243; Tue, 05 Jan 2021 09:48:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868906; cv=none; d=google.com; s=arc-20160816; b=viT5zZqSLSnRa+wFykl6FLqfWSw5CI3Gbf1pg9ZCiCtHdWxuPVnaBpbYwLsAbHb1WK B3EcI2BWjGtSvw6B6WBbf/syCXD9gPxungji/bhD8xnWK93rE2Io0uhMVDkF0LrVtPLX JKlqjxd9ImZh5OzWrGP3FYphqoW+3T005bDrRY8K7I15yuI3DuOeA/e4WDW9I6AHcgEC 6cJ2kfD1HnhyjZF3Rkcsd0u/YnsosASdfGVMZ/+MHRwkofR5ZvqEK1U6Gh7X38sHAZVb B48HRryZSIfDuZH3wRvgv4Pc/u+pEFKLXSKmq6fH248uj5qN/E0fnQQrPzzSgpl7TKmi 41PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=72zHjmApxurokrOqBQhkIhZjtudzzH1TIj1EwkLb0WU=; b=spQzIu4hVWQTocnHBi7GMEL5kwG5IZLNQ3hThZfJ5uvAuWuobPdUivWjlpMMtih9Jj LrjPwsE1Cw72/FedrjU5bDC2I3PtKGZwTXCpETvFgA9JDsfo58UGm6yB9WSwvz6lWkcJ z26Ij/9swO/fRrrp2U5Z7cy2FCZuG96WbbMf9gkzC1xt4TpZrrj39JXg9aNjCx37tEj+ UgUNAOONdPQ+rED/MW4oYWAYkoO5Yy0j0LDyv41xvzlXGfoxMfMi/YPU0mZMSXGe9Txf wrhkdfSbkTsAoH8YJcP8aoCeHMrUeYGeP/9ZkShFptaEhc4kKbfwFngTEytM+t5zQffo 5dEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EtHBH68O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p71si493653ybg.346.2021.01.05.09.48.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:48:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EtHBH68O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqRV-00064w-O7 for patch@linaro.org; Tue, 05 Jan 2021 12:48:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0Q-0002LO-17 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:26 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:37008) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0J-0006TE-S6 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:25 -0500 Received: by mail-pl1-x62f.google.com with SMTP id be12so65137plb.4 for ; Tue, 05 Jan 2021 09:20:16 -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=EtHBH68ObpytjPTb5G3H7TQ2mbYwhZCrWunD4Q3C2O4YwKJ5mnnsTf4wLR5ON61cUF lu24MrQQlQUlXfayPaTDXXRmVqujveCHLN0TGyvXWPb+qfN1bfg+VpOMpLbT+/cYX9/U M81mshM5f5ae0xkvyaVJnpuQPu9xGnQft8pAxMA4BgEzVPuaYXah/RTslazI37VtSOzE nqw7lhO6aJ5CWZNPyMhW1Mo1jjgB/ibgnP27+L8SntI1BgcCsfnq1SAXA0wmAKPXpdap k8RyEfQkUafDwAlOfTzFZgen6iJ8cxFQ0nLjLzmxw4ff2k6WsrNimSLTWXNfb6VbjQdN jfcw== 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=TGa0F2PgiJ8/tHEV5JQ/Q63S4Vo+3inRkJ6CmBMZMNSl7ot6e43Oq/dJ1Z107JXqnq upL4Q4xTAfoJzGtimAHB0CJoPL87YYWDmjI1uG8CA0BuCWeZLjDeM5aNUKBgD4+AMPgP 31BfDzMz7uNcgTgSDUw4//IFna+JhkG/kUqUN4/QBM/tlYSoYQAdg54o6rcLl6vCPfVM Dz7QUOr5Rqz4lZRCpq1sYSdO0j1gipqtxt+X4YruyQXI9s3KIvERE/3aS6TUHBnvkYxs mkx5xeJApqPkXaPi/+DAklkwcjV1RnbsdNoVLS/CLVYNmcpVxpe7Sje0S+gPiCl2u2Ku c6Kg== X-Gm-Message-State: AOAM533KJUDJvGJcfD/I+Ud7bSW52KF/phgzLNPhmnJ5cubTPuljvIYj yOGtnjc2LtvDoiUQbnN+r2tL8F619wpNUQ== X-Received: by 2002:a17:90a:7085:: with SMTP id g5mr275209pjk.132.1609867214721; Tue, 05 Jan 2021 09:20:14 -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 u12sm2010pfh.98.2021.01.05.09.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 10/43] tcg: Adjust tcg_out_call for const Date: Tue, 5 Jan 2021 07:19:17 -1000 Message-Id: <20210105171950.415486-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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é 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(-) -- 2.25.1 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, TCGReg 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, TCGReg reg) tcg_out_insn(s, 3207, BLR, reg); } -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 = target - s->code_ptr; if (offset == 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, const tcg_insn_unit *addr) /* 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 = (intptr_t)addr; ptrdiff_t disp = 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, TCGReg dest, TCGReg arg1, } } -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 *dest) { intptr_t disp = tcg_pcrel_diff(s, dest) - 5; @@ -1619,7 +1619,7 @@ static void tcg_out_branch(TCGContext *s, int call, tcg_insn_unit *dest) } } -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 opc1, 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 *target) { uintptr_t dest = (uintptr_t)target; uintptr_t from = (uintptr_t)s->code_ptr + 4; @@ -1080,7 +1080,7 @@ static void tcg_out_movcond(TCGContext *s, TCGCond cond, TCGReg ret, } } -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) } } -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); } -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 = tcg_pcrel_diff(s, target); if (in_range_b(disp)) { @@ -1762,13 +1762,13 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, } } -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 = ((void **)target)[0]; - uintptr_t toc = ((uintptr_t *)target)[1]; + const void *tgt = ((const void * const *)target)[0]; + uintptr_t toc = ((const uintptr_t *)target)[1]; intptr_t diff = tcg_pcrel_diff(s, tgt); if (in_range_b(diff) && toc == (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_insn_unit *target) return false; } -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 *target) { intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; int32_t lo = 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); } -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 = tail ? TCG_REG_ZERO : TCG_REG_RA; ptrdiff_t offset = tcg_pcrel_diff(s, arg); @@ -888,7 +888,7 @@ static void tcg_out_call_int(TCGContext *s, tcg_insn_unit *arg, bool tail) } } -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); } -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 = dest - s->code_ptr; if (off == (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 rl, TCGReg rh, tcg_out_mov(s, TCG_TYPE_I64, rl, tmp); } -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 = tcg_pcrel_diff(s, dest); @@ -855,7 +855,7 @@ static void tcg_out_call_nodelay(TCGContext *s, tcg_insn_unit *dest, } } -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] = s->code_ptr - old_code_ptr; } -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 = s->code_ptr; tcg_out_op_t(s, INDEX_op_call); From patchwork Tue Jan 5 17:19:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356885 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp304926ejs; Tue, 5 Jan 2021 09:28:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuPaimSjiKeTrp8evCSdMpdE6yGVak+x4KOn7Zz5g3gSufuRTmsJTK4ttPy2AlqDLrTsDK X-Received: by 2002:a25:d24a:: with SMTP id j71mr664440ybg.13.1609867734859; Tue, 05 Jan 2021 09:28:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609867734; cv=none; d=google.com; s=arc-20160816; b=AQUqnVFWhJJgwTAivMPAnn7uk1s3JxJCRJ3xP+9J5vFHBlFJbS8jaFokG9fjxflb8B nPGK+NZqTGZgh0mHanu0/joBWfCVO4FT/Q+2q+ApfpDzFwc3GdEVvi4P/9FvCmLDvo9Y /nfobzGrxZXyabEZS/6VsJ994ixPn8eIQrBuU6jp00vSnrW5QEdsnnb06smNv/DK9Ivh ssfpSnzdMH0t/bK8ogbNHsUtlRChuXWkvkznXo9HpmNpv9s24cOXO96cLw1qtMKlkIrL nGoNk7xQZyGOyafnERmUOo6nDxNJF9KNHEJG8vrzpnr41aIBXuEkTDtwQ4Cd/CUV1JBf aONg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=NQliFXXfgB1CXPoiBmFHUeq1S6nzHe9RcOFk3sVmuPo=; b=J2g2ZY0ms3+6SvMJbTyZHIy2zEVZw4/GRxf8d6IwRkXHVbbOehlGAy4q2eqo7Jhc5p IMnasHVOQ2dgqFW6PGDkASExffpyNzuC0l+h8nAE0ls8vp5uEkUSfC2whjEpHFq1lirq qE+c0AgnnysnrefDaNSOuWB6sspj7yrDCtblrr9FXmueNtSHgbiJj1PGq23SUR3tKSRV W1QFtwdwaBydjzDE10NkkrBKUG3hGazaOowkT4NJcMDnfFosEVZppJpi9T5096rdvDwE T15HnK5hASyPWZhpom/gsnyloXFxGzCKVz2Zjuqc95/NMo3HupwdT9Xo/KqbT4JGnsNR MNlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tnKLdzXs; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p197si531469ybc.155.2021.01.05.09.28.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:28:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tnKLdzXs; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwq8b-00060s-TJ for patch@linaro.org; Tue, 05 Jan 2021 12:28:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0U-0002Mq-2i for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:30 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:37010) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0J-0006Uq-SW for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:29 -0500 Received: by mail-pl1-x631.google.com with SMTP id be12so65188plb.4 for ; Tue, 05 Jan 2021 09:20: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=NQliFXXfgB1CXPoiBmFHUeq1S6nzHe9RcOFk3sVmuPo=; b=tnKLdzXsiQb0QTB/dyNIZ3mBWJHqNzCm2AABhXgkKDHkVn/CmSSJR2NJVUkWUqYqJb 06F8aLwXszB0z3cIyBdBze26Qzewj1f+n4NzcT+9trXg//NxQrEMUZOkjLUknREV198E aQ40Ed5lwhPYbTnyQjPPAO3NZWaJb8NAg/0/wXiBHAT21R/Xksp8N1L7Ay0WAys/iWwi bXdH0CqROzNXk3MZbbAgE7OxygFtf3ibZYtlT0Y4DJxq+TH6nuV3KJB5g22ZuTlAJX+R 9VPSln6eJnu4cL9OlPkCMCprR8JwwOjgs9W2K/8YBRta4pQ9/cMAOxZIJW9MlPu+Pzhx lLCA== 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=ZY7cKqvC89JrvVe8KXo9i9H4bVqI8SYLbH3NtkudZg8LsjGTh420tuemo53bLcwtV2 hfHnqe8zgppgIzm98DgZCg8ZB8j3KOV0MglSOCm1k97QEWyvBA6KDjRXoIrrumcD1rfl ul0Wz7DqhOjjNyPKcGmlrylEof0POQd7KouCouSUQ6PkY3FiwvWdsarcC7JKudGyVK4H 83jbaIgqHN+HNzx3EVuUUJXA5FdUCFWPWEXKDDzMxHAztdiBNCYaWUnXvCtq7h/KQ498 iDqzBPt0X9MhViVXeplL7/wQNYvOvs2GGE6ur1Ie2UKfocLdSMAKF9nZcfgPZfSuqz0j kAxA== X-Gm-Message-State: AOAM5323IIYXCFzWUgU/B2Myo6eZc5vjmKOi3Up/lzox8vfuUbysRiZ6 TUMSdDQ1BkCd4chhkugzBTJlH/hg2Cp7gw== X-Received: by 2002:a17:90a:db96:: with SMTP id h22mr261292pjv.204.1609867216496; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 11/43] tcg: Adjust tcg_out_label for const Date: Tue, 5 Jan 2021 07:19:18 -1000 Message-Id: <20210105171950.415486-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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é Signed-off-by: Richard Henderson --- tcg/tcg.c | 6 +++--- tcg/i386/tcg-target.c.inc | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) -- 2.25.1 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_unit *code_ptr, int type, QSIMPLEQ_INSERT_TAIL(&l->relocs, r, next); } -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 = 1; - l->u.value_ptr = tcg_splitwx_to_rx(ptr); + l->u.value_ptr = tcg_splitwx_to_rx(s->code_ptr); } 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 TCGArg *args, default: tcg_abort(); } - tcg_out_label(s, label_next, s->code_ptr); + tcg_out_label(s, label_next); } #endif @@ -1503,10 +1503,10 @@ static void tcg_out_setcond2(TCGContext *s, const TCGArg *args, 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); 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 TCGArg *args, tcg_out_brcond2(s, new_args, const_args+1, 1); 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 = 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); } } From patchwork Tue Jan 5 17:19:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356888 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp308331ejs; Tue, 5 Jan 2021 09:33:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+zkc5FO7eAbjI/Ot8JJsLKSAb75St7dhtmhxGfQP5wMKgjRnelP7mRD/IqLBQQro8I/Qm X-Received: by 2002:a25:348a:: with SMTP id b132mr725175yba.378.1609868015918; Tue, 05 Jan 2021 09:33:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868015; cv=none; d=google.com; s=arc-20160816; b=UXVxZKFvbKxUyMI04o10e6ltYXdtk2oal3J6g2d0mb/81PoW9CMdea6iQkVa9PqkTu o3HxEqdwJWgquQb2S51l0i/PKhCkzC233YohETPpkv90un1ahkf2FFsGewxBs6JEXVsa fsAAdaN0qG31dyTUmTEIkhL+zp6U2HRl+huRJsN1SUZp+hj7zsjzheYgfFmW7zJ92c7D OFyrcTtC/Xm1B5/tdbswjN0+i3N+mGqUQxBGf+5nYAR9Wp1L+ZbMG0RbFVKz2brYmRJr BySbhX36ZXDEdkA+EdM1UU0UKzAMd3ikX01vN1K60mFlW1AcSQpsksfVL/CcFbS+wCcC eNjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=rtXLHEnFm6PYImUKUfsTMRutoZrBjCY0hpS4NqovFSw=; b=0dGYHAMORlz6CHmMDMkx2/Gm6vP9g5b1rsUhiAV0hUyVEQZw7rCdGhx8f0dFCsmEBV GQGJu6X335w5dG6JjQGT+M7ZrrbDbwW3YlswJDMSBMj+6CPMx6ULFkGOHIf3H2C+BPOG EWxs5hP2pGKM4p8I9H9VTls0yXNwdYfqF/H5oGpJRSA3xvgiDNfQBoK04TB08RRRmQdX t5dLdoafi4drEjZUvyVqpa0BEjOlvoklcXqT4SMkKIWZAeKaaxp4qorvDwrObLDXbnp+ uJKS+Dd9EXyj36vxTt91fojFAzNGnR3LJ4CETZgl1w3ZCmWCuBN6hi7vup2jrS2PTF6Z 5QQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EY+M/8gN"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n69si543013yba.348.2021.01.05.09.33.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:33:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EY+M/8gN"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqD9-0001a1-An for patch@linaro.org; Tue, 05 Jan 2021 12:33:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0S-0002Mk-KH for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:30 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:37703) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0J-0006XA-TC for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:27 -0500 Received: by mail-pg1-x536.google.com with SMTP id z21so287114pgj.4 for ; Tue, 05 Jan 2021 09:20:19 -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=EY+M/8gNzVhdKntpBBWgdB1gsDvy2Vd5rYKdBhF7OVi5oaZ/qxF+a0u/eyYGW5S+yF Hs0RLKfU2Q5j1ng9GhghIrN0bLqvsuwDKR7QR+otdQ3SmChF5jvmhWGSXQ/4S101GTYT F7gLZPMXA4TSAs98GJTUSl5poVWC3ZYy1TphtZpByDWa/z+2ZAOFw3gicG0qGncoebJJ jZQ1E1dunezKTfgW1xa3aO03jDXuPnKlCcV1dqmsivljLIVNz2dLBfBELVMUdHOyh+hk Fn4lJUwKm9EwXkaRsAciNB/oo3akNHro7EQchX+kcx8gtfph4v9fOzKJs9d2xuU2RD2c hnPA== 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=uL3F0YhcbZNwsIsCYvtYkr9G2ilAaVUR+0udfG/rLZXNq2INPVxjcWRiD9aOSv5LKa Hca15HKbQnIDHjwUsJ/HqlU+m26bO2Obw1LvuMTLE38NGr0p+os9WGDqAKSs6MaTANMN Lnss/FTLm70ClnXtw7eBceO1D3zLD0tYl+nJA2hXNwYv8Ui4605vCYNgyqp92srBYG+J T1PVT3TGw1FQofiHprY7y05gkpkYlxfYtIiSUEO6ZRN42H/3/e1CpAwiCt+n3QtXSWic YmLYSCAte5nznfA0lG67uOK/19XJ4LQYjne0ZgAhi0cWrT47B5iptWe1He+qjkQh4KDK DY5A== X-Gm-Message-State: AOAM533feOeoFo6acQgKyHsh7L4IG0Ce+JIQLoM2App/NGCWN7eXqDgn 24jr0CyxeZeUYuAlRYI8e9KsaVpvyZ0r/w== X-Received: by 2002:a05:6a00:88b:b029:19c:780e:1cd with SMTP id q11-20020a056a00088bb029019c780e01cdmr456388pfj.64.1609867218037; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 12/43] tcg: Adjust tcg_register_jit for const Date: Tue, 5 Jan 2021 07:19:19 -1000 Message-Id: <20210105171950.415486-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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 -void tcg_register_jit(void *buf, size_t buf_size); +void tcg_register_jit(const void *buf, size_t buf_size); #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; -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 -= prologue_size; s->code_gen_buffer_size = total_size; - tcg_register_jit(s->code_gen_buffer, total_size); + tcg_register_jit(tcg_splitwx_to_rx(s->code_gen_buffer), total_size); #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) } } -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, size_t buf_size, /* No support for the feature. Provide the entry point expected by exec.c, and implement the internal function we declared earlier. */ -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) { } -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 = { } }; -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 = { } }; -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 = { #endif #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 = { } }; -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 = { } }; -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { uint8_t *p = &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 = { } }; -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 = { } }; -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 = { .fde_ret_save = { 9, 15, 31 }, /* DW_CFA_register o7, i7 */ }; -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)); } From patchwork Tue Jan 5 17:19:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356918 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp196174jai; Tue, 5 Jan 2021 09:58:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxRsGFJ4XzTDVy/iXVfl6dWnyOLDo+vjrrXbBYUBP6CQCoKNvyV4Ka6w188PATT3OObcyxh X-Received: by 2002:a0c:b797:: with SMTP id l23mr635062qve.42.1609869492890; Tue, 05 Jan 2021 09:58:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609869492; cv=none; d=google.com; s=arc-20160816; b=V+12ZgzJRnfWxPwQ32SYKIW90CngtPqeRPS3HSImvaKLyejXd5lpAK0kexCuftG5e0 h/BM0tSMfNS/FtrmGCB6l008DLtraY6gSk1BoAkv2CdMfwrmypG1gv1knMVLCQwWXrJv ciLPOQyBbG1zQBGD6qWQ4+zHBdAUPHMmZVg9r2Re+XLlutligrVFcAHekJ9EfB3y0NvG D7qJAUmOU11L5oWtH69lfKBvg+dbTnRjZQiyXhdQHIh5rHKwb1gMK+PvyL6Q4SVx/fYa HSxvr1fqWJhIZss0w/oFV+2zSLEQf4df3Xci8CnBiIysgxGrkNDvbzbc/0OkYfpj1A9y DdBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=KX8SYTYaScyamvEyH934P5SIRrediuz1DR0OI/8HBNE=; b=cElOThivjgxgLwVPQEWS9EEfZuvVbrESvus5fw6OH8jTQyUVvmLi44/SxaW176X/qP b/k9f04xhICXcTWSjSGT80c7GuYCL0mArGxY1L2XpmlxgGsPAKjSQXm+BRg9loiF6+SM zodcFEsMfD4rSvpbOeEwr3cK0EtXp0plabgeBuVjJr14ZrKLjNc0Vo3QGmVWULECdr54 C2kUkueOeQhsN3rz3tgCszkm+I4iHhzJBJayIKA/vLvnhTv7p/fOG35Fmi5NjOPIXDsm fGPR7w2VL9nqkDnAI3/Fz1Lz0tbEnDzBAP2pM4Bzb3/9r9erzNzMr3zUj/2L31IpQolV ChRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dKwlu+VY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e49si17419qtc.383.2021.01.05.09.58.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:58:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dKwlu+VY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqaw-0001tj-Hn for patch@linaro.org; Tue, 05 Jan 2021 12:58:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0W-0002O5-HD for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:34 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:38288) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0M-0006Xp-Ks for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:32 -0500 Received: by mail-pl1-x62d.google.com with SMTP id 4so62352plk.5 for ; Tue, 05 Jan 2021 09:20: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=KX8SYTYaScyamvEyH934P5SIRrediuz1DR0OI/8HBNE=; b=dKwlu+VYmpnZdiRCXMbGYKcAX/SZ8Kwb5PIAZ0hk/JMJsgcol6D5TyIzv5lGhEQLoB fJBkG+Q9KRFyvsr6zZ+ZrL/xGC1TdoqPxM9nSMD7vASCjE6rq+ntK6bq/xNqNkvuMhhk Jclgd2FzAX6wl9JmMmrlgZZByhulQoNnMTeqbEqhibKCZqC6ZtDnCUGpCYDEvwJI5JR6 grlkAKeVtniflrwuLJGQ3qRt3D+JsXCP1Gv4bk+gxSN+BvK3xQWhTrkWiBbuUOeNUh1N uL4mKhQu9oFVqE2Yed7yWYzM76Odd26NLnq4r4uyfQaZFbrpU5dXw0fAVcoXhMmhLin4 KFVw== 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=KX8SYTYaScyamvEyH934P5SIRrediuz1DR0OI/8HBNE=; b=uerYPGhMtUgEzpQhJNYAfMB/1JVKA1FV/cV4BY2jjnhAxGBekuHzlSDKAgENrMWWOz njyc3AaLFGld7SJuppZurBYKAfTp9ZjReYMDW1AgkLs0T7O3UsCl6c3UyulFh/9arH1e n6hyGySKvLdC8SFd5Wa2yr+WysEy60Ep1Ks3fiwtchX8F55MMya6ikXCoTMR09bOHW6k a5k7gu6Xy/Rv9ZiqLY5oZwU518VKlvCmt/MJ3Ze+WJoH6ThGm/SPGRJoh5YxzHYbimjK res7KtvoZ90rh0X8bHO2JbfjICJsMjECwOITNIot/SD7cMktV3mW7JBv99xmdeW/cUMv Cy4A== X-Gm-Message-State: AOAM532ktwi/sTTvMw3JcnwgUTnhmi2STlM0KSnMp2VXqBgxfVnNJfvE 2e8Cy7ux5q03g/r6JibEkf316RhjpmoPqw== X-Received: by 2002:a17:90a:a012:: with SMTP id q18mr209882pjp.223.1609867219543; Tue, 05 Jan 2021 09:20:19 -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 u12sm2010pfh.98.2021.01.05.09.20.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 13/43] tcg: Adjust tb_target_set_jmp_target for split-wx Date: Tue, 5 Jan 2021 07:19:20 -1000 Message-Id: <20210105171950.415486-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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 -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); #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 /* 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); #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) == 8 && (len) == 8) || ((ofs) + (len)) == 32) -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 jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { /* 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 */ } 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 -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); #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 -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); #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 /* 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); #define TCG_TARGET_DEFAULT_MO (0) 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 = TCG_REG_R10, }; -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 jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { /* patch the branch destination */ - intptr_t disp = addr - (jmp_addr - 2); - qatomic_set((int32_t *)jmp_addr, disp / 2); + intptr_t disp = addr - (jmp_rx - 2); + qatomic_set((int32_t *)jmp_rw, disp / 2); /* no need to flush icache explicitly */ } 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 -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); #define TCG_TARGET_NEED_POOL_LABELS 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); #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -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 jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { /* 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 */ } diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index e01045f66c..8b74ad8d97 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -371,7 +371,9 @@ void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr) if (TCG_TARGET_HAS_direct_jump) { uintptr_t offset = tb->jmp_target_arg[n]; uintptr_t tc_ptr = (uintptr_t)tb->tc.ptr; - tb_target_set_jmp_target(tc_ptr, tc_ptr + offset, addr); + uintptr_t jmp_rx = tc_ptr + offset; + uintptr_t jmp_rw = jmp_rx - tcg_splitwx_diff; + tb_target_set_jmp_target(tc_ptr, jmp_rx, jmp_rw, addr); } else { tb->jmp_target_arg[n] = 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, const tcg_insn_unit *target) } } -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 = TCG_TYPE_I64; TCGReg rd = TCG_REG_TMP; uint64_t pair; - ptrdiff_t offset = addr - jmp_addr; + ptrdiff_t offset = addr - jmp_rx; if (offset == sextract64(offset, 0, 26)) { i1 = I3206_B | ((offset >> 2) & 0x3ffffff); i2 = NOP; } else { - offset = (addr >> 12) - (jmp_addr >> 12); + offset = (addr >> 12) - (jmp_rx >> 12); /* patch ADRP */ i1 = I3406_ADRP | (offset & 3) << 29 | (offset & 0x1ffffc) << (5 - 2) | rd; @@ -1362,8 +1362,8 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, i2 = I3401_ADDI | rt << 31 | (addr & 0xfff) << 10 | rd << 5 | rd; } pair = (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); } 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 */ } -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); } 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); } -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 == 64) { tcg_insn_unit i1, i2; intptr_t tb_diff = addr - tc_ptr; - intptr_t br_diff = addr - (jmp_addr + 4); + intptr_t br_diff = addr - (jmp_rx + 4); uint64_t pair; /* 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, uintptr_t jmp_addr, /* As per the enclosing if, this is ppc64. Avoid the _Static_assert 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 = addr - jmp_addr; + intptr_t diff = 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); } } 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_size) tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } -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 = addr - tc_ptr; - intptr_t br_disp = addr - jmp_addr; + intptr_t br_disp = addr - jmp_rx; tcg_insn_unit i1, i2; /* We can reach the entire address space for ILP32. @@ -1834,9 +1834,9 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, tcg_debug_assert(br_disp == (int32_t)br_disp); 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; } @@ -1859,6 +1859,6 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, | INSN_IMM13((tb_disp & 0x3ff) | -0x400)); } - 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); } From patchwork Tue Jan 5 17:19:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356915 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp194217jai; Tue, 5 Jan 2021 09:55:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJy996S8kWIGU/HGC1atbGTD2CoPr//nmbGllGexlo4Cu3+DV11X3gB1A8x2CCt6XGrG01Ro X-Received: by 2002:a25:5f06:: with SMTP id t6mr766031ybb.136.1609869306647; Tue, 05 Jan 2021 09:55:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609869306; cv=none; d=google.com; s=arc-20160816; b=B0FaNgPhNrAzT+PrUQj+xtW97zcoUhD8wUkd89cFF4xbXj9Ua8aR2X4Ia/qAtWipdo ULRU4MUH2KWAHTvC8WWhHlgG2O5DYL/enmE5g6Cd2mILbUhsYp4AhrkP8Gke1fUiHZAS N2FlrHbP750lDYrzbyyhxVo40hO0m2odczgbVe72jst9y1HI4c9gBpvVrYDPvOj4nUhd Tf6czvOiehvHo4kiwsx6GHHb51wRlIfKGQSZ6amAauhVhehbfKcsPKohzIgcccdNpihu KIb6f+d/jaFdNy3mlGAWxWdGTE+AtKcf8nUIVndRPGptzb8fLvRHJlCHDWSfC7AL6h7W +NjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=E8w1jAPv5ZMwC9hUfY2h/aIQICFcgu6SGeTKeYT6t3w=; b=YBE0EstOuzEEux0GOXkpE2wtij6OJOLZYpuLPjFWku32WlTxHDX5HlcIS5XFMzxA8o Fy6KVbYRxF0O3dCjyp5G/5vRXigm0H/wDw0+OldhDZxMiXqITJOrA5ZUsb9ixvBcpFhU DHpLVF4XiMzuOiBBh2s+GHuHuEfZXJ77p07+2nBRdKmVFqg8JIvnKtJML1dSdU5/wZ8x Lho0HFORNxazfC85vJtUCfBJpzvMjEQHW6+5XkSF2MBJ3Vt0gf9oGmH0ced0R+/BK+z3 n0SlwdgB7Sfxo8BRSKCer7WSQJilebIlbeCkDu/aijieQZ3ZiUqnk0VM5gUcSi/IUjSg djQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P/JWR125"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e124si486264ybb.272.2021.01.05.09.55.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:55:06 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P/JWR125"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqXy-0007v8-1P for patch@linaro.org; Tue, 05 Jan 2021 12:55:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0V-0002Nb-Hh for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:32 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:36208) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0N-0006Yb-Tj for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:30 -0500 Received: by mail-pl1-x634.google.com with SMTP id j1so67817pld.3 for ; Tue, 05 Jan 2021 09:20: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=E8w1jAPv5ZMwC9hUfY2h/aIQICFcgu6SGeTKeYT6t3w=; b=P/JWR125xZFj2Zv/iq/7ZgYfeuPWJRBQaFtBy5Y29h4xw/fmkV8duqeBqIAlULnmFx 2/wHPtrqEjcgjp7Oj3oqJM47gP1NKCoe9IwoogY7xVFrSDBrjyRNiIqIRLcRmpMNuw0v gDrfwIlEnecefBDjMzWHBF3a0V/O43lFa0/spPw1CH7i1E3ambeWUsz1bZDqAgz3quMl Ad1tBHyGLXpbSZqOl6KiZhcpeAKHnv1jEqowc9uTW6UgZ8+w4Gkntxp0dqxhD9Im/vKg NOgsynVl1ZFzX9Mi2+gY/Xta/CtZDxtURUzACfst8sW4PNtUR7pCAJiapxxzrcDkbARN Xs/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=E8w1jAPv5ZMwC9hUfY2h/aIQICFcgu6SGeTKeYT6t3w=; b=dizuD7cb3428/M2yFKcy4A/q7f+aKPyAxL/aO7GPD9s4BugO7uM74zOQuLbuqeoyBd 8QaKvQtn9Un9mm+ABEAiu94u8Hlku3ksWlVlBtrPUsR1rIk9xTHWaoXqT6TaRIaLvoAr vdb8VpVGzpOJJf/RwKwY2oYIlRGPlwdlzEg4kQEF9HBDjQiWJFs23NC7PVJGReG6J8kk k5pfxLq73uHWwzfLXgJqGVUh89OYXuTPxDR4XmoSv7yAlZI7VxLGNS0cCXbFmRsGGbLi zCvpfisHhY9CXqfPDUjyrsU2oJYRclQRqYs/2bWUfPCZJKKcxLU6imWUY3hV91l09Wzw Q6rg== X-Gm-Message-State: AOAM5315ZyuQj2U8DN0oakGoMxp9LRM6M2gxvf75jub00EgSLO3RbndP 219B11xIL4lPh9eypbaR8ZDekjJMrJeX2A== X-Received: by 2002:a17:90a:bb91:: with SMTP id v17mr218078pjr.231.1609867221126; Tue, 05 Jan 2021 09:20:21 -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 u12sm2010pfh.98.2021.01.05.09.20.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 14/43] tcg: Make DisasContextBase.tb const Date: Tue, 5 Jan 2021 07:19:21 -1000 Message-Id: <20210105171950.415486-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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é 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(-) -- 2.25.1 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); } -static inline void gen_tb_start(TranslationBlock *tb) +static inline void gen_tb_start(const TranslationBlock *tb) { TCGv_i32 count, imm; @@ -71,7 +71,7 @@ static inline void gen_tb_start(TranslationBlock *tb) tcg_temp_free_i32(count); } -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); /** * 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, DisasContextBase *db, } /* The disas_log hook may use these values rather than recompute. */ - db->tb->size = db->pc_next - db->pc_first; - db->tb->icount = db->num_insns; + tb->size = db->pc_next - db->pc_first; + tb->icount = db->num_insns; #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) static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) { - TranslationBlock *tb; + const TranslationBlock *tb; tb = 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, TCGv_i64 arg) /* QEMU specific operations. */ -void tcg_gen_exit_tb(TranslationBlock *tb, unsigned idx) +void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx) { uintptr_t val = (uintptr_t)tb + idx; From patchwork Tue Jan 5 17:19:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356891 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp310641ejs; Tue, 5 Jan 2021 09:37:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1Q294yTAurc9mObJhme4t3u+F0wGNSdaVyGW9sUGJEuIRsyqcRSOzj77EkpzsALwdf+NO X-Received: by 2002:a25:c60a:: with SMTP id k10mr776496ybf.104.1609868228274; Tue, 05 Jan 2021 09:37:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868228; cv=none; d=google.com; s=arc-20160816; b=xZPQxseMZoy3mFrq0QmCM6GDxpnlXpoZkYHgJ08czGpy09TJmvYabYQXMew0noIskq IzR3WOIrBeGLCEVK4psDGggTdqss+razLCUlZDDeukAAFeI05+1AjjORF/lEt6HHa+rD TouogwCwruXcCUwzXgxfz5o6E+KUKr/5PoyUY78vlIdrb61gvkw6BwApWODSpcCI39No SJcwJbNqClyiA9Rmkv9DFKM1WIJVvuvkhvzvnMcENohCcT4MFnpUiuLQb2qjokpmFbLT UR48aGGwdJ9+T63EJeowhi7K0Cm8N6PXGmodXKczyTEZ+Sh/rklXhfASR0xbPYl+RuyC Xe5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=eilLw9ZK6iSUvH1D+Vc53ITHJN75NUB/4q2IHZwdzjI=; b=x3InybHCEQ/BnKP3nr6D0iQIqhXgyjIjJdPS9I+CyhQyrjf5BqMwpAdTFHGfq73gV3 BG4P/axc1kfs53z8rdjCXOBNiDixh+SZaYAqZyaItFdPBflYGMUyNmVblipfV3Ap+yJl U2VG+pN0iQ22mqOhO/8uubp8l6WZma8RKbzIOoq9lNZ/5l4K5azOI4JC8kkcogJBdpzI WwLRHt5H3qosWdm+oCYx3noi2+tK7SoFv6KcN//c76Bjow4OM3Mnuq0WFSgZV3eJQD4u 5APeCG9QR9vNndGutwv75sTc4Hz3c38Giq7XU/1LsqHY03VSWlfxeUrkTVkKAaqvPgzX N1qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QbBo3ru8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a10si514397ybq.331.2021.01.05.09.37.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:37:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QbBo3ru8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqGZ-0006mS-Kd for patch@linaro.org; Tue, 05 Jan 2021 12:37:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0V-0002Nc-N3 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:32 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:34004) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0P-0006Zp-9N for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:31 -0500 Received: by mail-pl1-x630.google.com with SMTP id t6so74340plq.1 for ; Tue, 05 Jan 2021 09:20:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eilLw9ZK6iSUvH1D+Vc53ITHJN75NUB/4q2IHZwdzjI=; b=QbBo3ru8E3tumRDsMi+pScCctikjWpFcDQsvCVEE2OXUbYNpsIu7C1+M3JdtKJf0PZ hiLxvMeAwJIN180hv5cw0HTf5dCY4tnm8UL99qr/fmIVaHjcyTWn6wqC0ZuGiCh+fAey c6R5cC+8+xnaU3aGg/NlKTuBJcPXVlmA3e4t9JoyiUuBPURYnOGdyZXSBgpSpzvYbfL0 bE8tBhv0rq5OVIAbvFjAzYmSVLRxTyh/o19Tct4fINEPkt/DrTZlvcn3mMkftu2Zg7ZW 1Vceil519g7u5noyNspYieKQrJurqVOZCGGWh3QNPK5FI1f9OoCX1rv+xXFqXzKXrls4 wntg== 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=eilLw9ZK6iSUvH1D+Vc53ITHJN75NUB/4q2IHZwdzjI=; b=c9Qhe2dEAOQ7zIIf8gk5CfA6wVGSigww4BOBmyhVD+M6JfR6uHklXeyTtXEX2BR2e5 Hb2KlDAO1DDaqBRqgcC6iswJptkB50la0Oz7XMdkkAJspLRGKVa6y6sbS36XbM4Pn2T1 FuIcrt0d4adtqe7v64BSEBmjIPj/8ER/7TXLARfFqTa0PeeKWSL7ijDaxsKG3R2UuYvy gNaazjTHu9CIaqD4evcRfbrCUakH1X5CJb8V1Di5eMnqqNwpi38X77uQgBtQ87qCgGTb 4eQl48ObsvOWtYzhgZLDJVQ1yeY+3O4rAmBHdIgkxYvibZ8FZMjwy7MOxF4meCXQ24Kt hQaA== X-Gm-Message-State: AOAM533AbHMoiJpi3dT74UgJr6vsOZqTo2pua019xVZLPpFgq446Ix4u 7KohOQ6ZISoBibRSoe3xgWCGcLDBStFOcg== X-Received: by 2002:a17:902:b282:b029:da:fd05:7766 with SMTP id u2-20020a170902b282b02900dafd057766mr636321plr.52.1609867222911; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 15/43] tcg: Make tb arg to synchronize_from_tb const Date: Tue, 5 Jan 2021 07:19:22 -1000 Message-Id: <20210105171950.415486-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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é 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(-) -- 2.25.1 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) } } -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 = ARM_CPU(cs); CPUARMState *env = &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); } -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 = AVR_CPU(cs); CPUAVRState *env = &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 = value + 4; } -static void hppa_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void hppa_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { HPPACPU *cpu = HPPA_CPU(cs); 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 = cpu_compute_eflags(env); } -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 = X86_CPU(cs); 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 = 0; } -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 = MICROBLAZE_CPU(cs); diff --git a/target/mips/cpu.c b/target/mips/cpu.c index b2cd69ff7f..318e0360ac 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) } } -static void mips_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void mips_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { MIPSCPU *cpu = MIPS_CPU(cs); CPUMIPSState *env = &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 = value; } -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 = RISCV_CPU(cs); CPURISCVState *env = &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 = value; } -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 = RX_CPU(cs); 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 = value; } -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 = SUPERH_CPU(cs); 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 = value + 4; } -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 = SPARC_CPU(cs); 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) } static void tricore_cpu_synchronize_from_tb(CPUState *cs, - TranslationBlock *tb) + const TranslationBlock *tb) { TriCoreCPU *cpu = TRICORE_CPU(cs); CPUTriCoreState *env = &cpu->env; From patchwork Tue Jan 5 17:19:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356916 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp194479jai; Tue, 5 Jan 2021 09:55:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2apX78WYRaorRHoifJOtvzQtzdiLM5BKyMgzFYFaBbSA/EkCxcTM1V8VNsHEV0E7ZNr6n X-Received: by 2002:a0c:fd8f:: with SMTP id p15mr713822qvr.48.1609869328539; Tue, 05 Jan 2021 09:55:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609869328; cv=none; d=google.com; s=arc-20160816; b=j0QfNVXLIKe4GqIKe9ODidQvAWAZKiuXR/Sbm78ZIOdgO4Q0N8wuLsLGbyWvZs7lbO 0FEYbcS0xRbnH6JgBy9eOC9uXYO7PIxKUAyW4Xb6wodHJRDOHkwn4UEpzA8429d2GIvl 1woTqgozOhjEOEoeBGB5qGDE5UcL7Mxq++ujI9y8SW9LMrcO9lFlMghIYtwlmXjmmlCP 3YPZXJD5CWWcOew4G7CvBE6iChM2OTlRdq4ihEmKtoIlzV/aQtRNISra4U8zXQF/N7Ka ZyXyzwzfiIErwJfHGtO6Zkoc7IiTfdSTrcXxTB+NvbW8Ofwc9bGOjphH4ykB4CRJAqDi KQug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=GOc/QdYClClYlMp2dKbUVjQGtFUnV184hz1wUbaQM2s=; b=SPPtwJQG6FByTzihkk7Cz7d3atdtcek2XqI6+6f0AwCrao76s2q9QRz6pAwaE5r/c/ wUIhv3a0gOaf65kFhh/6hhM227uDw+EmQwBculGxU/2DwGb6/fBwIQhi7QB79+9zeFOW ZZxKu5nFaNohiZDhsj7J+0d3iua1rjmPs0FH5bXAhGOT1zJucUUSi1kok9PW9EqHDNF1 Ut/M6PucrRpfrz7oon3gmzbKoAoETuV81q6SmUxs0Rq9OZPCx3U3c8+v8kR4TtxCMDje idIW6MxlXCBaZQtynth4842H/Er/IfgLvFR+zp5Xgo/cIVKJPI9M2r/NYFHpqd9GRsdS POQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E8HzXHV0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v3si153163qvz.78.2021.01.05.09.55.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:55:28 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E8HzXHV0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqYI-00086M-6p for patch@linaro.org; Tue, 05 Jan 2021 12:55:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0W-0002Nd-1e for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:32 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:33414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0Q-0006ap-Bj for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:31 -0500 Received: by mail-pl1-x62a.google.com with SMTP id b8so77403plx.0 for ; Tue, 05 Jan 2021 09:20: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=GOc/QdYClClYlMp2dKbUVjQGtFUnV184hz1wUbaQM2s=; b=E8HzXHV0hUWHkYw2rZ10TU4XOaQQx1E0CtiGqek0mN4dRfx5Ncvv++NuFmiAsf5poQ rRPxqCErNAiqesQxr58Fri0+sFX6IdmEK/0hCV6LjCsLbQes31bYn+nB2iEsssWaGDzS 4LAtOTDaoBp7yP+DxdA27cMIBppP19Opeibo1/t/eoft4zquMJ3jJBUmIXK3u0mKgKqo d3g2VwgyGDuDjphWGLqs5CChCSgLeUriSPbLU50H0AdCX8w+26ePU68YnhnT+pSvVmTw WN1TdyYl+iVqcQO7KDBV+HKLout8CXGN0XH0qW8UYvmdv1vsYCOGAoLgvyNy7l9pPMiw PfqA== 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=GOc/QdYClClYlMp2dKbUVjQGtFUnV184hz1wUbaQM2s=; b=NsknMu7hrsa0cAsde/fP+f4gdBXHjakFPrkqeNmlpQsJmPiLhnGAT2Aynlp5bIJ3pW y/fkw6GDD956jqgwZX7KYL9nLxIhhPYhfIMdVPuh9FMRxLIwL/REF11zfu0SykUxn2vp rDDAJuPSG+E8OYvLNmQR6h4qbaXNCHMJ+Ic63hIgAW994drn/pz9D4yOExyGGbga9tlx HjnOivHX5ArTd7gg5E9TGY9GAhI0X0hvaRfTPDlk1l8VAmb+hiW0KCs9cDC5bj1QleEj oBWZmGhoPzpCmNf8bgzYROUSHQTj11ZYqpxM6T+llL6oPAtbO7ytPNrPSD6hYr1rvVGE N7wg== X-Gm-Message-State: AOAM532Rjbc4nfLBK1txBgtoG192iKp6Cf06/7M2cFRcobartGYMIVpc rc/2jyOI+KmDQnUxi1y6PTP2OEq0kLf/6g== X-Received: by 2002:a17:902:7242:b029:db:d1ae:46bb with SMTP id c2-20020a1709027242b02900dbd1ae46bbmr313961pll.77.1609867224667; Tue, 05 Jan 2021 09:20:24 -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 u12sm2010pfh.98.2021.01.05.09.20.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 16/43] tcg: Use Error with alloc_code_gen_buffer Date: Tue, 5 Jan 2021 07:19:23 -1000 Message-Id: <20210105171950.415486-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 60 ++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 26 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 224821943b..77444ddbbd 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" /* #define DEBUG_TB_INVALIDATE */ /* #define DEBUG_TB_FLUSH */ @@ -963,7 +964,7 @@ static void page_lock_pair(PageDesc **ret_p1, tb_page_addr_t phys1, (DEFAULT_CODE_GEN_BUFFER_SIZE_1 < MAX_CODE_GEN_BUFFER_SIZE \ ? DEFAULT_CODE_GEN_BUFFER_SIZE_1 : MAX_CODE_GEN_BUFFER_SIZE) -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 == 0) { @@ -1014,7 +1015,7 @@ static inline void *split_cross_256mb(void *buf1, size_t size1) static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE] __attribute__((aligned(CODE_GEN_ALIGN))); -static inline void *alloc_code_gen_buffer(void) +static bool alloc_code_gen_buffer(size_t tb_size, Error **errp) { void *buf = static_code_gen_buffer; void *end = static_code_gen_buffer + sizeof(static_code_gen_buffer); @@ -1027,9 +1028,8 @@ static inline void *alloc_code_gen_buffer(void) size = end - buf; /* Honor a command-line option limiting the size of the buffer. */ - if (size > tcg_ctx->code_gen_buffer_size) { - size = QEMU_ALIGN_DOWN(tcg_ctx->code_gen_buffer_size, - qemu_real_host_page_size); + if (size > tb_size) { + size = QEMU_ALIGN_DOWN(tb_size, qemu_real_host_page_size); } tcg_ctx->code_gen_buffer_size = size; @@ -1041,31 +1041,43 @@ static inline void *alloc_code_gen_buffer(void) #endif 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); - return buf; + tcg_ctx->code_gen_buffer = 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 = tcg_ctx->code_gen_buffer_size; - return VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, - PAGE_EXECUTE_READWRITE); + void *buf = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, + PAGE_EXECUTE_READWRITE); + if (buf == NULL) { + error_setg_win32(errp, GetLastError(), + "allocate %zu bytes for jit buffer", size); + return false; + } + + tcg_ctx->code_gen_buffer = buf; + tcg_ctx->code_gen_buffer_size = 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 = PROT_WRITE | PROT_READ | PROT_EXEC; int flags = MAP_PRIVATE | MAP_ANONYMOUS; - size_t size = tcg_ctx->code_gen_buffer_size; void *buf; buf = mmap(NULL, size, prot, flags, -1, 0); if (buf == MAP_FAILED) { - return NULL; + error_setg_errno(errp, errno, + "allocate %zu bytes for jit buffer", size); + return false; } + tcg_ctx->code_gen_buffer_size = size; #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); - return buf; + tcg_ctx->code_gen_buffer = buf; + return true; } #endif /* USE_STATIC_CODE_GEN_BUFFER, WIN32, POSIX */ -static inline void code_gen_alloc(size_t tb_size) -{ - tcg_ctx->code_gen_buffer_size = size_code_gen_buffer(tb_size); - tcg_ctx->code_gen_buffer = alloc_code_gen_buffer(); - if (tcg_ctx->code_gen_buffer == 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 = ap; @@ -1144,11 +1147,16 @@ static void tb_htable_init(void) size. */ void tcg_exec_init(unsigned long tb_size) { + bool ok; + tcg_allowed = true; cpu_gen_init(); page_init(); tb_htable_init(); - code_gen_alloc(tb_size); + + ok = alloc_code_gen_buffer(size_code_gen_buffer(tb_size), &error_fatal); + assert(ok); + #if defined(CONFIG_SOFTMMU) /* There's no guest base to take into account, so go ahead and initialize the prologue now. */ From patchwork Tue Jan 5 17:19:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356881 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp303541ejs; Tue, 5 Jan 2021 09:26:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgmZeB0qCtiL+tXAgjRy5ZwpQ2VR+lA8xM+H1yPwmSP6LZ+uSs0kzazmwRA83C8joFzdzP X-Received: by 2002:a25:ea09:: with SMTP id p9mr672626ybd.109.1609867597317; Tue, 05 Jan 2021 09:26:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609867597; cv=none; d=google.com; s=arc-20160816; b=y684Uuz5e3dwNaHH+jC7nGwWB0YYWeZs8YJlO5g8UeBj+p9LcCr21QAejQfEhK6SZd hB96AxLLUzluhgcCCVCVlgSSg556s6hV5saQg3EFkKnorR8EvPzRLSEPRkLuaYcBW5Ah XPRVLikxFccq2yTVs5CV5+P3FNvzsuibQ+3o98EbooM4rzhw+Vn9FWAFuwjog3V0VWwF Q6LxH59H+F3HXVnOUGzm4reCOJ/jOF+YH0rlR568H0sQeJ5XBb7ClldOFBpNLWpXqjND blHCvVNMKqwP/C80rWiC9q6sT9AHWkh9QfWTOb2GIf+VmvcRosViMZ49fWZ/ZY1Izxxo 65Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=WLJ+IEp8InEElHssOjuTaax0u1zPSDB8mKgJLbPbdu0=; b=NXNITWopxfbwtEImkQCjA6OemJdiEdzPV4bkDawVILHz5imZ01b1yfJtsM90OlSfYp rLfNY4UHnL1f+f2vdFGTOJT0C9mq4eXnK7h+t7iEx37neSkhIlWpGI3RpAeKU8GnaI+/ AuMcOZeRVlJbfDd6Fobq9mE1y1cFALTN1onpMbAkZ/aYZq6LQgDUqasH+dLPuufW9tIm MSkGqfj++jYwbd+5sPr1N0hF/62NA45EM7MX3kWu8EEH7jHOIsKlPCSKm06SPyQdfc9W IsUs4R4Oj4RWUpb8+QqPpRXe+qYmtg6CdrXZWQ0zjj6M3E6G+uf3Bk+0JRZOsPNpv1a5 T2uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BBUIolrn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u44si392569ybi.470.2021.01.05.09.26.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:26:37 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BBUIolrn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwq6O-0002dg-Lc for patch@linaro.org; Tue, 05 Jan 2021 12:26:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0X-0002OO-0o for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:34 -0500 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:40529) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0S-0006bA-Cw for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:32 -0500 Received: by mail-pf1-x42f.google.com with SMTP id x126so117676pfc.7 for ; Tue, 05 Jan 2021 09:20:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=WLJ+IEp8InEElHssOjuTaax0u1zPSDB8mKgJLbPbdu0=; b=BBUIolrnpnEVXpI9yXcBCYdi+vR2JFyhHCHVS6hEsPgmx3cuITBq+wG2h2SIkDDWqn zdCO0cmbqhou+tfAlE8HjVtPYJsAlB6UgH31SthAUV9/O74TIXNI5DV0+79GTlr/JSO9 a/ln3SZ8EKyCafDSzGkyjQNdM2HR/LIPjoeAlEqglNA/sJ571uNtkjeyxwG0vr5y4JjO vfUnpQQYy0k+P2lCfDKOVJNdtlswXdwHLG7IDDMOQWKBaVyJYZGsorWof1DuNxLa3ceR HqZD0uARWAiHzkagQoNeWCUId2Ir2nOWdSOS/ilijDcQi4bYLtwO+37QEA7Pcr+m+3ym K17w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WLJ+IEp8InEElHssOjuTaax0u1zPSDB8mKgJLbPbdu0=; b=V6tpTxVE+UUh4ppPI33ZW5/Nh18k5zwKTBWeLwashlIpdc5+6X0ctyzYXE6s65mbUZ fXURtj+s0JJ3o7ItIDZN4OBWjxTbQhtYSZIXrK9F0/wYPUrlENitcQNnBDQlgz/mizoa Hs551t4cLJyyIO+I7VfX13Sve2orohz/r2dZ88byirNmnOfkHV/0YtMJ9l57HClfJfHy TeQ9yuAZI+GdbkEdgw1TvBRKIEOQtAvt6qRPUny6YgA/iCnu/jzQlAkoyYKedq8DOm8w lwpFF/Vki7eJbDntNyh7Hd3QYMC4kG2nAvzxN1Vb7vjDOwL+WXZdOjLfE9qTHc7/WDvx aZ7w== X-Gm-Message-State: AOAM532fIFfit2GaaDUswRXrmPeXYAVb8SVHii6PWjJjEtqBKwjyxmYY faJIFUVwocH11VagCy+wqxxJnrcOH99P6w== X-Received: by 2002:a63:f010:: with SMTP id k16mr377694pgh.28.1609867226221; Tue, 05 Jan 2021 09:20:26 -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 u12sm2010pfh.98.2021.01.05.09.20.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 17/43] tcg: Add --accel tcg,split-wx property Date: Tue, 5 Jan 2021 07:19:24 -1000 Message-Id: <20210105171950.415486-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Plumb the value through to alloc_code_gen_buffer. This is not supported by any os or tcg backend, so for now enabling it will result in an error. Signed-off-by: Richard Henderson --- include/sysemu/tcg.h | 3 ++- tcg/aarch64/tcg-target.h | 1 + tcg/arm/tcg-target.h | 1 + tcg/i386/tcg-target.h | 1 + tcg/mips/tcg-target.h | 1 + tcg/ppc/tcg-target.h | 1 + tcg/riscv/tcg-target.h | 1 + tcg/s390/tcg-target.h | 1 + tcg/sparc/tcg-target.h | 1 + tcg/tci/tcg-target.h | 1 + accel/tcg/tcg-all.c | 26 +++++++++++++++++++++++++- accel/tcg/translate-all.c | 35 +++++++++++++++++++++++++++-------- bsd-user/main.c | 2 +- linux-user/main.c | 2 +- qemu-options.hx | 7 +++++++ 15 files changed, 72 insertions(+), 12 deletions(-) -- 2.25.1 Reviewed-by: Joelle van Dyne 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 -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, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 #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, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 #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 tc_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 #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; #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 +#define TCG_TARGET_SUPPORT_MIRROR 0 void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); 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, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 #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, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS #define TCG_TARGET_HAS_MEMORY_BSWAP 0 +#define TCG_TARGET_SUPPORT_MIRROR 0 #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 tc_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 #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); #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 #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) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 +#define TCG_TARGET_SUPPORT_MIRROR 0 static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, uintptr_t jmp_rw, uintptr_t addr) 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; 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 = TCG_STATE(obj); s->mttcg_enabled = default_mttcg_enabled(); + + /* If debugging enabled, default "auto on", otherwise off. */ +#ifdef CONFIG_DEBUG_TCG + s->splitwx_enabled = -1; +#else + s->splitwx_enabled = 0; +#endif } bool mttcg_enabled; @@ -102,7 +110,7 @@ static int tcg_init(MachineState *ms) { TCGState *s = TCG_STATE(current_accel()); - tcg_exec_init(s->tb_size * 1024 * 1024); + tcg_exec_init(s->tb_size * 1024 * 1024, s->splitwx_enabled); mttcg_enabled = s->mttcg_enabled; /* @@ -179,6 +187,18 @@ static void tcg_set_tb_size(Object *obj, Visitor *v, s->tb_size = value; } +static bool tcg_get_splitwx(Object *obj, Error **errp) +{ + TCGState *s = TCG_STATE(obj); + return s->splitwx_enabled; +} + +static void tcg_set_splitwx(Object *obj, bool value, Error **errp) +{ + TCGState *s = TCG_STATE(obj); + s->splitwx_enabled = value; +} + static void tcg_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac = 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"); + 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"); } static const TypeInfo tcg_accel_type = { diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 77444ddbbd..0c1801b034 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, size_t size1) static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE] __attribute__((aligned(CODE_GEN_ALIGN))); -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 **errp) { - void *buf = static_code_gen_buffer; - void *end = static_code_gen_buffer + sizeof(static_code_gen_buffer); + void *buf, *end; size_t size; + if (splitwx > 0) { + error_setg(errp, "jit split-wx not supported"); + return false; + } + /* page-align the beginning and end of the buffer */ + buf = static_code_gen_buffer; + end = static_code_gen_buffer + sizeof(static_code_gen_buffer); buf = QEMU_ALIGN_PTR_UP(buf, qemu_real_host_page_size); end = QEMU_ALIGN_PTR_DOWN(end, qemu_real_host_page_size); @@ -1050,9 +1056,16 @@ static bool alloc_code_gen_buffer(size_t tb_size, Error **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 = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, + void *buf; + + if (splitwx > 0) { + error_setg(errp, "jit split-wx not supported"); + return false; + } + + buf = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (buf == NULL) { error_setg_win32(errp, GetLastError(), @@ -1065,12 +1078,17 @@ static bool alloc_code_gen_buffer(size_t size, Error **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 = PROT_WRITE | PROT_READ | PROT_EXEC; int flags = MAP_PRIVATE | MAP_ANONYMOUS; void *buf; + if (splitwx > 0) { + error_setg(errp, "jit split-wx not supported"); + return false; + } + buf = mmap(NULL, size, prot, flags, -1, 0); if (buf == 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; @@ -1154,7 +1172,8 @@ void tcg_exec_init(unsigned long tb_size) page_init(); tb_htable_init(); - ok = alloc_code_gen_buffer(size_code_gen_buffer(tb_size), &error_fatal); + ok = alloc_code_gen_buffer(size_code_gen_buffer(tb_size), + splitwx, &error_fatal); assert(ok); #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) } /* init tcg before creating CPUs and to get qemu_host_page_size */ - tcg_exec_init(0); + tcg_exec_init(0, false); cpu_type = parse_cpu_option(cpu_model); cpu = 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 = parse_cpu_option(cpu_model); /* init tcg before creating CPUs and to get qemu_host_page_size */ - tcg_exec_init(0); + tcg_exec_init(0, false); cpu = cpu_create(cpu_type); env = 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=on|off (enable Xen integrated Intel graphics passthrough, default=off)\n" " kernel-irqchip=on|off|split controls accelerated irqchip support (default=on)\n" " kvm-shadow-mem=size of KVM shadow MMU in bytes\n" + " split-wx=on|off (enable TCG split w^x mapping)\n" " tb-size=n (TCG translation block cache size)\n" " thread=single|multi (enable multi-threaded TCG)\n", QEMU_ARCH_ALL) SRST @@ -140,6 +141,12 @@ SRST ``kvm-shadow-mem=size`` Defines the size of the KVM shadow MMU. + ``split-wx=on|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=n`` Controls the size (in MiB) of the TCG translation block cache. From patchwork Tue Jan 5 17:19:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356883 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp303683ejs; Tue, 5 Jan 2021 09:26:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPF322vuTwLAyhEpKoQ6r0saU0iQjnmq033Hl7/u7JPohQItb5QfdFUsmN+HvQQl/qKT5I X-Received: by 2002:a25:d0d4:: with SMTP id h203mr723488ybg.274.1609867610773; Tue, 05 Jan 2021 09:26:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609867610; cv=none; d=google.com; s=arc-20160816; b=eRasf1EhVdHVVQplCm/SY6khgUugcUxoKwtg4ZNWArv+15jGFtzxQkeaAsY1diq+GJ ZIpEkJMjGh+3OT9muTPtDypRvxbwZ04+6zLz2VLWQShn7W3EX02iIzEISQmgYSGHAKYP 6J8PX3looYp2MOikaurA8Mg/OqCesChoipeWQQB2UXKFA4zIkVYYM8fKisLTSTSWJq81 CFyvaNfZUlR78vrMxi1Jf6Mx/c0oPw52G7Hmtms+5NVT73WqzEaYuDGhGAdk42J4myc+ WPQEeT7bye5+QGgH+xji2FzTmC41tyLJjPCHtG9t2xgRFmEWuCRKE0E+8QoFJbmEqMCd Rftw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=eOIoFRufaJyIw+Oc9PubO7k3MAtBUycjaNlTW//kLYE=; b=cMfaEXQ086il0JFFLgDV0cbcx0POM4zwXmS5mV+4FNh2F34N++SHdpXayFUQHbeJ3v vj0WK5vW/6wemhgJGLXTs6V3IxdeYEez6HguSa8TpsXmxNUZygwh+GDGs9yT3VEveyN3 Z7yXBdYNoXGTXwUIgcuc7e++HAL+oNocoHuxwRnGp+5zTdmwXX1hgQl+y+LBdtS5R+q3 cUl5ODb8a6m8g+HtQ1VAMgB4KGZ4lARon/h0lbPjSm6UuW6A2yB/yihi1tdD3r53rT7W HaGpzKG0qyyZAjXuB7OgR9SWOmBzgk8ojcbS8YllxX1o2v9TjNQfah2li1xMcLnTJ2IB SM2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EdzMGYE8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j7si378176ybt.380.2021.01.05.09.26.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:26:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EdzMGYE8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwq6c-0002qy-6n for patch@linaro.org; Tue, 05 Jan 2021 12:26:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0Y-0002Ob-DO for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:36 -0500 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:46614) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0T-0006bP-R9 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:33 -0500 Received: by mail-pg1-x52f.google.com with SMTP id c22so251665pgg.13 for ; Tue, 05 Jan 2021 09:20:28 -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=eOIoFRufaJyIw+Oc9PubO7k3MAtBUycjaNlTW//kLYE=; b=EdzMGYE8qddmzTjJ2Xhq67S7P48+nbYMWwmBFXkmqfw6/1OjLkEGTIpNXM3nRY4/kj KenehbIIHL7tJFyHW3ndyDJTSLDXB4nhXiHjzh3eEuYT/c7ynfqJ1Ljg0KYsnq6WXEwr kTCBCP5iMw93T7CIv5JLOXCTbfOUS8FZxe4fwUVRqO7JCsMrKOAhRnmrw2jxMQag6+tH t2geJHUS5md/eeHO8ZOJE9SDifcp4fJJ7nCxCB+1Vf4O2j326Dc1PFeAvedcuLvKtxW/ le2Ri5DQfTMOSBDfhmnNF2lN8vuOGkplnP7e9ETr8XVmQj4Vm1stabARJNz5lENYwjmq E4sg== 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=eOIoFRufaJyIw+Oc9PubO7k3MAtBUycjaNlTW//kLYE=; b=bX+/po+mGSwC810AwEYJb2RwEfB2F8SAK1xTH6/i4A+idrr3CaYBwLs/rc8SsTy31r uaPykry8vhiFCrZtUlqsgtsNZyHyCKEiKc8YArGjSlnUb31oAdA3gtOKoGNZvE/YWEL7 SVfeW9FHbah0sUqs1wrZ+UZBx7xXA2m+szMTYIlE/tyGtDZFu1vkmlbi3SCLAbPajAft C39sTBPpICNg0E3/GtiLAnwRyE1Dc4BKv+zTU9AOkhgAB7JMfnLW1FGqba8IWQ9RfstV A53361FSk+1puHkMmZ+N53KYmehA5axhOyT3k6XbOhr3D3cIigwEDSKwvphRgYJNsmdc i3mg== X-Gm-Message-State: AOAM533WdK+2FdvB48gEcR5qDnX3c1cb5w3fmBT9sUHeiwUJSApDMu06 W99wqLnP6as/qQ6UYTeeGDpWm32zE15+wA== X-Received: by 2002:aa7:96d8:0:b029:19e:bc79:cf7 with SMTP id h24-20020aa796d80000b029019ebc790cf7mr237418pfq.22.1609867227705; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 18/43] accel/tcg: Support split-wx for linux with memfd Date: Tue, 5 Jan 2021 07:19:25 -1000 Message-Id: <20210105171950.415486-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 0c1801b034..27c88527ea 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 = PROT_WRITE | PROT_READ | PROT_EXEC; - int flags = MAP_PRIVATE | MAP_ANONYMOUS; void *buf; - if (splitwx > 0) { - error_setg(errp, "jit split-wx not supported"); - return false; - } - buf = mmap(NULL, size, prot, flags, -1, 0); if (buf == MAP_FAILED) { error_setg_errno(errp, errno, @@ -1137,6 +1131,80 @@ static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) tcg_ctx->code_gen_buffer = 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 = -1; + + buf_rw = qemu_memfd_alloc("tcg-jit", size, 0, &fd, errp); + if (buf_rw == NULL) { + return false; + } + + buf_rx = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0); + if (buf_rx == 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 = buf_rw; + tcg_ctx->code_gen_buffer_size = size; + tcg_splitwx_diff = 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 = PROT_READ | PROT_WRITE | PROT_EXEC; + flags = MAP_PRIVATE | MAP_ANONYMOUS; +#ifdef CONFIG_TCG_INTERPRETER + /* The tcg interpreter does not need execute permission. */ + prot = PROT_READ | PROT_WRITE; +#endif + + return alloc_code_gen_buffer_anon(size, prot, flags, errp); +} #endif /* USE_STATIC_CODE_GEN_BUFFER, WIN32, POSIX */ static bool tb_cmp(const void *ap, const void *bp) From patchwork Tue Jan 5 17:19:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356899 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp185295jai; Tue, 5 Jan 2021 09:41:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFa2GYue7ZKPhVO41OOqdjS6v3RCUzIwxlS9ERZ7novuNn7tMdduPes1aOCPTSae129R+q X-Received: by 2002:a25:ab30:: with SMTP id u45mr760444ybi.516.1609868503545; Tue, 05 Jan 2021 09:41:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868503; cv=none; d=google.com; s=arc-20160816; b=HLYJh441egFgDmS2xv+8ZIRDPKEbqhZW9wbu6SW4O7h83La7aHndgawFDzhCZ7h3E1 MhgjkBiFhw/CphB2GZtOH2EBGEZtFxZPSRNBvNNoHMFM83WB3ObkG2jBxKLigs60gGd3 k0FQC1198LzKPkSIBNpXpspILz9gTHm3u9MwqI5uPNBp4wKgLYKgaB+EZF20wjS5ndZl oyaqYOm+OGJUB9rHzMZGc1M0WhFVdok9seDFocmQ5eIJ/ZoBtYTIwUoPdGkSHGhdNBzZ 7NsG3tPBl6wcfjnx2jmaa6LDI56czlC1qBhg4Q/YbYNfFMrmfmBYvjw+rfvRVbv/fVrk SH6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=a/0Vgv50hc1LXXX4C7/zC4wpNnScirkNY5xQi7vT9aQ=; b=FWVtNR71ilWHOeahU3ZyYmy/DYedAYifrbnx0++ENzKgWiOeoTmckMUd8PSXZIJJAv A62mUbX2og1CWfRO3kdz7fp2Mmr5Ctwg2h/I2DvG1Jlo16OZ8kMBYl9rKwvDG1Vy33OP zxhVAnAf75H3xCMDWhL7WOVX4kc6mgdJd+7CFooEAM6VxyRPuAAjC1esHJEVM877RSCj iZr1nLZLRKwA3PJgFiHpRn43NxnKj7ZDdvOiHQPAMHT5FZwFUHV+70LiLOR6dUm2DcY+ ZtHZBo0pVL9H9hXQDkBc78tnye/TAl7dsYY8wK2SiAxNCAKz8sG/uRighvm5lAN+xPpx 8gbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=djZUjhCM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 21si460978ybf.441.2021.01.05.09.41.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:41:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=djZUjhCM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqL1-0005nJ-2s for patch@linaro.org; Tue, 05 Jan 2021 12:41:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0Z-0002P6-5R for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:36 -0500 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:34935) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0U-0006bg-P4 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:34 -0500 Received: by mail-pj1-x1035.google.com with SMTP id b5so27658pjl.0 for ; Tue, 05 Jan 2021 09:20: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=a/0Vgv50hc1LXXX4C7/zC4wpNnScirkNY5xQi7vT9aQ=; b=djZUjhCMewsq21/c+tjVafsy2FGjVfvpxuDMBM5dNiyFxfw3gbMYdfjx2iu2bjeVGm 9n9cbW5tjFUcvRZV21LvItkuv2wLhA3iMtIwBCLbzGvT+RaV6jVOBLu0JXj7URLlsZIJ 2ORMa8hKdac0ARs8//aHhphXlo632tRkxTtiQW8iAZ0YE8BsCb3MTE2lqXUrmph/WVnY lqwupssdW16Sq792cy5Uwv0vw0hOTk+Xgq1ghQTs1/07d7DQ/prSSroBsZEjQj7O6em1 CzlqP5e5skjDTv8V1Fl8pl2KrMdGt0b9Jn6AaGfUuz3d1WlPVXo6N/7Qq4BMH/vKIacg l2Qw== 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=a/0Vgv50hc1LXXX4C7/zC4wpNnScirkNY5xQi7vT9aQ=; b=d/3Q2qFmwa34L1AczUPLaEuZWrV4A1eCgsoHnZc86+oartfqN8GcZGxU5sj/t1XMg3 G+O+gXEacwimm759YZAqZYo02IK+kaLkFfR4dxfaputCDBeWz1U5Szb+DQq0sAU/KTJy opAhQanaOV3gaAcijmVdgKgPlRvbuIeyaUT5TS+6hef5KIxM6YX4QWTPnBbPOksFNTHg VAxteAWrz4AMvgP3+6PFLdFypsx8Q7rYSkKVV4FuYYw86WJ0yhP1UJ6t8YNzeA4fopxS /d+r6Uuuo+LGw1nTtlOlHZ45OU8uvvnyrNufbMUcfhrotjTymzNC0GloGi+pG57VcJz8 u1eQ== X-Gm-Message-State: AOAM533/wrV1LTxUP30HcCTKEU/psFZm/rXUewqMtnuBRSmw6J8vuVXz ZknebQBZy5BRPJHsn3j3k/rpsrIMdhjNnA== X-Received: by 2002:a17:902:ac98:b029:da:cd0f:b6a4 with SMTP id h24-20020a170902ac98b02900dacd0fb6a4mr323216plr.71.1609867229247; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 19/43] accel/tcg: Support split-wx for darwin/iOS with vm_remap Date: Tue, 5 Jan 2021 07:19:26 -1000 Message-Id: <20210105171950.415486-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(+) -- 2.25.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 27c88527ea..0c0f9c3e62 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 */ +#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 **errp) +{ + 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 = (mach_vm_address_t)tcg_ctx->code_gen_buffer; + buf_rx = 0; + ret = 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 != 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) != 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 = 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 splitwx, Error **errp) #ifdef CONFIG_TCG_INTERPRETER /* The tcg interpreter does not need execute permission. */ prot = PROT_READ | PROT_WRITE; +#elif defined(CONFIG_DARWIN) + /* Applicable to both iOS and macOS (Apple Silicon). */ + if (!splitwx) { + flags |= MAP_JIT; + } #endif return alloc_code_gen_buffer_anon(size, prot, flags, errp); From patchwork Tue Jan 5 17:19:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356892 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp310923ejs; Tue, 5 Jan 2021 09:37:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXyirHIeVLseSqaGEUhIOy6deAXz+43K2ggzqPLBMFYvQDNpltTdFHo/ATzY7v0nvhz2ND X-Received: by 2002:a25:5052:: with SMTP id e79mr732519ybb.51.1609868260440; Tue, 05 Jan 2021 09:37:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868260; cv=none; d=google.com; s=arc-20160816; b=eEDMej+slR2DOf+rU4SJqJeiuaQbuZC9AetY6iEXTO7V+R4oo0zUIbHvSTANn350yE 7Elsn9ce+mROKC429r84tE1P1zOLGQtMjgsPOtVsDWMWITH/4wFQtu5t16RRCb2jfr0r s2eenGhorElOiAXf7dCP8zAtn6lYlz3DgOuu8tmg2Y47X+EbTroc1gnMyst0xTbSDdjh meHw3C8W9++WC8rJxs0AvdimD1RfCRcvTVK+m0GL56/GS0N3thuHmoqLTmMibfvs+y0e 0hs5KSIP9d4HDLn60skgRG/jsLmBFMR8LLmMvZvaLCrDd0/olPHVAl53n47D/kfPje0A GHRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=FZ00kItmZ47N3S02niGICD6Ulwts3rlbBFeGNjnPxC0=; b=Rc7hAxmPgEAxDgMfqx1aZeWXh/3dX8AdtS+/QwGwlzpEI4J1jYd0eQwu7khnUm8bYh w5uzDKPAfNz2C9MRJII27Ezr7gYzZb6rAjvmRI7VFYNb3nO3RBwvhsK0q2nlMphdSY9O XCKGc3fqtWK3DC3q3yDWjtSraAmjK82iYGUG4icruYdsaw2rArMtIWGFAqwqG/JAvn2A frkQuX/JuOmi+9HrC7eIwJV4JPy4tFnbtoyH0nwp2dLfknhys3x3yN65qE1z1gsoFkPl iTjzdBA9eYddWFYAIWvtJV8Ffdgr6+FUbCSQShgk16IdfB5LlaewykeLuTPULauG+xZC licQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UFN8wyIw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h18si495565ybq.495.2021.01.05.09.37.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:37:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UFN8wyIw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqH5-00077o-Qh for patch@linaro.org; Tue, 05 Jan 2021 12:37:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0Y-0002P4-RA for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:36 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:45509) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0W-0006c4-F3 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:34 -0500 Received: by mail-pl1-x634.google.com with SMTP id e2so41153plt.12 for ; Tue, 05 Jan 2021 09:20: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=FZ00kItmZ47N3S02niGICD6Ulwts3rlbBFeGNjnPxC0=; b=UFN8wyIwB1zAxcIdKE8yBVrmyrPiqDxs7xKgQ6xCBXeib8wwi6yRloZFC5nhZtUBxN T7TGcRClJ03IbpXUUWV8t3GdA7Q/uvuDMStwQP+A1uhedZFJbVuLvicMql/6XwrwDN/k bAMV09b74yJrnNZp84yDeTCCgZX9lWSPcruzeFefnb15qKA1HO2jmI7CMkeMp55QA+C1 1rLmLUzZSlDWAw0s6LaPi7JFRuHGWOjhrm34bE+G1WUHSJjG2iqLhYitC+RZ55C33rMO D2AyVgKeyHkNFaXTmG4mU8VNUJ2aiPL5HyDKldAS91TEY/4CsUGP0ovtz461OYKisJ2x +Ngg== 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=FZ00kItmZ47N3S02niGICD6Ulwts3rlbBFeGNjnPxC0=; b=oi2eApOCrAiznv6V+7SmgLGKTBOw5MotROZq5d2DXJnx4wr6kYoulZgFXQ7ZNGN05e UzQ8elE41fTNGxYOYQiMfyh97/f0z9i+KTJ693jfQxWTkId4jvJ5+Tq96fb4PTpUYvfv iOD49vTV6KJ2muQGRQc/HE18JaHqPCon/a00nbgRY5WoLhRUOnWcvTcz5S3iGNSh2xC1 Fud9c2eHipD8/fZN0uY5DMba0oaT8GNMfi7k+zGjlyjZh8sQ2UqEL6fAbZmMrH4NwAqg RJ0KDCGmmyIn3X2OuAK5lAHSnlgHmwDNIW7xxnwTle3wMFE3IupXBtxX+JoNAq6+AdiP 2uzQ== X-Gm-Message-State: AOAM530WPYefIqgrQheqx6aGoFxc32AlsnMWFfpdy+dEmjj22yGLPavB RRTzmULat/9dBC3HSfbyz5JXlNLuh+i2Ag== X-Received: by 2002:a17:902:8c85:b029:dc:2f27:c684 with SMTP id t5-20020a1709028c85b02900dc2f27c684mr557105plo.44.1609867230886; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 20/43] tcg: Return the TB pointer from the rx region from exit_tb Date: Tue, 5 Jan 2021 07:19:27 -1000 Message-Id: <20210105171950.415486-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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, 34 insertions(+), 14 deletions(-) -- 2.25.1 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 8b74ad8d97..17343d2a83 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -144,12 +144,13 @@ static void init_delay_params(SyncClocks *sc, const CPUState *cpu) #endif /* CONFIG USER ONLY */ /* Execute a TB, and fix up the CPU state afterwards if necessary */ -static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) +static inline TranslationBlock *cpu_tb_exec(CPUState *cpu, + TranslationBlock *itb, + int *tb_exit) { CPUArchState *env = cpu->env_ptr; uintptr_t ret; TranslationBlock *last_tb; - int tb_exit; const void *tb_ptr = itb->tc.ptr; qemu_log_mask_and_addr(CPU_LOG_EXEC, itb->pc, @@ -177,11 +178,20 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) ret = tcg_qemu_tb_exec(env, tb_ptr); cpu->can_do_io = 1; - last_tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK); - tb_exit = 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 = tcg_splitwx_to_rw((void *)(ret & ~TB_EXIT_MASK)); + *tb_exit = ret & TB_EXIT_MASK; - if (tb_exit > TB_EXIT_IDX1) { + trace_exec_tb_exit(last_tb, *tb_exit); + + if (*tb_exit > TB_EXIT_IDX1) { /* We didn't start executing this TB (eg because the instruction * counter hit zero); we must restore the guest PC to the address * of the start of the TB. @@ -199,7 +209,7 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) cc->set_pc(cpu, last_tb->pc); } } - return ret; + return last_tb; } #ifndef CONFIG_USER_ONLY @@ -210,6 +220,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles, { TranslationBlock *tb; uint32_t cflags = curr_cflags() | CF_NOCACHE; + int tb_exit; if (ignore_icount) { cflags &= ~CF_USE_ICOUNT; @@ -227,7 +238,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles, /* execute the generated code */ trace_exec_tb_nocache(tb, tb->pc); - cpu_tb_exec(cpu, tb); + cpu_tb_exec(cpu, tb, &tb_exit); mmap_lock(); tb_phys_invalidate(tb, -1); @@ -261,6 +272,7 @@ void cpu_exec_step_atomic(CPUState *cpu) uint32_t flags; uint32_t cflags = 1; uint32_t cf_mask = cflags & CF_HASH_MASK; + int tb_exit; if (sigsetjmp(cpu->jmp_env, 0) == 0) { start_exclusive(); @@ -277,7 +289,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 { /* @@ -673,13 +685,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_exit) { - uintptr_t ret; int32_t insns_left; trace_exec_tb(tb, tb->pc); - ret = cpu_tb_exec(cpu, tb); - tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK); - *tb_exit = ret & TB_EXIT_MASK; + tb = cpu_tb_exec(cpu, tb, tb_exit); if (*tb_exit != TB_EXIT_REQUESTED) { *last_tb = 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, TCGv_i64 arg) void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx) { - uintptr_t val = (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 = (uintptr_t)tcg_splitwx_to_rx((void *)tb) + idx; if (tb == NULL) { tcg_debug_assert(idx == 0); From patchwork Tue Jan 5 17:19:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356887 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp308268ejs; Tue, 5 Jan 2021 09:33:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6YWbAMFbLV45cJeJcDOGsgiD+sen+XBk8raSAFmFEkLdvVtYQT/5cc7HhrSSUXkUXCQyL X-Received: by 2002:a25:d98f:: with SMTP id q137mr793122ybg.128.1609868011339; Tue, 05 Jan 2021 09:33:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868011; cv=none; d=google.com; s=arc-20160816; b=VMlTMXfUCx2UA4hTxofwQ9lSqc/Lymy064SRjzdHx78OaMjQQTF27XbjNRytOA1zmJ 1wvfRASOSD7iKE02uPP/DGeyEhkh96/VrR//Ls+s46J5sRcT194T8+6WELZq7WiZih4V htM8NgWnl2UJh9VZ4zBl+hGv8V/9/jmXfF4YEbSIeVCHAz7AtbGu8Hcvy3LCjshxmv88 IQQPG/ceTVGBbHYea+m9wCgH1bincRzpFiB5gcNRwiS9MTIOSqUDGHwift7kMkwwgmgc /ZjLHyZ40uYFbxK8GLsY+pzxolJIgUyL5Hgn/VlMpf9aspO78b0icq3OZHiMz2XuYbcS VQ/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=5vS8wJ/iNPyRl3pgmKuFkCd5a4WmbW3WD3BdbgSErfg=; b=HcyfGJg2cxdgG7xoxp7y3BnbiMIgiDj/CVpgxw7kxdzVLgBuzYRlCGVuKpl3FzrpeF k4Mq8OQKsZpVErf4e2OrammndHpUIeWMYeOtOqgk1tI6ywi5+xw0koWSQScJNfjX/+zj aJEsI/lyciyLLNAgBtcHcV2yM3spowuAxG/Afzorh2qAZCQ5imBicta9NDoVqlQTHXfr yPlDwSwGEBzB6PVwkOfZhKOUeO1x3erWElzVPpxZXbIffr0hkXduKQbHgWVnf8x4opmC mwwl+5gpsyzr/0DxSwWv0JSECHGAZrC5ftf7BOa6uwesmNVggce1dQiTHCFnLmOhQmbH fHBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o2xisyRU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m132si439697ybc.305.2021.01.05.09.33.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:33:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o2xisyRU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqD4-0001pR-C4 for patch@linaro.org; Tue, 05 Jan 2021 12:33:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0a-0002PD-Eg for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:36 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:53556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0Y-0006cP-5o for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:36 -0500 Received: by mail-pj1-x1034.google.com with SMTP id iq13so16540pjb.3 for ; Tue, 05 Jan 2021 09:20: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=5vS8wJ/iNPyRl3pgmKuFkCd5a4WmbW3WD3BdbgSErfg=; b=o2xisyRU+c8hmwTNzYfwaXCYLs4rdKbUG5N/c+x18La3hBuXYAeV3edTRn+2XdGZRn DYBy9EkFB651EwLY3wksIxrtfidoumkZzPKgkt/+catU7YcgYHtzaA+xPkCHSjEmnFcv Z3ePKhymOHl87HVUxVIvIN6u76FJkVrq4nNWLXDk97gptGs94wrP/ctofRebqLgWIOZz amPErX6pBOpe7b+X6eSHczICYqwDoMpn7iAVVsO5kS+OLf/D8bEXinuquAW4LH7oDw31 pFJRfqOpRzbygylBHkVdCzgrCzR3lbYIMfoEczBIHl8uc8Q45IjglahJuOigdqvVzVry Uq2A== 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=tdI72OUwWIrK4huuQa9msNrW3SoTHCcm+omwcSBPQ9gJ/n4yTkdtI8gPh4caPlYURO sW5KKPCy00z5PuQZ65fgyAqysSIjosgwvVvC+oXmtaPKOYuCzvtzEvWfUVU1eSxI4btk td8BJhJmlhoN0pmRDvdI0evS/h3egWcNn0wA4INBHlP4YmctLQiNv4iEEPWms5UpAldL XJLp+Dhk3CY08wiEywwTypOIuhwkBMi/ImAiYteVvWNPmLdt2xC9KjFDOIPUcbtw2vmy DVSJUiZm/LiKdw+UfC5+S5QqthymznKXdLnqA8Po6xB0bGJcIPOiZHnPu0QnB6FUH8Lb vY+w== X-Gm-Message-State: AOAM532Y+pS6U8tgd3SbVg+OLl/wMvdqHMAv6ml6OCGOzmDgzRtuTCs0 gc2LGnE2sE0V5SMe9KfoY6b+TWvFK13b/A== X-Received: by 2002:a17:902:848e:b029:dc:b38:98f0 with SMTP id c14-20020a170902848eb02900dc0b3898f0mr545666plo.82.1609867232423; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 21/43] tcg/i386: Support split-wx code generation Date: Tue, 5 Jan 2021 07:19:28 -1000 Message-Id: <20210105171950.415486-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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 tc_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 #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 -static tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *tb_ret_addr; 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 type, value += addend; switch(type) { case R_386_PC32: - value -= (uintptr_t)code_ptr; + value -= (uintptr_t)tcg_splitwx_to_rx(code_ptr); if (value != (int32_t)value) { return false; } @@ -181,7 +181,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, tcg_patch32(code_ptr, value); break; case R_386_PC8: - value -= (uintptr_t)code_ptr; + value -= (uintptr_t)tcg_splitwx_to_rx(code_ptr); if (value != (int8_t)value) { return false; } @@ -1015,7 +1015,7 @@ static void tcg_out_movi(TCGContext *s, TCGType type, } /* Try a 7 byte pc-relative lea before the 10 byte movq. */ - diff = arg - ((uintptr_t)s->code_ptr + 7); + diff = tcg_pcrel_diff(s, (const void *)arg) - 7; if (diff == (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); } -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 is_ld, bool is_64, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr[0]; if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) { label->label_ptr[1] = label_ptr[1]; @@ -2253,7 +2254,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, /* jump displacement must be aligned for atomic patching; * see if we need to add extra nops before jump */ - gap = tcg_pcrel_diff(s, QEMU_ALIGN_PTR_UP(s->code_ptr + 1, 4)); + gap = QEMU_ALIGN_PTR_UP(s->code_ptr + 1, 4) - s->code_ptr; if (gap != 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 = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0); /* TB epilogue */ - tb_ret_addr = s->code_ptr; + tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr); tcg_out_addi(s, TCG_REG_CALL_STACK, stack_addend); From patchwork Tue Jan 5 17:19:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356919 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp197438jai; Tue, 5 Jan 2021 10:00:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8+w2e/ZH881/D5SpelkQuuEZounDzhHkoqLs+zSQcWb4czGVk4J0DX1qWZpHP16aT1ziu X-Received: by 2002:a1f:dec2:: with SMTP id v185mr899598vkg.8.1609869606616; Tue, 05 Jan 2021 10:00:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609869606; cv=none; d=google.com; s=arc-20160816; b=sjFMiy4bJNrZ84HTaeNNPSD5305wY486ywsklW2x0AhQf6ZGzWfK+Gp4nTJ/Idxi8/ RPB1dRi3qCXCN42U+1Cn7nDm/tD8BruwHSztRaEfGJJuqHM2fA7L5Di22PcnIFdgky07 tmTYEoOXNFkqVg1x0U4e5jK+4LHSz+HqLsnIiLMRFxxckEMVxxwTbn1X0E+f6cc1c0y1 2V/OfdiR2+MYMxryKAyqgbtxUDFw10+QJ/5cM7hkOvaL6cdm292uzD/A6prdJay9MiJ9 co77yQdvmJpCcaLsoMp72AKoTqDCVzr5Mk7VnWKS+bTua/wQ4te/p6q9OazihKyzlMQE 5+Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=8LKGM21omgiw4s8pLH3F/GfWnbD4CM5oKLWF8kPN/DI=; b=oM7LIY7FqUOkMlzY2ICm3byi6wH90ChIU5J9WV5lqUhXoWnr/S4v87m0gdoo3oeHGq Otif1itYJnymYZVm9EX0zGdjhL1j56/9+zkfHOPuZs5+J2VK8qWSjsYCh4Rz3ua3R2e1 hsMqYIPUoDVPu7dGDE9Ak4IAZZ9bdxJYqZkpLyHtGvzVo+8FO0RxjJqJeKF7aMnXib+h 3ah3ZewZd/Dw/v0g6MmR3HFwvw1ZkEshY+n0DA/xtGgvd1zNItQh8YaYcWOdUwkWNoCd tKaw99XDi/HKJ6i+ZbAnMu/Vh3fCDqP3i9Eg+S51ahIdair5s9c/2qQ5+0jPo+AN+1fw VUzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QjnMf5B8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 22si130568vkf.66.2021.01.05.10.00.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 10:00:06 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QjnMf5B8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqco-0003k4-4a for patch@linaro.org; Tue, 05 Jan 2021 13:00:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0d-0002RZ-2f for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:40 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:42518) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0a-0006cb-4q for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:38 -0500 Received: by mail-pl1-x62d.google.com with SMTP id s15so50189plr.9 for ; Tue, 05 Jan 2021 09:20: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=8LKGM21omgiw4s8pLH3F/GfWnbD4CM5oKLWF8kPN/DI=; b=QjnMf5B8ZV2KCJxA2jhoccW4MDB/cum8xjbFaHV7+zBV4Hnjx5Uep7b9QQsll7XfHe LUyTwFN3dfD0CmxcttiZqJ6JbRYMkETQGif2pHaB1t+F+2fohO412YuIDzWVwr/56Wgx HMmk+XuoSFwbCjJ7pHh0SfA4sF0/9fgwyrHCir0G1xWG69dKGCfJq3uVj3GOhUaoNal0 jCW9nPvQSZPLrBUN5va7gL1Sgn6zr4RLkaVKLLoVv9s3u/2nhBbvhiz+y6yf7giSmh1e syE8NL2dXGbD7zkOxo30h0CYRLXnzPIKtc7QF18g2fscLR0SH/AaYUQRZESwqURMQrnI hQLQ== 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=ckVNvPwQzuliGC6eWeVEragAvc9nNRCwqlytjlzdHAzDVrQeSJ4LgBR/ZjqJXtqD9+ kpjx6VTiCLyVY6NrUAHfxYR6ImK6l3jZS9cbd68NNyIg3DMjlt3DxazJXPTeQZh1tRXV Aa44PRrBYebmyMstRcWa7pgtgKlzMrxZKA55xaoVsgnmr093b5LBA6V3/Gnj1wC9geOc UCOzHpxZRpTy8cbyfQ5ki2foeLa0V3HZ+PA9/ch5fAuizJ2AdsKITjpCOIvGMsvafbgx GdjMypVAaDoLaJyT4y0OYKpdhyd2KptPVGY0C9mCBj6tijo5BlR7+DeJmdA16pgXfdgA k+Sg== X-Gm-Message-State: AOAM532oPDuQ3vPQRBXqm/5BHrZKG8WxHATUYPUA+QmIt4GhWJxK1PAz 5iE4kPmHeOwanIJJz/mLoUoBWN5e3BByhQ== X-Received: by 2002:a17:90a:df12:: with SMTP id gp18mr246719pjb.43.1609867233891; Tue, 05 Jan 2021 09:20:33 -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 u12sm2010pfh.98.2021.01.05.09.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 22/43] tcg/aarch64: Use B not BL for tcg_out_goto_long Date: Tue, 5 Jan 2021 07:19:29 -1000 Message-Id: <20210105171950.415486-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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, tcg_insn_unit *target) { ptrdiff_t offset = target - s->code_ptr; if (offset == 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); From patchwork Tue Jan 5 17:19:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356894 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp311660ejs; Tue, 5 Jan 2021 09:38:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmE1jhQG//rTqW+YPg2pdrlPGeg9idq6nwjnRv9QtpbsI+mIhMbPFowdFhi3MgYuiMcCI/ X-Received: by 2002:a5b:2cf:: with SMTP id h15mr662627ybp.475.1609868329806; Tue, 05 Jan 2021 09:38:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868329; cv=none; d=google.com; s=arc-20160816; b=KBy98FWHzO244kAPra/rj5+gl3ngadTAfdiyj+XJ5nFyr/hmwIPqvy9OYihZNJUDzA T+vRr0XD5JbQ+xO+GllWwoWNGW24RR4ofdanez4xSoFwfM3036SzGp6rQiX1hGwrrIXx v/Bu/lYGz/Awc3DqVp4Z89JSMTsSPv/zRgfxaSj4s2CP8whpM+/mmEtSI6dQ2mNe1dmg abTy+64wX323He7b0gaV+rIbNV5oV4KH5q19FeGPWF4tQCdgiICj7vBa3C2coIIZuz2d 3F3L/zGAsE28a5od87w9S13sH9BQK+R91CVG1TOy2t9MEH4rCxUZmr6VZ14VaHVHfYba bScQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=T8AfGj+HO8ldfN1QyJhTtl82SWRrf2P8eJp7eJUkZZU=; b=lX+ax3un+kGdnOXvtkox/iOVsq+GiC2/QVYpI8J4j7BT+SIFZPrIlXd4JyIgHvOrXK +1XSrHQiF/vavexVG3/BtyZmnrqhIx+ZEYWS6cB65jtfJBtzFu9l93sjeu4gUmRp2scl ojMOVnQf4t9VIzA7BZD8o8SXpUdvjAKJyWsq3SifPa/x57hfefw2FRR5p56XmhLYyIsi LoT8KIQbvlZzN/0K0tH4tV2pyjy+/xcuj+EIGDqwvx1OADFitim28ALXgRUcSqq5jBSF 1vl5aaZ8Oq5W/pMZf6j4PQG43oJ/Ptcz3VZXhsSLLsSn1cP9PzOQzdYXZYG1ydDM8577 QmSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qlzAktpO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y69si452447ybe.493.2021.01.05.09.38.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:38:49 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qlzAktpO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqID-00011B-5O for patch@linaro.org; Tue, 05 Jan 2021 12:38:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0d-0002S0-Eh for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:40 -0500 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:39701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0b-0006cy-J9 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:39 -0500 Received: by mail-pg1-x533.google.com with SMTP id 30so280256pgr.6 for ; Tue, 05 Jan 2021 09:20:36 -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=qlzAktpOKCnDylI1FjbM94qXbyRiFHhTd+zdJ49C52FWwRzQtUd1ODJMm5qfdelsxI IpXNC0FA82zPlinEThJAT0JeaVWMk69zb3i70MeoU5BI+04HulFgJFx2IGlRqBTlEmXg ZIdndJ/p4eJQMTC0bddfuv3sWqOzn8LFkWqUB+9yzCRQZgsoN3WBQd10CxIBYvEjszc2 jwPZJx6umE8bjuAMHqjueof/RXqrUtzeZLIoAPDeaFmjSjExjCWJ4v3lJGCsaLrAB/Gp axat86krR5YOwS3N9x1LEb7jd4RvX///Z7/vHjSYWrw2vmqlj7yAlvN36wiwLNjE+/O1 HLzQ== 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=rsvjT+wcgTGcaf6+m4XV4223WwuBvlnC7bkOfKjtUdgAts0uvZeTYkbQjfkik/5FMQ S5c+M8qFchVgGl1+EHBSLumQf2KhxshouOqWQ+oJe24q6hWTMsUbYEC+vBKxN7EE6EIL uqPbTOdiXwqtooMuDZ6kiGKhW91r9vy7qHWION7CsOjsTP9atvwhJq3t1PRD0VGuwRL/ FTyRHYyNQjriVFfACCfN6ubKi0hsEcn+pmaB9VSwBke2xOEtx4sXqZLKqUvXzWL0xTya zZuiOKVJaS44RbD9BDZrUXB8hCzTonR0/CB5uMgnnkfVDWxm9HWCnq7YpWezD7PEsYkm /k/A== X-Gm-Message-State: AOAM533pdZ7ylkvF8QNFVNhgd5gXk0COiq0jkThlC4zQrOalGAPtJuoh 1aMhz0b8f4yWJoKjEe/uotH51IjkfLXiVw== X-Received: by 2002:a63:4764:: with SMTP id w36mr334507pgk.127.1609867235436; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 23/43] tcg/aarch64: Support split-wx code generation Date: Tue, 5 Jan 2021 07:19:30 -1000 Message-Id: <20210105171950.415486-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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, uintptr_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 #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] = { #define TCG_REG_GUEST_BASE TCG_REG_X28 #endif -static inline bool reloc_pc26(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_pc26(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset = target - code_ptr; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset = target - src_rx; + if (offset == sextract64(offset, 0, 26)) { /* read instruction, mask away previous PC_REL26 parameter contents, set the proper offset, then write back the instruction. */ - *code_ptr = deposit32(*code_ptr, 0, 26, offset); + *src_rw = deposit32(*src_rw, 0, 26, offset); return true; } return false; } -static inline bool reloc_pc19(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_pc19(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset = target - code_ptr; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset = target - src_rx; + if (offset == sextract64(offset, 0, 19)) { - *code_ptr = deposit32(*code_ptr, 5, 19, offset); + *src_rw = deposit32(*src_rw, 5, 19, offset); return true; } return false; } -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 == 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 type, 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 == TCG_TYPE_I64) { - tcg_target_long disp = value - (intptr_t)s->code_ptr; + intptr_t src_rx = (intptr_t)tcg_splitwx_to_rx(s->code_ptr); + tcg_target_long disp = value - src_rx; if (disp == sextract64(disp, 0, 21)) { tcg_out_insn(s, 3406, ADR, rd, disp); return; } - disp = (value >> 12) - ((intptr_t)s->code_ptr >> 12); + disp = (value >> 12) - (src_rx >> 12); if (disp == 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, static void tcg_out_goto(TCGContext *s, const tcg_insn_unit *target) { - ptrdiff_t offset = target - s->code_ptr; + ptrdiff_t offset = tcg_pcrel_diff(s, target) >> 2; tcg_debug_assert(offset == sextract64(offset, 0, 26)); tcg_out_insn(s, 3206, B, offset); } -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 = target - s->code_ptr; + ptrdiff_t offset = tcg_pcrel_diff(s, target) >> 2; if (offset == sextract64(offset, 0, 26)) { tcg_out_insn(s, 3206, B, offset); } else { @@ -1329,9 +1334,9 @@ static inline void tcg_out_callr(TCGContext *s, TCGReg reg) tcg_out_insn(s, 3207, BLR, reg); } -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 = target - s->code_ptr; + ptrdiff_t offset = tcg_pcrel_diff(s, target) >> 2; if (offset == 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 = tcg_in32(s) >> 5; } else { - offset = l->u.value_ptr - s->code_ptr; + offset = tcg_pcrel_diff(s, l->u.value_ptr) >> 2; tcg_debug_assert(offset == sextract64(offset, 0, 19)); } @@ -1568,7 +1573,7 @@ static void * const qemu_st_helpers[16] = { [MO_BEQ] = helper_be_stq_mmu, }; -static inline void tcg_out_adr(TCGContext *s, TCGReg rd, void *target) +static inline void tcg_out_adr(TCGContext *s, TCGReg rd, const void *target) { ptrdiff_t offset = tcg_pcrel_diff(s, target); tcg_debug_assert(offset == sextract64(offset, 0, 21)); @@ -1581,7 +1586,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp opc = get_memop(oi); MemOp size = opc & MO_SIZE; - 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; } @@ -1606,7 +1611,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp opc = get_memop(oi); MemOp size = opc & MO_SIZE; - 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; } @@ -1631,7 +1636,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, label->type = ext; label->datalo_reg = data_reg; label->addrlo_reg = addr_reg; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr; } @@ -1849,7 +1855,7 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, #endif /* CONFIG_SOFTMMU */ } -static tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *tb_ret_addr; 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 = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_X0, 0); /* TB epilogue */ - tb_ret_addr = s->code_ptr; + tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr); /* Remove TCG locals stack space. */ tcg_out_insn(s, 3401, ADDI, TCG_TYPE_I64, TCG_REG_SP, TCG_REG_SP, From patchwork Tue Jan 5 17:19:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356889 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp308473ejs; Tue, 5 Jan 2021 09:33:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEwZ1aTsQay+j/0VTDCCQU9vwPk++0GZGJlkDkbrfmZdCCzRhXOIlLwuPIebZibFa7y2ME X-Received: by 2002:a5b:eca:: with SMTP id a10mr646483ybs.447.1609868027776; Tue, 05 Jan 2021 09:33:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868027; cv=none; d=google.com; s=arc-20160816; b=qU/te1BvAmL7GFwAo2119LR99tLelD6qODYcWnCrBn5qss4Ui8s9tHaBFfXXvxY18O X0wsBrkPUbBuecgh/lw8uvn7BvuSQUm2s56IUM84ufbexjHhzEiGrjV6wLCC4y74K5XJ Q11klUpJdoQwgXKo1oGs6q/CxRc2VOgkV+ok7rtHJfXG/I4j6pIQvQtGFiPT04T62N4e tmLST3tgb/RdZI1tj/HLgrA1tNHVWSiLHJMWF9AXIWG8p/SPQDXyMB3c5bcjiLjMfv1x Eyl3rx7PI9GsgBJZQfHBf3k+DxdBkiJ20rY+ZkXv3cSX4qgKfX5VvP7Gq81TX0bLxX1U l+eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=MOmUYS+2+okyDd2n7XwYqRe+eURAl58gvEsSNOVb+48=; b=gip7boDYxINNSeNSwzI8YopGtX3NnQDskA22t/dn5POpqZf26qL9e3lpBazPyiKo5a Y18MQeSEhynZT3d8W5o+uvpzMwKh2ZQZa1vDhYBouyyBvZfox5zETOxK57aaG5dDw8hS 8W/AXU7SY05EEQyOulxJu20moqSnEMN4TTu/wDb28vxBdORQwJX70UaPWgwjm90pICnk qBhNxWrF4OvUsZyk//Lvx8sCzjcPYxgGFZVV72T5o4hwEcC+3Q7BjgNsFnLuDsjIr5aF A53B1+uhcQSmI0V5YNfB8B8oNaPugWRv/zqoUr8SJZowgckGgFliGnatjv1huW9eNW2I G/5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lKQTEa2J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w11si485266ybs.204.2021.01.05.09.33.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:33:47 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lKQTEa2J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqDL-00022b-3l for patch@linaro.org; Tue, 05 Jan 2021 12:33:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0e-0002S2-Bc for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:40 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:35542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0c-0006dB-QY for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:40 -0500 Received: by mail-pl1-x631.google.com with SMTP id g3so71057plp.2 for ; Tue, 05 Jan 2021 09:20:38 -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=lKQTEa2J6twkaMH79bT86tXW3YD7i8Fg3sN0m6rTYxiY+TwTPaT1K5Et634nZJh+FZ AEodrGXkUK2oQ05+gyhtt/56mi2OVayKHEZCbZJj39WMwMwOFb0tZjmKSzoPIHPMSNhW 9Nc2DaudNHbKQWx0wAGYCqXVAhyQAQ/+45blxI3/ryyl45g3oEfS2X9yYi0ESf3hEwlQ kXG1aasXr0MY5I8iIZhOnceHurvDRLNkrTpPrx0kbvfVZaeixDmXSVna6Bu4WtSkTWlT qt8bv03FzDX2VRRI3XWTnJmuAW78HQmXmdFHK0PGa94Ho0nGDiijuesorLrLZjrytvZ/ ixsA== 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=TKUzRFFAoRKbxuVy/Zyd/R5kuYzZAwjIxlAp3DnHRkKW5RsiLByWtq3KYUkSdDQTs9 2MiypYRuYTCOKCi/Yf0qoydEgRHtaNyM5nET8VgWiRvgKZ/VwWQywVKwO/RgbrIBPAcH NAOr3gY/YYhAvZLh1RNyJvO+Zi5oASEqKRtRvmle5IrHuT6Xg+fGo39zeHEsPuQkZiI9 H2onpus0RRUkEYAP1UR44x7l3D1OUdG93RBcduo5VoL1kBZJPf9VoA6CQs9WHog6zAX6 OUkNz/+majgz7l0o6Kbt/OWpLlZbWfE0iKqbYADgcbNcBJtu7Xrr2Y38sc4blhNVymIc aDbg== X-Gm-Message-State: AOAM5311/rLKOttFNy+XAAWBCVxSbOjFdxM9cOkE7BwYsM0OieI0EfzK AM1wFep31bcv8TkY0JWoXi68WbODuwS2AQ== X-Received: by 2002:a17:90a:5b06:: with SMTP id o6mr154305pji.49.1609867237113; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 24/43] disas: Push const down through host disassembly Date: Tue, 5 Jan 2021 07:19:31 -1000 Message-Id: <20210105171950.415486-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Joelle van Dyne Reviewed-by: Philippe Mathieu-Daudé 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(-) -- 2.25.1 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); /* These are for buffer_read_memory. */ - bfd_byte *buffer; + const bfd_byte *buffer; bfd_vma buffer_vma; int buffer_length; @@ -462,7 +462,7 @@ int print_insn_rx(bfd_vma, disassemble_info *); #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) } /* 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 = (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) } /* 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; From patchwork Tue Jan 5 17:19:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356895 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp311736ejs; Tue, 5 Jan 2021 09:38:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrtytMB3JpPsaOctrEmH5k9vl58VqZEvcqtae6wE5aZ6CWQaAIgM3ypeI3AqSvwzeooX81 X-Received: by 2002:a25:9981:: with SMTP id p1mr682360ybo.440.1609868338345; Tue, 05 Jan 2021 09:38:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868338; cv=none; d=google.com; s=arc-20160816; b=xRyML2y891waUw5T81dq5+w81NuGLvlBzM+2iz0JMnB96HWZdTi667xH/NEFsQHNro 6Ak9sMylKM3ghQdKupOYmqU7pfjAnMqeB28FrO7G2jGKod9wesKyI9tOQGVsYovgAXsT hdHYo+oUF0JSX40i6D/8wqHV2ezK5HYdxuhALBwIUSxO3BWzGpIwr1921Fn6z0/+t9AJ NMtGHuSX6kL8/iMpPeTJMMLoP08lgs6pu/qWNmJjl9mBh/6ppwCEudM6NJpGipVqeSM3 Hey029toRle7gmP9M9H+xkjdnDBHerfO41Qlkb8Zx9+SVfh1FEGbb/JZVANI+XKSpA5H jQIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Qg8z1dlE9oS65UsWf3s5g5pB3pQWghIvDzukq2LmEmc=; b=WNf4AxHTXYQMD9zhTvnU18HLFB3A4AOqfZ6qhbkLb3n7F7PuP9caSfO6307psxEaHD uTAICVrl/mwTLNGp6o+zbLWCWXOGXXzwLp17hnmi3g/wQBfiMIIT5q1jAlQALzVIUWQk g402EGV31JAPgk74RmomhXK7Ik0reCAIDDYyMlQYD1/I4EAlp4AA/izSoDPRNhWFiON+ 82nKSxCWG7n40sE3FKTurMJ/ktJamHiXfQEV/Twm2S0+X01DiCYB6hB3IjxMGrV4jDCn K1hbvyKC2C/m5jhZiV+dglGEitzbAOysN5hq+M7YLsZ9+oSXyH1DWlhtCHgqDrpWRhgW YnBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LAiBx2Jr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v42si501458ybi.6.2021.01.05.09.38.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:38:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LAiBx2Jr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqIL-0001OJ-MI for patch@linaro.org; Tue, 05 Jan 2021 12:38:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0h-0002U7-80 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:43 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:38285) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0e-0006dQ-Bm for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:42 -0500 Received: by mail-pl1-x629.google.com with SMTP id 4so62881plk.5 for ; Tue, 05 Jan 2021 09:20: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=Qg8z1dlE9oS65UsWf3s5g5pB3pQWghIvDzukq2LmEmc=; b=LAiBx2Jr42CN6k8Nx+bFU6fW0L0TW3ZJtYx8JNsC0VXo4VEO4rMiipN440rLfoEyxq StXMhoNk4ORYfPD+vOA0Z3ip0i+3yGGcgazWcmnzkCg+bKY8HHShn8svKZNbRdnsQthb WyeiwltHEaPA6vxFmu5SLwNBuv5K7+sqlvA2KJly/lzCrxHqvqgFy7RGyMziV/+FcJ8c x+hQ17kmyhQ5cyiIszxnLjEL6DyGb3e5ZNRHlpcy5mMXzSAzBKZ6YJ7kbAnKneDXpinh G5VGYpqqDoQ6jHvB7FzLmosmg4B0YJraQSNV4bcXXlMRdRgo3pX3LwfBzSLkGJaSvSWR UgZg== 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=Qg8z1dlE9oS65UsWf3s5g5pB3pQWghIvDzukq2LmEmc=; b=E3pqXB7Aip72HqKfTQ80xJDBrdkNw6wEdtZWFstF+0YMqxztI9eMPXwcWAwLR9Z96l 792RZt8aaLq20larFqgsH45ap+PisJXZCBlUVi9CmBpVX0ZDCy7YQZYYlGQtf0mhkGoW sMsn8XACPcbj7FvPZVRPSeeH1MhFQv2XBGJQRauWOLDCmE/dFB3TSsoZabYKqBIPWE+0 +Xv+H6o8NcNC0EPoNK7ecuenJ+UPWqzf5vJalzzc8VBTLNibMGj3vtxU6nB/KcmiwRBG 2/NIeNmBAjpANA026vr2Q3s8A/YbjJjVDA9TrY8mwmOwj0XY+QGL1mfTBArhAE4xgL2N yuog== X-Gm-Message-State: AOAM533flbvSdhCYVQ5mVGJQLp4hbShCFgbqBPtxNa07tMqx9549TSxd kQuLY/l/zJbfqXHJtIzE5UHwJiYLZLjboA== X-Received: by 2002:a17:90a:7c44:: with SMTP id e4mr268000pjl.138.1609867238694; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 25/43] tcg/tci: Push const down through bytecode reading Date: Tue, 5 Jan 2021 07:19:32 -1000 Message-Id: <20210105171950.415486-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- tcg/tci.c | 60 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 26 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/tci.c b/tcg/tci.c index 262a2b39ce..388c1dbee8 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -163,34 +163,34 @@ static uint64_t tci_uint64(uint32_t high, uint32_t low) #endif /* 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 = *(tcg_target_ulong *)(*tb_ptr); + tcg_target_ulong value = *(const tcg_target_ulong *)(*tb_ptr); *tb_ptr += sizeof(value); return value; } /* 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 = *(uint32_t *)(*tb_ptr); + uint32_t value = *(const uint32_t *)(*tb_ptr); *tb_ptr += sizeof(value); return value; } /* 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 = *(int32_t *)(*tb_ptr); + int32_t value = *(const int32_t *)(*tb_ptr); *tb_ptr += sizeof(value); return value; } #if TCG_TARGET_REG_BITS == 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 = *(uint64_t *)(*tb_ptr); + uint64_t value = *(const uint64_t *)(*tb_ptr); *tb_ptr += sizeof(value); return value; } @@ -198,7 +198,7 @@ static uint64_t tci_read_i64(uint8_t **tb_ptr) /* 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 = tci_read_reg(regs, **tb_ptr); *tb_ptr += 1; @@ -206,7 +206,7 @@ tci_read_r(const tcg_target_ulong *regs, uint8_t **tb_ptr) } /* 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 **tb_ptr) { uint8_t value = tci_read_reg8(regs, **tb_ptr); *tb_ptr += 1; @@ -215,7 +215,7 @@ static uint8_t tci_read_r8(const tcg_target_ulong *regs, uint8_t **tb_ptr) #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 **tb_ptr) { int8_t value = tci_read_reg8s(regs, **tb_ptr); *tb_ptr += 1; @@ -224,7 +224,8 @@ static int8_t tci_read_r8s(const tcg_target_ulong *regs, uint8_t **tb_ptr) #endif /* Read indexed register (16 bit) from bytecode. */ -static uint16_t tci_read_r16(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint16_t tci_read_r16(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint16_t value = tci_read_reg16(regs, **tb_ptr); *tb_ptr += 1; @@ -233,7 +234,8 @@ static uint16_t tci_read_r16(const tcg_target_ulong *regs, uint8_t **tb_ptr) #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_ptr) +static int16_t tci_read_r16s(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { int16_t value = tci_read_reg16s(regs, **tb_ptr); *tb_ptr += 1; @@ -242,7 +244,8 @@ static int16_t tci_read_r16s(const tcg_target_ulong *regs, uint8_t **tb_ptr) #endif /* Read indexed register (32 bit) from bytecode. */ -static uint32_t tci_read_r32(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint32_t tci_read_r32(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint32_t value = tci_read_reg32(regs, **tb_ptr); *tb_ptr += 1; @@ -251,14 +254,16 @@ static uint32_t tci_read_r32(const tcg_target_ulong *regs, uint8_t **tb_ptr) #if TCG_TARGET_REG_BITS == 32 /* Read two indexed registers (2 * 32 bit) from bytecode. */ -static uint64_t tci_read_r64(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint64_t tci_read_r64(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint32_t low = tci_read_r32(regs, tb_ptr); return tci_uint64(tci_read_r32(regs, tb_ptr), low); } #elif TCG_TARGET_REG_BITS == 64 /* Read indexed register (32 bit signed) from bytecode. */ -static int32_t tci_read_r32s(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static int32_t tci_read_r32s(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { int32_t value = tci_read_reg32s(regs, **tb_ptr); *tb_ptr += 1; @@ -266,7 +271,8 @@ static int32_t tci_read_r32s(const tcg_target_ulong *regs, uint8_t **tb_ptr) } /* Read indexed register (64 bit) from bytecode. */ -static uint64_t tci_read_r64(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint64_t tci_read_r64(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint64_t value = tci_read_reg64(regs, **tb_ptr); *tb_ptr += 1; @@ -276,7 +282,7 @@ static uint64_t tci_read_r64(const tcg_target_ulong *regs, uint8_t **tb_ptr) /* 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 = tci_read_r(regs, tb_ptr); #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS @@ -287,7 +293,7 @@ tci_read_ulong(const tcg_target_ulong *regs, uint8_t **tb_ptr) /* 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 = **tb_ptr; @@ -301,7 +307,8 @@ tci_read_ri(const tcg_target_ulong *regs, uint8_t **tb_ptr) } /* Read indexed register or constant (32 bit) from bytecode. */ -static uint32_t tci_read_ri32(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint32_t tci_read_ri32(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint32_t value; TCGReg r = **tb_ptr; @@ -316,14 +323,16 @@ static uint32_t tci_read_ri32(const tcg_target_ulong *regs, uint8_t **tb_ptr) #if TCG_TARGET_REG_BITS == 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_ptr) +static uint64_t tci_read_ri64(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint32_t low = tci_read_ri32(regs, tb_ptr); return tci_uint64(tci_read_ri32(regs, tb_ptr), low); } #elif TCG_TARGET_REG_BITS == 64 /* Read indexed register or constant (64 bit) from bytecode. */ -static uint64_t tci_read_ri64(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint64_t tci_read_ri64(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint64_t value; TCGReg r = **tb_ptr; @@ -337,7 +346,7 @@ static uint64_t tci_read_ri64(const tcg_target_ulong *regs, uint8_t **tb_ptr) } #endif -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 = tci_read_i(tb_ptr); tci_assert(label != 0); @@ -477,8 +486,7 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) /* Interpret pseudo code in tb. */ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const void *v_tb_ptr) { - /* TODO: Propagate const through this file. */ - uint8_t *tb_ptr = (uint8_t *)v_tb_ptr; + const uint8_t *tb_ptr = v_tb_ptr; tcg_target_ulong regs[TCG_TARGET_NB_REGS]; long tcg_temps[CPU_TEMP_BUF_NLONGS]; uintptr_t sp_value = (uintptr_t)(tcg_temps + CPU_TEMP_BUF_NLONGS); @@ -492,7 +500,7 @@ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const void *v_tb_ptr) TCGOpcode opc = tb_ptr[0]; #if defined(CONFIG_DEBUG_TCG) && !defined(NDEBUG) uint8_t op_size = tb_ptr[1]; - uint8_t *old_code_ptr = tb_ptr; + const uint8_t *old_code_ptr = tb_ptr; #endif tcg_target_ulong t0; tcg_target_ulong t1; From patchwork Tue Jan 5 17:19:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356896 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp312066ejs; Tue, 5 Jan 2021 09:39:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpHcKhdcwHEFi9acV4RoFXwZZsodRGfAgjJaNe2Ay0S6DA1E1PuZZNA/BfTcPJXLzeK5Xz X-Received: by 2002:a25:d44:: with SMTP id 65mr757988ybn.260.1609868367207; Tue, 05 Jan 2021 09:39:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868367; cv=none; d=google.com; s=arc-20160816; b=gqxiaCiLBkr8Cn9fcNq8NTpl6OZcBg0kEZQcB8KZCqAM8m++Hh/i3ef/dJnLK/6fIN J6etgqZRda323z3dUS5NLuzQZzq7mju92OjM8dr56ZpLcuo85KWLi8HoCrJ6DaTbqXgs 328J73To5QdiTIJZxLNkXNe4rhwVxeCgafTCnPQX/PyAloIGpKoCu4jOSEnr7gFA1vXq xEbRBfE2dW7tnfMqTZ7Jj68LMozFskKBeApT6ex4Wru2lZ7TN1R4eaUo2lnz7EmiBbha /9nNweHp+y73oQX4rpgzkNLb/WLeLQBPBIL8BtbWbtynE/DGTRCF9rUju/28HgSCEZFH 4Dig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=1C9DAauAp7ESr+w+Jngt35D1tFX2Zjw12yc74O3Eyt0=; b=hht4qSaAQQlhsARpaB+pUAoQPVQbFFVPIpTaHV4y15XmoMCVsP0N9f3PSQ5NXEwvaa 7ILRQPaF4prT5fYQNP1/VUpw1LLVJiVL3r41shfUueFh48DL4Fs2rjG4X7d4kw8wYZZS sqhC3IT2S4Ij5OHcmWMFTqxFkLRv/7uFhsxR1STc3QOXQBzTq3sl3SFRz3U1XW+Hm8Vr m3y81qktFtJEJIZCbYLqRBcCVNTKLEsgfP8XS9+deoKXUo3bvufB09DEZlvMg0GTMOZ+ XrBpzqCD/HVbr7SfkKFwbBn+kyQGl90+dnr85+fpPjm2JGcflQJgSeNSb+NN5HAwdSM+ Vi3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="I/V1vPVL"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p71si471607ybg.346.2021.01.05.09.39.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:39:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="I/V1vPVL"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqIo-0001bg-Kg for patch@linaro.org; Tue, 05 Jan 2021 12:39:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0i-0002WS-TS for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:46 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:54340) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0g-0006db-Fr for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:43 -0500 Received: by mail-pj1-x102f.google.com with SMTP id f14so13056pju.4 for ; Tue, 05 Jan 2021 09:20: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=1C9DAauAp7ESr+w+Jngt35D1tFX2Zjw12yc74O3Eyt0=; b=I/V1vPVLQVR13pOrXFmUuyTiGilNIhZtksqtSRL7gNAHju7Jh9XllBuiZ7UlVUATrA D0pW9yukKSvm0O5s4pni4eFn9UE1eVBJGOFE98CVge+i4o+bVsXoMS4vGE06la7DXb8S EAJiuXMS1kY9sNAeGV1MyQ5RcHaAlM8YJcL3rNr7A20H9TmDQCeEu4uRpGoqKjE1Yk6N SVXlGcuNpyrTqdrKfKxGRFfzDh3iaPkBgXtXu4IYCbj41SrlrhqOfhs86nn2kX6yWE8k Jo+jXg/74CBTdXRwhLy+e1h0DcClFLciPmlujSPr6Ze8VVsFUCLsL0LeBjt0JbR69Ccv nEXA== 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=J7M3hTNSPtP4wg+8TV1gDvjxGbGuXpi9hElLy+Jf2x0J5jdSXIgq8Vht7iVrc19IIt AFl+REIYudJOcZ0SgMAJt0w+ZJ0NplP2CCg+O8NxiPnlBi16TEqXqp0dB4v5tcQOdQhm B0Wh1KiLY8oG2sEw+d0cRSz8hdo+PKR/NefkeHJpGysMBYnMWUcFJE2YruU9FNv5zjRi N3i18usBMpHXELQAt3fAcPpt+FlXswsoWzPriTgF8ZIs4YYASQSjf5Lk2BIJW5olE0nS RNyE3qUsDCO4w2E/FegodC7ABOkLZdVmGyCTA19uHDZEP4HyRXpMssuKSNRDecgH30UJ xGSw== X-Gm-Message-State: AOAM533dv88vZEFoGoKyO93pMKrFRHn5pMVEDFdJTV/GokWCcnFJIpyq Y8p3Nt7EaZ6LWCwZW+xQ3hCWP4QVi2rK+Q== X-Received: by 2002:a17:902:6a82:b029:da:fc41:bafe with SMTP id n2-20020a1709026a82b02900dafc41bafemr649510plk.20.1609867240301; Tue, 05 Jan 2021 09:20:40 -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 u12sm2010pfh.98.2021.01.05.09.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 26/43] tcg: Introduce tcg_tbrel_diff Date: Tue, 5 Jan 2021 07:19:33 -1000 Message-Id: <20210105171950.415486-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Joelle van Dyne Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.25.1 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)); } +/** + * 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 From patchwork Tue Jan 5 17:19:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356897 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp184925jai; Tue, 5 Jan 2021 09:41:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHzjx09HlKWORNA8CGqOnO9gXIEilBnzk4PloBMfw41oahHkJpUtOVS3AO+2Jip9DZpYO/ X-Received: by 2002:a25:2317:: with SMTP id j23mr866557ybj.388.1609868463607; Tue, 05 Jan 2021 09:41:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868463; cv=none; d=google.com; s=arc-20160816; b=N9oamG0EEMnwFe3A0QZtZJeKADuiF2veXpmB5adb8osuc5rv2nmkitDIiT/sX4jwcG jpsOcQXz6FclzOidmmKnAPMeeACkLh3qSwV6+Z5JEFAeAYvBznA+F5QBa1zqzwuABJkh ISnbp+PAxv+rNklu7sNr4/oZfM+zrtCRgdQWoMWRf9wwlAwGXBJxLtsVMHPGKJ5g6eab TvnrWxLWNyqrmg5FvtNsH/mDrhmiMFEnCkjysL5s+czmeeXS5jl3tBaKw4TWl4fKJ+k/ OFYBN4mRCkug9f0sAbrqFAWUx+2iYNxtTfGOX1t0Kxl0vaKFGCVfNNxJOQrrhqzJIPb8 F3Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=qay0jNTmpyZq4ULzg3vkr0em7pJVaOqPAuzaBx5paoU=; b=CnqJKcudK9kxDFnXq8AI0Cx4IM4S8s9yKPoPVos9+FAFRDk9x7p+4CeYLQFLm8YrjV F8rIPdsfnPq+4KC1xHNXMB3O5LmuC5HsB0qKA0G98y1r2CMKMSQEfLhO36PEpm0nt5Hn WrqmKzMEt5ZiM9fsevpgiJKIvGDV77odPGW0FzeuG9MmPWhwsBQn9/NOtlQcIGbwOF6S yTJiw26EetwlBq6tO7PXC32vCQ+qo04QlSKx2ZGynzVz7+gLngnv4B2L5ZABNxmBqsod GXl7OAHt7roq8t+urgwmwEmkVO17+CA8Yj9VVmefwejT3LoYX6rKPEYqV3ePx1IVBhBN vPyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sRhq5WoK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f200si441414yba.49.2021.01.05.09.41.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:41:03 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sRhq5WoK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqKM-0004dt-N8 for patch@linaro.org; Tue, 05 Jan 2021 12:41:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0j-0002X1-Gd for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:46 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:43482) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0h-0006di-1O for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:45 -0500 Received: by mail-pl1-x634.google.com with SMTP id x12so48109plr.10 for ; Tue, 05 Jan 2021 09:20:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=qay0jNTmpyZq4ULzg3vkr0em7pJVaOqPAuzaBx5paoU=; b=sRhq5WoKVWYc/JL9efgcD75LuvpzDgsMXSuNWlnu0L5piohTkIjikNyujwLqq8Cn2e RRG/JbK2b2+yor3WING977SXK0T1aWEg2YOp/uKjbOuwd4umicty3YAb5oYUxLPb5dRM 0qEiAWSzCQE010DZVMwDq/fSyV+/cuyTHNSeNk+84q2PQIQuIR7ec1/gpvtAAwhaUOZD VD0DzcQ6KGDswAq+S8LTy1CPi24pm9wBEc/1JA+549LwRhAQUjSYOxxGsOhFje5QqsLX OOa3JnD4NMaBzKFzwhlCHgN0DwW4Hk0wEZBCHTMnL/zmQuIUtUyNHaR2iCjZfmTemRle RlFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qay0jNTmpyZq4ULzg3vkr0em7pJVaOqPAuzaBx5paoU=; b=jS1pPYqmvgnWGW52Tu9Cp5ZwxghPSi/riHAUj6G7suYAlLD9GuvpvkB4utO9IdpA/S 7Yj/GIiDeSuIOnPTPfd9HS79uU1a/ny24gS3Ei4BZ6yAXGTP6y8pYCuD0bfqGljcNFBD Fv/F1Z57OAqwR3ua/4zF1fzGD9CU3uGk1qexMC/AbIkDmxuWygcn+SpGZ5RDqMWj+NTx YdKpLkb8RvueKnFD6j+0IeB9tG8xw52/9Cumt+/pzQG+sLj4WpQFFK5PL0Ti6YWnXWzZ 90Ld+Et7njyMV0B3eD/13YptLI/8HlGYuZy3/Y705FekQb5HdA4AVbU6Qc4BMRnkK5vv K96Q== X-Gm-Message-State: AOAM530PVF+l2eKgabKP5Y0SeH5svKiQxtumkGjqmWpJbKKR5emBJPAG 6u7G8ZOFd4VtqIJtacwdhbJk2/muwfKIMQ== X-Received: by 2002:a17:90a:1d07:: with SMTP id c7mr280050pjd.154.1609867241625; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 27/43] tcg/ppc: Use tcg_tbrel_diff Date: Tue, 5 Jan 2021 07:19:34 -1000 Message-Id: <20210105171950.415486-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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 type, TCGReg ret, } /* Load addresses within the TB with one insn. */ - tb_diff = arg - (intptr_t)s->code_gen_ptr; + tb_diff = tcg_tbrel_diff(s, (void *)arg); if (!in_prologue && USE_REG_TB && tb_diff == (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 type, 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 type, TCGReg ret, */ if (USE_REG_TB) { rel = R_PPC_ADDR16; - add = -(intptr_t)s->code_gen_ptr; + add = tcg_tbrel_diff(s, NULL); } else { rel = R_PPC_ADDR32; add = 0; From patchwork Tue Jan 5 17:19:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356920 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp201420jai; Tue, 5 Jan 2021 10:04:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1b9xs5Uss6/DWkk6SOxj4IjvLhOYkWGetrBzbDwzPgPjYbopzuYfCdv7iylBr+rZiaP1f X-Received: by 2002:a17:902:e9c5:b029:db:d1ae:46ba with SMTP id 5-20020a170902e9c5b02900dbd1ae46bamr432172plk.38.1609869868237; Tue, 05 Jan 2021 10:04:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609869868; cv=none; d=google.com; s=arc-20160816; b=bMY3Y8K7Qs6VHNrXjzvwilY4Wxo0KzS9TEZiVfzELFOgYQyNkk2CJ0WzYlOA6lH2fL UKGb6Ly/rjq65zaheHEEbl7E12/zZmxPeu3SCnb/epEN1N5ZXXHgrM84Uu4QFOe8SEx3 Z4JPbeGLf6CkeSUSB6H7q93dk+cAoa5I2DDe7JGdIz8tz63VqCCHsLujwXp8/dIN+DOe 0pvoIA5iBESoCo3kfmzXcLYSt02nAVN7pnFAgP3b1mNlhZep3eLjvv0mJWRoBG9eDD2m zooMqI8bIsw9avkoW6vEFDZbc6gt7J1vzQjfeRRe7wQTvNfG8hj+uW8VOiHExzWHux55 O5dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ASquR/6BxZoSVQzDtOnOXOHE8jLTrkcyVCDT0iJkP14=; b=rLP7OPiTIjRZOzxxgnzT3z3XCu49AIQt/cloEl94BCW4IbPPJC+NJGMk7ncGkHrtFY sRYPMgBtFvlijKmzgSvoUbJT37t5KX0BFMXeKiw+4mcyjBMmThi8svu6ih4YDn2DIjxj bGFDHwooZUy0b96cBs6zNMlrtNg8EQUG5NjUa851MdAwjwzMqp4PZFWbA24WSvG9eSTs b2cAMkEZGUVzDsKVmB4cG2wFuL4lmX5Z7Mk2Vx7iSowvDv2c9SYbasetnCLQeyLH1sgD B55/mjSwKjgI4wdbVVxV0OPSgON3FOykQAISk5KBYj20uhkHmqmYESW2shX34MUhZ27a cAgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GCObIqW7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x23si521747pge.114.2021.01.05.10.04.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 10:04:28 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GCObIqW7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqh0-00064H-7A for patch@linaro.org; Tue, 05 Jan 2021 13:04:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0k-0002Ye-UN for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:47 -0500 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:41496) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0i-0006e0-NZ for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:46 -0500 Received: by mail-pf1-x42f.google.com with SMTP id t8so114645pfg.8 for ; Tue, 05 Jan 2021 09:20:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ASquR/6BxZoSVQzDtOnOXOHE8jLTrkcyVCDT0iJkP14=; b=GCObIqW7cA1P+k87n7bLESf18Szye8tDkfwF8xF5qsw8hcZCVI/FwOCbvBTEm6EIxM bcr35oTasqCFghSDbvtepThgk65hTTCxxTpdLRdT0bl15e2WYx9Sm9PVVnawl1vugMK5 OURa1Td3uluRNYtrHlHjSg0Yr7YoDPPDNhpt/dVHWc1mpa1Tl/hT8H3rTg6DTd3OGlSB qYeTeC6ccgvPx9z062jAFM8WH9cHBFc1nqUJLLFWjNHXeGeaPYCfEqkPc7Wi+cVmHjye bAMKKvRcqcs/zSQ77ABn9zAfYhw+DRQpmXX24f9mVME7cXXrTA8iMF6YQJ8erAbqxYwb grnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ASquR/6BxZoSVQzDtOnOXOHE8jLTrkcyVCDT0iJkP14=; b=lsDygsOrCu8JitRikhN/Wv9a3llbd2TVoqsKRaf5SdWLOvfEuc8V+6qavUVJi0ncSG 0WPcz/NVqA65gRPz6msI4/FKL45rMqMo6z1lxIMGp90dbFRQ7ZzPI8R+IkyQbxJZWA8R JWPgqk6FtwGfEnmYi7KqazaFcifpi/X27SBbiexgN84O4Gxqj33zcwWiPqGlr2Jo7VV/ sLJUoVnmvc+9tqRXCV75otdkfbKW/XY5vK2kpZ6yh4deUdb7fEP+C8GqZQvVnI9/uDbs 4o57rDlswuI0vF9qA7w0rxcLuMS1IBR2LyNqdDj7aMkNb1bI9CXN6rH40g5BO1YkfkfE /mgg== X-Gm-Message-State: AOAM531dSjEzCv+NDi2q2wEsqxqDzSMJmrnVo+MBTyyWTTOgu9sLIAeg L6Cpy/RUm7DmjYlzTvYbfk3DF4XkcSdT8Q== X-Received: by 2002:a63:d446:: with SMTP id i6mr352490pgj.446.1609867242980; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 28/43] tcg/ppc: Use tcg_out_mem_long to reset TCG_REG_TB Date: Tue, 5 Jan 2021 07:19:35 -1000 Message-Id: <20210105171950.415486-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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 = -tcg_current_code_size(s); - assert(c == (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: From patchwork Tue Jan 5 17:19:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356898 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp185275jai; Tue, 5 Jan 2021 09:41:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9GK0T80V3JgmyuQ6yT2kBYUk8gx5surgxghzt9FwI2IzRV4XlA8ocvNpdgbftq+TzSdSx X-Received: by 2002:a25:8743:: with SMTP id e3mr778253ybn.362.1609868501741; Tue, 05 Jan 2021 09:41:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868501; cv=none; d=google.com; s=arc-20160816; b=WPSj3mljj4cEAqD+QSvvaxYe1T4yRngkW94Jz1sYekaLd36TmPTP3N2lAUFYD8FiSa Pjtl+SzEGoOyT0ZRkRQuyw4oP+UHCUG02Edt4Zu2LhlMiSfAungVGtL2Y3QYVYVHzK/A iE2wGt+oAhLnNjT+W2hdATp1olzKtmEFaeXyib6urXfEx5tj+dovYBuVUr54nsgHIFq7 6BR89jsy8igMcH8C49QvASviC1qk40agMQ84K5aT9PzYRVQo4qkA+7QHAohkh0w3Pfpa C2Lsvak5UE26lQy62qyR6xk3U9aZPjJ4EWrX321mmXKi93FEd+tbbv9Uv6QPLaiggUes t8kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=k1dwR6fbig20YHFioF/qNG9UvMMCDYRmx+wuQtP3btg=; b=WLWDT7PciWt8hpnrmp0LqDHQPCCTWBi1smkfW9EM/pRTmjWULtgqLgz75rSKF+U1Vn 2FQLKt4eRF9M6YlIYkfuLovKgw5WuvyphDMOY9r44hvskHdoNPcGvld0n4S+29D1q/Xg AQKk321JVnWIW9mh15AsVI5k2DAks7mZQxQr6g6324uSfJXRaS4zrZKeGM210G8EFO6V WHYv9eSTgLeOXsLlVI+TBFJUnaS02mqPnvEmvJxsiox2E/RUs04znQHrYV9KgJ/BmSVk HBKRoZ1ROQwfoUUfXgyVw9DMy/kpWnVbaXNsBD/id/ridL/9KlO9b/vhsqiVa7YqrlVL q2Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NlaIogj5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h6si451195ybc.407.2021.01.05.09.41.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:41:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NlaIogj5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqKz-0005KQ-74 for patch@linaro.org; Tue, 05 Jan 2021 12:41:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0m-0002aX-FW for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:50 -0500 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:40528) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0k-0006eP-Kt for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:48 -0500 Received: by mail-pf1-x42c.google.com with SMTP id x126so118148pfc.7 for ; Tue, 05 Jan 2021 09:20:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=k1dwR6fbig20YHFioF/qNG9UvMMCDYRmx+wuQtP3btg=; b=NlaIogj55les8giV/MdDPc/zRvuTaMp9zkEAXrfqeiy6Lky+GGkDj5XZr+3Ti7f/m8 xq31gB3NMp4/AS0btbe7UjD9Q1AVGME1bKnDREDvCNIaYTBamE0Hbi1Qb97QyhhNK0ls ZNMfuqBvegsqkUzCEJGsWnItL4kAVzmkzOUJR1GdUbI0nZ4VXV40CkZMb0Y1NjPIR03F cOfTJrWrLlUsY7UXwx13HPSCjorcFPV+KoTYrRyIrPfRQKwxWGl4rJZpRU/m4YqfMZe+ fsDO7HEddLB5mTUQaVz/V/mVj4EAh701uHiHE6hsdp6G71FfGmkfBqWdiasIsa4NYHTb hLNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k1dwR6fbig20YHFioF/qNG9UvMMCDYRmx+wuQtP3btg=; b=kYYZJGruiA80tu0mhThgI62BXS+wCMshKSW1y3Nqmhv5tzfQ1pL3auPuMOScth6yP7 XnGwbBI3ZdiXB8dYETr6BswGHaW6fcUNjscOlVqpHvwxOIz4vze1L1Rk1ZeOEShcFM/A N7ZvMB50LQeXQGyzaKA579o//kWOkEfCHEU8sxk/NMy8qzKk1jHl/LsOU5jLtapx4i9Q CKT4T6Y5BP8jZN2G4OKFsE1n8HZOIWo7occ+RoVUOU5Qs1la4vormYJ9TJ6pDzhPXsDY h+McVMLgKkQaNvcZgTV0YTfj7LScYmn0s7rfzGjalC78XGtEneP59uecz6n14WA9x5tF VKBg== X-Gm-Message-State: AOAM532WUDInG8wPtfR2EhGgG2fuNa1yARSx1ueWBmLCWyzS4TXqhBtO UYVEebQVtSO7JyZJcEzvQw4u95YUk+mMDw== X-Received: by 2002:a65:488d:: with SMTP id n13mr319973pgs.315.1609867244669; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 29/43] tcg/ppc: Support split-wx code generation Date: Tue, 5 Jan 2021 07:19:36 -1000 Message-Id: <20210105171950.415486-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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, uintptr_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 #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 -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 == sextract64(target, 0, 26); } -static uint32_t reloc_pc24_val(tcg_insn_unit *pc, const tcg_insn_unit *target) +static uint32_t reloc_pc24_val(const tcg_insn_unit *pc, + const tcg_insn_unit *target) { ptrdiff_t disp = tcg_ptr_byte_diff(target, pc); tcg_debug_assert(in_range_b(disp)); return disp & 0x3fffffc; } -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 = tcg_ptr_byte_diff(target, pc); + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t disp = tcg_ptr_byte_diff(target, src_rx); + if (in_range_b(disp)) { - *pc = (*pc & ~0x3fffffc) | (disp & 0x3fffffc); + *src_rw = (*src_rw & ~0x3fffffc) | (disp & 0x3fffffc); return true; } return false; } -static uint16_t reloc_pc14_val(tcg_insn_unit *pc, const tcg_insn_unit *target) +static uint16_t reloc_pc14_val(const tcg_insn_unit *pc, + const tcg_insn_unit *target) { ptrdiff_t disp = tcg_ptr_byte_diff(target, pc); tcg_debug_assert(disp == (int16_t) disp); return disp & 0xfffc; } -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 = tcg_ptr_byte_diff(target, pc); + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t disp = tcg_ptr_byte_diff(target, src_rx); + if (disp == (int16_t) disp) { - *pc = (*pc & ~0xfffc) | (disp & 0xfffc); + *src_rw = (*src_rw & ~0xfffc) | (disp & 0xfffc); return true; } return false; @@ -673,12 +677,12 @@ static const uint32_t tcg_to_isel[] = { 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; value += addend; - target = (tcg_insn_unit *)value; + target = (const tcg_insn_unit *)value; switch (type) { case R_PPC_REL14: @@ -1544,7 +1548,7 @@ static void tcg_out_setcond(TCGContext *s, TCGType type, TCGCond cond, static void tcg_out_bc(TCGContext *s, int bc, TCGLabel *l) { if (l->has_value) { - bc |= reloc_pc14_val(s->code_ptr, l->u.value_ptr); + bc |= 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 is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi_reg; label->addrlo_reg = addrlo_reg; label->addrhi_reg = addrhi_reg; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = lptr; } @@ -2007,7 +2012,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp opc = get_memop(oi); TCGReg hi, lo, arg = TCG_REG_R3; - 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; } @@ -2055,7 +2060,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp s_bits = opc & MO_SIZE; TCGReg hi, lo, arg = TCG_REG_R3; - 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; } @@ -2306,10 +2311,10 @@ static void tcg_target_qemu_prologue(TCGContext *s) int i; #ifdef _CALL_AIX - void **desc = (void **)s->code_ptr; - desc[0] = desc + 2; /* entry point */ - desc[1] = 0; /* environment pointer */ - s->code_ptr = (void *)(desc + 2); /* skip over descriptor */ + const void **desc = (const void **)s->code_ptr; + desc[0] = tcg_splitwx_to_rx(desc + 2); /* entry point */ + desc[1] = 0; /* environment pointer */ + s->code_ptr = (void *)(desc + 2); /* skip over descriptor */ #endif 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); /* Epilogue */ - tcg_code_gen_epilogue = tb_ret_addr = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_REG_R1, FRAME_SIZE+LR_OFFSET); for (i = 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 = B; if (l->has_value) { - insn |= reloc_pc24_val(s->code_ptr, l->u.value_ptr); + insn |= 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); } From patchwork Tue Jan 5 17:19:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356901 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp186402jai; Tue, 5 Jan 2021 09:43:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJ1FAFpv5A8K+BbQLS60Jw4vAmcbKdIk8X/u63+rU4CBreaI/SDLwLEPE4H4eFqU99fA4m X-Received: by 2002:a25:5f07:: with SMTP id t7mr699435ybb.395.1609868611345; Tue, 05 Jan 2021 09:43:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868611; cv=none; d=google.com; s=arc-20160816; b=viTC3B15yfLwgxAtIRBOsQAao37yYYBKEtJYlfsmS2X4BLT0O29u2UnBp3nx4rF5+E cR0bUTD0vL9mJRb3owxmo/GcMvxl0WIm43axwCvIQo2oKpanjf0udAW9VfwzCOD94mHC H+qFqJclgn+FGW6Xp9n+77jAaJLJPUUb0zMuwg1JKSS3l2AHFpIrnz78JqUUQqk5gWSf CEPZTQZVLyPGLdY6S/J9eKulByOylL6PUEbu/S/wBrzWP1/4EQmALg0lhQTcsiobSQbM SdXgU1DQ+t4y3Xgz+fuM24cCIzDXJgWkrMkc0pD5aPMDynE4yvKDAOGxmstg7Iqdmeuc gsag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mZ7Cv5t9pDHcLwkTAHUkGoZLzbW+EIVJw5j5xRLRZ3w=; b=mxdwx3vLVOlOuGwMwNCpOzucFhzEXgGeihQ3rflgUr4ZWQNri94QbBrAHP0F0ZYMaq AhTxEP1H7HXij4icFos+qwA3kyZ1b+FAowBVEq83GKbfNdubSHox5ky0A8Xihve6uuZr gqjontf+41OH2CfkT+MLk12YOAO95wTVBTkxHMgrtNGqLcJNsDbxJYg/odFyZd8TgsPY aWH/Z6jWuRcwI2ZRibc2P9BKYfiEJLwNTXXGZXM6BmDMxqCX66uX79hluv6kqP8yoQ93 jkN+1CFp5zDCIGwc1hPnMiucJTtlr0DF6NwLSn6OxI53HOamBoA2UJQGiWp0ltTCgoLT ZdpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sN9PEKjm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m17si450035ybt.241.2021.01.05.09.43.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:43:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sN9PEKjm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqMk-0008Ch-Q6 for patch@linaro.org; Tue, 05 Jan 2021 12:43:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0o-0002c9-OA for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:50 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:42524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0l-0006ed-NE for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:50 -0500 Received: by mail-pl1-x633.google.com with SMTP id s15so50524plr.9 for ; Tue, 05 Jan 2021 09:20:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=mZ7Cv5t9pDHcLwkTAHUkGoZLzbW+EIVJw5j5xRLRZ3w=; b=sN9PEKjm7sfFYqdkyieBz4AyoczuulsT0D3HWmBnS3uPNQzMD8T9+RlPtEX//OgrZy /x2iRFRzAa/x5fq2MXHBf+b8YtmpyA6JscZImkgz1WClwJ5ycnT4A9nc/kNEiSwaZZem eDFCNF2iRWQHoLjPnA7HFk5v7FJzdfYo0lMRLebT3SoyB5o7WdKVTsf0jnClckypgcEH jj8lrp/5gEQq8UcyTWfFr1idRqQOgbFH78Uu4D42f+K3tAgrLFsx4x2yDh+7b3ixp3pK qWCVB3bhYyAX923AKRZZ77X//pH1gQKGDduybw7Eor9mCazksZjzxQujulPGBJU3qFZM aabw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mZ7Cv5t9pDHcLwkTAHUkGoZLzbW+EIVJw5j5xRLRZ3w=; b=LHACkgq+gF6W2W+YjmhiNhqOH7aawIga8RolF4r74XfgPdrztOhBVfOGeFHFrouWvn 6Q3v9PtyEbr4imglLlJoqa8g5f1maXs82tzdIWUKTDOgwo1kRXkPYJ/cdSjcSw6m1zS1 21/d0o5RmsbYluJEETOq/z9j/EjRtS6yQslJ0YcBUJSielYWGCRpiCAOf09FbijWll+1 DswDusPm0yEeZlcYuSWoWGntXAJ7FUtjeU115/lMYTBZhkg7tJ88QWEhQPEK0QSC/81r apPUHVYd1HkOVG+ci72ZtFwVBumqpHWWf6jdcvfEbAafl+Qia4cihHZCYO1blxMKbO6N TcaQ== X-Gm-Message-State: AOAM531jv7BM4HsbEG6rWUkmhzbTFVTcARDlvW5eXeKrUjx/VJr5qWdK 9apXzcxMHHkzLt4oKO80lH/Cj+AU1qg7Pw== X-Received: by 2002:a17:90a:ce0c:: with SMTP id f12mr248495pju.89.1609867246187; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 30/43] tcg/sparc: Use tcg_tbrel_diff Date: Tue, 5 Jan 2021 07:19:37 -1000 Message-Id: <20210105171950.415486-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) -- 2.25.1 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 type, TCGReg ret, /* A 13-bit constant relative to the TB. */ if (!in_prologue && USE_REG_TB) { - test = arg - (uintptr_t)s->code_gen_ptr; + test = 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; } -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 = arg - (uintptr_t)s->code_gen_ptr; + intptr_t diff = 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); } 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 = a0 - (uintptr_t)s->code_gen_ptr; + intptr_t tb_diff = 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); } From patchwork Tue Jan 5 17:19:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356902 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp186609jai; Tue, 5 Jan 2021 09:43:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJyfjef3R+edZzp76+CUkU93QNr+GaeoO5ifb66CEsAti6b9yoYZbEuXwoz8+5cKWbuskf53 X-Received: by 2002:a25:aa91:: with SMTP id t17mr705585ybi.394.1609868628020; Tue, 05 Jan 2021 09:43:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868628; cv=none; d=google.com; s=arc-20160816; b=C3AxRmi28WPDVZqozN898pOnNAoWinqncr6yltB5gUzVqxHR30x/dvwDZbv6GtIT7H VnmehI8Yqu+OqQFyvSDHRiAyUp720p9lTWXDb3zPZTMwVyZm/aqRwUt1U1urhFgaXmKy 1dsKhilDyAkX96v8bBCNk49R4GNQlgj/gym9ZWJaK3hMF8IJpVTIukmpRMeqSD3rM6Ib 1lwlbnwe8PMZDzNf9rWdeie0M3hYATwecPw0jaoKDP4R/xwtURWnC/61iAQv/VjlUZtd xUUJFXktgP4wibaMVWQsa8Y+9IQBHkUtM74zpF26BUgAxs7QxM0y5Tzv6EcirL8KMjqv DGHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=CTx1bMRPoVCbR9ZXrYADDGmrgIOCMd4LcuRPi7m2xvc=; b=OFnncVomrTi84sC4HGrJ/QBCwiJXZ1X5k1QHqDxhsz0dKXdAZciOCIEjA3G9cODZ+q El82IMDSACqC12F7bd+b7Ey4ALvC7LMrfqdYPuOJ7AzV6XInRLHByTVVIRZA4GzIgTa0 Tkc4mYMUPdRXsnaCs1vQFBFLUuYskLr6mbMP+y1f6aWoWWIs4jM9OjmR2EOo1xu2DW5k PLCaMtzHR9e72OSJzm87RCANABWNTmu9pxsj6ZHPAmFLuoUDU+B2URWHzgNnh/FlfPV8 92xqZRQFsyWP941YPoxxJzhGBJxU7l28QF4e+uzNYba6wybbTpt7kbGCPLTYd+Xrr2Jh 15Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yNttRrxw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i193si466746yba.471.2021.01.05.09.43.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:43:48 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yNttRrxw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqN1-0008Q1-1y for patch@linaro.org; Tue, 05 Jan 2021 12:43:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0q-0002hO-Dp for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:52 -0500 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:36030) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0o-0006eu-GC for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:52 -0500 Received: by mail-pg1-x52e.google.com with SMTP id c132so291134pga.3 for ; Tue, 05 Jan 2021 09:20:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=CTx1bMRPoVCbR9ZXrYADDGmrgIOCMd4LcuRPi7m2xvc=; b=yNttRrxwhILtIBkfbzbBANM51FzLoQJoaKzBvshw1HPg+Q79WiPUE8wn9iPTyND17t 81StWsta2WLun07+69utmeYDu9eGVuqOO6lQ/ul7GC491+91RLAHePGKy8kR1PhREAuS hMpjs4i+IttbuLTvXkjyI7a+GquzOxSrRItMOqrzDjRn7OYN7bBnrB07nRLU3GKZu5ys sM0DyBtKZTc3458die2HFuPqbBtx03CCbiNoBRoHP+MCSMezxALtkv+pSKoulrbi8PZu kziAWbAjAzSorf70J+ZmUfuHbgh8m/JYHjj9eEUOYqjvG3hJsldQPrgel7YHGNohbXAC aHiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CTx1bMRPoVCbR9ZXrYADDGmrgIOCMd4LcuRPi7m2xvc=; b=hDRraIwQGzS5uIfvVvWR4YWSmUwqfG6r8am3Nionjc1RGuRVuVdBYob5O29eCNnGax aUFnTBWlk04sfnoNWvfJuYEyx5GWFJ3e/4md2GeE97LlSrHtth6pX4p6EmELliK5DbLF Rm/96H4tocO7+RP9gg9iecB7P8GY1kPjZWVxNetm1u9WJgw5OvhK4DbhMeT/qlgNg021 pp18QYAzLuKjYSzL79/SbzQttmSu8HIYlYtzVbpCMV+K8MKRhC5pLtWjaaGNcMZ9MKhX 4kWkwxFeVuIsy6SHHseCnfJ1rehky7PzoTRDAauP994JGQAxvlTJTcYb9c/TJ25Xzb3I Cx5g== X-Gm-Message-State: AOAM532jBXz5vAlEJ1L2xVviCShKG/VfwbtaoEAqntYcTSlEQNKLzmEF 3/Jb41/1Z+Fd59NuO+qEEBkeC5AxCJm5rQ== X-Received: by 2002:a63:fb54:: with SMTP id w20mr316064pgj.419.1609867247700; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 31/43] tcg/sparc: Support split-wx code generation Date: Tue, 5 Jan 2021 07:19:38 -1000 Message-Id: <20210105171950.415486-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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); #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 #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 -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 = *code_ptr; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + uint32_t insn = *src_rw; intptr_t pcrel; value += addend; - pcrel = tcg_ptr_byte_diff((tcg_insn_unit *)value, code_ptr); + pcrel = tcg_ptr_byte_diff((tcg_insn_unit *)value, src_rx); switch (type) { case R_SPARC_WDISP16: @@ -315,7 +316,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, g_assert_not_reached(); } - *code_ptr = insn; + *src_rw = insn; return true; } @@ -868,8 +869,8 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) } #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]; 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] = s->code_ptr; + qemu_ld_trampoline[i] = tcg_splitwx_to_rx(s->code_ptr); if (SPARC64 || TARGET_LONG_BITS == 32) { ra = 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] = s->code_ptr; + qemu_st_trampoline[i] = tcg_splitwx_to_rx(s->code_ptr); 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); /* Epilogue for goto_ptr. */ - tcg_code_gen_epilogue = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (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 data, TCGReg addr, #ifdef CONFIG_SOFTMMU unsigned memi = get_mmuidx(oi); TCGReg addrz, param; - tcg_insn_unit *func; + const tcg_insn_unit *func; tcg_insn_unit *label_ptr; addrz = tcg_out_tlb_load(s, addr, memi, memop, @@ -1245,7 +1247,7 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg data, TCGReg addr, #ifdef CONFIG_SOFTMMU unsigned memi = get_mmuidx(oi); TCGReg addrz, param; - tcg_insn_unit *func; + const tcg_insn_unit *func; tcg_insn_unit *label_ptr; addrz = tcg_out_tlb_load(s, addr, memi, memop, From patchwork Tue Jan 5 17:19:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356904 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp187593jai; Tue, 5 Jan 2021 09:45:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOUgwR4vQSsPZSe1wPaW/lMFFd2/sC14NIZSDKxXPJ4OYsyhxBaPrIvNUzQrMdAcOEZsB8 X-Received: by 2002:a25:900d:: with SMTP id s13mr799662ybl.496.1609868708554; Tue, 05 Jan 2021 09:45:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868708; cv=none; d=google.com; s=arc-20160816; b=iAKP55+copw67SvST4wVtn20bmMcSV9Vo1CFeChEuJIXEMd88JEcVQiRylshf7GbL8 I/JmGI67tMCXclLrAZwcZw1KmFcnhEmnOFtGGMlVspQOpgVszUEmswKqqDc/v+bsF3IB h0XHFq4MOlmSsZrEiIQa88foopQRXWJVvKWZsMcIeptuVEOc08G/vBPX8XAtzH6QPADD e1I/hP/ryjSylGwuOCUZoXv29OA1CjXq0JnzjX1xOWVqUXUoLC9klBpYer7wZtsINFN1 1rclAcXXqARogVEHS/BLTu+/0mArZxR4r3ToRMW2j5FSjLJ0tJKGszBZNUUFX00DXr42 A4wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=wkypnopb5BzPYlv4jtMpd96OEpFhEMM9GKjZQ7ld/TU=; b=J7xi1wA0qCXWlH8IBWCEIZAOtctURO9r7LM0nwCEwAx/9XuuWONibSY5W147wysmU3 NjajhYoB4qG8XmnuFmeUEjHdoO75966jWvL52My3TzIqqII2EkSXDYCynriHbmXJ+jqQ gfFrNzejhANAiIbT/DQsvMqNhTwE9B4x5TdBPwQHMtQZ6WEZD5kCUNJMAaussLPLu90f BolyNikbi3EOvV6RvrFYFVqIwxnSxjXWdhf8z29gcqm2SYOl2Enlvt7LwvWOiSopQXrs 7Z4z5gTV6WnAcg1OERUXXmDKwZ3Kgbs9I7Kh5N8goVbhPBBJN14rPPTvqwupg66fgDWO 49ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MtbGtIOq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k13si570417ybt.256.2021.01.05.09.45.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:45:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MtbGtIOq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqOJ-00029N-VU for patch@linaro.org; Tue, 05 Jan 2021 12:45:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0q-0002iG-NA for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:52 -0500 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:39839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0o-0006gM-NJ for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:52 -0500 Received: by mail-pf1-x42b.google.com with SMTP id m6so121723pfm.6 for ; Tue, 05 Jan 2021 09:20:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=wkypnopb5BzPYlv4jtMpd96OEpFhEMM9GKjZQ7ld/TU=; b=MtbGtIOqY5SBF9O0XH31ELRHHusQe1Sriz+uaxxmmLW/TG3QUPk2MRSnf5EwkTGXCQ SXbaYflXUe4k4PF2nF4qkOfXZVUZgSzeQ29SVuxJrIUSgzk02Q4Qkkgs8gsNru/vOtm4 dBH/BUNU76rTSzRWsl4yMA1wHQB0LlfgLW+BtXEN2+NT0+TFH1D4CPpYq4RPWqhxzZdx KqX+xFY3WX5OoyTfinRSQFIa4nvBgD2NSx57YTlAsLNZ2lwFQU55l85X43/wrZbLC/Jm 4epatupdLA39/yb+REcgZrGgmmh4V2Tyse3oaYpiDzZiJMGsu9dZWuOTOd2EZzWQCmwH g3Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wkypnopb5BzPYlv4jtMpd96OEpFhEMM9GKjZQ7ld/TU=; b=ry2vH0tGQrN6gS85Xb+kZl9NKR9O2fUc1PQ/fEQUtuTlk/RZUE9uHvpJxa3CXtoQYT 0W1r458B7F+oXqC97Auvqn2AFSIBaJci7CNHs1qkg3fIBVX/zjYBObKV7CvK/Vgii9Zb j/x2xFjq3VccYjv+3VCGnD6OHFbrkmMskbEKGc80E2CJPWaO3LUcHm25kHTq2KfuCmmj nX03o8mBjELU9juslVtjDkILirOTiSZ3qtweFX7E6tAsOSlYY6PT1i4PK1SSCDrCdKvB TIDs2ZstFX9EgF2wOIvSNyCp4annNtr1gZEGiMb80AXPz26bPiTUynfGDiW7URjV1T7I egiw== X-Gm-Message-State: AOAM530fTjq/2G8W1sdLv6+IL/3S+yDk2IgeSDrPAL5NSg3B+OVQq3Gw o2potBfjCqt9G7H7zOpBYmJG6T2kGjqjMg== X-Received: by 2002:a05:6a00:230d:b029:18b:9cb:dead with SMTP id h13-20020a056a00230db029018b09cbdeadmr198335pfh.24.1609867249118; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 32/43] tcg/s390: Use tcg_tbrel_diff Date: Tue, 5 Jan 2021 07:19:39 -1000 Message-Id: <20210105171950.415486-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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 type, TCGReg ret, return; } } else if (USE_REG_TB && !in_prologue) { - ptrdiff_t off = sval - (uintptr_t)s->code_gen_ptr; + ptrdiff_t off = tcg_tbrel_diff(s, (void *)sval); if (off == 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 type, 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 = 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 = abs - (void *)s->code_gen_ptr; + ptrdiff_t disp = tcg_tbrel_diff(s, abs); if (disp == 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, TCGReg 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, TCGReg 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, TCGReg 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, TCGCond c, TCGReg r1, op = (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 = (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 { From patchwork Tue Jan 5 17:19:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356907 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp188568jai; Tue, 5 Jan 2021 09:46:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeJC1R8zeve5/qPO4ma4Mgwq5xKlipH67Nq+4aSzh8UYoYL4hVHdmuOS20OtvdHjhpkBcO X-Received: by 2002:a25:d3c4:: with SMTP id e187mr758351ybf.259.1609868792704; Tue, 05 Jan 2021 09:46:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868792; cv=none; d=google.com; s=arc-20160816; b=nbX4lIXFJAUpUohQjEieGqZJSwIpdLrP61NSDzcCKcMFlK/YMRATXqCLPY56XWLrZ7 rnwZ2knHw+7DRGcEk3Urga/Yyk7D4dqK8PYeR//7tNYvpnjsAO5xAf57Wetf7g90PNPz Febim7VEVcHrDZzYGNFIKaxc01+sjZuQLSo2kJui2DKQ6b676wOkw3XFnWvQh8kotjXi 8Zp0IosD9rnaqChHKl1QQf6zIvNg8mTGSBiKohqQ+qCHwMu8jbnPDWGz+vg7nCc+v1zk EGNm+NGR2JZZbCgnxDpr3Uf3zHtiKndMwuL1joUby6XzdEritprNcV7V4aVLMQfeGopv LAGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=XwAGDhPsMBTlCDYICLuTcDF1WAEZQ1i2iAFKQ493O/8=; b=RnRuZc1NfEl51Zs07qVCW9FgLZqvez4YksAxvsxKBx+ipqOj7FBC79fbpux/OoOy4k BWwW7fwdjN/bAb2zCbbgkF6rfG94zMp1DZjJUsuiVhdLA+9DLKF54+cKPKeae1Wy/D9h kXIr1H4ZRYkrxv4PGR1VRlEdBnwT7Ael9tPycek3Ngear3Xcaph+PRAF//KAmzXeu4cC 1C6ELw6AcRKVYYflVu9CruvBF+48NLm7QFMIZ9AVGeMvtaUle7qq99WyhGdzU51BvcwZ AlURocf9MdZF5arROcDNg7mwG/63hmKEZwjB+hHPZXkoTU/rp9I7t4J7XE3ovbhTQBnI FzNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vZvcu97C; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t2si563298ybl.203.2021.01.05.09.46.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:46:32 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vZvcu97C; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqPg-0003Xp-5b for patch@linaro.org; Tue, 05 Jan 2021 12:46:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0s-0002o5-Ie for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:54 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:36210) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0q-0006hh-5J for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:54 -0500 Received: by mail-pl1-x634.google.com with SMTP id j1so68609pld.3 for ; Tue, 05 Jan 2021 09:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=XwAGDhPsMBTlCDYICLuTcDF1WAEZQ1i2iAFKQ493O/8=; b=vZvcu97CkEJ19S3RVTCX3TY2ylF3/cdrj85FDZI6R0Tem5QZjHFK4SySSNPLevDQD6 QQazkkg+n/t8yj+HscZwbXW2yEajmIgg3E1io5KQQ88CY6iWYncC6RrS1ZPZNWzprY/4 uOYUKQze1sY7ozrNQzMxY7c9CaaasYeBT1Y4EdEcoXEI/TqMJ5p6KgtB0qghtex3DfUA 1AXHWlkCi1dZu+zhemEivUN40FXkwMKXQ8lJGuobauAtlodTyJeTlXvTbhMPUG69ZDVa MDX1FvLDtEQkFO6E8mWRexlY9FEVhwW69f+0CxcW2x/4HckRekfOrTmgcGc2LHwseCrt oxvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XwAGDhPsMBTlCDYICLuTcDF1WAEZQ1i2iAFKQ493O/8=; b=Bax+wHvXHR97r4I77HGbxl23DQnw3tAaKSp5leJeJsXMI8fW2OEMkdpliwU+ShZxlB XpB/gWuVhs2Om3WvFWOqe33/qHQUL5VCFcdU7h+zh8AUVLieldwDA1yYmBVFK9ln92Ty aaey4Wj1AVRou8X1GbwzgNJxtDsqjQmoLfo+AROs+w3/zC9w7/jKbFK6JRBxrIYoSoey GszRh1tQqI1PZAmwsIRGDTFaWZubflBg8yxA+t4tMJ4pw7DUTI2zOfHpcQTsty+DZ740 nGWyfuMGh3gJ85QjyV1C4MSKtzsZLExacEd7TgiT6QJ+tyakf0wneDTVJoiPWInMgqqo bRfQ== X-Gm-Message-State: AOAM533FMj8m4K1LzrE6GAMxzWSBsfbmhCvWeGazI3rfpDlMCj+jO5CF 1A36jbwbTVOIW9CePOg4Rtkf7MWkFrh8ng== X-Received: by 2002:a17:902:59dc:b029:da:84c7:f175 with SMTP id d28-20020a17090259dcb02900da84c7f175mr593579plj.75.1609867250558; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 33/43] tcg/s390: Support split-wx code generation Date: Tue, 5 Jan 2021 07:19:40 -1000 Message-Id: <20210105171950.415486-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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 tc_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 #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] = { }; #endif -static tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *tb_ret_addr; uint64_t s390_facilities; -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 = tcg_splitwx_to_rx(src_rw); intptr_t pcrel2; uint32_t old; value += addend; - pcrel2 = (tcg_insn_unit *)value - code_ptr; + pcrel2 = (tcg_insn_unit *)value - src_rx; switch (type) { case R_390_PC16DBL: if (pcrel2 == (int16_t)pcrel2) { - tcg_patch16(code_ptr, pcrel2); + tcg_patch16(src_rw, pcrel2); return true; } break; case R_390_PC32DBL: if (pcrel2 == (int32_t)pcrel2) { - tcg_patch32(code_ptr, pcrel2); + tcg_patch32(src_rw, pcrel2); return true; } break; case R_390_20: if (value == sextract64(value, 0, 20)) { - old = *(uint32_t *)code_ptr & 0xf00000ff; + old = *(uint32_t *)src_rw & 0xf00000ff; old |= ((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 type, TCGArg val, } /* 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 = (intptr_t)abs; @@ -1304,7 +1306,7 @@ static void tgen_extract(TCGContext *s, TCGReg dest, TCGReg src, static void tgen_gotoi(TCGContext *s, int cc, const tcg_insn_unit *dest) { - ptrdiff_t off = dest - s->code_ptr; + ptrdiff_t off = tcg_pcrel_diff(s, dest) >> 1; if (off == (int16_t)off) { tcg_out_insn(s, RI, BRC, cc, off); } else if (off == (int32_t)off) { @@ -1333,34 +1335,18 @@ static void tgen_branch(TCGContext *s, int cc, TCGLabel *l) static void tgen_compare_branch(TCGContext *s, S390Opcode opc, int cc, TCGReg r1, TCGReg r2, TCGLabel *l) { - intptr_t off = 0; - - if (l->has_value) { - off = l->u.value_ptr - s->code_ptr; - tcg_debug_assert(off == (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)); } static void tgen_compare_imm_branch(TCGContext *s, S390Opcode opc, int cc, TCGReg r1, int i2, TCGLabel *l) { - tcg_target_long off = 0; - - if (l->has_value) { - off = l->u.value_ptr - s->code_ptr; - tcg_debug_assert(off == (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)); } @@ -1417,7 +1403,7 @@ static void tgen_brcond(TCGContext *s, TCGType type, TCGCond c, static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) { - ptrdiff_t off = dest - s->code_ptr; + ptrdiff_t off = tcg_pcrel_diff(s, dest) >> 1; if (off == (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 is_ld, TCGMemOpIdx oi, label->oi = oi; label->datalo_reg = data; label->addrlo_reg = addr; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr; } @@ -1613,7 +1600,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp opc = get_memop(oi); 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; } @@ -1638,7 +1625,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp opc = get_memop(oi); 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; } @@ -1766,7 +1753,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_goto_tb: a0 = 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, TCGOpcode 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, TCGOpcode opc, TCG_REG_TB to the beginning of this TB. */ if (USE_REG_TB) { int ofs = -tcg_current_code_size(s); - assert(ofs == (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 == sextract64(ofs, 0, 20)); + tcg_out_insn(s, RXY, LAY, TCG_REG_TB, + TCG_REG_TB, TCG_REG_NONE, ofs); } break; @@ -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 = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, 0); /* TB epilogue */ - tb_ret_addr = s->code_ptr; + tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr); /* lmg %r6,%r15,fs+48(%r15) (restore registers) */ tcg_out_insn(s, RXY, LMG, TCG_REG_R6, TCG_REG_R15, TCG_REG_R15, From patchwork Tue Jan 5 17:19:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356921 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp202641jai; Tue, 5 Jan 2021 10:05:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrFvvkC2jZBDj0VFTPx3Wy6D9i2hvhl69BoFUevKhFbu9ToCNRSUwHapmp56J56IJIBuci X-Received: by 2002:a67:2a46:: with SMTP id q67mr558400vsq.40.1609869952274; Tue, 05 Jan 2021 10:05:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609869952; cv=none; d=google.com; s=arc-20160816; b=pmrhSH9eDCjh7sf51hLMH0MBn7ich+paKLQ86dtHE/56pd5vywoKOtUpQWq2BibOLO OTENnTg0hSGgIEzlKGd6JhPX6rbe0fdVq+nFJ8qvvemQmA0qLzyCTs9A2hii5fDdxcCk HXitLWGeOV41phDrsvlFc39T40ZraaCNoNX4C+yzKZGfysJ2uuJ2ZPrEq0HfSPRPiNPK bObj83hYD1JGVOrEq1cJaUD07wpRUwrnNh9rUaRTcTaEPPO/37vBRurItUozjavRJCf7 zpdxW2mex1JEBb04w5ooeR6dKYMNSs12udjP5Rc0u8XWmQ4CjJgagqPSXYLOLctEiNeC LhMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=sam4hUV/EzcXgGAJgfUtLyaqNJNq9uqdrP2iGsKVsYI=; b=OQOKzVDg+Qd6cVYjGE9l/qRxjH2q8uhrbGLrInSQwsj5oTATH3De6SsDAweTp0eJY3 OAqf4Aydz46Lo/H9v+GK54P135N6pWBukAB9PCLiA5sGFwXWM0WSELXirayrE/Jin+0R coCfClbUwjwmX6LerDc9zn9SQwSZRv11KTr18lWLZkaCSLLt0AbOsZbFyL/WxLxkwoNX tgR4P7hNOC8m+MA8J9biGau0mLVa1uR3mib7fJjoszkS3v1DBeK9p1EIdXn93iom4T8q 1JyGBzOf86lCXFBnVL5YV3Qjep8rcnyfqGZ6SPKOzMpEaPZoY8MD4M+egNcOWIJRkK0Z fw3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nfb0yi4j; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i76si139796vke.48.2021.01.05.10.05.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 10:05:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nfb0yi4j; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqiN-00074G-M8 for patch@linaro.org; Tue, 05 Jan 2021 13:05:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0t-0002rX-TV for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:55 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:40028) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0r-0006iO-Ub for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:55 -0500 Received: by mail-pl1-x62a.google.com with SMTP id q4so57354plr.7 for ; Tue, 05 Jan 2021 09:20: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=sam4hUV/EzcXgGAJgfUtLyaqNJNq9uqdrP2iGsKVsYI=; b=nfb0yi4j7KUzFliBn3KDEDyE2nptEtrrGI0Y57352g+zIWM1TXeLp+55gbr0q6bSkk TDbv70DdMtX5Zrg5nDTPdytf7ulh/1n+cSLq7wAFSo9sECmTg1oMjPrgXpcjlsEie2qZ ekHoMk2S/ovV3a3JS2U2/m7PHCbyZP3nG8eZ7fP39XzI+BGdr6HjFA4NQNTCzPg4YQnF 1lqWHmuRlGFQc2FG2fs/C9pnRVohOIRNFk86DxYTT3W/ms0GqP/G6ASH0lLGVTchBVCQ M3URo66QzxlmaDR5CtupMVFwbuX4IYkQLpPGDITVmCaf2+viG0HVz7MuBWfLxRXYd0n9 Rn5A== 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=FknBtlKh6uGy/AgObJ/MVLsfXYRsAR9qx1Z+38Ti2tKaPh06w9oUHgVU71q9jc9/qa FreFkedhwwv/hy/yGJUbwdk18e7B7AlrIsZTMY5W8bejKoiLEtnhh6aETgQ4wIGSfI4r EHIN8YRMbiYrP53Ey0me9eziL1txArq5RBEMFELUgslHltJyNALyBdQK++BddjkuquJC RKCxxhgGVgfTIGcLWjpLrYntiCfPwflHvEPITWOfBDaBe7V63Xz6PGuJA5k7dnW4vg/i 63QFKm3nSPiK8Bt+7fpEBuuvIiANjYdzMncC3BikBeY8n3DxEQjHsF9saqmGlmhxCSDL h2TA== X-Gm-Message-State: AOAM532LSGXbYwWeoA56m7kmfoOLTnwXplAa6A2gKCGvUw1CMFGaZ96I i1vsPCFpN9F4BP4wzjCbYvOeUX47y/wQLg== X-Received: by 2002:a17:902:b584:b029:dc:1425:e5af with SMTP id a4-20020a170902b584b02900dc1425e5afmr343278pls.3.1609867252257; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 34/43] tcg/riscv: Fix branch range checks Date: Tue, 5 Jan 2021 07:19:41 -1000 Message-Id: <20210105171950.415486-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Alistair Francis Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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 = (intptr_t)target - (intptr_t)code_ptr; - if (offset == sextreg(offset, 1, 12) << 1) { + tcg_debug_assert((offset & 1) == 0); + if (offset == sextreg(offset, 0, 12)) { code_ptr[0] |= encode_sbimm12(offset); return true; } @@ -441,7 +442,8 @@ static bool reloc_jimm20(tcg_insn_unit *code_ptr, tcg_insn_unit *target) { intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; - if (offset == sextreg(offset, 1, 20) << 1) { + tcg_debug_assert((offset & 1) == 0); + if (offset == sextreg(offset, 0, 20)) { code_ptr[0] |= encode_ujimm20(offset); return true; } @@ -854,28 +856,21 @@ static void tcg_out_setcond2(TCGContext *s, TCGCond cond, TCGReg ret, g_assert_not_reached(); } -static inline void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) -{ - ptrdiff_t offset = tcg_pcrel_diff(s, target); - tcg_debug_assert(offset == 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 = tail ? TCG_REG_ZERO : TCG_REG_RA; ptrdiff_t offset = tcg_pcrel_diff(s, arg); int ret; - if (offset == sextreg(offset, 1, 20) << 1) { + tcg_debug_assert((offset & 1) == 0); + if (offset == sextreg(offset, 0, 20)) { /* short jump: -2097150 to 2097152 */ tcg_out_opc_jump(s, OPC_JAL, link, offset); - } else if (TCG_TARGET_REG_BITS == 32 || - offset == sextreg(offset, 1, 31) << 1) { + } else if (TCG_TARGET_REG_BITS == 32 || offset == (int32_t)offset) { /* 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 = reloc_call(s->code_ptr - 2, arg);\ + ret = reloc_call(s->code_ptr - 2, arg); tcg_debug_assert(ret == true); } else if (TCG_TARGET_REG_BITS == 64) { /* far jump: 64-bit */ @@ -962,6 +957,13 @@ QEMU_BUILD_BUG_ON(TCG_TARGET_REG_BITS < TARGET_LONG_BITS); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) > 0); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -(1 << 11)); +static void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) +{ + tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, 0); + bool ok = 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) From patchwork Tue Jan 5 17:19:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356922 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp202922jai; Tue, 5 Jan 2021 10:06:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOgBeSegoCbEotplW/DTUaaRXpREMp7AviR0OdK4R3Is+h/OJ2ELWgMp3UZZOkNaaqn84A X-Received: by 2002:a05:6102:2da:: with SMTP id h26mr445818vsh.27.1609869972167; Tue, 05 Jan 2021 10:06:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609869972; cv=none; d=google.com; s=arc-20160816; b=fa/lTPz4yZvqtwsDsccEGIMTSTaIMeGSdyfM9dt6ujTPvAxZJE9CV/aOv67kl13NQL ncbSnMsY4sOPqnXJuKVW2AO2wxlR4Tq+DBT9gE6ouzj2rxJwidH3l1x534jtOTOCUSqF yfALlsPq9vS+YUOWzttgLXeB8dffGAGxSxQPNF9mxwr9/3Mm/EWhjefWoK3pxtPMJDZn diB0/U4uPo9MByrJNFBkMy33TZ4pfNzqWp4qqVkpzWf1wTqXsRLDL/JHDmWj0eseCXNC XcOZsVxuLxUFIZiV3rUOFs8YjESiFUXyiY+QA2gklFCI+drS5Hm+P1KAJQKxgkkBPkR6 uM5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=2ceeCrB5ObxXqiOq+gfMl3DKYMpwFGb7NLNLd4oEq1k=; b=gj0EO/0USHlUrzi8LQANm8HD7KQ9ITENcV2ObQZEEs0x11iGqTYjxr7ZLj7x5Dc2BN VejRHU+iYqj9Btvpupu/oKQXRJmWwrQfc2Dt/CSh/snfhIL6gvDkfATsLIR3/lhgLeon 2TRg2V3l24VQac20rWiHlAKWKixnLgeV6byM3sBQwnHKX2O2MMc98kExUP3YGEd5i1gK fbQMNARoLkoDxCbwUseoeJPrZeKWTqJtsTgOkAnZghhA0QSRZfzgNDkROswgCvvNGs1s VKU+yeBWmLzB85OMqxoB1k/cpmIklleUlPFjSRWCzLX9HDDBVbG2aSv8rUzurDq7a3z7 V/fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T6BkLGMb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d4si10861uam.83.2021.01.05.10.06.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 10:06:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T6BkLGMb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqif-00077j-O0 for patch@linaro.org; Tue, 05 Jan 2021 13:06:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0v-0002wt-JO for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:57 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:32918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0t-0006jC-Od for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:57 -0500 Received: by mail-pg1-x52a.google.com with SMTP id n25so302833pgb.0 for ; Tue, 05 Jan 2021 09:20: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=2ceeCrB5ObxXqiOq+gfMl3DKYMpwFGb7NLNLd4oEq1k=; b=T6BkLGMbg3DA5Fos+36Z4OifTFptou3O2TGdVZ3OjB/y3tuetp8V4sOq5k5cMastHX pgYHARb+5JGxYIzVVeKh/0bF8xP3q5Fz1ps8prbIj1f0LW8rMwXm4nqHEX7gsWCTum4y PvutrKj14dX4YhKe0Xb70/HcokFEOTdvc/uGWQVObns65VaMhcU5vsxlUgElgvR3esW5 O4ajWNiGIDzr45Vskm4q8VpTaebIKdbZZXOKbroDyg88m80W3ia9hr0PUNmO/SOOeEYX fgv5CBj9gRrHs2F37ptzPH12mJRzav9EYedQqvpPPZL64IuUHbqQlILJCHT9NT6QCx+N FXUA== 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=FX4MgKMdKog/InbONEh4I3z4DnhcZPqgJlD+NuGS4qPjAItxnrX+0rraYxtsRzoyD9 BlJpEaUs+2z2RrfkY0QSV5cm387XrjmFWzxchaheTkGFdEm7paMtAt2JU0OP/UOLIyZw 2SsEcCfChAWv+9egf4m3d81/PbL3Km7DURtqQjdpETf6ClNrVNbZYMDgF2rDEeQfb+aY ZG0h6SKkTGdumDp3V0C3LcMNdflPhDd1h+99lY7ikJIDheSyXtAU4SLWLQCsmOUhM6wa GIwrKByXTY0+Zmc3ptsrAcyFDi3SaK1EhnU8FkKRG09i3uMTtdVf8CBG4L8Y+6h46kD0 g+yw== X-Gm-Message-State: AOAM533S8aM4Oocvj1JXKLNv3hX4fVV3BacMNbB6kFW+QBdClvCPDoSS V7KyyaUPvdoYrs/eSCmpFEYkl9wcoHBMmA== X-Received: by 2002:a63:4b54:: with SMTP id k20mr367312pgl.290.1609867253881; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 35/43] tcg/riscv: Remove branch-over-branch fallback Date: Tue, 5 Jan 2021 07:19:42 -1000 Message-Id: <20210105171950.415486-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Alistair Francis Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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 = *code_ptr; - intptr_t diff; - bool short_jmp; - tcg_debug_assert(addend == 0); - switch (type) { case R_RISCV_BRANCH: - diff = value - (uintptr_t)code_ptr; - short_jmp = diff == sextreg(diff, 0, 12); - if (short_jmp) { - return reloc_sbimm12(code_ptr, (tcg_insn_unit *)value); - } else { - /* Invert the condition */ - insn = insn ^ (1 << 12); - /* Clear the offset */ - insn &= 0x01fff07f; - /* Set the offset to the PC + 8 */ - insn |= encode_sbimm12(8); - - /* Move forward */ - code_ptr[0] = insn; - - /* Overwrite the NOP with jal x0,value */ - diff = value - (uintptr_t)(code_ptr + 1); - insn = encode_uj(OPC_JAL, TCG_REG_ZERO, diff); - code_ptr[1] = 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(); } } @@ -779,21 +752,8 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, arg2 = t; } - if (l->has_value) { - intptr_t diff = tcg_pcrel_diff(s, l->u.value_ptr); - if (diff == 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); } static void tcg_out_setcond(TCGContext *s, TCGCond cond, TCGReg ret, @@ -1009,8 +969,6 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl, /* Compare masked address with the TLB entry. */ label_ptr[0] = 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); /* 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) } /* 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; } @@ -1089,8 +1046,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) } /* 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; } From patchwork Tue Jan 5 17:19:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356903 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp187005jai; Tue, 5 Jan 2021 09:44:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNKU8epMx0JsaPNslfLTsfAq4pqOJfP8VPfIaMtJFmHrttc51MY9/ricWs1AysZHN2xhz6 X-Received: by 2002:a25:9906:: with SMTP id z6mr751236ybn.238.1609868660276; Tue, 05 Jan 2021 09:44:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868660; cv=none; d=google.com; s=arc-20160816; b=vsmpugO9i3kCXkRtXxGl4hi7QtaSNl8UMtyLcfuzCpIySmFPDbhQtZO6skb3aXRFFZ wQytvQH717DLyRAQ6Q53nPueQAMgujWTkHJiu87eETN4vAsh3gv54CYsUeFomf3hc2sc K2L0ZU3q/KXatvphvTKA3TKUoCcz6SJfIS4prz5cyHysos2iaX0YSVqOwgkbLzBC8r0V +xgA1SMeNv5jrofEi7GCS8izTMkkykr6DMFvpEgAy79XITKgB0mlAuZqjLUk59V9HF57 PqhglIgvxrrOzYVpuWuW+h1WL7wilh6BPr8e44Sx+Sso3mw0B1Z0LQSUpN6F7RZU1QVy iu1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Q/5vpDX6rjCPgvb/9YU60IegGHSAx+QWhFDunev+ydE=; b=Gd8uAzPpjkHLSG6R38J0/VgiDdX7OsEKYpYagbSOmiJuKMCcvRm0hq4jAfib+ylj0z ScNWsjGQUgVx3M8Q72KPuPHeOWR3WJDR4jhmKNy5DSy/pGbhYtq0+ecFrWXn2Qalmsck uAPycNy2PL9955My4pHNy0LwzZQTYH6jLUHW7oDnzBKFq9f54beOJPoZVznXGcEtFcOe IsZ+W0xuVXPRcEGhnPnH4kkhnbk5o38NusaGhtqbbsorNkT7fxyiEIq28s+EI7ZFeGzN 5GLH3hFhDMydJlN926HDnQbRdV4vIcuXL5HC96VtMKhghb5aXpRlGK3p/YwyIhbOvPIG 5VcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ZV/RDqiD"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x36si518784ybd.122.2021.01.05.09.44.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:44:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ZV/RDqiD"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqNX-0000Ps-Ot for patch@linaro.org; Tue, 05 Jan 2021 12:44:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0w-00030G-QI for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:58 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:47019) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0u-0006kM-UO for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:58 -0500 Received: by mail-pl1-x630.google.com with SMTP id v3so39056plz.13 for ; Tue, 05 Jan 2021 09:20: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=Q/5vpDX6rjCPgvb/9YU60IegGHSAx+QWhFDunev+ydE=; b=ZV/RDqiDkgBL4Jpfvc70f3eWatofFqf6B1fWJOedilxqkUt+1psshOWpOH+0dQs/cu IEftZBVQboMUtSwO0N/vx3yS5eeEPRomEIbEOqEUojJOLvWC/OqvlH/dPoS8abBLZdC2 Fbd/hAeFUFso4l/GV7Nb9MsoaxmjrvnfMZKz2fZCntuI0I8+bqujn2ko5VGlwS4RsnyA 2kWr9sDs9Ckp9BDvMszTSTKDwzxMWzXQPCB23SBRYX+I442alRWhW2mRKVQW9uXqMndg anjq5VVtuqHTaS08i2/+166V/IcSjuv8u/KIdd0Mpw+PBe/3fcCLp34/QHzp6+QNRMTI LgqQ== 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=fiTRp6tSu44VNonYxYstpgs0/jVtiX8Pc3Qm9vTtFke+lzCWVGzoOZ6LYeQLXk2t91 y/j677AYfDY5QfNDHGUW8qL9BQO6yE+yE1ZIdSLfyY2xOZXyb0/q4WxcKTCznyW6STZZ UMxNjdhHKMRanMsN9cX3I5+17hhEOpkCSd+sKYJq9alaJuU19o7ycdgHiPYv8pz6MvKU s+PXXyIhA7lioqKYQJV56mD/c3Moicj7oOjAiLrdQCgBovYCCy/LEtgSM3tQvRdzQ/13 JuPsR9KUCnRXu1ADcgqoR25gqTSZNooohmMrt4dUvWgaeE2SKAvxbcoRVCMqdvfYSCzs uccg== X-Gm-Message-State: AOAM5310RTL+iKcV2kCfCPtWoRsI+87UT19cPVZ0yFcxOMz44uagyGjo w0r9SaYjqHtJcInlD7JdKgxIzClYp++Szw== X-Received: by 2002:a17:90a:fa81:: with SMTP id cu1mr253513pjb.39.1609867255438; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 36/43] tcg/riscv: Support split-wx code generation Date: Tue, 5 Jan 2021 07:19:43 -1000 Message-Id: <20210105171950.415486-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=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: Alistair Francis Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS #define TCG_TARGET_HAS_MEMORY_BSWAP 0 -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 #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 count) * Relocations */ -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 *target) { - intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + intptr_t offset = (intptr_t)target - (intptr_t)src_rx; tcg_debug_assert((offset & 1) == 0); if (offset == sextreg(offset, 0, 12)) { - code_ptr[0] |= encode_sbimm12(offset); + *src_rw |= encode_sbimm12(offset); return true; } return false; } -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 *target) { - intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + intptr_t offset = (intptr_t)target - (intptr_t)src_rx; tcg_debug_assert((offset & 1) == 0); if (offset == sextreg(offset, 0, 20)) { - code_ptr[0] |= encode_ujimm20(offset); + *src_rw |= encode_ujimm20(offset); return true; } return false; } -static bool reloc_call(tcg_insn_unit *code_ptr, const tcg_insn_unit *target) +static bool reloc_call(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + intptr_t offset = (intptr_t)target - (intptr_t)src_rx; int32_t lo = sextreg(offset, 0, 12); int32_t hi = offset - lo; if (offset == hi + lo) { - code_ptr[0] |= encode_uimm20(hi); - code_ptr[1] |= encode_imm12(lo); + src_rw[0] |= encode_uimm20(hi); + src_rw[1] |= encode_imm12(lo); return true; } @@ -532,7 +535,7 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, if (tmp == (int32_t)tmp) { tcg_out_opc_upper(s, OPC_AUIPC, rd, 0); tcg_out_opc_imm(s, OPC_ADDI, rd, rd, 0); - ret = reloc_call(s->code_ptr - 2, (tcg_insn_unit *)val); + ret = reloc_call(s->code_ptr - 2, (const tcg_insn_unit *)val); tcg_debug_assert(ret == true); return; } @@ -917,7 +920,7 @@ QEMU_BUILD_BUG_ON(TCG_TARGET_REG_BITS < TARGET_LONG_BITS); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) > 0); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -(1 << 11)); -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 = reloc_jimm20(s->code_ptr - 1, target); @@ -993,7 +996,8 @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr[0]; } @@ -1012,7 +1016,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) } /* 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; } @@ -1046,7 +1050,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) } /* 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; } @@ -1232,7 +1236,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) #endif } -static tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *tb_ret_addr; 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); /* Return path for goto_ptr. Set return value to 0 */ - tcg_code_gen_epilogue = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_A0, TCG_REG_ZERO); /* TB epilogue */ - tb_ret_addr = s->code_ptr; + tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr); for (i = 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); From patchwork Tue Jan 5 17:19:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356910 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp190121jai; Tue, 5 Jan 2021 09:48:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxf4cFLqx93Ob7LVGupKsmBhAB9+V7JWZLtR1XiSFbtYZBNRCCy8NFDM7Huz623RO1Vb3dd X-Received: by 2002:a37:6744:: with SMTP id b65mr616387qkc.199.1609868928048; Tue, 05 Jan 2021 09:48:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868928; cv=none; d=google.com; s=arc-20160816; b=tQ3Icfi5GYsButnFB/0NrXEDJ0H0IBDBHc32Fxc/uhoLP4qngp+hXiMKWERzqnHVYp Y0dFlTAFEiIJQOLlzgBkYKGX1E4fB+NNOXDW681icQH+SgZMMlRTi6HlrCxpvxGQkgHP DaVBD/dDdq+a3rmKv046JT+hwhfIJpzmmHC2MsLF7SVLUW9JkNk9CUs4hb2BvYtYXkr2 zNSr9ZxzF5JMiDRi4dyylOAkY2H801wW4wU56xYqIoi3kKSSqS19UZMLcOe7a5q3JVX0 K2hL5zJP7gOn2tcyCjLeTE8bWiaDiy+TyHkPes5Osw85ccuOnS1cDznlSvCmuYSfpCKI cqtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=PZBhVDepUcDpkv6qOWXmKFUYbcFXiGc8v0ZHGvlO+rI=; b=NHRwcmzUgUA6WtQ8TvhgjmgQU1PkeLcyyza6v2Hbv8xAaKLsz0YEZRXPDpoxVp3x7x 9U81MhZnfrs4vcWWms1PMZ2IKBVTsB3/mW3XzNZ8Q1Vv5bCwmMP4SFZRM4ULrvu3ssrq CIhXofo7W4tg2vUKCODe28BN1WEbweV+Bw+lWL9z6nu1g/4JaUE9XBIY3HIK7ajRgeLb SC2awxPk0BYvNLe94aIvEEZCxmzogP57oj7tBCs3o4Cxs2HB0HugiJEv2EiNIDfk+BC9 tJVqBJlFs1w9FhBM5IPkdsF7drtylDhudKP9Iz+Z8dw70EtLghXVXF+EQh7GmEgMA9qb FbRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YqmPi+Jh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x23si227336qkm.314.2021.01.05.09.48.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:48:48 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YqmPi+Jh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:33168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqRp-0007Dv-VS for patch@linaro.org; Tue, 05 Jan 2021 12:48:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0y-00033p-4Q for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:00 -0500 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:42811) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0w-0006kv-Eg for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:20:59 -0500 Received: by mail-pf1-x42c.google.com with SMTP id h10so110696pfo.9 for ; Tue, 05 Jan 2021 09:20:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PZBhVDepUcDpkv6qOWXmKFUYbcFXiGc8v0ZHGvlO+rI=; b=YqmPi+JhWp9PVGRjdJSJO+y2w2PYNV9xtuKuBMM7xiBJ8WgO4MK00VhGGJIPoUXrBD TgVi+7uPBWMO5lBuL2lASyHEWXZdvVB7vMRWt7JNVST7UweU3vAEf0T7XDcmRa8XbQvl eTi9x9ShGzTxyTlrbzrC38+TrUjSi41Oabsqtc2t721cynxBAwk36DcG8VRN5w7bv/5w gM9knVt4flOlzeyutik7ppySxsyb/oWS6MosinviIVc8W9GDDuvlIe++V/EVCNiCrkPB nY0VQnAmC3sA30w8Z0kblATctD28nL4pIB12KWwikJHy/cFmzgMcj5Wwp7FSCtPA/H8D MVzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PZBhVDepUcDpkv6qOWXmKFUYbcFXiGc8v0ZHGvlO+rI=; b=fu8c1e7dWkKctSnkUDbrQeyUY51elFyEJc/CzKbLOSXXlPCXNIAoVm1/SA+3SZGelS 6lAnu4XhtJhk/zJ/Al1S3aDSRD1yD1XN/cf+MMXBoxO0CgRxeLVWMGDUvHIN7t14fC74 LoAsIjHPH+ntuGo0nT9aFtrjU7vwhRR9RLF1v+r2V12tNV3wlCN35ufYM3VXm67dypGB KzsDzHfpyvGc1o923FnnuTm4ocCBGNJiTO99PHngKY610UM1jn7CyMrdy1/4CgJxHv4/ pT7xntciFAApVhbn74QR3ZvJOsxEXGJ5+SM24bJIyB9wZoamrXq0wZ7HwC5DGr/m62tQ AgQA== X-Gm-Message-State: AOAM533bwa99bKGIGXp6KyON8OK7DRYtGoL4je/WWPO7pSKVVRqKqT27 H3oNcJUJJm03RMqSAXru8jH6lRfQTbKoOg== X-Received: by 2002:a63:ea4b:: with SMTP id l11mr338097pgk.61.1609867256783; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 37/43] accel/tcg: Add mips support to alloc_code_gen_buffer_splitwx_memfd Date: Tue, 5 Jan 2021 07:19:44 -1000 Message-Id: <20210105171950.415486-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 0c0f9c3e62..39a0413524 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, static bool alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp) { - void *buf_rw, *buf_rx; + void *buf_rw = NULL, *buf_rx = MAP_FAILED; int fd = -1; +#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 = tcg_ctx->code_gen_buffer_size; + buf_rx = tcg_ctx->code_gen_buffer; +#endif + buf_rw = qemu_memfd_alloc("tcg-jit", size, 0, &fd, errp); if (buf_rw == NULL) { - return false; + goto fail; } +#ifdef __mips__ + void *tmp = mmap(buf_rx, size, PROT_READ | PROT_EXEC, + MAP_SHARED | MAP_FIXED, fd, 0); + if (tmp != buf_rx) { + goto fail_rx; + } +#else buf_rx = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0); if (buf_rx == 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 + close(fd); tcg_ctx->code_gen_buffer = buf_rw; tcg_ctx->code_gen_buffer_size = size; tcg_splitwx_diff = 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 != MAP_FAILED) { + munmap(buf_rx, size); + } + if (buf_rw) { + munmap(buf_rw, size); + } + if (fd >= 0) { + close(fd); + } + return false; } #endif /* CONFIG_POSIX */ From patchwork Tue Jan 5 17:19:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356911 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp191540jai; Tue, 5 Jan 2021 09:51:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4yjB3AcguRXTcIOa0eRMR94UbGXg8p6j1G8dRA/lj2lHMSfLOuqLnfpp+GSAsd5JvweZe X-Received: by 2002:a37:a413:: with SMTP id n19mr649553qke.15.1609869069824; Tue, 05 Jan 2021 09:51:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609869069; cv=none; d=google.com; s=arc-20160816; b=EOoLkvunnXCO7b3sBtf2svysyE9IYJ2sLYmSo6kuw4tIzmQP8aRe927qypA/4arrir ZX8v8BhuockRwfCTtLoqcZiXGC2j+oXLFBg0ENHxYlLQIizHze/erIooZ0YekGr0Y+m4 9fPWQEsXYdCLK4voeSnHUxS+trlrVQSUuBpA8nuQp+4F2CMz2PhtuIJugSiUAGkuG0Y+ Pve4zrZ0QosjlR6mJizaV0mXuh4K69l/fVsKzRMCqNIsYXQvwuot1dRnCt53knQ/Ca3c LBsXl4xdiog7K8uWOyGofyrrzbBM4ouXH7T0VJ453sb9L//E2Xkw/zb5qU/RgevJtbO4 PVKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=LTOwMATyaXZP7SM6BGb5+X2EG27N5NburtTLzhMxMhPioB0WMbk5cujUMmkNrLZv9p xrOGjeeQMjhJ0wmVKBli5iK6j0eWOGmBOcmBQDx8Ky4FUgFfVuhA7FFikL0avcM8qbqo SiozwnHqelOEREsLET8piBUIC+Df2M3NfpRT8hVHWUaLHLaoXCeUt7DmrlDbeJ7uDOgU oB9vbsodQmAL9CkYj6Q4iNQIaOLxaJLbHVmCVN47WDi6cNFxTq8BgBUb2LTZmEHVoWW7 O5BVVgT21gyLniSGXwGMk+abjILvX5okdk45ueJomBMcl+9cZXz1/z4ac+grhuzV9Q5J nYXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R38x4VGW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u3si27639qtw.127.2021.01.05.09.51.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:51:09 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R38x4VGW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqU7-0001xL-EX for patch@linaro.org; Tue, 05 Jan 2021 12:51:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq0z-00037Y-LN for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:01 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:43931) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0x-0006lo-Qu for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:01 -0500 Received: by mail-pf1-x42a.google.com with SMTP id c12so108068pfo.10 for ; Tue, 05 Jan 2021 09:20:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=R38x4VGWu1mvGmr+dLlMEx5aQCVPxyI2mx7Ucj/H7ZwU6BhhDP315prg+XzL9f9ISB 7ESNo9LDcT9XLZN+aeNKElNeRbti5pyjsx8c0P/DfndoaaA6RBAAhWhbrCyaGNx0e3br JhXRndo62qm0bp6pnkb/9bjxlB51aEJ1FU9jUxetXC8/DIgwxLfeoyJOdb1enfq1q4P6 0nyHjadAzQca29ZPKefqqX4rs81Xcl0tyIpD/MxLWtDsDA++HWvOpvYt4Dk1tSDYNL2O pQhVro5YAwTaH1EzY5P4SOxAzdUHP0uXo5icbd33RsaUr4AdqZrrZlFTB41/xIYeXfRh rGgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=olTqJf/q9v+71cBreKYB8oa0ELmOGkIKkfB2FPuEyfXMA00GjgDsmDFP3oJLLjI8S+ Tf9NNItX+TYSB+Va7eIRoAdRNn1xUouWgVcLPSFiHX4KczI/LZWEzrSqMML+l8icOuc8 edX+IxVZ8tL6plwxl/kfyIpRNZgCicBsfUifgldOBwMe9suV/c0aHLu8Mw0wpjCLlxms kwJpqZwWGjds09EjbVBmI/Z5joie6RaM2ZwBS5DD32s6AlhtW/n7+de9wMPZA0towMMT /EktIYwqT5U6hMFb3eLiPTaJQ0uGC8fAo8NUW44UtQkUWml0ZupYqkxSUjwyQiIJ23GG x2FA== X-Gm-Message-State: AOAM532iVlG01Rjm9HVOkNhUX7TluK+tGBchiBAUG7FmFCeVwAN9p3OX UUP4xctwWcCTwTnx+LR2e4T+Fj1OSFGrGA== X-Received: by 2002:a63:605:: with SMTP id 5mr366054pgg.144.1609867258240; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 38/43] tcg/mips: Do not assert on relocation overflow Date: Tue, 5 Jan 2021 07:19:45 -1000 Message-Id: <20210105171950.415486-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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; -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 = target - (pc + 1); - tcg_debug_assert(disp == (int16_t)disp); - return disp & 0xffff; -} - -static inline void reloc_pc16(tcg_insn_unit *pc, const tcg_insn_unit *target) -{ - *pc = deposit32(*pc, 0, 16, reloc_pc16_val(pc, target)); -} - -static inline uint32_t reloc_26_val(tcg_insn_unit *pc, tcg_insn_unit *target) -{ - tcg_debug_assert((((uintptr_t)pc ^ (uintptr_t)target) & 0xf0000000) == 0); - return ((uintptr_t)target >> 2) & 0x3ffffff; -} - -static inline void reloc_26(tcg_insn_unit *pc, tcg_insn_unit *target) -{ - *pc = deposit32(*pc, 0, 26, reloc_26_val(pc, target)); + if (disp == (int16_t)disp) { + *pc = deposit32(*pc, 0, 16, disp); + return true; + } + return false; } 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 type, { tcg_debug_assert(type == R_MIPS_PC16); tcg_debug_assert(addend == 0); - reloc_pc16(code_ptr, (tcg_insn_unit *)value); - return true; + return reloc_pc16(code_ptr, (const tcg_insn_unit *)value); } #define TCG_CT_CONST_ZERO 0x100 @@ -925,11 +910,7 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, } 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); } @@ -1316,9 +1297,10 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) int i; /* 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; } i = 1; @@ -1346,7 +1328,9 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) } 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; + } /* delay slot */ if (TCG_TARGET_REG_BITS == 64 && l->type == TCG_TYPE_I32) { @@ -1366,9 +1350,10 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) int i; /* 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; } i = 1; From patchwork Tue Jan 5 17:19:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356912 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp191667jai; Tue, 5 Jan 2021 09:51:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCaQ0xD2/Ew3sTGGmMLiOUEYIHYj6mvXRBEq0HTghk7sIOHOcWvA2dh06ml4Ars91m7xzL X-Received: by 2002:a1f:f44d:: with SMTP id s74mr870161vkh.14.1609869082929; Tue, 05 Jan 2021 09:51:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609869082; cv=none; d=google.com; s=arc-20160816; b=HYnR7n8MC53ml2uaIVVsyLW1rcniJ0Sjh+1JbKk6N/uKGuKC/NVztDrOl53daoPqpz D2gOiu6qfE5SUzpQEd8SPLdSxBhv1iEkBekkLcsVTPI25adYgo+ruN1VjD3iX7Ik/Yen 5erhp5Qt8KDIJdSYlvnrcacuAYraDXb8i+I7pn/fwquSNCJ55Xmuuus0PUsf4b/DxtkW D0nFY7sW7+Mrre/0rW5U/8bFOoE98JuLeTOGXcBoRNYnceMcr0tTBQnDwKOR/vVIG9x/ iNEbmrojmu9ADfMukOcibNJIdAljIZ0knULsnTGln9d1bPFCFUeLFUpuqll54BYuowFd 8Ldg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=GB4LwLk5ad1S19/6qn6+Wto2rSdhDANrw5dxSbGlL68=; b=bNCICG9FfpTwpdoI+SDnnFefCVYV+Vmy6LjvI9LgYQ+DkSPCjbIV7sMFWyMBhQ9noC BFcxpMjsYj0RbmEefUaAf7yYefhXwPkMK9MIrIFu5vU58Jd0zJ57CJ5pnyMpI1vhtYx2 xBnji9KmXyVNCGCRLDIQlnsQUibtY3aoe9QRzafDuA7A8J8Wiu3MV7U6bh4Hw/DMGxJQ SbEpBA0VS7F70zEZ+VvVCXFE1G8WntdLaZn0jSkBkH/Z4tSn49n8WRIZ9x8G2HbI1OqL RREo6GkSaCp9VXeHEv7jqjx+q1ZVfhI5gzzsVHHwD6Zhp30pjHmvqU0uRBpv2Dp4MyQv B97g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iEX3ceU4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h24si4169vsl.104.2021.01.05.09.51.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:51:22 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iEX3ceU4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqUM-0002MX-DH for patch@linaro.org; Tue, 05 Jan 2021 12:51:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq11-0003Bp-9a for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:03 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:34934) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq0z-0006m7-7I for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:03 -0500 Received: by mail-pj1-x1032.google.com with SMTP id b5so28404pjl.0 for ; Tue, 05 Jan 2021 09:21:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=GB4LwLk5ad1S19/6qn6+Wto2rSdhDANrw5dxSbGlL68=; b=iEX3ceU44Y/SgowqqSGvPzbHXJq0G7LxkcKAXagjgvD4iBvIf2+5nHhaKe1VxaEniH WbvS5LnokyNgJmeyqXNwWAWLi7rSZiALqR5Y7T7GklyltqN2GEClvUcXTP4qale4tsKC Dia8fKUjTri0+qhnmcSfabBR1N4kTVQu9uoQJlP2zlNHqEh7gtcw9TOYWRfUYtDomSSV sJ9tpSHGOBkE6oGeEw0H+yzXnpugc9NidW3Zg3MVdKxbQHUnBRcmQDP2iyB9TP8tKm9v lCVO/F2iAb0XpzWidui9CBkiKEhsp0IO0SVXyjP/iWt5ra7EaIv2mcvQGUCftWFCb0Kr UlVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GB4LwLk5ad1S19/6qn6+Wto2rSdhDANrw5dxSbGlL68=; b=R4L5tMpFj7/RfeLOxs5FsznCnXt5MB0izgtE11E13zI8CUjXozOoa1FkjTw5BSXqm0 EZNJbt/2l3IpDAsl6Amwv65O3qjhFFYH8woGk1ippZzEXZxPlh1ipkJQ3WDtVioN1t54 Qs4CLfDLe3H8Afv5Msb7gDsOGHQxu3kc+thh4jt4xsLzXgWsvSroLf1a/WRwKxGdblts tG1sknGv0eHM+AkooRVVb10mYztFGahIROOIRIGt1EZJjsMTdxcnHbl7i7y5d8RpA5S0 4Jf4E1tEn25FHN56MpH6UZacJJ2wP09ja/gQei1rsW8ORMCGBIwmPGMTwq9qqGc99vFx WNng== X-Gm-Message-State: AOAM531DjZoeihShHVRiHAA3dVPuzSoOWFAaXsGGmSpNikreijcBrMcj zb4+lO1to5PC0IyiraEiDpyPNlzaqzad0w== X-Received: by 2002:a17:90a:394f:: with SMTP id n15mr244822pjf.121.1609867259650; Tue, 05 Jan 2021 09:20: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 u12sm2010pfh.98.2021.01.05.09.20.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 39/43] tcg/mips: Support split-wx code generation Date: Tue, 5 Jan 2021 07:19:46 -1000 Message-Id: <20210105171950.415486-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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; #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 void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); 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] = { TCG_REG_V1 }; -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; -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 = target - (pc + 1); + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t disp = target - (src_rx + 1); if (disp == (int16_t)disp) { - *pc = deposit32(*pc, 0, 16, disp); + *src_rw = deposit32(*src_rw, 0, 16, disp); return true; } return false; @@ -505,7 +506,7 @@ static void tcg_out_opc_sa64(TCGContext *s, MIPSInsn opc1, MIPSInsn opc2, static bool tcg_out_opc_jmp(TCGContext *s, MIPSInsn opc, const void *target) { uintptr_t dest = (uintptr_t)target; - uintptr_t from = (uintptr_t)s->code_ptr + 4; + uintptr_t from = (uintptr_t)tcg_splitwx_to_rx(s->code_ptr) + 4; int32_t inst; /* The pc-region branch happens within the 256MB region of @@ -617,7 +618,7 @@ static inline void tcg_out_bswap16s(TCGContext *s, TCGReg ret, TCGReg arg) } } -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 = 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 = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr[0]; if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { label->label_ptr[1] = label_ptr[1]; @@ -1291,15 +1293,16 @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) { + const tcg_insn_unit *tgt_rx = tcg_splitwx_to_rx(s->code_ptr); TCGMemOpIdx oi = l->oi; MemOp opc = get_memop(oi); TCGReg v0; int i; /* 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; } @@ -1344,15 +1347,16 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) { + const tcg_insn_unit *tgt_rx = tcg_splitwx_to_rx(s->code_ptr); TCGMemOpIdx oi = l->oi; MemOp opc = get_memop(oi); MemOp s_bits = opc & MO_SIZE; int i; /* 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; } @@ -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 = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_V0, TCG_REG_ZERO); /* TB epilogue */ - tb_ret_addr = s->code_ptr; + tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr); for (i = 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 = abcd. */ - bswap32_addr = align_code_ptr(s); + bswap32_addr = tcg_splitwx_to_rx(align_code_ptr(s)); /* t3 = (ssss)d000 */ tcg_out_opc_sa(s, OPC_SLL, TCG_TMP3, TCG_TMP0, 24); /* t1 = 000a */ @@ -2521,7 +2526,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) /* * bswap32u -- unsigned 32-bit swap. a0 = ....abcd. */ - bswap32u_addr = align_code_ptr(s); + bswap32u_addr = tcg_splitwx_to_rx(align_code_ptr(s)); /* t1 = (0000)000d */ tcg_out_opc_imm(s, OPC_ANDI, TCG_TMP1, TCG_TMP0, 0xff); /* t3 = 000a */ @@ -2547,7 +2552,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) /* * bswap64 -- 64-bit swap. a0 = abcdefgh */ - bswap64_addr = align_code_ptr(s); + bswap64_addr = tcg_splitwx_to_rx(align_code_ptr(s)); /* t3 = h0000000 */ tcg_out_dsll(s, TCG_TMP3, TCG_TMP0, 56); /* t1 = 0000000a */ From patchwork Tue Jan 5 17:19:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356914 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp193061jai; Tue, 5 Jan 2021 09:53:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzgZdjV4jJ01rv3muZzoboQBdJaWkE2uB+XVOayGrVJ45Nif68mtkXFseLxEiRp5Xq2KWM X-Received: by 2002:a25:2c58:: with SMTP id s85mr804426ybs.366.1609869211527; Tue, 05 Jan 2021 09:53:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609869211; cv=none; d=google.com; s=arc-20160816; b=bCAtfGuFJKALP7WzvjBZbIzmNkf01Drsud5Cm8D/XscUFSHEbP7iJRJTlFVLs709J8 Gedd7FugHKTSEjohb6z2rUr7+S9OdFAA0K39XMh+C6zZJ2tR/DBpn/gdQc6ruL1psM5M B+sNOk4JXfajhCI0zISYuXhuuTGwWrJQf99AbDNPb5wV1lFAPj1pNCwueOTTZiN/BRxn eZ1yzQNWkAO5tf5Yd/kl7LpPt5+m8Ogdo6MhfdYp1jGDS/OpNW7ce0q9nDwRxnIBTjmT fSMD/WxhaVrQ0pzptIHnBOaxb0tpMzj2LkDAtiL6zJNZBZFK5W0T75GSwyBPlzL0+xck vMrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=RjsLWt3F7DefhddvmyHDtzHbHX1tk83XD8LIVsXHpX8=; b=S5iJYhoe76ivrRLHpYlBhmiceG6AaqwUZ3J8PqSEz4dNLiTSgfVDu5S28ma0DvA8by hyGV+OW4qgGCtxHq4tp5Y1AVBYIH73RVimYi7fRjga6zRc9JxuWmx1hiYnDbxc4XJAjW MY5xCyxuqgDa7DOVckKSVYPPmJIW7XRmpnvr1ZJmVLzqmsEDnajbG2tYbZ3SYWc7rZ6H vRs5051aOeUcJ33rpKYVKPMfT8RxXp45DlCaKjZhy0qb7yn1mTuFt4uYUFh8PiEoPfkP 28BFDQj7K5fEgSIM1Q6Ol3xJyibbV0Pw33qlJlnrt96uE6WIhhdfqoYQg/wuNaRa9a+t eGZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qhm8XYo4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a96si516488ybi.370.2021.01.05.09.53.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:53:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qhm8XYo4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqWQ-0005Xd-Tz for patch@linaro.org; Tue, 05 Jan 2021 12:53:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq12-0003Fh-TW for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:04 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:55578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq10-0006mM-QH for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:04 -0500 Received: by mail-pj1-x1030.google.com with SMTP id lb18so9573pjb.5 for ; Tue, 05 Jan 2021 09:21:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RjsLWt3F7DefhddvmyHDtzHbHX1tk83XD8LIVsXHpX8=; b=qhm8XYo4JZMU4QVa31c11O0tILe9/lKoafWbH7xNi5ERuL2q/3xd7BMEuE1uS80XgL T333f6bMscJtTn28zIcJE8vzQIKxlMOoDfuNIEI/aFrvt3auHIVGrHvZpOerONcxXD6H S2XexIxdUhavlsFeK1Orx840wtwZBXJ3eW7JlZzc7N44v5AW7do97+vK63WKUcvslTGe ZMKZz9+dGFC4pb5qePtt7TqHIW1fy+m2ajWomYRlKym/WdZSxkCsgkaklSzjrjwQVKXK POM2jIlJn0cliagzG68HsP0la/pI6woHbpCTQ7Ldf//B97o8RKM1d+igVjVSicpxWJq6 q5cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RjsLWt3F7DefhddvmyHDtzHbHX1tk83XD8LIVsXHpX8=; b=E0Cygz4l+/BqxQ/uye9tQZ1f3jc1rtBD98Dx0QrYR6vXq//ngPXo4mGfEgm4itSpHn uY0CGsMwkUeLG8V+JhOVu9gwA5hl6A/lMkPNcbI0O+z8jpuQWXsddoMBzaFryV5n8yty IXN6d0Fj2AW2G2+F3OJn4XqNjdeSP6N0WCl3Ygs8C3j6RZc0GpL+UiFpBP+K3wjxzG+B t8Nnk/OhJrVLHTLt/m6Y+fLAIaAR1clAKTI8t+mX3howU8IQqRSRh3ZLKHdMUWV/eDYs 5lRMfnMTB4XPSi2XvsZ16BHyweUvV7ST49tkftFNcPWXEh88iEljZrwefVtZPKnKmpRu kALw== X-Gm-Message-State: AOAM532nbI/Jo4KiT4Gk8vY4D1zMF+VkoW2UrTSfPXQe12lAiPDa1c77 XpjgoErh2zunFdwF0QfZf31ltrRrnKVDMg== X-Received: by 2002:a17:90b:78d:: with SMTP id l13mr258820pjz.51.1609867261190; Tue, 05 Jan 2021 09:21: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 u12sm2010pfh.98.2021.01.05.09.20.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:21:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 40/43] tcg/arm: Support split-wx code generation Date: Tue, 5 Jan 2021 07:19:47 -1000 Message-Id: <20210105171950.415486-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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, uintptr_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 #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[] = { [TCG_COND_GTU] = COND_HI, }; -static inline bool reloc_pc24(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_pc24(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset = (tcg_ptr_byte_diff(target, code_ptr) - 8) >> 2; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset = (tcg_ptr_byte_diff(target, src_rx) - 8) >> 2; + if (offset == sextract32(offset, 0, 24)) { - *code_ptr = (*code_ptr & ~0xffffff) | (offset & 0xffffff); + *src_rw = deposit32(*src_rw, 0, 24, offset); return true; } return false; } -static inline bool reloc_pc13(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_pc13(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset = tcg_ptr_byte_diff(target, code_ptr) - 8; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset = tcg_ptr_byte_diff(target, src_rx) - 8; if (offset >= -0xfff && offset <= 0xfff) { - tcg_insn_unit insn = *code_ptr; + tcg_insn_unit insn = *src_rw; bool u = (offset >= 0); if (!u) { offset = -offset; } insn = deposit32(insn, 23, 1, u); insn = deposit32(insn, 0, 12, offset); - *code_ptr = insn; + *src_rw = insn; return true; } return false; @@ -221,9 +224,9 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, tcg_debug_assert(addend == 0); if (type == 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 == 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) /* Check for a pc-relative address. This will usually be the TB, or within the TB, which is immediately before the code block. */ - diff = arg - ((intptr_t)s->code_ptr + 8); + diff = tcg_pcrel_diff(s, (void *)arg) - 8; if (diff >= 0) { rot = encode_imm(diff); if (rot >= 0) { @@ -1337,7 +1340,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr; } @@ -1348,7 +1352,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp opc = get_memop(oi); void *func; - 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; } @@ -1411,7 +1415,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) TCGMemOpIdx oi = lb->oi; MemOp opc = get_memop(oi); - 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; } @@ -1762,8 +1766,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, TCGReg base = TCG_REG_PC; tcg_debug_assert(s->tb_jmp_insn_offset == 0); - ptr = (intptr_t)(s->tb_jmp_target_addr + args[0]); - dif = ptr - ((intptr_t)s->code_ptr + 8); + ptr = (intptr_t)tcg_splitwx_to_rx(s->tb_jmp_target_addr + args[0]); + dif = tcg_pcrel_diff(s, (void *)ptr) - 8; dil = sextract32(dif, 0, 12); if (dif != 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 = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R0, 0); tcg_out_epilogue(s); } From patchwork Tue Jan 5 17:19:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356923 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp204413jai; Tue, 5 Jan 2021 10:07:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMJFqcLoCYFLRg6FOaAtDBJoCIUSfR8JCplbO16Ev15ShrKh7jicD+CVm1ciD/TgNUn45k X-Received: by 2002:a25:348b:: with SMTP id b133mr971002yba.282.1609870077916; Tue, 05 Jan 2021 10:07:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609870077; cv=none; d=google.com; s=arc-20160816; b=NfABvVW3OPPWL/6lvpbKoRM+d0T/b00dfG20K2dkhhAVspy607nuzGIM7lZRIEp2EK iXzzeU/y4nuVuWGCVp3TvpIXg8PA9qqAcFR7bk6Jkp9R/n7iKHCOlLUavY3p8z17gCFZ gokcl0w5fZ3YQZnzkmxRXp1dqsuDNcprUD/GcQLRp2R0+wYMepVwcXabz0mgPj1hpiUt uSuU74HUtf4vMjtJttyuIYefd7wEel/UI896zlViIk2ycR38iBQUvsROm8Ys9fiF8RDq CrufhlfBK/aeeMYu3U7vMa5CFAKTtaU4LpEmNa1UD+/EDXdx4lXwpzqnWHJsHeQBYyx1 yS7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=OF87yS+E5QD0SBdCxeZUcLC4LFRBanhqa0uZJhdmLQU=; b=Y0w0ThfuNBZyRJBP2gZN9d87bEEh30BlBUR3Do3sGedNlSf+pEBevWec2XYPfQZX0D lQDk/Who5pfBpiW5dUtbuAmUjpvduycynZGx+ovtr4KzFylaoCM+JHWockN6Fkb6I3bs E4cq+LyulMSTq16qxqEbP6NcPobmth+JppqXU9mNOGzEiz/qikCniCupY2LyQYAW5UBu bYAEAqgbKkDC7Wv5VBsIvW5ZfcaD1nO2q9Abapcm2CZvR89FoYb482kEiB57JTG0c4Ny G0ADcpJwqMNu13uqz6dwIgBfA21DJPulXroadtvP1kGQzDVG0iXdCBmzoK20BZUCM5b8 WznA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="syM/eoeJ"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h4si20486ybk.286.2021.01.05.10.07.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 10:07:57 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="syM/eoeJ"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqkP-00089S-Di for patch@linaro.org; Tue, 05 Jan 2021 13:07:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq14-0003Hq-7M for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:11 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:35540) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq12-0006md-93 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:05 -0500 Received: by mail-pl1-x62e.google.com with SMTP id g3so71727plp.2 for ; Tue, 05 Jan 2021 09:21: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=OF87yS+E5QD0SBdCxeZUcLC4LFRBanhqa0uZJhdmLQU=; b=syM/eoeJbAJkhv0BiekE8PjbdCiNAWY88B4McxqqlHhuZWICCxJVey9FVxig/pjGVL Z4L3thExjwiIuuZwqsO1B6gVUfx7RptuAZqZtujZrv1l7FvanP4fVfIPmPdU8sLccFcd 9kXXcvs+rxAIowGkvS42y0sZRYdmmHwtFdoe0kDTXMFBvFPSLCbj2HRdj3p0WpQuTLgL yCqXHQF+WqmfzzkKgDz6iQS380a/XyvbFqY6B28whzvx6Kcd/vaswRa9q4N/02wpHkc6 VYv7/WIWGJUI926+uN7/BQn7JTwaEfBAO9kfyevWZ2d413zIRih0qTWh3iVIfoDXE4uy IisA== 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=OF87yS+E5QD0SBdCxeZUcLC4LFRBanhqa0uZJhdmLQU=; b=KEsSc/BLpcxOCcoX6FFvm0r9CZXggEEtzXF1LyvB0b3ZayiidUuuobDgdj1ZxkPsrb XJPBe9XkpSjvWlBOddKfr70n+9OlvY1NUhFCQ0FSHI350x5C2EPcO/TIhbDQ75mvjiwz XhdTrHZ/GiyIh2Q+fQcpIKfTa6xHo78FAiHLKfDg2uucYprwLa2S8Yao9b2HbOGhg8nj /O72uleRwtEn6x+cM6nHhwBIKAWr/nV0yZ1gLxQTk0HssSobPRCA7dpHWsd9NHOCsrEf P0tlYaLAkfYyIKoHBbpQG7HyDHB0OTmfkQX6wHh5Varef/mplaCfsa1z70HTq2uBgcj9 Yw2Q== X-Gm-Message-State: AOAM532VjbJImj4nLbFfc+hSoTuf9XxXGnpo90jTyEFma3SdxT+g797e QVTTlkBTG0ObYpmf6eN9hqdHB/9VCl1rGw== X-Received: by 2002:a17:902:b213:b029:db:3a3e:d8ad with SMTP id t19-20020a170902b213b02900db3a3ed8admr515698plr.73.1609867262696; Tue, 05 Jan 2021 09:21: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 u12sm2010pfh.98.2021.01.05.09.21.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:21:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 41/43] tcg: Remove TCG_TARGET_SUPPORT_MIRROR Date: Tue, 5 Jan 2021 07:19:48 -1000 Message-Id: <20210105171950.415486-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.25.1 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, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 #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, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 #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 tc_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 #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; #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -#define TCG_TARGET_SUPPORT_MIRROR 1 void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); 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, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 #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, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS #define TCG_TARGET_HAS_MEMORY_BSWAP 0 -#define TCG_TARGET_SUPPORT_MIRROR 1 #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 tc_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 #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); #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 #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) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -#define TCG_TARGET_SUPPORT_MIRROR 0 static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, uintptr_t jmp_rw, uintptr_t addr) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 39a0413524..2155dd4df3 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, int prot, return true; } +#ifndef CONFIG_TCG_INTERPRETER #ifdef CONFIG_POSIX #include "qemu/memfd.h" @@ -1254,17 +1255,18 @@ static bool alloc_code_gen_buffer_splitwx_vmremap(size_t size, Error **errp) return true; } #endif /* CONFIG_DARWIN */ +#endif /* CONFIG_TCG_INTERPRETER */ 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; } From patchwork Tue Jan 5 17:19:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356906 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp188071jai; Tue, 5 Jan 2021 09:45:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8QlcwkX6hwrbwlp5g6+ev1HanN7785Df8/0w7XwuaSRpHDEaicrWMIqc1r2RkaQQg/HDP X-Received: by 2002:a25:76c3:: with SMTP id r186mr953720ybc.226.1609868749122; Tue, 05 Jan 2021 09:45:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609868749; cv=none; d=google.com; s=arc-20160816; b=TaWEYQ4ZWZbRKwFYKeO1K2WF/DZnTpa5tzBPEdKXxvbvKq8ZrG74hHeS41lGUJlk9S +Agj0wopPDqdy33NIxF/JIzLPnvlOm0VgZ8z13il7fuXP5eDZcevO/Oq8ipwv77e97Aj tOI+RnuF7P/mrN+FWWtUN9wGmwT9UAV87ykQ2iJjfRXVTZ/8WixG/WfNx+0kVY6Qbf7j CCpvpGdKAUh5xpNT9s6eZnXn0VLbZMvBjGA04Hgd4T5Y5E93htulmJgginfXKiL4YRD9 f5mgjYGzOORNPjp68fyLUJKUPwH8jvFWyuYuxICcCnuDHN7ECs/lrW1q+7vjkc6P7bYx zzVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=4gbZ1hEp2iGpxBH0NVqdoNfsrRxmgU8uhJbc8FVSLCA=; b=zo41MNdufSZjVkeXc/qFM/F/wkTolplpxkiKQT3qqRUvWVfh9fE509eNb5APC5IJZw R2IacbJSRzHhwydHdLkbBrNK0fAeW4GtOL6TI9CX/MRvPRG3mMcMxp4EVPFXLDrfIAIt J+hjk6/Mg26sMo23XytA8a3le48f7NUlNjXZ7wngCX4aTPk61v83Qhx1KQ+htWdgyTO6 fOkGDFMH35eTJD2MNHHgsWGhAHFOKlLxDK2H+UeOEFR2ORDIPZ73kmV28JemCnVwEcFI Rb/dHSmpMGx86M3eRgJ01fgJxtZ5fcI6KeGTLKgLQUiyhb0wCBsGn1fJlMu3Cv49nVs+ Fxyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hZ+cWB4J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n15si469986yba.113.2021.01.05.09.45.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:45:49 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hZ+cWB4J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqOy-0002Re-Hx for patch@linaro.org; Tue, 05 Jan 2021 12:45:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq1A-0003JQ-Ob for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:14 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:50618) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq14-0006mr-11 for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:08 -0500 Received: by mail-pj1-x1029.google.com with SMTP id lj6so27017pjb.0 for ; Tue, 05 Jan 2021 09:21:05 -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=4gbZ1hEp2iGpxBH0NVqdoNfsrRxmgU8uhJbc8FVSLCA=; b=hZ+cWB4JJNCC6SzCMhiypjU7ItO1yQtCJctncUOfgmpx+koUrah3tCyEf57MobX17k 82CGHGnkMR5TSDfLWd1aUDYfETn9J0m/EOsOStgFML+VWP+4HedVQfa+Zg8rJWlmJ1RT 333YlZT3e3zaYluZNKjXz5bMgQHugoy7vAtpJlNf03lxyMV+Hvpu2AHETxCAmU8JgJnH XFHxJojOnKs7S+4QUakS9dg/wEEAHCBRnay2cki8IuJk9cIZPUPh/ooirELlBUFoapow Lx2gjTIu/4lhbn5FNOsYr7NAZanH1mZrfca6JxeeFrCmRkOxNxliCtjHr+E41GXUlJQf yVxg== 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=4gbZ1hEp2iGpxBH0NVqdoNfsrRxmgU8uhJbc8FVSLCA=; b=MnKqn2mJZbMHz5RKbbFFCaOw/dfeT6yMhyTGfVSzwHEJWB7lRV3CnDu+wFa5Yw/6uB O+EM253ctAFkv1mRcX/tTveBvQrO305M2gQFe3k8iZBfjwLUCqD3c92kBxOL9Vtb83zW WuPsDpMbNTXYTHJIpXbc99ri9h/Zj13QrJM7vsySxNF1DWeCu/pFyVZkZ41dBwbXMCWQ RrhAVw1wJIXPbc9GYw107idjROol9r3aLFCxFmIy8blSv3fFYCb1RsEFHvQLhQdP6Wa0 iNPB1Ia1/jW9kGTb950o2Hgf06GCbERsCcCyvTDu303UJM8BjHjj2Mk9D74ELTzqpe56 WgTw== X-Gm-Message-State: AOAM532bmSF8Est6aBp++uMwzrmV3womOyrWkHDazHof19EB6YgHfZce 2R99GCgpDx9aKglCaM9hasA24o9L1biYfQ== X-Received: by 2002:a17:902:6a83:b029:dc:2a2c:6b91 with SMTP id n3-20020a1709026a83b02900dc2a2c6b91mr299973plk.8.1609867264152; Tue, 05 Jan 2021 09:21: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 u12sm2010pfh.98.2021.01.05.09.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:21:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 42/43] tcg: Constify tcg_code_gen_epilogue Date: Tue, 5 Jan 2021 07:19:49 -1000 Message-Id: <20210105171950.415486-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now that all native tcg hosts support splitwx, make this pointer const. 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 | 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(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé 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 { 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; 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 = 0; -void *tcg_code_gen_epilogue; +const void *tcg_code_gen_epilogue; uintptr_t tcg_splitwx_diff; #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 = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_X0, 0); /* 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 = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = 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 = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0); /* 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 = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_V0, TCG_REG_ZERO); /* 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); /* Epilogue */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_REG_R1, FRAME_SIZE+LR_OFFSET); for (i = 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); /* Return path for goto_ptr. Set return value to 0 */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_A0, TCG_REG_ZERO); /* 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 = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, 0); /* 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); /* Epilogue for goto_ptr. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = 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); From patchwork Tue Jan 5 17:19:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 356917 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp194852jai; Tue, 5 Jan 2021 09:56:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzi4ICEiP99SrkxY0lvSuIdSRGO7WIqn7OzG/tHlR4MBD56yq87VffQMptz1aBiCO3D71TN X-Received: by 2002:a05:620a:140c:: with SMTP id d12mr683732qkj.340.1609869360244; Tue, 05 Jan 2021 09:56:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609869360; cv=none; d=google.com; s=arc-20160816; b=iZV/VoOLYp7KSf6/OnGOEmYO/7Wat/MQeroqbbC7QyqoYaZayvq4o5l6aq8zNyuVa6 E7THSjFpCLHCNMcglkfhJfwHhzX5ejEujkhG29Cvgdrmxtok+pOnFcOKglZ7EEC/JwgV utMm7Hfdmf/B2e1CMM1JbWU2LZTmxnXRqAVOslItQWSiaSTI7TXyXRyyxKes4Jc1sLTC wjFrBeSgC0FP2FrS8k+fW0QvYb74kBSX1xLBZ/jyz/xJEvpP/87bIm1lq8tm2OTOGP4L 1iLki8blwIq+Sqvk/UqDgrtJe2wagIcXZzPfF/qcIwvMou5/tUuvGp99lHy0nsjb06Uf DSXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=DDt9G4G0380iY4uD326AhbzaTibvzTwO85rcnYobk9o=; b=FGWLaOjOrjPrq4ZdhAuih+wKk+F7WgO5AQVJWvVic0FJWmjNyyNvIlt+ClTGuNiWRD SrFqllyAUFW73cOCYvf6z+iETKAtAY/nhLhnYCKefwO8d8JSyeJ9HzN2rkkKqLCx0tnA y33ww/y3zpxdNlCo7FJKLuLFKx2/q7zCgib+uM+JZ1TaYZOcMDzPhaVhUYfIjFuD3Y0M U9TyxSYqXGZSpN6K683ooFs15Y1Dff4UVjXwg2WmWReDqp59G7Bo461lptSF62JX68Y5 77owniXQGKVjvUkhPPuvZrSw6dCDwqCRqEGmBjE/mkyBrG5tT3VwpVx2tDEE/QVcfWjh OmWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HDP2nytz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f7si31774qtf.160.2021.01.05.09.55.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jan 2021 09:56:00 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HDP2nytz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwqYn-0000Ol-TT for patch@linaro.org; Tue, 05 Jan 2021 12:55:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwq1A-0003Jc-QO for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:14 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:54345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwq15-0006n4-9l for qemu-devel@nongnu.org; Tue, 05 Jan 2021 12:21:12 -0500 Received: by mail-pj1-x1033.google.com with SMTP id f14so13668pju.4 for ; Tue, 05 Jan 2021 09:21: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=DDt9G4G0380iY4uD326AhbzaTibvzTwO85rcnYobk9o=; b=HDP2nytzc/Y8eGQiCFchpkgmcdojCFDZCAR8hWWpdnPWXBRucxocoVT2TdknZbQmbz MRIYsFYyighvXoYVVJczBAQKtx+EtWCVCnrqAlQsPbdUY2RmKEll/YbGzwXxsdqCfVBd EvyM3DKaPPM6Gwx2DfQgf5fwRnDBC4hhBdovWKpYo7jWImrbBFY+n1qZTXbE2R+8Kje/ 7s+xn25sC4gtUiSFl9zWKcyyWOTEFqd3AWSeXXnekRr4EDhDpAshnWwZ0OjEy2VNwt62 haZubOytL1hx7f0sMu4zB45X9jp91qyGvohYsFKVX9DuivhcLOM8TAHUolQOeL/9ZZzt PvHA== 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=DDt9G4G0380iY4uD326AhbzaTibvzTwO85rcnYobk9o=; b=poCNoq0DyWBTrDBjeb3/RMrbt+hmCEYALNWu3gFUjwmedmiIChD1NhWNpLnAkKkliL cfN/kVgYMgodrcoxaGKYsLM2153JsPolAq9PSGwLOdUwhjSLOlFjojXyGwDCLk1VRXzp zWFTjn41jrzQHVrFhrnQ2RJE+Rv47efXmKSxMYSDqYsoAFTqzOKYmLIWmziaPQAqjeUs wfqqmyTKZWv2eqYfd7SKMJp3bLGJJ1nfr+pBATwiSH89AmGGgHKI4ao0/sICiMd20lt0 s5wWYyJq6nRlO3xCv401AEOx8OB6Cspwk/AYfsoBGUNn++fJOx2Hsc3FDIrMFYeh0Tz2 qdZA== X-Gm-Message-State: AOAM533hrr7tIfm6uEVo/S4ZbYV2djrsRnN9mQQQAsGJlrzeMIUQ1Tn9 MC9dIdHqhohaCARrYqCHG5ZXA1O746n04A== X-Received: by 2002:a17:902:6b89:b029:da:fc41:baec with SMTP id p9-20020a1709026b89b02900dafc41baecmr528675plk.39.1609867265841; Tue, 05 Jan 2021 09:21: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 u12sm2010pfh.98.2021.01.05.09.21.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:21:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 43/43] tcg: Constify TCGLabelQemuLdst.raddr Date: Tue, 5 Jan 2021 07:19:50 -1000 Message-Id: <20210105171950.415486-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105171950.415486-1-richard.henderson@linaro.org> References: <20210105171950.415486-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: Joelle van Dyne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now that all native tcg hosts support splitwx, make this pointer const. Reviewed-by: Joelle van Dyne 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(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé 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 is_ld, TCGMemOpIdx oi, label->type = ext; label->datalo_reg = data_reg; label->addrlo_reg = addr_reg; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr; } 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 is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr; } 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 is_ld, bool is_64, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr[0]; if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) { label->label_ptr[1] = 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 = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr[0]; if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { label->label_ptr[1] = 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 is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi_reg; label->addrlo_reg = addrlo_reg; label->addrhi_reg = addrhi_reg; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = lptr; } 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_ld, TCGMemOpIdx oi, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr[0]; } 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 is_ld, TCGMemOpIdx oi, label->oi = oi; label->datalo_reg = data; label->addrlo_reg = addr; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr; } 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 addr */ TCGReg datalo_reg; /* reg index for low word to be loaded or stored */ TCGReg datahi_reg; /* reg index for high word to be loaded or stored */ - 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;