Release 4.7 drivers/s390/cio/blacklist.c
/*
* S/390 common I/O routines -- blacklisting of specific devices
*
* Copyright IBM Corp. 1999, 2013
* Author(s): Ingo Adlung (adlung@de.ibm.com)
* Cornelia Huck (cornelia.huck@de.ibm.com)
* Arnd Bergmann (arndb@de.ibm.com)
*/
#define KMSG_COMPONENT "cio"
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
#include <linux/init.h>
#include <linux/vmalloc.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/ctype.h>
#include <linux/device.h>
#include <asm/uaccess.h>
#include <asm/cio.h>
#include <asm/ipl.h>
#include "blacklist.h"
#include "cio.h"
#include "cio_debug.h"
#include "css.h"
#include "device.h"
/*
* "Blacklisting" of certain devices:
* Device numbers given in the commandline as cio_ignore=... won't be known
* to Linux.
*
* These can be single devices or ranges of devices
*/
/* 65536 bits for each set to indicate if a devno is blacklisted or not */
#define __BL_DEV_WORDS ((__MAX_SUBCHANNEL + (8*sizeof(long) - 1)) / \
(8*sizeof(long)))
static unsigned long bl_dev[__MAX_SSID + 1][__BL_DEV_WORDS];
typedef enum {add, free} range_action;
/*
* Function: blacklist_range
* (Un-)blacklist the devices from-to
*/
static int blacklist_range(range_action action, unsigned int from_ssid,
unsigned int to_ssid, unsigned int from,
unsigned int to, int msgtrigger)
{
if ((from_ssid > to_ssid) || ((from_ssid == to_ssid) && (from > to))) {
if (msgtrigger)
pr_warn("0.%x.%04x to 0.%x.%04x is not a valid range for cio_ignore\n",
from_ssid, from, to_ssid, to);
return 1;
}
while ((from_ssid < to_ssid) || ((from_ssid == to_ssid) &&
(from <= to))) {
if (action == add)
set_bit(from, bl_dev[from_ssid]);
else
clear_bit(from, bl_dev[from_ssid]);
from++;
if (from > __MAX_SUBCHANNEL) {
from_ssid++;
from = 0;
}
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
michael ernst | michael ernst | 78 | 54.17% | 1 | 20.00% |
martin schwidefsky | martin schwidefsky | 54 | 37.50% | 2 | 40.00% |
cornelia huck | cornelia huck | 10 | 6.94% | 1 | 20.00% |
joe perches | joe perches | 2 | 1.39% | 1 | 20.00% |
| Total | 144 | 100.00% | 5 | 100.00% |
static int pure_hex(char **cp, unsigned int *val, int min_digit,
int max_digit, int max_val)
{
int diff;
diff = 0;
*val = 0;
while (diff <= max_digit) {
int value = hex_to_bin(**cp);
if (value < 0)
break;
*val = *val * 16 + value;
(*cp)++;
diff++;
}
if ((diff < min_digit) || (diff > max_digit) || (*val > max_val))
return 1;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
michael ernst | michael ernst | 53 | 49.07% | 1 | 20.00% |
andrew morton | andrew morton | 32 | 29.63% | 2 | 40.00% |
martin schwidefsky | martin schwidefsky | 12 | 11.11% | 1 | 20.00% |
andy shevchenko | andy shevchenko | 11 | 10.19% | 1 | 20.00% |
| Total | 108 | 100.00% | 5 | 100.00% |
static int parse_busid(char *str, unsigned int *cssid, unsigned int *ssid,
unsigned int *devno, int msgtrigger)
{
char *str_work;
int val, rc, ret;
rc = 1;
if (*str == '\0')
goto out;
/* old style */
str_work = str;
val = simple_strtoul(str, &str_work, 16);
if (*str_work == '\0') {
if (val <= __MAX_SUBCHANNEL) {
*devno = val;
*ssid = 0;
*cssid = 0;
rc = 0;
}
goto out;
}
/* new style */
str_work = str;
ret = pure_hex(&str_work, cssid, 1, 2, __MAX_CSSID);
if (ret || (str_work[0] != '.'))
goto out;
str_work++;
ret = pure_hex(&str_work, ssid, 1, 1, __MAX_SSID);
if (ret || (str_work[0] != '.'))
goto out;
str_work++;
ret = pure_hex(&str_work, devno, 4, 4, __MAX_SUBCHANNEL);
if (ret || (str_work[0] != '\0'))
goto out;
rc = 0;
out:
if (rc && msgtrigger)
pr_warn("%s is not a valid device for the cio_ignore kernel parameter\n",
str);
return rc;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
michael ernst | michael ernst | 157 | 65.97% | 1 | 16.67% |
andrew morton | andrew morton | 67 | 28.15% | 2 | 33.33% |
martin schwidefsky | martin schwidefsky | 9 | 3.78% | 1 | 16.67% |
cornelia huck | cornelia huck | 3 | 1.26% | 1 | 16.67% |
joe perches | joe perches | 2 | 0.84% | 1 | 16.67% |
| Total | 238 | 100.00% | 6 | 100.00% |
static int blacklist_parse_parameters(char *str, range_action action,
int msgtrigger)
{
unsigned int from_cssid, to_cssid, from_ssid, to_ssid, from, to;
int rc, totalrc;
char *parm;
range_action ra;
totalrc = 0;
while ((parm = strsep(&str, ","))) {
rc = 0;
ra = action;
if (*parm == '!') {
if (ra == add)
ra = free;
else
ra = add;
parm++;
}
if (strcmp(parm, "all") == 0) {
from_cssid = 0;
from_ssid = 0;
from = 0;
to_cssid = __MAX_CSSID;
to_ssid = __MAX_SSID;
to = __MAX_SUBCHANNEL;
} else if (strcmp(parm, "ipldev") == 0) {
if (ipl_info.type == IPL_TYPE_CCW) {
from_cssid = 0;
from_ssid = ipl_info.data.ccw.dev_id.ssid;
from = ipl_info.data.ccw.dev_id.devno;
} else if (ipl_info.type == IPL_TYPE_FCP ||
ipl_info.type == IPL_TYPE_FCP_DUMP) {
from_cssid = 0;
from_ssid = ipl_info.data.fcp.dev_id.ssid;
from = ipl_info.data.fcp.dev_id.devno;
} else {
continue;
}
to_cssid = from_cssid;
to_ssid = from_ssid;
to = from;
} else if (strcmp(parm, "condev") == 0) {
if (console_devno == -1)
continue;
from_cssid = to_cssid = 0;
from_ssid = to_ssid = 0;
from = to = console_devno;
} else {
rc = parse_busid(strsep(&parm, "-"), &from_cssid,
&from_ssid, &from, msgtrigger);
if (!rc) {
if (parm != NULL)
rc = parse_busid(parm, &to_cssid,
&to_ssid, &to,
msgtrigger);
else {
to_cssid = from_cssid;
to_ssid = from_ssid;
to = from;
}
}
}
if (!rc) {
rc = blacklist_range(ra, from_ssid, to_ssid, from, to,
msgtrigger);
if (rc)
totalrc = -EINVAL;
} else
totalrc = -EINVAL;
}
return totalrc;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
sebastian ott | sebastian ott | 153 | 38.06% | 2 | 22.22% |
michael ernst | michael ernst | 127 | 31.59% | 1 | 11.11% |
andrew morton | andrew morton | 64 | 15.92% | 2 | 22.22% |
martin schwidefsky | martin schwidefsky | 40 | 9.95% | 1 | 11.11% |
cornelia huck | cornelia huck | 14 | 3.48% | 2 | 22.22% |
peter oberparleiter | peter oberparleiter | 4 | 1.00% | 1 | 11.11% |
| Total | 402 | 100.00% | 9 | 100.00% |
static int __init
blacklist_setup (char *str)
{
CIO_MSG_EVENT(6, "Reading blacklist parameters\n");
if (blacklist_parse_parameters(str, add, 1))
return 0;
return 1;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
martin schwidefsky | martin schwidefsky | 18 | 51.43% | 1 | 50.00% |
michael ernst | michael ernst | 17 | 48.57% | 1 | 50.00% |
| Total | 35 | 100.00% | 2 | 100.00% |
__setup ("cio_ignore=", blacklist_setup);
/* Checking if devices are blacklisted */
/*
* Function: is_blacklisted
* Returns 1 if the given devicenumber can be found in the blacklist,
* otherwise 0.
* Used by validate_subchannel()
*/
int
is_blacklisted (int ssid, int devno)
{
return test_bit (devno, bl_dev[ssid]);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
martin schwidefsky | martin schwidefsky | 16 | 72.73% | 1 | 50.00% |
cornelia huck | cornelia huck | 6 | 27.27% | 1 | 50.00% |
| Total | 22 | 100.00% | 2 | 100.00% |
#ifdef CONFIG_PROC_FS
/*
* Function: blacklist_parse_proc_parameters
* parse the stuff which is piped to /proc/cio_ignore
*/
static int blacklist_parse_proc_parameters(char *buf)
{
int rc;
char *parm;
parm = strsep(&buf, " ");
if (strcmp("free", parm) == 0) {
rc = blacklist_parse_parameters(buf, free, 0);
css_schedule_eval_all_unreg(0);
} else if (strcmp("add", parm) == 0)
rc = blacklist_parse_parameters(buf, add, 0);
else if (strcmp("purge", parm) == 0)
return ccw_purge_blacklisted();
else
return -EINVAL;
return rc;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
martin schwidefsky | martin schwidefsky | 40 | 38.83% | 1 | 25.00% |
michael ernst | michael ernst | 38 | 36.89% | 1 | 25.00% |
peter oberparleiter | peter oberparleiter | 25 | 24.27% | 2 | 50.00% |
| Total | 103 | 100.00% | 4 | 100.00% |
/* Iterator struct for all devices. */
struct ccwdev_iter {
int devno;
int ssid;
int in_range;
};
static void *
cio_ignore_proc_seq_start(struct seq_file *s, loff_t *offset)
{
struct ccwdev_iter *iter = s->private;
if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1))
return NULL;
memset(iter, 0, sizeof(*iter));
iter->ssid = *offset / (__MAX_SUBCHANNEL + 1);
iter->devno = *offset % (__MAX_SUBCHANNEL + 1);
return iter;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
cornelia huck | cornelia huck | 66 | 75.86% | 2 | 40.00% |
christian borntraeger | christian borntraeger | 11 | 12.64% | 1 | 20.00% |
martin schwidefsky | martin schwidefsky | 10 | 11.49% | 2 | 40.00% |
| Total | 87 | 100.00% | 5 | 100.00% |
static void
cio_ignore_proc_seq_stop(struct seq_file *s, void *it)
{
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
cornelia huck | cornelia huck | 13 | 92.86% | 1 | 50.00% |
christian borntraeger | christian borntraeger | 1 | 7.14% | 1 | 50.00% |
| Total | 14 | 100.00% | 2 | 100.00% |
static void *
cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset)
{
struct ccwdev_iter *iter;
if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1))
return NULL;
iter = it;
if (iter->devno == __MAX_SUBCHANNEL) {
iter->devno = 0;
iter->ssid++;
if (iter->ssid > __MAX_SSID)
return NULL;
} else
iter->devno++;
(*offset)++;
return iter;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
cornelia huck | cornelia huck | 94 | 97.92% | 2 | 66.67% |
martin schwidefsky | martin schwidefsky | 2 | 2.08% | 1 | 33.33% |
| Total | 96 | 100.00% | 3 | 100.00% |
static int
cio_ignore_proc_seq_show(struct seq_file *s, void *it)
{
struct ccwdev_iter *iter;
iter = it;
if (!is_blacklisted(iter->ssid, iter->devno))
/* Not blacklisted, nothing to output. */
return 0;
if (!iter->in_range) {
/* First device in range. */
if ((iter->devno == __MAX_SUBCHANNEL) ||
!is_blacklisted(iter->ssid, iter->devno + 1)) {
/* Singular device. */
seq_printf(s, "0.%x.%04x\n", iter->ssid, iter->devno);
return 0;
}
iter->in_range = 1;
seq_printf(s, "0.%x.%04x-", iter->ssid, iter->devno);
return 0;
}
if ((iter->devno == __MAX_SUBCHANNEL) ||
!is_blacklisted(iter->ssid, iter->devno + 1)) {
/* Last device in range. */
iter->in_range = 0;
seq_printf(s, "0.%x.%04x\n", iter->ssid, iter->devno);
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
cornelia huck | cornelia huck | 130 | 75.58% | 3 | 50.00% |
martin schwidefsky | martin schwidefsky | 33 | 19.19% | 2 | 33.33% |
joe perches | joe perches | 9 | 5.23% | 1 | 16.67% |
| Total | 172 | 100.00% | 6 | 100.00% |
static ssize_t
cio_ignore_write(struct file *file, const char __user *user_buf,
size_t user_len, loff_t *offset)
{
char *buf;
ssize_t rc, ret, i;
if (*offset)
return -EINVAL;
if (user_len > 65536)
user_len = 65536;
buf = vzalloc(user_len + 1); /* maybe better use the stack? */
if (buf == NULL)
return -ENOMEM;
if (strncpy_from_user (buf, user_buf, user_len) < 0) {
rc = -EFAULT;
goto out_free;
}
i = user_len - 1;
while ((i >= 0) && (isspace(buf[i]) || (buf[i] == 0))) {
buf[i] = '\0';
i--;
}
ret = blacklist_parse_proc_parameters(buf);
if (ret)
rc = ret;
else
rc = user_len;
out_free:
vfree (buf);
return rc;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
martin schwidefsky | martin schwidefsky | 87 | 50.58% | 2 | 25.00% |
michael ernst | michael ernst | 67 | 38.95% | 1 | 12.50% |
cornelia huck | cornelia huck | 13 | 7.56% | 1 | 12.50% |
sebastian ott | sebastian ott | 2 | 1.16% | 1 | 12.50% |
peter oberparleiter | peter oberparleiter | 1 | 0.58% | 1 | 12.50% |
andrew morton | andrew morton | 1 | 0.58% | 1 | 12.50% |
joe perches | joe perches | 1 | 0.58% | 1 | 12.50% |
| Total | 172 | 100.00% | 8 | 100.00% |
static const struct seq_operations cio_ignore_proc_seq_ops = {
.start = cio_ignore_proc_seq_start,
.stop = cio_ignore_proc_seq_stop,
.next = cio_ignore_proc_seq_next,
.show = cio_ignore_proc_seq_show,
};
static int
cio_ignore_proc_open(struct inode *inode, struct file *file)
{
return seq_open_private(file, &cio_ignore_proc_seq_ops,
sizeof(struct ccwdev_iter));
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
cornelia huck | cornelia huck | 24 | 77.42% | 1 | 50.00% |
christian borntraeger | christian borntraeger | 7 | 22.58% | 1 | 50.00% |
| Total | 31 | 100.00% | 2 | 100.00% |
static const struct file_operations cio_ignore_proc_fops = {
.open = cio_ignore_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release_private,
.write = cio_ignore_write,
};
static int
cio_ignore_proc_init (void)
{
struct proc_dir_entry *entry;
entry = proc_create("cio_ignore", S_IFREG | S_IRUGO | S_IWUSR, NULL,
&cio_ignore_proc_fops);
if (!entry)
return -ENOENT;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
martin schwidefsky | martin schwidefsky | 35 | 81.40% | 1 | 25.00% |
denis v. lunev | denis v. lunev | 4 | 9.30% | 1 | 25.00% |
cornelia huck | cornelia huck | 3 | 6.98% | 1 | 25.00% |
alexey dobriyan | alexey dobriyan | 1 | 2.33% | 1 | 25.00% |
| Total | 43 | 100.00% | 4 | 100.00% |
__initcall (cio_ignore_proc_init);
#endif /* CONFIG_PROC_FS */
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
michael ernst | michael ernst | 548 | 29.67% | 2 | 7.41% |
cornelia huck | cornelia huck | 459 | 24.85% | 5 | 18.52% |
martin schwidefsky | martin schwidefsky | 425 | 23.01% | 2 | 7.41% |
andrew morton | andrew morton | 170 | 9.20% | 4 | 14.81% |
sebastian ott | sebastian ott | 160 | 8.66% | 3 | 11.11% |
peter oberparleiter | peter oberparleiter | 33 | 1.79% | 2 | 7.41% |
christian borntraeger | christian borntraeger | 20 | 1.08% | 1 | 3.70% |
joe perches | joe perches | 14 | 0.76% | 3 | 11.11% |
andy shevchenko | andy shevchenko | 11 | 0.60% | 1 | 3.70% |
denis v. lunev | denis v. lunev | 4 | 0.22% | 1 | 3.70% |
arjan van de ven | arjan van de ven | 1 | 0.05% | 1 | 3.70% |
jan engelhardt | jan engelhardt | 1 | 0.05% | 1 | 3.70% |
alexey dobriyan | alexey dobriyan | 1 | 0.05% | 1 | 3.70% |
| Total | 1847 | 100.00% | 27 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.