Re: [patch V4 part 4 04/24] x86/int3: Inline bsearch()

2020-05-13 Thread Andy Lutomirski
On Tue, May 5, 2020 at 7:15 AM Thomas Gleixner  wrote:
>
> From: Peter Zijlstra 
>
> Avoid calling out to bsearch() by inlining it, for normal kernel configs
> this was the last external call and poke_int3_handler() is now fully self
> sufficient -- no calls to external code.
>


Acked-by: Andy Lutomirski 


[patch V4 part 4 04/24] x86/int3: Inline bsearch()

2020-05-05 Thread Thomas Gleixner
From: Peter Zijlstra 

Avoid calling out to bsearch() by inlining it, for normal kernel configs
this was the last external call and poke_int3_handler() is now fully self
sufficient -- no calls to external code.

Signed-off-by: Peter Zijlstra (Intel) 
Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/alternative.c |8 
 arch/x86/kernel/traps.c   |5 +
 2 files changed, 9 insertions(+), 4 deletions(-)

--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -979,7 +979,7 @@ static __always_inline void *text_poke_a
return _stext + tp->rel_addr;
 }
 
-static int noinstr patch_cmp(const void *key, const void *elt)
+static __always_inline int patch_cmp(const void *key, const void *elt)
 {
struct text_poke_loc *tp = (struct text_poke_loc *) elt;
 
@@ -1023,9 +1023,9 @@ int noinstr poke_int3_handler(struct pt_
 * Skip the binary search if there is a single member in the vector.
 */
if (unlikely(desc->nr_entries > 1)) {
-   tp = bsearch(ip, desc->vec, desc->nr_entries,
-sizeof(struct text_poke_loc),
-patch_cmp);
+   tp = __bsearch(ip, desc->vec, desc->nr_entries,
+  sizeof(struct text_poke_loc),
+  patch_cmp);
if (!tp)
goto out_put;
} else {
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -566,6 +566,11 @@ DEFINE_IDTENTRY_ERRORCODE(exc_general_pr
 
 dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
 {
+   /*
+* poke_int3_handler() is completely self contained code; it does (and
+* must) *NOT* call out to anything, lest it hits upon yet another
+* INT3.
+*/
if (poke_int3_handler(regs))
return;