diff options
| author | He Zhe <zhe.he@windriver.com> | 2022-10-17 18:01:01 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-10-20 15:36:02 +0100 |
| commit | 59d2aeb3b18d94f3397d7097e34bc61790e37b0d (patch) | |
| tree | af983a05d01da70813e560f3465d52386278b796 /meta | |
| parent | 96a316068f770daeec2bb044141d968ada7fc39b (diff) | |
| download | poky-59d2aeb3b18d94f3397d7097e34bc61790e37b0d.tar.gz | |
lttng-modules: Fix crash on powerpc64
Backport a patch to fix the following on powerpc64 ABIv2.
root@qemuppc64:~# lttng create trace_session --live -U net://127.0.0.1
Spawning a session daemon
lttng_kretprobes: loading out-of-tree module taints kernel.
BUG: Unable to handle kernel data access on read at 0xfffffffffffffff8
Faulting instruction address: 0xc0000000001f6fd0
Oops: Kernel access of bad area, sig: 11 [#1]
<snip>
(From OE-Core rev: 4781fee6aea9512b7cb390b76e6f9f0a86a5bd11)
Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/recipes-kernel/lttng/lttng-modules/0001-wrapper-powerpc64-fix-kernel-crash-caused-by-do_get_.patch | 94 | ||||
| -rw-r--r-- | meta/recipes-kernel/lttng/lttng-modules_2.13.4.bb | 1 |
2 files changed, 95 insertions, 0 deletions
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0001-wrapper-powerpc64-fix-kernel-crash-caused-by-do_get_.patch b/meta/recipes-kernel/lttng/lttng-modules/0001-wrapper-powerpc64-fix-kernel-crash-caused-by-do_get_.patch new file mode 100644 index 0000000000..b3b191c7ac --- /dev/null +++ b/meta/recipes-kernel/lttng/lttng-modules/0001-wrapper-powerpc64-fix-kernel-crash-caused-by-do_get_.patch | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | From 480cce4315ce5bf59a509e8a53a52545f393de68 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: He Zhe <zhe.he@windriver.com> | ||
| 3 | Date: Tue, 27 Sep 2022 15:59:42 +0800 | ||
| 4 | Subject: [PATCH] wrapper: powerpc64: fix kernel crash caused by | ||
| 5 | do_get_kallsyms | ||
| 6 | |||
| 7 | Kernel crashes on powerpc64 ABIv2 as follow when lttng_tracer initializes, | ||
| 8 | since do_get_kallsyms in lttng_wrapper fails to return a proper address of | ||
| 9 | kallsyms_lookup_name. | ||
| 10 | |||
| 11 | root@qemuppc64:~# lttng create trace_session --live -U net://127.0.0.1 | ||
| 12 | Spawning a session daemon | ||
| 13 | lttng_kretprobes: loading out-of-tree module taints kernel. | ||
| 14 | BUG: Unable to handle kernel data access on read at 0xfffffffffffffff8 | ||
| 15 | Faulting instruction address: 0xc0000000001f6fd0 | ||
| 16 | Oops: Kernel access of bad area, sig: 11 [#1] | ||
| 17 | <snip> | ||
| 18 | NIP [c0000000001f6fd0] module_kallsyms_lookup_name+0xf0/0x180 | ||
| 19 | LR [c0000000001f6f28] module_kallsyms_lookup_name+0x48/0x180 | ||
| 20 | Call Trace: | ||
| 21 | module_kallsyms_lookup_name+0x34/0x180 (unreliable) | ||
| 22 | kallsyms_lookup_name+0x258/0x2b0 | ||
| 23 | wrapper_kallsyms_lookup_name+0x4c/0xd0 [lttng_wrapper] | ||
| 24 | wrapper_get_pfnblock_flags_mask_init+0x28/0x60 [lttng_wrapper] | ||
| 25 | lttng_events_init+0x40/0x344 [lttng_tracer] | ||
| 26 | do_one_initcall+0x78/0x340 | ||
| 27 | do_init_module+0x6c/0x2f0 | ||
| 28 | __do_sys_finit_module+0xd0/0x120 | ||
| 29 | system_call_exception+0x194/0x2f0 | ||
| 30 | system_call_vectored_common+0xe8/0x278 | ||
| 31 | <snip> | ||
| 32 | |||
| 33 | do_get_kallsyms makes use of kprobe_register and in turn kprobe_lookup_name | ||
| 34 | to get the address of the kernel function kallsyms_lookup_name. In case of | ||
| 35 | PPC64_ELF_ABI_v2, when kprobes are placed at function entry, | ||
| 36 | kprobe_lookup_name adjusts the global entry point of the function returned | ||
| 37 | by kallsyms_lookup_name to the local entry point(at some fixed offset of | ||
| 38 | global one). This adjustment is all for kprobes to be able to work properly. | ||
| 39 | Global and local entry point are defined in powerpc64 ABIv2. | ||
| 40 | |||
| 41 | When the local entry point is given, some instructions at the beginning of | ||
| 42 | the function are skipped and thus causes the above kernel crash. We just | ||
| 43 | want to make a simple function call which needs global entry point. | ||
| 44 | |||
| 45 | This patch adds 4 bytes which is the length of one instruction to | ||
| 46 | kallsyms_lookup_name so that it will not trigger the global to local | ||
| 47 | adjustment, and then substracts 4 bytes from the returned address. See the | ||
| 48 | following kernel change for more details. | ||
| 49 | |||
| 50 | https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=290e3070762ac80e5fc4087d8c4de7e3f1d90aca | ||
| 51 | |||
| 52 | Upstream-Status: Backport | ||
| 53 | |||
| 54 | Signed-off-by: He Zhe <zhe.he@windriver.com> | ||
| 55 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
| 56 | Change-Id: I34e68e886b97e3976d0b5e25be295a8bb866c1a4 | ||
| 57 | --- | ||
| 58 | src/wrapper/kallsyms.c | 16 ++++++++++++++++ | ||
| 59 | 1 file changed, 16 insertions(+) | ||
| 60 | |||
| 61 | diff --git a/src/wrapper/kallsyms.c b/src/wrapper/kallsyms.c | ||
| 62 | index d2848764..93017adc 100644 | ||
| 63 | --- a/src/wrapper/kallsyms.c | ||
| 64 | +++ b/src/wrapper/kallsyms.c | ||
| 65 | @@ -39,10 +39,26 @@ unsigned long do_get_kallsyms(void) | ||
| 66 | memset(&probe, 0, sizeof(probe)); | ||
| 67 | probe.pre_handler = dummy_kprobe_handler; | ||
| 68 | probe.symbol_name = "kallsyms_lookup_name"; | ||
| 69 | +#ifdef PPC64_ELF_ABI_v2 | ||
| 70 | + /* | ||
| 71 | + * With powerpc64 ABIv2, we need the global entry point of | ||
| 72 | + * kallsyms_lookup_name to call it later, while kprobe_register would | ||
| 73 | + * automatically adjust the global entry point to the local entry point, | ||
| 74 | + * when a kprobe was registered at a function entry. So we add 4 bytes | ||
| 75 | + * which is the length of one instruction to kallsyms_lookup_name to | ||
| 76 | + * avoid the adjustment. | ||
| 77 | + */ | ||
| 78 | + probe.offset = 4; | ||
| 79 | +#endif | ||
| 80 | ret = register_kprobe(&probe); | ||
| 81 | if (ret) | ||
| 82 | return 0; | ||
| 83 | +#ifdef PPC64_ELF_ABI_v2 | ||
| 84 | + /* Substract 4 bytes to get what we originally want */ | ||
| 85 | + addr = (unsigned long)(((char *)probe.addr) - 4); | ||
| 86 | +#else | ||
| 87 | addr = (unsigned long)probe.addr; | ||
| 88 | +#endif | ||
| 89 | #ifdef CONFIG_ARM | ||
| 90 | #ifdef CONFIG_THUMB2_KERNEL | ||
| 91 | if (addr) | ||
| 92 | -- | ||
| 93 | 2.17.1 | ||
| 94 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-modules_2.13.4.bb b/meta/recipes-kernel/lttng/lttng-modules_2.13.4.bb index 80b9ceec3f..ad4063bed3 100644 --- a/meta/recipes-kernel/lttng/lttng-modules_2.13.4.bb +++ b/meta/recipes-kernel/lttng/lttng-modules_2.13.4.bb | |||
| @@ -17,6 +17,7 @@ SRC_URI = "https://lttng.org/files/${BPN}/${BPN}-${PV}.tar.bz2 \ | |||
| 17 | file://0001-fix-net-skb-introduce-kfree_skb_reason-v5.15.58.v5.1.patch \ | 17 | file://0001-fix-net-skb-introduce-kfree_skb_reason-v5.15.58.v5.1.patch \ |
| 18 | file://0001-fix-compaction.patch \ | 18 | file://0001-fix-compaction.patch \ |
| 19 | file://0001-fix-adjust-range-v5.10.137-in-block-probe.patch \ | 19 | file://0001-fix-adjust-range-v5.10.137-in-block-probe.patch \ |
| 20 | file://0001-wrapper-powerpc64-fix-kernel-crash-caused-by-do_get_.patch \ | ||
| 20 | " | 21 | " |
| 21 | 22 | ||
| 22 | # Use :append here so that the patch is applied also when using devupstream | 23 | # Use :append here so that the patch is applied also when using devupstream |
