Skip to contentSkip to conversation

BUG: bad page map under Xen

DISCUSSION Lukas Hejtmanek 12 participants 40 messages Oct 21, 2013 – Jan 2, 2014 15 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Hello,

I'm trying to get SR-IOV working under Xen (4.2). It almost works except memory bug. This is easily reproducible just in Dom0.

I have Connect-X3 card with the latest firmware. OFED 2.0-3 drivers. I tried 3.2 kernel from Debian, 3.10 kernel from Debian and vanila 3.11.5 kernel. All are the same.

As soon as I issue ibv_devinfo command, it produces the following messages into dmesg. Problem is that with ib_rdma_bw command, I get more of those messages and moreover, oom killer gets confused and kills almost all processes.

[23502.645455] mlx4_core 0000:06:00.0: mlx4_ib: Port 1 logical link is up
[23550.181907] <mlx4_ib> check_flow_steering_support: Device managed flow steering is unavailable for IB port in multifunction env.
[23550.183822] swap_free: Unused swap offset entry 00000001
[23550.183868] BUG: Bad page map in process ibv_devinfo  pte:00000200 pmd:1b7df4067
[23550.183939] addr:00007f7ef5e18000 vm_flags:400844fa anon_vma:          (null) mapping:ffff8801b83c0480 index:380fe0882
[23550.184022] vma->vm_file->f_op->mmap: ib_uverbs_mmap+0x0/0x2d [ib_uverbs]
[23550.195382] Pid: 13813, comm: ibv_devinfo Tainted: G           O 3.2.0-0.bpo.4-amd64 #1 Debian 3.2.41-2+deb7u2~bpo60+1+zs4
[23550.195461] Call Trace:
[23550.195508]  [<ffffffff810d9009>] ? print_bad_pte+0x1f5/0x20d
[23550.195553]  [<ffffffff810db083>] ? unmap_vmas+0x5fe/0x814
[23550.195601]  [<ffffffff810c68dd>] ? __add_page_to_lru_list+0x53/0x53
[23550.195647]  [<ffffffff810df2de>] ? unmap_region+0x9f/0x102
[23550.195694]  [<ffffffff8100d722>] ? __switch_to+0x23b/0x2b1
[23550.195741]  [<ffffffff8103d870>] ? pick_next_task_fair+0xfc/0x10c
[23550.195788]  [<ffffffff810463a2>] ? finish_task_switch+0x53/0xc7
[23550.195832]  [<ffffffff810e01f7>] ? do_munmap+0x281/0x2eb
[23550.195875]  [<ffffffff810e02a0>] ? sys_munmap+0x3f/0x55
[23550.195921]  [<ffffffff8136e51c>] ? system_call_fastpath+0x16/0x1b
[23550.195965] Disabling lock debugging due to kernel taint
[23550.196412] <mlx4_ib> check_flow_steering_support: Device managed flow steering is unavailable for IB port in multifunction env.
[23550.198303] swap_free: Unused swap offset entry 00000001
[23550.198348] BUG: Bad page map in process ibv_devinfo  pte:00000200 pmd:1b7df4067
[23550.198424] addr:00007f7ef5e18000 vm_flags:400844fa anon_vma:          (null) mapping:ffff8801b83c09a0 index:380fe0082
[23550.198508] vma->vm_file->f_op->mmap: ib_uverbs_mmap+0x0/0x2d [ib_uverbs]
[23550.198558] Pid: 13813, comm: ibv_devinfo Tainted: G    B      O 3.2.0-0.bpo.4-amd64 #1 Debian 3.2.41-2+deb7u2~bpo60+1+zs4
[23550.198637] Call Trace:
[23550.198680]  [<ffffffff810d9009>] ? print_bad_pte+0x1f5/0x20d
[23550.198730]  [<ffffffff810db083>] ? unmap_vmas+0x5fe/0x814
[23550.198775]  [<ffffffff810c68dd>] ? __add_page_to_lru_list+0x53/0x53
[23550.198820]  [<ffffffff810df2de>] ? unmap_region+0x9f/0x102
[23550.198865]  [<ffffffff8100d6b0>] ? __switch_to+0x1c9/0x2b1
[23550.198913]  [<ffffffff8103d870>] ? pick_next_task_fair+0xfc/0x10c
[23550.198959]  [<ffffffff810463a2>] ? finish_task_switch+0x53/0xc7
[23550.199005]  [<ffffffff810e01f7>] ? do_munmap+0x281/0x2eb
[23550.199052]  [<ffffffff810e02a0>] ? sys_munmap+0x3f/0x55
[23550.199096]  [<ffffffff8136e51c>] ? system_call_fastpath+0x16/0x1b
[23550.199766] <mlx4_ib> check_flow_steering_support: Device managed flow steering is unavailable for IB port in multifunction env.
[23550.201661] swap_free: Unused swap offset entry 00000001
[23550.201706] BUG: Bad page map in process ibv_devinfo  pte:00000200 pmd:1b7df4067
[23550.201776] addr:00007f7ef5e18000 vm_flags:400844fa anon_vma:          (null) mapping:ffff8801b83c0ec0 index:380fdf882
[23550.201861] vma->vm_file->f_op->mmap: ib_uverbs_mmap+0x0/0x2d [ib_uverbs]
[23550.201908] Pid: 13813, comm: ibv_devinfo Tainted: G    B      O 3.2.0-0.bpo.4-amd64 #1 Debian 3.2.41-2+deb7u2~bpo60+1+zs4
[23550.201990] Call Trace:
[23550.202032]  [<ffffffff810d9009>] ? print_bad_pte+0x1f5/0x20d
[23550.202081]  [<ffffffff810db083>] ? unmap_vmas+0x5fe/0x814
[23550.202125]  [<ffffffff810df2de>] ? unmap_region+0x9f/0x102
[23550.202169]  [<ffffffff8100d6b0>] ? __switch_to+0x1c9/0x2b1
[23550.202217]  [<ffffffff8103d870>] ? pick_next_task_fair+0xfc/0x10c
[23550.202267]  [<ffffffff810463a2>] ? finish_task_switch+0x53/0xc7
[23550.202312]  [<ffffffff810e01f7>] ? do_munmap+0x281/0x2eb
[23550.202355]  [<ffffffff810e02a0>] ? sys_munmap+0x3f/0x55
[23550.202398]  [<ffffffff8136e51c>] ? system_call_fastpath+0x16/0x1b
[23550.202925] <mlx4_ib> check_flow_steering_support: Device managed flow steering is unavailable for IB port in multifunction env.
[23550.213336] swap_free: Unused swap offset entry 00000001
[23550.213377] BUG: Bad page map in process ibv_devinfo  pte:00000200 pmd:1b7df4067
[23550.213448] addr:00007f7ef5e18000 vm_flags:400844fa anon_vma:          (null) mapping:ffff8801b6bd8ec0 index:380fdf082
[23550.213527] vma->vm_file->f_op->mmap: ib_uverbs_mmap+0x0/0x2d [ib_uverbs]
[23550.213573] Pid: 13813, comm: ibv_devinfo Tainted: G    B      O 3.2.0-0.bpo.4-amd64 #1 Debian 3.2.41-2+deb7u2~bpo60+1+zs4
[23550.213651] Call Trace:
[23550.213775]  [<ffffffff810d9009>] ? print_bad_pte+0x1f5/0x20d
[23550.213820]  [<ffffffff810db083>] ? unmap_vmas+0x5fe/0x814
[23550.213863]  [<ffffffff810df2de>] ? unmap_region+0x9f/0x102
[23550.213907]  [<ffffffff8100d6b0>] ? __switch_to+0x1c9/0x2b1
[23550.213951]  [<ffffffff8103d870>] ? pick_next_task_fair+0xfc/0x10c
[23550.213996]  [<ffffffff810463a2>] ? finish_task_switch+0x53/0xc7
[23550.214041]  [<ffffffff810e01f7>] ? do_munmap+0x281/0x2eb
[23550.214084]  [<ffffffff810e02a0>] ? sys_munmap+0x3f/0x55
[23550.214127]  [<ffffffff8136e51c>] ? system_call_fastpath+0x16/0x1b
[23550.214461] <mlx4_ib> check_flow_steering_support: Device managed flow steering is unavailable for IB port in multifunction env.
[23550.215924] swap_free: Unused swap offset entry 00000001
[23550.215974] BUG: Bad page map in process ibv_devinfo  pte:00000200 pmd:1b7df4067
[23550.216049] addr:00007f7ef5e18000 vm_flags:400844fa anon_vma:          (null) mapping:ffff8801b8f381f0 index:380fff085
[23550.216133] vma->vm_file->f_op->mmap: ib_uverbs_mmap+0x0/0x2d [ib_uverbs]
[23550.216184] Pid: 13813, comm: ibv_devinfo Tainted: G    B      O 3.2.0-0.bpo.4-amd64 #1 Debian 3.2.41-2+deb7u2~bpo60+1+zs4
[23550.216267] Call Trace:
[23550.216306]  [<ffffffff810d9009>] ? print_bad_pte+0x1f5/0x20d
[23550.216351]  [<ffffffff810db083>] ? unmap_vmas+0x5fe/0x814
[23550.216395]  [<ffffffff810df2de>] ? unmap_region+0x9f/0x102
[23550.216443]  [<ffffffff8100d6b0>] ? __switch_to+0x1c9/0x2b1
[23550.216487]  [<ffffffff8103d870>] ? pick_next_task_fair+0xfc/0x10c
[23550.216532]  [<ffffffff810463a2>] ? finish_task_switch+0x53/0xc7
[23550.216581]  [<ffffffff810e01f7>] ? do_munmap+0x281/0x2eb
[23550.216628]  [<ffffffff810e02a0>] ? sys_munmap+0x3f/0x55
[23550.216677]  [<ffffffff8136e51c>] ? system_call_fastpath+0x16/0x1b
[23550.216728] swap_free: Unused swap offset entry 00000001
[23550.216777] BUG: Bad page map in process ibv_devinfo  pte:00000200 pmd:1b7df4067
[23550.216846] addr:00007f7ef5e16000 vm_flags:400844fa anon_vma:          (null) mapping:ffff8801b8f381f0 index:380fff485
[23550.216925] vma->vm_file->f_op->mmap: ib_uverbs_mmap+0x0/0x2d [ib_uverbs]
[23550.216980] Pid: 13813, comm: ibv_devinfo Tainted: G    B      O 3.2.0-0.bpo.4-amd64 #1 Debian 3.2.41-2+deb7u2~bpo60+1+zs4
[23550.217077] Call Trace:
[23550.217124]  [<ffffffff810d9009>] ? print_bad_pte+0x1f5/0x20d
[23550.217169]  [<ffffffff810db083>] ? unmap_vmas+0x5fe/0x814
[23550.217212]  [<ffffffff810df2de>] ? unmap_region+0x9f/0x102
[23550.217256]  [<ffffffff8100d6b0>] ? __switch_to+0x1c9/0x2b1
[23550.217300]  [<ffffffff8103d870>] ? pick_next_task_fair+0xfc/0x10c
[23550.217349]  [<ffffffff810e01f7>] ? do_munmap+0x281/0x2eb
[23550.217396]  [<ffffffff810e02a0>] ? sys_munmap+0x3f/0x55
[23550.217443]  [<ffffffff8136e51c>] ? system_call_fastpath+0x16/0x1b

