From nobody Mon Feb 9 23:42:11 2026 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=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1682463003; cv=none; d=zohomail.com; s=zohoarc; b=hS5yqebDrTx2EbTQxlWDMFVhS4IDobmQKapTwAm45IBGvt1Dsf+RBW/yY+tnxYUMEnKHICp4JBm6y2DlavfDZIofgQXxIu+eJ05b7iZ/gEXz/ZvftBcR9RTQ4E4AeeuXKHWsVcTkwbwP6mEgZGE0hA7Te0TlB88FRxqcu0P/Pzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682463003; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c0dsHYRrvkSdXZi0MVl3rfX6Pp3omRtPpTBIqJ3lt5c=; b=GR2eA+jl6Ht7DDK/1WurmCjbKA8LkvC0DUEdqRoQ3CFzSJZ/kju61Ow8vHGfouqWpIZlZLbB4hz604VDBikGPINiyWXM4Znhb3IBj2ipEKczqnpmVd24XzNxXZbkYwcVS4vIDNgoENxF8/pIuSvUMYu/5wOKan12DyFlOGpbBlc= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682463002979530.6002951184523; Tue, 25 Apr 2023 15:50:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prRT9-0002ZW-Oy; Tue, 25 Apr 2023 18:49:07 -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 1prRT8-0002Yf-63; Tue, 25 Apr 2023 18:49:06 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1prRT5-00045A-3J; Tue, 25 Apr 2023 18:49:05 -0400 Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33PMc5fO023142; Tue, 25 Apr 2023 22:48:59 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3q6q6rsn4v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Apr 2023 22:48:59 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33PMeUr6004902; Tue, 25 Apr 2023 22:48:58 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3q6q6rsn48-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Apr 2023 22:48:58 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 33PLdLkT019191; Tue, 25 Apr 2023 22:48:56 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3q477720m9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Apr 2023 22:48:56 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 33PMmsLc34406870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Apr 2023 22:48:54 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 729FA20043; Tue, 25 Apr 2023 22:48:54 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB87F20040; Tue, 25 Apr 2023 22:48:53 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.10.36]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 25 Apr 2023 22:48:53 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=c0dsHYRrvkSdXZi0MVl3rfX6Pp3omRtPpTBIqJ3lt5c=; b=OC8ZLWf8MMq8fwtRwx++2TZHVs7fLm7lBpR612n3tdHJPMfg930TIgovxiqZfI/zyohD mGeDAR4L+NUxXMEo4X+frIez5nxgfSqyM3+WufP0ZbYkiEOM/LsSuu+mrw33txb4yhhT U50Iq1WKDMW+uF+5lGLRlyXJwIIaBIm5MWXRv6MNgNpIiMu8aQu0xOi8ciY2l+45NoOY glvna5qjTkokcRsm16FSmt0tj4umY55Gqki8aJoqFLvt1Rj6fRAlqDPe1bIVH2zklIUz QskruvDRjFlA+e98UbhRphR6HW1kcGSBVGlvfywFapFmeQ9+nlv+hC6okIwRllB1db9z nA== From: Ilya Leoshkevich To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , David Hildenbrand Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Peter Maydell , Ilya Leoshkevich Subject: [PATCH v3 1/2] tests/tcg/multiarch: Make the system memory test work on big-endian Date: Wed, 26 Apr 2023 00:48:49 +0200 Message-Id: <20230425224850.2116064-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230425224850.2116064-1-iii@linux.ibm.com> References: <20230425224850.2116064-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: V2qOAkd7wEiIMpsf8-jB5jYTp0Lkheth X-Proofpoint-GUID: Btl2GUnH3dZQ3Tq94bBz0FDUKw40iO69 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-25_08,2023-04-25_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 malwarescore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304250201 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=148.163.158.5; envelope-from=iii@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @ibm.com) X-ZM-MESSAGEID: 1682463005645100006 Content-Type: text/plain; charset="utf-8" Store the bytes in descending order on big-endian. Invert the logic in the multi-byte signed tests on big-endian. Make the checks in the multi-byte signed tests stricter. Signed-off-by: Ilya Leoshkevich Reviewed-by: Alex Benn=C3=A9e --- tests/tcg/multiarch/system/memory.c | 64 +++++++++++++++++++---------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/tests/tcg/multiarch/system/memory.c b/tests/tcg/multiarch/syst= em/memory.c index 214f7d4f54b..eaae6929cb3 100644 --- a/tests/tcg/multiarch/system/memory.c +++ b/tests/tcg/multiarch/system/memory.c @@ -40,18 +40,21 @@ static void pdot(int count) } =20 /* - * Helper macros for shift/extract so we can keep our endian handling - * in one place. + * Helper macros for endian handling. */ -#define BYTE_SHIFT(b, pos) ((uint64_t)b << (pos * 8)) -#define BYTE_EXTRACT(b, pos) ((b >> (pos * 8)) & 0xff) +#if __BYTE_ORDER__ =3D=3D __ORDER_LITTLE_ENDIAN__ +#define BYTE_SHIFT(b, pos) (b << (pos * 8)) +#define BYTE_NEXT(b) ((b)++) +#elif __BYTE_ORDER__ =3D=3D __ORDER_BIG_ENDIAN__ +#define BYTE_SHIFT(b, pos) (b << ((sizeof(b) - 1 - (pos)) * 8)) +#define BYTE_NEXT(b) ((b)--) +#else +#error Unsupported __BYTE_ORDER__ +#endif =20 /* - * Fill the data with ascending value bytes. - * - * Currently we only support Little Endian machines so write in - * ascending address order. When we read higher address bytes should - * either be zero or higher than the lower bytes. + * Fill the data with ascending (for little-endian) or descending (for + * big-endian) value bytes. */ =20 static void init_test_data_u8(int unused_offset) @@ -62,14 +65,14 @@ static void init_test_data_u8(int unused_offset) =20 ml_printf("Filling test area with u8:"); for (i =3D 0; i < TEST_SIZE; i++) { - *ptr++ =3D count++; + *ptr++ =3D BYTE_NEXT(count); pdot(i); } ml_printf("done\n"); } =20 /* - * Full the data with alternating positive and negative bytes. This + * Fill the data with alternating positive and negative bytes. This * should mean for reads larger than a byte all subsequent reads will * stay either negative or positive. We never write 0. */ @@ -119,7 +122,7 @@ static void init_test_data_u16(int offset) reset_start_data(offset); =20 for (i =3D 0; i < max; i++) { - uint8_t low =3D count++, high =3D count++; + uint16_t low =3D BYTE_NEXT(count), high =3D BYTE_NEXT(count); word =3D BYTE_SHIFT(high, 1) | BYTE_SHIFT(low, 0); *ptr++ =3D word; pdot(i); @@ -139,9 +142,10 @@ static void init_test_data_u32(int offset) reset_start_data(offset); =20 for (i =3D 0; i < max; i++) { - uint8_t b4 =3D count++, b3 =3D count++; - uint8_t b2 =3D count++, b1 =3D count++; - word =3D BYTE_SHIFT(b1, 3) | BYTE_SHIFT(b2, 2) | BYTE_SHIFT(b3, 1)= | b4; + uint32_t b4 =3D BYTE_NEXT(count), b3 =3D BYTE_NEXT(count); + uint32_t b2 =3D BYTE_NEXT(count), b1 =3D BYTE_NEXT(count); + word =3D BYTE_SHIFT(b1, 3) | BYTE_SHIFT(b2, 2) | BYTE_SHIFT(b3, 1)= | + BYTE_SHIFT(b4, 0); *ptr++ =3D word; pdot(i); } @@ -160,13 +164,13 @@ static void init_test_data_u64(int offset) reset_start_data(offset); =20 for (i =3D 0; i < max; i++) { - uint8_t b8 =3D count++, b7 =3D count++; - uint8_t b6 =3D count++, b5 =3D count++; - uint8_t b4 =3D count++, b3 =3D count++; - uint8_t b2 =3D count++, b1 =3D count++; + uint64_t b8 =3D BYTE_NEXT(count), b7 =3D BYTE_NEXT(count); + uint64_t b6 =3D BYTE_NEXT(count), b5 =3D BYTE_NEXT(count); + uint64_t b4 =3D BYTE_NEXT(count), b3 =3D BYTE_NEXT(count); + uint64_t b2 =3D BYTE_NEXT(count), b1 =3D BYTE_NEXT(count); word =3D BYTE_SHIFT(b1, 7) | BYTE_SHIFT(b2, 6) | BYTE_SHIFT(b3, 5)= | BYTE_SHIFT(b4, 4) | BYTE_SHIFT(b5, 3) | BYTE_SHIFT(b6, 2) | - BYTE_SHIFT(b7, 1) | b8; + BYTE_SHIFT(b7, 1) | BYTE_SHIFT(b8, 0); *ptr++ =3D word; pdot(i); } @@ -374,12 +378,20 @@ static bool read_test_data_s16(int offset, bool neg_f= irst) ml_printf("Reading s16 from %#lx (offset %d, %s):", ptr, offset, neg_first ? "neg" : "pos"); =20 + /* + * If the first byte is negative, then the last byte is positive. + * Therefore the logic below must be flipped for big-endian. + */ +#if __BYTE_ORDER__ =3D=3D __ORDER_BIG_ENDIAN__ + neg_first =3D !neg_first; +#endif + for (i =3D 0; i < max; i++) { int32_t data =3D *ptr++; =20 if (neg_first && data < 0) { pdot(i); - } else if (data > 0) { + } else if (!neg_first && data > 0) { pdot(i); } else { ml_printf("Error %d %c 0\n", data, neg_first ? '<' : '>'); @@ -399,12 +411,20 @@ static bool read_test_data_s32(int offset, bool neg_f= irst) ml_printf("Reading s32 from %#lx (offset %d, %s):", ptr, offset, neg_first ? "neg" : "pos"); =20 + /* + * If the first byte is negative, then the last byte is positive. + * Therefore the logic below must be flipped for big-endian. + */ +#if __BYTE_ORDER__ =3D=3D __ORDER_BIG_ENDIAN__ + neg_first =3D !neg_first; +#endif + for (i =3D 0; i < max; i++) { int64_t data =3D *ptr++; =20 if (neg_first && data < 0) { pdot(i); - } else if (data > 0) { + } else if (!neg_first && data > 0) { pdot(i); } else { ml_printf("Error %d %c 0\n", data, neg_first ? '<' : '>'); --=20 2.39.2 From nobody Mon Feb 9 23:42:11 2026 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=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1682463018; cv=none; d=zohomail.com; s=zohoarc; b=Q0LgYP7lQ1pp6936FhCJFsUfQRZeozgxtAuvezwq6TZa/xQwqSDvfsmJ7HrzefPBHzhCyPoyD/7OKuHUiGe+qn1Mq96nmKtNpVG7XrZcna0hS26irAreyAcBz54nzqt7PLLiQlUwyxZD1YQ1+txFv1loT+bov0Ym7ptCIZkt93M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682463018; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3sSmCqqp4PVVXUJxxxCqnolLDxJwdfS8G1LGJ7DoThk=; b=bY9rnw2GoDJ5/MbpL73X5MaFyK+N5w1c5zMbjAszCzdz1Rh0PrtrW9m0g3XFWl1k3S9HrKwQ+kIyUL099IzgaDes6qykYYuWyM2Gmtd1zCUhTYhK23PpR2jl9DwKQjRRQ3k659QzxptIO2ThB7nccvUPwGzzyYCf4ObDmgXsDN4= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682463018415824.0202558490785; Tue, 25 Apr 2023 15:50:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prRTA-0002aB-RA; Tue, 25 Apr 2023 18:49:08 -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 1prRT9-0002Z4-8x; Tue, 25 Apr 2023 18:49:07 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1prRT7-00045V-DR; Tue, 25 Apr 2023 18:49:07 -0400 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33PMfxHK028826; Tue, 25 Apr 2023 22:49:01 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3q6q0v24da-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Apr 2023 22:49:01 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33PMaLjn000356; Tue, 25 Apr 2023 22:49:00 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3q6q0v24cc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Apr 2023 22:49:00 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 33PMaF3q020257; Tue, 25 Apr 2023 22:48:58 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma01fra.de.ibm.com (PPS) with ESMTPS id 3q47771nt4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Apr 2023 22:48:57 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 33PMmtA619464712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Apr 2023 22:48:55 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 86CF020043; Tue, 25 Apr 2023 22:48:55 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1181520040; Tue, 25 Apr 2023 22:48:55 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.10.36]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 25 Apr 2023 22:48:54 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=3sSmCqqp4PVVXUJxxxCqnolLDxJwdfS8G1LGJ7DoThk=; b=lvQ0Kn9006z8dBPmY6oiszwCZBXa9d37jchsfGqwbjsMltOjBxI1WgRbuR0n+t75UmBR YKIonGsnal2w6ee0i0ys4SwTXdd4AE4XNzFKhY8Gpa0Z8CHCwiqtyplGt5hrY/xyMKXQ xDBkUSJDNpuCjC9BN6sQC0MV5XXXLjNIER2rLHcyp+pNX7VcvepcF5izgOUGDL0ke3xy i3xUrVQNVenTKEprWxMRjYzzdsfFV0nkrlmiP6qi9d64hsfOKp+5ctpvtJR7ubohy9b3 a7k98TYIM7QCwUDc3miRae7gOUVSO31QnGWnGXQrzuBkJEuI1SD5ts7BRfcGgBieHUok Bw== From: Ilya Leoshkevich To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , David Hildenbrand Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Peter Maydell , Ilya Leoshkevich Subject: [PATCH v3 2/2] tests/tcg/s390x: Enable the multiarch system tests Date: Wed, 26 Apr 2023 00:48:50 +0200 Message-Id: <20230425224850.2116064-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230425224850.2116064-1-iii@linux.ibm.com> References: <20230425224850.2116064-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: QNKsBi18B2Wo5PA6-0f7VeHei5khX-RW X-Proofpoint-ORIG-GUID: ATI3K4jVxKzIKGqfoXFciWNomnQGzu_s X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-25_08,2023-04-25_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 spamscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304250201 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=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @ibm.com) X-ZM-MESSAGEID: 1682463019189100001 Content-Type: text/plain; charset="utf-8" Multiarch tests are written in C and need support for printing characters. Instead of implementing the runtime from scratch, just reuse the pc-bios/s390-ccw one. Run tests with -nographic in order to enable SCLP (enable this for the existing tests as well, since it does not hurt). Use the default linker script for the new tests. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson --- tests/tcg/s390x/Makefile.softmmu-target | 40 +++++++++++++++++-------- tests/tcg/s390x/console.c | 12 ++++++++ tests/tcg/s390x/head64.S | 31 +++++++++++++++++++ 3 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 tests/tcg/s390x/console.c create mode 100644 tests/tcg/s390x/head64.S diff --git a/tests/tcg/s390x/Makefile.softmmu-target b/tests/tcg/s390x/Make= file.softmmu-target index 3e7f72abcdc..e22df5e1c58 100644 --- a/tests/tcg/s390x/Makefile.softmmu-target +++ b/tests/tcg/s390x/Makefile.softmmu-target @@ -1,25 +1,41 @@ S390X_SRC=3D$(SRC_PATH)/tests/tcg/s390x VPATH+=3D$(S390X_SRC) -QEMU_OPTS=3D-action panic=3Dexit-failure -kernel +QEMU_OPTS=3D-action panic=3Dexit-failure -nographic -kernel LINK_SCRIPT=3D$(S390X_SRC)/softmmu.ld -LDFLAGS=3D-nostdlib -static -Wl,-T$(LINK_SCRIPT) -Wl,--build-id=3Dnone +CFLAGS+=3D-ggdb -O0 +LDFLAGS=3D-nostdlib -static =20 %.o: %.S $(CC) -march=3Dz13 -m64 -c $< -o $@ =20 -%: %.o $(LINK_SCRIPT) +%.o: %.c + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -march=3Dz13 -m64 -c $< -o $@ + +%: %.o $(CC) $< -o $@ $(LDFLAGS) =20 -TESTS +=3D unaligned-lowcore -TESTS +=3D bal -TESTS +=3D sam -TESTS +=3D lpsw -TESTS +=3D lpswe-early -TESTS +=3D ssm-early -TESTS +=3D stosm-early -TESTS +=3D exrl-ssm-early +ASM_TESTS =3D = \ + bal = \ + exrl-ssm-early = \ + sam = \ + lpsw = \ + lpswe-early = \ + ssm-early = \ + stosm-early = \ + unaligned-lowcore =20 include $(S390X_SRC)/pgm-specification.mak $(PGM_SPECIFICATION_TESTS): pgm-specification-softmmu.o $(PGM_SPECIFICATION_TESTS): LDFLAGS+=3Dpgm-specification-softmmu.o -TESTS +=3D $(PGM_SPECIFICATION_TESTS) +ASM_TESTS +=3D $(PGM_SPECIFICATION_TESTS) + +$(ASM_TESTS): LDFLAGS +=3D -Wl,-T$(LINK_SCRIPT) -Wl,--build-id=3Dnone +$(ASM_TESTS): $(LINK_SCRIPT) +TESTS +=3D $(ASM_TESTS) + +S390X_MULTIARCH_RUNTIME_OBJS =3D head64.o console.o $(MINILIB_OBJS) +$(MULTIARCH_TESTS): $(S390X_MULTIARCH_RUNTIME_OBJS) +$(MULTIARCH_TESTS): LDFLAGS +=3D $(S390X_MULTIARCH_RUNTIME_OBJS) +$(MULTIARCH_TESTS): CFLAGS +=3D $(MINILIB_INC) +memory: CFLAGS +=3D -DCHECK_UNALIGNED=3D0 +TESTS +=3D $(MULTIARCH_TESTS) diff --git a/tests/tcg/s390x/console.c b/tests/tcg/s390x/console.c new file mode 100644 index 00000000000..d43ce3f44b4 --- /dev/null +++ b/tests/tcg/s390x/console.c @@ -0,0 +1,12 @@ +/* + * Console code for multiarch tests. + * Reuses the pc-bios/s390-ccw implementation. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include "../../../pc-bios/s390-ccw/sclp.c" + +void __sys_outc(char c) +{ + write(1, &c, sizeof(c)); +} diff --git a/tests/tcg/s390x/head64.S b/tests/tcg/s390x/head64.S new file mode 100644 index 00000000000..c6f36dfea4b --- /dev/null +++ b/tests/tcg/s390x/head64.S @@ -0,0 +1,31 @@ +/* + * Startup code for multiarch tests. + * Reuses the pc-bios/s390-ccw implementation. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#define main main_pre +#include "../../../pc-bios/s390-ccw/start.S" +#undef main + +main_pre: + aghi %r15,-160 /* reserve stack for C code */ + brasl %r14,sclp_setup + brasl %r14,main + larl %r1,success_psw /* check main() return code */ + ltgr %r2,%r2 + je 0f + larl %r1,failure_psw +0: + lpswe 0(%r1) + + .align 8 +success_psw: + .quad 0x2000180000000,0xfff /* see is_special_wait_psw() */ +failure_psw: + .quad 0x2000180000000,0 /* disabled wait */ + + .section .bss + .align 0x1000 +stack: + .skip 0x8000 --=20 2.39.2