Commit Graph

61 Commits

Author SHA1 Message Date
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
ad f474dceb13 Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
christos fc6d984beb kauth fallout 2006-05-15 00:05:16 +00:00
elad 874fef3711 integrate kauth. 2006-05-14 21:19:33 +00:00
thorpej be8b235384 Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
  trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
  about KTRACE and SYSTRACE, but do no more.
2006-03-07 03:32:04 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
perry 477853c351 nuke trailing whitespace 2005-02-26 22:58:54 +00:00
manu 996e659ce6 Try to do a better job at Mach port refcount. That's not perfect, though. 2004-01-01 22:48:54 +00:00
manu 834aafd284 Rework Mach exception and Darwin's ptrace. gdb is now able to attach a
remote process. This new implementation also passes all the test programs
I've written so far.

- When exceptions come from traps, no UNIX signal should evet be sent.
- Add a lock to ensure a debugger handles only one exception at a time
- Use a structure to hold flavor and behavior in exception ports, instead
  of stuffing the two argument into an int.
- Implement new Mach services: thread_suspend, thread_resume and thread_abort
- Implement Darwin's ptrace PT_ATTACHEXC and PT_THUPDATE commands
- Handle NULL second argument correctly in sigprocmask.
- One mistake in the last commit (darwin_tracesig prototype)
2003-12-24 23:22:22 +00:00
manu 066436a916 Provide a kernel port for each thread. This makes the emulation of
Mach threads much more accurate: we do not confuse threads and tasks
anymore.
2003-12-20 19:43:17 +00:00
grant 44ed233ab5 KNF, spelling and english fixes to some comments. remove trailing
whitespace.
2003-12-18 01:10:20 +00:00
manu 99ee466dbb Move most of the code involved into message header, trailer, and descriptor
construction to inline functions. This removes a lot of redundent code
from Mach services
2003-12-09 11:29:01 +00:00
manu 98f233296d Factor the code for OOL data movement into mach_ool_copyin and
mach_ool_copyout.

Handle port namespace and address space translations when OOL
data moves between different processes (untested)
2003-12-08 19:27:38 +00:00
manu 9046478856 Use appropriate macro definitions when filling complex messages
descriptor. This changes nothing but it removes a lot of XXX
2003-12-08 12:03:16 +00:00
manu 174b751317 In task_terminate, unstop the process so that we can really terminate it now 2003-12-06 15:16:10 +00:00
manu 8f3ee36470 Fix some panics caused by incorrect Mach exceptions reference counts 2003-12-06 15:15:19 +00:00
manu ab8a1b7902 Add task_terminate 2003-11-30 20:42:03 +00:00
manu 8aa5d7b0f3 In Mach_task_suspend, stop the process without awaking its parent, this is
wrong on the semantic front; the spurious wakeup confuses Darwin's gdb.

Allow vm, task and thread operations on remote processes. The code to pick up
the remote process is in mach_sys_msg_trap(), so that any Mach service can
use it.
2003-11-27 23:44:49 +00:00
manu ae4ac4f570 Also allow to change special and exception ports from a remote process 2003-11-24 20:30:19 +00:00
manu 2569c624db Don't free a buffer before we finished reading it 2003-11-24 17:20:58 +00:00
manu 1147a0b1e6 Enable tracing of out of line data sent with Mach message 2003-11-24 16:51:33 +00:00
manu 662a14a8e6 Once a process has the kernel port to another process or thread, it can
use it to get process state and other stuff. It's not clear if this can
be used to modify exception ports or special ports (this needs to be
tested)
2003-11-24 14:31:40 +00:00
manu 48b5fdb14d Don't use the target port in task_for_pid: it is only usefull on
multiple-machine configurations -- something we don't do yet.
2003-11-22 17:17:55 +00:00
manu 3c00d1aad5 Start to implement another strange feature: signals as Mach software
exceptions. This can be requested with ptrace, and cause signals to
be transformed into a particular kind of exception.
2003-11-20 07:12:34 +00:00
manu e04d06c9bb More work on exceptions. Once a task has raised an exception, it remains
blocked in the kernel. The task that catched the exception may unblock
it by sending a reply to the exception message (Of course it will have
to change something so that the exception is not immediatly raised again).

Handling of this reply is a bit complicated, as the kernel acts as the
client instead of the server. In this situation, we receive a message
but we will not send any reply (the message we receive is already a reply).
I have not found anything better than a special case in
mach_msg_overwrite_trap() to handle this.

A surprise: exceptions ports are preserved accross forks.

While we are there, use appropriate 64 bit types for make_memory_entry_64.
2003-11-18 01:40:18 +00:00
manu d4b49d8b97 Illegal instruction exceptions
Warning on non-supported exception in task_set_exception_ports
Implementation of task_get_exception_ports
2003-11-17 13:20:06 +00:00
manu 144bfac97b First work on Mach exceptions. Things that can turn into signals on UNIX
may turn into exceptions on Mach: a small message sent by the kernel to
the task that requested the exception.
On Darwin, when an exception is sent, no signal can be delivered.

TODO: more exceptions: arithmetic, bad instructions, emulation, s
software, and syscalls (plain and Mach). There is also RPC alert, but
I have no idea about what it is.

