From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id C8515385480F for ; Thu, 8 Apr 2021 14:49:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C8515385480F Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 138EZiTk166109 for ; Thu, 8 Apr 2021 10:49:09 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 37rvunuy8e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 08 Apr 2021 10:49:08 -0400 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 138Ea3hr167694 for ; Thu, 8 Apr 2021 10:49:08 -0400 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 37rvunuy6f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Apr 2021 10:49:08 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 138EgxXH010550; Thu, 8 Apr 2021 14:49:05 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04fra.de.ibm.com with ESMTP id 37rvc5gw6q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Apr 2021 14:49:05 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 138En2rf42926572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 Apr 2021 14:49:02 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C1C93A405B; Thu, 8 Apr 2021 14:49:02 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 99B23A405C; Thu, 8 Apr 2021 14:49:02 +0000 (GMT) Received: from li-ab9d22cc-354d-11b2-a85c-e984af76f811.ibm.com (unknown [9.171.68.84]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 8 Apr 2021 14:49:02 +0000 (GMT) Subject: Re: s390x: Diagnose missing VXE at run time if required at build time To: Florian Weimer , libc-alpha@sourceware.org References: <87k0pfmmpy.fsf@oldenburg.str.redhat.com> From: Stefan Liebler Message-ID: <294a9d07-64bc-7db7-6cd9-1fe4fdbfc1f9@linux.ibm.com> Date: Thu, 8 Apr 2021 16:49:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 In-Reply-To: <87k0pfmmpy.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-GUID: E2g3BJh7aVWweGCtBHi4pKWf_QMW5Ayd X-Proofpoint-ORIG-GUID: si6xIfv-swt-LVRv4R8zB1620bMe8jAW Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-04-08_03:2021-04-08, 2021-04-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 mlxscore=0 clxscore=1015 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104080102 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 14:49:11 -0000 On 06/04/2021 17:55, Florian Weimer wrote: > It turns out that if glibc is built with -march=z14, it is still > possible to run up to dl_platform_init on z13 CPUs. This means we can > add a diagnostic to glibc, notifying the user that the CPU is too old. > > The check is based on the way GCC sets the __LONG_DOUBLE_VX__ > preprocessor macro: > > s390_def_or_undef_macro ( > pfile, > [] (const struct cl_target_option *opts) { return TARGET_VXE_P (opts); }, > old_opts, opts, "__LONG_DOUBLE_VX__", "__LONG_DOUBLE_VX__"); > > > diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h > index 543361c83637c071..deaf37951206fb7c 100644 > --- a/sysdeps/s390/s390-64/dl-machine.h > +++ b/sysdeps/s390/s390-64/dl-machine.h > @@ -235,6 +235,12 @@ _dl_start_user:\n\ > static inline void __attribute__ ((unused)) > dl_platform_init (void) > { > +#ifdef __LONG_DOUBLE_VX__ > + if (!(GLRO(dl_hwcap) & HWCAP_S390_VXE)) > + _dl_fatal_printf ("\ > +Fatal glibc error: CPU lacks VXE support (z14 or later required)\n"); > +#endif > + > if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0') > /* Avoid an empty string which would disturb us. */ > GLRO(dl_platform) = NULL; > Hi Florian, I've just had a quick look to dl_platform_init for other architectures to check if there are similar checks. But I haven't found those there. Are there similar checks for other architectures at a different place? Is there a special reason for this check beyond giving the user an error message instead of crashing with SIGILL? The user will get the error message if build with -march=z14 and running on z13. If this binary is running on zEC12, it just crashes with SIGILL as there is a z13 vector instructions before dl_platform_init. Currently it works on z13, but who knows if this does not change if build with a different gcc version? The __LONG_DOUBLE_VX__ macro is quite new and the first gcc release will be gcc 11. But there is also the __ARCH__ macro. If defined by the used gcc, it is set to the architecture level determined by -march=xyz (z15=13; z14=12; z13=11; ...). See gcc commit "S/390: Rename __S390_ARCH_LEVEL__ to __ARCH__." https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=4727e06bb7c047a10aa502c829b7e4b519d8082b If I remember correctly, this was introduced with gcc 7 or 8. Would it make sense to add such a check also if build with -march=z15?: #if defined __ARCH__ # if __ARCH__ >= 13 if (!(GLRO(dl_hwcap) & HWCAP_S390_VXRS_EXT2)) _dl_fatal_printf ("\ Fatal glibc error: CPU lacks VXRS_EXT2 support (z15 or later required)\n"); # elif __ARCH__ >= 12 if (!(GLRO(dl_hwcap) & HWCAP_S390_VXE)) _dl_fatal_printf ("\ Fatal glibc error: CPU lacks VXE support (z14 or later required)\n"); #endif There are also configure checks which checks if arch-level specific instructions are available at build-time (but not for all levels): z15: HAVE_S390_MIN_ARCH13_ZARCH_ASM_SUPPORT z13: HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT z196: HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT z10: HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT Thanks, Stefan