summaryrefslogtreecommitdiffstats
path: root/sys/dev/pv/xen.c
diff options
context:
space:
mode:
authormikeb <mikeb@openbsd.org>2016-04-28 16:40:10 +0000
committermikeb <mikeb@openbsd.org>2016-04-28 16:40:10 +0000
commita80d814f59d31f717d3347188791f25455532f4f (patch)
treeb8fcf798eadfcf57fb798b8b020d15ca93e09779 /sys/dev/pv/xen.c
parentImplement the IETF ChaCha20-Poly1305 cipher suites. (diff)
downloadwireguard-openbsd-a80d814f59d31f717d3347188791f25455532f4f.tar.xz
wireguard-openbsd-a80d814f59d31f717d3347188791f25455532f4f.zip
Preserve the domid when swapping 16 bit grant table entry flags
We use an atomic CMPXCHG on first 32 bits of the grant table entry when revoking access to the memory page. Target domain ID field is part of these 32 bits, thus shouldn't be masked out for comparison. This appears to be the last piece of the QubesOS VM chaining puzzle; tested by Marco Peereboom, thanks!
Diffstat (limited to 'sys/dev/pv/xen.c')
-rw-r--r--sys/dev/pv/xen.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/dev/pv/xen.c b/sys/dev/pv/xen.c
index a2b5dfc3623..6e13b129688 100644
--- a/sys/dev/pv/xen.c
+++ b/sys/dev/pv/xen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xen.c,v 1.55 2016/04/19 18:15:41 mikeb Exp $ */
+/* $OpenBSD: xen.c,v 1.56 2016/04/28 16:40:10 mikeb Exp $ */
/*
* Copyright (c) 2015 Mike Belopuhov
@@ -1088,7 +1088,8 @@ xen_grant_table_remove(struct xen_softc *sc, grant_ref_t ref)
/* Invalidate the grant reference */
virtio_membar_sync();
ptr = (uint32_t *)&ge->ge_table[ref];
- flags = (ge->ge_table[ref].flags & ~(GTF_reading|GTF_writing));
+ flags = (ge->ge_table[ref].flags & ~(GTF_reading|GTF_writing)) |
+ (ge->ge_table[ref].domid << 16);
loop = 0;
while (atomic_cas_uint(ptr, flags, GTF_invalid) != flags) {
if (loop++ > 10000000) {