lkml.org 
[lkml]   [2021]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [RFC][PATCH] x86/alternatives: Optimize optimize_nops()
On Mon, Mar 15, 2021 at 04:45:24PM +0100, Peter Zijlstra wrote:
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -345,19 +345,39 @@ recompute_jump(struct alt_instr *a, u8 *
> static void __init_or_module noinline optimize_nops(struct alt_instr *a, u8 *instr)
> {
> unsigned long flags;
> + int nops = 0, i = 0;
> + struct insn insn;
> + u8 *nop = NULL;
> +
> + do {
> + kernel_insn_init(&insn, &instr[i], MAX_INSN_SIZE);
> + insn_get_length(&insn);
> +

I suppose you'd like to see that replaced with something like this,
rite?


--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -350,8 +350,8 @@ static void __init_or_module noinline op
u8 *nop = NULL;

do {
- kernel_insn_init(&insn, &instr[i], MAX_INSN_SIZE);
- insn_get_length(&insn);
+ if (insn_decode(&insn, &instr[i], MAX_INSN_SIZE, INSN_MODE_KERN))
+ return;

if (insn.length == 1 && insn.opcode.bytes[0] == 0x90) {
if (!nop) {
\
 
 \ /
  Last update: 2021-03-15 17:25    [W:0.038 / U:1.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site