[PATCH v2] x86: Ignore CS, DS, ES, and SS segment-override prefixes in 64-bit mode
H.J. Lu
hjl.tools@gmail.com
Mon Nov 2 14:59:26 GMT 2020
On Sun, Nov 1, 2020 at 2:46 PM Borislav Petkov <bp@suse.de> wrote:
>
> On Wed, Oct 28, 2020 at 09:59:24PM +0100, Borislav Petkov wrote:
> > On Sun, Oct 25, 2020 at 11:23:12AM -0700, H.J. Lu wrote:
> > > Yes, this looks right. Please add a testcase to verify it.
> >
> > Yeah, I need to analyze and address a couple of testcases failures
> > first. Will send v2 when ready.
>
> Ok, here's v2. I've fixed all test cases that started failing due to the
> change so that they accept the new format, see below. With that, there's
> no need for adding a new testcase as the old ones are simply made to
> check for the new dumping of prefixes before the insn.
>
> Also, I've added
>
> gas/testsuite/ChangeLog
> ld/testsuite/ChangeLog
>
> because there weren't changelog files for this year. I hope that is the
> correct way to do that.
>
> What also needed adjustment is the NOTRACK_Fixup() handling, see also
> below.
>
> Now all testcases pass again.
>
> Thx.
>
> ---
> From: Borislav Petkov <bp@suse.de>
> Date: Sun, 25 Oct 2020 10:23:26 +0100
>
> In 64-bit mode, the four segment override prefixes are ignored:
>
> "In 64-bit mode, the CS, DS, ES, and SS segment-override prefixes have
> no effect. These four prefixes are not treated as segment-override
> prefixes for the purposes of multiple-prefix rules. Instead, they are
> treated as null prefixes." (AMD APM v2).
>
> However, objdump disassembles instructions containing those ignored
> prefixes by still generating that segment override:
>
> 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1)
> 00 00 00 00
>
> Print those segment override prefixes as excessive ones:
>
> 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
> 00 00 00 00
>
> which is what they actually are - they have no effect and the decoding
> hardware ignores them.
> ---
> gas/testsuite/ChangeLog | 37 ++++
> .../gas/i386/ilp32/x86-64-nops-1-core2.d | 12 +-
> .../gas/i386/ilp32/x86-64-nops-1-k8.d | 12 +-
> gas/testsuite/gas/i386/ilp32/x86-64-nops-1.d | 12 +-
> gas/testsuite/gas/i386/ilp32/x86-64-nops-2.d | 14 +-
> gas/testsuite/gas/i386/ilp32/x86-64-nops-3.d | 6 +-
> .../gas/i386/ilp32/x86-64-nops-4-core2.d | 54 +++---
> .../gas/i386/ilp32/x86-64-nops-4-k8.d | 54 +++---
> gas/testsuite/gas/i386/ilp32/x86-64-nops-4.d | 54 +++---
> .../gas/i386/ilp32/x86-64-nops-5-k8.d | 16 +-
> gas/testsuite/gas/i386/ilp32/x86-64-nops-5.d | 16 +-
> gas/testsuite/gas/i386/ilp32/x86-64-nops.d | 2 +-
> .../gas/i386/x86-64-align-branch-1a.d | 4 +-
> .../gas/i386/x86-64-align-branch-1b.d | 4 +-
> .../gas/i386/x86-64-align-branch-1c.d | 4 +-
> .../gas/i386/x86-64-align-branch-1d.d | 2 +-
> .../gas/i386/x86-64-align-branch-1g.d | 4 +-
> .../gas/i386/x86-64-align-branch-2c.d | 4 +-
> .../gas/i386/x86-64-align-branch-6.d | 10 +-
> .../gas/i386/x86-64-align-branch-7.d | 2 +-
> .../gas/i386/x86-64-align-branch-8.d | 2 +-
> gas/testsuite/gas/i386/x86-64-nop-1.d | 28 +--
> gas/testsuite/gas/i386/x86-64-nops-1-core2.d | 12 +-
> gas/testsuite/gas/i386/x86-64-nops-1-g64.d | 12 +-
> gas/testsuite/gas/i386/x86-64-nops-1-k8.d | 12 +-
> gas/testsuite/gas/i386/x86-64-nops-1.d | 12 +-
> gas/testsuite/gas/i386/x86-64-nops-2.d | 14 +-
> gas/testsuite/gas/i386/x86-64-nops-3.d | 6 +-
> gas/testsuite/gas/i386/x86-64-nops-4-core2.d | 54 +++---
> gas/testsuite/gas/i386/x86-64-nops-4-k8.d | 54 +++---
> gas/testsuite/gas/i386/x86-64-nops-4.d | 54 +++---
> gas/testsuite/gas/i386/x86-64-nops-5-k8.d | 16 +-
> gas/testsuite/gas/i386/x86-64-nops-5.d | 16 +-
> gas/testsuite/gas/i386/x86-64-nops-7.d | 172 +++++++++---------
> gas/testsuite/gas/i386/x86-64-nops.d | 2 +-
> gas/testsuite/gas/i386/x86-64-segovr.d | 32 ++--
> ld/testsuite/ChangeLog | 6 +
> ld/testsuite/ld-x86-64/align-branch-1.d | 2 +-
> ld/testsuite/ld-x86-64/pe-x86-64-4.od | 2 +-
> ld/testsuite/ld-x86-64/tlsld3.dd | 2 +-
> ld/testsuite/ld-x86-64/tlsld4.dd | 2 +-
> opcodes/ChangeLog | 5 +
> opcodes/i386-dis.c | 25 ++-
> 43 files changed, 464 insertions(+), 401 deletions(-)
> create mode 100644 gas/testsuite/ChangeLog
> create mode 100644 ld/testsuite/ChangeLog
>
+2020-10-26 Borislav Petkov <bp@suse.de>
+
+ * opcodes/i386-dis.c: Ignore CS,DS,FS,ES segment override prefix in
+ 64-bit mode.
Please mention what you changed in which functions in ChangeLog
entry. OK with these changes.
Thanks.
--
H.J.
More information about the Binutils
mailing list