<html><body><p><tt><font size="2">Michael Ellerman <mpe@ellerman.id.au> wrote on 11/06/2017 11:45:34 AM:<br><br>> From: Michael Ellerman <mpe@ellerman.id.au></font></tt><br><tt><font size="2">> To: Alexey Kardashevskiy <aik@ozlabs.ru>, David Gibson <br>> <david@gibson.dropbear.id.au></font></tt><br><tt><font size="2">> Cc: linuxppc-dev@lists.ozlabs.org, Jonas Pfefferle1 <br>> <JPF@zurich.ibm.com>, Nicholas Piggin <npiggin@gmail.com></font></tt><br><tt><font size="2">> Date: 11/06/2017 11:45 AM</font></tt><br><tt><font size="2">> Subject: Re: [PATCH kernel] powerpc/powernv/ioda: Relax max DMA <br>> window size check</font></tt><br><tt><font size="2">> <br>> Alexey Kardashevskiy <aik@ozlabs.ru> writes:<br>> <br>> > On 31/10/17 15:04, Alexey Kardashevskiy wrote:<br>> >> DMA windows can only have a size of power of two on IODA2 hardware and<br>> >> using memory_hotplug_max() to determine the upper limit won't work<br>> >> correcly if it returns not power of two value.<br>> >> <br>> >> This relaxes the check by rounding up the value returned by<br>> >> memory_hotplug_max().<br>> >> <br>> >> It is expected to impact DPDK on machines with non-power-of-two RAM size,<br>> >> mostly. KVM guests are less likely to be affected as usually guests get<br>> >> less than half of hosts RAM.<br>> ><br>> ><br>> > It was pointed out that this check is quite useless anyway as the vm_locked<br>> > memory limit should hit first, and if that is not set or the user got the<br>> > root privilege level, then there are easier ways to crash the host so I am<br>> > thinking of:<br>> ><br>> ><br>> > diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c<br>> > b/arch/powerpc/platforms/powernv/pci-ioda.c<br>> > index 269f119e4b3c..a47e4cf343b2 100644<br>> > --- a/arch/powerpc/platforms/powernv/pci-ioda.c<br>> > +++ b/arch/powerpc/platforms/powernv/pci-ioda.c<br>> > @@ -2769,7 +2769,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid,<br>> > __u64 bus_offset,<br>> >         if (!levels || (levels > POWERNV_IOMMU_MAX_LEVELS))<br>> >                 return -EINVAL;<br>> ><br>> > -       if ((window_size > memory_hotplug_max()) ||<br>> > !is_power_of_2(window_size))<br>> > +       if (!is_power_of_2(window_size))<br>> >                 return -EINVAL;<br>> ><br>> ><br>> ><br>> > Makes sense?<br>> <br>> Sounds reasonable.<br>> <br>> Execpt where is the vm_locked check? I think it's in the VFIO driver? If<br>> so I guess the only concern is that this code might be called via some<br>> other path that doesn't do that check.<br>> <br>> cheers<br>> </font></tt><br><br><tt><font size="2">The vm_locked is incremented here:</font></tt><br><a href="http://elixir.free-electrons.com/linux/v4.13.11/source/drivers/vfio/vfio_iommu_spapr_tce.c#L176"><tt><font size="2">http://elixir.free-electrons.com/linux/v4.13.11/source/drivers/vfio/vfio_iommu_spapr_tce.c#L176</font></tt></a><br><tt><font size="2">resp. </font></tt><a href="http://elixir.free-electrons.com/linux/v4.13.11/source/arch/powerpc/mm/mmu_context_iommu.c#L124"><tt><font size="2">http://elixir.free-electrons.com/linux/v4.13.11/source/arch/powerpc/mm/mmu_context_iommu.c#L124</font></tt></a><br><tt><font size="2">on </font></tt><tt><font size="2">VFIO_IOMMU_SPAPR_REGISTER_MEMORY.</font></tt><tt><font size="2"> From my understanding only pages</font></tt><br><tt><font size="2">that have been registered through here can be mapped with MAP_DMA.</font></tt><br><br><tt><font size="2">Cheers,</font></tt><br><tt><font size="2">Jonas<br></font></tt><BR>
</body></html>