mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][GIT PULL][v3.3] x86: Specify a size for the cmp in the NMI handler
@ 2012-02-20 23:42 Steven Rostedt
  2012-02-21  0:03 ` H. Peter Anvin
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2012-02-20 23:42 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Andrew Morton, Linus Torvalds, H. Peter Anvin

[-- Attachment #1: Type: text/plain, Size: 2305 bytes --]


Ingo,

Please pull the latest tip/x86/urgent tree, which can be found at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
tip/x86/urgent

Head SHA1: 869d49dc575a9cf7041e535ea4911a511bbee764


Steven Rostedt (1):
      x86: Specify a size for the cmp in the NMI handler

----
 arch/x86/kernel/entry_64.S |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---------------------------
commit 869d49dc575a9cf7041e535ea4911a511bbee764
Author: Steven Rostedt <srostedt@redhat.com>
Date:   Mon Feb 20 15:29:34 2012 -0500

    x86: Specify a size for the cmp in the NMI handler
    
    Linus noticed that the cmp used to check if the code segment is
    __KERNEL_CS or not did not specify a size. Perhaps it does not matter
    as H. Peter Anvin noted that user space can not set the bottom two
    bits of the %cs register. But it's best not to let the assembly choose
    and change things between different versions of gas, but instead just
    pick the size.
    
    The full 8 bytes is used to compare the saved code segment against
    __KERNEL_CS. Perhaps this might mess up Xen, but we can fix that when
    the time comes.
    
    Also I noticed that there was another non-specified cmp that checks
    the special stack variable if it is 1 or 0. This too probably doesn't
    matter what cmp is used, but this patch uses cmpl just to make it non
    ambiguous.
    
    Link: http://lkml.kernel.org/r/CA+55aFxfAn9MWRgS3O5k2tqN5ys1XrhSFVO5_9ZAoZKDVgNfGA@mail.gmail.com
    
    Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index debd851..666f2cb 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1535,14 +1535,14 @@ ENTRY(nmi)
 	 * If %cs was not the kernel segment, then the NMI triggered in user
 	 * space, which means it is definitely not nested.
 	 */
-	cmp $__KERNEL_CS, 16(%rsp)
+	cmpq $__KERNEL_CS, 16(%rsp)
 	jne first_nmi
 
 	/*
 	 * Check the special variable on the stack to see if NMIs are
 	 * executing.
 	 */
-	cmp $1, -8(%rsp)
+	cmpl $1, -8(%rsp)
 	je nested_nmi
 
 	/*


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][GIT PULL][v3.3] x86: Specify a size for the cmp in the NMI handler
  2012-02-20 23:42 [PATCH][GIT PULL][v3.3] x86: Specify a size for the cmp in the NMI handler Steven Rostedt
@ 2012-02-21  0:03 ` H. Peter Anvin
  2012-02-21  0:11   ` Linus Torvalds
  0 siblings, 1 reply; 4+ messages in thread
From: H. Peter Anvin @ 2012-02-21  0:03 UTC (permalink / raw)
  To: Steven Rostedt, LKML; +Cc: Ingo Molnar, Andrew Morton, Linus Torvalds

You can use cmpl here... the segment is only a 16-bit number.  Or use testb $3,...

Steven Rostedt <rostedt@goodmis.org> wrote:

>
>Ingo,
>
>Please pull the latest tip/x86/urgent tree, which can be found at:
>
>  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
>tip/x86/urgent
>
>Head SHA1: 869d49dc575a9cf7041e535ea4911a511bbee764
>
>
>Steven Rostedt (1):
>      x86: Specify a size for the cmp in the NMI handler
>
>----
> arch/x86/kernel/entry_64.S |    4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>---------------------------
>commit 869d49dc575a9cf7041e535ea4911a511bbee764
>Author: Steven Rostedt <srostedt@redhat.com>
>Date:   Mon Feb 20 15:29:34 2012 -0500
>
>    x86: Specify a size for the cmp in the NMI handler
>    
>    Linus noticed that the cmp used to check if the code segment is
>  __KERNEL_CS or not did not specify a size. Perhaps it does not matter
>    as H. Peter Anvin noted that user space can not set the bottom two
> bits of the %cs register. But it's best not to let the assembly choose
>  and change things between different versions of gas, but instead just
>    pick the size.
>    
>    The full 8 bytes is used to compare the saved code segment against
>  __KERNEL_CS. Perhaps this might mess up Xen, but we can fix that when
>    the time comes.
>    
>    Also I noticed that there was another non-specified cmp that checks
>  the special stack variable if it is 1 or 0. This too probably doesn't
>  matter what cmp is used, but this patch uses cmpl just to make it non
>    ambiguous.
>    
>Link:
>http://lkml.kernel.org/r/CA+55aFxfAn9MWRgS3O5k2tqN5ys1XrhSFVO5_9ZAoZKDVgNfGA@mail.gmail.com
>    
>    Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
>    Cc: H. Peter Anvin <hpa@zytor.com>
>    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
>
>diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
>index debd851..666f2cb 100644
>--- a/arch/x86/kernel/entry_64.S
>+++ b/arch/x86/kernel/entry_64.S
>@@ -1535,14 +1535,14 @@ ENTRY(nmi)
> 	 * If %cs was not the kernel segment, then the NMI triggered in user
> 	 * space, which means it is definitely not nested.
> 	 */
>-	cmp $__KERNEL_CS, 16(%rsp)
>+	cmpq $__KERNEL_CS, 16(%rsp)
> 	jne first_nmi
> 
> 	/*
> 	 * Check the special variable on the stack to see if NMIs are
> 	 * executing.
> 	 */
>-	cmp $1, -8(%rsp)
>+	cmpl $1, -8(%rsp)
> 	je nested_nmi
> 
> 	/*

-- 
Sent from my mobile phone. Please excuse my brevity and lack of formatting.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][GIT PULL][v3.3] x86: Specify a size for the cmp in the NMI handler
  2012-02-21  0:03 ` H. Peter Anvin
@ 2012-02-21  0:11   ` Linus Torvalds
  2012-02-21  0:44     ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Torvalds @ 2012-02-21  0:11 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Steven Rostedt, LKML, Ingo Molnar, Andrew Morton

On Mon, Feb 20, 2012 at 4:03 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> You can use cmpl here... the segment is only a 16-bit number.  Or use testb $3,...

Yeah. And cmpl is one byte shorter (and the same size as testb).

               Linus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][GIT PULL][v3.3] x86: Specify a size for the cmp in the NMI handler
  2012-02-21  0:11   ` Linus Torvalds
@ 2012-02-21  0:44     ` Steven Rostedt
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2012-02-21  0:44 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: H. Peter Anvin, LKML, Ingo Molnar, Andrew Morton

On Mon, 2012-02-20 at 16:11 -0800, Linus Torvalds wrote:
> On Mon, Feb 20, 2012 at 4:03 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> > You can use cmpl here... the segment is only a 16-bit number.  Or use testb $3,...
> 
> Yeah. And cmpl is one byte shorter (and the same size as testb).

I'll rebase and send again.

Thanks,

-- Steve



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-21  0:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-20 23:42 [PATCH][GIT PULL][v3.3] x86: Specify a size for the cmp in the NMI handler Steven Rostedt
2012-02-21  0:03 ` H. Peter Anvin
2012-02-21  0:11   ` Linus Torvalds
2012-02-21  0:44     ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®