Module Name:    src
Committed By:   jdolecek
Date:           Tue Aug 21 18:11:10 UTC 2018

Modified Files:
        src/sys/arch/xen/xen: xbd_xenbus.c

Log Message:
avoid race condition between I/O submission in xbd_diskstart() and
interrupt handling in xbd_handler() - need to protect it with splbio()

fixes PR port-xen/53506 by Emmanuel Dreyfus, and likely also port-xen/53074
by Brad Spencer


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/xen/xen/xbd_xenbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/xbd_xenbus.c
diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.82 src/sys/arch/xen/xen/xbd_xenbus.c:1.83
--- src/sys/arch/xen/xen/xbd_xenbus.c:1.82	Wed Aug 15 15:49:15 2018
+++ src/sys/arch/xen/xen/xbd_xenbus.c	Tue Aug 21 18:11:10 2018
@@ -1,4 +1,4 @@
-/*      $NetBSD: xbd_xenbus.c,v 1.82 2018/08/15 15:49:15 jdolecek Exp $      */
+/*      $NetBSD: xbd_xenbus.c,v 1.83 2018/08/21 18:11:10 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.82 2018/08/15 15:49:15 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.83 2018/08/21 18:11:10 jdolecek Exp $");
 
 #include "opt_xen.h"
 
@@ -932,6 +932,7 @@ xbd_diskstart(device_t self, struct buf 
 	vaddr_t va;
 	int nsects, nbytes, seg;
 	int notify, error = 0;
+	int s;
 
 	DPRINTF(("xbd_diskstart(%p): b_bcount = %ld\n",
 	    bp, (long)bp->b_bcount));
@@ -947,6 +948,8 @@ xbd_diskstart(device_t self, struct buf 
 		goto err;
 	}
 
+	s = splbio();	/* XXX SMP */
+
 	if (__predict_false(
 	    sc->sc_backend_status == BLKIF_STATE_SUSPENDED)) {
 		/* device is suspended, do not consume buffer */
@@ -1024,6 +1027,7 @@ out:
 	RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&sc->sc_ring, notify);
 	if (notify)
 		hypervisor_notify_via_evtchn(sc->sc_evtchn);
+	splx(s);	/* XXXSMP */
 err:
 	return error;
 }

Reply via email to