this happens only if running under Xen. Native kernel in the same version is OK.

Is it a known bug or is something wrong with BIOS/firmware?

Signature · 1 line
Lukáš Hejtmánek

A message that is not in the archive (sent off-list or not yet received): 20131021115740.GN20913-8qz54MUs51PtwjQa/[email protected]

#2 lore raw
Quoted 8 lines · Lukas Hejtmanek

Hello,

I'm trying to get SR-IOV working under Xen (4.2). It almost works except memory bug. This is easily reproducible just in Dom0.

I have Connect-X3 card with the latest firmware. OFED 2.0-3 drivers. I tried 3.2 kernel from Debian, 3.10 kernel from Debian and vanila 3.11.5 kernel. All are the same.

Ha! Funny you mention that. I had been looking at this.

Quoted 28 lines

As soon as I issue ibv_devinfo command, it produces the following messages into dmesg. Problem is that with ib_rdma_bw command, I get more of those messages and moreover, oom killer gets confused and kills almost all processes.

[23502.645455] mlx4_core 0000:06:00.0: mlx4_ib: Port 1 logical link is up
[23550.181907] <mlx4_ib> check_flow_steering_support: Device managed flow steering is unavailable for IB port in multifunction env.
[23550.183822] swap_free: Unused swap offset entry 00000001
[23550.183868] BUG: Bad page map in process ibv_devinfo  pte:00000200 pmd:1b7df4067
[23550.183939] addr:00007f7ef5e18000 vm_flags:400844fa anon_vma:          (null) mapping:ffff8801b83c0480 index:380fe0882
[23550.184022] vma->vm_file->f_op->mmap: ib_uverbs_mmap+0x0/0x2d [ib_uverbs]
[23550.195382] Pid: 13813, comm: ibv_devinfo Tainted: G           O 3.2.0-0.bpo.4-amd64 #1 Debian 3.2.41-2+deb7u2~bpo60+1+zs4
[23550.195461] Call Trace:
[23550.195508]  [<ffffffff810d9009>] ? print_bad_pte+0x1f5/0x20d
[23550.195553]  [<ffffffff810db083>] ? unmap_vmas+0x5fe/0x814
[23550.195601]  [<ffffffff810c68dd>] ? __add_page_to_lru_list+0x53/0x53
[23550.195647]  [<ffffffff810df2de>] ? unmap_region+0x9f/0x102
[23550.195694]  [<ffffffff8100d722>] ? __switch_to+0x23b/0x2b1
[23550.195741]  [<ffffffff8103d870>] ? pick_next_task_fair+0xfc/0x10c
[23550.195788]  [<ffffffff810463a2>] ? finish_task_switch+0x53/0xc7
[23550.195832]  [<ffffffff810e01f7>] ? do_munmap+0x281/0x2eb
[23550.195875]  [<ffffffff810e02a0>] ? sys_munmap+0x3f/0x55
[23550.195921]  [<ffffffff8136e51c>] ? system_call_fastpath+0x16/0x1b
[23550.195965] Disabling lock debugging due to kernel taint
[23550.196412] <mlx4_ib> check_flow_steering_support: Device managed flow steering is unavailable for IB port in multifunction env.
[23550.198303] swap_free: Unused swap offset entry 00000001
[23550.198348] BUG: Bad page map in process ibv_devinfo  pte:00000200 pmd:1b7df4067
[23550.198424] addr:00007f7ef5e18000 vm_flags:400844fa anon_vma:          (null) mapping:ffff8801b83c09a0 index:380fe0082

..

Quoted 4 lines

this happens only if running under Xen. Native kernel in the same version is OK.

Is it a known bug or is something wrong with BIOS/firmware?

It is a bug in the drivers I believe. The issue is that the mapping created for the second mmap call is done without VM_IO and on an PFN that is RAM (and not the BAR). But I am not entirely sure and hopefully this week will have a better idea and fix. Stay tuned.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 4 lines
Quoted 1 line
Quoted 1 line · konrad wilk

It is a bug in the drivers I believe. The issue is that the mapping created for the second mmap
call is done without VM_IO and on an PFN that is RAM (and not the BAR).

So while putting together the reply that I had sent to Lukas a minute ago I was actually hunting for that VM_IO -> _PAGE_IOMAP translation, and wasn't able to find it anywhere. As you say it nevertheless exists - what am I overlooking (and why would then pci_mmap_page_range() nevertheless have to set _PAGE_IOMAP by hand)?

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 526545E002000078000FC5F1-ce6RLXgGx+vWGUEhTRrCg1aTQe2KTcn/@public.gmane.org

#6 lore raw
Quoted 10 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · konrad wilk

It is a bug in the drivers I believe. The issue is that the mapping created for the second mmap
call is done without VM_IO and on an PFN that is RAM (and not the BAR).

So while putting together the reply that I had sent to Lukas a minute ago I was actually hunting for that VM_IO -> _PAGE_IOMAP translation, and wasn't able to find it anywhere. As you say it nevertheless exists - what am I overlooking (and why would then pci_mmap_page_range() nevertheless have to set _PAGE_IOMAP by hand)?

The P2M (arch/x86/xen/p2m.c) is consulted which for the MMIO gaps and E820_RESV has the MFNs set to the PFN. This is the 1-1 pfn/mfn stuff that I implemented some time ago - as hpa was opposed to having the _PAGE_IOMAP being stuck on any macro call to pgprot_writecombine|noncached|etc. Or perhaps that was on the arch_something_prot.

Anyhow, the odd thing is that looking at the code:

669 if (io_remap_pfn_range(vma, vma->vm_start,
670 to_mucontext(context)->uar.pfn +
671 dev->dev->caps.num_uars,
672 PAGE_SIZE, vma->vm_page_prot))

The PFN in question (uar.pfn) is in mlx4_uar_alloc is set to:

159 uar->pfn = (pci_resource_start(dev->pdev, 2) >> PAGE_SHIFT) + offset;

So is the BAR not in the MMIO region? Or is it the 64-bit type MMIO that lays outside the 4GB and hence when the P2M is consulted it thinks its INVALID_P2M_ENTRY?

Which comes back to the bug you (Jan) discovered when you pointed out that PVH needs to setup MMIO entries for 64-bit MMIO regions which can be outside the 4GB region <sigh>. And that is something the pvops kernel completly ignores as it assumes that any region past the E820 can be used for ballooning.

Anyhow, one easy thing to figure out is to get the lspci -v output from the InfiniBand card to see where its BARs are, and also the start of the kernel. You should see an E820 map (please also boot with "debug" on the Linux command line).

Quoted 2 lines

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 13 lines · konrad wilk
Quoted 10 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · konrad wilk

It is a bug in the drivers I believe. The issue is that the mapping created for the second mmap
call is done without VM_IO and on an PFN that is RAM (and not the BAR).

So while putting together the reply that I had sent to Lukas a minute ago I was actually hunting for that VM_IO -> _PAGE_IOMAP translation, and wasn't able to find it anywhere. As you say it nevertheless exists - what am I overlooking (and why would then pci_mmap_page_range() nevertheless have to set _PAGE_IOMAP by hand)?

Quoted 4 lines

The P2M (arch/x86/xen/p2m.c) is consulted which for the MMIO gaps and E820_RESV has the MFNs set to the PFN. This is the 1-1 pfn/mfn stuff that I implemented some time ago - as hpa was opposed to having the _PAGE_IOMAP being stuck on any macro call to pgprot_writecombine|noncached|etc. Or perhaps that was on the arch_something_prot.

This is the one that Jeremy cooked up some time ago:
http://lkml.indiana.edu/hypermail/linux/kernel/1010.2/03012.html

And here was the thread:
http://www.spinics.net/lists/linux-rdma/msg07085.html

which I thought had been fixed by the P2M identity code.

Quoted 16 lines

Anyhow, the odd thing is that looking at the code:

669 if (io_remap_pfn_range(vma, vma->vm_start,
670 to_mucontext(context)->uar.pfn +
671 dev->dev->caps.num_uars,
672 PAGE_SIZE,
vma->vm_page_prot))

The PFN in question (uar.pfn) is in mlx4_uar_alloc is set to:

159 uar->pfn = (pci_resource_start(dev->pdev, 2) >> PAGE_SHIFT) + offset;

So is the BAR not in the MMIO region? Or is it the 64-bit type MMIO that lays outside the 4GB and hence when the P2M is consulted it thinks its INVALID_P2M_ENTRY?

Quoted 11 lines

Which comes back to the bug you (Jan) discovered when you pointed out that PVH needs to setup MMIO entries for 64-bit MMIO regions which can be outside the 4GB region <sigh>. And that is something the pvops kernel completly ignores as it assumes that any region past the E820 can be used for ballooning.

Anyhow, one easy thing to figure out is to get the lspci -v output from the InfiniBand card to see where its BARs are, and also the start of the kernel. You should see an E820 map (please also boot with "debug" on the Linux command line).

Quoted 2 lines

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw
In reply to a message not in the archive
Quoted 5 lines · konrad wilk

Anyhow, one easy thing to figure out is to get the lspci -v output from the InfiniBand card
to see where its BARs are, and also the start of the kernel. You should see an E820 map (please also boot with
"debug" on the Linux command line).

note, adding _PAGE_IO as Jan suggested fixed those mem errors.

here is lspci from the card and its virtual functions.

06:00.0 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3]
Subsystem: Mellanox Technologies Device 0017
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 42
Region 0: Memory at dfa00000 (64-bit, non-prefetchable) [size=1M]
Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]
Expansion ROM at df900000 [disabled] [size=1M]
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [48] Vital Product Data
Product Name: CX353A - ConnectX-3 QSFP
Read-only fields:
[PN] Part number: MCX353A-QCBT
[EC] Engineering changes: A4
[SN] Serial number: MT1327X00814
[V0] Vendor specific: PCIe Gen3 x8
[RV] Reserved: checksum good, 0 byte(s) reserved
Read/write fields:
[V1] Vendor specific: N/A
[YA] Asset tag: N/A
[RW] Read-write area: 105 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 252 byte(s) free
End
Capabilities: [9c] MSI-X: Enable+ Count=128 Masked-
Vector table: BAR=0 offset=0007c000
PBA: BAR=0 offset=0007d000
Capabilities: [60] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 unlimited
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset+
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset-
MaxPayload 256 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #8, Speed 8GT/s, Width x8, ASPM L0s, Latency L0 unlimited, L1 unlimited
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 8GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-
LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete+, EqualizationPhase1+
EqualizationPhase2+, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [100 v1] Alternative Routing-ID Interpretation (ARI)
ARICap: MFVC- ACS-, Next Function: 0
ARICtl: MFVC- ACS-, Function Group: 0
Capabilities: [148 v1] Device Serial Number 00-02-c9-03-00-b6-fc-70
Capabilities: [108 v1] Single Root I/O Virtualization (SR-IOV)
IOVCap: Migration-, Interrupt Message Number: 000
IOVCtl: Enable+ Migration- Interrupt- MSE+ ARIHierarchy+
IOVSta: Migration-
Initial VFs: 64, Total VFs: 64, Number of VFs: 4, Function Dependency Link: 00 VF offset: 1, stride: 1, Device ID: 1004
Supported Page Size: 000007ff, System Page Size: 00000001
Region 2: Memory at 0000380fdf000000 (64-bit, prefetchable)
VF Migration: offset: 00000000, BIR: 0
Capabilities: [154 v2] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq+ ACSViol-
UESvrt: DLP+ SDES- TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
Capabilities: [18c v1] #19
Kernel driver in use: mlx4_core

06:00.1 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]
Subsystem: Mellanox Technologies Device 61b0
Control: I/O- Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Region 2: [virtual] Memory at 380fdf000000 (64-bit, prefetchable) [size=8M]
Capabilities: [60] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset+
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM unknown, Latency L0 <64ns, L1 <1us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed unknown, Width x0, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [9c] MSI-X: Enable+ Count=4 Masked-
Vector table: BAR=2 offset=00002000
PBA: BAR=2 offset=00003000
Kernel driver in use: mlx4_core

06:00.2 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]
Subsystem: Mellanox Technologies Device 61b0
Control: I/O- Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Region 2: [virtual] Memory at 380fdf800000 (64-bit, prefetchable) [size=8M]
Capabilities: [60] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset+
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM unknown, Latency L0 <64ns, L1 <1us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed unknown, Width x0, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [9c] MSI-X: Enable+ Count=4 Masked-
Vector table: BAR=2 offset=00002000
PBA: BAR=2 offset=00003000
Kernel driver in use: mlx4_core

06:00.3 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]
Subsystem: Mellanox Technologies Device 61b0
Control: I/O- Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Region 2: [virtual] Memory at 380fe0000000 (64-bit, prefetchable) [size=8M]
Capabilities: [60] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset+
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM unknown, Latency L0 <64ns, L1 <1us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed unknown, Width x0, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [9c] MSI-X: Enable+ Count=4 Masked-
Vector table: BAR=2 offset=00002000
PBA: BAR=2 offset=00003000
Kernel driver in use: mlx4_core

06:00.4 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]
Subsystem: Mellanox Technologies Device 61b0
Control: I/O- Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Region 2: [virtual] Memory at 380fe0800000 (64-bit, prefetchable) [size=8M]
Capabilities: [60] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset+
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM unknown, Latency L0 <64ns, L1 <1us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed unknown, Width x0, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [9c] MSI-X: Enable+ Count=4 Masked-
Vector table: BAR=2 offset=00002000
PBA: BAR=2 offset=00003000
Kernel driver in use: mlx4_core

and this is from dmesg:

[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] Xen: [mem 0x0000000000000000-0x0000000000090fff] usable
[    0.000000] Xen: [mem 0x0000000000091800-0x00000000000fffff] reserved
[    0.000000] Xen: [mem 0x0000000000100000-0x000000007dd76fff] usable
[    0.000000] Xen: [mem 0x000000007dd77000-0x000000007ddb5fff] reserved
[    0.000000] Xen: [mem 0x000000007ddb6000-0x000000007debefff] ACPI data
[    0.000000] Xen: [mem 0x000000007debf000-0x000000007e0dafff] ACPI NVS
[    0.000000] Xen: [mem 0x000000007e0db000-0x000000007f357fff] reserved
[    0.000000] Xen: [mem 0x000000007f358000-0x000000007f7fffff] ACPI NVS
[    0.000000] Xen: [mem 0x0000000080000000-0x000000008fffffff] reserved
[    0.000000] Xen: [mem 0x00000000fec00000-0x00000000fec01fff] reserved
[    0.000000] Xen: [mem 0x00000000fec40000-0x00000000fec40fff] reserved
[    0.000000] Xen: [mem 0x00000000fed1c000-0x00000000fed3ffff] reserved
[    0.000000] Xen: [mem 0x00000000fee00000-0x00000000fee00fff] reserved
[    0.000000] Xen: [mem 0x00000000ff000000-0x00000000ffffffff] reserved
[    0.000000] Xen: [mem 0x0000000100000000-0x000000107fffffff] usable
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
[    0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable
[    0.000000] e820: last_pfn = 0x1080000 max_arch_pfn = 0x400000000
[    0.000000] e820: last_pfn = 0x7dd77 max_arch_pfn = 0x400000000
[    0.000000] e820: [mem 0x90000000-0xfebfffff] available for PCI devices
[   23.917733] PCI: MMCONFIG at [mem 0x80000000-0x8fffffff] reserved in E820
[   24.587366] e820: reserve RAM buffer [mem 0x00091000-0x0009ffff]
[   24.587468] e820: reserve RAM buffer [mem 0x7dd77000-0x7fffffff]

do you need anything else?

Signature · 5 lines
Lukáš Hejtmánek
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw
Quoted 8 lines · Lukas Hejtmanek
Quoted 5 lines · konrad wilk

Anyhow, one easy thing to figure out is to get the lspci -v output from the InfiniBand card
to see where its BARs are, and also the start of the kernel. You should see an E820 map (please also boot with
"debug" on the Linux command line).

note, adding _PAGE_IO as Jan suggested fixed those mem errors.

<nods> Right.

Quoted 11 lines

here is lspci from the card and its virtual functions.

06:00.0 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3]
Subsystem: Mellanox Technologies Device 0017
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 42
Region 0: Memory at dfa00000 (64-bit, non-prefetchable) [size=1M]
Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

Wow.

Quoted 6 lines

06:00.1 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]
Subsystem: Mellanox Technologies Device 61b0
Control: I/O- Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Region 2: [virtual] Memory at 380fdf000000 (64-bit, prefetchable) [size=8M]

Wow again.

.. snip..

Quoted 18 lines

and this is from dmesg:

[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] Xen: [mem 0x0000000000000000-0x0000000000090fff] usable
[    0.000000] Xen: [mem 0x0000000000091800-0x00000000000fffff] reserved
[    0.000000] Xen: [mem 0x0000000000100000-0x000000007dd76fff] usable
[    0.000000] Xen: [mem 0x000000007dd77000-0x000000007ddb5fff] reserved
[    0.000000] Xen: [mem 0x000000007ddb6000-0x000000007debefff] ACPI data
[    0.000000] Xen: [mem 0x000000007debf000-0x000000007e0dafff] ACPI NVS
[    0.000000] Xen: [mem 0x000000007e0db000-0x000000007f357fff] reserved
[    0.000000] Xen: [mem 0x000000007f358000-0x000000007f7fffff] ACPI NVS
[    0.000000] Xen: [mem 0x0000000080000000-0x000000008fffffff] reserved
[    0.000000] Xen: [mem 0x00000000fec00000-0x00000000fec01fff] reserved
[    0.000000] Xen: [mem 0x00000000fec40000-0x00000000fec40fff] reserved
[    0.000000] Xen: [mem 0x00000000fed1c000-0x00000000fed3ffff] reserved
[    0.000000] Xen: [mem 0x00000000fee00000-0x00000000fee00fff] reserved
[    0.000000] Xen: [mem 0x00000000ff000000-0x00000000ffffffff] reserved
[    0.000000] Xen: [mem 0x0000000100000000-0x000000107fffffff] usable

Odd, there should be messages about 1-1 mapping when you use 'debug'.

But either way - the problem (bug) is what I suspected - we treat any region past the E820 as INVALID_P2M_ENTRY and hence doing any set_pte(..) operations will fetch an 0 value, which in turn means that the PTE is zero (with the 0x200 _PAGE_SPECIAL b/c of VMA tracking).

