This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH][GAS][AArch64] Fix MSR/MRS Encoding and Decoding


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>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]