Commit Graph

42 Commits

Author SHA1 Message Date
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
fvdl c487efe4a7 Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.
* For sparc64 and amd64, define *SIZ32 VM constants.
* Add a new function pointer to struct emul, pointing at a function
  that will return the default VM map address. The default function
  is uvm_map_defaultaddr, which just uses the VM_DEFAULT_ADDRESS
  macro. This gives emulations control over the default map address,
  and allows things to be mapped at the right address (in 32bit range)
  for COMPAT_NETBSD32.
* Add code to adjust the data and stack limits when a COMPAT_NETBSD32
  or COMPAT_SVR4_32 binary is executed.
* Don't use USRSTACK in kern_resource.c, use p_vmspace->vm_minsaddr
  instead (emulations might have set it differently)
* Since this changes struct emul, bump kernel version to 3.99.2

Tested on amd64, compile-tested on sparc64.
2005-03-26 05:12:34 +00:00
perry 477853c351 nuke trailing whitespace 2005-02-26 22:58:54 +00:00
yamt 0994e6acb8 introduce a function, proclist_foreach_call, to iterate all procs on
a proclist and call the specified function for each of them.
primarily to fix a procfs locking problem, but i think that it's useful for
others as well.

while i'm here, introduce PROCLIST_FOREACH macro, which is similar to
LIST_FOREACH but skips marker entries which are used by proclist_foreach_call.
2004-10-01 16:30:52 +00:00
jdolecek 74436be135 pass the fork flags down to the emulation fork hook, so that emulation
code can use the information for setup
2004-08-08 08:42:03 +00:00
fvdl d99705e941 Put back Emmanuel's sigfilter hooks, as decided by Core. 2003-12-20 19:01:29 +00:00
manu b23b73b953 Introduce lwp_emuldata and the associated hooks. No hook is provided for the
exec case, as the emulation already has the ability to intercept that
with the e_proc_exec hook. It is the responsability of the emulation to
take appropriaye action about lwp_emuldata in e_proc_exec.

Patch reviewed by Christos.
2003-12-20 18:22:16 +00:00
jdolecek 0e253cf5f5 back the sigfilter emulation hook change off 2003-12-05 21:12:42 +00:00
atatat 13f8d2ce5f Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al.  Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded.  Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment.  I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 19:38:21 +00:00
manu 18e13eee35 Add a sigfilter emulation hook. It is used at the beginning of kpsignal2()
so that a specific emulation has the oportunity to filter out some signals.

if sigfilter returns 0, then no signal is sent by kpsignal2().

There is another place where signals can be generated: trapsignal. Since this
function is already an emulation hook, no call to the sigfilter hook was
introduced in trapsignal.

This is needed to emulate the softsignal feature in COMPAT_DARWIN (signals
sent as Mach exception messages)
2003-12-03 20:24:51 +00:00
he ea56bcee84 Hide the register number constants behind an _R_ prefix, and also
rename FPBASE to _FPBASE, so that we avoid polluting the user's
name space when e.g. <sys/ptrace.h> is included.  Previously, the
PC symbol in mips/regnum.h would conflict with the declaration of
the external variable by the same name in termcap.h, as discovered
by the ``okheaders'' regression test.
2003-11-26 08:36:49 +00:00
manu ee7a6d2747 Restore COMPAT_IRIX signal delivery to an usable state. We provide a
fake sigcode so that trampoline vers checks in sigaction1() will not
return EINVAL. Another fix would be to duplicate code from svr4_sys_sigaction()
to irix_sys_sigaction() and call sigaction1() with vers != 0. We do not
do that because it would duplicate some code.
2003-11-08 21:28:45 +00:00
chs 939df36e55 add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default.  the changes
fall into two basic catagories:

 - pmap and trap-handler changes.  these are all MD:
   = alpha: we already track per-page execute permission with the (software)
	PG_EXEC bit, so just have the trap handler pay attention to it.
   = i386: use a new GDT segment for %cs for processes that have no
	executable mappings above a certain threshold (currently the
	bottom of the stack).  track per-page execute permission with
	the last unused PTE bit.
   = powerpc/ibm4xx: just use the hardware exec bit.
   = powerpc/oea: we already track per-page exec bits, but the hardware only
	implements non-exec mappings at the segment level.  so track the
	number of executable mappings in each segment and turn on the no-exec
	segment bit iff the count is 0.  adjust the trap handler to deal.
   = sparc (sun4m): fix our use of the hardware protection bits.
	fix the trap handler to recognize text faults.
   = sparc64: split the existing unified TSB into data and instruction TSBs,
	and only load TTEs into the appropriate TSB(s) for the permissions.
	fix the trap handler to check for execute permission.
   = not yet implemented: amd64, hppa, sh5

 - changes in all the emulations that put a signal trampoline on the stack.
   instead, we now put the trampoline into a uvm_aobj and map that into
   the process separately.

