Re: [PATCH v2] ARM: kprobes: rewrite test-[arm|thumb].c in UAL

From: Nick Desaulniers
Date: Thu Jan 28 2021 - 19:23:14 EST


> On Thu, 28 Jan 2021 at 20:34, Nick Desaulniers <ndesaulniers@xxxxxxxxxx> wrote:
> > + TEST_RX("tbh [pc, r",7, (9f-(1f+4))>>1,", lsl #1]",
> >
> On Thu, Jan 28, 2021 at 1:03 PM Ard Biesheuvel <ardb@xxxxxxxxxx> wrote:
> Why is this change needed? Are the resulting opcodes equivalent? Does
> GAS infer the lsl #1 but Clang doesn't?

Yes; it seems if you serialize/deserialize this using GNU `as` and
objdump, that's the canonical form (GNU objdump seems to print in UAL
form, IIUC). I didn't see anything specifically about `tbh` in
https://developer.arm.com/documentation/dui0473/c/writing-arm-assembly-language/assembly-language-changes-after-rvctv2-1?lang=en
but it's what GNU objdump produces and what clang's integrated
assembler accepts.

> >
> > #define _DATA_PROCESSING32_DNM(op,s,val) \
> > - TEST_RR(op s".w r0, r",1, VAL1,", r",2, val, "") \
> > + TEST_RR(op s" r0, r",1, VAL1,", r",2, val, "") \
>
> What is wrong with these .w suffixes? Shouldn't the assembler accept
> these even on instructions that only exist in a wide encoding?

Yeah, I'm not sure these have anything to do with UAL. Looking at
LLVM's sources and IIRC, LLVM has "InstAlias"es it uses for .w
suffixes. I think I need to fix those in LLVM for a couple
instructions, rather than modify these in kernel sources. I'll split
off the arm-test.c and thumb-test.c into separate patches, fix LLVM,
and drop the .w suffix changes to thumb-test.c.

--
Thanks,
~Nick Desaulniers