From nobody Wed May  7 23:12:43 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass(p=none dis=none)  header.from=linaro.org
ARC-Seal: i=1; a=rsa-sha256; t=1733441112; cv=none;
	d=zohomail.com; s=zohoarc;
	b=YnaEg63IzpLuzVkPD8i2mdWTvjeF6DjXIEvITODbshRxyhrUesNn8TUAsAq8tu60GiscZoOfVCVSPmp1ryOlekX6xwLdwz/+8+o2SgNEPWbk+8wjxHV7aGBIO9FJBkTG+W0z+bJTTC99AwJVtFQqfC5I58GiZ2EZPWHdB/DJHPc=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1733441112;
 h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To;
	bh=NfTBm75o97Cz8/aU/8hyy/8ZcyfCCBeJMjQXzg2r+cU=;
	b=XW/pW8i8fLYfyVBsENbhzNthaZVwyMPDTUDkq+xDUo0y2mkGD6qBEHi6siQp552rmW2FPMfR8wG+ldL3qgMA5y+kUOPtzdrkjLgHspDjHPNHtFIPI7j/aLJJuA3kXmQnewxesUj0jYSAtG8GEs17QrOLIabWzWcmabRpJJFk14w=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass header.from=<philmd@linaro.org> (p=none dis=none)
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1733441112083453.9415368819929;
 Thu, 5 Dec 2024 15:25:12 -0800 (PST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tJLDG-0007Iq-T0; Thu, 05 Dec 2024 18:24:50 -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 <philmd@linaro.org>) id 1tJLDF-0007Id-6d
 for qemu-devel@nongnu.org; Thu, 05 Dec 2024 18:24:49 -0500
Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <philmd@linaro.org>) id 1tJLDD-0002Kn-NU
 for qemu-devel@nongnu.org; Thu, 05 Dec 2024 18:24:48 -0500
Received: by mail-wm1-x330.google.com with SMTP id
 5b1f17b1804b1-434a95095efso15908175e9.0
 for <qemu-devel@nongnu.org>; Thu, 05 Dec 2024 15:24:46 -0800 (PST)
Received: from localhost.localdomain (88-187-86-199.subs.proxad.net.
 [88.187.86.199]) by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-434da0d2738sm40030065e9.4.2024.12.05.15.24.43
 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
 Thu, 05 Dec 2024 15:24:44 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=linaro.org; s=google; t=1733441084; x=1734045884; darn=nongnu.org;
 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=NfTBm75o97Cz8/aU/8hyy/8ZcyfCCBeJMjQXzg2r+cU=;
 b=DeTL5FpYyAPcysikjB5Ar6SCl/XwB1baAEvvxzlvnN3oEnY8T31VJikhSgjaEQqkyw
 CPKpYBOSKkAEkTR023yzapmsF5O9NADLmoDWc9ns+Jdwg8IekQfFkyAAdA7SwwdDtEGj
 2rGd7Rg34NyMVnEqyskHgy7xcZbmhzsonLAgJav0DxDJ2Yb7BDjJMGPnr8SEiqYiOeFM
 XnY4ZvXqyA1aPGaL5RkRBOG74IW0kUhZpzmmflbsGu4DMsSnjHyiiHXRo3L5aFtCLf/Z
 VdcXNonq5VRVz584tomqFncdN0AMN13+FlllwXGK0A/lAGE265RiYPnHQLVSmgH7OV4j
 /UXw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1733441084; x=1734045884;
 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=NfTBm75o97Cz8/aU/8hyy/8ZcyfCCBeJMjQXzg2r+cU=;
 b=G+3QjAC92m7C+S413ymyZQ8pYCWnOX1D54RA7i6yXXbqeR8zRXKTaAtBosAXJFl5m/
 At9r3deWdy3kEEh8ZCwApRwFPejrDmC/aBPX9ZchG1UVG5Z9LKmMwCBSSSCJn5ZjWRvk
 BcBrQbaXmr+HPtF3dHz8/JyqzOVqlal9QimM0rMBv5qNZLcblQuP+3tArhwf4025S84k
 Idwz5vnP8jA2+cLi67bb6vQySGOGkWWJwVFedoQ4ncTexYFms1nfvLBGTkDuLDb2XTLw
 j/wezo1q8+oVApvOjRtrHGdRF5d3h2aC1fr2SWygcDFctXyOrcOPw3QFIvbQo5+T2Lp+
 ge6w==
X-Gm-Message-State: AOJu0YwET1AaWopaMN4Z+CvcbpvR0QxqSXuaJGl6GKL7omcrqsnEL8o0
 yGU3xzgGrpB0DDyp1h8XLu7dGyOSn2DDOeaZJFv8vbXBRgRY6a6w4L1MN+4vdpE+LY8vK8SljiK
 Z