originally from openbsd, adapted for netbsd by me.
2003-08-24 17:52:28 +00:00
he 86cc24bba0 #ifdef _KERNEL_OPT police. 2003-06-28 08:31:16 +00:00
martin d505b18964 Make sure to include opt_foo.h if a defflag option FOO is used. 2003-06-23 11:00:59 +00:00
rafal 5234d1eb92 Mechanical LWP'ification of IRIX compat code; untested as of right now. 2003-01-22 12:58:22 +00:00
jdolecek e1e0ff678b move ELF-specific items from irix_exec.c to irix_exec_elf32.c
merge the two emul_irix structures; the only difference was
  setregs function, which can be handled by exec-specific setregs hook
rename setregs_n32() to irix_n32_setregs(), and make it suitable
  as the exec-specific setregs hook
make irix_check_exec() a macro now that just single compare
2002-11-30 13:18:13 +00:00
jdolecek 47cd9b85d6 Get the dynamic interpreter location using emul_find_interp(), so that
it checks both the alternative/emul tree, and the non-emul tree.
This makes it possible to run chrooted emulated binaries without need
to setup shadow /emul tree within the chroot hierarchy.
Only tested for COMPAT_LINUX, changes to other compat modules were
mechanical.
Fixes kern/19161 by Christian Groessler.
2002-11-29 19:13:14 +00:00
manu 99bc517790 Added sysctl to change all IRIX kernel values reported by uname and systeminfo:
OS name, hw name, kernel version, and so forth.
2002-11-09 09:03:56 +00:00
jdolecek 1524c4bf08 set struct emul's nsysent to compat SYS_NSYSENT, not SYS_MAXSYSCALL 2002-11-01 19:26:21 +00:00
manu eeb799a6c9 Implement MAP_LOCAL option to mmap, which enable the mapping of regions
private to the process within the share group.

There is one bit missing in this implementation: when replicating a change
in a process VM to the other process of the share group, we avoid copying
mappings for private regions in the target process, but we don't prevent
copying private regions from the source process.
2002-10-14 21:14:23 +00:00
manu 80ee637534 - Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.

- While we are there, explicitely set to NULL the uninitialized fields in
struct emul: e_fault and e_sysctl on most ports

- e_fault is used by the trap handler, for now only on mips. In order to avoid
intrusive modifications in UVM, the function pointed by e_fault does not
has exactly the same protoype as uvm_fault:
int uvm_fault __P((struct vm_map *, vaddr_t, vm_fault_t, vm_prot_t));
int e_fault __P((struct proc *, vaddr_t, vm_fault_t, vm_prot_t));

- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
2002-09-21 21:14:54 +00:00
manu 652fe89179 - add locks to structures used by the /dev/usema driver and the
usync_cntl() system calls.

- when usync_cntl is used and the process is aborted (eg: by kill -9)
libc does not call usync_cntl() to unblock things. We have to cleanup
data allocated in the kernel. This is now done through the emulation
specific exit hook

- IRIX initialize some data in the system part of the PRDA: the pid and
a prid (PRDA ID?). We initialize both to pid.

- Move back struct irix_share_group from irix_exec.h to irix_prctl.h, it
is more revelant here.

- fix a few typos
2002-08-25 19:03:12 +00:00
manu 652d91cab0 Introduce a shared group structure, and make the sproc implementation
more SMP friendly.
2002-08-02 23:02:51 +00:00
manu 022bd85d32 When sproc is used to create a share group with shared memory, there is a
private area called PRDA that remains unshared. We implement this by using
different vmspace for each share group member, and keeping the memory
appings in sync on each mmap/munmap/mprotect/break...

