From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.68 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796233553; b=TeYv1L7+K3RoRiQU6ZKsw3gzpOxPnug6ucLR+vHtwfxvjzga+4nSATDIkzN/NxSwkY6+ eaVfkILOFQLaA4pn5IP9pQfI/qGUSpZ4vZ749dudYHmsrxYfN8XELS4WTChPaOmGtHx6p Af18hHWVxM0VufaqwCunxG23BmRyAm4kbCsJGoWwnPKncCKnDyfRSO+j7/D6ubb8pUXqf rJChFCPHzGx1kanY9VBpThLx099bXSRoR1AUoq+LrNnDxwFWnPJp9IUPvMnC3cIwx3K6k i5IiYCumCPlYUSxCeeuzFf8tk5pzKTm8jOfwy3AanHyNisB+UsjyVZMbLndcZGkZiLg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796233553; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=Qt1wtWi4gYAOh74rBWZtIY+mSCA1tO7jaNVGome2aes=; b=DBp0MVBx6DWUjL0bXiNDiEQ8wgrqGDHHFhhBD+rK+r3kkE9BWD4q5xb6GaZ9OJN7PLYl 2+Rmh47tYqdYrL5su0srLlRMZ5niKcIvyMfP7474LAKlOUhcPAFN7jELW2Ah01/xEbaux ro39B3ijl14DIVHaenGeO/u2otcUM1sOhqBOwY87Ar+5rGz5aXsh9iBQqdDnpxBG4Suc6 sqKHfgOEyWeS8okioPonnHAgq1Ot0UzYE1TUOTGP7HPbIZjq7zb4oLtOFKmtyvqyWCkSY +kTqtID1m8n9GumjPp75lR1ZlVAftiUWxQBED/AUZzfxmW7JcIwK88D2iDEj3ogTo9w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Sn7bCIp8; arc=none smtp.remote-ip=95.215.58.68 Received: from mta1.migadu.com (out-68.mta1.migadu.com [95.215.58.68]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87DCE606A322 for ; Wed, 2 Dec 2026 17:45:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 87DCE606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Sn7bCIp8 X-Envelope-To: linux-rdma@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=fneg7UIhi5PiyDJ9XzEvz4+GJMcODKihSLBHRTu7Lfo=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796233549; v=1; x=1796838349; b=Sn7bCIp8pMYl98MyNB0sidkKh30CVx9eEt1EYv89Sg1Ay2foeV4FtOnDNg1bnsdZ6dz2SMkE ElbFnHCRYiuDtxaghWd98WB7FzmNRruy/fcGEFug21qpJ6kHZkReTNqYpx61TV409rG2Nk5akQm uBzd95nnpQ32TdjgxPyHeC9c= X-Envelope-To: linux-rdma@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id afecfe00cd6a4e07; Wed, 02 Dec 2026 17:45:49 +0000 X-Mizu-Trace-ID: afecfe00cd6a4e07 X-Migadu-Flow: FLOW_OUT Message-ID: <9729e9b8-bd6a-483c-a8f9-86fbc3b557a7@linux.dev> Date: Wed, 2 Dec 2026 09:45:46 -0800 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH rdma-rc] RDMA/rxe: Bound MR copy and flush chunks to MR pages To: Andrew Stellman , Zhu Yanjun , "yanjun.zhu@linux.dev" Cc: Li Zhijian , Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261128140840.59003-1-bugs@stellman-greene.com> From: Zhu Yanjun In-Reply-To: <20261128140840.59003-1-bugs@stellman-greene.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 在 2026/11/28 6:08, Andrew Stellman 写道: > From: Andrew Stellman > > A fast-reg MR can use 4 KiB pages on a 64 KiB-page kernel, with each > MR page in its own page_info entry. rxe_mr_copy_xarray() limits each > chunk to the end of the system page, not the end of the MR page, so a > copy that crosses an MR-page boundary continues in the same system > page instead of moving to the next page_info entry. > rxe_mr_flush_pmem_iova() has the same bound. > > Limit each chunk to the end of the MR page when MR pages are smaller > than PAGE_SIZE. For MR pages of PAGE_SIZE or larger the bound is > unchanged. > > On arm64 with 64 KiB pages (QEMU TCG, mainline 7cd8495c0f16), a > test-only hook built an MR by hand with two 4 KiB pages at offsets > 0x1000 and 0x3000 of two different system pages and called > rxe_mr_copy() for 32 bytes starting 16 bytes before the MR-page > boundary, checking that the last 16 bytes came from or went to the > second MR page. Without this patch, both the read and the write check > failed. With it, both passed, and they failed again with it reverted. > A 32-byte read within one MR page passed on all three builds. The > flush path was not run. > > The issue was found by Claude Opus 5.5 running Quality Playbook, an > LLM-driven code review tool: > https://github.com/andrewstellman/quality-playbook > The fix was drafted with OpenAI GPT-6 (Codex) and this changelog with > Claude Opus 5.5, and both were reviewed by me. > > Fixes: 12985e5915a0 ("RDMA/rxe: Fix iova-to-va conversion for MR page sizes != PAGE_SIZE") > Signed-off-by: Andrew Stellman Thank you very much. Although this commit does not add variable page size support to RXE, it does address the NVMe issue you mentioned. I have no further comments. LGTM! Reviewed-by: Zhu Yanjun Zhu Yanjun > --- > A reproducer is available on request. > > drivers/infiniband/sw/rxe/rxe_mr.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c > index 13cb28d3916f6e..258f8524ef06b4 100644 > --- a/drivers/infiniband/sw/rxe/rxe_mr.c > +++ b/drivers/infiniband/sw/rxe/rxe_mr.c > @@ -333,12 +333,14 @@ static int rxe_mr_copy_xarray(struct rxe_mr *mr, u64 iova, void *addr, > unsigned long index = rxe_mr_iova_to_index(mr, iova); > struct rxe_mr_page *info = &mr->page_info[index]; > unsigned int page_offset = rxe_mr_iova_to_page_offset(mr, iova); > + unsigned int chunk = min_t(unsigned int, PAGE_SIZE, > + mr_page_size(mr)) - page_offset; > > if (!info->page) > return -EFAULT; > > page_offset += info->offset; > - bytes = min_t(unsigned int, length, PAGE_SIZE - page_offset); > + bytes = min_t(unsigned int, length, chunk); > va = kmap_local_page(info->page); > > if (dir == RXE_FROM_MR_OBJ) > @@ -519,12 +521,14 @@ static int rxe_mr_flush_pmem_iova(struct rxe_mr *mr, u64 iova, unsigned int leng > unsigned long index = rxe_mr_iova_to_index(mr, iova); > struct rxe_mr_page *info = &mr->page_info[index]; > unsigned int page_offset = rxe_mr_iova_to_page_offset(mr, iova); > + unsigned int chunk = min_t(unsigned int, PAGE_SIZE, > + mr_page_size(mr)) - page_offset; > > if (!info->page) > return -EFAULT; > > page_offset += info->offset; > - bytes = min_t(unsigned int, length, PAGE_SIZE - page_offset); > + bytes = min_t(unsigned int, length, chunk); > > va = kmap_local_page(info->page); > arch_wb_cache_pmem(va + page_offset, bytes); -- Best Regards, Yanjun.Zhu