diff options
author | Bob Cochran <yocto@mindchasers.com> | 2017-04-03 23:32:55 -0400 |
---|---|---|
committer | Otavio Salvador <otavio@ossystems.com.br> | 2017-04-11 18:45:55 -0300 |
commit | d7899bf507373a2f9df5afdf6174fb088d96a46a (patch) | |
tree | 0ee30df04af440e3050c14987109028dddec07b1 | |
parent | 8451a4648dae73e92492e9e60d73e9a9b768397a (diff) | |
download | meta-freescale-d7899bf507373a2f9df5afdf6174fb088d96a46a.tar.gz |
linux-qoriq, powerpc: kernel patches for cmp assembly instructions that fail with binutils 2.28
linux-qoriq 4.1.35 64b kernel fails to build for
vdso64/gettimeofday.S, vdso64/datapage.S, and head_64.S due to
incorrectly coded cmp instructions. Apply two existing kernel patches
from upstream, mainline kernel to correct the coding of these
instructions.
Built and tested on an e5500 t1040rdb-64b machine
Change-Id: I710d0d1a5b886cc23c2aa0052e0ec1c148870635
Signed-off-by: Bob Cochran <yocto@mindchasers.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
3 files changed, 126 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-qoriq/powerpc-64e-Convert-cmpi-to-cmpwi-in-head_64.S.patch b/recipes-kernel/linux/linux-qoriq/powerpc-64e-Convert-cmpi-to-cmpwi-in-head_64.S.patch new file mode 100644 index 00000000..710b2122 --- /dev/null +++ b/recipes-kernel/linux/linux-qoriq/powerpc-64e-Convert-cmpi-to-cmpwi-in-head_64.S.patch | |||
@@ -0,0 +1,57 @@ | |||
1 | From f87f253bac3ce4a4eb2a60a1ae604d74e65f9042 Mon Sep 17 00:00:00 2001 | ||
2 | From: Nicholas Piggin <npiggin@gmail.com> | ||
3 | Date: Thu, 24 Nov 2016 00:02:07 +1100 | ||
4 | Subject: [PATCH] powerpc/64e: Convert cmpi to cmpwi in head_64.S | ||
5 | |||
6 | From 80f23935cadb ("powerpc: Convert cmp to cmpd in idle enter sequence"): | ||
7 | |||
8 | PowerPC's "cmp" instruction has four operands. Normally people write | ||
9 | "cmpw" or "cmpd" for the second cmp operand 0 or 1. But, frequently | ||
10 | people forget, and write "cmp" with just three operands. | ||
11 | |||
12 | With older binutils this is silently accepted as if this was "cmpw", | ||
13 | while often "cmpd" is wanted. With newer binutils GAS will complain | ||
14 | about this for 64-bit code. For 32-bit code it still silently assumes | ||
15 | "cmpw" is what is meant. | ||
16 | |||
17 | In this case, cmpwi is called for, so this is just a build fix for | ||
18 | new toolchains. | ||
19 | |||
20 | Cc: stable@vger.kernel.org # v3.0+ | ||
21 | Signed-off-by: Nicholas Piggin <npiggin@gmail.com> | ||
22 | Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> | ||
23 | --- | ||
24 | arch/powerpc/kernel/head_64.S | 8 ++++---- | ||
25 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
26 | |||
27 | diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S | ||
28 | index 451a8e1..bdb4612 100644 | ||
29 | --- a/arch/powerpc/kernel/head_64.S | ||
30 | +++ b/arch/powerpc/kernel/head_64.S | ||
31 | @@ -221,9 +221,9 @@ booting_thread_hwid: | ||
32 | */ | ||
33 | _GLOBAL(book3e_start_thread) | ||
34 | LOAD_REG_IMMEDIATE(r5, MSR_KERNEL) | ||
35 | - cmpi 0, r3, 0 | ||
36 | + cmpwi r3, 0 | ||
37 | beq 10f | ||
38 | - cmpi 0, r3, 1 | ||
39 | + cmpwi r3, 1 | ||
40 | beq 11f | ||
41 | /* If the thread id is invalid, just exit. */ | ||
42 | b 13f | ||
43 | @@ -248,9 +248,9 @@ _GLOBAL(book3e_start_thread) | ||
44 | * r3 = the thread physical id | ||
45 | */ | ||
46 | _GLOBAL(book3e_stop_thread) | ||
47 | - cmpi 0, r3, 0 | ||
48 | + cmpwi r3, 0 | ||
49 | beq 10f | ||
50 | - cmpi 0, r3, 1 | ||
51 | + cmpwi r3, 1 | ||
52 | beq 10f | ||
53 | /* If the thread id is invalid, just exit. */ | ||
54 | b 13f | ||
55 | -- | ||
56 | 2.7.4 | ||
57 | |||
diff --git a/recipes-kernel/linux/linux-qoriq/powerpc-vdso64-Use-double-word-compare-on-pointers.patch b/recipes-kernel/linux/linux-qoriq/powerpc-vdso64-Use-double-word-compare-on-pointers.patch new file mode 100644 index 00000000..9fa40de4 --- /dev/null +++ b/recipes-kernel/linux/linux-qoriq/powerpc-vdso64-Use-double-word-compare-on-pointers.patch | |||
@@ -0,0 +1,67 @@ | |||
1 | From 5045ea37377ce8cca6890d32b127ad6770e6dce5 Mon Sep 17 00:00:00 2001 | ||
2 | From: Anton Blanchard <anton@samba.org> | ||
3 | Date: Sun, 25 Sep 2016 17:16:53 +1000 | ||
4 | Subject: [PATCH] powerpc/vdso64: Use double word compare on pointers | ||
5 | |||
6 | __kernel_get_syscall_map() and __kernel_clock_getres() use cmpli to | ||
7 | check if the passed in pointer is non zero. cmpli maps to a 32 bit | ||
8 | compare on binutils, so we ignore the top 32 bits. | ||
9 | |||
10 | A simple test case can be created by passing in a bogus pointer with | ||
11 | the bottom 32 bits clear. Using a clk_id that is handled by the VDSO, | ||
12 | then one that is handled by the kernel shows the problem: | ||
13 | |||
14 | printf("%d\n", clock_getres(CLOCK_REALTIME, (void *)0x100000000)); | ||
15 | printf("%d\n", clock_getres(CLOCK_BOOTTIME, (void *)0x100000000)); | ||
16 | |||
17 | And we get: | ||
18 | |||
19 | 0 | ||
20 | -1 | ||
21 | |||
22 | The bigger issue is if we pass a valid pointer with the bottom 32 bits | ||
23 | clear, in this case we will return success but won't write any data | ||
24 | to the pointer. | ||
25 | |||
26 | I stumbled across this issue because the LLVM integrated assembler | ||
27 | doesn't accept cmpli with 3 arguments. Fix this by converting them to | ||
28 | cmpldi. | ||
29 | |||
30 | Fixes: a7f290dad32e ("[PATCH] powerpc: Merge vdso's and add vdso support to 32 bits kernel") | ||
31 | Cc: stable@vger.kernel.org # v2.6.15+ | ||
32 | Signed-off-by: Anton Blanchard <anton@samba.org> | ||
33 | Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> | ||
34 | --- | ||
35 | arch/powerpc/kernel/vdso64/datapage.S | 2 +- | ||
36 | arch/powerpc/kernel/vdso64/gettimeofday.S | 2 +- | ||
37 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
38 | |||
39 | diff --git a/arch/powerpc/kernel/vdso64/datapage.S b/arch/powerpc/kernel/vdso64/datapage.S | ||
40 | index 184a6ba..abf17fe 100644 | ||
41 | --- a/arch/powerpc/kernel/vdso64/datapage.S | ||
42 | +++ b/arch/powerpc/kernel/vdso64/datapage.S | ||
43 | @@ -59,7 +59,7 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map) | ||
44 | bl V_LOCAL_FUNC(__get_datapage) | ||
45 | mtlr r12 | ||
46 | addi r3,r3,CFG_SYSCALL_MAP64 | ||
47 | - cmpli cr0,r4,0 | ||
48 | + cmpldi cr0,r4,0 | ||
49 | crclr cr0*4+so | ||
50 | beqlr | ||
51 | li r0,NR_syscalls | ||
52 | diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S | ||
53 | index a76b4af..3820213 100644 | ||
54 | --- a/arch/powerpc/kernel/vdso64/gettimeofday.S | ||
55 | +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S | ||
56 | @@ -145,7 +145,7 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) | ||
57 | bne cr0,99f | ||
58 | |||
59 | li r3,0 | ||
60 | - cmpli cr0,r4,0 | ||
61 | + cmpldi cr0,r4,0 | ||
62 | crclr cr0*4+so | ||
63 | beqlr | ||
64 | lis r5,CLOCK_REALTIME_RES@h | ||
65 | -- | ||
66 | 2.7.4 | ||
67 | |||
diff --git a/recipes-kernel/linux/linux-qoriq_4.1.bb b/recipes-kernel/linux/linux-qoriq_4.1.bb index 6c2b2351..12d12f53 100644 --- a/recipes-kernel/linux/linux-qoriq_4.1.bb +++ b/recipes-kernel/linux/linux-qoriq_4.1.bb | |||
@@ -15,6 +15,8 @@ SRC_URI = "git://git.freescale.com/ppc/sdk/linux.git;nobranch=1 \ | |||
15 | file://powerpc-fsl-Fix-build-of-the-dtb-embedded-kernel-images.patch \ | 15 | file://powerpc-fsl-Fix-build-of-the-dtb-embedded-kernel-images.patch \ |
16 | file://CVE-2016-2053.patch \ | 16 | file://CVE-2016-2053.patch \ |
17 | file://CVE-2016-0758.patch \ | 17 | file://CVE-2016-0758.patch \ |
18 | file://powerpc-64e-Convert-cmpi-to-cmpwi-in-head_64.S.patch \ | ||
19 | file://powerpc-vdso64-Use-double-word-compare-on-pointers.patch \ | ||
18 | " | 20 | " |
19 | SRCREV = "b14540ee315f79f6a5dfc621e7f4217c8fac7d1c" | 21 | SRCREV = "b14540ee315f79f6a5dfc621e7f4217c8fac7d1c" |
20 | 22 | ||