From: Jason Wang <jasowang@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-devel@nongnu.org
Cc: Prasad J Pandit <pjp@fedoraproject.org>,
Helge Deller <deller@gmx.de>, Li Qiang <liq3ea@gmail.com>,
Li Qiang <pangpei.lq@antfin.com>,
Sven Schnelle <svens@stackframe.org>,
Ziming Zhang <ezrakiez@gmail.com>
Subject: Re: [RFC PATCH 3/3] hw/net/tulip: Set descriptor error bit when lenght is incorrect
Date: Fri, 24 Apr 2020 10:16:42 +0800 [thread overview]
Message-ID: <606d1218-79ce-3fd5-5400-1a5ece8f183f@redhat.com> (raw)
In-Reply-To: <20200423231644.15786-4-f4bug@amsat.org>
On 2020/4/24 上午7:16, Philippe Mathieu-Daudé wrote:
> When a frame lenght is incorrect, set the RDES0 'Error Summary'
> and 'Frame too long' bits. Then stop the receive process and
> trigger an abnormal interrupt. See [4.3.5 Receive Process].
>
> Cc: Li Qiang <liq3ea@gmail.com>
> Cc: Li Qiang <pangpei.lq@antfin.com>
> Cc: Ziming Zhang <ezrakiez@gmail.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Prasad J Pandit <pjp@fedoraproject.org>
> Fixes: 8ffb7265af ("check frame size and r/w data length")
> Buglink: https://bugs.launchpad.net/bugs/1874539
> Reported-by: Helge Deller <deller@gmx.de>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Hi Philippe:
It's still unclear to me that how this fixes the stuck. Did you mean
guest trigger the error condition and then recvoer by abnormal interrupt?
If yes, this sounds still like a bug somewhere in the code.
Thanks
> ---
> hw/net/tulip.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/hw/net/tulip.c b/hw/net/tulip.c
> index 470f635acb..671f79b6f4 100644
> --- a/hw/net/tulip.c
> +++ b/hw/net/tulip.c
> @@ -158,7 +158,7 @@ static void tulip_next_rx_descriptor(TULIPState *s,
> s->current_rx_desc &= ~3ULL;
> }
>
> -static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
> +static int tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
> {
> int len1 = (desc->control >> RDES1_BUF1_SIZE_SHIFT) & RDES1_BUF1_SIZE_MASK;
> int len2 = (desc->control >> RDES1_BUF2_SIZE_SHIFT) & RDES1_BUF2_SIZE_MASK;
> @@ -177,7 +177,8 @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
> "(ofs: %u, len:%d, size:%zu)\n",
> __func__, s->rx_frame_len, len,
> sizeof(s->rx_frame));
> - return;
> + s->rx_frame_len = 0;
> + return -1;
> }
> pci_dma_write(&s->dev, desc->buf_addr1, s->rx_frame +
> (s->rx_frame_size - s->rx_frame_len), len);
> @@ -197,12 +198,15 @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
> "(ofs: %u, len:%d, size:%zu)\n",
> __func__, s->rx_frame_len, len,
> sizeof(s->rx_frame));
> - return;
> + s->rx_frame_len = 0;
> + return -1;
> }
> pci_dma_write(&s->dev, desc->buf_addr2, s->rx_frame +
> (s->rx_frame_size - s->rx_frame_len), len);
> s->rx_frame_len -= len;
> }
> +
> + return 0;
> }
>
> static bool tulip_filter_address(TULIPState *s, const uint8_t *addr)
> @@ -274,7 +278,11 @@ static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
> s->rx_frame_len = s->rx_frame_size;
> }
>
> - tulip_copy_rx_bytes(s, &desc);
> + if (tulip_copy_rx_bytes(s, &desc)) {
> + desc.status |= RDES0_ES | RDES0_TL; /* Error: frame too long */
> + s->csr[5] |= CSR5_RPS; /* Receive process stopped */
> + tulip_update_int(s);
> + }
>
> if (!s->rx_frame_len) {
> desc.status |= s->rx_status;
next prev parent reply other threads:[~2020-04-24 2:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-23 23:16 [RFC PATCH 0/3] hw/net/tulip: Fix LP#1874539 Philippe Mathieu-Daudé
2020-04-23 23:16 ` [RFC PATCH 1/3] hw/net/tulip: Fix 'Descriptor Error' definition Philippe Mathieu-Daudé
2020-04-23 23:16 ` [RFC PATCH 2/3] hw/net/tulip: Log descriptor overflows Philippe Mathieu-Daudé
2020-04-23 23:16 ` [RFC PATCH 3/3] hw/net/tulip: Set descriptor error bit when lenght is incorrect Philippe Mathieu-Daudé
2020-04-24 2:16 ` Jason Wang [this message]
2020-04-24 13:42 ` Helge Deller
2020-04-24 14:26 ` Eric Blake
2020-04-24 15:27 ` [RFC PATCH 0/3] hw/net/tulip: Fix LP#1874539 Helge Deller
2020-04-26 2:49 ` Jason Wang
2020-04-26 7:57 ` Peter Maydell
2020-04-27 3:32 ` Jason Wang
2020-05-12 7:13 ` Philippe Mathieu-Daudé
2020-05-13 2:18 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=606d1218-79ce-3fd5-5400-1a5ece8f183f@redhat.com \
--to=jasowang@redhat.com \
--cc=deller@gmx.de \
--cc=ezrakiez@gmail.com \
--cc=f4bug@amsat.org \
--cc=liq3ea@gmail.com \
--cc=pangpei.lq@antfin.com \
--cc=pjp@fedoraproject.org \
--cc=qemu-devel@nongnu.org \
--cc=svens@stackframe.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).