+
+void
+thread_set_wq_state64(thread_t thread, thread_state_t tstate)
+{
+ struct ppc_thread_state64 *ts;
+ struct savearea *genuser;
+ thread_t curth = current_thread();
+
+ genuser = get_user_regs(thread); /* Find or allocate and initialize one */
+ ts = (struct ppc_thread_state64 *)tstate;
+
+ if (curth != thread)
+ thread_lock(thread);
+
+ genuser->save_r1 = ts->r1;
+ genuser->save_r3 = ts->r3;
+ genuser->save_r4 = ts->r4;
+ genuser->save_r5 = ts->r5;
+ genuser->save_r6 = ts->r6;
+ genuser->save_r7 = ts->r7;
+ genuser->save_r8 = ts->r8;
+ genuser->save_srr0 = ts->srr0;
+
+ genuser->save_srr1 = (uint64_t)MSR_EXPORT_MASK_SET;
+
+ if (task_has_64BitAddr(thread->task))
+ genuser->save_srr1 |= (uint64_t)MASK32(MSR_SF) << 32; /* If 64-bit task, force 64-bit mode */
+
+ if (curth != thread)
+ thread_unlock(thread);
+}
+
+
+/*
+ * This is where registers that are not normally specified by the mach-o
+ * file on an execve should be nullified, perhaps to avoid a covert channel.
+ * We've never bothered to clear FPRs or VRs, but it is important to clear
+ * the FPSCR, which is kept in the general state but not set by the general
+ * flavor (ie, PPC_THREAD_STATE or PPC_THREAD_STATE64.)
+ */
+kern_return_t
+machine_thread_state_initialize(
+ thread_t thread)
+{
+ struct savearea *sv;
+
+ sv = get_user_regs(thread); /* Find or allocate and initialize one */
+
+ sv->save_fpscr = 0; /* Clear all floating point exceptions */
+ sv->save_vrsave = 0; /* Set the vector save state */
+ sv->save_vscr[0] = 0x00000000;
+ sv->save_vscr[1] = 0x00000000;
+ sv->save_vscr[2] = 0x00000000;
+ sv->save_vscr[3] = 0x00010000; /* Disable java mode and clear saturated */
+
+ return KERN_SUCCESS;
+}
+
+