Now the fix is to determine _where_ the end of real memory is so that we can make sure that ballooning will work (in case of dom0_mem_max parameter). And then anything past that PFN can be treated as IDENTITY_FRAME.

Naively, I think this patch would do it:

arch/x86/xen/setup.c +3 -0
index 09f3059..3871554 100644
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
                __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
        }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));
 }
 
 static unsigned long __init xen_do_chunk(unsigned long start,

But this is not even compile tested :-(

A message that is not in the archive (sent off-list or not yet received): 20131021141855.GA4211-6K5HmflnPlqSPmnEAIUT9EEOCMrvLtNR@public.gmane.org

#12 lore raw
Quoted 1 line · Konrad Rzeszutek Wilk

Odd, there should be messages about 1-1 mapping when you use 'debug'.

cat /proc/cmdline
placeholder root=UUID=b5711e0a-3fc8-44ec-940f-112e60d8f143 ro debug

so I suppose, I did it right. Maybe I didn't compile something important in?

Signature · 5 lines
Lukáš Hejtmánek
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw
In reply to a message not in the archive

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 start, u64 size) · line 97

Quoted 13 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Lukas Hejtmanek
        Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

...

arch/x86/xen/setup.c +3 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
                __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
        }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from an all 1:1 mapping, inserting the RAM translations as you find them?

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 5265560602000078000FC73E-ce6RLXgGx+vWGUEhTRrCg1aTQe2KTcn/@public.gmane.org

#15 lore raw
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Lukas Hejtmanek
        Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

...

arch/x86/xen/setup.c +0 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
Quoted 9 lines

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 start, u64 size) · line 97

Quoted 5 lines
arch/x86/xen/setup.c +3 -0
                __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
        }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from

Looks like your mailer ate some words.

Quoted 2 lines

an all 1:1 mapping, inserting the RAM translations as you find them?

Yeah, as this code can be called for the regions under 4GB. Definitly needs more analysis.

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

Quoted 3 lines

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20131021144407.GC4560-6K5HmflnPlqSPmnEAIUT9EEOCMrvLtNR@public.gmane.org

#17 lore raw
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Lukas Hejtmanek
        Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

...

arch/x86/xen/setup.c +0 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
Quoted 9 lines

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 start, u64 size) · line 97

Quoted 5 lines
arch/x86/xen/setup.c +3 -0
                __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
        }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from

Quoted 1 line

Looks like your mailer ate some words.

I don't think so - they're all there in the text you quoted.

Quoted 8 lines
Quoted 2 lines

an all 1:1 mapping, inserting the RAM translations as you find them?

Yeah, as this code can be called for the regions under 4GB. Definitly needs more analysis.

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 5265609802000078000FC7B7-ce6RLXgGx+vWGUEhTRrCg1aTQe2KTcn/@public.gmane.org

#19 lore raw
Quoted 31 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Lukas Hejtmanek
        Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

...

arch/x86/xen/setup.c +0 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
Quoted 9 lines

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 start, u64 size) · line 97

Quoted 5 lines
arch/x86/xen/setup.c +3 -0
                __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
        }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from

Quoted 1 line

Looks like your mailer ate some words.

I don't think so - they're all there in the text you quoted.

Quoted 7 lines
Quoted 2 lines

an all 1:1 mapping, inserting the RAM translations as you find them?

Yeah, as this code can be called for the regions under 4GB. Definitly needs more analysis.

Quoted 7 lines
Quoted 1 line

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

This is the patch I had in mind that I think will fix these issues. But I would appreciate testing it and naturally send me the dmesg if possible.

drivers/xen/balloon.c +19 -0
index b232908..258e3f9 100644
@@ -133,6 +133,25 @@ static void balloon_append(struct page *page)
 	adjust_managed_page_count(page, -1);
 }
 
+/*
+ * Check if any the balloon pages overlap with the supplied
+ * pfn and its range.
+ */
+bool balloon_pfn(unsigned long pfn, unsigned long nr)
+{
+	struct page *page;
+
+	if (list_empty(&ballooned_pages))
+		return false;
+
+	list_for_each_entry(page, &ballooned_pages, lru) {
+		unsigned long b_pfn = page_to_pfn(page);
+
+		if (b_pfn >= pfn && b_pfn < pfn + nr)
+			return true;
+	}
+	return false;
+}
 /* balloon_retrieve: rescue a page from the balloon, if it is not empty. */
 static struct page *balloon_retrieve(bool prefer_highmem)
 {
drivers/xen/pci.c +81 -5

121 lines not on this page · raw message

include/xen/balloon.h +1 -0
index a4c1c6a..60ecc50 100644
@@ -41,3 +41,4 @@ static inline int register_xen_selfballooning(struct device *dev)
 	return -ENOSYS;
 }
 #endif
+bool balloon_pfn(unsigned long pfn, unsigned long nr);
Quoted 3 lines

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20131023153645.GA28011-6K5HmflnPlqSPmnEAIUT9EEOCMrvLtNR@public.gmane.org

#21 lore raw
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Konrad Rzeszutek Wilk <[email protected]> 10/23/13 5:37 PM >>>

Quoted 2 lines · Jan Beulich
Quoted 1 line

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

Quoted 8 lines
Quoted 5 lines

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

This is the patch I had in mind that I think will fix these issues. But I would appreciate testing it and naturally send me the dmesg if possible.

So this indeed is only about PCI devices (i.e. not taking into account the comment I made earlier [above]).

Further, a brute force loop over all balloon pages seems like a pretty bad thing to do when the balloon is rather big.

And finally - did you check that the bus notification happens after resource assignment?

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 5267FD3102000078000A56A1-ce6RLXgGx+vWGUEhTRrCg1aTQe2KTcn/@public.gmane.org

#23 lore raw
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line

Konrad Rzeszutek Wilk <[email protected]> 10/23/13 5:37 PM >>>

Quoted 7 lines · Jan Beulich
Quoted 1 line

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

Quoted 5 lines
Quoted 2 lines

This is the patch I had in mind that I think will fix these issues. But I would appreciate testing it and naturally send me the dmesg if possible.

So this indeed is only about PCI devices (i.e. not taking into account the comment I made earlier [above]).

Correct.
What are some of those devices? It would help to understand what those are.

Quoted 3 lines

Further, a brute force loop over all balloon pages seems like a pretty bad thing to do when the balloon is rather big.

Sure.

Quoted 3 lines

And finally - did you check that the bus notification happens after resource assignment?

They do occur during the normal resource assigment. But I presume you meant during resource re-assigment?

Quoted 3 lines

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20131023160433.GA28260-6K5HmflnPlqSPmnEAIUT9EEOCMrvLtNR@public.gmane.org

#25 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line

Konrad Rzeszutek Wilk <[email protected]> 10/23/13 6:05 PM >>>

On Wed, Oct 23, 2013 at 04:45:37PM +0100, Jan Beulich wrote:
So this indeed is only about PCI devices (i.e. not taking into account the comment I made earlier [above]).

Correct.
What are some of those devices? It would help to understand what those are.

The simplest possible thing are MCFG ranges, which aren't required to be present in the E820 map.

Quoted 5 lines
Quoted 2 lines

And finally - did you check that the bus notification happens after resource assignment?

They do occur during the normal resource assigment. But I presume you meant during resource re-assigment?

No, I meant only assignment - iirc, re-assignment is still unimplemented.

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#26 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 7 lines
Quoted 1 line
Quoted 1 line

Konrad Rzeszutek Wilk <[email protected]> 10/23/13 6:05 PM >>>

On Wed, Oct 23, 2013 at 04:45:37PM +0100, Jan Beulich wrote:
So this indeed is only about PCI devices (i.e. not taking into account the comment I made earlier [above]).

Correct.
What are some of those devices? It would help to understand what those are.

The simplest possible thing are MCFG ranges, which aren't required to be present in the E820 map.

Quoted 5 lines
Quoted 2 lines

And finally - did you check that the bus notification happens after resource assignment?

They do occur during the normal resource assigment. But I presume you meant during resource re-assigment?

No, I meant only assignment - iirc, re-assignment is still unimplemented.

Jan

#27 lore raw
In reply to Jan Beulich
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line

Konrad Rzeszutek Wilk <[email protected]> 10/23/13 5:37 PM >>>

Quoted 7 lines · Jan Beulich
Quoted 1 line

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

Quoted 5 lines
Quoted 2 lines

This is the patch I had in mind that I think will fix these issues. But I would appreciate testing it and naturally send me the dmesg if possible.

So this indeed is only about PCI devices (i.e. not taking into account the comment I made earlier [above]).

Correct.
What are some of those devices? It would help to understand what those are.

Quoted 3 lines

Further, a brute force loop over all balloon pages seems like a pretty bad thing to do when the balloon is rather big.

Sure.

Quoted 3 lines

And finally - did you check that the bus notification happens after resource assignment?

They do occur during the normal resource assigment. But I presume you meant during resource re-assigment?

Quoted 3 lines

Jan

#28 lore raw
In reply to a message not in the archive
Quoted 34 lines · Konrad Rzeszutek Wilk
Quoted 33 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Lukas Hejtmanek
         Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

...

arch/x86/xen/setup.c +0 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
Quoted 9 lines

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 start, u64 size) · line 97

Quoted 5 lines
arch/x86/xen/setup.c +3 -0
                 __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
         }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from

Quoted 1 line

Looks like your mailer ate some words.

I don't think so - they're all there in the text you quoted.

Quoted 8 lines
Quoted 2 lines

an all 1:1 mapping, inserting the RAM translations as you find them?

Yeah, as this code can be called for the regions under 4GB. Definitly needs more analysis.

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

Quoted 8 lines
Quoted 5 lines

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

This is the patch I had in mind that I think will fix these issues. But I would appreciate testing it and naturally send me the dmesg if possible.

I think there is a simpler way to handle this.

If INVALID_P2M_ENTRY implies 1:1 and we arrange:

