From nobody Tue Apr 7 20:10:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@rwth-aachen.de; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1773246520; cv=none; d=zohomail.com; s=zohoarc; b=aBpu2yQbF680b6TEWx3dyfgyptHI4qF51wKPc4z14PV98WFUJ0R5F+LYZfipi+sy/s8ug9ylbBnjlUGrzbq0jOqig6xqWVY9XXD1H6UbioHFhKXovlkqjWIUeIM0ea8Sf6xdpoxtZhlR/Y6W/CQTGCNTRpOY425l9VmhATVfpc8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773246520; 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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=/FidnWFFs+3IBRV5H18XTmu7bClZ6RN25nhf0xepizY=; b=MqfNjCUicLo+anCJUnfu8cN2WN1IJjXiBhsCf4KLoa5cIWwcgT8qrQihLxDCa4MJdoxrmGFLM5+lql2ekoUE4OilxC8fBwXhk4NXHhaslJRD0TNb3YFYRmmpOM4JKnscN2ZKK1chsim24bh6zeJaFc08xGadriJDnM098rXlZLQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@rwth-aachen.de; 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= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773246520247252.80960150582882; Wed, 11 Mar 2026 09:28:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w0MQ7-000401-Rm; Wed, 11 Mar 2026 12:28:27 -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 1w0MPt-0003Wx-S3 for qemu-devel@nongnu.org; Wed, 11 Mar 2026 12:28:14 -0400 Received: from mail-out-3.itc.rwth-aachen.de ([2a00:8a60:1:e501::5:48]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0MPp-0006R0-43 for qemu-devel@nongnu.org; Wed, 11 Mar 2026 12:28:13 -0400 Received: from rwthex-s2-a.rwth-ad.de ([134.130.26.154]) by mail-in-3.itc.rwth-aachen.de with ESMTP; 11 Mar 2026 17:28:02 +0100 Received: from mkroening-air.local (137.226.124.87) by rwthex-s2-a.rwth-ad.de (2a00:8a60:1:e500::26:154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Wed, 11 Mar 2026 17:28:02 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=rwth-aachen.de; i=@rwth-aachen.de; q=dns/txt; s=20240516-RWTH; t=1773246489; x=1804782489; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=5SUlJtXBHyC2/mLKaRQMFjkp5YbpgrsvJ2WefT8MClk=; b=FDkXUwVssWEZisn5iTyfFC4B31mcK+SkteKjqpTaMSq01+ihHBcCI6TC hRSMTfox3N6mS60DbzhJm9gNYqQCwvXGAmLB36TJ72/vRJ/8a1j3MeEii CxLDiiWcB8GWIpSrpD8Gi7fRBN231E/0r0kgfFtoCTTz5KqOCzyvkZtON cM7gtwOFPIfpMUSvIQCS/j5V0G1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iGtY+6iDX1xK684D76vRzjnRaPpQTbZLwWm8L49m9pO2d/ f0W3XCGYVpzYvecyLx1vy5wSEmSNYUekFPOzOPWXca7lyUqeFO0qxli4d1f0YAwoo5K7W9yG fMwcA8LQR+y1umP7onnetJxlOMgPPGsBdZK0p1g5Wmx4fcOW4/fQ6jaoMQCmT52nN9SHbPXa 4wVZFKDbjyZOEEJYwxPTshg2r712hETcBUBwL6Rja8++XTSykpyyr/gNtvTdfSHQsNYhE3ev H3a/yHwCxoaOdrZxTftHneE3baRwXKlCN9KfFG+3tJ3v1KC2nFLM15MTgHgk6SJqwmBd+sKf iT4/QJr98De7neDR93wT1uyrXiCsxM0X9tWGvc9rgaXxcL8+waYAm0IZjpAbtU8s4kxXzNC/ keEg97zQzlmobGYTXa18raSpCm1fy8PIgcqfCIBUE4J7sfupKk1iRTASMslF7S65uAZAhnq3 CyKoTh7nO9WhIgRyLm7uFnLxT6hznTUcjMICszsdjrNxmtEiESNPuRENXCzAS58Ebuk IronPort-HdrOrdr: A9a23:ZfkSa64p5ZjR4T8ZdAPXwMvXdLJyesId70hD6qkRc3xom6mj/K qTdZsguCMc9wxhPU3I9ertBIClYVfxsaFY2rMwG5DKZniEhILLFvAB0WKK+VSJJ8SZzIBgPM xbEpSWZueeMbFyt7ef3DWF X-Talos-CUID: =?us-ascii?q?9a23=3A55qUlGkiWK7yxfMEvYA6FHQRRjnXOSXiyljfEh6?= =?us-ascii?q?zMEhSFI2uVE23+7Nc1PM7zg=3D=3D?= X-Talos-MUID: =?us-ascii?q?9a23=3ANNVTbw6GJ7mYTeJ3SHHufxoAxoxE/puhGVwQya5?= =?us-ascii?q?F4dLebh4tCxbasxiOF9o=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.23,113,1770591600"; d="scan'208";a="316496850" Date: Wed, 11 Mar 2026 17:27:14 +0100 Subject: [PATCH v3 1/3] include/hw/core: Rename virtio_is_big_endian to internal_is_big_endian MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260311-semihosting-cpu-tswap-v3-1-8e239575ec08@eonerc.rwth-aachen.de> References: <20260311-semihosting-cpu-tswap-v3-0-8e239575ec08@eonerc.rwth-aachen.de> In-Reply-To: <20260311-semihosting-cpu-tswap-v3-0-8e239575ec08@eonerc.rwth-aachen.de> To: CC: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , =?utf-8?q?Martin_Kr=C3=B6ning?= X-Mailer: b4 0.14.3 X-Originating-IP: [137.226.124.87] X-ClientProxiedBy: rwthex-s2-a.rwth-ad.de (2a00:8a60:1:e500::26:154) To rwthex-s2-a.rwth-ad.de (2a00:8a60:1:e500::26:154) 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:8a60:1:e501::5:48; envelope-from=martin.kroening@eonerc.rwth-aachen.de; helo=mail-out-3.itc.rwth-aachen.de X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: =?utf-8?q?Martin_Kr=C3=B6ning?= From: =?utf-8?q?Martin_Kr=C3=B6ning?= via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1773246523351154100 These functions are needed to do semihosting on CPUs that support runtime-configurable endiannes. This commit renames them and allows using them for semihosting, but makes sure to signal that these functions should not be used in other circumstances. Signed-off-by: Martin Kr=C3=B6ning Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/cpu-system.c | 6 +++--- hw/virtio/virtio.c | 2 +- include/hw/core/cpu.h | 4 ++-- include/hw/core/sysemu-cpu-ops.h | 6 +++--- target/arm/cpu.c | 4 ++-- target/ppc/cpu_init.c | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c index 4a91c3e8ec..273b9b7c22 100644 --- a/hw/core/cpu-system.c +++ b/hw/core/cpu-system.c @@ -127,10 +127,10 @@ int cpu_write_elf64_note(WriteCoreDumpFunction f, CPU= State *cpu, return (*cpu->cc->sysemu_ops->write_elf64_note)(f, cpu, cpuid, opaque); } =20 -bool cpu_virtio_is_big_endian(CPUState *cpu) +bool cpu_internal_is_big_endian(CPUState *cpu) { - if (cpu->cc->sysemu_ops->virtio_is_big_endian) { - return cpu->cc->sysemu_ops->virtio_is_big_endian(cpu); + if (cpu->cc->sysemu_ops->internal_is_big_endian) { + return cpu->cc->sysemu_ops->internal_is_big_endian(cpu); } return target_big_endian(); } diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 0ba734d0bc..8fcf6cfd0b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2323,7 +2323,7 @@ static enum virtio_device_endian virtio_default_endia= n(void) =20 static enum virtio_device_endian virtio_current_cpu_endian(void) { - if (cpu_virtio_is_big_endian(current_cpu)) { + if (cpu_internal_is_big_endian(current_cpu)) { return VIRTIO_DEVICE_ENDIAN_BIG; } else { return VIRTIO_DEVICE_ENDIAN_LITTLE; diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 7d2f4459d2..04e1f970ca 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -782,13 +782,13 @@ hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr a= ddr); int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs); =20 /** - * cpu_virtio_is_big_endian: + * cpu_internal_is_big_endian: * @cpu: CPU =20 * Returns %true if a CPU which supports runtime configurable endianness * is currently big-endian. */ -bool cpu_virtio_is_big_endian(CPUState *cpu); +bool cpu_internal_is_big_endian(CPUState *cpu); =20 /** * cpu_has_work: diff --git a/include/hw/core/sysemu-cpu-ops.h b/include/hw/core/sysemu-cpu-= ops.h index 877892373f..7b2d2d2610 100644 --- a/include/hw/core/sysemu-cpu-ops.h +++ b/include/hw/core/sysemu-cpu-ops.h @@ -77,13 +77,13 @@ typedef struct SysemuCPUOps { int (*write_elf64_qemunote)(WriteCoreDumpFunction f, CPUState *cpu, DumpState *s); /** - * @virtio_is_big_endian: Callback to return %true if a CPU which supp= orts + * @internal_is_big_endian: Callback to return %true if a CPU which su= pports * runtime configurable endianness is currently big-endian. * Non-configurable CPUs can use the default implementation of this me= thod. * This method should not be used by any callers other than the pre-1.0 - * virtio devices. + * virtio devices and the semihosting interface. */ - bool (*virtio_is_big_endian)(CPUState *cpu); + bool (*internal_is_big_endian)(CPUState *cpu); =20 /** * @legacy_vmsd: Legacy state for migration. diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 7e3e84b4bb..98d09ac065 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -756,7 +756,7 @@ static void arm_cpu_set_irq(void *opaque, int irq, int = level) } } =20 -static bool arm_cpu_virtio_is_big_endian(CPUState *cs) +static bool arm_cpu_internal_is_big_endian(CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -2299,7 +2299,7 @@ static const struct SysemuCPUOps arm_sysemu_ops =3D { .asidx_from_attrs =3D arm_asidx_from_attrs, .write_elf32_note =3D arm_cpu_write_elf32_note, .write_elf64_note =3D arm_cpu_write_elf64_note, - .virtio_is_big_endian =3D arm_cpu_virtio_is_big_endian, + .internal_is_big_endian =3D arm_cpu_internal_is_big_endian, .legacy_vmsd =3D &vmstate_arm_cpu, }; #endif diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 3d932a5642..191f5726f6 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7480,7 +7480,7 @@ static const struct SysemuCPUOps ppc_sysemu_ops =3D { .get_phys_page_debug =3D ppc_cpu_get_phys_page_debug, .write_elf32_note =3D ppc32_cpu_write_elf32_note, .write_elf64_note =3D ppc64_cpu_write_elf64_note, - .virtio_is_big_endian =3D ppc_cpu_is_big_endian, + .internal_is_big_endian =3D ppc_cpu_is_big_endian, .legacy_vmsd =3D &vmstate_ppc_cpu, }; #endif --=20 Git-155) From nobody Tue Apr 7 20:10:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@rwth-aachen.de; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1773246521; cv=none; d=zohomail.com; s=zohoarc; b=JSfcbB3H8+IN41LlSmAYHYeMJbsrfH+7fB8q4gvPC2r3or46MGQHc8WhL5RARSB60hfZgmlYSIOEjmG0GSmdX7b2W7OBlMKXRIkYf9XUxXR5Uh/vvns+3+9+zhcbj6AQ84rosuCivZFlrmrGqLa+P6ezi63Zon2/wid6OsOBfmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773246521; 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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=HvdsC2OEqhSJgPqR9PjoxKrsDSgd2LvI6izrrbZVRyA=; b=XasCDqmI1hKOeb6Rj8i5NU8sg7WGhnKMh8kj3RIlQddmfpqrtg9ceJX3nONtjKT7QhNDum68pcEIusjeeVEFNxQD9R6ZrU/r/3LiQy5ZUperilkSfgD0fbUqknQ0fMZ1IkgBvN9M5+B0EoUsrAIcBza2Sed7wLvvIjgln8Jy32Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@rwth-aachen.de; 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= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773246521060237.4265278210122; Wed, 11 Mar 2026 09:28:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w0MQ9-000490-CU; Wed, 11 Mar 2026 12:28:29 -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 1w0MPv-0003at-Gp for qemu-devel@nongnu.org; Wed, 11 Mar 2026 12:28:20 -0400 Received: from mail-out-4.itc.rwth-aachen.de ([2a00:8a60:1:e501::5:49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0MPt-0006QT-Mt for qemu-devel@nongnu.org; Wed, 11 Mar 2026 12:28:15 -0400 Received: from rwthex-s2-a.rwth-ad.de ([134.130.26.154]) by mail-in-4.itc.rwth-aachen.de with ESMTP; 11 Mar 2026 17:28:04 +0100 Received: from mkroening-air.local (137.226.124.87) by rwthex-s2-a.rwth-ad.de (2a00:8a60:1:e500::26:154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Wed, 11 Mar 2026 17:28:02 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=rwth-aachen.de; i=@rwth-aachen.de; q=dns/txt; s=20240516-RWTH; t=1773246494; x=1804782494; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=l6lweD7h74hVOVRYCejbvTTvCwLFBnbfNjOb2b63QAA=; b=d43PNJXqs8c/3BolPRRG1GZOHbmBgzfZLtvwgRbT7X0Ku8xSlQfszSvv 94X2LV8RR1i3gqzRExNWc1lGVa0OZkIB/aSdGwsjPqu0z7JCQpql0CKot GzWOQWFhHd5bZx+D72i0KvvgLMDfQdQgnDuvzIH+qgVQN5J+VI8ZZ7tmY Hm1jybXYfQ6+Q6Q1stmbTQ8kE8vkFXTjWoBDD6RMql4NbDEfgEHU3+kG6 K3brELzHps+oJmyUsdwI69Vg5DlLQzXLxLtR4f/EyRSZYsarJHgATPFvm RlnOFVSFuUJ94aroPoQuTtRzaCM3MuJ2/gj/N+eyodIbEA8kH+ETRgWGj w==; X-CSE-ConnectionGUID: 6H8uM6cUS2S1Z1kwrnGs1Q== X-CSE-MsgGUID: UXLbhgsbQkSa8nUNlsHXlA== X-IPAS-Result: =?us-ascii?q?A2C3BwD+lrFp/5oagoZagQmEJ4JbHQEBhDiqM4ddDwEBA?= =?us-ascii?q?QEBAQEBAQgBUQQBAYUHAo0iKDgTAQIEAQEBAQMCAwEBAQEBAQEBAQEBCwEBB?= =?us-ascii?q?gEBAQEBAQYFgSGGCVOGWwYjDwFGECUCJgICRhAGDgWDAoJ0sQKBMoEBhHzaB?= =?us-ascii?q?4EfAQsJAQoBgQouiFQBgXCEBIR6gk+BSoFHdnaFEIMOgmkEgzCHPgaLXwk/g?= =?us-ascii?q?QJ4LAFVEw0KCwcFYYEFAzUSKhVuMh2BIz4XM1gbBwWFHg+IcIE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uDS+zvvWKrPwLr1zdoMgy1knxilNoH1uA6ulfq WV98jzuiWYtN98YhsdcKm7Scq9qCrnhPxICOoqTNOftXfd11dARbsKhbcKpQePJ8TQzI9gPM xbH5SWZueRMbCQ4PyKhTWFLw== X-Talos-CUID: =?us-ascii?q?9a23=3A/l3N+WmjK5rsQhsgnM6RT+977/LXOSP9nGr1fUS?= =?us-ascii?q?FMjxSEY/MSkCK/ox/yvM7zg=3D=3D?= X-Talos-MUID: 9a23:w5qJ0Qtz4yH6ThQH482nuQFGPsdn+K6XC3sEwZM7nc2fFRx0EmLI X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.23,113,1770591600"; d="scan'208";a="24084765" Date: Wed, 11 Mar 2026 17:27:15 +0100 Subject: [PATCH v3 2/3] include/exec: Provide the cpu_internal_tswap() functions MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260311-semihosting-cpu-tswap-v3-2-8e239575ec08@eonerc.rwth-aachen.de> References: <20260311-semihosting-cpu-tswap-v3-0-8e239575ec08@eonerc.rwth-aachen.de> In-Reply-To: <20260311-semihosting-cpu-tswap-v3-0-8e239575ec08@eonerc.rwth-aachen.de> To: CC: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , =?utf-8?q?Martin_Kr=C3=B6ning?= X-Mailer: b4 0.14.3 X-Originating-IP: [137.226.124.87] X-ClientProxiedBy: rwthex-s2-a.rwth-ad.de (2a00:8a60:1:e500::26:154) To rwthex-s2-a.rwth-ad.de (2a00:8a60:1:e500::26:154) 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:8a60:1:e501::5:49; envelope-from=martin.kroening@eonerc.rwth-aachen.de; helo=mail-out-4.itc.rwth-aachen.de X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: =?utf-8?q?Martin_Kr=C3=B6ning?= From: =?utf-8?q?Martin_Kr=C3=B6ning?= via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1773246524212158500 These functions are needed to support semihosting on CPUs that support runtime-configurable endianness. They should not be used in other contexts. Signed-off-by: Martin Kr=C3=B6ning Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- include/exec/tswap.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/include/exec/tswap.h b/include/exec/tswap.h index 9e94fa0021..17ac544454 100644 --- a/include/exec/tswap.h +++ b/include/exec/tswap.h @@ -10,6 +10,7 @@ =20 #include "qemu/bswap.h" #include "qemu/target-info.h" +#include "hw/core/cpu.h" =20 /* * If we're in target-specific code, we can hard-code the swapping @@ -72,4 +73,39 @@ static inline void tswap64s(uint64_t *s) } #endif =20 +/* + * If we're in semihosting code, have to swap depending on the currently + * configured endianness of the CPU. These functions should not be used in + * other contexts. + */ +#define cpu_internal_needs_bswap(cpu) \ + (HOST_BIG_ENDIAN !=3D cpu_internal_is_big_endian(cpu)) + +static inline uint16_t cpu_internal_tswap16(CPUState *cpu, uint16_t s) +{ + if (cpu_internal_needs_bswap(cpu)) { + return bswap16(s); + } else { + return s; + } +} + +static inline uint32_t cpu_internal_tswap32(CPUState *cpu, uint32_t s) +{ + if (cpu_internal_needs_bswap(cpu)) { + return bswap32(s); + } else { + return s; + } +} + +static inline uint64_t cpu_internal_tswap64(CPUState *cpu, uint64_t s) +{ + if (cpu_internal_needs_bswap(cpu)) { + return bswap64(s); + } else { + return s; + } +} + #endif /* TSWAP_H */ --=20 Git-155) From nobody Tue Apr 7 20:10:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@rwth-aachen.de; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1773246521; cv=none; d=zohomail.com; s=zohoarc; b=VwN1ZBnLZ/5OxhNHdWIbKCbmOxt64wZCzMS8fdREKmEoWn8MldP3q+P0hFJ3SfzQnapJnSfg4S/khYlBQEWjRzKD82yQCpqKCPsEOlqiBjo7usUGdBp170PyuJv3/z+p6Vu9n5sTiSIY6iJe1d60ujaYuU2nUwZ06PDldl5pYXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773246521; 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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=hyinsbJD4F7+ncJVnimeHRSQI4oXVarBpKS+FimEa0U=; b=nbKhzTw8+b0nLAJqCJ6tC0E8YdWKg1Y6iev2PzoQuJx987YcPrzkfsQncYuL4L0UFJBJu4DvCNvbR/bpozrUToXvOVHOIWJ4Dq28gCT2yBgIzauQCprZxSpSYvGS0vxUDUF8vAMXVWsyAHnqTgJ2+LIt6+yWi3MgDDdSbi7DYfw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@rwth-aachen.de; 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= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773246521538680.14488731239; Wed, 11 Mar 2026 09:28:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w0MQ6-0003tX-RS; Wed, 11 Mar 2026 12:28:26 -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 1w0MPs-0003Wm-Lq for qemu-devel@nongnu.org; Wed, 11 Mar 2026 12:28:14 -0400 Received: from mail-out-2a.itc.rwth-aachen.de ([2a00:8a60:1:e501::5:45]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0MPo-0006SA-Qm for qemu-devel@nongnu.org; Wed, 11 Mar 2026 12:28:11 -0400 Received: from rwthex-s2-a.rwth-ad.de ([134.130.26.154]) by mail-in-2a.itc.rwth-aachen.de with ESMTP; 11 Mar 2026 17:28:03 +0100 Received: from mkroening-air.local (137.226.124.87) by rwthex-s2-a.rwth-ad.de (2a00:8a60:1:e500::26:154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Wed, 11 Mar 2026 17:28:03 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=rwth-aachen.de; i=@rwth-aachen.de; q=dns/txt; s=20240516-RWTH; t=1773246489; x=1804782489; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=+lX0kQwVmxvfq4f4pP95/st/xJ6ocK16Un5I4Y4JhL4=; b=XqWHLgrJHPZJFmyho229Q7JlEVvV16Qay9ia1q8RzHXVyCR4GEaN05MH khSGe8Zb2pO13jaMvbIPvA/3oh/qp9D+rfimvM+mvCNJOGIUfp6c0BjPH zylltd6OVygLsTIVsud3Z3iYGtyJr2/GcqBDctBW/InwFiRpa+haTwyIg lLffzVr79aLRtR2myR3VFkQFhEwiO0N/dAmvgZJad9IvSq7e4+M1GVW+O Ti+QuS8ad/GMs5fekACWitrzrNleZdgGDkiW/nj88isRhnm+W54kzTOeC 3VBhaiZH5bYDkeHlJ9sPgPDUfGPI1yYz34luH/6RfDbc7Q20AzB+agSLT g==; X-CSE-ConnectionGUID: EcBXGUCvRPmmFar4uN/a4w== X-CSE-MsgGUID: tSPFDkqrRfaiu4dblL2O3A== X-IPAS-Result: =?us-ascii?q?A2DOBwD+lrFp/5oagoZagQmEJ3GBah0BAYQ4qjOBWYYED?= =?us-ascii?q?wEBAQEBAQEBAQgBSgcEAQGCE4IuRgKNIig4EwECBAEBAQEDAgMBAQEBAQEBA?= =?us-ascii?q?QEBAQsBAQYBAQEBAQEGBYEhhglGDYZbBiMPAUYQJQImAgJGEAYOBYMCAYJzF?= =?us-ascii?q?AawaIEygQGEfNoHgR8BBQYJAQoBgQouiFQBgXCEBIR6gk+BSoFHdnaCYQICg?= =?us-ascii?q?iuDDoJpBIIiehSMEIcTCT+BAngsAVUTDQoLBwVhgQUDNRIqFW4yHYEjPhczW?= =?us-ascii?q?BsHBYUeD4hwgTsEI4ERgykDCxgNSBEsNxQbQQFuB411PYI0exMsIoFyl0SvV?= =?us-ascii?q?geCOIFnjB6VVAEyl2CTCy6HZZBzigqDf5ZQhD0CBAIEBQIYgX+BaQ4HcYM2U?= =?us-ascii?q?hcCD5IhyD93AjoCBwEKAQEDCYI5kBEBgRwBAQ?= IronPort-Data: A9a23:6wvEEqyx7dPdnh0tGdp6t+cWxyrEf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spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.23,113,1770591600"; d="scan'208";a="178978787" Date: Wed, 11 Mar 2026 17:27:16 +0100 Subject: [PATCH v3 3/3] semihosting/uaccess: Use the cpu_internal_tswap() functions MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260311-semihosting-cpu-tswap-v3-3-8e239575ec08@eonerc.rwth-aachen.de> References: <20260311-semihosting-cpu-tswap-v3-0-8e239575ec08@eonerc.rwth-aachen.de> In-Reply-To: <20260311-semihosting-cpu-tswap-v3-0-8e239575ec08@eonerc.rwth-aachen.de> To: CC: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , =?utf-8?q?Martin_Kr=C3=B6ning?= X-Mailer: b4 0.14.3 X-Originating-IP: [137.226.124.87] X-ClientProxiedBy: rwthex-s2-a.rwth-ad.de (2a00:8a60:1:e500::26:154) To rwthex-s2-a.rwth-ad.de (2a00:8a60:1:e500::26:154) 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:8a60:1:e501::5:45; envelope-from=martin.kroening@eonerc.rwth-aachen.de; helo=mail-out-2a.itc.rwth-aachen.de X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: =?utf-8?q?Martin_Kr=C3=B6ning?= From: =?utf-8?q?Martin_Kr=C3=B6ning?= via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1773246524044158500 The semihosting ABI [1] states: > Multi-byte values in memory must be formatted as pure little-endian or pu= re > big-endian to match the endianness mapping configuration of the processor. This commits ensures that semihosting data is properly byte-swapped if the guest's CPU is currently in a different runtime-configurable endianness than the host's CPU. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3258 Buglink: https://github.com/taiki-e/semihosting/issues/18 [1]: https://github.com/ARM-software/abi-aa/blob/2025Q1/semihosting/semihos= ting.rst#the-semihosting-interface Signed-off-by: Martin Kr=C3=B6ning Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- include/semihosting/uaccess.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/semihosting/uaccess.h b/include/semihosting/uaccess.h index 2093a49827..0911e3b31d 100644 --- a/include/semihosting/uaccess.h +++ b/include/semihosting/uaccess.h @@ -28,7 +28,7 @@ ({ uint64_t val_ =3D 0; \ int ret_ =3D cpu_memory_rw_debug(env_cpu(env), (addr), \ &val_, sizeof(val_), 0); \ - (val) =3D tswap64(val_); ret_; }) + (val) =3D cpu_internal_tswap64(cs, val_); ret_; }) =20 /** * get_user_u32: @@ -39,7 +39,7 @@ ({ uint32_t val_ =3D 0; \ int ret_ =3D cpu_memory_rw_debug(env_cpu(env), (addr), \ &val_, sizeof(val_), 0); \ - (val) =3D tswap32(val_); ret_; }) + (val) =3D cpu_internal_tswap32(cs, val_); ret_; }) =20 /** * get_user_u8: @@ -65,7 +65,7 @@ * Returns: 0 on success, -1 on error. */ #define put_user_u64(val, addr) \ - ({ uint64_t val_ =3D tswap64(val); \ + ({ uint64_t val_ =3D cpu_internal_tswap64(cs, val); \ cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); = }) =20 /** @@ -74,7 +74,7 @@ * Returns: 0 on success, -1 on error. */ #define put_user_u32(val, addr) \ - ({ uint32_t val_ =3D tswap32(val); \ + ({ uint32_t val_ =3D cpu_internal_tswap32(cs, val); \ cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); = }) =20 /** --=20 Git-155)