The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sparc64/sparc64/sys_machdep.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 2001 Jake Burkholder.
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  *
   28  * $FreeBSD$
   29  */
   30 
   31 #include "opt_capsicum.h"
   32 
   33 #include <sys/param.h>
   34 #include <sys/systm.h>
   35 #include <sys/capsicum.h>
   36 #include <sys/lock.h>
   37 #include <sys/malloc.h>
   38 #include <sys/mutex.h>
   39 #include <sys/proc.h>
   40 #include <sys/sysproto.h>
   41 
   42 #include <machine/md_var.h>
   43 #include <machine/utrap.h>
   44 #include <machine/sysarch.h>
   45 
   46 static int sparc_sigtramp_install(struct thread *td, char *args);
   47 static int sparc_utrap_install(struct thread *td, char *args);
   48 
   49 #ifndef _SYS_SYSPROTO_H_
   50 struct sysarch_args {
   51         int     op;
   52         char    *parms;
   53 };
   54 #endif
   55 
   56 int
   57 sysarch(struct thread *td, struct sysarch_args *uap)
   58 {
   59         int error;
   60 
   61 #ifdef CAPABILITY_MODE
   62         /*
   63          * When adding new operations, add a new case statement here to
   64          * explicitly indicate whether or not the operation is safe to
   65          * perform in capability mode.
   66          */
   67         if (IN_CAPABILITY_MODE(td)) {
   68                 switch (uap->op) {
   69                 case SPARC_SIGTRAMP_INSTALL:
   70                 case SPARC_UTRAP_INSTALL:
   71                         break;
   72 
   73                 default:
   74 #ifdef KTRACE
   75                         if (KTRPOINT(td, KTR_CAPFAIL))
   76                                 ktrcapfail(CAPFAIL_SYSCALL, NULL, NULL);
   77 #endif
   78                         return (ECAPMODE);
   79                 }
   80         }
   81 #endif
   82 
   83         mtx_lock(&Giant);
   84         switch (uap->op) {
   85         case SPARC_SIGTRAMP_INSTALL:
   86                 error = sparc_sigtramp_install(td, uap->parms);
   87                 break;
   88         case SPARC_UTRAP_INSTALL:
   89                 error = sparc_utrap_install(td, uap->parms);
   90                 break;
   91         default:
   92                 error = EINVAL;
   93                 break;
   94         }
   95         mtx_unlock(&Giant);
   96         return (error);
   97 }
   98 
   99 static int
  100 sparc_sigtramp_install(struct thread *td, char *args)
  101 {
  102         struct sparc_sigtramp_install_args sia;
  103         struct proc *p;
  104         int error;
  105 
  106         p = td->td_proc;
  107         if ((error = copyin(args, &sia, sizeof(sia))) != 0)
  108                 return (error);
  109         if (sia.sia_old != NULL) {
  110                 if (suword(sia.sia_old, (long)p->p_md.md_sigtramp) != 0)
  111                         return (EFAULT);
  112         }
  113         p->p_md.md_sigtramp = sia.sia_new;
  114         return (0);
  115 }
  116 
  117 static int
  118 sparc_utrap_install(struct thread *td, char *args)
  119 {
  120         struct sparc_utrap_install_args uia;
  121         struct sparc_utrap_args ua;
  122         struct md_utrap *ut;
  123         int error;
  124         int i;
  125 
  126         ut = td->td_proc->p_md.md_utrap;
  127         if ((error = copyin(args, &uia, sizeof(uia))) != 0)
  128                 return (error);
  129         if (uia.num < 0 || uia.num > UT_MAX ||
  130             (uia.handlers == NULL && uia.num > 0))
  131                 return (EINVAL);
  132         for (i = 0; i < uia.num; i++) {
  133                 if ((error = copyin(&uia.handlers[i], &ua, sizeof(ua))) != 0)
  134                         return (error);
  135                 if (ua.type != UTH_NOCHANGE &&
  136                     (ua.type < 0 || ua.type >= UT_MAX))
  137                         return (EINVAL);
  138                 if (ua.old_deferred != NULL) {
  139                         if ((error = suword(ua.old_deferred, 0)) != 0)
  140                                 return (error);
  141                 }
  142                 if (ua.old_precise != NULL) {
  143                         error = suword(ua.old_precise,
  144                             ut != NULL ? (long)ut->ut_precise[ua.type] : 0);
  145                         if (error != 0)
  146                                 return (error);
  147                 }
  148                 if (ua.type != UTH_NOCHANGE) {
  149                         if (ut == NULL) {
  150                                 ut = utrap_alloc();
  151                                 td->td_proc->p_md.md_utrap = ut;
  152                         }
  153                         ut->ut_precise[ua.type] = ua.new_precise;
  154                 }
  155         }
  156         return (0);
  157 }

Cache object: 808e70ba61e6ccf6cdfc025629e327cf


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.