From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 4C2EA3892463 for ; Wed, 3 Feb 2021 09:29:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4C2EA3892463 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-xzpYT1EcMMeW8VGUZ7-aIg-1; Wed, 03 Feb 2021 04:29:45 -0500 X-MC-Unique: xzpYT1EcMMeW8VGUZ7-aIg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 162341936B61; Wed, 3 Feb 2021 09:29:44 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-116.ams2.redhat.com [10.36.112.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3940D60C6B; Wed, 3 Feb 2021 09:29:43 +0000 (UTC) From: Florian Weimer To: "H.J. Lu via Libc-alpha" Subject: Re: [PATCH] x86: Require full ISA support for x86-64 level marker [BZ #27318] References: <20210202215112.1002416-1-hjl.tools@gmail.com> Date: Wed, 03 Feb 2021 10:29:46 +0100 In-Reply-To: <20210202215112.1002416-1-hjl.tools@gmail.com> (H. J. Lu via Libc-alpha's message of "Tue, 2 Feb 2021 13:51:12 -0800") Message-ID: <87pn1hsdmd.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK 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: Wed, 03 Feb 2021 09:29:50 -0000 * H. J. Lu via Libc-alpha: > Since -march=sandybridge enables ISAs in x86-64 ISA level v3, the v3 > marker is set in libc.so. We couldn't set the needed ISA marker to v2 > since this libc won't run on all v2 machines. Technically, the v3 marker > is correct. It's not correct due to the way the check is implemented: failing to load -march=sandybridge binaries on Sandybridge CPUs is clearly wrong. > But the resulting libc.so won't run on Sandy Brigde, which > is a v2 machine, even when libc is compiled with -march=sandybridge: > > $ ./elf/ld.so ./libc.so > ./libc.so: (p) CPU ISA level is lower than required: needed: 7; got: 3 They would run were it not for the check. > Instead, we should require full ISA support for x86-64 level marker to > detect such case: > > In file included from ../sysdeps/x86/abi-note.c:28: > ../sysdeps/x86/isa-level.c:62:5: error: #error "Invalid ISAs for x86-64 ISA level v3" > 62 | # error "Invalid ISAs for x86-64 ISA level v3" > | ^~~~~ If you want checks, doing them against an incorrect ABI level that can never fully match the host CPU is wrong. You could do something like this: #ifdef __SSE3___ if (!CPU_FEATURE_USABLE_P (cpu_features, SSE3)) _dl_fatal_printf ("Fatal glibc error: CPU does not support SSE3\n"); #endif And repeat that for all those GCC target macros. Thanks, Florian -- Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn, Commercial register: Amtsgericht Muenchen, HRB 153243, Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill