From: Khalid Aziz Date: Fri, 2 Dec 2016 19:45:37 +0000 (-0700) Subject: sparc64: Add sensible read values for /proc//sparc_adi X-Git-Tag: v4.1.12-92~1^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=54cc45869238af877fc71e7700dc5b90fc33fc22;p=users%2Fjedix%2Flinux-maple.git sparc64: Add sensible read values for /proc//sparc_adi This patch makes value read from /proc//sparc_adi consistent across platforms that support ADi and ones that do not. When ADI is not available for a process either due to process being an anonymous process on an ADI-capable platform or the process is running on a non-ADI platform, a read from /proc//sparc_adi always reads a value of -1. This patch updates the documentation file as well with the values for sparc_adi proc file. Orabug: 25173120 Signed-off-by: Khalid Aziz Signed-off-by: Allen Pais --- diff --git a/Documentation/sparc/adi.txt b/Documentation/sparc/adi.txt index 1740f8ac3f2cb..2f25edcf2906c 100644 --- a/Documentation/sparc/adi.txt +++ b/Documentation/sparc/adi.txt @@ -148,6 +148,25 @@ MCD disabled siginfo.si_trapno = 0; +ADI specific proc files +----------------------- + +ADI feature adds two new proc files: + +/proc/sys/kernel/mcd_on_by_default + This file indicates if TTE.mcd (and hence ADI) will be enabled by + default for a new task. Reading from the file returns current value + which can be changed by writing to this file. + +/proc//sparc_adi + This file reports the current state of ADI for the process. A + value of 1 means ADI si enabled currently for the process, a + value of 0 means ADI is not enabled currently for the process, + and a value of -1 means ADI is not available to the process. + Writing to this file, when ADI is available, changes the current + state of ADI for theprocess. + + Sample program to use ADI ------------------------- diff --git a/fs/proc/base.c b/fs/proc/base.c index 47f05bf4e7dc3..867206e142318 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1309,21 +1309,22 @@ sparc_adi_show(struct seq_file *m, void *v) 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 + if (!adi_capable()) { seq_printf(m, "-1\n"); + } else { + task_lock(task); - task_unlock(task); - put_task_struct(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; }