a) pfn_to_mfn() to return pfn if the mfn is missing in the p2m
b) mfn_to_pfn() to return mfn if p2m(m2p(mfn)) != mfn and there is no m2p override.

Then:

a) The identity p2m entries can be removed.
b) _PAGE_IOMAP becomes unnecessary.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 5269A865.2010100-5LkwijKnu/[email protected]

#30 lore raw
Quoted 41 lines · David Vrabel
Quoted 40 lines · Konrad Rzeszutek Wilk
Quoted 38 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Lukas Hejtmanek
        Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

...

arch/x86/xen/setup.c +0 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
Quoted 9 lines

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 start, u64 size) · line 97

Quoted 5 lines
arch/x86/xen/setup.c +3 -0
                __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
        }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from

Quoted 1 line

Looks like your mailer ate some words.

I don't think so - they're all there in the text you quoted.

Quoted 8 lines
Quoted 2 lines

an all 1:1 mapping, inserting the RAM translations as you find them?

Yeah, as this code can be called for the regions under 4GB. Definitly needs more analysis.

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

Quoted 6 lines
Quoted 2 lines

This is the patch I had in mind that I think will fix these issues. But I would appreciate testing it and naturally send me the dmesg if possible.

I think there is a simpler way to handle this.

If INVALID_P2M_ENTRY implies 1:1 and we arrange:

I am a bit afraid to make that assumption.

Quoted 2 lines

a) pfn_to_mfn() to return pfn if the mfn is missing in the p2m

The balloon pages are of missing type (initially). And they should return INVALID_P2M_ENTRY at start - later on they will return the scratch_page.

Quoted 2 lines

b) mfn_to_pfn() to return mfn if p2m(m2p(mfn)) != mfn and there is no m2p override.

The toolstack can map pages that are are p2m(p2m(mfn)) != mfn and have no m2p override.

Quoted 5 lines

Then:

a) The identity p2m entries can be removed.
b) _PAGE_IOMAP becomes unnecessary.

You still need it for the toolstack to map other guests pages. (xen_privcmd_map).

I think for right now to fix this issue going ahead and setting 1-1 in the P2M for affected devices (PCI and MCFG) is simpler, b/c:
- We only do it when said device is in the guest (so if you launch and PCI PV guest you can still migrate it - after unplugging the device). Assuming all 1-1 regions might not be a healthy (I had a heck of time fixing all of the migration issues when I wrote the 1:1 code).
- It will make PVH hypercall to mark I/O regions easier. Instead of it assuming that all non-RAM space is I/O regions it will be able to selectively setup the entries for said regions. I think that is what Jan suggested?
- This is a bug - so lets fix it as a bug first.

Redoing the P2M is certainly an option but I am not signing
up for that this year. Let me post my two patches that fix this for PCI devices and MCFG areas.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20131025142147.GB3742-6K5HmflnPlqSPmnEAIUT9EEOCMrvLtNR@public.gmane.org

#32 lore raw

Konrad Rzeszutek Wilk wrote on 2013-10-25:

Quoted 81 lines · David Vrabel
Quoted 3 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 21.10.13 at 16:44, Konrad Rzeszutek Wilk

Quoted 2 lines · <[email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 21.10.13 at 16:18, Konrad Rzeszutek Wilk

Quoted 11 lines · <[email protected]> wrote:
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 · line 95

Quoted 11 lines · Lukas Hejtmanek
Quoted 2 lines
        Region 2: Memory at 380fff000000 (64-bit,

prefetchable) [size=8M]

...

arch/x86/xen/setup.c +0 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64
 start,
 u64 size)
 
                __set_phys_to_machine(pfn,

INVALID_P2M_ENTRY);

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
arch/x86/xen/setup.c +1 -0
        }
+       /* Anything past the balloon area is marked as identity.
 */ +       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES;

pfn++) + __set_phys_to_machine(pfn,

IDENTITY_FRAME(pfn));

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from

Looks like your mailer ate some words.

I don't think so - they're all there in the text you quoted.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

an all 1:1 mapping, inserting the RAM translations as you find them?

Yeah, as this code can be called for the regions under 4GB. Definitly needs more analysis.

Were you suggesting a lookup when we scan the PCI devices?

(xen_add_device)?

Quoted 10 lines
Quoted 10 lines
Quoted 6 lines

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

This is the patch I had in mind that I think will fix these issues. But I would appreciate testing it and naturally send me the dmesg if

possible.

Quoted 4 lines

I think there is a simpler way to handle this.

If INVALID_P2M_ENTRY implies 1:1 and we arrange:

I am a bit afraid to make that assumption.

Quoted 2 lines

a) pfn_to_mfn() to return pfn if the mfn is missing in the p2m

The balloon pages are of missing type (initially). And they should return INVALID_P2M_ENTRY at start - later on they will return the scratch_page.

Quoted 2 lines

b) mfn_to_pfn() to return mfn if p2m(m2p(mfn)) != mfn and there is no m2p override.

The toolstack can map pages that are are p2m(p2m(mfn)) != mfn and have no m2p override.

Quoted 5 lines

Then:

a) The identity p2m entries can be removed.
b) _PAGE_IOMAP becomes unnecessary.

You still need it for the toolstack to map other guests pages. (xen_privcmd_map).

Quoted 14 lines

I think for right now to fix this issue going ahead and setting
1-1 in the P2M for affected devices (PCI and MCFG) is simpler, b/c:
- We only do it when said device is in the guest (so if you launch and PCI PV guest you can still migrate it - after unplugging the device). Assuming all 1-1 regions might not be a healthy (I had a heck of time fixing all of the migration issues when I wrote the 1:1 code). - It will make PVH hypercall to mark I/O regions easier. Instead of it assuming that all non-RAM space is I/O regions it will be able to selectively setup the entries for said regions. I think that is what Jan suggested?
- This is a bug - so lets fix it as a bug first.
Redoing the P2M is certainly an option but I am not signing up for that this year. Let me post my two patches that fix this for PCI devices and MCFG areas.

Any conclusion for this issue? Our custom also saw the same issue that they want to map an MMIO to userspace address(through UIO approach), but current ->mmap function call remap_pfn_range without setting _PAGE_IOMAP and cause the host crashed. It seems all userspace device drivers that tries to map device's mmio will caused host crashed.

They are using 3.10 kernel.

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Best regards,
Yang

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): A9667DDFB95DB7438FA9D7D576C3D87E0A99CE00-0J0gbvR4kTg/[email protected]

#34 lore raw
Quoted 9 lines · Yang Z

Any conclusion for this issue? Our custom also saw the same issue that they want to map an MMIO to userspace address(through UIO approach), but current ->mmap function call remap_pfn_range without setting _PAGE_IOMAP and cause the host crashed. It seems all userspace device drivers that tries to map device's mmio will caused host crashed.

They are using 3.10 kernel.

My first attempt at fixing this was broken and I need to find time for another look.

There were problems with pages that started out pre-ballooned.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#35 lore raw
In reply to Zhang, Yang Z
Quoted 9 lines · Yang Z

Any conclusion for this issue? Our custom also saw the same issue that they want to map an MMIO to userspace address(through UIO approach), but current ->mmap function call remap_pfn_range without setting _PAGE_IOMAP and cause the host crashed. It seems all userspace device drivers that tries to map device's mmio will caused host crashed.

They are using 3.10 kernel.

My first attempt at fixing this was broken and I need to find time for another look.

There were problems with pages that started out pre-ballooned.

David

#36 lore raw
In reply to Konrad Rzeszutek Wilk

Konrad Rzeszutek Wilk wrote on 2013-10-25:

Quoted 81 lines · David Vrabel
Quoted 3 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 21.10.13 at 16:44, Konrad Rzeszutek Wilk

Quoted 2 lines · <[email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 21.10.13 at 16:18, Konrad Rzeszutek Wilk

Quoted 11 lines · <[email protected]> wrote:
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 · line 95

Quoted 11 lines · Lukas Hejtmanek
Quoted 2 lines
        Region 2: Memory at 380fff000000 (64-bit,

prefetchable) [size=8M]

...

arch/x86/xen/setup.c +0 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64
 start,
 u64 size)
 
                __set_phys_to_machine(pfn,

INVALID_P2M_ENTRY);

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
arch/x86/xen/setup.c +1 -0
        }
+       /* Anything past the balloon area is marked as identity.
 */ +       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES;

pfn++) + __set_phys_to_machine(pfn,

IDENTITY_FRAME(pfn));

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from

Looks like your mailer ate some words.

I don't think so - they're all there in the text you quoted.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

an all 1:1 mapping, inserting the RAM translations as you find them?

Yeah, as this code can be called for the regions under 4GB. Definitly needs more analysis.

Were you suggesting a lookup when we scan the PCI devices?

(xen_add_device)?

Quoted 10 lines
Quoted 10 lines
Quoted 6 lines

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

This is the patch I had in mind that I think will fix these issues. But I would appreciate testing it and naturally send me the dmesg if

possible.

Quoted 4 lines

I think there is a simpler way to handle this.

If INVALID_P2M_ENTRY implies 1:1 and we arrange:

I am a bit afraid to make that assumption.

Quoted 2 lines

a) pfn_to_mfn() to return pfn if the mfn is missing in the p2m

The balloon pages are of missing type (initially). And they should return INVALID_P2M_ENTRY at start - later on they will return the scratch_page.

Quoted 2 lines

b) mfn_to_pfn() to return mfn if p2m(m2p(mfn)) != mfn and there is no m2p override.

The toolstack can map pages that are are p2m(p2m(mfn)) != mfn and have no m2p override.

Quoted 5 lines

Then:

a) The identity p2m entries can be removed.
b) _PAGE_IOMAP becomes unnecessary.

You still need it for the toolstack to map other guests pages. (xen_privcmd_map).

Quoted 14 lines

