public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] x86: Require full ISA support for x86-64 level marker [BZ #27318]
@ 2021-02-02 21:51 H.J. Lu
  2021-02-02 23:11 ` Joseph Myers
  2021-02-03  9:29 ` [PATCH] " Florian Weimer
  0 siblings, 2 replies; 28+ messages in thread
From: H.J. Lu @ 2021-02-02 21:51 UTC (permalink / raw)
  To: 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.  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

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"
      |     ^~~~~
---
 sysdeps/x86/isa-level.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/sysdeps/x86/isa-level.c b/sysdeps/x86/isa-level.c
index aaf524cb56..cbd3526406 100644
--- a/sysdeps/x86/isa-level.c
+++ b/sysdeps/x86/isa-level.c
@@ -31,6 +31,9 @@
 #ifdef INCLUDE_X86_ISA_LEVEL
 # if defined __x86_64__ || defined __FXSR__ || !defined _SOFT_FLOAT \
      || defined  __MMX__ || defined __SSE__ || defined __SSE2__
+#  if !defined __SSE__ || !defined __SSE2__
+#   error "Invalid ISAs for x86-64 ISA level baseline"
+#  endif
 #  define ISA_BASELINE	GNU_PROPERTY_X86_ISA_1_BASELINE
 # else
 #  define ISA_BASELINE	0
@@ -40,6 +43,12 @@
      || (defined __x86_64__ && defined __LAHF_SAHF__) \
      || defined __POPCNT__ || defined __SSE3__ \
      || defined __SSSE3__ || defined __SSE4_1__ || defined __SSE4_2__
+#  if !defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 \
+     || (defined __x86_64__ && !defined __LAHF_SAHF__) \
+     || !defined __POPCNT__ || !defined __SSE3__ \
+     || !defined __SSSE3__ || !defined __SSE4_1__ || !defined __SSE4_2__
+#   error "Invalid ISAs for x86-64 ISA level v2"
+#  endif
 #  define ISA_V2	GNU_PROPERTY_X86_ISA_1_V2
 # else
 #  define ISA_V2	0
@@ -48,6 +57,10 @@
 # if defined __AVX__ || defined __AVX2__ || defined __F16C__ \
      || defined __FMA__ || defined __LZCNT__ || defined __MOVBE__ \
      || defined __XSAVE__
+# if !defined __AVX__ || !defined __AVX2__ || !defined __F16C__ \
+     || !defined __FMA__ || !defined __LZCNT__ || !defined __MOVBE__
+#   error "Invalid ISAs for x86-64 ISA level v3"
+#  endif
 #  define ISA_V3	GNU_PROPERTY_X86_ISA_1_V3
 # else
 #  define ISA_V3	0
@@ -55,6 +68,11 @@
 
 # if defined __AVX512F__ || defined __AVX512BW__ || defined __AVX512CD__ \
      || defined __AVX512DQ__ || defined __AVX512VL__
+#  if !defined __AVX512F__ || !defined __AVX512BW__ \
+      || !defined __AVX512CD__ || !defined __AVX512DQ__ \
+      || !defined __AVX512VL__
+#   error "Invalid ISAs for x86-64 ISA level v4"
+#  endif
 #  define ISA_V4	GNU_PROPERTY_X86_ISA_1_V4
 # else
 #  define ISA_V4	0
-- 
2.29.2


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2021-03-06 15:58 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 21:51 [PATCH] x86: Require full ISA support for x86-64 level marker [BZ #27318] H.J. Lu
2021-02-02 23:11 ` Joseph Myers
2021-02-02 23:16   ` H.J. Lu
2021-02-03 14:14     ` Joseph Myers
2021-02-03 15:09       ` [PATCH v2] " H.J. Lu
2021-02-04 10:38         ` Florian Weimer
2021-02-04 13:22           ` H.J. Lu
2021-02-04 22:55             ` Andreas K. Hüttel
2021-02-04 23:09               ` H.J. Lu
2021-02-07 10:27                 ` Florian Weimer
2021-02-07 15:05                   ` H.J. Lu
2021-02-08 15:06                     ` Florian Weimer
2021-02-08 16:09                       ` H.J. Lu
2021-02-09  0:29                         ` [PATCH v3] x86: Disable " H.J. Lu
2021-02-22 10:40                           ` Florian Weimer
2021-02-22 12:51                             ` H.J. Lu
2021-02-22 13:51                               ` Florian Weimer
2021-03-01 16:07                                 ` Florian Weimer
2021-03-01 18:00                                   ` H.J. Lu
2021-03-01 18:06                                     ` Florian Weimer
2021-03-01 19:09                                       ` H.J. Lu
2021-03-03 13:37                                         ` [PATCH v4] x86: Set minimum " H.J. Lu
2021-03-05 19:43                                           ` Florian Weimer
2021-03-06 15:23                                             ` [PATCH v5] " H.J. Lu
2021-03-06 15:42                                               ` Florian Weimer
2021-03-06 15:58                                                 ` [2.33][PATCH] " H.J. Lu
2021-02-08 13:35               ` [PATCH v2] x86: Require full ISA support for " Nix
2021-02-03  9:29 ` [PATCH] " Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).