]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sparc64: Add proc files specific to ADI
authorKhalid Aziz <khalid.aziz@oracle.com>
Wed, 16 Nov 2016 23:43:13 +0000 (16:43 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 9 Mar 2017 03:30:16 +0000 (19:30 -0800)
This patch adds /proc/sys/kernel/mcd_on_by_default and
/proc/<pid>/sparc_adi files. These files allow userspace access to
change ADI parameters.

Orabug: 22713162

Signed-off-by: Khalid Aziz <khalid.aziz@oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
arch/sparc/include/asm/adi_64.h
fs/proc/base.c
kernel/sysctl.c

index 24fe52fe9e8fda760d851da1a721a8721ea7ddc9..cd2ce353de9e910789cdd81f48b54bde71a0c950 100644 (file)
@@ -24,6 +24,8 @@ struct adi_config {
 
 extern struct adi_config adi_state;
 
+extern int mcd_on_by_default;
+
 extern void mdesc_adi_init(void);
 
 static inline bool adi_capable(void)
index 093ca14f570154f5de1cc6db10c7995e1b7cba02..5da375d7b3b46c91aabed11e990adc677d2837d6 100644 (file)
@@ -1299,6 +1299,47 @@ static const struct file_operations proc_pid_sched_autogroup_operations = {
 
 #endif /* CONFIG_SCHED_AUTOGROUP */
 
+#ifdef CONFIG_SPARC64
+static int
+sparc_adi_show(struct seq_file *m, void *v)
+{
+       struct inode *inode = m->private;
+       struct task_struct *task = get_proc_task(inode);
+
+       if (!task)
+               return -ENOENT;
+
+       if (!adi_capable())
+               return -ENOTSUPP;
+
+       task_lock(task);
+
+       /* anonymous processes can not use ADI */
+       if (task->mm) {
+               struct pt_regs *regs;
+               regs = task_pt_regs(task);
+               seq_printf(m, "%d\n", !!(regs->tstate & TSTATE_MCDE));
+       } else
+               seq_printf(m, "-1\n");
+
+       task_unlock(task);
+       put_task_struct(task);
+       return 0;
+}
+
+static int
+sparc_adi_open(struct inode *inode, struct file *filp)
+{
+       return single_open(filp, sparc_adi_show, inode);
+}
+
+static const struct file_operations proc_sparc_adi_operations = {
+       .open           = sparc_adi_open,
+       .read           = seq_read,
+       .release        = single_release,
+};
+#endif /* CONFIG_SPARC_ADI */
+
 static ssize_t comm_write(struct file *file, const char __user *buf,
                                size_t count, loff_t *offset)
 {
@@ -2640,6 +2681,9 @@ static const struct pid_entry tgid_base_stuff[] = {
 #ifdef CONFIG_CHECKPOINT_RESTORE
        REG("timers",     S_IRUGO, proc_timers_operations),
 #endif
+#ifdef CONFIG_SPARC64
+       REG("sparc_adi",  S_IRUGO, proc_sparc_adi_operations),
+#endif
 };
 
 static int proc_tgid_base_readdir(struct file *file, struct dir_context *ctx)
index 2082b1a88fb9a451a00a759379bec8d786c3bab7..c2b551fcaac98d242f06d3fce77a280497a2470e 100644 (file)
@@ -1132,6 +1132,15 @@ static struct ctl_table kern_table[] = {
                .extra1         = &zero,
                .extra2         = &one,
        },
+#if defined(CONFIG_SPARC64)
+       {
+               .procname       = "mcd_on_by_default",
+               .data           = &mcd_on_by_default,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec,
+       },
+#endif
        { }
 };