DPDK patches and discussions
 help / color / mirror / Atom feed
From: longli@linuxonhyperv.com
To: Stephen Hemminger <stephen@networkplumber.org>,
	Wei Hu <weh@microsoft.com>
Cc: dev@dpdk.org, Long Li <longli@microsoft.com>, stable@dpdk.org
Subject: [PATCH 1/4] bus/vmbus: Align ring buffer data region to system page boundary
Date: Fri, 18 Apr 2025 12:32:47 -0700	[thread overview]
Message-ID: <1745004770-9795-2-git-send-email-longli@linuxonhyperv.com> (raw)
In-Reply-To: <1745004770-9795-1-git-send-email-longli@linuxonhyperv.com>

From: Long Li <longli@microsoft.com>

The ring buffer data region always starts at the system page boundary
after ring buffer head. The current code assumes the system page size is
4k. This is not always correct.

Fix this by using system page size for addressing ring buffer data.

Fixes: 831dba47bd ("bus/vmbus: add Hyper-V virtual bus support")
Cc: stable@dpdk.org
Signed-off-by: Long Li <longli@microsoft.com>
---
 drivers/bus/vmbus/rte_vmbus_reg.h | 9 +++------
 drivers/bus/vmbus/vmbus_bufring.c | 9 ++++++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/bus/vmbus/rte_vmbus_reg.h b/drivers/bus/vmbus/rte_vmbus_reg.h
index 54a26d12bd..fb7e3043ec 100644
--- a/drivers/bus/vmbus/rte_vmbus_reg.h
+++ b/drivers/bus/vmbus/rte_vmbus_reg.h
@@ -100,14 +100,11 @@ struct __rte_packed_begin vmbus_bufring {
 		uint32_t value;
 	} feature_bits;
 
-	/* Pad it to rte_mem_page_size() so that data starts on page boundary */
-	uint8_t	reserved2[4028];
-
 	/*
-	 * Ring data starts here + RingDataStartOffset
-	 * !!! DO NOT place any fields below this !!!
+	 * This is the end of ring buffer head. The ring buffer data is system
+	 * page aligned and starts at rte_mem_page_size() from the beginning
+	 * of this structure
 	 */
-	uint8_t data[];
 } __rte_packed_end;
 
 /*
diff --git a/drivers/bus/vmbus/vmbus_bufring.c b/drivers/bus/vmbus/vmbus_bufring.c
index c78619dc44..fcb97287dc 100644
--- a/drivers/bus/vmbus/vmbus_bufring.c
+++ b/drivers/bus/vmbus/vmbus_bufring.c
@@ -36,7 +36,10 @@ void vmbus_br_setup(struct vmbus_br *br, void *buf, unsigned int blen)
 {
 	br->vbr = buf;
 	br->windex = br->vbr->windex;
-	br->dsize = blen - sizeof(struct vmbus_bufring);
+
+	/* The ring buffer data starts at the 2nd page of the ring buffer */
+	RTE_VERIFY(blen > rte_mem_page_size());
+	br->dsize = blen - rte_mem_page_size();
 }
 
 /*
@@ -72,7 +75,7 @@ static inline uint32_t
 vmbus_txbr_copyto(const struct vmbus_br *tbr, uint32_t windex,
 		  const void *src0, uint32_t cplen)
 {
-	uint8_t *br_data = tbr->vbr->data;
+	uint8_t *br_data = (uint8_t *)tbr->vbr + rte_mem_page_size();
 	uint32_t br_dsize = tbr->dsize;
 	const uint8_t *src = src0;
 
@@ -170,7 +173,7 @@ static inline uint32_t
 vmbus_rxbr_copyfrom(const struct vmbus_br *rbr, uint32_t rindex,
 		    void *dst0, size_t cplen)
 {
-	const uint8_t *br_data = rbr->vbr->data;
+	const uint8_t *br_data = (uint8_t *)rbr->vbr + rte_mem_page_size();
 	uint32_t br_dsize = rbr->dsize;
 	uint8_t *dst = dst0;
 
-- 
2.34.1


  reply	other threads:[~2025-04-18 19:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-18 19:32 [PATCH 0/4] Fix incorrect page size and address caclulations on systems with 64k (or other) page sizes longli
2025-04-18 19:32 ` longli [this message]
2025-04-18 19:32 ` [PATCH 2/4] bus/vmbus: Define Hyper-V page size longli
2025-04-18 19:32 ` [PATCH 3/4] bus/vmbus: Use Hyper-V page size for mapping to UIO pages longli
2025-04-18 19:32 ` [PATCH 4/4] net/netvsc: Use Hyper-V page size for the driver longli

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=1745004770-9795-2-git-send-email-longli@linuxonhyperv.com \
    --to=longli@linuxonhyperv.com \
    --cc=dev@dpdk.org \
    --cc=longli@microsoft.com \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=weh@microsoft.com \
    /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).