summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i386/i386/trap.c6
-rw-r--r--i386/include/mach/i386/vm_param.h3
-rw-r--r--i386/include/mach/sa/stdarg.h2
-rw-r--r--include/mach/port.h7
-rw-r--r--ipc/ipc_kmsg.c44
-rw-r--r--ipc/mach_msg.c7
-rw-r--r--kern/ipc_kobject.c3
7 files changed, 52 insertions, 20 deletions
diff --git a/i386/i386/trap.c b/i386/i386/trap.c
index 281594d5..3cb9d5f1 100644
--- a/i386/i386/trap.c
+++ b/i386/i386/trap.c
@@ -483,6 +483,7 @@ int user_trap(struct i386_saved_state *regs)
seg[i] = inst_fetch(regs->eip+i+5, regs->cs);
if (opcode == 0x9a && seg[0] == 0x7 && seg[1] == 0) {
regs->eip += 7;
+ printf("%lx: lcall 7(%d)\n", regs->eip, -(unsigned)regs->eax);
return 1;
}
}
@@ -549,6 +550,11 @@ int user_trap(struct i386_saved_state *regs)
return 0;
}
+#if 1
+ printf("user trap %d error %d\n", type, code);
+ dump_ss(regs);
+#endif
+
#if MACH_TTD
if (debug_all_traps_with_kttd && kttd_trap(type, regs->err, regs))
return 0;
diff --git a/i386/include/mach/i386/vm_param.h b/i386/include/mach/i386/vm_param.h
index 3a209b83..c98f0e46 100644
--- a/i386/include/mach/i386/vm_param.h
+++ b/i386/include/mach/i386/vm_param.h
@@ -73,6 +73,7 @@
with that.
*/
#define VM_MIN_ADDRESS (0)
-#define VM_MAX_ADDRESS (0xc0000000UL)
+//#define VM_MAX_ADDRESS (0xc0000000UL)
+#define VM_MAX_ADDRESS (0x40000000UL)
#endif /* _MACH_I386_VM_PARAM_H_ */
diff --git a/i386/include/mach/sa/stdarg.h b/i386/include/mach/sa/stdarg.h
index 550fec4f..eea97e08 100644
--- a/i386/include/mach/sa/stdarg.h
+++ b/i386/include/mach/sa/stdarg.h
@@ -29,7 +29,7 @@
#ifndef _MACH_SA_STDARG_H_
#define _MACH_SA_STDARG_H_
-#if __GNUC__ >= 3
+#if __GNUC__ >= 3 || defined(__x86_64__)
typedef __builtin_va_list va_list;
diff --git a/include/mach/port.h b/include/mach/port.h
index e77e5c38..3a8bf91c 100644
--- a/include/mach/port.h
+++ b/include/mach/port.h
@@ -39,7 +39,14 @@
#include <mach/machine/vm_types.h>
+typedef natural_t mach_port_name_t;
+typedef mach_port_name_t *mach_port_name_array_t;
+
+#ifdef KERNEL
typedef vm_offset_t mach_port_t;
+#else
+typedef mach_port_name_t mach_port_t;
+#endif
typedef mach_port_t *mach_port_array_t;
typedef const mach_port_t *const_mach_port_array_t;
typedef int *rpc_signature_info_t;
diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c
index 28ed23c6..4a95aa61 100644
--- a/ipc/ipc_kmsg.c
+++ b/ipc/ipc_kmsg.c
@@ -231,7 +231,7 @@ ipc_kmsg_clean_body(
is_inline = ((mach_msg_type_t*)type)->msgt_inline;
if (((mach_msg_type_t*)type)->msgt_longform) {
/* This must be aligned */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
+ if ((sizeof(vm_offset_t) > sizeof(mach_msg_type_t)) &&
(is_misaligned(type))) {
saddr = ptr_align(saddr);
continue;
@@ -248,8 +248,8 @@ ipc_kmsg_clean_body(
}
/* padding (ptrs and ports) ? */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
- ((size >> 3) == sizeof(natural_t)))
+ if ((sizeof(vm_offset_t) > sizeof(mach_msg_type_t)) &&
+ ((size >> 3) == sizeof(vm_offset_t)))
saddr = ptr_align(saddr);
/* calculate length of data in bytes, rounding up */
@@ -262,6 +262,8 @@ ipc_kmsg_clean_body(
ipc_object_t *objects;
mach_msg_type_number_t i;
+ saddr = ptr_align(saddr);
+
if (is_inline) {
objects = (ipc_object_t *) saddr;
/* sanity check */
@@ -392,7 +394,7 @@ xxx: type = (mach_msg_type_long_t *) eaddr;
is_inline = ((mach_msg_type_t*)type)->msgt_inline;
if (((mach_msg_type_t*)type)->msgt_longform) {
/* This must be aligned */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
+ if ((sizeof(vm_offset_t) > sizeof(mach_msg_type_t)) &&
(is_misaligned(type))) {
eaddr = ptr_align(eaddr);
goto xxx;
@@ -409,8 +411,8 @@ xxx: type = (mach_msg_type_long_t *) eaddr;
}
/* padding (ptrs and ports) ? */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
- ((size >> 3) == sizeof(natural_t)))
+ if ((sizeof(vm_offset_t) > sizeof(mach_msg_type_t)) &&
+ ((size >> 3) == sizeof(vm_offset_t)))
eaddr = ptr_align(eaddr);
/* calculate length of data in bytes, rounding up */
@@ -423,6 +425,8 @@ xxx: type = (mach_msg_type_long_t *) eaddr;
ipc_object_t *objects;
mach_msg_type_number_t i;
+ eaddr = ptr_align(eaddr);
+
objects = (ipc_object_t *)
(is_inline ? eaddr : * (vm_offset_t *) eaddr);
@@ -1323,7 +1327,7 @@ ipc_kmsg_copyin_body(
dealloc = ((mach_msg_type_t*)type)->msgt_deallocate;
if (longform) {
/* This must be aligned */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
+ if ((sizeof(vm_offset_t) > sizeof(mach_msg_type_t)) &&
(is_misaligned(type))) {
saddr = ptr_align(saddr);
continue;
@@ -1352,8 +1356,8 @@ ipc_kmsg_copyin_body(
}
/* padding (ptrs and ports) ? */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
- ((size >> 3) == sizeof(natural_t)))
+ if ((sizeof(vm_offset_t) > sizeof(mach_msg_type_t)) &&
+ ((size >> 3) == sizeof(vm_offset_t)))
saddr = ptr_align(saddr);
/* calculate length of data in bytes, rounding up */
@@ -1590,7 +1594,7 @@ ipc_kmsg_copyin_from_kernel(ipc_kmsg_t kmsg)
/* type->msgtl_header.msgt_deallocate not used */
if (longform) {
/* This must be aligned */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
+ if ((sizeof(vm_offset_t) > sizeof(mach_msg_type_t)) &&
(is_misaligned(type))) {
saddr = ptr_align(saddr);
continue;
@@ -1607,8 +1611,8 @@ ipc_kmsg_copyin_from_kernel(ipc_kmsg_t kmsg)
}
/* padding (ptrs and ports) ? */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
- ((size >> 3) == sizeof(natural_t)))
+ if ((sizeof(vm_offset_t) > sizeof(mach_msg_type_t)) &&
+ ((size >> 3) == sizeof(vm_offset_t)))
saddr = ptr_align(saddr);
/* calculate length of data in bytes, rounding up */
@@ -1638,6 +1642,8 @@ ipc_kmsg_copyin_from_kernel(ipc_kmsg_t kmsg)
ipc_object_t *objects = (ipc_object_t *) data;
mach_msg_type_number_t i;
+ saddr = ptr_align(saddr);
+
if (longform)
type->msgtl_name = newname;
else
@@ -2359,7 +2365,7 @@ ipc_kmsg_copyout_body(
longform = ((mach_msg_type_t*)type)->msgt_longform;
if (longform) {
/* This must be aligned */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
+ if ((sizeof(vm_offset_t) > sizeof(mach_msg_type_t)) &&
(is_misaligned(type))) {
saddr = ptr_align(saddr);
continue;
@@ -2376,8 +2382,8 @@ ipc_kmsg_copyout_body(
}
/* padding (ptrs and ports) ? */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
- ((size >> 3) == sizeof(natural_t)))
+ if ((sizeof(vm_offset_t) > sizeof(mach_msg_type_t)) &&
+ ((size >> 3) == sizeof(vm_offset_t)))
saddr = ptr_align(saddr);
/* calculate length of data in bytes, rounding up */
@@ -2390,6 +2396,8 @@ ipc_kmsg_copyout_body(
mach_port_t *objects;
mach_msg_type_number_t i;
+ saddr = ptr_align(saddr);
+
if (!is_inline && (length != 0)) {
/* first allocate memory in the map */
@@ -2802,7 +2810,7 @@ ipc_msg_print(mach_msg_header_t *msgh)
dealloc = ((mach_msg_type_t*)type)->msgt_deallocate;
if (longform) {
/* This must be aligned */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
+ if ((sizeof(vm_offset_t) > sizeof(mach_msg_type_t)) &&
(is_misaligned(type))) {
saddr = ptr_align(saddr);
continue;
@@ -2847,8 +2855,8 @@ ipc_msg_print(mach_msg_header_t *msgh)
}
/* padding (ptrs and ports) ? */
- if ((sizeof(natural_t) > sizeof(mach_msg_type_t)) &&
- ((size >> 3) == sizeof(natural_t)))
+ if ((sizeof(vm_offset_t) > sizeof(mach_msg_type_t)) &&
+ ((size >> 3) == sizeof(vm_offset_t)))
saddr = ptr_align(saddr);
/* calculate length of data in bytes, rounding up */
diff --git a/ipc/mach_msg.c b/ipc/mach_msg.c
index fe0c43e3..fe7d9ac8 100644
--- a/ipc/mach_msg.c
+++ b/ipc/mach_msg.c
@@ -389,6 +389,13 @@ mach_msg_trap(
mach_port_t notify)
{
mach_msg_return_t mr;
+ send_size += 2*(sizeof(mach_port_t) - sizeof(natural_t));
+ rcv_size += 2*(sizeof(mach_port_t) - sizeof(natural_t));
+ printf("mach_msg_trap(%p,%x,%x,%x,%lx,%x,%lx)\n", msg, option, send_size, rcv_size, rcv_name, time_out, notify);
+ mach_msg_header_t khdr;
+ if (copyinmsg(msg, &khdr, sizeof(khdr)))
+ panic("oops");
+ printf("ID %d, %d %d %x\n", khdr.msgh_id, khdr.msgh_size, khdr.msgh_seqno, khdr.msgh_bits);
/* first check for common cases */
diff --git a/kern/ipc_kobject.c b/kern/ipc_kobject.c
index 709ec9ec..15cb6b77 100644
--- a/kern/ipc_kobject.c
+++ b/kern/ipc_kobject.c
@@ -174,7 +174,10 @@ ipc_kobject_server(request)
|| (routine = MACHINE_SERVER_ROUTINE(&request->ikm_header)) != 0
#endif /* MACH_MACHINE_ROUTINES */
) {
+ request->ikm_header.msgh_size -= 2*(sizeof(mach_port_t) - sizeof(natural_t));
+ reply->ikm_header.msgh_size -= 2*(sizeof(mach_port_t) - sizeof(natural_t));
(*routine)(&request->ikm_header, &reply->ikm_header);
+ reply->ikm_header.msgh_size += 2*(sizeof(mach_port_t) - sizeof(natural_t));
kernel_task->messages_received++;
} else {
if (!ipc_kobject_notify(&request->ikm_header,