kernel-ark/include/asm-i386
Laurent Vivier ed75e8d580 [PATCH] UML Support - Ptrace: adds the host SYSEMU support, for UML and general usage
Jeff Dike <jdike@addtoit.com>,
      Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>,
      Bodo Stroesser <bstroesser@fujitsu-siemens.com>

Adds a new ptrace(2) mode, called PTRACE_SYSEMU, resembling PTRACE_SYSCALL
except that the kernel does not execute the requested syscall; this is useful
to improve performance for virtual environments, like UML, which want to run
the syscall on their own.

In fact, using PTRACE_SYSCALL means stopping child execution twice, on entry
and on exit, and each time you also have two context switches; with SYSEMU you
avoid the 2nd stop and so save two context switches per syscall.

Also, some architectures don't have support in the host for changing the
syscall number via ptrace(), which is currently needed to skip syscall
execution (UML turns any syscall into getpid() to avoid it being executed on
the host).  Fixing that is hard, while SYSEMU is easier to implement.

* This version of the patch includes some suggestions of Jeff Dike to avoid
  adding any instructions to the syscall fast path, plus some other little
  changes, by myself, to make it work even when the syscall is executed with
  SYSENTER (but I'm unsure about them). It has been widely tested for quite a
  lot of time.

* Various fixed were included to handle the various switches between
  various states, i.e. when for instance a syscall entry is traced with one of
  PT_SYSCALL / _SYSEMU / _SINGLESTEP and another one is used on exit.
  Basically, this is done by remembering which one of them was used even after
  the call to ptrace_notify().

* We're combining TIF_SYSCALL_EMU with TIF_SYSCALL_TRACE or TIF_SINGLESTEP
  to make do_syscall_trace() notice that the current syscall was started with
  SYSEMU on entry, so that no notification ought to be done in the exit path;
  this is a bit of a hack, so this problem is solved in another way in next
  patches.

* Also, the effects of the patch:
"Ptrace - i386: fix Syscall Audit interaction with singlestep"
are cancelled; they are restored back in the last patch of this series.

Detailed descriptions of the patches doing this kind of processing follow (but
I've already summed everything up).

* Fix behaviour when changing interception kind #1.

  In do_syscall_trace(), we check the status of the TIF_SYSCALL_EMU flag
  only after doing the debugger notification; but the debugger might have
  changed the status of this flag because he continued execution with
  PTRACE_SYSCALL, so this is wrong.  This patch fixes it by saving the flag
  status before calling ptrace_notify().

* Fix behaviour when changing interception kind #2:
  avoid intercepting syscall on return when using SYSCALL again.

  A guest process switching from using PTRACE_SYSEMU to PTRACE_SYSCALL
  crashes.

  The problem is in arch/i386/kernel/entry.S.  The current SYSEMU patch
  inhibits the syscall-handler to be called, but does not prevent
  do_syscall_trace() to be called after this for syscall completion
  interception.

  The appended patch fixes this.  It reuses the flag TIF_SYSCALL_EMU to
  remember "we come from PTRACE_SYSEMU and now are in PTRACE_SYSCALL", since
  the flag is unused in the depicted situation.

* Fix behaviour when changing interception kind #3:
  avoid intercepting syscall on return when using SINGLESTEP.

  When testing 2.6.9 and the skas3.v6 patch, with my latest patch and had
  problems with singlestepping on UML in SKAS with SYSEMU.  It looped
  receiving SIGTRAPs without moving forward.  EIP of the traced process was
  the same for all SIGTRAPs.

What's missing is to handle switching from PTRACE_SYSCALL_EMU to
PTRACE_SINGLESTEP in a way very similar to what is done for the change from
PTRACE_SYSCALL_EMU to PTRACE_SYSCALL_TRACE.

I.e., after calling ptrace(PTRACE_SYSEMU), on the return path, the debugger is
notified and then wake ups the process; the syscall is executed (or skipped,
when do_syscall_trace() returns 0, i.e.  when using PTRACE_SYSEMU), and
do_syscall_trace() is called again.  Since we are on the return path of a
SYSEMU'd syscall, if the wake up is performed through ptrace(PTRACE_SYSCALL),
we must still avoid notifying the parent of the syscall exit.  Now, this
behaviour is extended even to resuming with PTRACE_SINGLESTEP.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-05 00:06:20 -07:00
..
mach-bigsmp
mach-default
mach-es7000 [PATCH] ES7000 platform update (i386) 2005-09-05 00:06:10 -07:00
mach-generic
mach-numaq
mach-summit
mach-visws
mach-voyager
8253pit.h
a.out.h
acpi.h
agp.h [PATCH] i386: inline asm cleanup 2005-09-05 00:06:11 -07:00
apic.h
apicdef.h
arch_hooks.h
atomic.h
bitops.h
boot.h
bug.h
bugs.h [PATCH] i386: inline asm cleanup 2005-09-05 00:06:11 -07:00
byteorder.h
cache.h
cacheflush.h
checksum.h
cpu.h
cpufeature.h
cputime.h
current.h
debugreg.h
delay.h
desc.h [PATCH] x86: introduce a write acessor for updating the current LDT 2005-09-05 00:06:13 -07:00
div64.h
dma-mapping.h
dma.h
e820.h
elf.h
emergency-restart.h
errno.h
fcntl.h
fixmap.h
floppy.h
genapic.h
hardirq.h
hdreg.h
highmem.h
hpet.h
hw_irq.h
i387.h
i8253.h
i8259.h
ide.h
io_apic.h
io.h
ioctl.h
ioctls.h
ipc.h
ipcbuf.h
irq.h
ist.h
kdebug.h [PATCH] x86 NMI: better support for debuggers 2005-09-05 00:06:13 -07:00
kexec.h
kmap_types.h
kprobes.h
ldt.h
linkage.h
local.h
math_emu.h
mc146818rtc.h
mca_dma.h
mca.h
mman.h
mmu_context.h
mmu.h
mmx.h
mmzone.h
module.h
mpspec_def.h
mpspec.h
msgbuf.h
msi.h
msr.h [PATCH] x86: more asm cleanups 2005-09-05 00:06:12 -07:00
mtrr.h
namei.h
nmi.h
node.h
numaq.h
numnodes.h
page.h
param.h
parport.h
pci-direct.h
pci.h
percpu.h
pgalloc.h
pgtable-2level-defs.h
pgtable-2level.h
pgtable-3level-defs.h
pgtable-3level.h [PATCH] i386: use set_pte macros in a couple places where they were missing 2005-09-05 00:06:12 -07:00
pgtable.h [PATCH] i386: encapsulate copying of pgd entries 2005-09-05 00:06:13 -07:00
poll.h
posix_types.h
processor.h [PATCH] x86: make IOPL explicit 2005-09-05 00:06:12 -07:00
ptrace.h [PATCH] x86: privilege cleanup 2005-09-05 00:06:12 -07:00
resource.h
rtc.h
rwlock.h
rwsem.h
scatterlist.h
seccomp.h
sections.h
segment.h
semaphore.h
sembuf.h
serial.h
setup.h
shmbuf.h
shmparam.h
sigcontext.h
siginfo.h
signal.h
smp.h [PATCH] i386 boottime for_each_cpu broken 2005-09-05 00:06:13 -07:00
socket.h
sockios.h
sparsemem.h
spinlock.h
srat.h
stat.h
statfs.h
string.h
suspend.h
system.h [PATCH] x86: make IOPL explicit 2005-09-05 00:06:12 -07:00
termbits.h
termios.h
thread_info.h [PATCH] UML Support - Ptrace: adds the host SYSEMU support, for UML and general usage 2005-09-05 00:06:20 -07:00
timer.h [PATCH] add suspend/resume for timer 2005-09-05 00:06:18 -07:00
timex.h
tlb.h
tlbflush.h
topology.h
types.h
uaccess.h
ucontext.h
unaligned.h
unistd.h
user.h
vga.h
vic.h
vm86.h
voyager.h
xor.h [PATCH] i386: inline asm cleanup 2005-09-05 00:06:11 -07:00