From patchwork Mon Apr 24 05:40:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 676494 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp1984798wrs; Sun, 23 Apr 2023 22:43:30 -0700 (PDT) X-Google-Smtp-Source: AKy350Zo6uKNYj9DJGXZItJzboqUmNKXC2a/iUnBufAVyjN0QdiyhlP7XVwUx8s5HL+di6hXZXrl X-Received: by 2002:ac8:57d0:0:b0:3ef:45df:cc05 with SMTP id w16-20020ac857d0000000b003ef45dfcc05mr21162656qta.15.1682315010191; Sun, 23 Apr 2023 22:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682315010; cv=none; d=google.com; s=arc-20160816; b=bDnDsYnJA4Si1HCKgLqqE1Ne2X63wwORwTuclHCUTiPP7TO8fHVoEbZAHmZoM8PKum hPqybDfM6pwhuWnLedUSZYS+qJv3kCULddjUIbTXgeuCF+ELA5vRMXF5fqRjTEin22SB guNVowJNCfWLX1G5iElahoh+LM/mqKy4RByC44d7DM1JVpX50aOsmYULh42YCRG5LdFh 2waVkW8nH9Iqbqv1Q4VL+bdy/+i91CU3tw2LkqsFwJwdN9rOsvk2OnORIaVXfG8jCAPp 3HTMZzFoCgjat1dnI+RsOTb4s7TEwck7YgdSS3hiveJnf6IUQXRf1Nakufl5fpk1D6Xy cMsg== 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:cc:to :from:dkim-signature; bh=eP2UcvTSjxkcvSWlSrM0QTbqla0I8aaMQCx8SFdrxDo=; b=Y9T6NCGzimAkpH1Qzy3mFVz5GMPXjBVavxOntMOaYWuKLaon3Gihgt8E2oTytTXudP unP+dcMVLf6/LqCztIQoAhIyorTGlA/k5VJalqI9hhfjqyFnDnbyyoXgDTamMn4k0yIq V2wM9gGQq7GLWl+JhnPn/61zGJ4zryY21XSd+x4qFP2Y85Yczb+itdfx0L673Z8mTtF/ t5N9nOuI0o4sSGBBBKw9YTbVhqkOLbYwSH/B7P2wXxFOrWgI1BBePwb1rJPcOdgnVYBk fogQlXrzlX/osBarhjHRa22wnuGfvZOQWBKBViFTxs7d0+yqEFnhhROV8DTNgXM9DCgq k/vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IlCNtRwB; 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 q4-20020a05622a030400b003e9f01abff8si6814653qtw.803.2023.04.23.22.43.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Apr 2023 22:43:30 -0700 (PDT) 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=IlCNtRwB; 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 1pqoxL-0005Vq-JQ; Mon, 24 Apr 2023 01:41:43 -0400 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 1pqox6-0005Lo-5i for qemu-devel@nongnu.org; Mon, 24 Apr 2023 01:41:28 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pqowr-0004Fw-Kn for qemu-devel@nongnu.org; Mon, 24 Apr 2023 01:41:26 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3f18dacd392so22110645e9.0 for ; Sun, 23 Apr 2023 22:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682314870; x=1684906870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eP2UcvTSjxkcvSWlSrM0QTbqla0I8aaMQCx8SFdrxDo=; b=IlCNtRwB1/xQU7iLzHM5XbtmCDFsCOjgZJmIipafeiIB9+1OrNeOkGdrqZYeQSwhKt Hy8GuUI4mthHOr1I8q4SjUqNqv59sQuw4X5cqQuPo2F4N3eA1YVEvygVUzz4/XT11iVk T0sMF0/j7IVmdIubK7vkDSuUDEmoYbmzqMPvOAXtboeEesfuFXp8N/NxnYoGVmkuIp5K h5fAbPcPwIoPR0swog010AFsfdl092RuKQlPGLNOtEaIZl/NOCMSKegu2oYJ0rtBbPnE qUWn7rMbyscmsuqGwjOjeatYjYqaampTEwkFqMyty4MypGZOa0AR0Ky7tgSiGexwDtLF PDOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682314870; x=1684906870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eP2UcvTSjxkcvSWlSrM0QTbqla0I8aaMQCx8SFdrxDo=; b=eqEVhVKHnrLNurXFNs7t8VF1ShH3MZw7qGlU6PmSP90lWa0Ul0VaEYqrKhzgbUICdX FqmG9QQuX/luw8mpUwqUMS4pTeRyBKFc7r5ovtgM5Ix0oGXSUIq4LvV25Ysv/XZQQ+Ng eAT/tqWVi+TWKiFc+rPxgnuEnayv2Q1sQCQA7T8eTTjtL1CcrbAIQrI4VfGa6H7Detb0 FnVxIupQ/SvhmuPSFNTPrCfxDyoJnBxzQpyR8105VSe5yCBjlepFXy2w6EWzemRkl5yK trcjB2f2OycgFPf0wSp1jFoKk6e5GOTRjLkQ7XsTP1uzaQXKZtWDwYNJfHQNsGPZH9bp kuUA== X-Gm-Message-State: AAQBX9eUAdHGxy5wM2EczkgGchc/svXrVIxHI4kM8rdgsW4WvCK+wUD9 aKPfKUxMlbnmlHr3F2h4Y40XgkYp21El08fzvjfKmQ== X-Received: by 2002:a5d:6e06:0:b0:2ce:fd37:938c with SMTP id h6-20020a5d6e06000000b002cefd37938cmr8682496wrz.50.1682314869885; Sun, 23 Apr 2023 22:41:09 -0700 (PDT) Received: from stoup.c.hoisthospitality.com (cust-west-loneq8-46-193-226-34.wb.wifirst.net. [46.193.226.34]) by smtp.gmail.com with ESMTPSA id j22-20020a5d6e56000000b002fbb285b01fsm9997852wrz.25.2023.04.23.22.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Apr 2023 22:41:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, git@xen0n.name, jiaxun.yang@flygoat.com Subject: [PATCH v3 06/57] tcg/i386: Generalize multi-part load overlap test Date: Mon, 24 Apr 2023 06:40:14 +0100 Message-Id: <20230424054105.1579315-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424054105.1579315-1-richard.henderson@linaro.org> References: <20230424054105.1579315-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32d.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Test for both base and index; use datahi as a temporary, overwritten by the final load. Always perform the loads in ascending order, so that any (user-only) fault sees the correct address. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index b986109d77..794d440a9e 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -2223,23 +2223,22 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, if (TCG_TARGET_REG_BITS == 64) { tcg_out_modrm_sib_offset(s, movop + P_REXW + seg, datalo, base, index, 0, ofs); + break; + } + if (use_movbe) { + TCGReg t = datalo; + datalo = datahi; + datahi = t; + } + if (base == datalo || index == datalo) { + tcg_out_modrm_sib_offset(s, OPC_LEA, datahi, base, index, 0, ofs); + tcg_out_modrm_offset(s, movop + seg, datalo, datahi, 0); + tcg_out_modrm_offset(s, movop + seg, datahi, datahi, 4); } else { - if (use_movbe) { - TCGReg t = datalo; - datalo = datahi; - datahi = t; - } - if (base != datalo) { - tcg_out_modrm_sib_offset(s, movop + seg, datalo, - base, index, 0, ofs); - tcg_out_modrm_sib_offset(s, movop + seg, datahi, - base, index, 0, ofs + 4); - } else { - tcg_out_modrm_sib_offset(s, movop + seg, datahi, - base, index, 0, ofs + 4); - tcg_out_modrm_sib_offset(s, movop + seg, datalo, - base, index, 0, ofs); - } + tcg_out_modrm_sib_offset(s, movop + seg, datalo, + base, index, 0, ofs); + tcg_out_modrm_sib_offset(s, movop + seg, datahi, + base, index, 0, ofs + 4); } break; default: