17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50209230bSgjelinek * Common Development and Distribution License (the "License"). 60209230bSgjelinek * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*438076ebSGangadhar Mylapuram * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #include <sys/types.h> 277c478bd9Sstevel@tonic-gate #include <sys/param.h> 287c478bd9Sstevel@tonic-gate #include <sys/var.h> 297c478bd9Sstevel@tonic-gate #include <sys/thread.h> 307c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 317c478bd9Sstevel@tonic-gate #include <sys/kstat.h> 327c478bd9Sstevel@tonic-gate #include <sys/uadmin.h> 337c478bd9Sstevel@tonic-gate #include <sys/systm.h> 347c478bd9Sstevel@tonic-gate #include <sys/errno.h> 357c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 367c478bd9Sstevel@tonic-gate #include <sys/procset.h> 377c478bd9Sstevel@tonic-gate #include <sys/processor.h> 387c478bd9Sstevel@tonic-gate #include <sys/debug.h> 397c478bd9Sstevel@tonic-gate #include <sys/task.h> 407c478bd9Sstevel@tonic-gate #include <sys/project.h> 417c478bd9Sstevel@tonic-gate #include <sys/zone.h> 427c478bd9Sstevel@tonic-gate #include <sys/contract_impl.h> 437c478bd9Sstevel@tonic-gate #include <sys/contract/process_impl.h> 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * Bind all the threads of a process to a CPU. 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate static int 497c478bd9Sstevel@tonic-gate cpu_bind_process(proc_t *pp, processorid_t bind, processorid_t *obind, 507c478bd9Sstevel@tonic-gate int *error) 517c478bd9Sstevel@tonic-gate { 527c478bd9Sstevel@tonic-gate kthread_t *tp; 537c478bd9Sstevel@tonic-gate kthread_t *fp; 547c478bd9Sstevel@tonic-gate int err = 0; 557c478bd9Sstevel@tonic-gate int i; 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&pidlock)); 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate /* skip kernel processes */ 607c478bd9Sstevel@tonic-gate if (pp->p_flag & SSYS) { 617c478bd9Sstevel@tonic-gate *obind = PBIND_NONE; 62*438076ebSGangadhar Mylapuram *error = ENOTSUP; 637c478bd9Sstevel@tonic-gate return (0); 647c478bd9Sstevel@tonic-gate } 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate mutex_enter(&pp->p_lock); 677c478bd9Sstevel@tonic-gate tp = pp->p_tlist; 687c478bd9Sstevel@tonic-gate if (tp != NULL) { 697c478bd9Sstevel@tonic-gate fp = tp; 707c478bd9Sstevel@tonic-gate do { 717c478bd9Sstevel@tonic-gate i = cpu_bind_thread(tp, bind, obind, error); 727c478bd9Sstevel@tonic-gate if (err == 0) 737c478bd9Sstevel@tonic-gate err = i; 747c478bd9Sstevel@tonic-gate } while ((tp = tp->t_forw) != fp); 757c478bd9Sstevel@tonic-gate } 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate mutex_exit(&pp->p_lock); 787c478bd9Sstevel@tonic-gate return (err); 797c478bd9Sstevel@tonic-gate } 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate /* 827c478bd9Sstevel@tonic-gate * Bind all the processes of a task to a CPU. 837c478bd9Sstevel@tonic-gate */ 847c478bd9Sstevel@tonic-gate static int 857c478bd9Sstevel@tonic-gate cpu_bind_task(task_t *tk, processorid_t bind, processorid_t *obind, 867c478bd9Sstevel@tonic-gate int *error) 877c478bd9Sstevel@tonic-gate { 887c478bd9Sstevel@tonic-gate proc_t *p; 897c478bd9Sstevel@tonic-gate int err = 0; 907c478bd9Sstevel@tonic-gate int i; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&pidlock)); 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate if ((p = tk->tk_memb_list) == NULL) 957c478bd9Sstevel@tonic-gate return (ESRCH); 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate do { 98*438076ebSGangadhar Mylapuram if (!(p->p_flag & SSYS)) { 997c478bd9Sstevel@tonic-gate i = cpu_bind_process(p, bind, obind, error); 1007c478bd9Sstevel@tonic-gate if (err == 0) 1017c478bd9Sstevel@tonic-gate err = i; 102*438076ebSGangadhar Mylapuram } 1037c478bd9Sstevel@tonic-gate } while ((p = p->p_tasknext) != tk->tk_memb_list); 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate return (err); 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* 1097c478bd9Sstevel@tonic-gate * Bind all the processes in a project to a CPU. 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate static int 1127c478bd9Sstevel@tonic-gate cpu_bind_project(kproject_t *kpj, processorid_t bind, processorid_t *obind, 1137c478bd9Sstevel@tonic-gate int *error) 1147c478bd9Sstevel@tonic-gate { 1157c478bd9Sstevel@tonic-gate proc_t *p; 1167c478bd9Sstevel@tonic-gate int err = 0; 1177c478bd9Sstevel@tonic-gate int i; 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&pidlock)); 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate for (p = practive; p != NULL; p = p->p_next) { 1227c478bd9Sstevel@tonic-gate if (p->p_tlist == NULL) 1237c478bd9Sstevel@tonic-gate continue; 124*438076ebSGangadhar Mylapuram if (p->p_task->tk_proj == kpj && !(p->p_flag & SSYS)) { 1257c478bd9Sstevel@tonic-gate i = cpu_bind_process(p, bind, obind, error); 1267c478bd9Sstevel@tonic-gate if (err == 0) 1277c478bd9Sstevel@tonic-gate err = i; 1287c478bd9Sstevel@tonic-gate } 1297c478bd9Sstevel@tonic-gate } 1307c478bd9Sstevel@tonic-gate return (err); 1317c478bd9Sstevel@tonic-gate } 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate /* 1347c478bd9Sstevel@tonic-gate * Bind all the processes in a zone to a CPU. 1357c478bd9Sstevel@tonic-gate */ 1367c478bd9Sstevel@tonic-gate int 1377c478bd9Sstevel@tonic-gate cpu_bind_zone(zone_t *zptr, processorid_t bind, processorid_t *obind, 1387c478bd9Sstevel@tonic-gate int *error) 1397c478bd9Sstevel@tonic-gate { 1407c478bd9Sstevel@tonic-gate proc_t *p; 1417c478bd9Sstevel@tonic-gate int err = 0; 1427c478bd9Sstevel@tonic-gate int i; 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&pidlock)); 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate for (p = practive; p != NULL; p = p->p_next) { 1477c478bd9Sstevel@tonic-gate if (p->p_tlist == NULL) 1487c478bd9Sstevel@tonic-gate continue; 149*438076ebSGangadhar Mylapuram if (p->p_zone == zptr && !(p->p_flag & SSYS)) { 1507c478bd9Sstevel@tonic-gate i = cpu_bind_process(p, bind, obind, error); 1517c478bd9Sstevel@tonic-gate if (err == 0) 1527c478bd9Sstevel@tonic-gate err = i; 1537c478bd9Sstevel@tonic-gate } 1547c478bd9Sstevel@tonic-gate } 1557c478bd9Sstevel@tonic-gate return (err); 1567c478bd9Sstevel@tonic-gate } 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate /* 1597c478bd9Sstevel@tonic-gate * Bind all the processes in a process contract to a CPU. 1607c478bd9Sstevel@tonic-gate */ 1617c478bd9Sstevel@tonic-gate int 1627c478bd9Sstevel@tonic-gate cpu_bind_contract(cont_process_t *ctp, processorid_t bind, processorid_t *obind, 1637c478bd9Sstevel@tonic-gate int *error) 1647c478bd9Sstevel@tonic-gate { 1657c478bd9Sstevel@tonic-gate proc_t *p; 1667c478bd9Sstevel@tonic-gate int err = 0; 1677c478bd9Sstevel@tonic-gate int i; 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&pidlock)); 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate for (p = practive; p != NULL; p = p->p_next) { 1727c478bd9Sstevel@tonic-gate if (p->p_tlist == NULL) 1737c478bd9Sstevel@tonic-gate continue; 1747c478bd9Sstevel@tonic-gate if (p->p_ct_process == ctp) { 1757c478bd9Sstevel@tonic-gate i = cpu_bind_process(p, bind, obind, error); 1767c478bd9Sstevel@tonic-gate if (err == 0) 1777c478bd9Sstevel@tonic-gate err = i; 1787c478bd9Sstevel@tonic-gate } 1797c478bd9Sstevel@tonic-gate } 1807c478bd9Sstevel@tonic-gate return (err); 1817c478bd9Sstevel@tonic-gate } 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate /* 1847c478bd9Sstevel@tonic-gate * processor_bind(2) - Processor binding interfaces. 1857c478bd9Sstevel@tonic-gate */ 1867c478bd9Sstevel@tonic-gate int 1877c478bd9Sstevel@tonic-gate processor_bind(idtype_t idtype, id_t id, processorid_t bind, 1887c478bd9Sstevel@tonic-gate processorid_t *obindp) 1897c478bd9Sstevel@tonic-gate { 1907c478bd9Sstevel@tonic-gate processorid_t obind = PBIND_NONE; 1917c478bd9Sstevel@tonic-gate int ret = 0; 1927c478bd9Sstevel@tonic-gate int err = 0; 1937c478bd9Sstevel@tonic-gate cpu_t *cp; 1947c478bd9Sstevel@tonic-gate kthread_id_t tp; 1957c478bd9Sstevel@tonic-gate proc_t *pp; 1967c478bd9Sstevel@tonic-gate task_t *tk; 1977c478bd9Sstevel@tonic-gate kproject_t *kpj; 1987c478bd9Sstevel@tonic-gate zone_t *zptr; 1997c478bd9Sstevel@tonic-gate contract_t *ct; 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate /* 2027c478bd9Sstevel@tonic-gate * Since we might be making a binding to a processor, hold the 2037c478bd9Sstevel@tonic-gate * cpu_lock so that the processor cannot be taken offline while 2047c478bd9Sstevel@tonic-gate * we do this. 2057c478bd9Sstevel@tonic-gate */ 2067c478bd9Sstevel@tonic-gate mutex_enter(&cpu_lock); 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate /* 2097c478bd9Sstevel@tonic-gate * Check to be sure binding processor ID is valid. 2107c478bd9Sstevel@tonic-gate */ 2117c478bd9Sstevel@tonic-gate switch (bind) { 2127c478bd9Sstevel@tonic-gate default: 2137c478bd9Sstevel@tonic-gate if ((cp = cpu_get(bind)) == NULL || 2147c478bd9Sstevel@tonic-gate (cp->cpu_flags & (CPU_QUIESCED | CPU_OFFLINE))) 2157c478bd9Sstevel@tonic-gate ret = EINVAL; 2167c478bd9Sstevel@tonic-gate else if ((cp->cpu_flags & CPU_READY) == 0) 2177c478bd9Sstevel@tonic-gate ret = EIO; 2187c478bd9Sstevel@tonic-gate break; 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate case PBIND_NONE: 2217c478bd9Sstevel@tonic-gate case PBIND_QUERY: 2220b70c467Sakolb case PBIND_HARD: 2230b70c467Sakolb case PBIND_SOFT: 2240b70c467Sakolb case PBIND_QUERY_TYPE: 2257c478bd9Sstevel@tonic-gate break; 2267c478bd9Sstevel@tonic-gate } 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate if (ret) { 2297c478bd9Sstevel@tonic-gate mutex_exit(&cpu_lock); 2307c478bd9Sstevel@tonic-gate return (set_errno(ret)); 2317c478bd9Sstevel@tonic-gate } 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate switch (idtype) { 2347c478bd9Sstevel@tonic-gate case P_LWPID: 2357c478bd9Sstevel@tonic-gate pp = curproc; 2367c478bd9Sstevel@tonic-gate mutex_enter(&pp->p_lock); 2377c478bd9Sstevel@tonic-gate if (id == P_MYID) { 2387c478bd9Sstevel@tonic-gate ret = cpu_bind_thread(curthread, bind, &obind, &err); 2397c478bd9Sstevel@tonic-gate } else { 2407c478bd9Sstevel@tonic-gate int found = 0; 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate tp = pp->p_tlist; 2437c478bd9Sstevel@tonic-gate do { 2447c478bd9Sstevel@tonic-gate if (tp->t_tid == id) { 2457c478bd9Sstevel@tonic-gate ret = cpu_bind_thread(tp, 2467c478bd9Sstevel@tonic-gate bind, &obind, &err); 2477c478bd9Sstevel@tonic-gate found = 1; 2487c478bd9Sstevel@tonic-gate break; 2497c478bd9Sstevel@tonic-gate } 2507c478bd9Sstevel@tonic-gate } while ((tp = tp->t_forw) != pp->p_tlist); 2517c478bd9Sstevel@tonic-gate if (!found) 2527c478bd9Sstevel@tonic-gate ret = ESRCH; 2537c478bd9Sstevel@tonic-gate } 2547c478bd9Sstevel@tonic-gate mutex_exit(&pp->p_lock); 2557c478bd9Sstevel@tonic-gate break; 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate case P_PID: 2587c478bd9Sstevel@tonic-gate /* 2597c478bd9Sstevel@tonic-gate * Note. Cannot use dotoprocs here because it doesn't find 2607c478bd9Sstevel@tonic-gate * system class processes, which are legal to query. 2617c478bd9Sstevel@tonic-gate */ 2627c478bd9Sstevel@tonic-gate mutex_enter(&pidlock); 2637c478bd9Sstevel@tonic-gate if (id == P_MYID) { 2647c478bd9Sstevel@tonic-gate ret = cpu_bind_process(curproc, bind, &obind, &err); 2657c478bd9Sstevel@tonic-gate } else if ((pp = prfind(id)) != NULL) { 2667c478bd9Sstevel@tonic-gate ret = cpu_bind_process(pp, bind, &obind, &err); 2677c478bd9Sstevel@tonic-gate } else { 2687c478bd9Sstevel@tonic-gate ret = ESRCH; 2697c478bd9Sstevel@tonic-gate } 2707c478bd9Sstevel@tonic-gate mutex_exit(&pidlock); 2717c478bd9Sstevel@tonic-gate break; 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate case P_TASKID: 2747c478bd9Sstevel@tonic-gate mutex_enter(&pidlock); 2757c478bd9Sstevel@tonic-gate if (id == P_MYID) { 2767c478bd9Sstevel@tonic-gate proc_t *p = curproc; 2777c478bd9Sstevel@tonic-gate id = p->p_task->tk_tkid; 2787c478bd9Sstevel@tonic-gate } 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate if ((tk = task_hold_by_id(id)) != NULL) { 2817c478bd9Sstevel@tonic-gate ret = cpu_bind_task(tk, bind, &obind, &err); 2827c478bd9Sstevel@tonic-gate mutex_exit(&pidlock); 2837c478bd9Sstevel@tonic-gate task_rele(tk); 2847c478bd9Sstevel@tonic-gate } else { 2857c478bd9Sstevel@tonic-gate mutex_exit(&pidlock); 2867c478bd9Sstevel@tonic-gate ret = ESRCH; 2877c478bd9Sstevel@tonic-gate } 2887c478bd9Sstevel@tonic-gate break; 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate case P_PROJID: 2910209230bSgjelinek pp = curproc; 2927c478bd9Sstevel@tonic-gate if (id == P_MYID) 2937c478bd9Sstevel@tonic-gate id = curprojid(); 2940209230bSgjelinek if ((kpj = project_hold_by_id(id, pp->p_zone, 2957c478bd9Sstevel@tonic-gate PROJECT_HOLD_FIND)) == NULL) { 2967c478bd9Sstevel@tonic-gate ret = ESRCH; 2977c478bd9Sstevel@tonic-gate } else { 2987c478bd9Sstevel@tonic-gate mutex_enter(&pidlock); 2997c478bd9Sstevel@tonic-gate ret = cpu_bind_project(kpj, bind, &obind, &err); 3007c478bd9Sstevel@tonic-gate mutex_exit(&pidlock); 3017c478bd9Sstevel@tonic-gate project_rele(kpj); 3027c478bd9Sstevel@tonic-gate } 3037c478bd9Sstevel@tonic-gate break; 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate case P_ZONEID: 3067c478bd9Sstevel@tonic-gate if (id == P_MYID) 3077c478bd9Sstevel@tonic-gate id = getzoneid(); 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate if ((zptr = zone_find_by_id(id)) == NULL) { 3107c478bd9Sstevel@tonic-gate ret = ESRCH; 3117c478bd9Sstevel@tonic-gate } else { 3127c478bd9Sstevel@tonic-gate mutex_enter(&pidlock); 3137c478bd9Sstevel@tonic-gate ret = cpu_bind_zone(zptr, bind, &obind, &err); 3147c478bd9Sstevel@tonic-gate mutex_exit(&pidlock); 3157c478bd9Sstevel@tonic-gate zone_rele(zptr); 3167c478bd9Sstevel@tonic-gate } 3177c478bd9Sstevel@tonic-gate break; 3187c478bd9Sstevel@tonic-gate 3197c478bd9Sstevel@tonic-gate case P_CTID: 3207c478bd9Sstevel@tonic-gate if (id == P_MYID) 3217c478bd9Sstevel@tonic-gate id = PRCTID(curproc); 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate if ((ct = contract_type_ptr(process_type, id, 3247c478bd9Sstevel@tonic-gate curproc->p_zone->zone_uniqid)) == NULL) { 3257c478bd9Sstevel@tonic-gate ret = ESRCH; 3267c478bd9Sstevel@tonic-gate } else { 3277c478bd9Sstevel@tonic-gate mutex_enter(&pidlock); 3287c478bd9Sstevel@tonic-gate ret = cpu_bind_contract(ct->ct_data, 3297c478bd9Sstevel@tonic-gate bind, &obind, &err); 3307c478bd9Sstevel@tonic-gate mutex_exit(&pidlock); 3317c478bd9Sstevel@tonic-gate contract_rele(ct); 3327c478bd9Sstevel@tonic-gate } 3337c478bd9Sstevel@tonic-gate break; 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate case P_CPUID: 3367c478bd9Sstevel@tonic-gate if (id == P_MYID || bind != PBIND_NONE || cpu_get(id) == NULL) 3377c478bd9Sstevel@tonic-gate ret = EINVAL; 3387c478bd9Sstevel@tonic-gate else 3390b70c467Sakolb ret = cpu_unbind(id, B_TRUE); 3407c478bd9Sstevel@tonic-gate break; 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate case P_ALL: 3437c478bd9Sstevel@tonic-gate if (id == P_MYID || bind != PBIND_NONE) { 3447c478bd9Sstevel@tonic-gate ret = EINVAL; 3457c478bd9Sstevel@tonic-gate } else { 3467c478bd9Sstevel@tonic-gate int i; 3477c478bd9Sstevel@tonic-gate cpu_t *cp = cpu_list; 3487c478bd9Sstevel@tonic-gate do { 3497c478bd9Sstevel@tonic-gate if ((cp->cpu_flags & CPU_EXISTS) == 0) 3507c478bd9Sstevel@tonic-gate continue; 3510b70c467Sakolb i = cpu_unbind(cp->cpu_id, B_TRUE); 3527c478bd9Sstevel@tonic-gate if (ret == 0) 3537c478bd9Sstevel@tonic-gate ret = i; 3547c478bd9Sstevel@tonic-gate } while ((cp = cp->cpu_next) != cpu_list); 3557c478bd9Sstevel@tonic-gate } 3567c478bd9Sstevel@tonic-gate break; 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate default: 3597c478bd9Sstevel@tonic-gate /* 3607c478bd9Sstevel@tonic-gate * Spec says this is invalid, even though we could 3617c478bd9Sstevel@tonic-gate * handle other idtypes. 3627c478bd9Sstevel@tonic-gate */ 3637c478bd9Sstevel@tonic-gate ret = EINVAL; 3647c478bd9Sstevel@tonic-gate break; 3657c478bd9Sstevel@tonic-gate } 3667c478bd9Sstevel@tonic-gate mutex_exit(&cpu_lock); 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate /* 3697c478bd9Sstevel@tonic-gate * If no search error occurred, see if any permissions errors did. 3707c478bd9Sstevel@tonic-gate */ 3717c478bd9Sstevel@tonic-gate if (ret == 0) 3727c478bd9Sstevel@tonic-gate ret = err; 3737c478bd9Sstevel@tonic-gate 3747c478bd9Sstevel@tonic-gate if (ret == 0 && obindp != NULL) 3757c478bd9Sstevel@tonic-gate if (copyout((caddr_t)&obind, (caddr_t)obindp, 3767c478bd9Sstevel@tonic-gate sizeof (obind)) == -1) 3777c478bd9Sstevel@tonic-gate ret = EFAULT; 3787c478bd9Sstevel@tonic-gate return (ret ? set_errno(ret) : 0); /* return success or failure */ 3797c478bd9Sstevel@tonic-gate } 380