[PATCH] D36742: [LLD][ELF][AArch64] Implement scanner for Cortex-A53 Erratum 843419

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 27 09:56:42 PST 2017


On 27 November 2017 at 17:30, Rafael Avila de Espindola
<rafael.espindola at gmail.com> wrote:
> Peter Smith <peter.smith at linaro.org> writes:
>
>>>> At the moment, until https://reviews.llvm.org/D37944 Add support for AArch64 Range Thunks lands the assignAddresses won't be entered. Some merge work will be needed here as Thunks and Errata fixes can impact each other.
>>>
>>> How? Can't you always put the errata fixes after all regular code?
>>>
>>
>> Not always if the program is large. I've recently been investigating a
>> problem with the gold implementation of --fix-cortex-a53-843419
>> (https://sourceware.org/bugzilla/show_bug.cgi?id=20765) in that
>> program there is over 180 Mb of code (quite a lot for a wiki editor,
>> but apparently Haskell tends to produce huge binaries) which in effect
>> means:
>> ~ 128 Mb code
>> Thunks and errata for first ~128Mb
>> ~ more code
>> Thunks and errata for next ~128Mb
>>
>> If these are all in the same OutputSection then adding errata fixes to
>> the first chunk will affect the ranges of the code after it, which may
>> need more Thunks. The gold problem is an internal error when that
>> condition occurs.
>
> But the patched errata code could use an adrp to just up to 4g ahead,
> no?
>

Unfortunately not easily as the control flow change is three
instructions (adrp reg, dest , add reg, reg, :lo12:dest, br reg) is
three instructions and needs a spare register, that we might need to
spill to obtain.

The erratum is worked around by copying a 4-byte sized LDR/STR
instruction into the patch, then overwriting the LDR/STR with a 4-byte
sized branch. In theory we could copy 3 instructions into the patch,
but this would be much harder to patch as we'd need to make sure that
it was safe to do so (for example instructions with pc-relative
immediates). The return sequence from the patch can in theory use use
the longer range ADRP form but again we'd need a spare register.

Peter


More information about the llvm-commits mailing list