[RFC][PATCH 4/9] jump_label, x86: Improve error when we fail expected text

From: Peter Zijlstra
Date: Mon Oct 07 2019 - 07:24:54 EST


There is only a single usage site left, remove the function and extend
the print to include more information, like the expected text and the
patch type.

Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
arch/x86/kernel/jump_label.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)

--- a/arch/x86/kernel/jump_label.c
+++ b/arch/x86/kernel/jump_label.c
@@ -16,17 +16,6 @@
#include <asm/alternative.h>
#include <asm/text-patching.h>

-static void bug_at(const void *ip, int line)
-{
- /*
- * The location is not an op that we were expecting.
- * Something went wrong. Crash the box, as something could be
- * corrupting the kernel.
- */
- pr_crit("jump_label: Fatal kernel bug, unexpected op at %pS [%p] (%5ph) %d\n", ip, ip, ip, line);
- BUG();
-}
-
static const void *
__jump_label_set_jump_code(struct jump_entry *entry, enum jump_label_type type, int init)
{
@@ -49,8 +38,16 @@ __jump_label_set_jump_code(struct jump_e
expect = code; line = __LINE__;
}

- if (memcmp(addr, expect, JUMP_LABEL_NOP_SIZE))
- bug_at(addr, line);
+ if (memcmp(addr, expect, JUMP_LABEL_NOP_SIZE)) {
+ /*
+ * The location is not an op that we were expecting.
+ * Something went wrong. Crash the box, as something could be
+ * corrupting the kernel.
+ */
+ pr_crit("jump_label: Fatal kernel bug, unexpected op at %pS [%p] (%5ph != %5ph)) line:%d init:%d type:%d\n",
+ addr, addr, addr, expect, line, init, type);
+ BUG();
+ }

if (type == JUMP_LABEL_NOP)
code = ideal_nop;