lkml.org 
[lkml]   [2017]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [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@goodmis.org> wrote:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.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.

\
 
 \ /
  Last update: 2017-03-10 03:45    [W:0.145 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site