X-Gm-Gg: ASbGncsZR5qBQ6R++WjjoGCDRaTcm+8GXNHKs78ySOqi9N62Cl7OovZDOvX8dxxNMBk
 gpg0ACimsY3ADX62dQE2+Vr3dg+psLOw4QqW2pgVZwB/J6+7uSJs4O3J89Sp0TZwH1B5wJ742KI
 O50gWO8vVe+aeoslhfrQlBHWMXAxvmRTN1d61Lv4rAg3m/6ucZz2pGpokL2nLwk/ILDGQkxCb4E
 2IBUBZPpGsRyh15rpMyf9E+UcydEcv1TsxpZk1bKG4syBNDi5QeJLQ5VF9+UL/q+0LuZkPTF6+s
 pW3Sibqw5FWO/vVSZYkcilE9
X-Google-Smtp-Source: 
 AGHT+IGYwORdv7cVAcXdnT9tMF6kG6nrqvNtI3Fu60roK8lzqPGsHrK0l2snrRN7Dqz3vDZW4E7lbQ==
X-Received: by 2002:a05:6000:1a88:b0:385:f3d8:66ab with SMTP id
 ffacd0b85a97d-3861bb7f79fmr3761920f8f.17.1733441084551;
 Thu, 05 Dec 2024 15:24:44 -0800 (PST)
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: Max Filippov <jcmvbkbc@gmail.com>,
 Richard Henderson <richard.henderson@linaro.org>,
 =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org>
Subject: [PATCH 1/2] target/xtensa: Implement xtensa_isa_is_big_endian()
Date: Fri,  6 Dec 2024 00:24:36 +0100
Message-ID: <20241205232437.85235-2-philmd@linaro.org>
X-Mailer: git-send-email 2.45.2
In-Reply-To: <20241205232437.85235-1-philmd@linaro.org>
References: <20241205232437.85235-1-philmd@linaro.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2a00:1450:4864:20::330;
 envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org
X-ZohoMail-DKIM: pass (identity @linaro.org)
X-ZM-MESSAGEID: 1733441112588116600

Xtensa internal fields are opaque, only accessible by
the Xtensa libisa. Implement xtensa_isa_is_big_endian()
to get vCPU endianness. This should be implemented in
libisa, not QEMU, but I couldn't figure out where to
contribute this.

Signed-off-by: Philippe Mathieu-Daud=C3=A9 <philmd@linaro.org>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
---
 include/hw/xtensa/xtensa-isa.h | 1 +
 target/xtensa/xtensa-isa.c     | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/include/hw/xtensa/xtensa-isa.h b/include/hw/xtensa/xtensa-isa.h
index a289531bdc8..1cb8e6ccb66 100644
--- a/include/hw/xtensa/xtensa-isa.h
+++ b/include/hw/xtensa/xtensa-isa.h
@@ -829,6 +829,7 @@ const char *xtensa_funcUnit_name(xtensa_isa isa, xtensa=
_funcUnit fun);
=20
 int xtensa_funcUnit_num_copies(xtensa_isa isa, xtensa_funcUnit fun);
=20
+bool xtensa_isa_is_big_endian(xtensa_isa isa);
=20
 #ifdef __cplusplus
 }
diff --git a/target/xtensa/xtensa-isa.c b/target/xtensa/xtensa-isa.c
index 630b4f9da1b..36eb4bcf3d4 100644
--- a/target/xtensa/xtensa-isa.c
+++ b/target/xtensa/xtensa-isa.c
@@ -1741,3 +1741,10 @@ int xtensa_funcUnit_num_copies(xtensa_isa isa, xtens=
a_funcUnit fun)
     CHECK_FUNCUNIT(intisa, fun, XTENSA_UNDEFINED);
     return intisa->funcUnits[fun].num_copies;
 }
+
+bool xtensa_isa_is_big_endian(xtensa_isa isa)
+{
+    xtensa_isa_internal *intisa =3D (xtensa_isa_internal *)isa;
+
+    return intisa->is_big_endian;
+}
--=20
2.45.2


