X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/b0d623f7f2ae71ed96e60569f61f9a9a27016e80..04b8595b18b1b41ac7a206e4b3d51a635f8413d7:/osfmk/i386/machine_task.c diff --git a/osfmk/i386/machine_task.c b/osfmk/i386/machine_task.c index c05d69bef..342f123f5 100644 --- a/osfmk/i386/machine_task.c +++ b/osfmk/i386/machine_task.c @@ -58,6 +58,10 @@ #include #include +#if HYPERVISOR +#include +#endif + extern zone_t ids_zone; kern_return_t @@ -229,6 +233,38 @@ machine_task_get_state(task_t task, } } +/* + * This is called when a task is terminated, and also on exec(). + * Clear machine-dependent state that is stored on the task. + */ +void +machine_task_terminate(task_t task) +{ + if (task) { + user_ldt_t user_ldt; + void *task_debug; + +#if HYPERVISOR + if (task->hv_task_target) { + hv_callbacks.task_destroy(task->hv_task_target); + task->hv_task_target = NULL; + } +#endif + + user_ldt = task->i386_ldt; + if (user_ldt != 0) { + task->i386_ldt = 0; + user_ldt_free(user_ldt); + } + + task_debug = task->task_debug; + if (task_debug != NULL) { + task->task_debug = NULL; + zfree(ids_zone, task_debug); + } + } +} + /* * Set initial default state on a thread as stored in the MACHINE_TASK data. * Note: currently only debug state is supported.