Skip to content

Commit 372bed5

Browse files
committed
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael Tsirkin: "Bugfixes all over the place" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: vhost-vdpa: fix use after free in vhost_vdpa_probe() virtio_pci: Switch away from deprecated irq_set_affinity_hint riscv, qemu_fw_cfg: Add support for RISC-V architecture vdpa_sim_blk: allocate the buffer zeroed virtio_pci: move structure to a header
2 parents c42d9ee + e07754e commit 372bed5

File tree

8 files changed

+22
-18
lines changed

8 files changed

+22
-18
lines changed

drivers/firmware/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ config RASPBERRYPI_FIRMWARE
131131

132132
config FW_CFG_SYSFS
133133
tristate "QEMU fw_cfg device support in sysfs"
134-
depends on SYSFS && (ARM || ARM64 || PARISC || PPC_PMAC || SPARC || X86)
134+
depends on SYSFS && (ARM || ARM64 || PARISC || PPC_PMAC || RISCV || SPARC || X86)
135135
depends on HAS_IOPORT_MAP
136136
default n
137137
help

drivers/firmware/qemu_fw_cfg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static void fw_cfg_io_cleanup(void)
211211

212212
/* arch-specific ctrl & data register offsets are not available in ACPI, DT */
213213
#if !(defined(FW_CFG_CTRL_OFF) && defined(FW_CFG_DATA_OFF))
214-
# if (defined(CONFIG_ARM) || defined(CONFIG_ARM64))
214+
# if (defined(CONFIG_ARM) || defined(CONFIG_ARM64) || defined(CONFIG_RISCV))
215215
# define FW_CFG_CTRL_OFF 0x08
216216
# define FW_CFG_DATA_OFF 0x00
217217
# define FW_CFG_DMA_OFF 0x10

drivers/vdpa/vdpa_sim/vdpa_sim_blk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ static int vdpasim_blk_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
437437
if (blk->shared_backend) {
438438
blk->buffer = shared_buffer;
439439
} else {
440-
blk->buffer = kvmalloc(VDPASIM_BLK_CAPACITY << SECTOR_SHIFT,
440+
blk->buffer = kvzalloc(VDPASIM_BLK_CAPACITY << SECTOR_SHIFT,
441441
GFP_KERNEL);
442442
if (!blk->buffer) {
443443
ret = -ENOMEM;
@@ -495,7 +495,7 @@ static int __init vdpasim_blk_init(void)
495495
goto parent_err;
496496

497497
if (shared_backend) {
498-
shared_buffer = kvmalloc(VDPASIM_BLK_CAPACITY << SECTOR_SHIFT,
498+
shared_buffer = kvzalloc(VDPASIM_BLK_CAPACITY << SECTOR_SHIFT,
499499
GFP_KERNEL);
500500
if (!shared_buffer) {
501501
ret = -ENOMEM;

drivers/vhost/vdpa.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,6 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa)
15821582

15831583
err:
15841584
put_device(&v->dev);
1585-
ida_simple_remove(&vhost_vdpa_ida, v->minor);
15861585
return r;
15871586
}
15881587

drivers/virtio/virtio_pci_common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void vp_del_vqs(struct virtio_device *vdev)
242242
if (v != VIRTIO_MSI_NO_VECTOR) {
243243
int irq = pci_irq_vector(vp_dev->pci_dev, v);
244244

245-
irq_set_affinity_hint(irq, NULL);
245+
irq_update_affinity_hint(irq, NULL);
246246
free_irq(irq, vq);
247247
}
248248
}
@@ -443,10 +443,10 @@ int vp_set_vq_affinity(struct virtqueue *vq, const struct cpumask *cpu_mask)
443443
mask = vp_dev->msix_affinity_masks[info->msix_vector];
444444
irq = pci_irq_vector(vp_dev->pci_dev, info->msix_vector);
445445
if (!cpu_mask)
446-
irq_set_affinity_hint(irq, NULL);
446+
irq_update_affinity_hint(irq, NULL);
447447
else {
448448
cpumask_copy(mask, cpu_mask);
449-
irq_set_affinity_hint(irq, mask);
449+
irq_set_affinity_and_hint(irq, mask);
450450
}
451451
}
452452
return 0;

drivers/virtio/virtio_pci_modern_dev.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,10 @@ int vp_modern_probe(struct virtio_pci_modern_device *mdev)
294294

295295
err = -EINVAL;
296296
mdev->common = vp_modern_map_capability(mdev, common,
297-
sizeof(struct virtio_pci_common_cfg), 4,
298-
0, sizeof(struct virtio_pci_modern_common_cfg),
299-
&mdev->common_len, NULL);
297+
sizeof(struct virtio_pci_common_cfg), 4, 0,
298+
offsetofend(struct virtio_pci_modern_common_cfg,
299+
queue_reset),
300+
&mdev->common_len, NULL);
300301
if (!mdev->common)
301302
goto err_map_common;
302303
mdev->isr = vp_modern_map_capability(mdev, isr, sizeof(u8), 1,

include/linux/virtio_pci_modern.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
#include <linux/pci.h>
66
#include <linux/virtio_pci.h>
77

8-
struct virtio_pci_modern_common_cfg {
9-
struct virtio_pci_common_cfg cfg;
10-
11-
__le16 queue_notify_data; /* read-write */
12-
__le16 queue_reset; /* read-write */
13-
};
14-
158
/**
169
* struct virtio_pci_modern_device - info for modern PCI virtio
1710
* @pci_dev: Ptr to the PCI device struct

include/uapi/linux/virtio_pci.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ struct virtio_pci_common_cfg {
166166
__le32 queue_used_hi; /* read-write */
167167
};
168168

169+
/*
170+
* Warning: do not use sizeof on this: use offsetofend for
171+
* specific fields you need.
172+
*/
173+
struct virtio_pci_modern_common_cfg {
174+
struct virtio_pci_common_cfg cfg;
175+
176+
__le16 queue_notify_data; /* read-write */
177+
__le16 queue_reset; /* read-write */
178+
};
179+
169180
/* Fields in VIRTIO_PCI_CAP_PCI_CFG: */
170181
struct virtio_pci_cfg_cap {
171182
struct virtio_pci_cap cap;

0 commit comments

Comments
 (0)