From nobody Wed May  7 23:12:43 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass(p=none dis=none)  header.from=linaro.org
ARC-Seal: i=1; a=rsa-sha256; t=1733441136; cv=none;
	d=zohomail.com; s=zohoarc;
	b=FUHuHur2bx6zoCzbpVPLort9BmYPPBJkLJDdnCftib5oVKTWW4TmE9powHXtt94Qe1HA6FEAoB9V0XviYnXN9boSp0sNQzx7yB4EiqF7VNa9djI3JtRXwcd/WkQMw8FbwBrYjjGOVLjFaze/pb0XxxP4dC3E8hUei8ZGVm6dSiU=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1733441136;
 h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To;
	bh=DWYSs/XaajbkBmJgNxXc7L7hi1mF2tY7+Tqqie/8xoU=;
	b=BIoh0zOQPWGSkjNZtuq3cdGaAnM2VtfUcJzkm37jDNAE2liSddAeUR5qLC8ySJU1PxSF14yKDG4D5jvz3fyLNRRS32cxCVfWP7vGqcN5bkDjQVqw4uPbOXiYCpbG+GsFGTVH8KmrBx7wu+k2X5lUaENgncAt8yA6TH48liHW5n8=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass header.from=<philmd@linaro.org> (p=none dis=none)
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1733441136778159.29933968676448;
 Thu, 5 Dec 2024 15:25:36 -0800 (PST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tJLDO-0007JT-V8; Thu, 05 Dec 2024 18:24:58 -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 <philmd@linaro.org>) id 1tJLDI-0007J6-P9
 for qemu-devel@nongnu.org; Thu, 05 Dec 2024 18:24:54 -0500
Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <philmd@linaro.org>) id 1tJLDH-0002Lg-7r
 for qemu-devel@nongnu.org; Thu, 05 Dec 2024 18:24:52 -0500
Received: by mail-wm1-x32f.google.com with SMTP id
 5b1f17b1804b1-434aabd688fso10144115e9.3
 for <qemu-devel@nongnu.org>; Thu, 05 Dec 2024 15:24:50 -0800 (PST)
Received: from localhost.localdomain (88-187-86-199.subs.proxad.net.
 [88.187.86.199]) by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3861fd46cb2sm3118604f8f.62.2024.12.05.15.24.48
 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
 Thu, 05 Dec 2024 15:24:48 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=linaro.org; s=google; t=1733441089; x=1734045889; darn=nongnu.org;
 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=DWYSs/XaajbkBmJgNxXc7L7hi1mF2tY7+Tqqie/8xoU=;
 b=OlnkeQr+xi4PTKmayEKbWoHM1xkvTqW1PhPtiS/NAZuXCbDbcaHYuPW4+vHVmukwCz
 JnXcSmeu6MjTn8T2DCRs2cQsmJZibtxXqSebcJax5YNmWqvtUCQGyH1t+sjde9Ycakbe
 lP2AWkoC4i0U/0a3Avaza/g6UgLKY0w/TiWUQP4F55ObD2uDxahKJLffmKhmQMFVOCz5
 V4r2kPtsognMv1D0orYllZSN9dTol1VwgiBknN06uvQ6f6zpfKhV4L0KbJJAVHx2JNHr
 +C0sG0RDCsd9KToO10Og0SqJLNLbmsWhbFMSlsH25qyr/J0uQV+nIGtn+wIMBklFyGaD
 ZpBw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1733441089; x=1734045889;
 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=DWYSs/XaajbkBmJgNxXc7L7hi1mF2tY7+Tqqie/8xoU=;
 b=Rmw6pb80+HDffyCCTUA46ovOCfS2KADOF12Dl8XeJMjLcGU7JTQP4hOByuz5wXt81f
 AbALOGQcI04GdCKfFpPOlLPl7ZYpfezrtw46Wr8YS/vMA8un1oCwNWrqH2JHYxDTD51O
 HcKDs/XqkiOjH+gGkQyJCowWP4oN6J+eB+MjzKGh0Lomx2Qqss+1s2NzbaL1LEA7usVW
 nsj7WRkkkCBAqmp64Xb3a0/UI767IBA1FLgobWrLrpBv4LJITqzwB/9T32+qndQHZJMU
 /O630fZ/tsnbkrnbDd8uyK+aBik4IGJGsHhJrEroRT6AlTyBgxBFMfVm0tHXrrG0mIY4
 kMPw==
X-Gm-Message-State: AOJu0YyxKUFwP/wytjm5U51qXpz85lQVsDiSjRhrJ5YzI8Y+KyNouZTF
 XhNzPzrPoBWEcKhwUU4VF81/ibUtvpvxZUuMC+YY7ESO8j215iZ0Tz2R0MGFmHpkKMXKrelMtJ+
 R
