mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Zhijian Li (Fujitsu)" <lizhijian@fujitsu.com>
To: yanjun.zhu <yanjun.zhu@linux.dev>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"zyjzyj2000@gmail.com" <zyjzyj2000@gmail.com>,
	"jgg@ziepe.ca" <jgg@ziepe.ca>,
	"leon@kernel.org" <leon@kernel.org>,
	Yi Zhang <yi.zhang@redhat.com>
Subject: Re: [PATCH RFC v2] RDMA/rxe: Fix iova-to-va conversion for MR page sizes != PAGE_SIZE
Date: Mon, 19 Jan 2026 05:24:50 +0000	[thread overview]
Message-ID: <7134f410-b8bd-4eee-8332-4d4dbccae014@fujitsu.com> (raw)
In-Reply-To: <1bc84ed5-6e06-47fd-a85a-c85ac8cc4118@linux.dev>



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.

  parent reply	other threads:[~2026-01-19  5:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-16  3:27 Li Zhijian
2026-01-16 17:36 ` yanjun.zhu
2026-01-19  2:25   ` Zhu Yanjun
2026-01-19  5:24   ` Zhijian Li (Fujitsu) [this message]
2026-01-25 13:41 ` Leon Romanovsky

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=7134f410-b8bd-4eee-8332-4d4dbccae014@fujitsu.com \
    --to=lizhijian@fujitsu.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=yanjun.zhu@linux.dev \
    --cc=yi.zhang@redhat.com \
    --cc=zyjzyj2000@gmail.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

all inboxes | Powered by JetHome®