|
@@ -30,6 +30,9 @@
|
|
#include <linux/uaccess.h>
|
|
#include <linux/uaccess.h>
|
|
#include <asm/unistd.h>
|
|
#include <asm/unistd.h>
|
|
#include <asm/switch_to.h>
|
|
#include <asm/switch_to.h>
|
|
|
|
+#include <asm/runtime_instr.h>
|
|
|
|
+#include <asm/facility.h>
|
|
|
|
+
|
|
#include "entry.h"
|
|
#include "entry.h"
|
|
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
#ifdef CONFIG_COMPAT
|
|
@@ -1239,6 +1242,96 @@ static int s390_gs_bc_set(struct task_struct *target,
|
|
data, 0, sizeof(struct gs_cb));
|
|
data, 0, sizeof(struct gs_cb));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static bool is_ri_cb_valid(struct runtime_instr_cb *cb)
|
|
|
|
+{
|
|
|
|
+ return (cb->rca & 0x1f) == 0 &&
|
|
|
|
+ (cb->roa & 0xfff) == 0 &&
|
|
|
|
+ (cb->rla & 0xfff) == 0xfff &&
|
|
|
|
+ cb->s == 1 &&
|
|
|
|
+ cb->k == 1 &&
|
|
|
|
+ cb->h == 0 &&
|
|
|
|
+ cb->reserved1 == 0 &&
|
|
|
|
+ cb->ps == 1 &&
|
|
|
|
+ cb->qs == 0 &&
|
|
|
|
+ cb->pc == 1 &&
|
|
|
|
+ cb->qc == 0 &&
|
|
|
|
+ cb->reserved2 == 0 &&
|
|
|
|
+ cb->key == PAGE_DEFAULT_KEY &&
|
|
|
|
+ cb->reserved3 == 0 &&
|
|
|
|
+ cb->reserved4 == 0 &&
|
|
|
|
+ cb->reserved5 == 0 &&
|
|
|
|
+ cb->reserved6 == 0 &&
|
|
|
|
+ cb->reserved7 == 0 &&
|
|
|
|
+ cb->reserved8 == 0 &&
|
|
|
|
+ cb->rla >= cb->roa &&
|
|
|
|
+ cb->rca >= cb->roa &&
|
|
|
|
+ cb->rca <= cb->rla+1 &&
|
|
|
|
+ cb->m < 3;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int s390_runtime_instr_get(struct task_struct *target,
|
|
|
|
+ const struct user_regset *regset,
|
|
|
|
+ unsigned int pos, unsigned int count,
|
|
|
|
+ void *kbuf, void __user *ubuf)
|
|
|
|
+{
|
|
|
|
+ struct runtime_instr_cb *data = target->thread.ri_cb;
|
|
|
|
+
|
|
|
|
+ if (!test_facility(64))
|
|
|
|
+ return -ENODEV;
|
|
|
|
+ if (!data)
|
|
|
|
+ return -ENODATA;
|
|
|
|
+
|
|
|
|
+ return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
|
|
|
|
+ data, 0, sizeof(struct runtime_instr_cb));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int s390_runtime_instr_set(struct task_struct *target,
|
|
|
|
+ const struct user_regset *regset,
|
|
|
|
+ unsigned int pos, unsigned int count,
|
|
|
|
+ const void *kbuf, const void __user *ubuf)
|
|
|
|
+{
|
|
|
|
+ struct runtime_instr_cb ri_cb = { }, *data = NULL;
|
|
|
|
+ int rc;
|
|
|
|
+
|
|
|
|
+ if (!test_facility(64))
|
|
|
|
+ return -ENODEV;
|
|
|
|
+
|
|
|
|
+ if (!target->thread.ri_cb) {
|
|
|
|
+ data = kzalloc(sizeof(*data), GFP_KERNEL);
|
|
|
|
+ if (!data)
|
|
|
|
+ return -ENOMEM;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (target->thread.ri_cb) {
|
|
|
|
+ if (target == current)
|
|
|
|
+ store_runtime_instr_cb(&ri_cb);
|
|
|
|
+ else
|
|
|
|
+ ri_cb = *target->thread.ri_cb;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
|
|
|
|
+ &ri_cb, 0, sizeof(struct runtime_instr_cb));
|
|
|
|
+ if (rc) {
|
|
|
|
+ kfree(data);
|
|
|
|
+ return -EFAULT;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!is_ri_cb_valid(&ri_cb)) {
|
|
|
|
+ kfree(data);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ preempt_disable();
|
|
|
|
+ if (!target->thread.ri_cb)
|
|
|
|
+ target->thread.ri_cb = data;
|
|
|
|
+ *target->thread.ri_cb = ri_cb;
|
|
|
|
+ if (target == current)
|
|
|
|
+ load_runtime_instr_cb(target->thread.ri_cb);
|
|
|
|
+ preempt_enable();
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
static const struct user_regset s390_regsets[] = {
|
|
static const struct user_regset s390_regsets[] = {
|
|
{
|
|
{
|
|
.core_note_type = NT_PRSTATUS,
|
|
.core_note_type = NT_PRSTATUS,
|
|
@@ -1312,6 +1405,14 @@ static const struct user_regset s390_regsets[] = {
|
|
.get = s390_gs_bc_get,
|
|
.get = s390_gs_bc_get,
|
|
.set = s390_gs_bc_set,
|
|
.set = s390_gs_bc_set,
|
|
},
|
|
},
|
|
|
|
+ {
|
|
|
|
+ .core_note_type = NT_S390_RI_CB,
|
|
|
|
+ .n = sizeof(struct runtime_instr_cb) / sizeof(__u64),
|
|
|
|
+ .size = sizeof(__u64),
|
|
|
|
+ .align = sizeof(__u64),
|
|
|
|
+ .get = s390_runtime_instr_get,
|
|
|
|
+ .set = s390_runtime_instr_set,
|
|
|
|
+ },
|
|
};
|
|
};
|
|
|
|
|
|
static const struct user_regset_view user_s390_view = {
|
|
static const struct user_regset_view user_s390_view = {
|
|
@@ -1548,6 +1649,14 @@ static const struct user_regset s390_compat_regsets[] = {
|
|
.get = s390_gs_cb_get,
|
|
.get = s390_gs_cb_get,
|
|
.set = s390_gs_cb_set,
|
|
.set = s390_gs_cb_set,
|
|
},
|
|
},
|
|
|
|
+ {
|
|
|
|
+ .core_note_type = NT_S390_RI_CB,
|
|
|
|
+ .n = sizeof(struct runtime_instr_cb) / sizeof(__u64),
|
|
|
|
+ .size = sizeof(__u64),
|
|
|
|
+ .align = sizeof(__u64),
|
|
|
|
+ .get = s390_runtime_instr_get,
|
|
|
|
+ .set = s390_runtime_instr_set,
|
|
|
|
+ },
|
|
};
|
|
};
|
|
|
|
|
|
static const struct user_regset_view user_s390_compat_view = {
|
|
static const struct user_regset_view user_s390_compat_view = {
|