From nobody Wed Oct 23 00:30:06 2024 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=1729594726; cv=none; d=zohomail.com; s=zohoarc; b=c+tKA5Uyx8xxCPE31lF0Tn3YROr8uOvmq3O7Sva0PVCF2+ZJj/ii5fAEoIsLCi05l2/J4XNaDCB8xBIqgL6obSkavdHZroPcDoiJvJEtek1iA9T4GTX6Mr9W18yttSabjIIYNvsQl/u9gR70cgT3i6Mxn0aMKpSFU1K0aQW63gM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729594726; 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=pf3uq1o/PXtMWzbvWkPU0TjSlCT93/aG9VyjOMqKoJo=; b=KuOiLxhObn04TXLpmt00ivM6srNE8ldIlF8M7CvhVdBNqo6okureZbm03Rf0OJ2OYQcBRfe9whyFkuNtGKP+YXh4n6yQQlnwJPos1Lio0UX+qSarxbR8e2COakJoIN6hz2CkUsioVzOUVoWMyrPNsiU8eWzcAjPwWp9tuwOy3Fg= 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= (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 1729594726969456.63217210226696; Tue, 22 Oct 2024 03:58:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3CZi-0002cK-6w; Tue, 22 Oct 2024 06:57: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 1t3CZ2-0001p8-Hm for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:56:36 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3CZ0-000257-O1 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 06:56:36 -0400 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5c941623a5aso10852828a12.0 for ; Tue, 22 Oct 2024 03:56:33 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a9155a1c9sm323018666b.129.2024.10.22.03.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 03:56:28 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C52CB5FBDC; Tue, 22 Oct 2024 11:56:15 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729594592; x=1730199392; 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=pf3uq1o/PXtMWzbvWkPU0TjSlCT93/aG9VyjOMqKoJo=; b=SrLSuTCGrnU2yecchuPfJahtlADKRbnkyk0UZHBIlvm4AWbVsc6HUJvxBwHhRvFfv/ FkSXuwhrfbssP6VN6Gz8WLfP33mw0yyzPfMlXteyUlzgxwXVb+j+Z97WPXp6C7sVC9rK r5AhPYP6yzGwbYFTG4Czfa7wGGIX7R5dCghKvUd17aqC/rM4qSDLz1DJfabXMfraHdwG KyTDBNb+fbi7nP8D/96/Ya3irymygw7jA58X+17u08LF6SbVWk+maEoUK7I1yqGSC6Lz SVptKbE8YYbN2kJxnPcYgqSpkFy2gZMPqSZVJGGo8e71FCkjKnNIjssERA0cJ8pyrINS XRRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729594592; x=1730199392; 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=pf3uq1o/PXtMWzbvWkPU0TjSlCT93/aG9VyjOMqKoJo=; b=mSSUILpojNz7U8/cY07phLHKBopj5xTQQva0iS4Me46m8z3R1KWJQxRW1EIcYhBPlb bckrdw4Ndy97RAho8J/foE8AblRx3YyXDhKix5VUgY6HFn5lBDpA0mevGuZwoz4Gu7Fn nHtd/SRmU+kZ3HEIZ1JJ6tc1pKMViNnvfBH3vZcMJH5J5kXSKmI7KV4Ft5rWsaTi8kZI tg3yUOSbpdaBYQdrlc8UMwHJOIaY8u9FWcE6Jts9a4q2RbuYhiaQ5czU9XnvSGgJ4uvN Qtf8MopDapLPASpZmzkXHeywLDWsHMEK47iYhSh7GNObci3KOxiTa6Rq9TxfMQxaPAYk 8K3A== X-Gm-Message-State: AOJu0YzszIXRb6k4vO4Jcw0bU4cbLnHF0bn9P5LT06OKxlIbfF9q/B14 qLDB8yCugW5+O1oNNSlaOMIG1hNTmKBPvyfaJsidRKK2cZFzgk/yv6G4ZPwGKdg= X-Google-Smtp-Source: AGHT+IFr+0mLMKe2JQJOUJSSxtHXWPXM2EDoaQ4nyTBJKccw5XUwjD1MaeL5ICuPvGV4e9NH5KWjRQ== X-Received: by 2002:a17:906:c116:b0:a9a:1575:23e3 with SMTP id a640c23a62f3a-a9aaa5428e4mr236057266b.19.1729594592209; Tue, 22 Oct 2024 03:56:32 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Beraldo Leal , Laurent Vivier , Wainer dos Santos Moschetta , Mahmoud Mandour , Jiaxun Yang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Yanan Wang , Thomas Huth , John Snow , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-arm@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , devel@lists.libvirt.org, Cleber Rosa , kvm@vger.kernel.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alexandre Iooss , Peter Maydell , Richard Henderson , Riku Voipio , Zhao Liu , Marcelo Tosatti , "Edgar E. Iglesias" , Marcel Apfelbaum , Pierrick Bouvier , Paolo Bonzini Subject: [PATCH v2 13/20] tests/tcg: enable basic testing for aarch64_be-linux-user Date: Tue, 22 Oct 2024 11:56:07 +0100 Message-Id: <20241022105614.839199-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241022105614.839199-1-alex.bennee@linaro.org> References: <20241022105614.839199-1-alex.bennee@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::52f; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1729594727303116600 We didn't notice breakage of aarch64_be because we don't have any TCG tests for it. However while the existing aarch64 compiler can target big-endian builds no one packages a BE libc. Instead we bang some rocks together to do the most basic of hello world with a nostdlib syscall test. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- v2 - fix checkpatch complaints --- configure | 5 ++++ tests/tcg/aarch64_be/hello.c | 35 ++++++++++++++++++++++++++++ tests/tcg/Makefile.target | 7 +++++- tests/tcg/aarch64_be/Makefile.target | 17 ++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/aarch64_be/hello.c create mode 100644 tests/tcg/aarch64_be/Makefile.target diff --git a/configure b/configure index 72d1a94225..7dd3400ccb 100755 --- a/configure +++ b/configure @@ -1418,6 +1418,7 @@ probe_target_compiler() { target_arch=3D${1%%-*} case $target_arch in aarch64) container_hosts=3D"x86_64 aarch64" ;; + aarch64_be) container_hosts=3D"x86_64 aarch64" ;; alpha) container_hosts=3Dx86_64 ;; arm) container_hosts=3D"x86_64 aarch64" ;; hexagon) container_hosts=3Dx86_64 ;; @@ -1447,6 +1448,10 @@ probe_target_compiler() { case $target_arch in # debian-all-test-cross architectures =20 + aarch64_be) + container_image=3Ddebian-all-test-cross + container_cross_prefix=3Daarch64-linux-gnu- + ;; hppa|m68k|mips|riscv64|sparc64) container_image=3Ddebian-all-test-cross ;; diff --git a/tests/tcg/aarch64_be/hello.c b/tests/tcg/aarch64_be/hello.c new file mode 100644 index 0000000000..a9b2ab45de --- /dev/null +++ b/tests/tcg/aarch64_be/hello.c @@ -0,0 +1,35 @@ +/* + * Non-libc syscall hello world for Aarch64 BE + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#define __NR_write 64 +#define __NR_exit 93 + +int write(int fd, char *buf, int len) +{ + register int x0 __asm__("x0") =3D fd; + register char *x1 __asm__("x1") =3D buf; + register int x2 __asm__("x2") =3D len; + register int x8 __asm__("x8") =3D __NR_write; + + asm volatile("svc #0" : : "r"(x0), "r"(x1), "r"(x2), "r"(x8)); + + return len; +} + +void exit(int ret) +{ + register int x0 __asm__("x0") =3D ret; + register int x8 __asm__("x8") =3D __NR_exit; + + asm volatile("svc #0" : : "r"(x0), "r"(x8)); + __builtin_unreachable(); +} + +void _start(void) +{ + write(1, "Hello World\n", 12); + exit(0); +} diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 2da70b2fcf..9722145b97 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -103,9 +103,14 @@ ifeq ($(filter %-softmmu, $(TARGET)),) # then the target. If there are common tests shared between # sub-targets (e.g. ARM & AArch64) then it is up to # $(TARGET_NAME)/Makefile.target to include the common parent -# architecture in its VPATH. +# architecture in its VPATH. However some targets are so minimal we +# can't even build the multiarch tests. +ifneq ($(filter $(TARGET_NAME),aarch64_be),) +-include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target +else -include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target +endif =20 # Add the common build options CFLAGS+=3D-Wall -Werror -O0 -g -fno-strict-aliasing diff --git a/tests/tcg/aarch64_be/Makefile.target b/tests/tcg/aarch64_be/Ma= kefile.target new file mode 100644 index 0000000000..297d2cf71c --- /dev/null +++ b/tests/tcg/aarch64_be/Makefile.target @@ -0,0 +1,17 @@ +# -*- Mode: makefile -*- +# +# A super basic AArch64 BE makefile. As we don't have any big-endian +#l ibc available the best we can do is a basic Hello World. + +AARCH64BE_SRC=3D$(SRC_PATH)/tests/tcg/aarch64_be +VPATH +=3D $(AARCH64BE_SRC) + +AARCH64BE_TEST_SRCS=3D$(notdir $(wildcard $(AARCH64BE_SRC)/*.c)) +AARCH64BE_TESTS=3D$(AARCH64BE_TEST_SRCS:.c=3D) +#MULTIARCH_TESTS =3D $(MULTIARCH_SRCS:.c=3D) + +# We need to specify big-endian cflags +CFLAGS +=3D-mbig-endian -ffreestanding +LDFLAGS +=3D-nostdlib + +TESTS +=3D $(AARCH64BE_TESTS) --=20 2.39.5