I think for right now to fix this issue going ahead and setting
1-1 in the P2M for affected devices (PCI and MCFG) is simpler, b/c:
- We only do it when said device is in the guest (so if you launch and PCI PV guest you can still migrate it - after unplugging the device). Assuming all 1-1 regions might not be a healthy (I had a heck of time fixing all of the migration issues when I wrote the 1:1 code). - It will make PVH hypercall to mark I/O regions easier. Instead of it assuming that all non-RAM space is I/O regions it will be able to selectively setup the entries for said regions. I think that is what Jan suggested?
- This is a bug - so lets fix it as a bug first.
Redoing the P2M is certainly an option but I am not signing up for that this year. Let me post my two patches that fix this for PCI devices and MCFG areas.

Any conclusion for this issue? Our custom also saw the same issue that they want to map an MMIO to userspace address(through UIO approach), but current ->mmap function call remap_pfn_range without setting _PAGE_IOMAP and cause the host crashed. It seems all userspace device drivers that tries to map device's mmio will caused host crashed.

They are using 3.10 kernel.

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Best regards,
Yang

#37 lore raw
In reply to David Vrabel
Quoted 41 lines · David Vrabel
Quoted 40 lines · Konrad Rzeszutek Wilk
Quoted 38 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Lukas Hejtmanek
        Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

...

arch/x86/xen/setup.c +0 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
Quoted 9 lines

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 start, u64 size) · line 97

Quoted 5 lines
arch/x86/xen/setup.c +3 -0
                __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
        }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from

Quoted 1 line

Looks like your mailer ate some words.

I don't think so - they're all there in the text you quoted.

Quoted 8 lines
Quoted 2 lines

an all 1:1 mapping, inserting the RAM translations as you find them?

Yeah, as this code can be called for the regions under 4GB. Definitly needs more analysis.

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

Quoted 6 lines
Quoted 2 lines

This is the patch I had in mind that I think will fix these issues. But I would appreciate testing it and naturally send me the dmesg if possible.

I think there is a simpler way to handle this.

If INVALID_P2M_ENTRY implies 1:1 and we arrange:

I am a bit afraid to make that assumption.

Quoted 2 lines

a) pfn_to_mfn() to return pfn if the mfn is missing in the p2m

The balloon pages are of missing type (initially). And they should return INVALID_P2M_ENTRY at start - later on they will return the scratch_page.

Quoted 2 lines

b) mfn_to_pfn() to return mfn if p2m(m2p(mfn)) != mfn and there is no m2p override.

The toolstack can map pages that are are p2m(p2m(mfn)) != mfn and have no m2p override.

Quoted 5 lines

Then:

a) The identity p2m entries can be removed.
b) _PAGE_IOMAP becomes unnecessary.

You still need it for the toolstack to map other guests pages. (xen_privcmd_map).

I think for right now to fix this issue going ahead and setting 1-1 in the P2M for affected devices (PCI and MCFG) is simpler, b/c:
- We only do it when said device is in the guest (so if you launch and PCI PV guest you can still migrate it - after unplugging the device). Assuming all 1-1 regions might not be a healthy (I had a heck of time fixing all of the migration issues when I wrote the 1:1 code).
- It will make PVH hypercall to mark I/O regions easier. Instead of it assuming that all non-RAM space is I/O regions it will be able to selectively setup the entries for said regions. I think that is what Jan suggested?
- This is a bug - so lets fix it as a bug first.

Redoing the P2M is certainly an option but I am not signing up for that this year. Let me post my two patches that fix this for PCI devices and MCFG areas.

#38 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Konrad Rzeszutek Wilk <[email protected]> 10/23/13 5:37 PM >>>

Quoted 2 lines · Jan Beulich
Quoted 1 line

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

Quoted 8 lines
Quoted 5 lines

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

This is the patch I had in mind that I think will fix these issues. But I would appreciate testing it and naturally send me the dmesg if possible.

So this indeed is only about PCI devices (i.e. not taking into account the comment I made earlier [above]).

Further, a brute force loop over all balloon pages seems like a pretty bad thing to do when the balloon is rather big.

And finally - did you check that the bus notification happens after resource assignment?

Jan

#39 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 34 lines · Konrad Rzeszutek Wilk
Quoted 33 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Lukas Hejtmanek
         Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

...

arch/x86/xen/setup.c +0 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
Quoted 9 lines

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 start, u64 size) · line 97

Quoted 5 lines
arch/x86/xen/setup.c +3 -0
                 __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
         }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from

Quoted 1 line

Looks like your mailer ate some words.

I don't think so - they're all there in the text you quoted.

Quoted 8 lines
Quoted 2 lines

an all 1:1 mapping, inserting the RAM translations as you find them?

Yeah, as this code can be called for the regions under 4GB. Definitly needs more analysis.

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

Quoted 8 lines
Quoted 5 lines

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

This is the patch I had in mind that I think will fix these issues. But I would appreciate testing it and naturally send me the dmesg if possible.

I think there is a simpler way to handle this.

If INVALID_P2M_ENTRY implies 1:1 and we arrange:

a) pfn_to_mfn() to return pfn if the mfn is missing in the p2m
b) mfn_to_pfn() to return mfn if p2m(m2p(mfn)) != mfn and there is no m2p override.

Then:

a) The identity p2m entries can be removed.
b) _PAGE_IOMAP becomes unnecessary.

David

#40 lore raw
In reply to Jan Beulich
Quoted 31 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Lukas Hejtmanek
        Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

...

arch/x86/xen/setup.c +0 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
Quoted 9 lines

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 start, u64 size) · line 97

Quoted 5 lines
arch/x86/xen/setup.c +3 -0
                __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
        }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from

Quoted 1 line

Looks like your mailer ate some words.

I don't think so - they're all there in the text you quoted.

Quoted 7 lines
Quoted 2 lines

an all 1:1 mapping, inserting the RAM translations as you find them?

Yeah, as this code can be called for the regions under 4GB. Definitly needs more analysis.

Quoted 7 lines
Quoted 1 line

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

This is the patch I had in mind that I think will fix these issues. But I would appreciate testing it and naturally send me the dmesg if possible.

drivers/xen/balloon.c +19 -0
index b232908..258e3f9 100644
@@ -133,6 +133,25 @@ static void balloon_append(struct page *page)
 	adjust_managed_page_count(page, -1);
 }
 
+/*
+ * Check if any the balloon pages overlap with the supplied
+ * pfn and its range.
+ */
+bool balloon_pfn(unsigned long pfn, unsigned long nr)
+{
+	struct page *page;
+
+	if (list_empty(&ballooned_pages))
+		return false;
+
+	list_for_each_entry(page, &ballooned_pages, lru) {
+		unsigned long b_pfn = page_to_pfn(page);
+
+		if (b_pfn >= pfn && b_pfn < pfn + nr)
+			return true;
+	}
+	return false;
+}
 /* balloon_retrieve: rescue a page from the balloon, if it is not empty. */
 static struct page *balloon_retrieve(bool prefer_highmem)
 {
drivers/xen/pci.c +81 -5

121 lines not on this page · raw message

include/xen/balloon.h +1 -0
index a4c1c6a..60ecc50 100644
@@ -41,3 +41,4 @@ static inline int register_xen_selfballooning(struct device *dev)
 	return -ENOSYS;
 }
 #endif
+bool balloon_pfn(unsigned long pfn, unsigned long nr);
Quoted 3 lines

Jan

#41 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Lukas Hejtmanek
        Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

...

arch/x86/xen/setup.c +0 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
Quoted 9 lines

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 start, u64 size) · line 97

Quoted 5 lines
arch/x86/xen/setup.c +3 -0
                __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
        }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from

Quoted 1 line

Looks like your mailer ate some words.

I don't think so - they're all there in the text you quoted.

Quoted 8 lines
Quoted 2 lines

an all 1:1 mapping, inserting the RAM translations as you find them?

Yeah, as this code can be called for the regions under 4GB. Definitly needs more analysis.

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

That was for PVH, and is obviously fragile, as there can be MMIO regions not matched by any PCI device's BAR. We could hope for all of them to be below 4Gb, but I think (based on logs I got to see recently from a certain vendor's upcoming systems) this isn't going to work out.

Jan

#42 lore raw
In reply to Jan Beulich
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Lukas Hejtmanek
        Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

...

arch/x86/xen/setup.c +0 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
Quoted 9 lines

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 start, u64 size) · line 97

Quoted 5 lines
arch/x86/xen/setup.c +3 -0
                __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
        }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from

Looks like your mailer ate some words.

Quoted 2 lines

an all 1:1 mapping, inserting the RAM translations as you find them?

Yeah, as this code can be called for the regions under 4GB. Definitly needs more analysis.

Were you suggesting a lookup when we scan the PCI devices? (xen_add_device)?

Quoted 3 lines

Jan

#43 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 1 line · Konrad Rzeszutek Wilk

Odd, there should be messages about 1-1 mapping when you use 'debug'.

cat /proc/cmdline
placeholder root=UUID=b5711e0a-3fc8-44ec-940f-112e60d8f143 ro debug

so I suppose, I did it right. Maybe I didn't compile something important in?

Signature · 1 line
Lukáš Hejtmánek
#44 lore raw
In reply to Konrad Rzeszutek Wilk

arch/x86/xen/setup.c static void __init xen_add_extra_mem(u64 start, u64 size) · line 97

Quoted 13 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Lukas Hejtmanek
        Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

...

arch/x86/xen/setup.c +3 -0
@@ -92,6 +92,9 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
 
                __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
        }
+       /* Anything past the balloon area is marked as identity. */
+       for (pfn = xen_max_p2m_pfn; pfn < MAX_DOMAIN_PAGES; pfn++)
+               __set_phys_to_machine(pfn, IDENTITY_FRAME(pfn));

Hardly - MAX_DOMAIN_PAGES derives from CONFIG_XEN_MAX_DOMAIN_MEMORY, which in turn is unrelated to where MMIO might be. Should you perhaps simply start from an all 1:1 mapping, inserting the RAM translations as you find them?

Jan

A message that is not in the archive (sent off-list or not yet received): 20131021140607.GQ20913-8qz54MUs51PtwjQa/[email protected]

