From: Kyo Liu <kyo.liu@nebula-matrix.com>
To: kyo.liu@nebula-matrix.com, dimon.zhao@nebula-matrix.com
Cc: Long Li <longli@microsoft.com>, stable@dpdk.org
Subject: [PATCH v1 05/10] bus/vmbus: align ring buffer data to page boundary
Date: Fri, 25 Apr 2025 02:07:53 +0000 [thread overview]
Message-ID: <20250425020758.3794-5-kyo.liu@nebula-matrix.com> (raw)
In-Reply-To: <20250425020758.3794-1-kyo.liu@nebula-matrix.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.43.0
next parent reply other threads:[~2025-04-25 2:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250425020758.3794-1-kyo.liu@nebula-matrix.com>
2025-04-25 2:07 ` Kyo Liu [this message]
2025-04-25 2:07 ` [PATCH v1 06/10] bus/vmbus: define Hyper-V page size Kyo Liu
2025-04-25 2:07 ` [PATCH v1 07/10] bus/vmbus: use Hyper-V page size for mapping to UIO pages Kyo Liu
2025-04-25 2:07 ` [PATCH v1 08/10] net/netvsc: use Hyper-V page size for the driver Kyo Liu
2025-04-25 2:07 ` [PATCH v1 09/10] net/netvsc: add stats counters from VF Kyo Liu
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=20250425020758.3794-5-kyo.liu@nebula-matrix.com \
--to=kyo.liu@nebula-matrix.com \
--cc=dimon.zhao@nebula-matrix.com \
--cc=longli@microsoft.com \
--cc=stable@dpdk.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).