[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrXAARdzFP-gpzmF3_Se2BvoogHH-C1Q0jmwgy2+JUO9Pg@mail.gmail.com>
Date: Thu, 9 Mar 2017 18:43:59 -0800
From: Andy Lutomirski <luto@...capital.net>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>,
Andy Lutomirski <luto@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 2/2] x86/nmi: Fix and optimize the NMI stack check code
On Thu, Mar 9, 2017 at 2:42 PM, Steven Rostedt <rostedt@...dmis.org> wrote:
> From: "Steven Rostedt (Red Hat)" <rostedt@...dmis.org>
>
> Andy Lutomirski reported an off by one in the NMI stack check
> for the nested NMI code, where if the stack pointer was one above
> the actual stack (stack start + STACK_SIZE) it would trigger a false
> positive. This is not that big of a deal because the stack pointer
> should never be that. Even if a stack was using the pages just
> above the NMI stack, it would require the stack about to overflow
> for this to trigger, which is a much bigger bug than this is fixing.
>
> Also, Linus Torvalds pointed out that doing two compares can be
> accomplish with a single compare. That is:
>
> ("reg" is top of stack we are comparing "stack" to)
>
> cmpq reg, stack
> jae label // note, code had one off "ja" instead of "jae"
> subq size, reg
> cmpq reg, stack
> jb label
>
> Is the same as:
>
> subq $1, reg
> subq stack, reg
> cmpq size, reg
> jae label
>
> The subq $1 was added into the leaq by doing:
>
> leaq 5*8+7(%rsp), %rdx
>
> Added more comments as well.
Nice.
Powered by blists - more mailing lists