[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240325093420.5de035d7@meshulam.tesarici.cz>
Date: Mon, 25 Mar 2024 09:34:20 +0100
From: Petr Tesařík <petr@...arici.cz>
To: Petr Tesarik <petrtesarik@...weicloud.com>
Cc: Andy Lutomirski <luto@...nel.org>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, Dave Hansen
<dave.hansen@...ux.intel.com>, "maintainer:X86 ARCHITECTURE (32-BIT AND
64-BIT)" <x86@...nel.org>, "H. Peter Anvin" <hpa@...or.com>, "open list:X86
ENTRY CODE" <linux-kernel@...r.kernel.org>, Roberto Sassu
<roberto.sassu@...weicloud.com>
Subject: Re: [PATCH 1/1] x86/entry: Use one cmpq in NMI entry to check RIP
for nested NMIs
On Tue, 12 Mar 2024 16:03:17 +0100
Petr Tesarik <petrtesarik@...weicloud.com> wrote:
> On 2/29/2024 9:37 AM, Petr Tesarik wrote:
> > From: Petr Tesarik <petr.tesarik1@...wei-partners.com>
> >
> > Optimize the check whether a nested NMI occurred between repeat_nmi and
> > end_repeat_nmi. Although this is not a hot path, this is standard code to
> > check whether a value is within a given range; it is slightly faster, takes
> > up less bytes of code and saves one entry in the branch predictor.
> >
> > This patch also removes the only relocation for end_repeat_nmi, removing
> > the need for ANNOTATE_NOENDBR.
>
> Any comment on this?
Ping. If you don't like the change, can I at least get an orderly NAK?
(Or have I made it onto an x86 maintainer blacklist?)
Petr T
> Kind regards
> Petr T
>
> > Signed-off-by: Petr Tesarik <petr.tesarik1@...wei-partners.com>
> > ---
> > arch/x86/entry/entry_64.S | 13 ++++---------
> > 1 file changed, 4 insertions(+), 9 deletions(-)
> >
> > diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> > index 9bb485977629..cae40076e109 100644
> > --- a/arch/x86/entry/entry_64.S
> > +++ b/arch/x86/entry/entry_64.S
> > @@ -1251,13 +1251,10 @@ SYM_CODE_START(asm_exc_nmi)
> > * the outer NMI.
> > */
> >
> > - movq $repeat_nmi, %rdx
> > - cmpq 8(%rsp), %rdx
> > - ja 1f
> > - movq $end_repeat_nmi, %rdx
> > - cmpq 8(%rsp), %rdx
> > - ja nested_nmi_out
> > -1:
> > + movq 8(%rsp), %rdx
> > + subq $repeat_nmi, %rdx
> > + cmpq $(end_repeat_nmi - repeat_nmi), %rdx
> > + jb nested_nmi_out
> >
> > /*
> > * Now check "NMI executing". If it's set, then we're nested.
> > @@ -1383,8 +1380,6 @@ repeat_nmi:
> > .endr
> > subq $(5*8), %rsp
> > end_repeat_nmi:
> > - ANNOTATE_NOENDBR // this code
> > -
> > /*
> > * Everything below this point can be preempted by a nested NMI.
> > * If this happens, then the inner NMI will change the "iret"
>
Powered by blists - more mailing lists