#46 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Lukas Hejtmanek

here is lspci from the card and its virtual functions.

06:00.0 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3]
Subsystem: Mellanox Technologies Device 0017
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 42
Region 0: Memory at dfa00000 (64-bit, non-prefetchable) [size=1M]
Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

Which confirms what Konrad said regarding MMIO above 4Gb.

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#47 lore raw
In reply to Lukas Hejtmanek
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Lukas Hejtmanek

here is lspci from the card and its virtual functions.

06:00.0 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3]
Subsystem: Mellanox Technologies Device 0017
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 42
Region 0: Memory at dfa00000 (64-bit, non-prefetchable) [size=1M]
Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]

Which confirms what Konrad said regarding MMIO above 4Gb.

Jan

#48 lore raw
In reply to konrad wilk
Quoted 13 lines · konrad wilk
Quoted 10 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · konrad wilk

It is a bug in the drivers I believe. The issue is that the mapping created for the second mmap
call is done without VM_IO and on an PFN that is RAM (and not the BAR).

So while putting together the reply that I had sent to Lukas a minute ago I was actually hunting for that VM_IO -> _PAGE_IOMAP translation, and wasn't able to find it anywhere. As you say it nevertheless exists - what am I overlooking (and why would then pci_mmap_page_range() nevertheless have to set _PAGE_IOMAP by hand)?

Quoted 4 lines

The P2M (arch/x86/xen/p2m.c) is consulted which for the MMIO gaps and E820_RESV has the MFNs set to the PFN. This is the 1-1 pfn/mfn stuff that I implemented some time ago - as hpa was opposed to having the _PAGE_IOMAP being stuck on any macro call to pgprot_writecombine|noncached|etc. Or perhaps that was on the arch_something_prot.

This is the one that Jeremy cooked up some time ago:
http://lkml.indiana.edu/hypermail/linux/kernel/1010.2/03012.html

And here was the thread:
http://www.spinics.net/lists/linux-rdma/msg07085.html

which I thought had been fixed by the P2M identity code.

Quoted 27 lines

Anyhow, the odd thing is that looking at the code:

669 if (io_remap_pfn_range(vma, vma->vm_start,
670 to_mucontext(context)->uar.pfn +
671 dev->dev->caps.num_uars,
672 PAGE_SIZE,
vma->vm_page_prot))

The PFN in question (uar.pfn) is in mlx4_uar_alloc is set to:

159 uar->pfn = (pci_resource_start(dev->pdev, 2) >> PAGE_SHIFT) + offset;

So is the BAR not in the MMIO region? Or is it the 64-bit type MMIO that lays outside the 4GB and hence when the P2M is consulted it thinks its INVALID_P2M_ENTRY?

Which comes back to the bug you (Jan) discovered when you pointed out that PVH needs to setup MMIO entries for 64-bit MMIO regions which can be outside the 4GB region <sigh>. And that is something the pvops kernel completly ignores as it assumes that any region past the E820 can be used for ballooning.

Anyhow, one easy thing to figure out is to get the lspci -v output from the InfiniBand card to see where its BARs are, and also the start of the kernel. You should see an E820 map (please also boot with "debug" on the Linux command line).

Quoted 2 lines

Jan

#49 lore raw
In reply to konrad wilk
Quoted 5 lines · konrad wilk

Anyhow, one easy thing to figure out is to get the lspci -v output from the InfiniBand card
to see where its BARs are, and also the start of the kernel. You should see an E820 map (please also boot with
"debug" on the Linux command line).

note, adding _PAGE_IO as Jan suggested fixed those mem errors.

here is lspci from the card and its virtual functions.

06:00.0 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3]
Subsystem: Mellanox Technologies Device 0017
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 42
Region 0: Memory at dfa00000 (64-bit, non-prefetchable) [size=1M]
Region 2: Memory at 380fff000000 (64-bit, prefetchable) [size=8M]
Expansion ROM at df900000 [disabled] [size=1M]
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [48] Vital Product Data
Product Name: CX353A - ConnectX-3 QSFP
Read-only fields:
[PN] Part number: MCX353A-QCBT
[EC] Engineering changes: A4
[SN] Serial number: MT1327X00814
[V0] Vendor specific: PCIe Gen3 x8
[RV] Reserved: checksum good, 0 byte(s) reserved
Read/write fields:
[V1] Vendor specific: N/A
[YA] Asset tag: N/A
[RW] Read-write area: 105 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 253 byte(s) free
[RW] Read-write area: 252 byte(s) free
End
Capabilities: [9c] MSI-X: Enable+ Count=128 Masked-
Vector table: BAR=0 offset=0007c000
PBA: BAR=0 offset=0007d000
Capabilities: [60] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 unlimited
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset+
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset-
MaxPayload 256 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #8, Speed 8GT/s, Width x8, ASPM L0s, Latency L0 unlimited, L1 unlimited
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 8GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-
LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete+, EqualizationPhase1+
EqualizationPhase2+, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [100 v1] Alternative Routing-ID Interpretation (ARI)
ARICap: MFVC- ACS-, Next Function: 0
ARICtl: MFVC- ACS-, Function Group: 0
Capabilities: [148 v1] Device Serial Number 00-02-c9-03-00-b6-fc-70
Capabilities: [108 v1] Single Root I/O Virtualization (SR-IOV)
IOVCap: Migration-, Interrupt Message Number: 000
IOVCtl: Enable+ Migration- Interrupt- MSE+ ARIHierarchy+
IOVSta: Migration-
Initial VFs: 64, Total VFs: 64, Number of VFs: 4, Function Dependency Link: 00 VF offset: 1, stride: 1, Device ID: 1004
Supported Page Size: 000007ff, System Page Size: 00000001
Region 2: Memory at 0000380fdf000000 (64-bit, prefetchable)
VF Migration: offset: 00000000, BIR: 0
Capabilities: [154 v2] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq+ ACSViol-
UESvrt: DLP+ SDES- TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
Capabilities: [18c v1] #19
Kernel driver in use: mlx4_core

06:00.1 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]
Subsystem: Mellanox Technologies Device 61b0
Control: I/O- Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Region 2: [virtual] Memory at 380fdf000000 (64-bit, prefetchable) [size=8M]
Capabilities: [60] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset+
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM unknown, Latency L0 <64ns, L1 <1us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed unknown, Width x0, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [9c] MSI-X: Enable+ Count=4 Masked-
Vector table: BAR=2 offset=00002000
PBA: BAR=2 offset=00003000
Kernel driver in use: mlx4_core

06:00.2 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]
Subsystem: Mellanox Technologies Device 61b0
Control: I/O- Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Region 2: [virtual] Memory at 380fdf800000 (64-bit, prefetchable) [size=8M]
Capabilities: [60] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset+
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM unknown, Latency L0 <64ns, L1 <1us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed unknown, Width x0, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [9c] MSI-X: Enable+ Count=4 Masked-
Vector table: BAR=2 offset=00002000
PBA: BAR=2 offset=00003000
Kernel driver in use: mlx4_core

06:00.3 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]
Subsystem: Mellanox Technologies Device 61b0
Control: I/O- Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Region 2: [virtual] Memory at 380fe0000000 (64-bit, prefetchable) [size=8M]
Capabilities: [60] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset+
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM unknown, Latency L0 <64ns, L1 <1us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed unknown, Width x0, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [9c] MSI-X: Enable+ Count=4 Masked-
Vector table: BAR=2 offset=00002000
PBA: BAR=2 offset=00003000
Kernel driver in use: mlx4_core

06:00.4 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]
Subsystem: Mellanox Technologies Device 61b0
Control: I/O- Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Region 2: [virtual] Memory at 380fe0800000 (64-bit, prefetchable) [size=8M]
Capabilities: [60] Express (v2) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset+
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM unknown, Latency L0 <64ns, L1 <1us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed unknown, Width x0, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [9c] MSI-X: Enable+ Count=4 Masked-
Vector table: BAR=2 offset=00002000
PBA: BAR=2 offset=00003000
Kernel driver in use: mlx4_core

and this is from dmesg:

