[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250905133624.GF616306@nvidia.com>
Date: Fri, 5 Sep 2025 10:36:24 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: ankita@...dia.com
Cc: alex.williamson@...hat.com, yishaih@...dia.com, skolothumtho@...dia.com,
kevin.tian@...el.com, yi.l.liu@...el.com, zhiw@...dia.com,
aniketa@...dia.com, cjia@...dia.com, kwankhede@...dia.com,
targupta@...dia.com, vsethi@...dia.com, acurrid@...dia.com,
apopple@...dia.com, jhubbard@...dia.com, danw@...dia.com,
anuaggarwal@...dia.com, mochs@...dia.com, kjaju@...dia.com,
dnigam@...dia.com, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC 09/14] vfio/nvgrace-egm: Add chardev ops for EGM management
On Thu, Sep 04, 2025 at 04:08:23AM +0000, ankita@...dia.com wrote:
> static int nvgrace_egm_mmap(struct file *file, struct vm_area_struct *vma)
> {
> - return 0;
> + struct chardev *egm_chardev = file->private_data;
> + struct nvgrace_egm_dev *egm_dev =
> + egm_chardev_to_nvgrace_egm_dev(egm_chardev);
> +
> + /*
> + * EGM memory is invisible to the host kernel and is not managed
> + * by it. Map the usermode VMA to the EGM region.
> + */
> + return remap_pfn_range(vma, vma->vm_start,
> + PHYS_PFN(egm_dev->egmphys),
> + (vma->vm_end - vma->vm_start),
> + vma->vm_page_prot);
This needs to handle vm_pgoff and sanity check end - start!!
It should also reject !MAP_SHARED
Jason
Powered by blists - more mailing lists