X-Gm-Gg: ASbGncv/l0Q9Zm4r+JCIgIHSvcENz+c+Xwy+Ppxgx/o6G8lDcoG3RFrQUasjo5qOaBe
 5CucpQjNsbUAq382WgyhRDQDBOoVJOkcrNPtl5Ixk/NKcjLYAAcEf/T68/VsBw9IFp7x0tcgl0a
 scDy2CB4lYzZ9iNY0R/p4+R+ObdnBuSCPAyc66kAnZzfHOKx779IkRn3soHaPt7ULbU72uVhSf7
 5Uh6Qora9mtEWoTpvIMZd/J7OGH9mPAbfKL8GWf8EwgIx2v+Pc1r/+l8lASTvbPjYe1uN5UqY3j
 B0tDt8YFVyfRWY+97GhbHBUz
X-Google-Smtp-Source: 
 AGHT+IHmmZkqACBXjmZnxY5i4r6RiUqo7dXqrZNyzLWEtm+ttvy9BgMsAkBnCauLYfbsv7VuTI7sFg==
X-Received: by 2002:a05:600c:a46:b0:42c:b16e:7a22 with SMTP id
 5b1f17b1804b1-434ddeb5573mr8302945e9.12.1733441089513;
 Thu, 05 Dec 2024 15:24:49 -0800 (PST)
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: Max Filippov <jcmvbkbc@gmail.com>,
 Richard Henderson <richard.henderson@linaro.org>,
 =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org>
Subject: [PATCH 2/2] target/xtensa: Remove tswap() calls in semihosting
 simcall() helper
Date: Fri,  6 Dec 2024 00:24:37 +0100
Message-ID: <20241205232437.85235-3-philmd@linaro.org>
X-Mailer: git-send-email 2.45.2
In-Reply-To: <20241205232437.85235-1-philmd@linaro.org>
References: <20241205232437.85235-1-philmd@linaro.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2a00:1450:4864:20::32f;
 envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org
X-ZohoMail-DKIM: pass (identity @linaro.org)
X-ZM-MESSAGEID: 1733441138744116600

In preparation of heterogeneous emulation where cores with
different endianness can run concurrently, we need to remove
the tswap() calls -- which use a fixed per-binary endianness.

Get the endianness of the CPU accessed using the libisa
xtensa_isa_is_big_endian() call and replace the tswap() calls
by bswap() ones when necessary.

Signed-off-by: Philippe Mathieu-Daud=C3=A9 <philmd@linaro.org>
---
 target/xtensa/xtensa-semi.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/target/xtensa/xtensa-semi.c b/target/xtensa/xtensa-semi.c
index fa21b7e11fc..21d23e39de5 100644
--- a/target/xtensa/xtensa-semi.c
+++ b/target/xtensa/xtensa-semi.c
@@ -328,10 +328,17 @@ void HELPER(simcall)(CPUXtensaState *env)
             struct timeval tv =3D {0};
=20
             if (target_tv) {
+                bool cpu_big_endian =3D xtensa_isa_is_big_endian(env->conf=
ig->isa);
+                bool swap_needed =3D HOST_BIG_ENDIAN !=3D cpu_big_endian;
+
                 cpu_memory_rw_debug(cs, target_tv,
                         (uint8_t *)target_tvv, sizeof(target_tvv), 0);
-                tv.tv_sec =3D (int32_t)tswap32(target_tvv[0]);
-                tv.tv_usec =3D (int32_t)tswap32(target_tvv[1]);
+                if (swap_needed) {
+                    bswap32s(&target_tvv[0]);
+                    bswap32s(&target_tvv[1]);
+                }
+                tv.tv_sec =3D (int32_t)target_tvv[0];
+                tv.tv_usec =3D (int32_t)target_tvv[1];
             }
             if (fd < 3 && sim_console) {
                 if ((fd =3D=3D 1 || fd =3D=3D 2) && rq =3D=3D SELECT_ONE_W=
RITE) {
@@ -381,6 +388,8 @@ void HELPER(simcall)(CPUXtensaState *env)
             int argc =3D semihosting_get_argc();
             int str_offset =3D (argc + 1) * sizeof(uint32_t);
             int i;
+            bool cpu_big_endian =3D xtensa_isa_is_big_endian(env->config->=
isa);
+            bool swap_needed =3D HOST_BIG_ENDIAN !=3D cpu_big_endian;
             uint32_t argptr;
=20
             for (i =3D 0; i < argc; ++i) {
@@ -388,6 +397,9 @@ void HELPER(simcall)(CPUXtensaState *env)
                 int str_size =3D strlen(str) + 1;
=20
                 argptr =3D tswap32(regs[3] + str_offset);
+                if (swap_needed) {
+                    bswap32s(&argptr);
+                }
=20
                 cpu_memory_rw_debug(cs,
                                     regs[3] + i * sizeof(uint32_t),
--=20
2.45.2