Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings
From: Masami Hiramatsu
Date: Wed Dec 05 2018 - 08:49:14 EST
Hi Borislav,
On Wed, 5 Dec 2018 11:11:31 +0100
Borislav Petkov <bp@xxxxxxxxx> wrote:
> From: Borislav Petkov <bp@xxxxxxx>
>
> ... with the goal of eventually enabling -Wmissing-prototypes by
> default. At least on x86.
>
> Make functions static where possible, otherwise add prototypes or make
> them visible through includes.
OK, and I have some comments for kprobe's parts.
[...]
> diff --git a/arch/x86/kernel/kprobes/common.h b/arch/x86/kernel/kprobes/common.h
> index 2b949f4fd4d8..f0fc628c4bb7 100644
> --- a/arch/x86/kernel/kprobes/common.h
> +++ b/arch/x86/kernel/kprobes/common.h
> @@ -91,6 +91,8 @@ extern int __copy_instruction(u8 *dest, u8 *src, u8 *real, struct insn *insn);
> extern void synthesize_reljump(void *dest, void *from, void *to);
> extern void synthesize_relcall(void *dest, void *from, void *to);
>
> +extern void *trampoline_handler(struct pt_regs *regs);
> +
I would like to put this prototype inside arch/x86/kernel/kprobes/core.c,
since that is locally used.
> #ifdef CONFIG_OPTPROBES
> extern int setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter);
> extern unsigned long __recover_optprobed_insn(kprobe_opcode_t *buf, unsigned long addr);
[...]
> diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
> index e909413e4e38..91d19d6a2892 100644
> --- a/include/linux/kprobes.h
> +++ b/include/linux/kprobes.h
> @@ -379,6 +379,9 @@ int enable_kprobe(struct kprobe *kp);
>
> void dump_kprobe(struct kprobe *kp);
>
> +void __weak *alloc_insn_page(void);
> +void __weak free_insn_page(void *page);
Should we declare prototypes for __weak functions? Anyway, we should remove
__weak from the prototypes.
Thank you,
--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>