aboutsummaryrefslogtreecommitdiff
path: root/net/lapb/lapb_subr.c
diff options
context:
space:
mode:
authorAndre Przywara <[email protected]>2021-11-22 16:28:43 +0100
committerRussell King (Oracle) <[email protected]>2021-12-17 11:34:32 +0000
commita92882a4d270fbcc021ee6848de5e48b7f0d27f3 (patch)
treede3076ca481ef27ab9d655ec9a989beebb8a4079 /net/lapb/lapb_subr.c
parent4a2f57ac7dada84224d71fe895580990b9062d68 (diff)
ARM: 9159/1: decompressor: Avoid UNPREDICTABLE NOP encoding
In the decompressor's head.S we need to start with an instruction that is some kind of NOP, but also mimics as the PE/COFF header, when the kernel is linked as an UEFI application. The clever solution here is "tstne r0, #0x4d000", which in the worst case just clobbers the condition flags, and bears the magic "MZ" signature in the lowest 16 bits. However the encoding used (0x13105a4d) is actually not valid, since bits [15:12] are supposed to be 0 (written as "(0)" in the ARM ARM). Violating this is UNPREDICTABLE, and *can* trigger an UNDEFINED exception. Common Cortex cores seem to ignore those bits, but QEMU chooses to trap, so the code goes fishing because of a missing exception handler at this point. We are just saved by the fact that commonly (with -kernel or when running from U-Boot) the "Z" bit is set, so the instruction is never executed. See [0] for more details. To make things more robust and avoid UNPREDICTABLE behaviour in the kernel code, lets replace this with a "two-instruction NOP": The first instruction is an exclusive OR, the effect of which the second instruction reverts. This does not leave any trace, neither in a register nor in the condition flags. Also it's a perfectly valid encoding. Kudos to Peter Maydell for coming up with this gem. [0] https://lore.kernel.org/qemu-devel/YTPIdbUCmwagL5%[email protected]/T/ Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/T/ Fixes: 81a0bc39ea19 ("ARM: add UEFI stub support") Signed-off-by: Andre Przywara <[email protected]> Reported-by: Adam Lackorzynski <[email protected]> Suggested-by: Peter Maydell <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]>
Diffstat (limited to 'net/lapb/lapb_subr.c')
0 files changed, 0 insertions, 0 deletions