diff options
author | Jan Beulich <jbeulich@suse.com> | 2013-06-17 15:16:33 -0400 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2013-06-17 15:17:15 -0400 |
commit | 8d9256906a97c24e97e016482b9be06ea2532b05 (patch) | |
tree | d6e1828f08344fa7f183ea9deddb8b898b26d5ab | |
parent | 604c499cbbcc3d5fe5fb8d53306aa0fae1990109 (diff) |
xen/io/ring.h: new macro to detect whether there are too many requests on the ring
Backends may need to protect themselves against an insane number of
produced requests stored by a frontend, in case they iterate over
requests until reaching the req_prod value. There can't be more
requests on the ring than the difference between produced requests
and produced (but possibly not yet published) responses.
This is a more strict alternative to a patch previously posted by
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
-rw-r--r-- | include/xen/interface/io/ring.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/ring.h index 75271b9a8f61..7d28aff605c7 100644 --- a/include/xen/interface/io/ring.h +++ b/include/xen/interface/io/ring.h | |||
@@ -188,6 +188,11 @@ struct __name##_back_ring { \ | |||
188 | #define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \ | 188 | #define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \ |
189 | (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r)) | 189 | (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r)) |
190 | 190 | ||
191 | /* Ill-behaved frontend determination: Can there be this many requests? */ | ||
192 | #define RING_REQUEST_PROD_OVERFLOW(_r, _prod) \ | ||
193 | (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r)) | ||
194 | |||
195 | |||
191 | #define RING_PUSH_REQUESTS(_r) do { \ | 196 | #define RING_PUSH_REQUESTS(_r) do { \ |
192 | wmb(); /* back sees requests /before/ updated producer index */ \ | 197 | wmb(); /* back sees requests /before/ updated producer index */ \ |
193 | (_r)->sring->req_prod = (_r)->req_prod_pvt; \ | 198 | (_r)->sring->req_prod = (_r)->req_prod_pvt; \ |