Re: [PATCH v8 8/8] livepatch: Detect offset for the ftrace location during build

From: Kamalesh Babulal
Date: Tue Feb 16 2016 - 00:47:27 EST


* Petr Mladek <pmladek@xxxxxxxx> [2016-02-12 17:45:17]:

[...]
> I guess that you used a broken gcc and cheated the check
> to pass the compilation. Did you, please?
>
> The test used to detect the offset is using a minimalistic
> function is is afftected by the gcc bug.
>
> The patch below might be used to cheat the offset check as well.
>
> Torsten, please mention this somewhere if you, just by chance,
> send a new version of the patchset.
>
> From f6a438a3f2f60cc1acc859b41d0cc9259c9a331e Mon Sep 17 00:00:00 2001
> From: root <root@xxxxxxxxxxxxxxxx>
> Date: Tue, 2 Feb 2016 15:35:06 +0100
> Subject: [PATCH 2/2] livepatch: Make sure the TOC is handled when detecting
> ftrace location
>
> There seems to be a bug in gcc on PPC. It does not handle TOC
> if the function does not access global variables or functions
> by default. But it should when profiling is enabled.
>
> This patch works around this problem by adding a call
> to a global function.
>
> This patch is for testing only!
> ---
> kernel/livepatch/ftrace-test.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/kernel/livepatch/ftrace-test.c b/kernel/livepatch/ftrace-test.c
> index 22f0c54bf7b3..a3b7aabb67e5 100644
> --- a/kernel/livepatch/ftrace-test.c
> +++ b/kernel/livepatch/ftrace-test.c
> @@ -1,6 +1,9 @@
> /* Sample code to figure out mcount location offset */
> +#include <linux/printk.h>
> +
>
> int test(int a)
> {
> + printk("%d\n", a);
> return ++a;
> }

Thanks. This workaround, helped to load sample livepatch module.

Thanks,
Kamalesh.