[PATCH 1/1] [RFC] drm/ttm: Don't init dma32_zone on 64-bit systems

Koenig, Christian Christian.Koenig at amd.com
Thu Feb 21 07:59:19 UTC 2019


Am 21.02.19 um 07:47 schrieb Thomas Hellstrom:
> On Wed, 2019-02-20 at 19:23 +0000, Kuehling, Felix wrote:
>> On 2019-02-20 1:41 a.m., Thomas Hellstrom wrote:
>>> On Tue, 2019-02-19 at 17:06 +0000, Kuehling, Felix wrote:
>>>> On 2019-02-18 3:39 p.m., Thomas Hellstrom wrote:
>>>>> On Mon, 2019-02-18 at 18:07 +0100, Christian König wrote:
>>>>>> Am 18.02.19 um 10:47 schrieb Thomas Hellstrom:
>>>>>>> On Mon, 2019-02-18 at 09:20 +0000, Koenig, Christian wrote:
>>>>>>>> Another good question is also why the heck the acc_size
>>>>>>>> counts
>>>>>>>> towards
>>>>>>>> the DMA32 zone?
>>>>>>> DMA32 TTM pages are accounted in the DMA32 zone. Other
>>>>>>> pages
>>>>>>> are
>>>>>>> not.
>>>>>> Yeah, I'm perfectly aware of this. But this is for the
>>>>>> accounting
>>>>>> size!
>>>>>>
>>>>>> We have an accounting for the stuff needed additional to the
>>>>>> pages
>>>>>> backing the BO (e.g. the page and DMA addr array).
>>>>>>
>>>>>> And from the bug description it sounds like we use the DMA32
>>>>>> zone
>>>>>> for
>>>>>> this accounting which of course is completely nonsense.
>>>>> It's actually accounted in all available zones, since it would
>>>>> be
>>>>> pretty hard to determine exactly where that memory should be
>>>>> accounted.
>>>>> In particular if it's vmalloced. It might be DMA32, it might
>>>>> not.
>>>>> Given
>>>>> the objective of stopping malicious user-space from exhausting
>>>>> the
>>>>> DMA32 zone it was, at the time the code was written, a
>>>>> reasonable
>>>>> approximation. With ever increasing memory sizes, there might
>>>>> be
>>>>> better
>>>>> solutions?
>>>> As far as I can see, in TTM, ttm_mem_global_alloc is only used
>>>> for
>>>> the
>>>> acc_size in ttm_bo_init_reserved. Other than that vmwgfx also
>>>> seems
>>>> to
>>>> use it to account for a few things that are allocated with
>>>> kmalloc.
>>>>
>>>> So would a better solution be to change ttm_mem_global_alloc to
>>>> use
>>>> only
>>>> the kernel zone?
>>>>
>>> IMO we need to determine what functionality to keep and then the
>>> best
>>> solution. The current code does its job, but is obviously too
>>> restrictive. Both of the solutions you suggest open up for
>>> potential
>>> DOS attacks (DMA32 and kernel zones are not mutually exclusive.
>>> They
>>> overlap).
>> On x86 with HIGHMEM there is no dma32 zone. Why do we need one on
>> x86_64? Can we make x86_64 more like HIGHMEM instead?
>>
>> Regards,
>>     Felix
>>
> IIRC with x86, the kernel zone is always smaller than any dma32 zone,
> so we'd always exhaust the kernel zone before dma32 anyway.
>
> Not sure why we have dma32 on x86 without highmem, though. sounds
> superflous but harmless.

Well DMA32 denotes memory which is accessible by devices who can only do 
32bit addressing. And IIRC we can actually do DMA32 to highmem since 
something like 2.4.*.

Because of this it is actually irrelevant if you have highmem or not, 
what matters for DMA32 is if you have an IOMMU or not.

So even on x86_64 you actually do need the DMA32 zone if you don't have 
an IOMMU which remaps all memory for devices which can't directly 
address it.

Regards,
Christian.

>
> /Thomas
>
>



More information about the dri-devel mailing list