]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.249/arm-p2v-fix-handling-of-lpae-translation-in-be-mode.patch
6.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.249 / arm-p2v-fix-handling-of-lpae-translation-in-be-mode.patch
CommitLineData
5a4432b0
SL
1From 3ebfffa9fc0040c17a701bf2129d01b544ba0cd5 Mon Sep 17 00:00:00 2001
2From: Sasha Levin <sashal@kernel.org>
3Date: Mon, 21 Sep 2020 00:10:16 +0200
4Subject: ARM: p2v: fix handling of LPAE translation in BE mode
5
6From: Ard Biesheuvel <ardb@kernel.org>
7
8[ Upstream commit 4e79f0211b473f8e1eab8211a9fd50cc41a3a061 ]
9
10When running in BE mode on LPAE hardware with a PA-to-VA translation
11that exceeds 4 GB, we patch bits 39:32 of the offset into the wrong
12byte of the opcode. So fix that, by rotating the offset in r0 to the
13right by 8 bits, which will put the 8-bit immediate in bits 31:24.
14
15Note that this will also move bit #22 in its correct place when
16applying the rotation to the constant #0x400000.
17
18Fixes: d9a790df8e984 ("ARM: 7883/1: fix mov to mvn conversion in case of 64 bit phys_addr_t and BE")
19Acked-by: Nicolas Pitre <nico@fluxnic.net>
20Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
21Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
22Signed-off-by: Sasha Levin <sashal@kernel.org>
23---
24 arch/arm/kernel/head.S | 6 +-----
25 1 file changed, 1 insertion(+), 5 deletions(-)
26
27diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
28index 04286fd9e09ce..2e336acd68b0a 100644
29--- a/arch/arm/kernel/head.S
30+++ b/arch/arm/kernel/head.S
31@@ -673,12 +673,8 @@ ARM_BE8(rev16 ip, ip)
32 ldrcc r7, [r4], #4 @ use branch for delay slot
33 bcc 1b
34 bx lr
35-#else
36-#ifdef CONFIG_CPU_ENDIAN_BE8
37- moveq r0, #0x00004000 @ set bit 22, mov to mvn instruction
38 #else
39 moveq r0, #0x400000 @ set bit 22, mov to mvn instruction
40-#endif
41 b 2f
42 1: ldr ip, [r7, r3]
43 #ifdef CONFIG_CPU_ENDIAN_BE8
44@@ -687,7 +683,7 @@ ARM_BE8(rev16 ip, ip)
45 tst ip, #0x000f0000 @ check the rotation field
46 orrne ip, ip, r6, lsl #24 @ mask in offset bits 31-24
47 biceq ip, ip, #0x00004000 @ clear bit 22
48- orreq ip, ip, r0 @ mask in offset bits 7-0
49+ orreq ip, ip, r0, ror #8 @ mask in offset bits 7-0
50 #else
51 bic ip, ip, #0x000000ff
52 tst ip, #0xf00 @ check the rotation field
53--
542.27.0
55