From patchwork Tue Jan 17 23:04:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 643415 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1439983pvb; Tue, 17 Jan 2023 15:05:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXuCwDxYPhgamjSbJbpTH3RwxNvCQyKjJ0E2ih1YVqdmnGJ1Mfjz/Ske9yyrSJAKjIUzeehX X-Received: by 2002:a81:9841:0:b0:38e:bf98:846f with SMTP id p62-20020a819841000000b0038ebf98846fmr22739623ywg.28.1673996707706; Tue, 17 Jan 2023 15:05:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673996707; cv=none; d=google.com; s=arc-20160816; b=xg2eqVcbCTQS2DZM0ZRpPQiYQjBjdj3RTBwgABNYR9xGjUXU5zgiH6vSZGt7tsbq0d +PH64MQwylZfys2rStb1LwUEhfvL5AP9dq5h6rqI/YlvwEIbXmZTvRbpMsJ24w0iJ3lD VGLDTv+9/UiCzRIJOJyeY4VVfl83Yk6Ud+vGn9Zsn+vXa+qBo+/HriJWZpcOPpjZpBF7 VBB4fd7FwbVMkMLDZD3pMSS8OZ3x3xeV7IQA61WC02aU4srPC91ZXColWBISfhq1iXCH rlDGUeOaUb+zX30JzuwTVQCBF+M92vYL1HpIsSbdI3s7XjGPqvO85qQzaYcs1KOp4IO9 Q6Fg== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=b0RaJxHriq3Te1EB6P00dNqAISsg79vtZKWwbbnq+Yk=; b=PsZED6LkDuxVzAJl4oPdPFrS0y/Y/3IGP80K1xcRqJeISWdfaERJnVc2rDrDzG8Bsu nSswEzutnmwQXoowSYcaocfz3YMVRtShuQ+HInj+uAh6gaFPzg431YnhGFyUROXOl6sw V22dnCW3rc9BN2n9WnjPWRtUVO/AeMtjo/eJbdlPVxFsKxtCdBVZ0QkWS8kNEanKuNOs ojfeZCNHYEHNJ69e7WH9g5h5PZ4Sib22Hnykg5rRRmbrYbuGU4JA/MDV24fN79gWFSJ4 01wWtXX5YH756+xo2spJGnZ2/R4Ce799Y4FX6mfnMH7GmMLpklEOrlsobNmJs0Wl1skg SyHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WGlollt1; 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 f8-20020a05620a280800b006ec5f9983a0si19670196qkp.398.2023.01.17.15.05.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jan 2023 15:05:07 -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=WGlollt1; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHv0E-00015P-Rg; Tue, 17 Jan 2023 18:04:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHv0C-000157-87 for qemu-devel@nongnu.org; Tue, 17 Jan 2023 18:04:24 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHv0A-0008PQ-0R for qemu-devel@nongnu.org; Tue, 17 Jan 2023 18:04:23 -0500 Received: by mail-pl1-x630.google.com with SMTP id jl3so20221plb.8 for ; Tue, 17 Jan 2023 15:04:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=b0RaJxHriq3Te1EB6P00dNqAISsg79vtZKWwbbnq+Yk=; b=WGlollt1g4CKFpfPYo2emR9kAiDj7nchGDk/FRN/y8gLAzGtk+4z6Xa0yVzZcb7O/m PQFUSmrfb8frmwjBQrTG9yNYxMKoVOTo8E9bkugBW82N53oiLbL8sRVSBnzsXInpERUc EDjKaZNPBYO46B/eWrrQ/exn0pGMDko1NX20P2WrV1oEjHrxweVpWjG6dCFMzkwvfUTv nWFT1H+lNJyHvDkjiqmCCZX8Wjtp9xZTsJuCPGjPJlI2YXkiAFhvbNwE1NyKevrtRpFe HQRmPQ+PvBtImm7CE8wZKArqpTlWCZ3ZqEWufm7sdjYsqs73hAsQ9+dxTJMMUDZQOvu5 jUzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b0RaJxHriq3Te1EB6P00dNqAISsg79vtZKWwbbnq+Yk=; b=NV4YpvbanIsxYcny5Y6JT9/32KW9xPfN8VQfwRxrpMXbAU9/GgbHugw408UeFddFe5 S9bqm2s2ukCLw2NHGDcqgJdxVZNOzgThezrpPaR70zo2MeTf69IwCIo6i5KIVXndXNDc xfSO4qI+QyyudLh+b4lMzdZSTJNTa/yn6+DEJpKCDHEwuu+zDQ/0Qb1/hxZOAVrZnzLK wSGbykWRd7ZBVHxUQWbbdI+la5dcxnnbxYAeyxhEH4gMLYOJjphfus0nB0gUnjK1QuoW 2d2TBec1HE3YBeRbOhM1C3uKat8R9+a1eag6oOyoTqdRvQQdUc99EBcbtZjxGLmJ04IG Mkhw== X-Gm-Message-State: AFqh2krtLKx5VaFel34ar/B6sQJ0tXuk/tCR1PAWH8sLGA3P3pKwCRyf KfVxfN5Ub45C9V8xPputajK0VZoW5/nhz+h5 X-Received: by 2002:a05:6a21:3282:b0:b8:c29f:1c01 with SMTP id yt2-20020a056a21328200b000b8c29f1c01mr5809347pzb.27.1673996659490; Tue, 17 Jan 2023 15:04:19 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id y13-20020a63e24d000000b00478eb777d18sm17996936pgj.72.2023.01.17.15.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 15:04:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, Alistair.Francis@wdc.com Subject: [PATCH] tcg/riscv: Use tcg_pcrel_diff in tcg_out_ldst Date: Tue, 17 Jan 2023 13:04:15 -1000 Message-Id: <20230117230415.354239-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We failed to update this with the w^x split, so misses the fact that true pc-relative offsets are usually small. Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis --- tcg/riscv/tcg-target.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index fc0edd811f..01cb67ef7b 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -599,7 +599,7 @@ static void tcg_out_ldst(TCGContext *s, RISCVInsn opc, TCGReg data, intptr_t imm12 = sextreg(offset, 0, 12); if (offset != imm12) { - intptr_t diff = offset - (uintptr_t)s->code_ptr; + intptr_t diff = tcg_pcrel_diff(s, (void *)offset); if (addr == TCG_REG_ZERO && diff == (int32_t)diff) { imm12 = sextreg(diff, 0, 12);