linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/5] CR4 handling improvements
@ 2014-10-14 22:57 Andy Lutomirski
  2014-10-14 22:57 ` [RFC 1/5] x86: Clean up cr4 manipulation Andy Lutomirski
                   ` (5 more replies)
  0 siblings, 6 replies; 47+ messages in thread
From: Andy Lutomirski @ 2014-10-14 22:57 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Valdis Kletnieks, linux-kernel, Paul Mackerras,
	Arnaldo Carvalho de Melo, Ingo Molnar, Kees Cook,
	Andrea Arcangeli, Erik Bosman, Andy Lutomirski

Hi Peter, etc,

This little series tightens up rdpmc permissions.  With it applied,
rdpmc can only be used if a perf_event is actually mmapped.  For now,
this is only really useful for seccomp.

At some point this could be further tightened up to only allow rdpmc
if an actual self-monitoring perf event that is compatible with
rdpmc is mapped.  (Is the current code there even correct?  What
happens if you set up a perf counter targetting a different pid and
then try to rdpmc it?  Do you end up reading the right value or does
perf event context switching mess you up?)

This should add <50ns to context switches between rdpmc-capable and
rdpmc-non-capable mms.  I suspect that this is well under 10%
overhead, given that perf already adds some context switch latency.

If needed, we could add a global switch that turns this behavior
off.  We could also rehink the logic.

I think that patches 1-3 are a good idea regardless of any rdpmc changes.

(Please don't apply quite yet, because there'll be a merge conflict
with some changes that haven't landed yet.  This is against 3.17.)

Andy Lutomirski (5):
  x86: Clean up cr4 manipulation
  x86: Store a per-cpu shadow copy of CR4
  x86: Add a comment clarifying LDT context switching
  perf: Add pmu callbacks to track event mapping and unmapping
  x86,perf: Only allow rdpmc if a perf_event is mapped

 arch/x86/include/asm/mmu.h           |  2 +
 arch/x86/include/asm/mmu_context.h   | 30 +++++++++++++-
 arch/x86/include/asm/processor.h     | 33 ----------------
 arch/x86/include/asm/tlbflush.h      | 77 ++++++++++++++++++++++++++++++++----
 arch/x86/include/asm/virtext.h       |  3 +-
 arch/x86/kernel/cpu/common.c         | 17 +++++---
 arch/x86/kernel/cpu/mcheck/mce.c     |  3 +-
 arch/x86/kernel/cpu/mcheck/p5.c      |  3 +-
 arch/x86/kernel/cpu/mcheck/winchip.c |  3 +-
 arch/x86/kernel/cpu/perf_event.c     | 61 +++++++++++++++++++++-------
 arch/x86/kernel/head32.c             |  1 +
 arch/x86/kernel/head64.c             |  2 +
 arch/x86/kernel/i387.c               |  3 +-
 arch/x86/kernel/process.c            |  5 ++-
 arch/x86/kernel/xsave.c              |  3 +-
 arch/x86/kvm/vmx.c                   |  8 ++--
 arch/x86/mm/init.c                   | 12 +++++-
 arch/x86/mm/tlb.c                    |  3 --
 arch/x86/xen/enlighten.c             |  4 +-
 include/linux/perf_event.h           |  7 ++++
 kernel/events/core.c                 |  9 +++++
 21 files changed, 210 insertions(+), 79 deletions(-)

-- 
1.9.3


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

end of thread, other threads:[~2014-10-24 22:14 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-14 22:57 [RFC 0/5] CR4 handling improvements Andy Lutomirski
2014-10-14 22:57 ` [RFC 1/5] x86: Clean up cr4 manipulation Andy Lutomirski
2014-10-16  8:16   ` Peter Zijlstra
2014-10-16 11:18     ` Borislav Petkov
2014-10-16 11:29       ` Borislav Petkov
2014-10-16 15:32         ` Andy Lutomirski
2014-10-16 15:47           ` Borislav Petkov
2014-10-14 22:57 ` [RFC 2/5] x86: Store a per-cpu shadow copy of CR4 Andy Lutomirski
2014-10-16  8:26   ` Peter Zijlstra
2014-10-16 11:49   ` Borislav Petkov
2014-10-16 15:30     ` Andy Lutomirski
2014-10-14 22:57 ` [RFC 3/5] x86: Add a comment clarifying LDT context switching Andy Lutomirski
2014-10-16 15:49   ` Borislav Petkov
2014-10-16 16:21     ` Andy Lutomirski
2014-10-21  5:41       ` Borislav Petkov
2014-10-21  5:44         ` Andy Lutomirski
2014-10-21  6:05           ` Borislav Petkov
2014-10-14 22:57 ` [RFC 4/5] perf: Add pmu callbacks to track event mapping and unmapping Andy Lutomirski
2014-10-14 22:57 ` [RFC 5/5] x86,perf: Only allow rdpmc if a perf_event is mapped Andy Lutomirski
2014-10-16  8:42   ` Peter Zijlstra
2014-10-16 15:37     ` Andy Lutomirski
2014-10-16 15:57     ` Borislav Petkov
2014-10-17  0:00   ` Andy Lutomirski
2014-10-19 20:23     ` Andy Lutomirski
2014-10-19 21:33       ` Peter Zijlstra
2014-10-19 22:05         ` Andy Lutomirski
2014-10-19 22:20           ` Peter Zijlstra
2014-10-19 22:57             ` Andy Lutomirski
2014-10-20  8:33               ` Peter Zijlstra
2014-10-20 16:49                 ` Andy Lutomirski
2014-10-20 17:39                   ` Andy Lutomirski
2014-10-21  8:59                     ` Peter Zijlstra
2014-10-19 21:35     ` Peter Zijlstra
2014-10-20  0:08       ` Andy Lutomirski
2014-10-20  8:48         ` Peter Zijlstra
2014-10-20  9:24           ` Martin Schwidefsky
2014-10-20 10:51           ` Hendrik Brueckner
2014-10-21  9:14             ` Peter Zijlstra
2014-10-21 15:52               ` Andy Lutomirski
2014-10-21  4:06 ` [RFC 0/5] CR4 handling improvements Vince Weaver
2014-10-21  4:28   ` Andy Lutomirski
2014-10-21 15:00     ` Vince Weaver
2014-10-21 16:04       ` Peter Zijlstra
2014-10-21 17:05         ` Vince Weaver
2014-10-23 11:42           ` Peter Zijlstra
2014-10-24 12:41             ` Vince Weaver
2014-10-24 22:14               ` Andy Lutomirski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).