Commit 8f0cbedc authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull virtio fixes from Michael Tsirkin:
 "Just a bunch of fixes, mostly trivial ones in tools/virtio"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
  vhost/vsock: improve RCU read sections around vhost_vsock_get()
  tools/virtio: add device, device_driver stubs
  tools/virtio: fix up oot build
  virtio_features: make it self-contained
  tools/virtio: switch to kernel's virtio_config.h
  tools/virtio: stub might_sleep and synchronize_rcu
  tools/virtio: add struct cpumask to cpumask.h
  tools/virtio: pass KCFLAGS to module build
  tools/virtio: add ucopysize.h stub
  tools/virtio: add dev_WARN_ONCE and is_vmalloc_addr stubs
  tools/virtio: stub DMA mapping functions
  tools/virtio: add struct module forward declaration
  tools/virtio: use kernel's virtio.h
  virtio: make it self-contained
  tools/virtio: fix up compiler.h stub
parents e2cc6440 d8ee3cfd
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -66,14 +66,15 @@ static u32 vhost_transport_get_local_cid(void)
	return VHOST_VSOCK_DEFAULT_HOST_CID;
}

/* Callers that dereference the return value must hold vhost_vsock_mutex or the
 * RCU read lock.
/* Callers must be in an RCU read section or hold the vhost_vsock_mutex.
 * The return value can only be dereferenced while within the section.
 */
static struct vhost_vsock *vhost_vsock_get(u32 guest_cid)
{
	struct vhost_vsock *vsock;

	hash_for_each_possible_rcu(vhost_vsock_hash, vsock, hash, guest_cid) {
	hash_for_each_possible_rcu(vhost_vsock_hash, vsock, hash, guest_cid,
				   lockdep_is_held(&vhost_vsock_mutex)) {
		u32 other_cid = vsock->guest_cid;

		/* Skip instances that have no CID yet */
@@ -709,9 +710,15 @@ static void vhost_vsock_reset_orphans(struct sock *sk)
	 * executing.
	 */

	rcu_read_lock();

	/* If the peer is still valid, no need to reset connection */
	if (vhost_vsock_get(vsk->remote_addr.svm_cid))
	if (vhost_vsock_get(vsk->remote_addr.svm_cid)) {
		rcu_read_unlock();
		return;
	}

	rcu_read_unlock();

	/* If the close timeout is pending, let it expire.  This avoids races
	 * with the timeout callback.
+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@
#include <linux/completion.h>
#include <linux/virtio_features.h>

struct module;

/**
 * struct virtqueue - a queue to register buffers for sending or receiving.
 * @list: the chain of virtqueues for this device
+2 −0
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@
#define _LINUX_VIRTIO_FEATURES_H

#include <linux/bits.h>
#include <linux/bug.h>
#include <linux/string.h>

#define VIRTIO_FEATURES_U64S	2
#define VIRTIO_FEATURES_BITS	(VIRTIO_FEATURES_U64S * 64)
+5 −3
Original line number Diff line number Diff line
@@ -20,8 +20,9 @@ CFLAGS += -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../
CFLAGS += -pthread
LDFLAGS += -pthread
vpath %.c ../../drivers/virtio ../../drivers/vhost
BUILD=KCFLAGS="-I "`pwd`/../../drivers/vhost ${MAKE} -C `pwd`/../.. V=${V}
mod:
	${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test V=${V}
	${BUILD} M=`pwd`/vhost_test

#oot: build vhost as an out of tree module for a distro kernel
#no effort is taken to make it actually build or work, but tends to mostly work
@@ -37,8 +38,9 @@ OOT_CONFIGS=\
	CONFIG_VHOST_NET=n \
	CONFIG_VHOST_SCSI=n \
	CONFIG_VHOST_VSOCK=n \
	CONFIG_VHOST_RING=n
OOT_BUILD=KCFLAGS="-I "${OOT_VHOST} ${MAKE} -C ${OOT_KSRC} V=${V}
	CONFIG_VHOST_RING=n \
	CONFIG_VHOST_VDPA=n
OOT_BUILD=KCFLAGS="-include "`pwd`"/oot-stubs.h -I "${OOT_VHOST} ${MAKE} -C ${OOT_KSRC} V=${V}
oot-build:
	echo "UNSUPPORTED! Don't use the resulting modules in production!"
	${OOT_BUILD} M=`pwd`/vhost_test
+6 −0
Original line number Diff line number Diff line
@@ -2,7 +2,11 @@
#ifndef LINUX_COMPILER_H
#define LINUX_COMPILER_H

/* Avoid redefinition warnings */
#undef __user
#include "../../../include/linux/compiler_types.h"
#undef __user
#define __user

#define WRITE_ONCE(var, val) \
	(*((volatile typeof(val) *)(&(var))) = (val))
@@ -35,4 +39,6 @@
	__v;								\
})

#define __must_check

#endif
Loading