This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: [PATCH][GAS][AArch64] Fix MSR/MRS Encoding and Decoding
- From: Tamar Christina <Tamar dot Christina at arm dot com>
- To: Andrew Pinski <pinskia at gmail dot com>
- Cc: binutils <binutils at sourceware dot org>, nd <nd at arm dot com>, Richard Earnshaw <Richard dot Earnshaw at arm dot com>, Marcus Shawcroft <Marcus dot Shawcroft at arm dot com>
- Date: Thu, 8 Mar 2018 18:42:30 +0000
- Subject: RE: [PATCH][GAS][AArch64] Fix MSR/MRS Encoding and Decoding
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Tamar dot Christina at arm dot com;
- Nodisclaimer: True
- References: <20180308181357.GA16889@arm.com> <CA+=Sn1kB0cOzL04kGdo628Ygdt=vSjB_QhP8HgS_zK=9F49fYQ@mail.gmail.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Hi Andrew,
> On Thu, Mar 8, 2018 at 10:14 AM, Tamar Christina <tamar.christina@arm.com>
> wrote:
> > Hi All,
> >
> > This patch corrects the opcode and mask for the MSR and MRS instructions.
> > These two instructions have bit 20 set but the current CORE_INSN do
> > not correctly have bit 20 set causing invalid encoding and decoding.
>
> I am trying to understand the patch but it is hard to figure out what was bad
> before hand. Can you show an example of the incorrect encoding that
> happens? The reason why I am asking is because I have a lot of code which
> has been using msr/mrs instructions (with the numbered operands) already
> and they are working.
This patch fixes two things:
1) Instructions that weren't MSR/MRS instructions were incorrectly being decoded
Such. E.g. .inst 0xd5000000 is unallocated but GAS will disassemble it as a valid MSR
Instruction.
2) a small subset of valid MSR/MRS instructions were being encoded incorrectly and
thus being decoded as other instructions. For instance msr s3_7_c15_c15_7, x27 was
previously being encoded as 0xd50ffffb and thus decoded as a "sys" instruction due to
the missing bit in the encoding. MSR and SYS are quite close in encoding.
If you look at the test file, it seems to indicate that the incorrect encoding is reasonably
rare. It looks like somehow for the majority of the cases GAS got the right encoding out.
I haven't looked at why this was the case, since the opcode and mask themselves were wrong.
Regards,
Tamar
>
> Thanks,
> Andrew
>
> >
> > Cross compiled and regtested:
> >
> > * aarch64-none-elf
> > * aarch64_be-none-elf
> >
> > and no regressions.
> >
> > Bootstrapped and regtested on:
> >
> > * aarch64-none-elf
> > * aarch64-none-elf (32 bit schroot)
> >
> > and no regressions.
> >
> > Ok for master?
> >
> > Thanks,
> > Tamar
> >
> > opcodes/
> > 2018-03-08 Tamar Christina <tamar.christina@arm.com>
> >
> > * aarch64-dis-2.c: Regenerate.
> > * aarch64-tbl.h (aarch64_opcode_table): Fix MSR and MRS encoding.
> >
> > gas/
> > 2018-03-08 Tamar Christina <tamar.christina@arm.com>
> >
> > * testsuite/gas/aarch64/sysreg-1.d: Update encodings.
> >
> > --
> <div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br /> <table
> style="border-top: 1px solid #D3D4DE;">
> <tr>
> <td style="width: 55px; padding-top: 13px;"><a
> href="http://www.avg.com/email-
> signature?utm_medium=email&utm_source=link&utm_campaign=sig-
> email&utm_content=webmail"
> target="_blank"><img
> src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-green-avg-
> v1.png"
> alt="" width="46" height="29" style="width: 46px; height: 29px;"
> /></a></td>
> <td style="width: 470px; padding-top: 12px; color: #41424e;
> font-size: 13px; font-family: Arial, Helvetica, sans-serif;
> line-height: 18px;">Virus-free. <a
> href="http://www.avg.com/email-
> signature?utm_medium=email&utm_source=link&utm_campaign=sig-
> email&utm_content=webmail"
> target="_blank" style="color: #4453ea;">www.avg.com</a>
> </td>
> </tr>
> </table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1"
> height="1"></a></div>