From c5d40b35761c8e7c4ab4503ec4d05d05d4cbb277 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 3 Oct 2016 22:18:31 -0700 Subject: [PATCH 1/8] assemble: print a warning on a forward reference in RESx Print a warning on a forward reference in RESx. This really should have been a critical expression, and a forward reference should have been an error, but it wasn't implemented that way and as such we can't just randomly break people's code, even if it is dangerous. --- assemble.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/assemble.c b/assemble.c index 4c8415fd..a1aef1cd 100644 --- a/assemble.c +++ b/assemble.c @@ -1178,6 +1178,9 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, if (ins->oprs[0].segment != NO_SEG) nasm_error(ERR_NONFATAL, "attempt to reserve non-constant" " quantity of BSS space"); + else if (ins->oprs[0].opflags & OPFLAG_FORWARD) + nasm_error(ERR_WARNING | ERR_PASS1, + "forward reference in RESx can result in unpredictable results"); else length += ins->oprs[0].offset; break; From e346b3b4a0fe19ede4228fc3ba2eab31456e00d0 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 3 Oct 2016 22:45:23 -0700 Subject: [PATCH 2/8] assemble: avoid redundant repetition in RESx warning message Clean up the language in this warning message, so as not be so unnecessarily repetitive. Signed-off-by: H. Peter Anvin --- assemble.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assemble.c b/assemble.c index a1aef1cd..0971fa3a 100644 --- a/assemble.c +++ b/assemble.c @@ -1180,7 +1180,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, " quantity of BSS space"); else if (ins->oprs[0].opflags & OPFLAG_FORWARD) nasm_error(ERR_WARNING | ERR_PASS1, - "forward reference in RESx can result in unpredictable results"); + "forward reference in RESx can have unpredictable results"); else length += ins->oprs[0].offset; break; From 5e0d3b773ffb32d1ae19215dc6a81e22cefba615 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 3 Oct 2016 23:01:58 -0700 Subject: [PATCH 3/8] changes.src: update for a 2.12.03 release We seem to have accumulated enough fixes that it ought to be time for a 2.12.03 release. Signed-off-by: H. Peter Anvin --- doc/changes.src | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/doc/changes.src b/doc/changes.src index 73d84eb1..3cae1fa1 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -7,6 +7,29 @@ The NASM 2 series supports x86-64, and is the production version of NASM since 2007. +\S{cl-2.12.03} Version 2.12.03 + +\b Add new warnings for certain dangerous constructs which never ought + to have been allowed. In particular, the \c{RESB} family of + instructions should have been taking a critical expression all + along. + +\b Fix the EVEX (AVX-512) versions of the \c{VPBROADCAST}, \c{VPEXTR}, + and \c{VPINSR} instructions. + +\b Support contracted forms of additional instructions. As a general + rule, if an instruction has a non-destructive source immediately + after a destination register that isn't used as an input, NASM + supports omitting that source register, using the destination + register as that value. This among other things makes it easier to + convert SSE code to the equivalent AVX code: + +\c addps xmm1,xmm0 ; SSE instruction +\c vaddps ymm1,ymm1,ymm0 ; AVX official long form +\c vaddps ymm1,ymm0 ; AVX contracted form + +\b Fix Codeview malformed compiler version record. + \S{cl-2.12.02} Version 2.12.02 \b Fix preprocessor errors, especially \c{%error} and \c{%warning}, From a617487b508967e950f18a790181bbe0adc94d7d Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 3 Oct 2016 23:23:02 -0700 Subject: [PATCH 4/8] Add the CLWB and (already deprecated) PCOMMIT instructions Add the CLWB and PCOMMIT instructions. Signed-off-by: H. Peter Anvin --- insns.dat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/insns.dat b/insns.dat index 9d01797e..e9e9230c 100644 --- a/insns.dat +++ b/insns.dat @@ -1,6 +1,6 @@ ;; -------------------------------------------------------------------------- ;; -;; Copyright 1996-2014 The NASM Authors - All Rights Reserved +;; Copyright 1996-2016 The NASM Authors - All Rights Reserved ;; See the file AUTHORS included with the NASM distribution for ;; the specific copyright holders. ;; @@ -5116,6 +5116,9 @@ WRPKRU void [ 0f 01 ef] X64,FUTURE ; New memory instructions CLFLUSHOPT mem [m: 66 0f ae /7] FUTURE +CLWB mem [m: 66 0f ae /6] FUTURE +;# This one was killed before it saw the light of day +PCOMMIT void [ 66 0f ae f8] FUTURE,UNDOC ; AMD Zen v1 CLZERO void [ 0f 01 fc] FUTURE,AMD @@ -5314,4 +5317,3 @@ HINT_NOP62 rm64 [m: o64 0f 1f /6] X64,UNDOC HINT_NOP63 rm16 [m: o16 0f 1f /7] P6,UNDOC HINT_NOP63 rm32 [m: o32 0f 1f /7] P6,UNDOC HINT_NOP63 rm64 [m: o64 0f 1f /7] X64,UNDOC - From 9b630b4361f558c56dac83e5dd620760f4ab77d7 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 3 Oct 2016 23:35:25 -0700 Subject: [PATCH 5/8] insns: add OBSOLETE flag for instructions removed from architecture There aren't that many instructions which have been rmeoved from the x86 architecture, but there is a handful. Flag those with an OBSOLETE flag. Signed-off-by: H. Peter Anvin --- insns-iflags.pl | 1 + insns.dat | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/insns-iflags.pl b/insns-iflags.pl index 1cd7a4c3..cad40b77 100644 --- a/insns-iflags.pl +++ b/insns-iflags.pl @@ -136,6 +136,7 @@ my %insns_flag_bit = ( "AVX512BW" => [ 73, "AVX-512 Byte and Word"], "AVX512IFMA" => [ 74, "AVX-512 IFMA instructions"], "AVX512VBMI" => [ 75, "AVX-512 VBMI instructions"], + "OBSOLETE" => [ 93, "Instruction removed from architecture"], "VEX" => [ 94, "VEX or XOP encoded instruction"], "EVEX" => [ 95, "EVEX encoded instruction"], diff --git a/insns.dat b/insns.dat index e9e9230c..d6f5c72a 100644 --- a/insns.dat +++ b/insns.dat @@ -191,8 +191,8 @@ AND mem,imm32 [mi: hle o32 81 /4 id] 386,SM,LOCK AND rm8,imm [mi: hle 82 /4 ib] 8086,SM,LOCK,ND,NOLONG ARPL mem,reg16 [mr: 63 /r] 286,PROT,SM,NOLONG ARPL reg16,reg16 [mr: 63 /r] 286,PROT,NOLONG -BB0_RESET void [ 0f 3a] PENT,CYRIX,ND -BB1_RESET void [ 0f 3b] PENT,CYRIX,ND +BB0_RESET void [ 0f 3a] PENT,CYRIX,ND,OBSOLETE +BB1_RESET void [ 0f 3b] PENT,CYRIX,ND,OBSOLETE BOUND reg16,mem [rm: o16 62 /r] 186,NOLONG BOUND reg32,mem [rm: o32 62 /r] 386,NOLONG BSF reg16,mem [rm: o16 nof3 0f bc /r] 386,SM @@ -335,12 +335,12 @@ CMPXCHG mem,reg32 [mr: hle o32 0f b1 /r] PENT,SM,LOCK CMPXCHG reg32,reg32 [mr: o32 0f b1 /r] PENT CMPXCHG mem,reg64 [mr: hle o64 0f b1 /r] X64,SM,LOCK CMPXCHG reg64,reg64 [mr: o64 0f b1 /r] X64 -CMPXCHG486 mem,reg8 [mr: 0f a6 /r] 486,SM,UNDOC,ND,LOCK -CMPXCHG486 reg8,reg8 [mr: 0f a6 /r] 486,UNDOC,ND -CMPXCHG486 mem,reg16 [mr: o16 0f a7 /r] 486,SM,UNDOC,ND,LOCK -CMPXCHG486 reg16,reg16 [mr: o16 0f a7 /r] 486,UNDOC,ND -CMPXCHG486 mem,reg32 [mr: o32 0f a7 /r] 486,SM,UNDOC,ND,LOCK -CMPXCHG486 reg32,reg32 [mr: o32 0f a7 /r] 486,UNDOC,ND +CMPXCHG486 mem,reg8 [mr: 0f a6 /r] 486,SM,UNDOC,ND,LOCK,OBSOLETE +CMPXCHG486 reg8,reg8 [mr: 0f a6 /r] 486,UNDOC,ND,OBSOLETE +CMPXCHG486 mem,reg16 [mr: o16 0f a7 /r] 486,SM,UNDOC,ND,LOCK,OBSOLETE +CMPXCHG486 reg16,reg16 [mr: o16 0f a7 /r] 486,UNDOC,ND,OBSOLETE +CMPXCHG486 mem,reg32 [mr: o32 0f a7 /r] 486,SM,UNDOC,ND,LOCK,OBSOLETE +CMPXCHG486 reg32,reg32 [mr: o32 0f a7 /r] 486,UNDOC,ND,OBSOLETE CMPXCHG8B mem [m: hle norexw 0f c7 /1] PENT,LOCK CMPXCHG16B mem [m: o64 0f c7 /1] X64,LOCK CPUID void [ 0f a2] PENT @@ -585,10 +585,10 @@ FXTRACT void [ d9 f4] 8086,FPU FYL2X void [ d9 f1] 8086,FPU FYL2XP1 void [ d9 f9] 8086,FPU HLT void [ f4] 8086,PRIV -IBTS mem,reg16 [mr: o16 0f a7 /r] 386,SW,UNDOC,ND -IBTS reg16,reg16 [mr: o16 0f a7 /r] 386,UNDOC,ND -IBTS mem,reg32 [mr: o32 0f a7 /r] 386,SD,UNDOC,ND -IBTS reg32,reg32 [mr: o32 0f a7 /r] 386,UNDOC,ND +IBTS mem,reg16 [mr: o16 0f a7 /r] 386,SW,UNDOC,ND,OBSOLETE +IBTS reg16,reg16 [mr: o16 0f a7 /r] 386,UNDOC,ND,OBSOLETE +IBTS mem,reg32 [mr: o32 0f a7 /r] 386,SD,UNDOC,ND,OBSOLETE +IBTS reg32,reg32 [mr: o32 0f a7 /r] 386,UNDOC,ND,OBSOLETE ICEBP void [ f1] 386,ND IDIV rm8 [m: f6 /7] 8086 IDIV rm16 [m: o16 f7 /7] 8086 @@ -751,8 +751,8 @@ LLDT reg16 [m: 0f 00 /2] 286,PROT,PRIV LMSW mem [m: 0f 01 /6] 286,PRIV LMSW mem16 [m: 0f 01 /6] 286,PRIV LMSW reg16 [m: 0f 01 /6] 286,PRIV -LOADALL void [ 0f 07] 386,UNDOC,ND -LOADALL286 void [ 0f 05] 286,UNDOC,ND +LOADALL void [ 0f 07] 386,UNDOC,ND,OBSOLETE +LOADALL286 void [ 0f 05] 286,UNDOC,ND,OBSOLETE LODSB void [ ac] 8086 LODSD void [ o32 ad] 386 LODSQ void [ o64 ad] X64 @@ -1016,7 +1016,7 @@ POP rm16 [m: o16 8f /0] 8086 POP rm32 [m: o32 8f /0] 386,NOLONG POP rm64 [m: o64nw 8f /0] X64 POP reg_es [-: 07] 8086,NOLONG -POP reg_cs [-: 0f] 8086,UNDOC,ND +POP reg_cs [-: 0f] 8086,UNDOC,ND,OBSOLETE POP reg_ss [-: 17] 8086,NOLONG POP reg_ds [-: 1f] 8086,NOLONG POP reg_fs [-: 0f a1] 386 @@ -1287,7 +1287,7 @@ SKINIT void [ 0f 01 de] X64 SMI void [ f1] 386,UNDOC SMINT void [ 0f 38] P6,CYRIX,ND ; Older Cyrix chips had this; they had to move due to conflict with MMX -SMINTOLD void [ 0f 7e] 486,CYRIX,ND +SMINTOLD void [ 0f 7e] 486,CYRIX,ND,OBSOLETE SMSW mem [m: 0f 01 /4] 286 SMSW mem16 [m: 0f 01 /4] 286 SMSW reg16 [m: o16 0f 01 /4] 286 @@ -5118,7 +5118,7 @@ WRPKRU void [ 0f 01 ef] X64,FUTURE CLFLUSHOPT mem [m: 66 0f ae /7] FUTURE CLWB mem [m: 66 0f ae /6] FUTURE ;# This one was killed before it saw the light of day -PCOMMIT void [ 66 0f ae f8] FUTURE,UNDOC +PCOMMIT void [ 66 0f ae f8] FUTURE,UNDOC,OBSOLETE ; AMD Zen v1 CLZERO void [ 0f 01 fc] FUTURE,AMD From 6a6a40c268d3c9ab020cf2cb39d3bdbe3a084ebb Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 3 Oct 2016 23:37:51 -0700 Subject: [PATCH 6/8] changes.src: document CLWB and PCOMMIT Signed-off-by: H. Peter Anvin --- doc/changes.src | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/changes.src b/doc/changes.src index 3cae1fa1..af2ababd 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -30,6 +30,11 @@ since 2007. \b Fix Codeview malformed compiler version record. +\b Add the \c{CLWB} and \c{PCOMMIT} instructions. Note that the + \c{PCOMMIT} instruction has been deprecated and will never be + included in a shipping product; it is included for completeness + only. + \S{cl-2.12.02} Version 2.12.02 \b Fix preprocessor errors, especially \c{%error} and \c{%warning}, From 20a38e43e4cd3fac1a5b86c49a4cc68f3cc30343 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 3 Oct 2016 23:57:44 -0700 Subject: [PATCH 7/8] NASM 2.12.03rc1 --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index a731342a..5c7362a2 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.12.02 +2.12.03rc1 From ce63783e85d79d8d21582c3458e2d7c7f8b77802 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 4 Oct 2016 00:04:44 -0700 Subject: [PATCH 8/8] changes.src: typographical adjustment Extremely minor typographical fix. Signed-off-by: H. Peter Anvin --- doc/changes.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes.src b/doc/changes.src index af2ababd..682c7d1c 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -44,7 +44,7 @@ since 2007. \b More Codeview debug format fixes. -\b If the MASM PTR keyword is encountered, issue a warning. This is +\b If the MASM \c{PTR} keyword is encountered, issue a warning. This is much more likely to indicate a MASM-ism encountered in NASM than it is a valid label. This warning can be suppressed with \c{-w-ptr}, the \c{[warning]} directive (see \k{opt-w}) or by the macro