From patchwork Fri May 5 21:24:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 679354 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp580155wrs; Fri, 5 May 2023 14:29:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5b06nQ+WPzb5EzNvMOEw/p6zE3SiWXIJjeTEDS2HycOEzQH8K8b/Y1F3f7JKgpQ6PB2SC+ X-Received: by 2002:ac8:5992:0:b0:3ef:3510:7c40 with SMTP id e18-20020ac85992000000b003ef35107c40mr4849455qte.65.1683322190683; Fri, 05 May 2023 14:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683322190; cv=none; d=google.com; s=arc-20160816; b=uzovW88PbVfnB7/VBiJQ7cYxTzjWRke2g6a0NHzbyLe8eYvb2WLHvTaBRFkNrBxaTp +Wux3BVcjQY3bD+ceQ8nwySyQZo6WSPeRUElkhIXslspWTJ4CqUSL9x7aeAe2HqNQiYF 3lo49DjAZ4lIN5Zh35GOaNMlSD2Mt3B3OlrxcyTn/J5M8WhRTZhoKcm+3+6yX7hJwW+q 6qr6l5QSH/tjG4+KcUki3ZB6TUxMy+7DtGg0XveJPz0SN8T26Y84qcIkGl98X72wyjfz qbnS0TS8P3Op2qMktpNSWn8nUeCD2yZr7QuLJT1bcTaBaOuUUZY1f4CVt1102c87FxOU caaw== 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=Op61LyFiNoJTk9LIzK5doaDEyxOgewGDHJjDkfUTrQ4=; b=buSejEHkatwJdnXZ5RBBWzkZK2fQpGBBHKpQpn1MgJasMWVo6LJHAGaCgc2T04KqBN jjDCCqGVjWiykSRX6fsmVjE3jaP6+/qr4/8vq0OCStLDi7s+fBvU0WgWW3v9W5V0uisU 3qtiBUW8XVrEsmpQb44ND6bdJnuslIaANoNR1ZbvHOTmgzxdlBXXfIiyc6XhL4WCQQY2 RnUlauiTx4REvu/mwFMvubxGz4vXI8IbSiGb+X7dUPqg2tdct3d+uzwQZ+tWP+hyV0zg OJjwWZwjVckhlrpSWU/MZf36hgONTOQYnftLzrYC0cRy4yANZvWOXZp/kWskRkvM2rnV ueCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XtIEOaEu; 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 w14-20020ae9e50e000000b0074e0ac37a60si978689qkf.586.2023.05.05.14.29.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 May 2023 14:29:50 -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=XtIEOaEu; 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 1pv2vW-0000pf-Py; Fri, 05 May 2023 17:25:18 -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 1pv2vU-0000nS-F1 for qemu-devel@nongnu.org; Fri, 05 May 2023 17:25:16 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pv2vF-0004ST-5T for qemu-devel@nongnu.org; Fri, 05 May 2023 17:25:16 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-307664010fdso1855863f8f.0 for ; Fri, 05 May 2023 14:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683321900; x=1685913900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Op61LyFiNoJTk9LIzK5doaDEyxOgewGDHJjDkfUTrQ4=; b=XtIEOaEuhG17hyduWVNQq+sloifk1TKf/Sxnie+7YP0ip0KD80J/tIpvyGhNlS+Tro 6e2mYd4W+V/4q00CcIoxQij/lLnbVksbU0lE4BvvJ+QWX+gPBg+u+Prlt/THZbM+WQ2d lhDCGeIG8XkArvFs3rfGb1RehMy91L8rqcpHNT6fJ1merp5Ev/yc83NwYaSYKy3EvkRp m8hLt+yXvOgBo0SABNkEDpXphMIlCJAoMeThzi6YNp+g9bgHlsr+6GkssWOdhR5FyoRL NCpJkTK/iL8cPiwzdu5NnuideFZYVjIixl+grtkuOt/SBO3pmAkHXDn2nZdcQFvmXkCp FXrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683321900; x=1685913900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Op61LyFiNoJTk9LIzK5doaDEyxOgewGDHJjDkfUTrQ4=; b=UGW1mjlwL4rhItEnHDHyj+tdO8zYpsbASXlu22mRnjOkopPqiHdZOxrw2my9QIDUqq x2XTB9hXjBDuo9cFX1w3ZDAEl8mSbeEpXe8cnq21ovdlEqoSilJbKwsHotbCTK//xN9F 3QleaSExjgjf88UEI1L0xnz7EdcssBmEGVuG4X7QmR4ku5pUkl+uaUx0JzGUmesYlP1e 8GFDYhDjglz7EGIElhTw8gAxY+ay57jP8VobyGTQuQi2wrE1KPABhCm1fE2m0X0R3xjw N1UP67HhIZBvQG+vUTYfBUmA5gYuYVDToERdhwFqS99TNPk/kO3XONjk3AFdHFqB+kX1 HsHA== X-Gm-Message-State: AC+VfDx0FX1HnT1Qrpz9mRiBGQmo3fNHX7MACocunNGGnh1O1u7KREpg TND7Qq1lHUEfsk1sFkckBb7oOjEhBc3+S+2x9keK/Q== X-Received: by 2002:adf:fb06:0:b0:307:7bca:2964 with SMTP id c6-20020adffb06000000b003077bca2964mr2180418wrr.14.1683321899915; Fri, 05 May 2023 14:24:59 -0700 (PDT) Received: from stoup.. ([212.241.182.8]) by smtp.gmail.com with ESMTPSA id t14-20020a5d460e000000b003047ae72b14sm3426709wrq.82.2023.05.05.14.24.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 14:24:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 20/42] tcg/i386: Generalize multi-part load overlap test Date: Fri, 5 May 2023 22:24:25 +0100 Message-Id: <20230505212447.374546-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230505212447.374546-1-richard.henderson@linaro.org> References: <20230505212447.374546-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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 cfa2349b03..173f3c3172 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -2221,23 +2221,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: