Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03c21cb7 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull virtio tests and fixes from Michael Tsirkin:
 "This fixes existing tests broken by barrier rework, and adds some new
  tests.

  Plus, there's a fix for an old bug in virtio-pci"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
  tools/virtio: add ringtest utilities
  sh: fix smp_store_mb for !SMP
  tools/virtio: use virt_xxx barriers
  virtio_pci: fix use after free on release
parents 075356c1 481eaec3
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@
#endif

#define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
#define smp_store_mb(var, value) __smp_store_mb(var, value)

#include <asm-generic/barrier.h>

+2 −0
Original line number Diff line number Diff line
@@ -545,6 +545,7 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
static void virtio_pci_remove(struct pci_dev *pci_dev)
{
	struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
	struct device *dev = get_device(&vp_dev->vdev.dev);

	unregister_virtio_device(&vp_dev->vdev);

@@ -554,6 +555,7 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)
		virtio_pci_modern_remove(vp_dev);

	pci_disable_device(pci_dev);
	put_device(dev);
}

static struct pci_driver virtio_pci_driver = {
+13 −9
Original line number Diff line number Diff line
#if defined(__i386__) || defined(__x86_64__)
#define barrier() asm volatile("" ::: "memory")
#define mb() __sync_synchronize()

#define smp_mb()	mb()
# define dma_rmb()	barrier()
# define dma_wmb()	barrier()
# define smp_rmb()	barrier()
# define smp_wmb()	barrier()
#define virt_mb() __sync_synchronize()
#define virt_rmb() barrier()
#define virt_wmb() barrier()
/* Atomic store should be enough, but gcc generates worse code in that case. */
#define virt_store_mb(var, value)  do { \
	typeof(var) virt_store_mb_value = (value); \
	__atomic_exchange(&(var), &virt_store_mb_value, &virt_store_mb_value, \
			  __ATOMIC_SEQ_CST); \
	barrier(); \
} while (0);
/* Weak barriers should be used. If not - it's a bug */
# define mb() abort()
# define rmb() abort()
# define wmb() abort()
#else
+9 −0
Original line number Diff line number Diff line
#ifndef LINUX_COMPILER_H
#define LINUX_COMPILER_H

#define WRITE_ONCE(var, val) \
	(*((volatile typeof(val) *)(&(var))) = (val))

#define READ_ONCE(var) (*((volatile typeof(val) *)(&(var))))

#endif
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include <assert.h>
#include <stdarg.h>

#include <linux/compiler.h>
#include <linux/types.h>
#include <linux/printk.h>
#include <linux/bug.h>
Loading