From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0AA8846623 for ; Fri, 25 Apr 2025 04:08:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B88FA400D7; Fri, 25 Apr 2025 04:08:14 +0200 (CEST) Received: from out28-73.mail.aliyun.com (out28-73.mail.aliyun.com [115.124.28.73]) by mails.dpdk.org (Postfix) with ESMTP id 57CC4400D5 for ; Fri, 25 Apr 2025 04:08:11 +0200 (CEST) Received: from localhost.localdomain(mailfrom:kyo.liu@nebula-matrix.com fp:SMTPD_---.cW5c8H0_1745546889 cluster:ay29) by smtp.aliyun-inc.com; Fri, 25 Apr 2025 10:08:09 +0800 From: Kyo Liu To: kyo.liu@nebula-matrix.com, dimon.zhao@nebula-matrix.com Cc: Long Li , 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 Message-ID: <20250425020758.3794-5-kyo.liu@nebula-matrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250425020758.3794-1-kyo.liu@nebula-matrix.com> References: <20250425020758.3794-1-kyo.liu@nebula-matrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Long Li 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 --- 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