[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7134f410-b8bd-4eee-8332-4d4dbccae014@fujitsu.com>
Date: Mon, 19 Jan 2026 05:24:50 +0000
From: "Zhijian Li (Fujitsu)" <lizhijian@...itsu.com>
To: yanjun.zhu <yanjun.zhu@...ux.dev>, "linux-rdma@...r.kernel.org"
<linux-rdma@...r.kernel.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"zyjzyj2000@...il.com" <zyjzyj2000@...il.com>, "jgg@...pe.ca" <jgg@...pe.ca>,
"leon@...nel.org" <leon@...nel.org>, Yi Zhang <yi.zhang@...hat.com>
Subject: Re: [PATCH RFC v2] RDMA/rxe: Fix iova-to-va conversion for MR page
sizes != PAGE_SIZE
On 17/01/2026 01:36, yanjun.zhu wrote:
> On 1/15/26 7:27 PM, Li Zhijian wrote:
>> The current implementation incorrectly handles memory regions (MRs) with
>> page sizes different from the system PAGE_SIZE. The core issue is that
>> rxe_set_page() is called with mr->page_size step increments, but the
>> page_list stores individual struct page pointers, each representing
>> PAGE_SIZE of memory.
>>
>> ib_sg_to_page() has ensured that when i>=1 either
>> a) SG[i-1].dma_end and SG[i].dma_addr are contiguous
>> or
>> b) SG[i-1].dma_end and SG[i].dma_addr are mr->page_size aligned.
>>
>> This leads to incorrect iova-to-va conversion in scenarios:
>>
>> 1) page_size < PAGE_SIZE (e.g., MR: 4K, system: 64K):
>> ibmr->iova = 0x181800
>> sg[0]: dma_addr=0x181800, len=0x800
>> sg[1]: dma_addr=0x173000, len=0x1000
>>
>> Access iova = 0x181800 + 0x810 = 0x182010
>> Expected VA: 0x173010 (second SG, offset 0x10)
>> Before fix:
>> - index = (0x182010 >> 12) - (0x181800 >> 12) = 1
>> - page_offset = 0x182010 & 0xFFF = 0x10
>> - xarray[1] stores system page base 0x170000
>> - Resulting VA: 0x170000 + 0x10 = 0x170010 (wrong)
>>
>> 2) page_size > PAGE_SIZE (e.g., MR: 64K, system: 4K):
>> ibmr->iova = 0x18f800
>> sg[0]: dma_addr=0x18f800, len=0x800
>> sg[1]: dma_addr=0x170000, len=0x1000
>>
>> Access iova = 0x18f800 + 0x810 = 0x190010
>> Expected VA: 0x170010 (second SG, offset 0x10)
>> Before fix:
>> - index = (0x190010 >> 16) - (0x18f800 >> 16) = 1
>> - page_offset = 0x190010 & 0xFFFF = 0x10
>> - xarray[1] stores system page for dma_addr 0x170000
>> - Resulting VA: system page of 0x170000 + 0x10 = 0x170010 (wrong)
>>
>> Yi Zhang reported a kernel panic[1] years ago related to this defect.
>
> Thanks a lot.
> I am not sure if this problem also occurs on SIW or not.
There is no such issue in SIW.
> If yes, can you also add this fix to SIW?
> If not, can you explain why this problem does not occur on SIW?
The reason is that SIW handles IB_MR_TYPE_USER and IB_MR_TYPE_MEM_REG differently.
For IB_MR_TYPE_USER, it stores its pages into the page[] array, and the page_size for IB_MR_TYPE_USER always matches the system's PAGE_SIZE.
For IB_MR_TYPE_MEM_REG, it stores the DMA address directly.
Therefore, theoretically, SIW can correctly handle any mr->page_size for IB_MR_TYPE_MEM_REG MRs.
Thanks
Zhijian
>
> I am just curious about this.
Powered by blists - more mailing lists