Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-07 Thread Masami Hiramatsu
On Fri, 7 Dec 2018 20:48:47 +0100
Borislav Petkov  wrote:

> On Fri, Dec 07, 2018 at 11:42:10PM +0900, Masami Hiramatsu wrote:
> > Hmm, I just thought that the symbol only referred from inline asm should
> > be visible. But if it is OK for any version of supported gcc and clang,
> > I'm good to remove it. :-) (IOW, I just concerned about older gcc)
> 
> I just tried two gcc versions: 8.2 and 4.8.5. Both asms looks good:
> 
> 81044690 :
> ...
> 
> 
> 810446ab:   41 57   push   %r15
> 810446ad:   48 89 e7mov%rsp,%rdi
> 810446b0:   e8 db 01 00 00  callq  81044890 
> 
> 
> there's the CALL...
> 
> 810446b5:   48 89 84 24 98 00 00mov%rax,0x98(%rsp)
> 810446bc:   00
> 
> ... and the handler is at the expected address.
> 
> 81044890 :
> 81044890:   e8 ab c9 7b 00  callq  81801240 
> <__fentry__>
> 81044895:   41 57   push   %r15
> 81044897:   41 56   push   %r14
> 81044899:   41 55   push   %r13
> 8104489b:   49 89 fdmov%rdi,%r13
> 
> Dunno, if you feel like there might be some trouble with some compilers,
> I can keep the hunk below as a separate patch and revert it when it
> explodes somewhere...?

OK, then please remove it. :-) Even if any problem occurs, which must be
build error, so we can revert it in that case.

Thank you!

> 
> > Reviewed-by: Masami Hiramatsu 
> > 
> > Thank you,
> > 
> > > 
> > > ---
> > > diff --git a/arch/x86/kernel/kprobes/core.c 
> > > b/arch/x86/kernel/kprobes/core.c
> > > index 6480056d370f..308bf103cc73 100644
> > > --- a/arch/x86/kernel/kprobes/core.c
> > > +++ b/arch/x86/kernel/kprobes/core.c
> > > @@ -66,8 +66,6 @@
> > >  
> > >  #include "common.h"
> > >  
> > > -void *trampoline_handler(struct pt_regs *regs);
> > > -
> > >  DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
> > >  DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
> > >  
> > > @@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);
> > >  /*
> > >   * Called from kretprobe_trampoline
> > >   */
> > > -__visible __used void *trampoline_handler(struct pt_regs *regs)
> > > +static __used void *trampoline_handler(struct pt_regs *regs)
> > >  {
> > >   struct kretprobe_instance *ri = NULL;
> > >   struct hlist_head *head, empty_rp;
> > > 
> > > -- 
> > > Regards/Gruss,
> > > Boris.
> > > 
> > > Good mailing practices for 400: avoid top-posting and trim the reply.
> > 
> > 
> > -- 
> > Masami Hiramatsu 
> 
> -- 
> Regards/Gruss,
> Boris.
> 
> Good mailing practices for 400: avoid top-posting and trim the reply.


-- 
Masami Hiramatsu 


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-07 Thread Masami Hiramatsu
On Fri, 7 Dec 2018 20:48:47 +0100
Borislav Petkov  wrote:

> On Fri, Dec 07, 2018 at 11:42:10PM +0900, Masami Hiramatsu wrote:
> > Hmm, I just thought that the symbol only referred from inline asm should
> > be visible. But if it is OK for any version of supported gcc and clang,
> > I'm good to remove it. :-) (IOW, I just concerned about older gcc)
> 
> I just tried two gcc versions: 8.2 and 4.8.5. Both asms looks good:
> 
> 81044690 :
> ...
> 
> 
> 810446ab:   41 57   push   %r15
> 810446ad:   48 89 e7mov%rsp,%rdi
> 810446b0:   e8 db 01 00 00  callq  81044890 
> 
> 
> there's the CALL...
> 
> 810446b5:   48 89 84 24 98 00 00mov%rax,0x98(%rsp)
> 810446bc:   00
> 
> ... and the handler is at the expected address.
> 
> 81044890 :
> 81044890:   e8 ab c9 7b 00  callq  81801240 
> <__fentry__>
> 81044895:   41 57   push   %r15
> 81044897:   41 56   push   %r14
> 81044899:   41 55   push   %r13
> 8104489b:   49 89 fdmov%rdi,%r13
> 
> Dunno, if you feel like there might be some trouble with some compilers,
> I can keep the hunk below as a separate patch and revert it when it
> explodes somewhere...?

OK, then please remove it. :-) Even if any problem occurs, which must be
build error, so we can revert it in that case.