While we are there, remove some user ktrace in notification code, and add
a NODEF qualifier in mach_services.master: it will be used for notifications
and exceptions, where the kernel is always client and never server: we
don't want the message to be displayed as "unimplemented xxx" in kdump (thus
UNIMPL is not good), but we don't want to generate the server prototype
(therefore, STD is not good either). NODEF will declare it normally in the
name tables without creating the prototype.
2003-11-17 01:52:14 +00:00
manu 26853377eb Try to add all mach servers defined in Darwin in the server list. Most of
them will never be implemented, of course.
2003-11-15 17:44:38 +00:00
manu b5139de154 Enforce good santity checks with Mach messages sizes:
1) make sure Mach servers will not work on data beyond the end of the
   request message buffer.
2) make sure that on copying out the reply message buffer, we will not
   leak kernel data located after the buffer.
3) make sure that the server will not overwrite memory beyond the end
   of the reply message buffer. That check is the responsability of the
   server, there is just a DIAGNOSTIC test to check everything is in
   good shape. All currently implemented servers in NetBSD have been
   modified to check for this condition

While we are here, build the mach services table (formerly in mach_namemap.c)
and the services prototypes automatically from mach_services.master, just
as this is done for system calls.

The next step would be to fold the message formats in the mach_services.master
file, but this tends to be difficult, as some messages are quite long and
complex.
2003-11-13 13:40:39 +00:00
manu 40a3558468 mach_msg_ool_ports_descriptor_t describe a memory region containing
an array of mach_port_name_t, not mach_msg_port_descriptor_t.
2003-11-12 00:00:28 +00:00
manu 95cc30edca Correctly implement task_suspend and task_resume: the struct proc is
taked from mp->mp_data.
2003-11-11 17:26:32 +00:00
manu 6961fe8c08 Fix an unitialized variable bug that caused a crash in mach_task_suspend().
While we are there, resolved another mystery: the unallocated port described
in the comment removed by this commit was in fact allocated by mach_task_pid().
2003-11-11 15:00:09 +00:00
manu 70a91d4b66 Better warnings on not fully implemented mach traps. 2003-11-09 11:10:11 +00:00
mycroft a65f74a513 Previous changes were not correct. 2003-10-25 20:15:13 +00:00
christos 4bec333ae4 Fix uninitialized variable warnings 2003-10-25 18:37:49 +00:00
manu 30bb8c56a7 More debug 2003-04-29 22:12:51 +00:00
manu 0479104b05 First attempt with task_suspend/task_resume, but we hit some bugs somewhere
else in our code.
2003-04-06 17:58:49 +00:00
manu c74de80216 Implement task_info 2003-04-05 21:18:02 +00:00
manu fd94bf9486 First work on notifications. Not really working for now. 2003-03-29 11:04:08 +00:00
manu cb771e3c64 Make the beast build again (but it is still probably broken) 2003-01-24 21:37:01 +00:00
matt b03d17694a Do a preliminary switchover of the mach code to lwp's. It compiles now
but probably doesn't work.   That's for someone who understand this code
better.
2003-01-21 04:06:06 +00:00
manu f3e11e72e9 Introduce port names, deallocate mach ressources at Darwin process exit 2002-12-31 15:47:37 +00:00
manu d9f2a8dbcd - When mach_init saves the bootstrap port, make it the default bootstrap port
for any program we will launch later. This is a hack to avoid the need
of launching any Darwin binary as a child of mach_init
- More and more debug
2002-12-30 18:44:33 +00:00
manu 874517b438 - When MACH_MSG_RCV_LARGE is set, we must return a message with just a header
and a body.
- If mach_init is not availabkle for boostrap requests, try to handle them
in the kernel (we don't really handle them, we just try to avoid hanging there)
- minor tweaks.
2002-12-27 19:57:47 +00:00
manu f464631d66 Several things:
1) rights should be shared by the threads within a process. While it would
be easier to handle this with the struct proc/struct lwp split, we attempt to
do this now by sharing the right lists. Because each right holds a reference
to struct proc, this might cause some problems later.
2) in pthread_exit, really exit the thread. Also reintialize the righ tlist to
make sure we will not destroy the parent's right list
3) rights can hold multiple permissions on a port (ie: send and receive). Fix th
is.
4) first attempt on right carried by messages. We still have to do rights carrie
d in the message body (complex messages).
2002-12-27 09:59:24 +00:00
manu 185383e0a7 Typo 2002-12-24 12:29:06 +00:00
manu 3b71b464b2 First attempt on mach ports sets. Also maitian only one list of rights
per process, as segregating recv, send and send_once did not buy anything.
2002-12-19 22:23:06 +00:00
manu 391c8a71fc In mach_ports_lookup, allow the out of band data mapping anywhere we have
some free space
2002-12-17 22:47:07 +00:00
manu 5ba396cfb3 Added support for exchange of Mach messages between processes.
This does not buy us new functionnality for now, because we still have to
discover how mach_init (which acts as a name server, enabling processes to
discover each other's ports) is able to receive messages from other processes
(this is a bootstrap problem, and the bootstrap port might be the place to
search).

While we are there:
- removed a lot of debug which is now available using ktrace.
- reworked message handling to avoid mutliple copyin/copyout of the
same data. ktrace of Mach message now uses the in-kernel copy of the
message instead of copying it from userland.
- packed mach trap handlers arguments into a structure to avoid modifying
everything next time we have to add an argument.
2002-12-17 18:42:54 +00:00