Add a barrier between reading the cqe flags and the command ID, which
authorjmatthew <jmatthew@openbsd.org>
Tue, 9 Feb 2021 01:50:10 +0000 (01:50 +0000)
committerjmatthew <jmatthew@openbsd.org>
Tue, 9 Feb 2021 01:50:10 +0000 (01:50 +0000)
should ensure that we don't read a stale command ID and complete the
wrong scsi io.  powerpc64 base builds were crashing like this fairly
regularly.

ok deraadt@ dlg@

sys/dev/ic/nvme.c

index 2d01688..602f93d 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: nvme.c,v 1.89 2020/10/15 13:22:13 krw Exp $ */
+/*     $OpenBSD: nvme.c,v 1.90 2021/02/09 01:50:10 jmatthew Exp $ */
 
 /*
  * Copyright (c) 2014 David Gwynne <dlg@openbsd.org>
@@ -994,6 +994,8 @@ nvme_q_complete(struct nvme_softc *sc, struct nvme_queue *q)
                if ((flags & NVME_CQE_PHASE) != q->q_cq_phase)
                        break;
 
+               membar_consumer();
+
                ccb = &sc->sc_ccbs[cqe->cid];
                ccb->ccb_done(sc, ccb, cqe);