From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org, John Fastabend <john.fastabend@gmail.com>,
virtualization@lists.linux-foundation.org
Subject: [PATCH v2] virtio_net: fix PAGE_SIZE > 64k
Date: Mon, 23 Jan 2017 21:37:52 +0200 [thread overview]
Message-ID: <1485197869-11350-1-git-send-email-mst@redhat.com> (raw)
I don't have any guests with PAGE_SIZE > 64k but the
code seems to be clearly broken in that case
as PAGE_SIZE / MERGEABLE_BUFFER_ALIGN will need
more than 8 bit and so the code in mergeable_ctx_to_buf_address
does not give us the actual true size.
Cc: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
changes from v1:
fix build warnings
drivers/net/virtio_net.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 4a10500..4dc373b 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -48,8 +48,16 @@ module_param(gso, bool, 0444);
*/
DECLARE_EWMA(pkt_len, 1, 64)
+/* With mergeable buffers we align buffer address and use the low bits to
+ * encode its true size. Buffer size is up to 1 page so we need to align to
+ * square root of page size to ensure we reserve enough bits to encode the true
+ * size.
+ */
+#define MERGEABLE_BUFFER_MIN_ALIGN_SHIFT ((PAGE_SHIFT + 1) / 2)
+
/* Minimum alignment for mergeable packet buffers. */
-#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, 256)
+#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, \
+ 1 << MERGEABLE_BUFFER_MIN_ALIGN_SHIFT)
#define VIRTNET_DRIVER_VERSION "1.0.0"
--
MST
next reply other threads:[~2017-01-23 19:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-23 19:37 Michael S. Tsirkin [this message]
2017-01-24 19:42 ` [PATCH v2] virtio_net: fix PAGE_SIZE > 64k David Miller
2017-01-24 19:53 ` Michael S. Tsirkin
2017-01-24 20:09 ` David Miller
[not found] ` <20170124.150959.1708982899683381291.davem@davemloft.net>
2017-01-24 20:45 ` Michael S. Tsirkin
[not found] ` <20170124221114-mutt-send-email-mst@kernel.org>
2017-01-24 20:53 ` David Miller
2017-01-24 21:07 ` Michael S. Tsirkin
2017-01-24 21:10 ` David Miller
[not found] ` <20170124.161046.824400071485171478.davem@davemloft.net>
2017-01-24 21:56 ` Michael S. Tsirkin
2017-01-25 3:48 ` John Fastabend
-- strict thread matches above, loose matches on Subject: below --
2017-01-25 4:07 Alexei Starovoitov
[not found] <CAADnVQ+ioJ7kgsFeFoSV9Nqnq9CkRGMmqS5QM66gsJG01-Rojw@mail.gmail.com>
2017-01-25 14:23 ` Michael S. Tsirkin
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=1485197869-11350-1-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=john.fastabend@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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).