All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] x86: do not save callee-preserved registers around lockdep_sys_exit_thunk
@ 2015-03-25 20:14 Denys Vlasenko
  2015-03-25 20:14 ` [PATCH 1/3] x86: move ARCH_LOCKDEP_SYS_EXIT[IRQ] defines closer to their users Denys Vlasenko
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Denys Vlasenko @ 2015-03-25 20:14 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Denys Vlasenko, Linus Torvalds, Steven Rostedt, Borislav Petkov,
	H. Peter Anvin, Andy Lutomirski, Oleg Nesterov,
	Frederic Weisbecker, Alexei Starovoitov, Will Drewry, Kees Cook,
	x86, linux-kernel

Recent change to struct pt_regs handling in entry.S, among other things,
changed how callee-preserved registers are saved around call
to lockdep_sys_exit_thunk:

 #    define LOCKDEP_SYS_EXIT_IRQ \
        TRACE_IRQS_ON; \
        sti; \
        SAVE_EXTRA_REGS; \    <======= HERE
        LOCKDEP_SYS_EXIT; \
        RESTORE_EXTRA_REGS; \ <======= HERE

The change is in fact a bit fragile:
now we assume that LOCKDEP_SYS_EXIT_IRQ macro is used only
when there is a struct pt_regs on the stack.

So far this assumption is true, but it is probably a coincidence.

We can revert back to pushing registers, but this callee-preserved registers
saving appears bogus. It is not necessary: they _are_ callee-preserved,
and lockdep_sys_exit() does not touch them on the stack either.

First two patches clean up #define maze so that we can see
that LOCKDEP_SYS_EXIT macro call above is merely "call lockdep_sys_exit_thunk".

Last patch removes SAVE/RESTORE.

I tested this patch series and everything seems to run fine
on a lockdep-enabled kernel with these lines removed.

Denys Vlasenko (3):
  x86: move ARCH_LOCKDEP_SYS_EXIT[IRQ] defines closer to their users
  x86: fold ARCH_LOCKDEP_SYS_EXIT defines into their users
  x86: do not save callee-preserved registers around lockdep_sys_exit_thunk

 arch/x86/include/asm/irqflags.h | 45 +++++++++++++++++------------------------
 1 file changed, 19 insertions(+), 26 deletions(-)

CC: Linus Torvalds <torvalds@linux-foundation.org>
CC: Steven Rostedt <rostedt@goodmis.org>
CC: Ingo Molnar <mingo@kernel.org>
CC: Borislav Petkov <bp@alien8.de>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Andy Lutomirski <luto@amacapital.net>
CC: Oleg Nesterov <oleg@redhat.com>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Alexei Starovoitov <ast@plumgrid.com>
CC: Will Drewry <wad@chromium.org>
CC: Kees Cook <keescook@chromium.org>
CC: x86@kernel.org
CC: linux-kernel@vger.kernel.org

-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH 0/3] x86: do not save callee-preserved registers around lockdep_sys_exit_thunk
@ 2015-02-28  0:29 Denys Vlasenko
  0 siblings, 0 replies; 8+ messages in thread
From: Denys Vlasenko @ 2015-02-28  0:29 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: Denys Vlasenko, Linus Torvalds, Steven Rostedt, Ingo Molnar,
	Borislav Petkov, H. Peter Anvin, Oleg Nesterov,
	Frederic Weisbecker, Alexei Starovoitov, Will Drewry, Kees Cook,
	x86, linux-kernel

Recent change to struct pt_regs handling in entry.S, among other things,
changed how callee-preserved registers are saved around call
to lockdep_sys_exit_thunk:

 #    define LOCKDEP_SYS_EXIT_IRQ \
        TRACE_IRQS_ON; \
        sti; \
        SAVE_EXTRA_REGS; \    <======= HERE
        LOCKDEP_SYS_EXIT; \
        RESTORE_EXTRA_REGS; \ <======= HERE

The change is in fact a bit fragile:
now we assume that LOCKDEP_SYS_EXIT_IRQ macro is used only
when there is a struct pt_regs on the stack.

So far this assumption is true, but it is probably a coincidence.

We can revert back to pushing registers, but this callee-preserved registers
saving appears bogus. It is not necessary: they _are_ callee-preserved,
and lockdep_sys_exit() does not touch them on the stack either.

First two patches clean up #define maze so that we can see
that LOCKDEP_SYS_EXIT macro call above is merely "call lockdep_sys_exit_thunk".

Last patch removes SAVE/RESTORE.

I tested this patch series and everything seems to run fine
on a lockdep-enabled kernel with these lines removed.

Denys Vlasenko (3):
  x86: move ARCH_LOCKDEP_SYS_EXIT[IRQ] defines closer to their users
  x86: fold ARCH_LOCKDEP_SYS_EXIT defines into their users
  x86: do not save callee-preserved registers around lockdep_sys_exit_thunk

 arch/x86/include/asm/irqflags.h | 45 +++++++++++++++++------------------------
 1 file changed, 19 insertions(+), 26 deletions(-)

CC: Linus Torvalds <torvalds@linux-foundation.org>
CC: Steven Rostedt <rostedt@goodmis.org>
CC: Ingo Molnar <mingo@kernel.org>
CC: Borislav Petkov <bp@alien8.de>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Andy Lutomirski <luto@amacapital.net>
CC: Oleg Nesterov <oleg@redhat.com>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Alexei Starovoitov <ast@plumgrid.com>
CC: Will Drewry <wad@chromium.org>
CC: Kees Cook <keescook@chromium.org>
CC: x86@kernel.org
CC: linux-kernel@vger.kernel.org

-- 
1.8.1.4


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

end of thread, other threads:[~2015-03-27 11:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-25 20:14 [PATCH 0/3] x86: do not save callee-preserved registers around lockdep_sys_exit_thunk Denys Vlasenko
2015-03-25 20:14 ` [PATCH 1/3] x86: move ARCH_LOCKDEP_SYS_EXIT[IRQ] defines closer to their users Denys Vlasenko
2015-03-27 11:47   ` [tip:x86/asm] x86/irq/tracing: Move ARCH_LOCKDEP_SYS_EXIT " tip-bot for Denys Vlasenko
2015-03-25 20:14 ` [PATCH 2/3] x86: fold ARCH_LOCKDEP_SYS_EXIT defines into " Denys Vlasenko
2015-03-27 11:47   ` [tip:x86/asm] x86/irq/tracing: Fold " tip-bot for Denys Vlasenko
2015-03-25 20:14 ` [PATCH 3/3] x86: do not save callee-preserved registers around lockdep_sys_exit_thunk Denys Vlasenko
2015-03-27 11:47   ` [tip:x86/asm] x86/irq/tracing: Do " tip-bot for Denys Vlasenko
  -- strict thread matches above, loose matches on Subject: below --
2015-02-28  0:29 [PATCH 0/3] x86: do " Denys Vlasenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.