Thank you!

> 
> > Reviewed-by: Masami Hiramatsu 
> > 
> > Thank you,
> > 
> > > 
> > > ---
> > > diff --git a/arch/x86/kernel/kprobes/core.c 
> > > b/arch/x86/kernel/kprobes/core.c
> > > index 6480056d370f..308bf103cc73 100644
> > > --- a/arch/x86/kernel/kprobes/core.c
> > > +++ b/arch/x86/kernel/kprobes/core.c
> > > @@ -66,8 +66,6 @@
> > >  
> > >  #include "common.h"
> > >  
> > > -void *trampoline_handler(struct pt_regs *regs);
> > > -
> > >  DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
> > >  DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
> > >  
> > > @@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);
> > >  /*
> > >   * Called from kretprobe_trampoline
> > >   */
> > > -__visible __used void *trampoline_handler(struct pt_regs *regs)
> > > +static __used void *trampoline_handler(struct pt_regs *regs)
> > >  {
> > >   struct kretprobe_instance *ri = NULL;
> > >   struct hlist_head *head, empty_rp;
> > > 
> > > -- 
> > > Regards/Gruss,
> > > Boris.
> > > 
> > > Good mailing practices for 400: avoid top-posting and trim the reply.
> > 
> > 
> > -- 
> > Masami Hiramatsu 
> 
> -- 
> Regards/Gruss,
> Boris.
> 
> Good mailing practices for 400: avoid top-posting and trim the reply.


-- 
Masami Hiramatsu 


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-07 Thread Borislav Petkov
On Fri, Dec 07, 2018 at 11:42:10PM +0900, Masami Hiramatsu wrote:
> Hmm, I just thought that the symbol only referred from inline asm should
> be visible. But if it is OK for any version of supported gcc and clang,
> I'm good to remove it. :-) (IOW, I just concerned about older gcc)

I just tried two gcc versions: 8.2 and 4.8.5. Both asms looks good:

81044690 :
...


810446ab:   41 57   push   %r15
810446ad:   48 89 e7mov%rsp,%rdi
810446b0:   e8 db 01 00 00  callq  81044890 


there's the CALL...

810446b5:   48 89 84 24 98 00 00mov%rax,0x98(%rsp)
810446bc:   00

... and the handler is at the expected address.

81044890 :
81044890:   e8 ab c9 7b 00  callq  81801240 
<__fentry__>
81044895:   41 57   push   %r15
81044897:   41 56   push   %r14
81044899:   41 55   push   %r13
8104489b:   49 89 fdmov%rdi,%r13

Dunno, if you feel like there might be some trouble with some compilers,
I can keep the hunk below as a separate patch and revert it when it
explodes somewhere...?

> Reviewed-by: Masami Hiramatsu 
> 
> Thank you,
> 
> > 
> > ---
> > diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
> > index 6480056d370f..308bf103cc73 100644
> > --- a/arch/x86/kernel/kprobes/core.c
> > +++ b/arch/x86/kernel/kprobes/core.c
> > @@ -66,8 +66,6 @@
> >  
> >  #include "common.h"
> >  
> > -void *trampoline_handler(struct pt_regs *regs);
> > -
> >  DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
> >  DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
> >  
> > @@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);
> >  /*
> >   * Called from kretprobe_trampoline
> >   */
> > -__visible __used void *trampoline_handler(struct pt_regs *regs)
> > +static __used void *trampoline_handler(struct pt_regs *regs)
> >  {
> > struct kretprobe_instance *ri = NULL;
> > struct hlist_head *head, empty_rp;
> > 
> > -- 
> > Regards/Gruss,
> > Boris.
> > 
> > Good mailing practices for 400: avoid top-posting and trim the reply.
> 
> 
> -- 
> Masami Hiramatsu 

-- 
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-07 Thread Borislav Petkov
On Fri, Dec 07, 2018 at 11:42:10PM +0900, Masami Hiramatsu wrote:
> Hmm, I just thought that the symbol only referred from inline asm should
> be visible. But if it is OK for any version of supported gcc and clang,
> I'm good to remove it. :-) (IOW, I just concerned about older gcc)

I just tried two gcc versions: 8.2 and 4.8.5. Both asms looks good:

81044690 :
...


810446ab:   41 57   push   %r15
810446ad:   48 89 e7mov%rsp,%rdi
810446b0:   e8 db 01 00 00  callq  81044890 


there's the CALL...

810446b5:   48 89 84 24 98 00 00mov%rax,0x98(%rsp)
810446bc:   00

... and the handler is at the expected address.

81044890 :
81044890:   e8 ab c9 7b 00  callq  81801240 
<__fentry__>
81044895:   41 57   push   %r15
81044897:   41 56   push   %r14
81044899:   41 55   push   %r13
8104489b:   49 89 fdmov%rdi,%r13

Dunno, if you feel like there might be some trouble with some compilers,
I can keep the hunk below as a separate patch and revert it when it
explodes somewhere...?

> Reviewed-by: Masami Hiramatsu 
> 
> Thank you,
> 
> > 
> > ---
> > diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
> > index 6480056d370f..308bf103cc73 100644
> > --- a/arch/x86/kernel/kprobes/core.c
> > +++ b/arch/x86/kernel/kprobes/core.c
> > @@ -66,8 +66,6 @@
> >  
> >  #include "common.h"
> >  
> > -void *trampoline_handler(struct pt_regs *regs);
> > -
> >  DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
> >  DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
> >  
> > @@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);
> >  /*
> >   * Called from kretprobe_trampoline
> >   */
> > -__visible __used void *trampoline_handler(struct pt_regs *regs)
> > +static __used void *trampoline_handler(struct pt_regs *regs)
> >  {
> > struct kretprobe_instance *ri = NULL;
> > struct hlist_head *head, empty_rp;
> > 
> > -- 
> > Regards/Gruss,
> > Boris.
> > 
> > Good mailing practices for 400: avoid top-posting and trim the reply.
> 
> 
> -- 
> Masami Hiramatsu 

-- 
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-07 Thread Masami Hiramatsu
On Wed, 5 Dec 2018 15:24:48 +0100
Borislav Petkov  wrote:

> On Wed, Dec 05, 2018 at 10:49:06PM +0900, Masami Hiramatsu wrote:
> > I would like to put this prototype inside arch/x86/kernel/kprobes/core.c,
> > since that is locally used.
> 
> Done.
> 
> > Should we declare prototypes for __weak functions? Anyway, we should remove
> > __weak from the prototypes.
> 
> And done.
> 
> Thx.

OK, I think it is good to me.

Reviewed-by: Masami Hiramatsu 

Thanks,

> 
> -- 
> Regards/Gruss,
> Boris.
> 
> Good mailing practices for 400: avoid top-posting and trim the reply.


-- 
Masami Hiramatsu 


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-07 Thread Masami Hiramatsu
On Wed, 5 Dec 2018 15:24:48 +0100
Borislav Petkov  wrote:

> On Wed, Dec 05, 2018 at 10:49:06PM +0900, Masami Hiramatsu wrote:
> > I would like to put this prototype inside arch/x86/kernel/kprobes/core.c,
> > since that is locally used.
> 
> Done.
> 
> > Should we declare prototypes for __weak functions? Anyway, we should remove
> > __weak from the prototypes.
> 
> And done.
> 
> Thx.

OK, I think it is good to me.

Reviewed-by: Masami Hiramatsu 

Thanks,

> 
> -- 
> Regards/Gruss,
> Boris.
> 
> Good mailing practices for 400: avoid top-posting and trim the reply.


-- 
Masami Hiramatsu 


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-07 Thread Masami Hiramatsu
Hi,

On Wed, 5 Dec 2018 18:15:47 +0100
Borislav Petkov  wrote:

> On Wed, Dec 05, 2018 at 05:25:26PM +0100, Ingo Molnar wrote:
> > Also, preferably the prototype should be eliminated via proper ordering 
> > of functions from lower level to higher levels.
> 
> Well, that trampoline_handler() is special as we call it from inline asm
> and I see Masami has marked it __visible etc.
> 
> So doing this below still builds and the trampoline_handler doesn't get
> discarded but maybe there's a reason for it not being static.
> 
> Masami?

Hmm, I just thought that the symbol only referred from inline asm should
be visible. But if it is OK for any version of supported gcc and clang,
I'm good to remove it. :-) (IOW, I just concerned about older gcc)

Reviewed-by: Masami Hiramatsu 

Thank you,

> 
> ---
> diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
> index 6480056d370f..308bf103cc73 100644
> --- a/arch/x86/kernel/kprobes/core.c
> +++ b/arch/x86/kernel/kprobes/core.c
> @@ -66,8 +66,6 @@
>  
>  #include "common.h"
>  
> -void *trampoline_handler(struct pt_regs *regs);
> -
>  DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
>  DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
>  
> @@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);
>  /*
>   * Called from kretprobe_trampoline
>   */
> -__visible __used void *trampoline_handler(struct pt_regs *regs)
> +static __used void *trampoline_handler(struct pt_regs *regs)
>  {
>   struct kretprobe_instance *ri = NULL;
>   struct hlist_head *head, empty_rp;
> 
> -- 
> Regards/Gruss,
> Boris.
> 
> Good mailing practices for 400: avoid top-posting and trim the reply.


-- 
Masami Hiramatsu 


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-07 Thread Masami Hiramatsu
Hi,

On Wed, 5 Dec 2018 18:15:47 +0100
Borislav Petkov  wrote:

> On Wed, Dec 05, 2018 at 05:25:26PM +0100, Ingo Molnar wrote:
> > Also, preferably the prototype should be eliminated via proper ordering 
> > of functions from lower level to higher levels.
> 
> Well, that trampoline_handler() is special as we call it from inline asm
> and I see Masami has marked it __visible etc.
> 
> So doing this below still builds and the trampoline_handler doesn't get
> discarded but maybe there's a reason for it not being static.
> 
> Masami?

Hmm, I just thought that the symbol only referred from inline asm should
be visible. But if it is OK for any version of supported gcc and clang,
I'm good to remove it. :-) (IOW, I just concerned about older gcc)

Reviewed-by: Masami Hiramatsu 

Thank you,

> 
> ---
> diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
> index 6480056d370f..308bf103cc73 100644
> --- a/arch/x86/kernel/kprobes/core.c
> +++ b/arch/x86/kernel/kprobes/core.c
> @@ -66,8 +66,6 @@
>  
>  #include "common.h"
>  
> -void *trampoline_handler(struct pt_regs *regs);
> -
>  DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
>  DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
>  
> @@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);
>  /*
>   * Called from kretprobe_trampoline
>   */
> -__visible __used void *trampoline_handler(struct pt_regs *regs)
> +static __used void *trampoline_handler(struct pt_regs *regs)
>  {
>   struct kretprobe_instance *ri = NULL;
>   struct hlist_head *head, empty_rp;
> 
> -- 
> Regards/Gruss,
> Boris.
> 
> Good mailing practices for 400: avoid top-posting and trim the reply.


-- 
Masami Hiramatsu 


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-05 Thread Borislav Petkov
On Wed, Dec 05, 2018 at 05:25:26PM +0100, Ingo Molnar wrote:
> Also, preferably the prototype should be eliminated via proper ordering 
> of functions from lower level to higher levels.

Well, that trampoline_handler() is special as we call it from inline asm
and I see Masami has marked it __visible etc.

So doing this below still builds and the trampoline_handler doesn't get
discarded but maybe there's a reason for it not being static.

Masami?

---
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 6480056d370f..308bf103cc73 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -66,8 +66,6 @@
 
 #include "common.h"
 
-void *trampoline_handler(struct pt_regs *regs);
-
 DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
 DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
 
@@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);
 /*
  * Called from kretprobe_trampoline
  */
