Commit Graph

215 Commits

Author SHA1 Message Date
manu df54a7fcc7 When handling complex messages, uses mach_msg_type_descriptor_t until we
know what type a descriptor really is.
2003-12-08 12:02:24 +00:00
manu 4e9539e452 When a task to task message carries ports, translate the port names into the
receiver namespace.

While we are there, refactor mach_msg_overwrite by splitting it into
several smaller functions. It had grown too big to be easily maintainable.
2003-12-07 23:44:14 +00:00
manu c29e7d5f16 Added SCHED_INFO flavor in host_info 2003-12-07 10:17:09 +00:00
manu dc728f311c Don't allow mappings at address zero in vm_allocate: first page is a
red zone in Darwin, and nothing should be mapped there.
While we are here, ifdef DEBUG_MACH_VM all the VM-related debug messages
2003-12-06 19:34:21 +00:00
manu 0951833f2e Remove the reference to struct proc in kernel and host port once the
process terminate, so that no stale pointer can be used if the port is
still referenced
2003-12-06 17:04:50 +00:00
manu 0105d58e0a Don't send Mach exceptions to dying processes 2003-12-06 15:16:38 +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
jdolecek 0e253cf5f5 back the sigfilter emulation hook change off 2003-12-05 21:12:42 +00:00
manu ac7838e90f In the basic thread info, suspend count is the suspend sempahore. Just return
0 for now. This is plain wrong, but at least it allows gdb to startup a
program.
2003-12-03 22:25:46 +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
manu 7973f2217b Rework Mach exceptions and softignals
Exceptions coming from a trap are generated from darwin_trapsignal()
softsignals are from darwin_sigfilter(), a function that is called
from darwin_trapsignal() and from kpsignal2() [the latter from a
emulation specific hook which is not yet committed]

Make some sanity checks to avoid sending data to a port with no receiver.

See http://mail-index.netbsd.org/tech-kern/2003/12/01/0008.html and
follow-ups for details.
2003-12-03 18:40:07 +00:00
manu 057381d1b4 Move machine dependent definitions to machine dependent headers. 2003-12-03 18:25:44 +00:00
manu 20fbf8c756 Trace data movement with vm_read and vm_write 2003-12-03 18:19:12 +00:00
manu eff089cdc0 More santity checks when sending data to a port: is there someone listening
on the receive end?
2003-12-03 18:18:43 +00:00
manu 437424d5f6 I forgot to commit this file for vm_machine_attribute to build correctly 2003-11-30 20:42:55 +00:00
manu ab8a1b7902 Add task_terminate 2003-11-30 20:42:03 +00:00
manu 540ad6ee85 Fix minor bug in the script that generate Mach services files (the master
fie tag was not copied)
2003-11-30 00:09:59 +00:00
manu 097771219f Implement vm_read, vm_write, and a framework for vm_machine_attribute.
THe machine dependent bit nees to be written.
2003-11-29 23:56:08 +00:00
manu 23a18da8cd To lookup a map entry in vm_map, use uvm_map_lookup, and not uvm_map_findspace,
which will not work on already mapped objects.
2003-11-28 08:03:14 +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 9f69fbc7dc When sending exception with identity, include right names in the
receiver name space, not the sender one.
2003-11-25 23:17:40 +00:00
christos 5b1f7c5277 lr is uninitialized if we goto out1 2003-11-25 21:59:31 +00:00
manu c5006e8c0c Outch, uninitialized variable. How could that work before? 2003-11-25 17:09:24 +00:00
manu 206a81affc Don't change process' special ports on exec(). If gdb attached the process,
it holds rights to the special ports, and it expects the rights to be valid
even after the process calls exec().
2003-11-25 13:22:38 +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 c7f488a7ae typo 2003-11-24 15:06:09 +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 43b8c2c38e Avoid re-allocations of darwin_emuldata structures by COMPAT_MACH. This
caused a memory leak, and as mach_emuldata is shorter than darwin_emuldata,
it caused memory corruption.
2003-11-20 22:05:25 +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 28116d3012 Don't release the bootstrap port too much, as it is shared between
processes.
2003-11-18 15:57:13 +00:00
manu 74076749f8 Avoid leaking some Mach ports allocated in the kernel on fork, exec and
exit operations.
2003-11-18 14:11:33 +00:00
manu 2079e3b2b5 SIGTRAP is used for breakpoints 2003-11-18 11:20: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 5d86e6465f Typos in make_memory_entry_64 name definitions 2003-11-16 01:14:07 +00:00
manu ce84f3934f Implement swtch_pri() and swtch() 2003-11-16 01:12:30 +00:00
manu 4513f19345 iTry to gather as much Mach services names as possible, this way we
will have unimplemented services showing their names in ktrace

Add a new generated file with only service id and name, which will
be included by kdump to display services names.

This removes the need for using the user ktrace facility for services names.
2003-11-15 22:55:35 +00:00
thorpej 052ba0ec50 We have CVS; there is no reason to make .bak files when generating the
syscall tables.
2003-11-15 20:30:59 +00:00
manu 527b59366e regen 2003-11-15 17:45:34 +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
chs e07f0b9362 eliminate uvm_useracc() in favor of checking the return value of
copyin() or copyout().

uvm_useracc() tells us whether the mapping permissions allow access to
the desired part of an address space, and many callers assume that
this is the same as knowing whether an attempt to access that part of
the address space will succeed.  however, access to user space can
fail for reasons other than insufficient permission, most notably that
paging in any non-resident data can fail due to i/o errors.  most of
the callers of uvm_useracc() make the above incorrect assumption.  the
rest are all misguided optimizations, which optimize for the case
where an operation will fail.  we'd rather optimize for operations
succeeding, in which case we should just attempt the access and handle
failures due to insufficient permissions the same way we handle i/o
errors.  since there appear to be no good uses of uvm_useracc(), we'll
just remove it.
2003-11-13 03:09:28 +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 b6b7d129a1 Added mach_thread_set_state 2003-11-11 18:12:40 +00:00
manu a2bed85761 Implement mach_thread_get_state.
While we are here, try to tag machine dependent functions in header files.
also transformed darwin_ppc_*_state into mach_ppc_*_state, as this is
what they really are (COMPAT_DARWIN is on the top of COMPAT_MACH, not the
other way around)
2003-11-11 17:31:59 +00:00