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  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

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

Cache object: 8fdbc7cca290e84c3b59430f53821600


[ 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.