From patchwork Thu Jan 26 04:37:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 647045 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp58093pvb; Wed, 25 Jan 2023 20:39:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXt9nq4cgOUDTzwRqJwQhf3MAmduUG3WVpk9cLfBEEIZdAcObavhoePW5d2twMQ5szVIIBmc X-Received: by 2002:ac8:6643:0:b0:3b4:14c8:8e69 with SMTP id j3-20020ac86643000000b003b414c88e69mr44531507qtp.38.1674707992637; Wed, 25 Jan 2023 20:39:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674707992; cv=none; d=google.com; s=arc-20160816; b=KrGSSdhp4Elk+cpmjtd/75oSpFrXJb6XpBaGDInTKQQ34M2Tj6CEkTavgAi8Q/pgfu UV33cQWmsK5j6aLqjtrevdY+iQrhYxMiRpTy0voCuAbelL3pwk3Z7ADy0tMwgMXNNZV3 N61pyWDS1DzWy9mMfvyV8Fs0qcUjEZbJa61Lii/WlzHaN4D3jNaxOt5CN/QxNUE87LOc bVyYnbdkDuv0YwC4RSaL4cS4knHRM/TRdYMpYBNebghgZ3ncTcysIYSfys/T9oJ2+gwU tkTiIAqmfmtYs9Q2eOio/gB8aIFTyg+bNkzcHr4IsoIpTdBitQqz281hgiBL5z/w8zsD Bn+A== 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=DFQ2aG+VnTqrFSc5ewVcTvqiqhyOxzsEeJCA6dzv8VM=; b=rqGI24MY+BykVSKY1957GH64BDDLqvT4lTQhldQ67WLHq51926EjNkiu14fcbjoF9F ubvAWCjGfxZV8L6Vp0vjelsCy+NgyjEZwTT/iRHPAjwKOoXYi7c412Pa4sQWSS2HmLTK joIiAu9YnDmff7Z8BnvihPecmYj2MuhM28PjCJn2OO8aip+oEh108K+mHHif+nFhbcPj yPJEfkCSGz/cG/0QaIhEo/DhJ72ZHS0zTTCdP65Skpjjsr3hIuYa8GTkhaX4E29ExybM pVuMCfd1RCvC2aruuurgqB5+DYVcb+gqwyzVc4ErHohtEz6VoSt6kl9OelSFgtifPeEx IXRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BkLKeQO0; 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 d14-20020ae9ef0e000000b00708eb13b268si374492qkg.269.2023.01.25.20.39.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jan 2023 20:39: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=BkLKeQO0; 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 1pKu2B-0000Ak-Fk; Wed, 25 Jan 2023 23:38:47 -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 1pKu2A-00009c-Ae for qemu-devel@nongnu.org; Wed, 25 Jan 2023 23:38:46 -0500 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKu28-0004Rg-Pb for qemu-devel@nongnu.org; Wed, 25 Jan 2023 23:38:46 -0500 Received: by mail-pj1-x1035.google.com with SMTP id z1-20020a17090a66c100b00226f05b9595so756540pjl.0 for ; Wed, 25 Jan 2023 20:38:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=DFQ2aG+VnTqrFSc5ewVcTvqiqhyOxzsEeJCA6dzv8VM=; b=BkLKeQO0oYsSeC6knVpG1IG77MXOVvALgjfEkIQFFp/0mDGmx8HqiB9Se6GohpkjXA DzIyqRz6en1gnhqWOEOouXieCd9ALUPtd4aQlfQ85kC2Gh418DWoGvmwEHiY3/2cvd0v zFQ2SICXNUNRbM8FGj08SQg0dYbiFyE4mn44M92Ctb6xLCYCR1OoFv2M039kShWZ8iuB lk8l4s70P3fHk4Xgq2GuGWlfKHJrYWJuyQWZW81gYyXDVphRy7d8ZaR9jekS17I1EG3Q N4/LQH6gVh7/iYc7erWBm+znxyae6dcxG1bjYI6ca8YxzoUlo21ONS6nXcbLf7n9BTqs nbDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=DFQ2aG+VnTqrFSc5ewVcTvqiqhyOxzsEeJCA6dzv8VM=; b=fBps2MjuQCQpbbXQiVtI7CWPkAMCAnqYGB2q9WcxeEo62YoSfx/qvS0bokIQI2Iwqc ZBu/qhirnWYnoulJ70c6c7XkSWdVWMV6BTNXYmUsSdJGIw1H0YKwerpOyvCrPQ8B327R vKLmJtp4PzAe+K2EEahoUUI2ndPnfDmyTWvioZ7SncioXWieNJ0jSnJ2nUGyiS29Rqnh jhGUGJRFnQyLVKIQFPfjUlH14CrnYwG8ARylyXb4FoXIweCPkGNdy94H0Tg9zRWFKTvr 8nHP4c7tnEXbjR8Dz+wnp/ou/+SzX5uI1v7q7DTI0GOGHVf2Rt+8I95PUBVpbCPUy7D0 M7Kg== X-Gm-Message-State: AO0yUKW1x0uEAEnIcg7sEsn8bsIe/Y7wfWRBcbrjwpX2GaQDS2zuSp4I V1GgRS+gg+3l+D9oDabXCB6tdmtneSYnRH1zdLk= X-Received: by 2002:a17:90b:1d91:b0:22b:ed4a:c46e with SMTP id pf17-20020a17090b1d9100b0022bed4ac46emr8942662pjb.30.1674707923426; Wed, 25 Jan 2023 20:38:43 -0800 (PST) Received: from stoup.. (rrcs-173-197-98-118.west.biz.rr.com. [173.197.98.118]) by smtp.gmail.com with ESMTPSA id s62-20020a17090a69c400b00228e56d375asm233376pjj.33.2023.01.25.20.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 20:38:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v5 10/36] tcg/tci: Fix big-endian return register ordering Date: Wed, 25 Jan 2023 18:37:58 -1000 Message-Id: <20230126043824.54819-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126043824.54819-1-richard.henderson@linaro.org> References: <20230126043824.54819-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.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 expect the backend to require register pairs in host-endian ordering, thus for big-endian the first register of a pair contains the high part. We were forcing R0 to contain the low part for calls. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- tcg/tci.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tcg/tci.c b/tcg/tci.c index 05a24163d3..eeccdde8bc 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -520,27 +520,28 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, ffi_call(pptr[1], pptr[0], stack, call_slots); } - /* Any result winds up "left-aligned" in the stack[0] slot. */ switch (len) { case 0: /* void */ break; case 1: /* uint32_t */ /* + * The result winds up "left-aligned" in the stack[0] slot. * Note that libffi has an odd special case in that it will * always widen an integral result to ffi_arg. */ - if (sizeof(ffi_arg) == 4) { - regs[TCG_REG_R0] = *(uint32_t *)stack; - break; - } - /* fall through */ - case 2: /* uint64_t */ - if (TCG_TARGET_REG_BITS == 32) { - tci_write_reg64(regs, TCG_REG_R1, TCG_REG_R0, stack[0]); + if (sizeof(ffi_arg) == 8) { + regs[TCG_REG_R0] = (uint32_t)stack[0]; } else { - regs[TCG_REG_R0] = stack[0]; + regs[TCG_REG_R0] = *(uint32_t *)stack; } break; + case 2: /* uint64_t */ + /* + * For TCG_TARGET_REG_BITS == 32, the register pair + * must stay in host memory order. + */ + memcpy(®s[TCG_REG_R0], stack, 8); + break; default: g_assert_not_reached(); }