We use irix_saddr_sync_vmcmd and irix_saddr_sync_syscall to apply a
vmcmd or a syscall to all share group member, this makes the job a bit
easier.

Also implements {get|set}rlimit{64}.
2002-06-12 20:33:20 +00:00
manu 55dd8b2806 - Introduce irix_check_exec() to check if a given process is an IRIX one
- First implementation of procblk(). THis is supposed to suspend processes.
We emulate this by sending a SIGSTOP, which is not very accurate since
on IRIX, sending a SIGCONT to a process suspended by procblk() will not
resume it.
- support for shared groups
2002-06-05 17:27:11 +00:00
manu a808ca7f07 Now support per-signal signal trampolines. 2002-06-02 19:06:02 +00:00
manu f4e81e0cfb - the signal trampoline address is now copied during a fork(). This avoids
a SIGSEGV when sigaction(2) is used before a fork(2) and a signal is received
in the child.
- we now nearly correctly emulate PR_TERMCHILD in prctl(2). (the perfect
emulation would not send a SIGHUP if the parent is killed)
2002-05-28 21:15:41 +00:00
manu d5ed80d9c6 The IRIX usinit(3) function expects a page of memory to be available at
address 0x200000 (disasembling usinit shows that this address is hardcoded in
libc). It uses it for locks and semaphres.

We therefore allocate this page of memory, to prevent IRIX process from
faulting when thay call usinit(3).
2002-04-20 16:19:22 +00:00
manu f8c12b3107 IRIX provide a signal trampoline in libc, we now use it.
- the signal trampoline address is given to the kernel by a sigaction()
  fourth argument
- we introduce an irix_emuldata structure to keep track of the signal
  trampoline address
- we don't support per-sigaction signal trampolines, we only do per-process
- now that we use the IRIX libc signal trampoline, we do not have to handle
  the errno update from the signal trampoline
- it is possible that IRIX 5 signal delivery works too, since theses binaries
  will come with their own signal trampoline
2002-04-14 21:50:49 +00:00
manu 89e46d8a99 Reworked the o32/n32 matching scheme. IRIX uses some e_flags in the ELF
header to distinguish between o32, n32 and n64 ABIs. We now use this.
This suppress the need of the mips_option test, which had some fake positive.
This also removes the mandatory ordering of n32 vs o32 in the exec switch
(exec_conf.c)
2002-02-21 21:53:00 +00:00
manu 25e8963ed3 Fixed typo 2002-02-20 21:18:18 +00:00
manu c8d430d60d missing include 2002-01-07 23:12:30 +00:00
manu 0b98511d4a Added code to match and launch n32 binaries (there is no N32 support in the
kernel yet)
2002-01-07 22:05:03 +00:00
manu 4d54359755 Implemented irix_sys_xstat(). This duplicates some code already present
for svr4 compat, maybe these should be merged..
2001-12-08 18:08:04 +00:00
manu e3824c6c59 Added IRIX signal delivery 2001-12-08 11:17:37 +00:00
manu 9dfecbefdb Fixed stack setup for argument passing. argc and **argv need to be aligned
on a 16 bytes boundary. To get things done, we currently duplicate a lot of
code from copyargs(), this should be done in a nicer way.
2001-12-04 22:13:41 +00:00
manu 77fa6038d9 Added errno translation 2001-12-02 16:16:57 +00:00
manu 7839e13a9c On IRIX, the first 88 system calls are quite plain SVR4, and the 137
remaining are IRIX specific. We know use SVR4 emulation for the first 88
system calls.
2001-11-28 12:00:53 +00:00
manu be8254f3a8 Added code to match IRIX N32 binaries 2001-11-26 21:36:24 +00:00
lukem dab6ef8b56 add RCSIDs (including regeneration of files as appropriate) 2001-11-13 02:07:52 +00:00
manu e7a3ba084e Empty framework for upcoming work on IRIX_COMPAT 2001-09-22 18:51:35 +00:00