]>
Commit | Line | Data |
---|---|---|
2720559d GKH |
1 | From 79c4d036e08cdcd9403047a37cbc9e37b5ee86b4 Mon Sep 17 00:00:00 2001 |
2 | From: Jan Beulich <jbeulich@suse.com> | |
3 | Date: Mon, 17 Jun 2013 15:16:33 -0400 | |
4 | Subject: xen/io/ring.h: new macro to detect whether there are too many requests on the ring | |
5 | ||
6 | From: Jan Beulich <jbeulich@suse.com> | |
7 | ||
8 | commit 8d9256906a97c24e97e016482b9be06ea2532b05 upstream. | |
9 | ||
10 | Backends may need to protect themselves against an insane number of | |
11 | produced requests stored by a frontend, in case they iterate over | |
12 | requests until reaching the req_prod value. There can't be more | |
13 | requests on the ring than the difference between produced requests | |
14 | and produced (but possibly not yet published) responses. | |
15 | ||
16 | This is a more strict alternative to a patch previously posted by | |
17 | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>. | |
18 | ||
19 | Signed-off-by: Jan Beulich <jbeulich@suse.com> | |
20 | Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | |
21 | Signed-off-by: Ben Hutchings <ben@decadent.org.uk> | |
22 | Cc: Yijing Wang <wangyijing@huawei.com> | |
23 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
24 | ||
25 | --- | |
26 | include/xen/interface/io/ring.h | 5 +++++ | |
27 | 1 file changed, 5 insertions(+) | |
28 | ||
29 | --- a/include/xen/interface/io/ring.h | |
30 | +++ b/include/xen/interface/io/ring.h | |
31 | @@ -188,6 +188,11 @@ struct __name##_back_ring { \ | |
32 | #define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \ | |
33 | (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r)) | |
34 | ||
35 | +/* Ill-behaved frontend determination: Can there be this many requests? */ | |
36 | +#define RING_REQUEST_PROD_OVERFLOW(_r, _prod) \ | |
37 | + (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r)) | |
38 | + | |
39 | + | |
40 | #define RING_PUSH_REQUESTS(_r) do { \ | |
41 | wmb(); /* back sees requests /before/ updated producer index */ \ | |
42 | (_r)->sring->req_prod = (_r)->req_prod_pvt; \ |