[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] Xen: [mem 0x0000000000000000-0x0000000000090fff] usable
[    0.000000] Xen: [mem 0x0000000000091800-0x00000000000fffff] reserved
[    0.000000] Xen: [mem 0x0000000000100000-0x000000007dd76fff] usable
[    0.000000] Xen: [mem 0x000000007dd77000-0x000000007ddb5fff] reserved
[    0.000000] Xen: [mem 0x000000007ddb6000-0x000000007debefff] ACPI data
[    0.000000] Xen: [mem 0x000000007debf000-0x000000007e0dafff] ACPI NVS
[    0.000000] Xen: [mem 0x000000007e0db000-0x000000007f357fff] reserved
[    0.000000] Xen: [mem 0x000000007f358000-0x000000007f7fffff] ACPI NVS
[    0.000000] Xen: [mem 0x0000000080000000-0x000000008fffffff] reserved
[    0.000000] Xen: [mem 0x00000000fec00000-0x00000000fec01fff] reserved
[    0.000000] Xen: [mem 0x00000000fec40000-0x00000000fec40fff] reserved
[    0.000000] Xen: [mem 0x00000000fed1c000-0x00000000fed3ffff] reserved
[    0.000000] Xen: [mem 0x00000000fee00000-0x00000000fee00fff] reserved
[    0.000000] Xen: [mem 0x00000000ff000000-0x00000000ffffffff] reserved
[    0.000000] Xen: [mem 0x0000000100000000-0x000000107fffffff] usable
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
[    0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable
[    0.000000] e820: last_pfn = 0x1080000 max_arch_pfn = 0x400000000
[    0.000000] e820: last_pfn = 0x7dd77 max_arch_pfn = 0x400000000
[    0.000000] e820: [mem 0x90000000-0xfebfffff] available for PCI devices
[   23.917733] PCI: MMCONFIG at [mem 0x80000000-0x8fffffff] reserved in E820
[   24.587366] e820: reserve RAM buffer [mem 0x00091000-0x0009ffff]
[   24.587468] e820: reserve RAM buffer [mem 0x7dd77000-0x7fffffff]

do you need anything else?

Signature · 1 line
Lukáš Hejtmánek
#50 lore raw
In reply to Jan Beulich
Quoted 10 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · konrad wilk

It is a bug in the drivers I believe. The issue is that the mapping created for the second mmap
call is done without VM_IO and on an PFN that is RAM (and not the BAR).

So while putting together the reply that I had sent to Lukas a minute ago I was actually hunting for that VM_IO -> _PAGE_IOMAP translation, and wasn't able to find it anywhere. As you say it nevertheless exists - what am I overlooking (and why would then pci_mmap_page_range() nevertheless have to set _PAGE_IOMAP by hand)?

The P2M (arch/x86/xen/p2m.c) is consulted which for the MMIO gaps and E820_RESV has the MFNs set to the PFN. This is the 1-1 pfn/mfn stuff that I implemented some time ago - as hpa was opposed to having the _PAGE_IOMAP being stuck on any macro call to pgprot_writecombine|noncached|etc. Or perhaps that was on the arch_something_prot.

Anyhow, the odd thing is that looking at the code:

669 if (io_remap_pfn_range(vma, vma->vm_start,
670 to_mucontext(context)->uar.pfn +
671 dev->dev->caps.num_uars,
672 PAGE_SIZE, vma->vm_page_prot))

The PFN in question (uar.pfn) is in mlx4_uar_alloc is set to:

159 uar->pfn = (pci_resource_start(dev->pdev, 2) >> PAGE_SHIFT) + offset;

So is the BAR not in the MMIO region? Or is it the 64-bit type MMIO that lays outside the 4GB and hence when the P2M is consulted it thinks its INVALID_P2M_ENTRY?

Which comes back to the bug you (Jan) discovered when you pointed out that PVH needs to setup MMIO entries for 64-bit MMIO regions which can be outside the 4GB region <sigh>. And that is something the pvops kernel completly ignores as it assumes that any region past the E820 can be used for ballooning.

Anyhow, one easy thing to figure out is to get the lspci -v output from the InfiniBand card to see where its BARs are, and also the start of the kernel. You should see an E820 map (please also boot with "debug" on the Linux command line).

Quoted 2 lines

Jan

#51 lore raw
In reply to konrad wilk
Quoted 4 lines
Quoted 1 line
Quoted 1 line · konrad wilk

It is a bug in the drivers I believe. The issue is that the mapping created for the second mmap
call is done without VM_IO and on an PFN that is RAM (and not the BAR).

So while putting together the reply that I had sent to Lukas a minute ago I was actually hunting for that VM_IO -> _PAGE_IOMAP translation, and wasn't able to find it anywhere. As you say it nevertheless exists - what am I overlooking (and why would then pci_mmap_page_range() nevertheless have to set _PAGE_IOMAP by hand)?

Jan

#52 lore raw
In reply to a message not in the archive
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Lukas Hejtmanek

I'm trying to get SR-IOV working under Xen (4.2). It almost works except memory bug. This is easily reproducible just in Dom0.

So without any SR-IOV then, I suppose?

Quoted 9 lines
[23502.645455] mlx4_core 0000:06:00.0: mlx4_ib: Port 1 logical link is up
[23550.181907] <mlx4_ib> check_flow_steering_support: Device managed flow 
steering is unavailable for IB port in multifunction env.
[23550.183822] swap_free: Unused swap offset entry 00000001
[23550.183868] BUG: Bad page map in process ibv_devinfo  pte:00000200 
pmd:1b7df4067
[23550.183939] addr:00007f7ef5e18000 vm_flags:400844fa anon_vma:          
(null) mapping:ffff8801b83c0480 index:380fe0882
[23550.184022] vma->vm_file->f_op->mmap: ib_uverbs_mmap+0x0/0x2d [ib_uverbs]

Looking at ib_uverbs_mmap() and its necessary (for mlx4) descendant mlx4_ib_mmap() I see that the latter calls io_remap_pfn_range(), but afaict there's nowhere _PAGE_IOMAP would get set here (as opposed to arch/x86/pci/i386.c:pci_mmap_page_range() for example). Could you check whether adding that flag helps? (I'm copying the kernel maintainers so that they could correct me if I'm wrong here - it would seem to me that this could equally be the reason for why there are other reports of certain things not working as expected in domains with more than 4Gb.)

You could also consider trying an openSUSE kernel - there, other than upstream, there's no need for each and every caller of io_remap_pfn_range() to take care of setting _PAGE_IOMAP (and I vaguely recall having discussed this a couple of years back with Konrad et al).

Jan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#53 lore raw
In reply to Lukas Hejtmanek
Quoted 8 lines · Lukas Hejtmanek

Hello,

I'm trying to get SR-IOV working under Xen (4.2). It almost works except memory bug. This is easily reproducible just in Dom0.

I have Connect-X3 card with the latest firmware. OFED 2.0-3 drivers. I tried 3.2 kernel from Debian, 3.10 kernel from Debian and vanila 3.11.5 kernel. All are the same.

Ha! Funny you mention that. I had been looking at this.

Quoted 28 lines

As soon as I issue ibv_devinfo command, it produces the following messages into dmesg. Problem is that with ib_rdma_bw command, I get more of those messages and moreover, oom killer gets confused and kills almost all processes.

[23502.645455] mlx4_core 0000:06:00.0: mlx4_ib: Port 1 logical link is up
[23550.181907] <mlx4_ib> check_flow_steering_support: Device managed flow steering is unavailable for IB port in multifunction env.
[23550.183822] swap_free: Unused swap offset entry 00000001
[23550.183868] BUG: Bad page map in process ibv_devinfo  pte:00000200 pmd:1b7df4067
[23550.183939] addr:00007f7ef5e18000 vm_flags:400844fa anon_vma:          (null) mapping:ffff8801b83c0480 index:380fe0882
[23550.184022] vma->vm_file->f_op->mmap: ib_uverbs_mmap+0x0/0x2d [ib_uverbs]
[23550.195382] Pid: 13813, comm: ibv_devinfo Tainted: G           O 3.2.0-0.bpo.4-amd64 #1 Debian 3.2.41-2+deb7u2~bpo60+1+zs4
[23550.195461] Call Trace:
[23550.195508]  [<ffffffff810d9009>] ? print_bad_pte+0x1f5/0x20d
[23550.195553]  [<ffffffff810db083>] ? unmap_vmas+0x5fe/0x814
[23550.195601]  [<ffffffff810c68dd>] ? __add_page_to_lru_list+0x53/0x53
[23550.195647]  [<ffffffff810df2de>] ? unmap_region+0x9f/0x102
[23550.195694]  [<ffffffff8100d722>] ? __switch_to+0x23b/0x2b1
[23550.195741]  [<ffffffff8103d870>] ? pick_next_task_fair+0xfc/0x10c
[23550.195788]  [<ffffffff810463a2>] ? finish_task_switch+0x53/0xc7
[23550.195832]  [<ffffffff810e01f7>] ? do_munmap+0x281/0x2eb
[23550.195875]  [<ffffffff810e02a0>] ? sys_munmap+0x3f/0x55
[23550.195921]  [<ffffffff8136e51c>] ? system_call_fastpath+0x16/0x1b
[23550.195965] Disabling lock debugging due to kernel taint
[23550.196412] <mlx4_ib> check_flow_steering_support: Device managed flow steering is unavailable for IB port in multifunction env.
[23550.198303] swap_free: Unused swap offset entry 00000001
[23550.198348] BUG: Bad page map in process ibv_devinfo  pte:00000200 pmd:1b7df4067
[23550.198424] addr:00007f7ef5e18000 vm_flags:400844fa anon_vma:          (null) mapping:ffff8801b83c09a0 index:380fe0082

..

Quoted 4 lines

this happens only if running under Xen. Native kernel in the same version is OK.

Is it a known bug or is something wrong with BIOS/firmware?

It is a bug in the drivers I believe. The issue is that the mapping created for the second mmap call is done without VM_IO and on an PFN that is RAM (and not the BAR). But I am not entirely sure and hopefully this week will have a better idea and fix. Stay tuned.

#54 lore raw
In reply to Lukas Hejtmanek
Quoted 3 lines
Quoted 1 line
Quoted 1 line · Lukas Hejtmanek

I'm trying to get SR-IOV working under Xen (4.2). It almost works except memory bug. This is easily reproducible just in Dom0.

So without any SR-IOV then, I suppose?

Quoted 9 lines
[23502.645455] mlx4_core 0000:06:00.0: mlx4_ib: Port 1 logical link is up
[23550.181907] <mlx4_ib> check_flow_steering_support: Device managed flow 
steering is unavailable for IB port in multifunction env.
[23550.183822] swap_free: Unused swap offset entry 00000001
[23550.183868] BUG: Bad page map in process ibv_devinfo  pte:00000200 
pmd:1b7df4067
[23550.183939] addr:00007f7ef5e18000 vm_flags:400844fa anon_vma:          
(null) mapping:ffff8801b83c0480 index:380fe0882
[23550.184022] vma->vm_file->f_op->mmap: ib_uverbs_mmap+0x0/0x2d [ib_uverbs]

Looking at ib_uverbs_mmap() and its necessary (for mlx4) descendant mlx4_ib_mmap() I see that the latter calls io_remap_pfn_range(), but afaict there's nowhere _PAGE_IOMAP would get set here (as opposed to arch/x86/pci/i386.c:pci_mmap_page_range() for example). Could you check whether adding that flag helps? (I'm copying the kernel maintainers so that they could correct me if I'm wrong here - it would seem to me that this could equally be the reason for why there are other reports of certain things not working as expected in domains with more than 4Gb.)

You could also consider trying an openSUSE kernel - there, other than upstream, there's no need for each and every caller of io_remap_pfn_range() to take care of setting _PAGE_IOMAP (and I vaguely recall having discussed this a couple of years back with Konrad et al).

Jan