From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: [PATCH 1/2] xen/io/ring.h: new macro to detect whether there are too many requests on the ring Date: Mon, 17 Jun 2013 15:47:33 -0400 Message-ID: <1371498454-2116-2-git-send-email-konrad.wilk@oracle.com> References: <1371498454-2116-1-git-send-email-konrad.wilk@oracle.com> Return-path: In-Reply-To: <1371498454-2116-1-git-send-email-konrad.wilk@oracle.com> Sender: linux-kernel-owner@vger.kernel.org To: jbeulich@suse.com, xen-devel@lists.xensource.com, linux-kernel@vger.kernel.org Cc: Konrad Rzeszutek Wilk List-Id: xen-devel@lists.xenproject.org From: Jan Beulich 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 . Signed-off-by: Jan Beulich Signed-off-by: Konrad Rzeszutek Wilk --- include/xen/interface/io/ring.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/ring.h index 75271b9..7d28aff 100644 --- a/include/xen/interface/io/ring.h +++ b/include/xen/interface/io/ring.h @@ -188,6 +188,11 @@ struct __name##_back_ring { \ #define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \ (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r)) +/* Ill-behaved frontend determination: Can there be this many requests? */ +#define RING_REQUEST_PROD_OVERFLOW(_r, _prod) \ + (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r)) + + #define RING_PUSH_REQUESTS(_r) do { \ wmb(); /* back sees requests /before/ updated producer index */ \ (_r)->sring->req_prod = (_r)->req_prod_pvt; \ -- 1.8.1.4