+static int
+handle_no_smt(int scope, int action, proc_t target_proc, uint64_t target_threadid)
+{
+ extern void task_set_no_smt(task_t);
+
+ if (action != PROC_POLICY_ACTION_APPLY) {
+ return EINVAL;
+ }
+
+ if (scope == PROC_POLICY_SCOPE_PROCESS) {
+ if (target_proc != current_proc()) {
+ return EINVAL;
+ }
+ task_set_no_smt(TASK_NULL);
+ } else if (scope == PROC_POLICY_SCOPE_THREAD) {
+ if (target_threadid != thread_tid(current_thread())) {
+ return EINVAL;
+ }
+ thread_set_no_smt(true);
+ } else {
+ return EINVAL;
+ }
+
+ return 0;
+}
+
+static int
+handle_tecs(int scope, int action, proc_t target_proc, uint64_t target_threadid)
+{
+ if (action != PROC_POLICY_ACTION_APPLY) {
+ return EINVAL;
+ }
+
+ if (scope == PROC_POLICY_SCOPE_PROCESS) {
+ if (target_proc != current_proc()) {
+ return EINVAL;
+ }
+ task_set_tecs(TASK_NULL);
+ } else if (scope == PROC_POLICY_SCOPE_THREAD) {
+ if (target_threadid != thread_tid(current_thread())) {
+ return EINVAL;
+ }
+ if (machine_csv(CPUVN_CI)) {
+ machine_tecs(current_thread());
+ }
+ } else {
+ return EINVAL;
+ }
+
+ return 0;
+}