Merge tag 'iio-for-4.17a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23...
[linux-2.6-microblaze.git] / arch / s390 / kernel / runtime_instr.c
index 32aefb2..125c7f6 100644 (file)
 #include <asm/cpu_mf.h>
 #include <asm/irq.h>
 
+#include "entry.h"
+
 /* empty control block to disable RI by loading it */
 struct runtime_instr_cb runtime_instr_empty_cb;
 
+void runtime_instr_release(struct task_struct *tsk)
+{
+       kfree(tsk->thread.ri_cb);
+}
+
 static void disable_runtime_instr(void)
 {
-       struct pt_regs *regs = task_pt_regs(current);
+       struct task_struct *task = current;
+       struct pt_regs *regs;
 
+       if (!task->thread.ri_cb)
+               return;
+       regs = task_pt_regs(task);
+       preempt_disable();
        load_runtime_instr_cb(&runtime_instr_empty_cb);
+       kfree(task->thread.ri_cb);
+       task->thread.ri_cb = NULL;
+       preempt_enable();
 
        /*
         * Make sure the RI bit is deleted from the PSW. If the user did not
@@ -37,27 +52,22 @@ static void disable_runtime_instr(void)
 
 static void init_runtime_instr_cb(struct runtime_instr_cb *cb)
 {
-       cb->buf_limit = 0xfff;
-       cb->pstate = 1;
-       cb->pstate_set_buf = 1;
-       cb->pstate_sample = 1;
-       cb->pstate_collect = 1;
+       cb->rla = 0xfff;
+       cb->s = 1;
+       cb->k = 1;
+       cb->ps = 1;
+       cb->pc = 1;
        cb->key = PAGE_DEFAULT_KEY;
-       cb->valid = 1;
+       cb->v = 1;
 }
 
-void exit_thread_runtime_instr(void)
-{
-       struct task_struct *task = current;
-
-       if (!task->thread.ri_cb)
-               return;
-       disable_runtime_instr();
-       kfree(task->thread.ri_cb);
-       task->thread.ri_cb = NULL;
-}
-
-SYSCALL_DEFINE1(s390_runtime_instr, int, command)
+/*
+ * The signum argument is unused. In older kernels it was used to
+ * specify a real-time signal. For backwards compatibility user space
+ * should pass a valid real-time signal number (the signum argument
+ * was checked in older kernels).
+ */
+SYSCALL_DEFINE2(s390_runtime_instr, int, command, int, signum)
 {
        struct runtime_instr_cb *cb;
 
@@ -65,9 +75,7 @@ SYSCALL_DEFINE1(s390_runtime_instr, int, command)
                return -EOPNOTSUPP;
 
        if (command == S390_RUNTIME_INSTR_STOP) {
-               preempt_disable();
-               exit_thread_runtime_instr();
-               preempt_enable();
+               disable_runtime_instr();
                return 0;
        }