[v2,4/4] x86: extend LEA's segment override warning to applicable MPX insns

Message ID 2b37489d-aa20-9c84-08b9-515de2032d12@suse.com
State New
Headers show
Series
  • x86: segment override handling adjustments
Related show

Commit Message

Jan Beulich Feb. 14, 2020, 11:44 a.m.
Besides LEA there are a couple of MPX insns behaving LEA-like, which
should be warned about in the same way.

gas/
2020-02-XX  Jan Beulich  <jbeulich@suse.com>

	* config/tc-i386.c (process_operands): Also check insn prefix
	for ineffectual segment override warning. Also cover BNDC* and
	BNDMK there. Don't cover possible VEX/EVEX encoded insns there.
	* testsuite/gas/i386/lea.s, testsuite/gas/i386/lea.d,
	testsuite/gas/i386/lea.e: New.
	* testsuite/gas/i386/i386.exp: Run new test.

Comments

H.J. Lu Feb. 14, 2020, 12:04 p.m. | #1
On Fri, Feb 14, 2020 at 3:44 AM Jan Beulich <jbeulich@suse.com> wrote:
>

> Besides LEA there are a couple of MPX insns behaving LEA-like, which

> should be warned about in the same way.

>

> gas/

> 2020-02-XX  Jan Beulich  <jbeulich@suse.com>

>

>         * config/tc-i386.c (process_operands): Also check insn prefix

>         for ineffectual segment override warning. Also cover BNDC* and

>         BNDMK there. Don't cover possible VEX/EVEX encoded insns there.

>         * testsuite/gas/i386/lea.s, testsuite/gas/i386/lea.d,

>         testsuite/gas/i386/lea.e: New.

>         * testsuite/gas/i386/i386.exp: Run new test.

>

> --- a/gas/config/tc-i386.c

> +++ b/gas/config/tc-i386.c

> @@ -7195,7 +7195,8 @@ duplicate:

>      }

>

>    if ((i.seg[0] || i.prefix[SEG_PREFIX])

> -      && i.tm.base_opcode == 0x8d /* lea */

> +      && (i.tm.base_opcode == 0x8d /* lea */

> +          || ((i.tm.base_opcode | 0x010001) == 0xf30f1b) /* bnd{c[lnu],mk} */)

>        && !is_any_vex_encoding(&i.tm))


There is no need for it.  Since MPX has been deprecated, I doubt anyone
will update MPX assembly codes even if they trigger this new warning.

-- 
H.J.
Jan Beulich Feb. 14, 2020, 12:08 p.m. | #2
On 14.02.2020 13:04, H.J. Lu wrote:
> On Fri, Feb 14, 2020 at 3:44 AM Jan Beulich <jbeulich@suse.com> wrote:

>>

>> Besides LEA there are a couple of MPX insns behaving LEA-like, which

>> should be warned about in the same way.

>>

>> gas/

>> 2020-02-XX  Jan Beulich  <jbeulich@suse.com>

>>

>>         * config/tc-i386.c (process_operands): Also check insn prefix

>>         for ineffectual segment override warning. Also cover BNDC* and

>>         BNDMK there. Don't cover possible VEX/EVEX encoded insns there.

>>         * testsuite/gas/i386/lea.s, testsuite/gas/i386/lea.d,

>>         testsuite/gas/i386/lea.e: New.

>>         * testsuite/gas/i386/i386.exp: Run new test.

>>

>> --- a/gas/config/tc-i386.c

>> +++ b/gas/config/tc-i386.c

>> @@ -7195,7 +7195,8 @@ duplicate:

>>      }

>>

>>    if ((i.seg[0] || i.prefix[SEG_PREFIX])

>> -      && i.tm.base_opcode == 0x8d /* lea */

>> +      && (i.tm.base_opcode == 0x8d /* lea */

>> +          || ((i.tm.base_opcode | 0x010001) == 0xf30f1b) /* bnd{c[lnu],mk} */)

>>        && !is_any_vex_encoding(&i.tm))

> 

> There is no need for it.  Since MPX has been deprecated, I doubt anyone

> will update MPX assembly codes even if they trigger this new warning.


There's perhaps as much doubt about this as there is on there being
people actually using segment overrides with LEA and alike. If it
was code I'm the maintainer for, I'd be glad if such issues were
pointed out to me. But anyway - you've made your position clear
before, and I've added this as the last patch here just for
completeness (as I'll want to have this in my local trees down the
road anyway).

Jan

Patch

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -7195,7 +7195,8 @@  duplicate:
     }
 
   if ((i.seg[0] || i.prefix[SEG_PREFIX])
-      && i.tm.base_opcode == 0x8d /* lea */
+      && (i.tm.base_opcode == 0x8d /* lea */
+          || ((i.tm.base_opcode | 0x010001) == 0xf30f1b) /* bnd{c[lnu],mk} */)
       && !is_any_vex_encoding(&i.tm))
     {
       if (!quiet_warnings)
--- a/gas/testsuite/gas/i386/lea-optimize.d
+++ b/gas/testsuite/gas/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 	]+bndcn[ 	]+%ss:\(%eax\),%bnd0
+[ 	]*[0-9a-f]+:[ 	]+36 f2 0f 1b 00[ 	]+bndcn[ 	]+%ss:\(%eax\),%bnd0
+[ 	]*[0-9a-f]+:[ 	]+36 f2 0f 1a 00[ 	]+bndcu[ 	]+%ss:\(%eax\),%bnd0
+[ 	]*[0-9a-f]+:[ 	]+36 f2 0f 1a 00[ 	]+bndcu[ 	]+%ss:\(%eax\),%bnd0
+[ 	]*[0-9a-f]+:[ 	]+36 f3 0f 1b 00[ 	]+bndmk[ 	]+%ss:\(%eax\),%bnd0
+[ 	]*[0-9a-f]+:[ 	]+36 f3 0f 1b 00[ 	]+bndmk[ 	]+%ss:\(%eax\),%bnd0
 #pass
--- a/gas/testsuite/gas/i386/lea.e
+++ b/gas/testsuite/gas/i386/lea.e
@@ -1,3 +1,11 @@ 
 .*: Assembler messages:
 .*:3: Warning: .* `lea' .*
 .*:4: Warning: .* `lea' .*
+.*:6: Warning: .* `bndcl' .*
+.*:7: Warning: .* `bndcl' .*
+.*:9: Warning: .* `bndcn' .*
+.*:10: Warning: .* `bndcn' .*
+.*:12: Warning: .* `bndcu' .*
+.*:13: Warning: .* `bndcu' .*
+.*:15: Warning: .* `bndmk' .*
+.*:16: Warning: .* `bndmk' .*
--- a/gas/testsuite/gas/i386/lea.s
+++ b/gas/testsuite/gas/i386/lea.s
@@ -2,3 +2,15 @@ 
 start:
 	lea	%ss:(%eax), %eax
 	ss lea	(%eax), %eax
+
+	bndcl	%ss:(%eax), %bnd0
+	ss bndcl (%eax), %bnd0
+
+	bndcn	%ss:(%eax), %bnd0
+	ss bndcn (%eax), %bnd0
+
+	bndcu	%ss:(%eax), %bnd0
+	ss bndcu (%eax), %bnd0
+
+	bndmk	%ss:(%eax), %bnd0
+	ss bndmk (%eax), %bnd0