From patchwork Wed Sep 25 17:11:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 830481 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1374:b0:367:895a:4699 with SMTP id q20csp856918wrz; Wed, 25 Sep 2024 10:14:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV4ee853by5uheKGhtEZ8RuAs+XswXKjnkZuETQW7/BaN4LuVDerHPh5mM/iB048nowQJy2Og==@linaro.org X-Google-Smtp-Source: AGHT+IGRa2rpQPuQZez9Xx8O+NeJq1/iGMSE2e31EQL37DmyQwmvhR6v3k5a6duBeGhzVoWubYHY X-Received: by 2002:a05:620a:4009:b0:7ac:e30e:f6f with SMTP id af79cd13be357-7ace744a45amr495496385a.43.1727284449268; Wed, 25 Sep 2024 10:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727284449; cv=none; d=google.com; s=arc-20240605; b=Z14grD/IUm5HIRwqwhRtusgyRuAQfcQwfOi3b5NgMUoGO4kIfm4cg+LXHxs7X26Oee W7jPiOwz0Cz6oyIn+8pKOwYCpeMBHeTUu4OyFh3DNTyoiBd0AON4xtrPJf5NZlMRfuJm whMnlFaPlkpxzjHQn+GHg/oVFBs+s6H6I57SK2YaxuPV0Vagz3+d7IXz034UFTOFSUqA CKRr3mBkAuz1rHsQRv2wO/P9zAlQGxY+XHkJe4kMrQCbhVUQ7zpwnO5iX2cyWP6fmdWa 1vn2i9NYIQexpg59c92puouoSnwR6kSrIP1l5VKRsY8gu/ZskFzoFrdL1ieMPx5AlDeI N4Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=KaJivYDlItR4YIDqMIuLxegmAwwZvWWIxpxaaVqdrBQ=; fh=jOpm9kmPAspKh5iBNE/fo3cA2AnxrIpta9f9jvC2IBE=; b=bYAPzxcAlJoLz3/9uPZbNbb5n3AQCNpBZmIhEzevPJ/qYBnTCtSLqt5pJ8yXcZ0Gcv 57ZqOZr7kFQ2Rc1eajNbhuswpsWUDU2tEzB22w/jeZdoPzoRvjrXlTDQ35ga1yQRG3wT UIcvB8jowWtMGa1ff/5NndCfEj8+7cHzuYLixN3WTKc/5WNHj0GrV43G90BIj5u7jaZw wHblCnG8xYC/tCwIIU9mHixs41Tt63cOPFc6wYQ3p08ppgKzuHX0dqZi+W5ZEzzDiU6+ 1wMHZnlsAuoz9dD7sormpbw/FtLhSPMKBjsOzFbWpPaDOr8aBf63pjqTt5Wc/CqR6w13 1COA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IR84kaqn; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7acde62e97fsi448149285a.585.2024.09.25.10.14.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Sep 2024 10:14:09 -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=IR84kaqn; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1stVYs-0001vP-9w; Wed, 25 Sep 2024 13:12:22 -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 1stVYR-0000Kx-Hb for qemu-devel@nongnu.org; Wed, 25 Sep 2024 13:11:55 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1stVYM-0000cF-QL for qemu-devel@nongnu.org; Wed, 25 Sep 2024 13:11:54 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42cba8340beso7769395e9.1 for ; Wed, 25 Sep 2024 10:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727284308; x=1727889108; 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=KaJivYDlItR4YIDqMIuLxegmAwwZvWWIxpxaaVqdrBQ=; b=IR84kaqn5iCqReAzD2i03JC82nHAz+os3aeXOEOw13yGB0wbCh+dKtFIAdpi7mEZS5 pqP29+QdceDMkzpAgAG+KeIbd4jdKelW67iixrLZRc34r6MQ2AF+pcJbXhG06Qkozu1E uvLV1YTw3AkzpJsmJ+7JaMsG9nPK2ERpeRCASG2FWCENKTpAwNNvtDiBCzchHV0HL/F3 lLpwg/QnKwr7txSrjYmemRRmhPQoXDH1TaXDj37gDoPsBIYzwHcsH0D5gtu1SUo6XJi1 jGXQS0+JobGJr/53mX44xUyslDSsTfYUvA4XYksocuZ+mmigX2hggZYrVSppAW1ooGuh YwVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727284308; x=1727889108; 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=KaJivYDlItR4YIDqMIuLxegmAwwZvWWIxpxaaVqdrBQ=; b=K6a8Q6ZUq6EBgaSSXx1NscTcMgKcJ/I0lHmZ/0r807Z4pOkM9tqyMz609NjKzEGsc6 cW1MsNGu+rMXGb/EKRQ378BQo517fLiVl+PC0BmDFPRuiDIQo717uks/7zJ+G81g8mtc BWxZiI9LP5+lSSfUY/9HJeLfXcRyX2YhhoM4SRCjIAljZSwl5b5R9+NGK55b9kJZhuSN NAYz7nzT4IU+ksEpGSwmekN02qID1E+zKMmYaX3lvEeumQJ7lPwfuCqPDNoQzH745SBe po0iZlbJGeSk7gkY8FBmulp33kwRaaD9mc3tvFpnqXYnKHhCFqSL/Plxtm8OFnISt4HU tvkQ== X-Gm-Message-State: AOJu0YxBL8PX7R0SQeEes8RluF98mCOysBqmd1Hs0JRElQ/tmUQ0th6o W6jTKDBq5wGq8JJD1pXsDxaPF1O0aJ2bZdNEJSHt+kJDfqzP3Z9IdvqGYrMk6hU= X-Received: by 2002:a05:600c:3542:b0:424:895c:b84b with SMTP id 5b1f17b1804b1-42f521cb7b9mr2431035e9.4.1727284308140; Wed, 25 Sep 2024 10:11:48 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e969f1fe4sm24113855e9.14.2024.09.25.10.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 10:11:44 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 4FA755FAAF; Wed, 25 Sep 2024 18:11:41 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Zhao Liu , "Edgar E. Iglesias" , Marcel Apfelbaum , Alexandre Iooss , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Mahmoud Mandour , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Richard Henderson , Paolo Bonzini , Eduardo Habkost , Pierrick Bouvier , Wainer dos Santos Moschetta , kvm@vger.kernel.org, Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-arm@nongnu.org, Peter Maydell , devel@lists.libvirt.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Marcelo Tosatti , Laurent Vivier , Yanan Wang , Thomas Huth , Beraldo Leal Subject: [PATCH 10/10] tests/tcg: enable basic testing for aarch64_be-linux-user Date: Wed, 25 Sep 2024 18:11:40 +0100 Message-Id: <20240925171140.1307033-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240925171140.1307033-1-alex.bennee@linaro.org> References: <20240925171140.1307033-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32e.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 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 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ée --- 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 aa7aae70fa..1aebf8ece0 100755 --- a/configure +++ b/configure @@ -1274,6 +1274,7 @@ probe_target_compiler() { target_arch=${1%%-*} case $target_arch in aarch64) container_hosts="x86_64 aarch64" ;; + aarch64_be) container_hosts="x86_64 aarch64" ;; alpha) container_hosts=x86_64 ;; arm) container_hosts="x86_64 aarch64" ;; hexagon) container_hosts=x86_64 ;; @@ -1303,6 +1304,10 @@ probe_target_compiler() { case $target_arch in # debian-all-test-cross architectures + aarch64_be) + container_image=debian-all-test-cross + container_cross_prefix=aarch64-linux-gnu- + ;; hppa|m68k|mips|riscv64|sparc64) container_image=debian-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..93c6074db1 --- /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") = fd; + register char * x1 __asm__("x1") = buf; + register int x2 __asm__("x2") = len; + register int x8 __asm__("x8") = __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") = ret; + register int x8 __asm__("x8") = __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 # Add the common build options CFLAGS+=-Wall -Werror -O0 -g -fno-strict-aliasing diff --git a/tests/tcg/aarch64_be/Makefile.target b/tests/tcg/aarch64_be/Makefile.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=$(SRC_PATH)/tests/tcg/aarch64_be +VPATH += $(AARCH64BE_SRC) + +AARCH64BE_TEST_SRCS=$(notdir $(wildcard $(AARCH64BE_SRC)/*.c)) +AARCH64BE_TESTS=$(AARCH64BE_TEST_SRCS:.c=) +#MULTIARCH_TESTS = $(MULTIARCH_SRCS:.c=) + +# We need to specify big-endian cflags +CFLAGS +=-mbig-endian -ffreestanding +LDFLAGS +=-nostdlib + +TESTS += $(AARCH64BE_TESTS)