summaryrefslogtreecommitdiff
path: root/ipc/ipc_kmsg.c
diff options
context:
space:
mode:
authorThomas Schwinge <tschwinge@gnu.org>2006-12-03 20:16:16 +0000
committerThomas Schwinge <tschwinge@gnu.org>2009-06-18 00:26:57 +0200
commit96c01087a657dfc1c877b63e9e6b0f45c37b9c78 (patch)
tree11f6e4d507c8327b52d167a718ec65c184c6bbfd /ipc/ipc_kmsg.c
parenta0e81d1ebfbf11bc056f729242e8565f177afa95 (diff)
2006-12-03 Thomas Schwinge <tschwinge@gnu.org>
[patch #5017 --- ``Remove obsolete IPC interfaces.''] * DEVELOPMENT: Document the removal. * configfrag.ac (MACH_IPC_COMPAT): Don't define. 2006-12-03 Leonardo Lopes Pereira <leonardolopespereira@gmail.com> [patch #5017 --- ``Remove obsolete IPC interfaces.''] * kern/act.c [MIGRATING_THREADS]: Don't include <mach_ipc_compat.h>. * kern/act.h: Likewise. * i386/include/mach/i386/machine_types.defs: Adapt all users of MACH_IPC_COMPAT as if it were always defined to `0'. * include/mach/mach.defs: Likewise. * include/mach/mach_param.h: Likewise. * include/mach/mach_traps.h: Likewise. * include/mach/message.h: Likewise. * include/mach/mig_errors.h: Likewise. * include/mach/notify.h: Likewise. * include/mach/port.h: Likewise. * include/mach/std_types.defs: Likewise. * include/mach/syscall_sw.h: Likewise. * include/mach/task_special_ports.h: Likewise. * include/mach/thread_special_ports.h: Likewise. * ipc/ipc_kmsg.c: Likewise. * ipc/ipc_kmsg.h: Likewise. * ipc/ipc_marequest.c: Likewise. * ipc/ipc_notify.c: Likewise. * ipc/ipc_notify.h: Likewise. * ipc/ipc_object.c: Likewise. * ipc/ipc_object.h: Likewise. * ipc/ipc_port.c: Likewise. * ipc/ipc_port.h: Likewise. * ipc/ipc_right.c: Likewise. * ipc/ipc_right.h: Likewise. * ipc/ipc_space.c: Likewise. * ipc/ipc_space.h: Likewise. * ipc/mach_debug.c: Likewise. * ipc/mach_msg.c: Likewise * ipc/mach_msg.h: Likewise. * ipc/mach_port.c: Likewise. * kern/act.c: Likewise. * kern/act.h: Likewise. * kern/ipc_host.c: Likewise. * kern/ipc_tt.c: Likewise. * kern/syscall_sw.c: Likewise. * kern/thread.h: Likewise.
Diffstat (limited to 'ipc/ipc_kmsg.c')
-rw-r--r--ipc/ipc_kmsg.c494
1 files changed, 0 insertions, 494 deletions
diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c
index 9f207d7..e6e2932 100644
--- a/ipc/ipc_kmsg.c
+++ b/ipc/ipc_kmsg.c
@@ -651,13 +651,6 @@ ipc_kmsg_put_to_kernel(
* notification would be sent to the named receive right,
* then it isn't sent and the send-once right for the notify
* port is quietly destroyed.
- *
- * [MACH_IPC_COMPAT] There is an atomicity problem if the
- * reply port is a compat entry and dies at an inopportune
- * time. This doesn't have any serious consequences
- * (an observant user task might conceivably notice that
- * the destination and reply ports were handled inconsistently),
- * only happens in compat mode, and is extremely unlikely.
* Conditions:
* Nothing locked.
* Returns:
@@ -1225,27 +1218,7 @@ ipc_kmsg_copyin_header(msg, space, notify)
kr = ipc_right_copyin(space, reply_name, reply_entry,
reply_type, TRUE,
&reply_port, &reply_soright);
-#if MACH_IPC_COMPAT
- if (kr != KERN_SUCCESS) {
- assert(kr == KERN_INVALID_NAME);
-
- /*
- * Oops. This must have been a compat entry
- * and the port died after the check above.
- * We should back out the copyin of dest_port,
- * and report MACH_SEND_INVALID_REPLY, but
- * if dest_port is alive we can't always do that.
- * Punt and pretend we got IO_DEAD, skipping
- * further hairy atomicity problems.
- */
-
- reply_port = IO_DEAD;
- reply_soright = IP_NULL;
- goto skip_reply_checks;
- }
-#else /* MACH_IPC_COMPAT */
assert(kr == KERN_SUCCESS);
-#endif /* MACH_IPC_COMPAT */
if ((saved_reply != IP_NULL) && (reply_port == IO_DEAD)) {
ipc_port_t dest = (ipc_port_t) dest_port;
@@ -1306,15 +1279,6 @@ ipc_kmsg_copyin_header(msg, space, notify)
if (IE_BITS_TYPE(reply_entry->ie_bits) == MACH_PORT_TYPE_NONE)
ipc_entry_dealloc(space, reply_name, reply_entry);
-#if MACH_IPC_COMPAT
- skip_reply_checks:
- /*
- * We jump here if the reply entry was a compat entry
- * and the port died on us. In this case, the copyin
- * code already deallocated reply_entry.
- */
-#endif /* MACH_IPC_COMPAT */
-
if (IE_BITS_TYPE(dest_entry->ie_bits) == MACH_PORT_TYPE_NONE)
ipc_entry_dealloc(space, dest_name, dest_entry);
@@ -2685,464 +2649,6 @@ ipc_kmsg_copyout_dest(kmsg, space)
}
}
-#if MACH_IPC_COMPAT
-
-/*
- * Routine: ipc_kmsg_copyin_compat
- * Purpose:
- * "Copy-in" port rights and out-of-line memory
- * in the message.
- *
- * In all failure cases, the message is left holding
- * no rights or memory. However, the message buffer
- * is not deallocated. If successful, the message
- * contains a valid destination port.
- * Conditions:
- * Nothing locked.
- * Returns:
- * MACH_MSG_SUCCESS Successful copyin.
- * MACH_SEND_INVALID_DEST Can't copyin destination port.
- * MACH_SEND_INVALID_REPLY Can't copyin reply port.
- * MACH_SEND_INVALID_MEMORY Can't grab out-of-line memory.
- * MACH_SEND_INVALID_RIGHT Can't copyin port right in body.
- * MACH_SEND_INVALID_TYPE Bad type specification.
- * MACH_SEND_MSG_TOO_SMALL Body is too small for types/data.
- */
-
-mach_msg_return_t
-ipc_kmsg_copyin_compat(kmsg, space, map)
- ipc_kmsg_t kmsg;
- ipc_space_t space;
- vm_map_t map;
-{
- msg_header_t msg;
- mach_port_t dest_name;
- mach_port_t reply_name;
- ipc_object_t dest, reply;
- mach_msg_type_name_t dest_type, reply_type;
- vm_offset_t saddr, eaddr;
- boolean_t complex;
- kern_return_t kr;
- boolean_t use_page_lists, steal_pages;
-
- msg = * (msg_header_t *) &kmsg->ikm_header;
- dest_name = (mach_port_t) msg.msg_remote_port;
- reply_name = (mach_port_t) msg.msg_local_port;
-
- /* translate the destination and reply ports */
-
- kr = ipc_object_copyin_header(space, dest_name, &dest, &dest_type);
- if (kr != KERN_SUCCESS)
- return MACH_SEND_INVALID_DEST;
-
- if (reply_name == MACH_PORT_NULL) {
- reply = IO_NULL;
- reply_type = 0;
- } else {
- kr = ipc_object_copyin_header(space, reply_name,
- &reply, &reply_type);
- if (kr != KERN_SUCCESS) {
- ipc_object_destroy(dest, dest_type);
- return MACH_SEND_INVALID_REPLY;
- }
- }
-
- kmsg->ikm_header.msgh_bits = MACH_MSGH_BITS(dest_type, reply_type);
- kmsg->ikm_header.msgh_size = (mach_msg_size_t) msg.msg_size;
- kmsg->ikm_header.msgh_remote_port = (mach_port_t) dest;
- kmsg->ikm_header.msgh_local_port = (mach_port_t) reply;
- kmsg->ikm_header.msgh_seqno = (mach_msg_kind_t) msg.msg_type;
- kmsg->ikm_header.msgh_id = (mach_msg_id_t) msg.msg_id;
-
- if (msg.msg_simple)
- return MACH_MSG_SUCCESS;
-
- complex = FALSE;
- use_page_lists = ipc_kobject_vm_page_list(ip_kotype((ipc_port_t)dest));
- steal_pages = ipc_kobject_vm_page_steal(ip_kotype((ipc_port_t)dest));
-
- saddr = (vm_offset_t) (&kmsg->ikm_header + 1);
- eaddr = (vm_offset_t) &kmsg->ikm_header + kmsg->ikm_header.msgh_size;
-
- while (saddr < eaddr) {
- vm_offset_t taddr = saddr;
- mach_msg_type_long_t *type;
- mach_msg_type_name_t name;
- mach_msg_type_size_t size;
- mach_msg_type_number_t number;
- boolean_t is_inline, longform, dealloc, is_port;
- vm_offset_t data;
- vm_size_t length;
-
- type = (mach_msg_type_long_t *) saddr;
-
- if (((eaddr - saddr) < sizeof(mach_msg_type_t)) ||
- ((longform = ((mach_msg_type_t*)type)->msgt_longform) &&
- ((eaddr - saddr) < sizeof(mach_msg_type_long_t)))) {
- ipc_kmsg_clean_partial(kmsg, taddr, FALSE, 0);
- return MACH_SEND_MSG_TOO_SMALL;
- }
-
- is_inline = ((mach_msg_type_t*)type)->msgt_inline;
- dealloc = ((mach_msg_type_t*)type)->msgt_deallocate;
- if (longform) {
- /* This must be aligned */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
- (is_misaligned(type))) {
- saddr = ptr_align(saddr);
- continue;
- }
- name = type->msgtl_name;
- size = type->msgtl_size;
- number = type->msgtl_number;
- saddr += sizeof(mach_msg_type_long_t);
- } else {
- name = ((mach_msg_type_t*)type)->msgt_name;
- size = ((mach_msg_type_t*)type)->msgt_size;
- number = ((mach_msg_type_t*)type)->msgt_number;
- saddr += sizeof(mach_msg_type_t);
- }
-
- is_port = MSG_TYPE_PORT_ANY(name);
-
- if (is_port && (size != PORT_T_SIZE_IN_BITS)) {
- ipc_kmsg_clean_partial(kmsg, taddr, FALSE, 0);
- return MACH_SEND_INVALID_TYPE;
- }
-
- /*
- * New IPC says these should be zero, but old IPC
- * tasks often leave them with random values. So
- * we have to clear them.
- */
-
- ((mach_msg_type_t*)type)->msgt_unused = 0;
- if (longform) {
- type->msgtl_header.msgt_name = 0;
- type->msgtl_header.msgt_size = 0;
- type->msgtl_header.msgt_number = 0;
- }
-
- /* padding (ptrs and ports) ? */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
- ((size >> 3) == sizeof(natural_t)))
- saddr = ptr_align(saddr);
-
- /* calculate length of data in bytes, rounding up */
-
- length = ((number * size) + 7) >> 3;
-
- if (is_inline) {
- vm_size_t amount;
-
- /* inline data sizes round up to int boundaries */
-
- amount = (length + 3) &~ 3;
- if ((eaddr - saddr) < amount) {
- ipc_kmsg_clean_partial(kmsg, taddr, FALSE, 0);
- return MACH_SEND_MSG_TOO_SMALL;
- }
-
- data = saddr;
- saddr += amount;
- } else {
- vm_offset_t addr;
-
- if ((eaddr - saddr) < sizeof(vm_offset_t)) {
- ipc_kmsg_clean_partial(kmsg, taddr, FALSE, 0);
- return MACH_SEND_MSG_TOO_SMALL;
- }
-
- /* grab the out-of-line data */
-
- addr = * (vm_offset_t *) saddr;
-
- if (length == 0)
- data = 0;
- else if (is_port) {
- data = kalloc(length);
- if (data == 0)
- goto invalid_memory;
-
- if (copyinmap(map, (char *) addr,
- (char *) data, length) ||
- (dealloc &&
- (vm_deallocate(map, addr, length) !=
- KERN_SUCCESS))) {
- kfree(data, length);
- goto invalid_memory;
- }
- } else {
- vm_map_copy_t copy;
-
- if (use_page_lists) {
- kr = vm_map_copyin_page_list(map,
- addr, length, dealloc,
- steal_pages, &copy, FALSE);
- } else {
- kr = vm_map_copyin(map, addr, length,
- dealloc,
- &copy);
- }
- if (kr != KERN_SUCCESS) {
- invalid_memory:
- ipc_kmsg_clean_partial(kmsg, taddr,
- FALSE, 0);
- return MACH_SEND_INVALID_MEMORY;
- }
-
- data = (vm_offset_t) copy;
- }
-
- * (vm_offset_t *) saddr = data;
- saddr += sizeof(vm_offset_t);
- complex = TRUE;
- }
-
- if (is_port) {
- mach_msg_type_name_t newname =
- ipc_object_copyin_type(name);
- ipc_object_t *objects = (ipc_object_t *) data;
- mach_msg_type_number_t i;
-
- if (longform)
- type->msgtl_name = newname;
- else
- ((mach_msg_type_t*)type)->msgt_name = newname;
-
- for (i = 0; i < number; i++) {
- mach_port_t port = (mach_port_t) objects[i];
- ipc_object_t object;
-
- if (!MACH_PORT_VALID(port))
- continue;
-
- kr = ipc_object_copyin_compat(space, port,
- name, dealloc, &object);
- if (kr != KERN_SUCCESS) {
- ipc_kmsg_clean_partial(kmsg, taddr,
- TRUE, i);
- return MACH_SEND_INVALID_RIGHT;
- }
-
- if ((newname == MACH_MSG_TYPE_PORT_RECEIVE) &&
- ipc_port_check_circularity(
- (ipc_port_t) object,
- (ipc_port_t) dest))
- kmsg->ikm_header.msgh_bits |=
- MACH_MSGH_BITS_CIRCULAR;
-
- objects[i] = object;
- }
-
- complex = TRUE;
- }
- }
-
- if (complex)
- kmsg->ikm_header.msgh_bits |= MACH_MSGH_BITS_COMPLEX;
-
- return MACH_MSG_SUCCESS;
-}
-
-/*
- * Routine: ipc_kmsg_copyout_compat
- * Purpose:
- * "Copy-out" port rights and out-of-line memory
- * in the message, producing an old IPC message.
- *
- * Doesn't bother to handle the header atomically.
- * Skips over errors. Problem ports produce MACH_PORT_NULL
- * (MACH_PORT_DEAD is never produced), and problem memory
- * produces a zero address.
- * Conditions:
- * Nothing locked.
- * Returns:
- * MACH_MSG_SUCCESS Copied out rights and memory.
- */
-
-mach_msg_return_t
-ipc_kmsg_copyout_compat(kmsg, space, map)
- ipc_kmsg_t kmsg;
- ipc_space_t space;
- vm_map_t map;
-{
- msg_header_t msg;
- mach_msg_bits_t mbits = kmsg->ikm_header.msgh_bits;
- ipc_object_t dest = (ipc_object_t) kmsg->ikm_header.msgh_remote_port;
- ipc_object_t reply = (ipc_object_t) kmsg->ikm_header.msgh_local_port;
- mach_port_t dest_name, reply_name;
- vm_offset_t saddr, eaddr;
- kern_return_t kr;
-
- assert(IO_VALID(dest));
-
- io_lock(dest);
- if (io_active(dest)) {
- mach_msg_type_name_t dest_type = MACH_MSGH_BITS_REMOTE(mbits);
-
- ipc_object_copyout_dest(space, dest, dest_type, &dest_name);
- /* dest is unlocked */
- } else {
- io_release(dest);
- io_check_unlock(dest);
- dest_name = MACH_PORT_NULL;
- }
-
- if (IO_VALID(reply)) {
- mach_msg_type_name_t reply_type = MACH_MSGH_BITS_LOCAL(mbits);
-
- kr = ipc_object_copyout_compat(space, reply, reply_type,
- &reply_name);
- if (kr != KERN_SUCCESS) {
- ipc_object_destroy(reply, reply_type);
- reply_name = MACH_PORT_NULL;
- }
- } else
- reply_name = MACH_PORT_NULL;
-
- msg.msg_unused = 0;
- msg.msg_simple = (mbits & MACH_MSGH_BITS_COMPLEX) ? FALSE : TRUE;
- msg.msg_size = (msg_size_t) kmsg->ikm_header.msgh_size;
- msg.msg_type = (integer_t) kmsg->ikm_header.msgh_seqno;
- msg.msg_local_port = (port_name_t) dest_name;
- msg.msg_remote_port = (port_name_t) reply_name;
- msg.msg_id = (integer_t) kmsg->ikm_header.msgh_id;
- * (msg_header_t *) &kmsg->ikm_header = msg;
-
- if (msg.msg_simple)
- return MACH_MSG_SUCCESS;
-
- saddr = (vm_offset_t) (&kmsg->ikm_header + 1);
- eaddr = (vm_offset_t) &kmsg->ikm_header + kmsg->ikm_header.msgh_size;
-
- while (saddr < eaddr) {
- vm_offset_t taddr = saddr;
- mach_msg_type_long_t *type;
- mach_msg_type_name_t name;
- mach_msg_type_size_t size;
- mach_msg_type_number_t number;
- boolean_t is_inline, longform, is_port;
- vm_size_t length;
- vm_offset_t addr;
-
- type = (mach_msg_type_long_t *) saddr;
- is_inline = ((mach_msg_type_t*)type)->msgt_inline;
- longform = ((mach_msg_type_t*)type)->msgt_longform;
- if (longform) {
- /* This must be aligned */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
- (is_misaligned(type))) {
- saddr = ptr_align(saddr);
- continue;
- }
- name = type->msgtl_name;
- size = type->msgtl_size;
- number = type->msgtl_number;
- saddr += sizeof(mach_msg_type_long_t);
- } else {
- name = ((mach_msg_type_t*)type)->msgt_name;
- size = ((mach_msg_type_t*)type)->msgt_size;
- number = ((mach_msg_type_t*)type)->msgt_number;
- saddr += sizeof(mach_msg_type_t);
- }
-
- /* padding (ptrs and ports) ? */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
- ((size >> 3) == sizeof(natural_t)))
- saddr = ptr_align(saddr);
-
- /* calculate length of data in bytes, rounding up */
-
- length = ((number * size) + 7) >> 3;
-
- is_port = MACH_MSG_TYPE_PORT_ANY(name);
-
- if (is_port) {
- mach_port_t *objects;
- mach_msg_type_number_t i;
- mach_msg_type_name_t newname;
-
- if (!is_inline && (length != 0)) {
- /* first allocate memory in the map */
-
- kr = vm_allocate(map, &addr, length, TRUE);
- if (kr != KERN_SUCCESS) {
- ipc_kmsg_clean_body(taddr, saddr);
- goto vm_copyout_failure;
- }
- }
-
- newname = ipc_object_copyout_type_compat(name);
- if (longform)
- type->msgtl_name = newname;
- else
- ((mach_msg_type_t*)type)->msgt_name = newname;
-
- objects = (mach_port_t *)
- (is_inline ? saddr : * (vm_offset_t *) saddr);
-
- /* copyout port rights carried in the message */
-
- for (i = 0; i < number; i++) {
- ipc_object_t object =
- (ipc_object_t) objects[i];
-
- if (!IO_VALID(object)) {
- objects[i] = MACH_PORT_NULL;
- continue;
- }
-
- kr = ipc_object_copyout_compat(space, object,
- name, &objects[i]);
- if (kr != KERN_SUCCESS) {
- ipc_object_destroy(object, name);
- objects[i] = MACH_PORT_NULL;
- }
- }
- }
-
- if (is_inline) {
- /* inline data sizes round up to int boundaries */
-
- saddr += (length + 3) &~ 3;
- } else {
- vm_offset_t data = * (vm_offset_t *) saddr;
-
- /* copyout memory carried in the message */
-
- if (length == 0) {
- assert(data == 0);
- addr = 0;
- } else if (is_port) {
- /* copyout to memory allocated above */
-
- (void) copyoutmap(map, (char *) data,
- (char *) addr, length);
- kfree(data, length);
- } else {
- vm_map_copy_t copy = (vm_map_copy_t) data;
-
- kr = vm_map_copyout(map, &addr, copy);
- if (kr != KERN_SUCCESS) {
- vm_map_copy_discard(copy);
-
- vm_copyout_failure:
-
- addr = 0;
- }
- }
-
- * (vm_offset_t *) saddr = addr;
- saddr += sizeof(vm_offset_t);
- }
- }
-
- return MACH_MSG_SUCCESS;
-}
-
-#endif /* MACH_IPC_COMPAT */
-
#if MACH_KDB
char *