From c3bb24f5663f3e423f313bc16f27e32ef5e1dc0a Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 24 Feb 2023 13:58:35 +0100 Subject: x86-64: don't permit LAHF/SAHF with "generic64" The feature isn't universally available on 64-bit CPUs. Note that in i386-gen.c:isa_dependencies[] I'm only adding it to models where I'm certain the functionality exists. For Nocona and Core I'm uncertain in particular. --- gas/config/tc-i386.c | 1 + gas/doc/c-i386.texi | 3 +- gas/testsuite/gas/i386/i386.exp | 1 + gas/testsuite/gas/i386/ilp32/x86-64-arch-2.d | 2 +- gas/testsuite/gas/i386/x86-64-arch-2-1.l | 3 + gas/testsuite/gas/i386/x86-64-arch-2-2.l | 3 + gas/testsuite/gas/i386/x86-64-arch-2-3.l | 93 ++++++++++++++++++++++++ gas/testsuite/gas/i386/x86-64-arch-2-3.s | 1 + gas/testsuite/gas/i386/x86-64-arch-2-lzcnt.d | 2 +- gas/testsuite/gas/i386/x86-64-arch-2-prefetchw.d | 2 +- gas/testsuite/gas/i386/x86-64-arch-2.d | 3 +- gas/testsuite/gas/i386/x86-64-arch-2.s | 2 + 12 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 gas/testsuite/gas/i386/x86-64-arch-2-3.l create mode 100644 gas/testsuite/gas/i386/x86-64-arch-2-3.s (limited to 'gas') diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 920c4bd..71d991b 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -1047,6 +1047,7 @@ static const arch_entry cpu_arch[] = SUBARCH (lwp, LWP, ANY_LWP, false), SUBARCH (movbe, MOVBE, MOVBE, false), SUBARCH (cx16, CX16, CX16, false), + SUBARCH (lahf_sahf, LAHF_SAHF, LAHF_SAHF, false), SUBARCH (ept, EPT, ANY_EPT, false), SUBARCH (lzcnt, LZCNT, LZCNT, false), SUBARCH (popcnt, POPCNT, POPCNT, false), diff --git a/gas/doc/c-i386.texi b/gas/doc/c-i386.texi index 6c846bf..f529383 100644 --- a/gas/doc/c-i386.texi +++ b/gas/doc/c-i386.texi @@ -151,6 +151,7 @@ accept various extension mnemonics. For example, @code{sse4}, @code{avx}, @code{avx2}, +@code{lahf_sahf}, @code{adx}, @code{rdseed}, @code{prfchw}, @@ -1487,7 +1488,7 @@ supported on the CPU specified. The choices for @var{cpu_type} are: @item @samp{.rdrnd} @tab @samp{.f16c} @tab @samp{.avx2} @tab @samp{.bmi2} @item @samp{.lzcnt} @tab @samp{.popcnt} @tab @samp{.invpcid} @tab @samp{.vmfunc} @item @samp{.hle} @tab @samp{.rtm} @tab @samp{.tsx} -@item @samp{.adx} @tab @samp{.rdseed} @tab @samp{.prfchw} +@item @samp{.lahf_sahf} @tab @samp{.adx} @tab @samp{.rdseed} @tab @samp{.prfchw} @item @samp{.smap} @tab @samp{.mpx} @tab @samp{.sha} @tab @samp{.prefetchwt1} @item @samp{.clflushopt} @tab @samp{.xsavec} @tab @samp{.xsaves} @tab @samp{.se1} @item @samp{.avx512f} @tab @samp{.avx512cd} @tab @samp{.avx512er} @tab @samp{.avx512pf} diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp index 6546e28..8d5f4e8 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -934,6 +934,7 @@ if [gas_64_check] then { run_dump_test "x86-64-arch-2-btver2" run_list_test "x86-64-arch-2-1" "-march=generic64 -I${srcdir}/$subdir -al" run_list_test "x86-64-arch-2-2" "-march=generic64+cx16 -I${srcdir}/$subdir -al" + run_list_test "x86-64-arch-2-3" "-march=generic64+lahf_sahf -I${srcdir}/$subdir -aln" run_dump_test "xmmhi64" run_dump_test "x86-64-xsave" run_dump_test "x86-64-xsave-intel" diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-arch-2.d b/gas/testsuite/gas/i386/ilp32/x86-64-arch-2.d index 284cc24..ea641d4 100644 --- a/gas/testsuite/gas/i386/ilp32/x86-64-arch-2.d +++ b/gas/testsuite/gas/i386/ilp32/x86-64-arch-2.d @@ -1,5 +1,5 @@ #source: ../x86-64-arch-2.s -#as: -march=generic64+avx+vmx+smx+xsave+xsaveopt+aes+pclmul+fma+movbe+cx16+ept+clflush+syscall+rdtscp+3dnowa+sse4a+svme+abm+padlock+bmi+tbm +#as: -march=generic64+avx+vmx+smx+xsave+xsaveopt+aes+pclmul+fma+movbe+cx16+lahf_sahf+ept+clflush+syscall+rdtscp+3dnowa+sse4a+svme+abm+padlock+bmi+tbm #objdump: -dw #name: x86-64 (ILP32) arch 2 #dump: ../x86-64-arch-2.d diff --git a/gas/testsuite/gas/i386/x86-64-arch-2-1.l b/gas/testsuite/gas/i386/x86-64-arch-2-1.l index 355b91c..8a62037 100644 --- a/gas/testsuite/gas/i386/x86-64-arch-2-1.l +++ b/gas/testsuite/gas/i386/x86-64-arch-2-1.l @@ -24,6 +24,7 @@ .*:60: Error: .* .*:62: Error: .* .*:64: Error: .* +.*:66: Error: .* GAS LISTING .* @@ -95,3 +96,5 @@ GAS LISTING .* [ ]*62[ ]+blsr %ecx,%ebx [ ]*63[ ]+\# TBM [ ]*64[ ]+blcfill %ecx,%ebx +[ ]*65[ ]+\# LAHF/SAHF +[ ]*66[ ]+lahf diff --git a/gas/testsuite/gas/i386/x86-64-arch-2-2.l b/gas/testsuite/gas/i386/x86-64-arch-2-2.l index 2f8bf56..45a4df3 100644 --- a/gas/testsuite/gas/i386/x86-64-arch-2-2.l +++ b/gas/testsuite/gas/i386/x86-64-arch-2-2.l @@ -23,6 +23,7 @@ .*:60: Error: .* .*:62: Error: .* .*:64: Error: .* +.*:66: Error: .* GAS LISTING .* @@ -94,3 +95,5 @@ GAS LISTING .* [ ]*62[ ]+blsr %ecx,%ebx [ ]*63[ ]+\# TBM [ ]*64[ ]+blcfill %ecx,%ebx +[ ]*65[ ]+\# LAHF/SAHF +[ ]*66[ ]+lahf diff --git a/gas/testsuite/gas/i386/x86-64-arch-2-3.l b/gas/testsuite/gas/i386/x86-64-arch-2-3.l new file mode 100644 index 0000000..9a61d84 --- /dev/null +++ b/gas/testsuite/gas/i386/x86-64-arch-2-3.l @@ -0,0 +1,93 @@ +.*: Assembler messages: +.*:16: Error: .* +.*:18: Error: .* +.*:20: Error: .* +.*:22: Error: .* +.*:24: Error: .* +.*:26: Error: .* +.*:28: Error: .* +.*:30: Error: .* +.*:32: Error: .* +.*:34: Error: .* +.*:36: Error: .* +.*:38: Error: .* +.*:40: Error: .* +.*:42: Error: .* +.*:44: Error: .* +.*:46: Error: .* +.*:48: Error: .* +.*:50: Error: .* +.*:52: Error: .* +.*:54: Error: .* +.*:56: Error: .* +.*:58: Error: .* +.*:60: Error: .* +.*:62: Error: .* +.*:64: Error: .* +[ ]*1[ ]+\.include "x86-64-arch-2\.s" +[ ]*1[ ]+\# Test -march= +[ ]*2[ ]+\.text +[ ]*3[ ]+\# cmov feature * +[ ]*4[ ]+\?\?\?\? 0F44D8 cmove %eax,%ebx +[ ]*5[ ]+\# clflush +[ ]*6[ ]+\?\?\?\? 0FAE38 clflush \(%rax\) +[ ]*7[ ]+\# SYSCALL +[ ]*8[ ]+\?\?\?\? 0F05 syscall +[ ]*9[ ]+\# MMX +[ ]*10[ ]+\?\?\?\? 0FFCDC paddb %mm4,%mm3 +[ ]*11[ ]+\# SSE +[ ]*12[ ]+\?\?\?\? F30F58DC addss %xmm4,%xmm3 +[ ]*13[ ]+\# SSE2 +[ ]*14[ ]+\?\?\?\? F20F58DC addsd %xmm4,%xmm3 +[ ]*15[ ]+\# SSE3 +[ ]*16[ ]+addsubpd %xmm4,%xmm3 +[ ]*17[ ]+\# SSSE3 +[ ]*18[ ]+phaddw %xmm4,%xmm3 +[ ]*19[ ]+\# SSE4\.1 +[ ]*20[ ]+phminposuw %xmm1,%xmm3 +[ ]*21[ ]+\# SSE4\.2 +[ ]*22[ ]+crc32 %ecx,%ebx +[ ]*23[ ]+\# AVX +[ ]*24[ ]+vzeroall +[ ]*25[ ]+\# VMX +[ ]*26[ ]+vmxoff +[ ]*27[ ]+\# SMX +[ ]*28[ ]+getsec +[ ]*29[ ]+\# Xsave +[ ]*30[ ]+xgetbv +[ ]*31[ ]+\# Xsaveopt +[ ]*32[ ]+xsaveopt \(%rcx\) +[ ]*33[ ]+\# AES +[ ]*34[ ]+aesenc \(%rcx\),%xmm0 +[ ]*35[ ]+\# PCLMUL +[ ]*36[ ]+pclmulqdq \$8,%xmm1,%xmm0 +[ ]*37[ ]+\# AES \+ AVX +[ ]*38[ ]+vaesenc \(%rcx\),%xmm0,%xmm2 +[ ]*39[ ]+\# PCLMUL \+ AVX +[ ]*40[ ]+vpclmulqdq \$8,%xmm4,%xmm6,%xmm2 +[ ]*41[ ]+\# FMA +[ ]*42[ ]+vfmadd132pd %xmm4,%xmm6,%xmm2 +[ ]*43[ ]+\# MOVBE +[ ]*44[ ]+movbe \(%rcx\),%ebx +[ ]*45[ ]+\# CX16 +[ ]*46[ ]+cmpxchg16b \(%rsi\) +[ ]*47[ ]+\# EPT +[ ]*48[ ]+invept \(%rcx\),%rbx +[ ]*49[ ]+\# RDTSCP +[ ]*50[ ]+rdtscp +[ ]*51[ ]+\# 3DNow or PRFCHW +[ ]*52[ ]+prefetchw 0x1000\(,%rsi,2\) +[ ]*53[ ]+\# SSE4a +[ ]*54[ ]+insertq %xmm2,%xmm1 +[ ]*55[ ]+\# SVME +[ ]*56[ ]+vmload +[ ]*57[ ]+\# ABM/LZCNT +[ ]*58[ ]+lzcnt %ecx,%ebx +[ ]*59[ ]+\# PadLock +[ ]*60[ ]+xstorerng +[ ]*61[ ]+\# BMI +[ ]*62[ ]+blsr %ecx,%ebx +[ ]*63[ ]+\# TBM +[ ]*64[ ]+blcfill %ecx,%ebx +[ ]*65[ ]+\# LAHF/SAHF +[ ]*66[ ]+\?\?\?\? 9F lahf diff --git a/gas/testsuite/gas/i386/x86-64-arch-2-3.s b/gas/testsuite/gas/i386/x86-64-arch-2-3.s new file mode 100644 index 0000000..63544a1 --- /dev/null +++ b/gas/testsuite/gas/i386/x86-64-arch-2-3.s @@ -0,0 +1 @@ +.include "x86-64-arch-2.s" diff --git a/gas/testsuite/gas/i386/x86-64-arch-2-lzcnt.d b/gas/testsuite/gas/i386/x86-64-arch-2-lzcnt.d index eac5830..65cf03f 100644 --- a/gas/testsuite/gas/i386/x86-64-arch-2-lzcnt.d +++ b/gas/testsuite/gas/i386/x86-64-arch-2-lzcnt.d @@ -1,5 +1,5 @@ #source: x86-64-arch-2.s -#as: -march=generic64+avx+vmx+smx+xsave+xsaveopt+aes+pclmul+fma+movbe+cx16+ept+clflush+syscall+rdtscp+3dnowa+sse4a+svme+lzcnt+padlock+bmi+tbm +#as: -march=generic64+avx+vmx+smx+xsave+xsaveopt+aes+pclmul+fma+movbe+cx16+lahf_sahf+ept+clflush+syscall+rdtscp+3dnowa+sse4a+svme+lzcnt+padlock+bmi+tbm #objdump: -dw #name: x86-64 arch 2 (lzcnt) #dump: x86-64-arch-2.d diff --git a/gas/testsuite/gas/i386/x86-64-arch-2-prefetchw.d b/gas/testsuite/gas/i386/x86-64-arch-2-prefetchw.d index 0e8c073..3e0a836 100644 --- a/gas/testsuite/gas/i386/x86-64-arch-2-prefetchw.d +++ b/gas/testsuite/gas/i386/x86-64-arch-2-prefetchw.d @@ -1,5 +1,5 @@ #source: x86-64-arch-2.s -#as: -march=generic64+avx+vmx+smx+xsave+xsaveopt+aes+pclmul+fma+movbe+cx16+ept+clflush+syscall+rdtscp+sse4a+svme+lzcnt+padlock+bmi+tbm+prfchw +#as: -march=generic64+avx+vmx+smx+xsave+xsaveopt+aes+pclmul+fma+movbe+cx16+lahf_sahf+ept+clflush+syscall+rdtscp+sse4a+svme+lzcnt+padlock+bmi+tbm+prfchw #objdump: -dw #name: x86-64 arch 2 (prefetchw) #dump: x86-64-arch-2.d diff --git a/gas/testsuite/gas/i386/x86-64-arch-2.d b/gas/testsuite/gas/i386/x86-64-arch-2.d index 21fdc97..c1f1534 100644 --- a/gas/testsuite/gas/i386/x86-64-arch-2.d +++ b/gas/testsuite/gas/i386/x86-64-arch-2.d @@ -1,4 +1,4 @@ -#as: -march=generic64+avx+vmx+smx+xsave+xsaveopt+aes+pclmul+fma+movbe+cx16+ept+clflush+syscall+rdtscp+3dnowa+sse4a+svme+abm+padlock+bmi+tbm +#as: -march=generic64+avx+vmx+smx+xsave+xsaveopt+aes+pclmul+fma+movbe+cx16+lahf_sahf+ept+clflush+syscall+rdtscp+3dnowa+sse4a+svme+abm+padlock+bmi+tbm #objdump: -dw #name: x86-64 arch 2 @@ -38,4 +38,5 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 0f a7 c0 xstore-rng [ ]*[a-f0-9]+: c4 e2 60 f3 c9 blsr %ecx,%ebx [ ]*[a-f0-9]+: 8f e9 60 01 c9 blcfill %ecx,%ebx +[ ]*[a-f0-9]+: 9f lahf #pass diff --git a/gas/testsuite/gas/i386/x86-64-arch-2.s b/gas/testsuite/gas/i386/x86-64-arch-2.s index fb98771..a6454c5 100644 --- a/gas/testsuite/gas/i386/x86-64-arch-2.s +++ b/gas/testsuite/gas/i386/x86-64-arch-2.s @@ -62,3 +62,5 @@ xstorerng blsr %ecx,%ebx # TBM blcfill %ecx,%ebx +# LAHF/SAHF +lahf -- cgit v1.1