summaryrefslogtreecommitdiff
path: root/drivers/s390
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/block/dasd.c64
-rw-r--r--drivers/s390/block/dasd_devmap.c3
-rw-r--r--drivers/s390/block/dasd_eckd.c8
-rw-r--r--drivers/s390/block/dasd_genhd.c80
-rw-r--r--drivers/s390/char/sclp_mem.c16
-rw-r--r--drivers/s390/char/sclp_sd.c3
-rw-r--r--drivers/s390/char/vmur.c8
-rw-r--r--drivers/s390/cio/vfio_ccw_ops.c47
8 files changed, 100 insertions, 129 deletions
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 9a5c6a73511f..35031357ac4d 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -207,19 +207,6 @@ static int dasd_state_known_to_new(struct dasd_device *device)
return 0;
}
-static struct dentry *dasd_debugfs_setup(const char *name,
- struct dentry *base_dentry)
-{
- struct dentry *pde;
-
- if (!base_dentry)
- return NULL;
- pde = debugfs_create_dir(name, base_dentry);
- if (!pde || IS_ERR(pde))
- return NULL;
- return pde;
-}
-
/*
* Request the irq line for the device.
*/
@@ -234,14 +221,14 @@ static int dasd_state_known_to_basic(struct dasd_device *device)
if (rc)
return rc;
block->debugfs_dentry =
- dasd_debugfs_setup(block->gdp->disk_name,
+ debugfs_create_dir(block->gdp->disk_name,
dasd_debugfs_root_entry);
dasd_profile_init(&block->profile, block->debugfs_dentry);
if (dasd_global_profile_level == DASD_PROFILE_ON)
dasd_profile_on(&device->block->profile);
}
device->debugfs_dentry =
- dasd_debugfs_setup(dev_name(&device->cdev->dev),
+ debugfs_create_dir(dev_name(&device->cdev->dev),
dasd_debugfs_root_entry);
dasd_profile_init(&device->profile, device->debugfs_dentry);
dasd_hosts_init(device->debugfs_dentry, device);
@@ -1057,19 +1044,9 @@ static const struct file_operations dasd_stats_raw_fops = {
static void dasd_profile_init(struct dasd_profile *profile,
struct dentry *base_dentry)
{
- umode_t mode;
- struct dentry *pde;
-
- if (!base_dentry)
- return;
- profile->dentry = NULL;
profile->data = NULL;
- mode = (S_IRUSR | S_IWUSR | S_IFREG);
- pde = debugfs_create_file("statistics", mode, base_dentry,
- profile, &dasd_stats_raw_fops);
- if (pde && !IS_ERR(pde))
- profile->dentry = pde;
- return;
+ profile->dentry = debugfs_create_file("statistics", 0600, base_dentry,
+ profile, &dasd_stats_raw_fops);
}
static void dasd_profile_exit(struct dasd_profile *profile)
@@ -1089,25 +1066,9 @@ static void dasd_statistics_removeroot(void)
static void dasd_statistics_createroot(void)
{
- struct dentry *pde;
-
- dasd_debugfs_root_entry = NULL;
- pde = debugfs_create_dir("dasd", NULL);
- if (!pde || IS_ERR(pde))
- goto error;
- dasd_debugfs_root_entry = pde;
- pde = debugfs_create_dir("global", dasd_debugfs_root_entry);
- if (!pde || IS_ERR(pde))
- goto error;
- dasd_debugfs_global_entry = pde;
+ dasd_debugfs_root_entry = debugfs_create_dir("dasd", NULL);
+ dasd_debugfs_global_entry = debugfs_create_dir("global", dasd_debugfs_root_entry);
dasd_profile_init(&dasd_global_profile, dasd_debugfs_global_entry);
- return;
-
-error:
- DBF_EVENT(DBF_ERR, "%s",
- "Creation of the dasd debugfs interface failed");
- dasd_statistics_removeroot();
- return;
}
#else
@@ -1168,17 +1129,8 @@ static void dasd_hosts_exit(struct dasd_device *device)
static void dasd_hosts_init(struct dentry *base_dentry,
struct dasd_device *device)
{
- struct dentry *pde;
- umode_t mode;
-
- if (!base_dentry)
- return;
-
- mode = S_IRUSR | S_IFREG;
- pde = debugfs_create_file("host_access_list", mode, base_dentry,
- device, &dasd_hosts_fops);
- if (pde && !IS_ERR(pde))
- device->hosts_dentry = pde;
+ device->hosts_dentry = debugfs_create_file("host_access_list", 0400, base_dentry,
+ device, &dasd_hosts_fops);
}
struct dasd_ccw_req *dasd_smalloc_request(int magic, int cplength, int datasize,
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index ddbdf1f85d44..73972900fc55 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -355,7 +355,8 @@ static int __init dasd_parse_range(const char *range)
/* each device in dasd= parameter should be set initially online */
features |= DASD_FEATURE_INITIAL_ONLINE;
while (from <= to) {
- sprintf(bus_id, "%01x.%01x.%04x", from_id0, from_id1, from++);
+ scnprintf(bus_id, sizeof(bus_id),
+ "%01x.%01x.%04x", from_id0, from_id1, from++);
devmap = dasd_add_busid(bus_id, features);
if (IS_ERR(devmap)) {
rc = PTR_ERR(devmap);
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 687396703788..b08e900687f3 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -6139,6 +6139,7 @@ static int dasd_eckd_copy_pair_swap(struct dasd_device *device, char *prim_busid
struct dasd_copy_relation *copy;
struct dasd_block *block;
struct gendisk *gdp;
+ int rc;
copy = device->copy;
if (!copy)
@@ -6173,6 +6174,13 @@ static int dasd_eckd_copy_pair_swap(struct dasd_device *device, char *prim_busid
/* swap blocklayer device link */
gdp = block->gdp;
dasd_add_link_to_gendisk(gdp, secondary);
+ rc = device_move(disk_to_dev(gdp), &secondary->cdev->dev, DPM_ORDER_NONE);
+ if (rc) {
+ dev_err(&primary->cdev->dev,
+ "copy_pair_swap: moving blockdevice parent %s->%s failed (%d)\n",
+ dev_name(&primary->cdev->dev),
+ dev_name(&secondary->cdev->dev), rc);
+ }
/* re-enable device */
dasd_device_remove_stop_bits(primary, DASD_STOPPED_PPRC);
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index 28e92fad0ca1..6ee3d952412e 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -22,6 +22,7 @@
static unsigned int queue_depth = 32;
static unsigned int nr_hw_queues = 4;
+static void dasd_gd_free(struct gendisk *gdp);
module_param(queue_depth, uint, 0444);
MODULE_PARM_DESC(queue_depth, "Default queue depth for new DASD devices");
@@ -30,6 +31,37 @@ module_param(nr_hw_queues, uint, 0444);
MODULE_PARM_DESC(nr_hw_queues, "Default number of hardware queues for new DASD devices");
/*
+ * Set device name.
+ * dasda - dasdz : 26 devices
+ * dasdaa - dasdzz : 676 devices, added up = 702
+ * dasdaaa - dasdzzz : 17576 devices, added up = 18278
+ * dasdaaaa - dasdzzzz : 456976 devices, added up = 475252
+ */
+static int dasd_name_format(char *prefix, int index, char *buf, int buflen)
+{
+ const int base = 'z' - 'a' + 1;
+ char *begin = buf + strlen(prefix);
+ char *end = buf + buflen;
+ char *p;
+ int unit;
+
+ p = end - 1;
+ *p = '\0';
+ unit = base;
+ do {
+ if (p == begin)
+ return -EINVAL;
+ *--p = 'a' + (index % unit);
+ index = (index / unit) - 1;
+ } while (index >= 0);
+
+ memmove(begin, p, end - p);
+ memcpy(buf, prefix, strlen(prefix));
+
+ return 0;
+}
+
+/*
* Allocate and register gendisk structure for device.
*/
int dasd_gendisk_alloc(struct dasd_block *block)
@@ -45,11 +77,13 @@ int dasd_gendisk_alloc(struct dasd_block *block)
};
struct gendisk *gdp;
struct dasd_device *base;
- int len, rc;
+ unsigned int devindex;
+ int rc;
/* Make sure the minor for this device exists. */
base = block->base;
- if (base->devindex >= DASD_PER_MAJOR)
+ devindex = base->devindex;
+ if (devindex >= DASD_PER_MAJOR)
return -EBUSY;
block->tag_set.ops = &dasd_mq_ops;
@@ -69,31 +103,17 @@ int dasd_gendisk_alloc(struct dasd_block *block)
/* Initialize gendisk structure. */
gdp->major = DASD_MAJOR;
- gdp->first_minor = base->devindex << DASD_PARTN_BITS;
+ gdp->first_minor = devindex << DASD_PARTN_BITS;
gdp->minors = 1 << DASD_PARTN_BITS;
gdp->fops = &dasd_device_operations;
- /*
- * Set device name.
- * dasda - dasdz : 26 devices
- * dasdaa - dasdzz : 676 devices, added up = 702
- * dasdaaa - dasdzzz : 17576 devices, added up = 18278
- * dasdaaaa - dasdzzzz : 456976 devices, added up = 475252
- */
- len = sprintf(gdp->disk_name, "dasd");
- if (base->devindex > 25) {
- if (base->devindex > 701) {
- if (base->devindex > 18277)
- len += sprintf(gdp->disk_name + len, "%c",
- 'a'+(((base->devindex-18278)
- /17576)%26));
- len += sprintf(gdp->disk_name + len, "%c",
- 'a'+(((base->devindex-702)/676)%26));
- }
- len += sprintf(gdp->disk_name + len, "%c",
- 'a'+(((base->devindex-26)/26)%26));
+ rc = dasd_name_format("dasd", devindex, gdp->disk_name, sizeof(gdp->disk_name));
+ if (rc) {
+ DBF_DEV_EVENT(DBF_ERR, block->base,
+ "setting disk name failed, rc %d", rc);
+ dasd_gd_free(gdp);
+ return rc;
}
- len += sprintf(gdp->disk_name + len, "%c", 'a'+(base->devindex%26));
if (base->features & DASD_FEATURE_READONLY ||
test_bit(DASD_FLAG_DEVICE_RO, &base->flags))
@@ -112,14 +132,22 @@ int dasd_gendisk_alloc(struct dasd_block *block)
}
/*
+ * Free gendisk structure
+ */
+static void dasd_gd_free(struct gendisk *gd)
+{
+ del_gendisk(gd);
+ gd->private_data = NULL;
+ put_disk(gd);
+}
+
+/*
* Unregister and free gendisk structure for device.
*/
void dasd_gendisk_free(struct dasd_block *block)
{
if (block->gdp) {
- del_gendisk(block->gdp);
- block->gdp->private_data = NULL;
- put_disk(block->gdp);
+ dasd_gd_free(block->gdp);
block->gdp = NULL;
blk_mq_free_tag_set(&block->tag_set);
}
diff --git a/drivers/s390/char/sclp_mem.c b/drivers/s390/char/sclp_mem.c
index 676c085b4f8a..27f0d2f12a8b 100644
--- a/drivers/s390/char/sclp_mem.c
+++ b/drivers/s390/char/sclp_mem.c
@@ -44,6 +44,9 @@ struct sclp_mem {
unsigned int id;
unsigned int memmap_on_memory;
unsigned int config;
+#ifdef CONFIG_KASAN
+ unsigned int early_shadow_mapped;
+#endif
};
struct sclp_mem_arg {
@@ -244,6 +247,16 @@ static ssize_t sclp_config_mem_store(struct kobject *kobj, struct kobj_attribute
put_device(&mem->dev);
sclp_mem_change_state(addr, block_size, 0);
__remove_memory(addr, block_size);
+#ifdef CONFIG_KASAN
+ if (sclp_mem->early_shadow_mapped) {
+ unsigned long start, end;
+
+ start = (unsigned long)kasan_mem_to_shadow(__va(addr));
+ end = start + (block_size >> KASAN_SHADOW_SCALE_SHIFT);
+ vmemmap_free(start, end, NULL);
+ sclp_mem->early_shadow_mapped = 0;
+ }
+#endif
WRITE_ONCE(sclp_mem->config, 0);
}
out_unlock:
@@ -316,6 +329,9 @@ static int sclp_create_mem(struct sclp_mem *sclp_mem, struct kset *kset,
sclp_mem->memmap_on_memory = memmap_on_memory;
sclp_mem->config = config;
+#ifdef CONFIG_KASAN
+ sclp_mem->early_shadow_mapped = config;
+#endif
sclp_mem->id = id;
kobject_init(&sclp_mem->kobj, &ktype);
rc = kobject_add(&sclp_mem->kobj, &kset->kobj, "memory%d", id);
diff --git a/drivers/s390/char/sclp_sd.c b/drivers/s390/char/sclp_sd.c
index bb1bce70ec00..e4a90a14028a 100644
--- a/drivers/s390/char/sclp_sd.c
+++ b/drivers/s390/char/sclp_sd.c
@@ -16,8 +16,7 @@
#include <linux/vmalloc.h>
#include <linux/async.h>
#include <linux/mutex.h>
-
-#include <asm/pgalloc.h>
+#include <linux/pgalloc.h>
#include "sclp.h"
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index e3e0e9f36527..a226ff208eda 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -154,7 +154,7 @@ static struct urdev *urdev_get_from_devno(u16 devno)
struct ccw_device *cdev;
struct urdev *urd;
- sprintf(bus_id, "0.0.%04x", devno);
+ scnprintf(bus_id, sizeof(bus_id), "0.0.%04x", devno);
cdev = get_ccwdev_by_busid(&ur_driver, bus_id);
if (!cdev)
return NULL;
@@ -904,11 +904,11 @@ static int ur_set_online(struct ccw_device *cdev)
goto fail_free_cdev;
if (urd->cdev->id.cu_type == READER_PUNCH_DEVTYPE) {
if (urd->class == DEV_CLASS_UR_I)
- sprintf(node_id, "vmrdr-%s", dev_name(&cdev->dev));
+ scnprintf(node_id, sizeof(node_id), "vmrdr-%s", dev_name(&cdev->dev));
if (urd->class == DEV_CLASS_UR_O)
- sprintf(node_id, "vmpun-%s", dev_name(&cdev->dev));
+ scnprintf(node_id, sizeof(node_id), "vmpun-%s", dev_name(&cdev->dev));
} else if (urd->cdev->id.cu_type == PRINTER_DEVTYPE) {
- sprintf(node_id, "vmprt-%s", dev_name(&cdev->dev));
+ scnprintf(node_id, sizeof(node_id), "vmprt-%s", dev_name(&cdev->dev));
} else {
rc = -EOPNOTSUPP;
goto fail_free_cdev;
diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c
index ea532a8a4a0c..a596f6013019 100644
--- a/drivers/s390/cio/vfio_ccw_ops.c
+++ b/drivers/s390/cio/vfio_ccw_ops.c
@@ -313,10 +313,12 @@ static int vfio_ccw_mdev_get_device_info(struct vfio_ccw_private *private,
return 0;
}
-static int vfio_ccw_mdev_get_region_info(struct vfio_ccw_private *private,
- struct vfio_region_info *info,
- unsigned long arg)
+static int vfio_ccw_mdev_ioctl_get_region_info(struct vfio_device *vdev,
+ struct vfio_region_info *info,
+ struct vfio_info_cap *caps)
{
+ struct vfio_ccw_private *private =
+ container_of(vdev, struct vfio_ccw_private, vdev);
int i;
switch (info->index) {
@@ -328,7 +330,6 @@ static int vfio_ccw_mdev_get_region_info(struct vfio_ccw_private *private,
return 0;
default: /* all other regions are handled via capability chain */
{
- struct vfio_info_cap caps = { .buf = NULL, .size = 0 };
struct vfio_region_info_cap_type cap_type = {
.header.id = VFIO_REGION_INFO_CAP_TYPE,
.header.version = 1 };
@@ -351,27 +352,10 @@ static int vfio_ccw_mdev_get_region_info(struct vfio_ccw_private *private,
cap_type.type = private->region[i].type;
cap_type.subtype = private->region[i].subtype;
- ret = vfio_info_add_capability(&caps, &cap_type.header,
+ ret = vfio_info_add_capability(caps, &cap_type.header,
sizeof(cap_type));
if (ret)
return ret;
-
- info->flags |= VFIO_REGION_INFO_FLAG_CAPS;
- if (info->argsz < sizeof(*info) + caps.size) {
- info->argsz = sizeof(*info) + caps.size;
- info->cap_offset = 0;
- } else {
- vfio_info_cap_shift(&caps, sizeof(*info));
- if (copy_to_user((void __user *)arg + sizeof(*info),
- caps.buf, caps.size)) {
- kfree(caps.buf);
- return -EFAULT;
- }
- info->cap_offset = sizeof(*info);
- }
-
- kfree(caps.buf);
-
}
}
return 0;
@@ -532,24 +516,6 @@ static ssize_t vfio_ccw_mdev_ioctl(struct vfio_device *vdev,
return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
}
- case VFIO_DEVICE_GET_REGION_INFO:
- {
- struct vfio_region_info info;
-
- minsz = offsetofend(struct vfio_region_info, offset);
-
- if (copy_from_user(&info, (void __user *)arg, minsz))
- return -EFAULT;
-
- if (info.argsz < minsz)
- return -EINVAL;
-
- ret = vfio_ccw_mdev_get_region_info(private, &info, arg);
- if (ret)
- return ret;
-
- return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
- }
case VFIO_DEVICE_GET_IRQ_INFO:
{
struct vfio_irq_info info;
@@ -627,6 +593,7 @@ static const struct vfio_device_ops vfio_ccw_dev_ops = {
.read = vfio_ccw_mdev_read,
.write = vfio_ccw_mdev_write,
.ioctl = vfio_ccw_mdev_ioctl,
+ .get_region_info_caps = vfio_ccw_mdev_ioctl_get_region_info,
.request = vfio_ccw_mdev_request,
.dma_unmap = vfio_ccw_dma_unmap,
.bind_iommufd = vfio_iommufd_emulated_bind,