• Vivek Kasireddy's avatar
    udmabuf: add back support for mapping hugetlb pages · 0c8b91ef
    Vivek Kasireddy authored
    A user or admin can configure a VMM (Qemu) Guest's memory to be backed by
    hugetlb pages for various reasons.  However, a Guest OS would still
    allocate (and pin) buffers that are backed by regular 4k sized pages.  In
    order to map these buffers and create dma-bufs for them on the Host, we
    first need to find the hugetlb pages where the buffer allocations are
    located and then determine the offsets of individual chunks (within those
    pages) and use this information to eventually populate a scatterlist.
    
    Testcase: default_hugepagesz=2M hugepagesz=2M hugepages=2500 options
    were passed to the Host kernel and Qemu was launched with these
    relevant options: qemu-system-x86_64 -m 4096m....
    -device virtio-gpu-pci,max_outputs=1,blob=true,xres=1920,yres=1080
    -display gtk,gl=on
    -object memory-backend-memfd,hugetlb=on,id=mem1,size=4096M
    -machine memory-backend=mem1
    
    Replacing -display gtk,gl=on with -display gtk,gl=off above would
    exercise the mmap handler.
    
    Link: https://lkml.kernel.org/r/20240624063952.1572359-7-vivek.kasireddy@intel.comSigned-off-by: default avatarVivek Kasireddy <vivek.kasireddy@intel.com>
    Acked-by: Mike Kravetz <mike.kravetz@oracle.com> (v2)
    Acked-by: default avatarDave Airlie <airlied@redhat.com>
    Acked-by: default avatarGerd Hoffmann <kraxel@redhat.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: Jason Gunthorpe <jgg@nvidia.com>
    Cc: Dongwon Kim <dongwon.kim@intel.com>
    Cc: Junxiao Chang <junxiao.chang@intel.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Christoph Hellwig <hch@infradead.org>
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Oscar Salvador <osalvador@suse.de>
    Cc: Shuah Khan <shuah@kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    0c8b91ef
udmabuf.c 10.6 KB