-__visible __used void *trampoline_handler(struct pt_regs *regs)
+static __used void *trampoline_handler(struct pt_regs *regs)
 {
struct kretprobe_instance *ri = NULL;
struct hlist_head *head, empty_rp;

-- 
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-05 Thread Borislav Petkov
On Wed, Dec 05, 2018 at 05:25:26PM +0100, Ingo Molnar wrote:
> Also, preferably the prototype should be eliminated via proper ordering 
> of functions from lower level to higher levels.

Well, that trampoline_handler() is special as we call it from inline asm
and I see Masami has marked it __visible etc.

So doing this below still builds and the trampoline_handler doesn't get
discarded but maybe there's a reason for it not being static.

Masami?

---
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 6480056d370f..308bf103cc73 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -66,8 +66,6 @@
 
 #include "common.h"
 
-void *trampoline_handler(struct pt_regs *regs);
-
 DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
 DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
 
@@ -753,7 +751,7 @@ STACK_FRAME_NON_STANDARD(kretprobe_trampoline);
 /*
  * Called from kretprobe_trampoline
  */
-__visible __used void *trampoline_handler(struct pt_regs *regs)
+static __used void *trampoline_handler(struct pt_regs *regs)
 {
struct kretprobe_instance *ri = NULL;
struct hlist_head *head, empty_rp;

-- 
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-05 Thread Ingo Molnar


* Borislav Petkov  wrote:

> On Wed, Dec 05, 2018 at 10:49:06PM +0900, Masami Hiramatsu wrote:
> > I would like to put this prototype inside arch/x86/kernel/kprobes/core.c,
> > since that is locally used.
> 
> Done.

Also, preferably the prototype should be eliminated via proper ordering 
of functions from lower level to higher levels.

On the rest:

Reviewed-by: Ingo Molnar 

Thanks,

Ingo


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-05 Thread Ingo Molnar


* Borislav Petkov  wrote:

> On Wed, Dec 05, 2018 at 10:49:06PM +0900, Masami Hiramatsu wrote:
> > I would like to put this prototype inside arch/x86/kernel/kprobes/core.c,
> > since that is locally used.
> 
> Done.

Also, preferably the prototype should be eliminated via proper ordering 
of functions from lower level to higher levels.

On the rest:

Reviewed-by: Ingo Molnar 

Thanks,

Ingo


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-05 Thread Borislav Petkov
On Wed, Dec 05, 2018 at 10:49:06PM +0900, Masami Hiramatsu wrote:
> I would like to put this prototype inside arch/x86/kernel/kprobes/core.c,
> since that is locally used.

Done.

> Should we declare prototypes for __weak functions? Anyway, we should remove
> __weak from the prototypes.

And done.

Thx.

-- 
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-05 Thread Borislav Petkov
On Wed, Dec 05, 2018 at 10:49:06PM +0900, Masami Hiramatsu wrote:
> I would like to put this prototype inside arch/x86/kernel/kprobes/core.c,
> since that is locally used.

Done.

> Should we declare prototypes for __weak functions? Anyway, we should remove
> __weak from the prototypes.

And done.

Thx.

-- 
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-05 Thread Masami Hiramatsu
Hi Borislav,

On Wed,  5 Dec 2018 11:11:31 +0100
Borislav Petkov  wrote:

> From: Borislav Petkov 
> 
> ... 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 


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-05 Thread Masami Hiramatsu
Hi Borislav,

On Wed,  5 Dec 2018 11:11:31 +0100
Borislav Petkov  wrote:

> From: Borislav Petkov 
> 
> ... 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 


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-05 Thread Rafael J. Wysocki
On Wed, Dec 5, 2018 at 11:11 AM Borislav Petkov  wrote:
>
> From: Borislav Petkov 
>
> ... 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.
>
> asm/trace/ changes courtesy of Steven Rostedt .
>
> Signed-off-by: Borislav Petkov 

Acked-by: Rafael J. Wysocki 

for the ACPI and cpufreq bits.


Re: [PATCH] x86/kernel: Fix more -Wmissing-prototypes warnings

2018-12-05 Thread Rafael J. Wysocki
On Wed, Dec 5, 2018 at 11:11 AM Borislav Petkov  wrote:
>
> From: Borislav Petkov 
>
> ... 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.
>
> asm/trace/ changes courtesy of Steven Rostedt .
>
> Signed-off-by: Borislav Petkov 

Acked-by: Rafael J. Wysocki 

for the ACPI and cpufreq bits.