Page MenuHomeFreeBSD

D19501.1795718561.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D19501.1795718561.diff

Index: usr.sbin/bhyve/virtio.c
===================================================================
--- usr.sbin/bhyve/virtio.c
+++ usr.sbin/bhyve/virtio.c
@@ -3,6 +3,7 @@
*
* Copyright (c) 2013 Chris Torek <torek @ torek net>
* All rights reserved.
+ * Copyright (c) 2019 Joyent, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -37,6 +38,8 @@
#include <pthread.h>
#include <pthread_np.h>
+#include <machine/atomic.h>
+
#include "bhyverun.h"
#include "pci_emul.h"
#include "virtio.h"
@@ -422,6 +425,11 @@
vue = &vuh->vu_ring[uidx++ & mask];
vue->vu_idx = idx;
vue->vu_tlen = iolen;
+ /*
+ * Ensure the used descriptor is visible before updating the index.
+ * This is necessary on ISAs with memory ordering less strict than x86.
+ */
+ atomic_thread_fence_rel();
vuh->vu_idx = uidx;
}
@@ -459,6 +467,12 @@
vs = vq->vq_vs;
old_idx = vq->vq_save_used;
vq->vq_save_used = new_idx = vq->vq_used->vu_idx;
+ /*
+ * Use full memory barrier between vu_idx store from preceding
+ * vq_relchain() call and the loads from VQ_USED_EVENT_IDX() or
+ * va_flags below.
+ */
+ atomic_thread_fence_seq_cst();
if (used_all_avail &&
(vs->vs_negotiated_caps & VIRTIO_F_NOTIFY_ON_EMPTY))
intr = 1;

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 26, 6:42 PM (8 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42024714
Default Alt Text
D19501.1795718561.diff (1 KB)

Event Timeline