From: "Jan Beulich" Subject: [PATCH v3] io/ring.h: new macro to detect whether there are too many requests on the ring Date: Tue, 11 Jun 2013 09:23:19 +0100 Message-ID: <51B6FA9702000078000DCFE8@nat28.tlf.novell.com> References: <1370880121-7690-1-git-send-email-konrad.wilk@oracle.com> <1370880121-7690-2-git-send-email-konrad.wilk@oracle.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part3606DC67.0__=" Return-path: In-Reply-To: <1370880121-7690-2-git-send-email-konrad.wilk@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Konrad Rzeszutek Wilk List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part3606DC67.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 --- a/xen/include/public/io/ring.h +++ b/xen/include/public/io/ring.h @@ -234,6 +234,10 @@ typedef struct __name##_back_ring __name #define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \ (((_cons) - (_r)->rsp_prod_pvt) >=3D RING_SIZE(_r)) =20 +/* 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 { \ xen_wmb(); /* back sees requests /before/ updated producer index */ \ (_r)->sring->req_prod =3D (_r)->req_prod_pvt; = \ --=__Part3606DC67.0__= Content-Type: text/plain; name="ring-request-prod-overflow.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ring-request-prod-overflow.patch" io/ring.h: new macro to detect whether there are too many requests on the = ring=0A=0ABackends may need to protect themselves against an insane number = of=0Aproduced requests stored by a frontend, in case they iterate = over=0Arequests until reaching the req_prod value. There can't be = more=0Arequests on the ring than the difference between produced = requests=0Aand produced (but possibly not yet published) responses.=0A=0ATh= is is a more strict alternative to a patch previously posted by=0AKonrad = Rzeszutek Wilk .=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/include/public/io/ring.h=0A+++ = b/xen/include/public/io/ring.h=0A@@ -234,6 +234,10 @@ typedef struct = __name##_back_ring __name=0A #define RING_REQUEST_CONS_OVERFLOW(_r, _cons) = \=0A (((_cons) - (_r)->rsp_prod_pvt) >=3D = RING_SIZE(_r))=0A =0A+/* Ill-behaved frontend determination: Can there be = this many requests? */=0A+#define RING_REQUEST_PROD_OVERFLOW(_r, _prod) = \=0A+ (((_prod) - (_r)->rsp_prod_pvt) > = RING_SIZE(_r))=0A+=0A #define RING_PUSH_REQUESTS(_r) do { = \=0A xen_wmb(); /* back sees requests /before/ = updated producer index */ \=0A (_r)->sring->req_prod =3D (_r)->req_prod= _pvt; \=0A --=__Part3606DC67.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part3606DC67.0__=--