~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/s390/kernel/runtime_instr.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * Copyright IBM Corp. 2012
  4  * Author(s): Jan Glauber <jang@linux.vnet.ibm.com>
  5  */
  6 
  7 #include <linux/kernel.h>
  8 #include <linux/syscalls.h>
  9 #include <linux/signal.h>
 10 #include <linux/mm.h>
 11 #include <linux/slab.h>
 12 #include <linux/init.h>
 13 #include <linux/errno.h>
 14 #include <linux/kernel_stat.h>
 15 #include <linux/sched/task_stack.h>
 16 
 17 #include <asm/runtime_instr.h>
 18 #include <asm/cpu_mf.h>
 19 #include <asm/irq.h>
 20 
 21 #include "entry.h"
 22 
 23 /* empty control block to disable RI by loading it */
 24 struct runtime_instr_cb runtime_instr_empty_cb;
 25 
 26 void runtime_instr_release(struct task_struct *tsk)
 27 {
 28         kfree(tsk->thread.ri_cb);
 29 }
 30 
 31 static void disable_runtime_instr(void)
 32 {
 33         struct task_struct *task = current;
 34         struct pt_regs *regs;
 35 
 36         if (!task->thread.ri_cb)
 37                 return;
 38         regs = task_pt_regs(task);
 39         preempt_disable();
 40         load_runtime_instr_cb(&runtime_instr_empty_cb);
 41         kfree(task->thread.ri_cb);
 42         task->thread.ri_cb = NULL;
 43         preempt_enable();
 44 
 45         /*
 46          * Make sure the RI bit is deleted from the PSW. If the user did not
 47          * switch off RI before the system call the process will get a
 48          * specification exception otherwise.
 49          */
 50         regs->psw.mask &= ~PSW_MASK_RI;
 51 }
 52 
 53 static void init_runtime_instr_cb(struct runtime_instr_cb *cb)
 54 {
 55         cb->rla = 0xfff;
 56         cb->s = 1;
 57         cb->k = 1;
 58         cb->ps = 1;
 59         cb->pc = 1;
 60         cb->key = PAGE_DEFAULT_KEY >> 4;
 61         cb->v = 1;
 62 }
 63 
 64 /*
 65  * The signum argument is unused. In older kernels it was used to
 66  * specify a real-time signal. For backwards compatibility user space
 67  * should pass a valid real-time signal number (the signum argument
 68  * was checked in older kernels).
 69  */
 70 SYSCALL_DEFINE2(s390_runtime_instr, int, command, int, signum)
 71 {
 72         struct runtime_instr_cb *cb;
 73 
 74         if (!test_facility(64))
 75                 return -EOPNOTSUPP;
 76 
 77         if (command == S390_RUNTIME_INSTR_STOP) {
 78                 disable_runtime_instr();
 79                 return 0;
 80         }
 81 
 82         if (command != S390_RUNTIME_INSTR_START)
 83                 return -EINVAL;
 84 
 85         if (!current->thread.ri_cb) {
 86                 cb = kzalloc(sizeof(*cb), GFP_KERNEL);
 87                 if (!cb)
 88                         return -ENOMEM;
 89         } else {
 90                 cb = current->thread.ri_cb;
 91                 memset(cb, 0, sizeof(*cb));
 92         }
 93 
 94         init_runtime_instr_cb(cb);
 95 
 96         /* now load the control block to make it available */
 97         preempt_disable();
 98         current->thread.ri_cb = cb;
 99         load_runtime_instr_cb(cb);
100         preempt_enable();
101         return 0;
102 }
103 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php