[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231208132204.GBZXMYfLSaIbn3BvN3@fat_crate.local>
Date: Fri, 8 Dec 2023 14:22:04 +0100
From: Borislav Petkov <bp@...en8.de>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>, paul.gortmaker@...driver.com,
x86@...nel.org, regressions@...mhuis.info,
richard.purdie@...uxfoundation.org, regressions@...ts.linux.dev
Subject: Re: [patch 2/2] x86/alternatives: Disable interrupts and sync when
optimizing NOPs in place
On Thu, Dec 07, 2023 at 08:49:26PM +0100, Thomas Gleixner wrote:
> +static void __init_or_module noinline optimize_nops_inplace(u8 *instr, size_t len)
> +{
> + unsigned long flags;
> +
> + local_irq_save(flags);
> + optimize_nops(instr, len);
> + sync_core();
> + local_irq_restore(flags);
> +}
> +
> /*
> * In this context, "source" is where the instructions are placed in the
> * section .altinstr_replacement, for example during kernel build by the
> @@ -438,7 +448,7 @@ void __init_or_module noinline apply_alt
> * patch if feature is *NOT* present.
> */
> if (!boot_cpu_has(a->cpuid) == !(a->flags & ALT_FLAG_NOT)) {
> - optimize_nops(instr, a->instrlen);
> + optimize_nops_inplace(instr, a->instrlen);
> continue;
> }
Arguably, the proper thing to do here would be to convert the NOP
optimizing to the same 2-stage process as normal patching: write insns
into a buffer and text_poke* it.
VS what we currently do: operating straight on kernel memory.
Lemme put it on the TODO and see how ugly it becomes.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists