Commit Graph

186 Commits

Author SHA1 Message Date
Marcel Moolenaar
f2c49dd248 Revamp of the syscall path, exception and context handling. The
prime objectives are:
o  Implement a syscall path based on the epc inststruction (see
   sys/ia64/ia64/syscall.s).
o  Revisit the places were we need to save and restore registers
   and define those contexts in terms of the register sets (see
   sys/ia64/include/_regset.h).

Secundairy objectives:
o  Remove the requirement to use contigmalloc for kernel stacks.
o  Better handling of the high FP registers for SMP systems.
o  Switch to the new cpu_switch() and cpu_throw() semantics.
o  Add a good unwinder to reconstruct contexts for the rare
   cases we need to (see sys/contrib/ia64/libuwx)

Many files are affected by this change. Functionally it boils
down to:
o  The EPC syscall doesn't preserve registers it does not need
   to preserve and places the arguments differently on the stack.
   This affects libc and truss.
o  The address of the kernel page directory (kptdir) had to
   be unstaticized for use by the nested TLB fault handler.
   The name has been changed to ia64_kptdir to avoid conflicts.
   The renaming affects libkvm.
o  The trapframe only contains the special registers and the
   scratch registers. For syscalls using the EPC syscall path
   no scratch registers are saved. This affects all places where
   the trapframe is accessed. Most notably the unaligned access
   handler, the signal delivery code and the debugger.
o  Context switching only partly saves the special registers
   and the preserved registers. This affects cpu_switch() and
   triggered the move to the new semantics, which additionally
   affects cpu_throw().
o  The high FP registers are either in the PCB or on some
   CPU. context switching for them is done lazily. This affects
   trap().
o  The mcontext has room for all registers, but not all of them
   have to be defined in all cases. This mostly affects signal
   delivery code now. The *context syscalls are as of yet still
   unimplemented.

Many details went into the removal of the requirement to use
contigmalloc for kernel stacks. The details are mostly CPU
specific and limited to exception_save() and exception_restore().
The few places where we create, destroy or switch stacks were
mostly simplified by not having to construct physical addresses
and additionally saving the virtual addresses for later use.

Besides more efficient context saving and restoring, which of
course yields a noticable speedup, this also fixes the dreaded
SMP bootup problem as a side-effect. The details of which are
still not fully understood.

This change includes all the necessary backward compatibility
code to have it handle older userland binaries that use the
break instruction for syscalls. Support for break-based syscalls
has been pessimized in favor of a clean implementation. Due to
the overall better performance of the kernel, this will still
be notived as an improvement if it's noticed at all.

Approved by: re@ (jhb)
2003-05-16 21:26:42 +00:00
John Baldwin
840558b971 s/procsig/sigacts/ to catch up to procsig and sigacts changes in the kernel.
Approved by:	re (scottl)
2003-05-14 15:01:20 +00:00
Peter Wemm
e472fbeee2 Bandaid for world. jhb gets the pointy hat here and he needs to look at
this.

Approved by:   re (scottl)
2003-05-14 07:28:43 +00:00
Peter Wemm
a1de871d26 AMD64 support; repocopied from i386 2003-04-30 21:05:33 +00:00
Tom Rhodes
225823c590 Add sys/user.h to the list of includes. Without it you lack a definition of
'struct kinfo_proc' for calls to kvm_getargv() and kvm_getenvv().

PR:	51322
2003-04-26 15:00:57 +00:00
Julian Elischer
a0ddbf497b Catch up with the kernel. Move the current cpu indicator to the thread. 2003-04-10 17:41:40 +00:00
Jeff Roberson
42d3ad7144 - Spell SIGSETOR correctly. 2003-04-01 04:49:12 +00:00
Jeff Roberson
31a9779e5d - Catch up with kernel signal changes. 2003-03-31 22:57:55 +00:00
Philippe Charnier
4cacb61823 The .Fn function
The .Fa argument
2003-03-24 15:58:53 +00:00
John Baldwin
8b7a975ed4 Catch up to p_tracep -> p_tracevp rename to unbreak world.
Pointy hat to:	jhb
2003-03-13 21:40:54 +00:00
Julian Elischer
ac2e415327 Change the process flags P_KSES to be P_THREADED.
This is just a cosmetic change but I've been meaning to do it for about a year.
2003-02-27 02:05:19 +00:00
Matthew Dillon
57e6d29b1e Remove all use of the LOG2() macro/inline, undoing some non-optimal cruft
that crept in recently.  GCC will optimize the divides and multiplies for us.

Submitted by:	David Schultz <dschultz@uclink.Berkeley.EDU>
MFC after:	1 day
2003-01-11 01:09:51 +00:00
Poul-Henning Kamp
42c43e6031 Make struct swblock kernel only, to make vm/swap_pager.h userland includable.
Move struct swdevt from sys/conf.h to the more appropriate vm/swap_pager.h.
Adjust #include use in libkvm and pstat(8) to match.
2003-01-03 16:23:12 +00:00
Jake Burkholder
3eb81c6900 Teach libkvm to deal with direct mapped addresses. 2002-12-27 01:45:05 +00:00
Ruslan Ermilov
facc67676f mdoc(7) police: Deal with self-xrefs. 2002-12-24 13:41:48 +00:00
Ruslan Ermilov
ae82896268 Consistently mark std(in|out|err) with .Dv, because that's how they
are marked up in stdio(3), and because they are defined expressions
of type "FILE *".

Approved by:	re
2002-12-04 18:57:46 +00:00
Marcel Moolenaar
8aab0cca45 Implement working on ELF corefiles. Use kvm_read() when reading
memory while mapping a virtual address to a physical address.
This allows us to work with virtual addresses for page tables,
provided it doesn't cause infinite recursion. Currently all
page tables are direct mapped.
2002-10-21 04:21:12 +00:00
Thomas Moestl
4ed0293602 Adapt to handle the new sparc64 core dump format correctly.
Reviewed by:	jake
2002-10-20 17:06:50 +00:00
John Baldwin
0d6326492b Catch up to SMTX -> SLOCK changes. 2002-10-02 20:33:52 +00:00
Juli Mallett
e8a58a8362 Ressurect libkvm use of the bitmasked signal list in the kernel, now that
reliable signal queues are gone.
2002-10-01 17:17:32 +00:00
Juli Mallett
1340544372 Fix typo, should zero the kinfo_proc's siglist, not the real one's - the real
one doesn't have one.

Submitted by:	jake, scottl
Big pointed hat that lands one in the badcommitters box to:	jmallett
2002-10-01 00:28:14 +00:00
Juli Mallett
fc256ea463 The list of queued signals is not, can not, and will not be exported to the
userland.  If someone wants to implement a backup p_siglist in the kernel
for compatability and to export one could.  For now, just tell KVM to hand
an empty signal set off to the userland.
2002-09-30 21:40:33 +00:00
Bruce Evans
f86e3350f8 Fixed messes involving $FreeBSD$ starting with one left in the copyright
after adding __FBSDID().

Garbage-collected kvm_readswap().  This was once used by kvm_uread(), but
kvm_uread() now just reads /proc/<pid>/mem and procfs hopefully handles
swapped out pages.
2002-09-16 08:22:57 +00:00
Julian Elischer
4f0db5e08c Allocate KSEs and KSEGRPs separatly and remove them from the proc structure.
next step is to allow > 1 to be allocated per process. This would give
multi-processor threads. (when the rest of the infrastructure is
in place)

While doing this I noticed libkvm and sys/kern/kern_proc.c:fill_kinfo_proc
are diverging more than they should.. corrective action needed soon.
2002-09-15 23:52:25 +00:00
Jacques Vidrine
f76b74d6d7 In kvm_openfiles/kvm_open, mark the file descriptors as close-on-exec.
Applications can not do this themselves, as the descriptors are hidden
behind the opaque `kvm_t' type.
2002-09-11 16:41:39 +00:00
Julian Elischer
71fad9fdee Completely redo thread states.
Reviewed by:	davidxu@freebsd.org
2002-09-11 08:13:56 +00:00
Peter Wemm
0d8293f4ab Hopefully unbreak world. ke_slptime is gone. It should really have been
looking at p_ksegrp.kg_slptime anyway.
2002-08-30 02:18:38 +00:00
Alfred Perlstein
b20ea17938 Allow one to grab the definition of struct ucred by defining _WANT_UCRED
instead of forcing _KERNEL.

Move the include of sys/_label.h in ucred.h under the
_KERNEL || _WANT_UCRED case.
2002-08-28 20:39:48 +00:00
Kris Kennaway
d3cf4981d9 &x is not a format string 2002-08-24 07:15:55 +00:00
Mike Barcroft
abbd890233 o Merge <machine/ansi.h> and <machine/types.h> into a new header
called <machine/_types.h>.
o <machine/ansi.h> will continue to live so it can define MD clock
  macros, which are only MD because of gratuitous differences between
  architectures.
o Change all headers to make use of this.  This mainly involves
  changing:
    #ifdef _BSD_FOO_T_
    typedef	_BSD_FOO_T_	foo_t;
    #undef _BSD_FOO_T_
    #endif
  to:
    #ifndef _FOO_T_DECLARED
    typedef	__foo_t	foo_t;
    #define	_FOO_T_DECLARED
    #endif

Concept by:	bde
Reviewed by:	jake, obrien
2002-08-21 16:20:02 +00:00
Alfred Perlstein
aa22cbfea7 Hide 'struct ucred' behind '#ifdef _KERNEL', this should stop userland
from attempting to use it for good.  There is a catch, kvm_proc.c needs
to '#define _KERNEL' to get at the ucred.

Requested by: rwatson
2002-08-16 07:01:43 +00:00
Jake Burkholder
5aebb40291 Auto size available kernel virtual address space based on phsyical memory
size.  This avoids blowing out kva in kmeminit() on large memory machines
(4 gigs or more).

Reviewed by:	tmm
2002-08-10 22:14:16 +00:00
Julian Elischer
58551c0393 Don't even read in the thread if it is a zombie process. 2002-06-30 20:13:53 +00:00
Julian Elischer
bff4151c28 grow a brain and do this right. 2002-06-30 17:06:46 +00:00
Julian Elischer
6143c38376 Don't follow non existant thread pointers (e.g. for zombies) 2002-06-30 08:11:30 +00:00
Julian Elischer
e602ba25fd Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)

Reviewed by:	Almost everyone who counts
	(at various times, peter, jhb, matt, alfred, mini, bernd,
	and a cast of thousands)

	NOTE: this is still Beta code, and contains lots of debugging stuff.
	expect slight instability in signals..
2002-06-29 17:26:22 +00:00
Alfred Perlstein
a82bbc730e Assume __STDC__, remove non-__STDC__ code.
Submitted by: keramida
2002-05-28 17:03:12 +00:00
Jake Burkholder
8a9bbbc50a Catch up to tte.h changes. 2002-05-21 02:22:49 +00:00
David E. O'Brien
2242258dc7 Stub out _kvm_mdopen, we don't the same constants as NetBSD 2002-05-15 09:56:40 +00:00
David E. O'Brien
3a52718aad Add a PowerPC machdep for kvm.
Obtained from:	NetBSD (rev 1.4, pre-UVM)
2002-05-15 09:55:41 +00:00
Dima Dorfman
21687047cf Fix (for the second time) kvm_getprocs() for the case where no
processes match the given criteria.  Since revision 1.60 of malloc.c,
malloc() and friends return an invalid pointer when given a size of 0.
kvm_getprocs() uses sysctl() with a NULL oldp argument to get an
initial size, but does not check whether it's 0 before passing it to
realloc() (via _kvm_realloc()).  Before the aforementioned malloc()
change, this resulted in a minimal allocation made and a valid poitner
returned, but now results in an invalid, but non-NULL, pointer being
returned.  When this is passed to sysctl(), the latter returns EFAULT
(as it should).
2002-04-07 04:47:58 +00:00
David E. O'Brien
1372519b15 Remove multi-line __P() usage. 2002-03-22 09:22:15 +00:00
David E. O'Brien
69160b1eb7 Remove __P() usage. 2002-03-21 23:54:04 +00:00
David E. O'Brien
be04b6d190 Remove 'register' keyword. 2002-03-21 23:39:28 +00:00
Brian Feldman
49b33de841 Also blindly attempt to fix broken world with respect to proc.p_runtime
changes.
2002-02-22 19:10:09 +00:00
Julian Elischer
65e4542fca I THINK this fixes 'make world'
I'll know as soon as I re-import it and compile it.. :-)
 There is no longer a 'pri' strict in the proc struct.
 the fields are scattered between the ksegrp and thread in question.
2002-02-13 00:10:04 +00:00
Julian Elischer
3daf63fc50 pre-emptively fix a KSE/M3 problem.
Make a slight change so that libkvm reaches the main thread via the
linked list, rather than assuming it is in the proc structure. Both
conditions are true in -current but only the first will be true in
the KSE M3 world.
2002-02-07 20:28:25 +00:00
Ruslan Ermilov
fe42e96eff Finish cleanup in kvm.c revisions 1.10 and 1.11 -- mark sf (swapfile)
argument to kvm_open() and kvm_openfiles() as unused.

BSD didn't read swap since kvm.c CSRG revision 5.21 (u-area is pageable
under new VM.  no need to read from swap.)

The old !NEWVM code was removed in CSRG revision 5.23 (~ten years ago).
2002-01-22 10:07:03 +00:00
Jake Burkholder
e5a86020b0 Adapt to new kernel tsb structure. 2001-12-29 06:43:36 +00:00
Ruslan Ermilov
e6cb3c3608 s/processes/files/ inherited from kvm_getprocs(3).
PR:		docs/32252
Submitted by:	tobez
2001-11-24 15:38:28 +00:00