diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2013-07-02 02:05:13 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-07-02 02:12:04 -0400 |
commit | 8fd9a6365eb8a79a2d8f0e0baa01f4db6345e8dd (patch) | |
tree | 35b566aed74e6b4c46cdbff23b2ceda5f4fe5a9b /tools | |
parent | 8c6bab4f3874d31804a00782c48a8f244a0d3cc0 (diff) |
tools/lguest: fix missing rmb().
The virtio spec was missing a barrier in example code, so I went back
to look at the lguest code. Indeed, we need one.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lguest/lguest.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/lguest/lguest.c b/tools/lguest/lguest.c index 07a03452c227..49ed25b5bbb9 100644 --- a/tools/lguest/lguest.c +++ b/tools/lguest/lguest.c | |||
@@ -177,6 +177,7 @@ static struct termios orig_term; | |||
177 | * in precise order. | 177 | * in precise order. |
178 | */ | 178 | */ |
179 | #define wmb() __asm__ __volatile__("" : : : "memory") | 179 | #define wmb() __asm__ __volatile__("" : : : "memory") |
180 | #define rmb() __asm__ __volatile__("" : : : "memory") | ||
180 | #define mb() __asm__ __volatile__("" : : : "memory") | 181 | #define mb() __asm__ __volatile__("" : : : "memory") |
181 | 182 | ||
182 | /* Wrapper for the last available index. Makes it easier to change. */ | 183 | /* Wrapper for the last available index. Makes it easier to change. */ |
@@ -676,6 +677,12 @@ static unsigned wait_for_vq_desc(struct virtqueue *vq, | |||
676 | errx(1, "Guest moved used index from %u to %u", | 677 | errx(1, "Guest moved used index from %u to %u", |
677 | last_avail, vq->vring.avail->idx); | 678 | last_avail, vq->vring.avail->idx); |
678 | 679 | ||
680 | /* | ||
681 | * Make sure we read the descriptor number *after* we read the ring | ||
682 | * update; don't let the cpu or compiler change the order. | ||
683 | */ | ||
684 | rmb(); | ||
685 | |||
679 | /* | 686 | /* |
680 | * Grab the next descriptor number they're advertising, and increment | 687 | * Grab the next descriptor number they're advertising, and increment |
681 | * the index we've seen. | 688 | * the index we've seen. |
@@ -695,6 +702,12 @@ static unsigned wait_for_vq_desc(struct virtqueue *vq, | |||
695 | i = head; | 702 | i = head; |
696 | 703 | ||
697 | /* | 704 | /* |
705 | * We have to read the descriptor after we read the descriptor number, | ||
706 | * but there's a data dependency there so the CPU shouldn't reorder | ||
707 | * that: no rmb() required. | ||
708 | */ | ||
709 | |||
710 | /* | ||
698 | * If this is an indirect entry, then this buffer contains a descriptor | 711 | * If this is an indirect entry, then this buffer contains a descriptor |
699 | * table which we handle as if it's any normal descriptor chain. | 712 | * table which we handle as if it's any normal descriptor chain. |
700 | */ | 713 | */ |