lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTin1noI6IUfuQsbAgVVzj2rSOhm-Cx3WpsMBgdJ6@mail.gmail.com>
Date:	Sun, 18 Jul 2010 10:36:42 -0700
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	Avi Kivity <avi@...hat.com>
Cc:	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Ingo Molnar <mingo@...e.hu>,
	Peter Zijlstra <peterz@...radead.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Steven Rostedt <rostedt@...tedt.homelinux.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Christoph Hellwig <hch@....de>, Li Zefan <lizf@...fujitsu.com>,
	Lai Jiangshan <laijs@...fujitsu.com>,
	Johannes Berg <johannes.berg@...el.com>,
	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
	Arnaldo Carvalho de Melo <acme@...radead.org>,
	Tom Zanussi <tzanussi@...il.com>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Andi Kleen <andi@...stfloor.org>,
	"H. Peter Anvin" <hpa@...or.com>,
	Jeremy Fitzhardinge <jeremy@...p.org>,
	"Frank Ch. Eigler" <fche@...hat.com>, Tejun Heo <htejun@...il.com>
Subject: Re: [patch 1/2] x86_64 page fault NMI-safe

On Sun, Jul 18, 2010 at 4:03 AM, Avi Kivity <avi@...hat.com> wrote:
>
> By trading off some memory, we don't need this trickery.  We can allocate
> two nmi stacks, so the code becomes:

I really don't think you need even that. See earlier in the discussion
about how we could just test %rsp itself. Which makes all the %rip
testing totally unnecessary, because we don't even need any flags,and
we have no races because %rsp is atomically changed with taking the
exception.

Lookie here, the %rsp comparison really isn't that hard:

  nmi:
      pushq %rax
      pushq %rdx
      movq %rsp,%rdx          # current stack top
      movq 40(%rsp),%rax   # old stack top
      xor %rax,%rdx              # same 8kB aligned area?
      shrq $13,%rdx             # ignore low 13 bits
      je it_is_a_nested_nmi   # looks nested..
  non_nested:
      ...
      ... ok, we're not nested, do normal NMI handling ...
      ...
      popq %rdx
      popq %rax
      iret

  it_is_a_nested_nmi:
      cmpw $0,48(%rsp)     # double-check that it really was a nested exception
      jne non_nested           # from user space or something..
      # this is the nested case
      # NOTE! NMI's are blocked, we don't take any exceptions etc etc
      addq $-160,%rax        # 128-byte redzone on the old stack + 4 words
      movq (%rsp),%rdx
      movq %rdx,(%rax)       # old %rdx
      movq 8(%rsp),%rdx
      movq %rdx,8(%rax)     # old %rax
      movq 32(%rsp),%rdx
      movq %rdx,16(%rax)   # old %rflags
      movq 16(%rsp),%rdx
      movq %rdx,24(%rax)   # old %rip
      movq %rax,%rsp
      popq %rdx
      popq %rax
      popf
      ret $128                     # restore %rip and %rsp

doesn't that look pretty simple?

NOTE! OBVIOUSLY TOTALLY UNTESTED!

                            Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