/*
- * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
thread_state_t tstate,
__unused unsigned int count,
mach_vm_offset_t *user_stack,
- int *customstack
+ int *customstack,
+ __unused boolean_t is64bit
)
{
if (customstack)
*/
kern_return_t
thread_userstackdefault(
- thread_t thread,
- mach_vm_offset_t *default_user_stack)
+ mach_vm_offset_t *default_user_stack,
+ boolean_t is64bit)
{
- if (thread_is_64bit(thread)) {
+ if (is64bit) {
*default_user_stack = VM_USRSTACK64;
} else {
*default_user_stack = VM_USRSTACK32;
extern long fuword(vm_offset_t);
-
-
+__attribute__((noreturn))
void
machdep_syscall(x86_saved_state_t *state)
{
default:
panic("machdep_syscall: too many args");
}
- if (current_thread()->funnel_lock)
- (void) thread_funnel_set(current_thread()->funnel_lock, FALSE);
DEBUG_KPRINT_SYSCALL_MDEP("machdep_syscall: retval=%u\n", regs->eax);
/* NOTREACHED */
}
-
+__attribute__((noreturn))
void
machdep_syscall64(x86_saved_state_t *state)
{
case 1:
regs->rax = (*entry->routine.args64_1)(regs->rdi);
break;
+ case 2:
+ regs->rax = (*entry->routine.args64_2)(regs->rdi, regs->rsi);
+ break;
default:
panic("machdep_syscall64: too many args");
}
- if (current_thread()->funnel_lock)
- (void) thread_funnel_set(current_thread()->funnel_lock, FALSE);
DEBUG_KPRINT_SYSCALL_MDEP("machdep_syscall: retval=%llu\n", regs->rax);
{
if (copyin((user_addr_t)(sp + sizeof(int)), (char *)args, trapp->mach_trap_u32_words * sizeof (int)))
return KERN_INVALID_ARGUMENT;
- trapp->mach_trap_arg_munge32(NULL, args);
+#if CONFIG_REQUIRES_U32_MUNGING
+ trapp->mach_trap_arg_munge32(args);
+#else
+#error U32 mach traps on x86_64 kernel requires munging
+#endif
return KERN_SUCCESS;
}
extern const char *mach_syscall_name_table[];
+__attribute__((noreturn))
void
mach_call_munger(x86_saved_state_t *state)
{
struct mach_call_args args = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
x86_saved_state32_t *regs;
+ struct uthread *ut = get_bsdthread_info(current_thread());
+ uthread_reset_proc_refcount(ut);
+
assert(is_saved_state32(state));
regs = saved_state32(state);
throttle_lowpri_io(1);
+#if PROC_REF_DEBUG
+ if (__improbable(uthread_get_proc_refcount(ut) != 0)) {
+ panic("system call returned with uu_proc_refcount != 0");
+ }
+#endif
+
thread_exception_return();
/* NOTREACHED */
}
__private_extern__ void mach_call_munger64(x86_saved_state_t *regs);
+__attribute__((noreturn))
void
mach_call_munger64(x86_saved_state_t *state)
{
int call_number;
int argc;
mach_call_t mach_call;
+ struct mach_call_args args = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
x86_saved_state64_t *regs;
+ struct uthread *ut = get_bsdthread_info(current_thread());
+ uthread_reset_proc_refcount(ut);
+
assert(is_saved_state64(state));
regs = saved_state64(state);
/* NOTREACHED */
}
argc = mach_trap_table[call_number].mach_trap_arg_count;
+ if (argc) {
+ int args_in_regs = MIN(6, argc);
- if (argc > 6) {
+ memcpy(&args.arg1, ®s->rdi, args_in_regs * sizeof(syscall_arg_t));
+
+ if (argc > 6) {
int copyin_count;
- copyin_count = (argc - 6) * (int)sizeof(uint64_t);
+ assert(argc <= 9);
+ copyin_count = (argc - 6) * (int)sizeof(syscall_arg_t);
- if (copyin((user_addr_t)(regs->isf.rsp + sizeof(user_addr_t)), (char *)®s->v_arg6, copyin_count)) {
+ if (copyin((user_addr_t)(regs->isf.rsp + sizeof(user_addr_t)), (char *)&args.arg7, copyin_count)) {
regs->rax = KERN_INVALID_ARGUMENT;
- thread_exception_return();
- /* NOTREACHED */
+ thread_exception_return();
+ /* NOTREACHED */
+ }
}
}
mach_kauth_cred_uthread_update();
#endif
- regs->rax = (uint64_t)mach_call((void *)(®s->rdi));
+ regs->rax = (uint64_t)mach_call((void *)&args);
DEBUG_KPRINT_SYSCALL_MACH( "mach_call_munger64: retval=0x%llx\n", regs->rax);
throttle_lowpri_io(1);
+#if PROC_REF_DEBUG
+ if (__improbable(uthread_get_proc_refcount(ut) != 0)) {
+ panic("system call returned with uu_proc_refcount != 0");
+ }
+#endif
+
thread_exception_return();
/* NOTREACHED */
}
return (KERN_SUCCESS);
}
-
-
-/* XXX this should be a struct savearea so that CHUD will work better on x86 */
void *
-find_user_regs(thread_t thread)
+get_user_regs(thread_t th)
{
- pal_register_cache_state(thread, DIRTY);
- return USER_STATE(thread);
+ pal_register_cache_state(th, DIRTY);
+ return(USER_STATE(th));
}
void *
-get_user_regs(thread_t th)
+find_user_regs(thread_t thread)
{
- pal_register_cache_state(th, DIRTY);
- return(USER_STATE(th));
+ return get_user_regs(thread);
}
#if CONFIG_DTRACE