Received: from eggs.gnu.org ([2001:4830:134:3::10]:47204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnJel-0005Xn-ML for qemu-devel@nongnu.org; Fri, 23 Sep 2016 02:08:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnJei-0006Q2-5K for qemu-devel@nongnu.org; Fri, 23 Sep 2016 02:08:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53170) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnJeh-0006Pm-V9 for qemu-devel@nongnu.org; Fri, 23 Sep 2016 02:08:16 -0400 References: <1474540298-4152-1-git-send-email-ppandit@redhat.com> <44697264-cc82-7c93-5b04-241bfe4035ab@redhat.com> <65a02429-9c7b-5c9d-c3d7-0cda13789539@redhat.com> From: Jason Wang Message-ID: <37065598-2277-5ea4-f75b-d88dcbf8cff4@redhat.com> Date: Fri, 23 Sep 2016 14:08:09 +0800 MIME-Version: 1.0 In-Reply-To: <65a02429-9c7b-5c9d-c3d7-0cda13789539@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] net: imx: limit buffer descriptor count List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , P J P , Qemu Developers Cc: Li Qiang , Prasad J Pandit On 2016=E5=B9=B409=E6=9C=8823=E6=97=A5 13:17, Jason Wang wrote: > > > On 2016=E5=B9=B409=E6=9C=8822=E6=97=A5 18:32, Paolo Bonzini wrote: >> >> On 22/09/2016 12:31, P J P wrote: >>> From: Prasad J Pandit >>> >>> i.MX Fast Ethernet Controller uses buffer descriptors to manage >>> data flow to/fro receive & transmit queues. While transmitting >>> packets, it could continue to read buffer descriptors if a buffer >>> descriptor has length of zero and has crafted values in bd.flags. >>> Set an upper limit to number of buffer descriptors. >>> >>> Reported-by: Li Qiang >>> Signed-off-by: Prasad J Pandit >>> --- >>> hw/net/imx_fec.c | 6 ++++-- >>> 1 file changed, 4 insertions(+), 2 deletions(-) >>> >>> Update per >>> ->=20 >>> https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg05284.html >>> >>> diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c >>> index e60e338..547fa99 100644 >>> --- a/hw/net/imx_fec.c >>> +++ b/hw/net/imx_fec.c >>> @@ -94,6 +94,8 @@ static const VMStateDescription vmstate_imx_fec =3D= { >>> #define PHY_INT_PARFAULT (1 << 2) >>> #define PHY_INT_AUTONEG_PAGE (1 << 1) >>> +#define IMX_MAX_DESC 1024 >>> + >>> static void imx_fec_update(IMXFECState *s); >>> /* >>> @@ -264,12 +266,12 @@ static void imx_fec_update(IMXFECState *s) >>> static void imx_fec_do_tx(IMXFECState *s) >>> { >>> - int frame_size =3D 0; >>> + int frame_size =3D 0, descnt =3D 0; >>> uint8_t frame[FEC_MAX_FRAME_SIZE]; >>> uint8_t *ptr =3D frame; >>> uint32_t addr =3D s->tx_descriptor; >>> - while (1) { >>> + while (descnt++ < IMX_MAX_DESC) { >>> IMXFECBufDesc bd; >>> int len; >>> >> Reviewed-by: Paolo Bonzini > > Applied, thanks. > Actually the patch does not apply cleanly. Please fix and repost. Thanks