[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2bbd0e25-a285-4475-9709-42ae65cb47ea@orca.pet>
Date: Thu, 21 Aug 2025 14:48:00 +0200
From: Marcos Del Sol Vives <marcos@...a.pet>
To: David Laight <david.laight.linux@...il.com>
Cc: linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>, Brian Gerst <brgerst@...il.com>,
Uros Bizjak <ubizjak@...il.com>, Ard Biesheuvel <ardb@...nel.org>,
David Kaplan <david.kaplan@....com>, "Ahmed S. Darwish"
<darwi@...utronix.de>, Kees Cook <kees@...nel.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Andrew Cooper <andrew.cooper3@...rix.com>, Oleg Nesterov <oleg@...hat.com>,
"Xin Li (Intel)" <xin@...or.com>, Sabyrzhan Tasbolatov <snovitoll@...il.com>
Subject: Re: [PATCH] x86: add hintable NOPs emulation
El 21/08/2025 a las 14:26, David Laight escribió:
> Marcos Del Sol Vives <marcos@...a.pet> wrote:
>> + if (!insn_decode_from_regs(&insn, regs, buf, nr_copied))
>> + return false;
>> +
>> + /* Hintable NOPs cover 0F 18 to 0F 1F */
>> + if (insn.opcode.bytes[0] != 0x0F ||
>> + insn.opcode.bytes[1] < 0x18 || insn.opcode.bytes[1] > 0x1F)
>> + return false;
>
> Can you swap the order of those tests?
> Looks like the 'decode' is only needed for the length.
>
Not really. The opcodes may have prefixes that are "removed" by the decode
function. ENDBR32 for instance is actually "F3 0F 1E FB", with a REP
prefix.
>> +#ifdef CONFIG_X86_HNOP_EMU
>> + if (user_mode(regs) && handle_hnop(regs))
>> + return;
>
> Why not move the user_mode() test into handle_hnop() ?
> Should make the config tests easier.
>
Other code I saw did this in the calling function itself (eg handle_bug)
so I did it here too.
Powered by blists - more mailing lists