lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251106145622.1610d306.alex@shazbot.org>
Date: Thu, 6 Nov 2025 14:56:22 -0700
From: Alex Williamson <alex@...zbot.org>
To: <ankita@...dia.com>
Cc: <aniketa@...dia.com>, <vsethi@...dia.com>, <jgg@...dia.com>,
 <mochs@...dia.com>, <skolothumtho@...dia.com>, <linmiaohe@...wei.com>,
 <nao.horiguchi@...il.com>, <akpm@...ux-foundation.org>, <david@...hat.com>,
 <lorenzo.stoakes@...cle.com>, <Liam.Howlett@...cle.com>, <vbabka@...e.cz>,
 <rppt@...nel.org>, <surenb@...gle.com>, <mhocko@...e.com>,
 <tony.luck@...el.com>, <bp@...en8.de>, <rafael@...nel.org>,
 <guohanjun@...wei.com>, <mchehab@...nel.org>, <lenb@...nel.org>,
 <kevin.tian@...el.com>, <cjia@...dia.com>, <kwankhede@...dia.com>,
 <targupta@...dia.com>, <zhiw@...dia.com>, <dnigam@...dia.com>,
 <kjaju@...dia.com>, <linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
 <linux-edac@...r.kernel.org>, <Jonathan.Cameron@...wei.com>,
 <ira.weiny@...el.com>, <Smita.KoralahalliChannabasappa@....com>,
 <u.kleine-koenig@...libre.com>, <peterz@...radead.org>,
 <linux-acpi@...r.kernel.org>, <kvm@...r.kernel.org>
Subject: Re: [PATCH v5 3/3] vfio/nvgrace-gpu: register device memory for
 poison handling

On Sun, 2 Nov 2025 18:44:34 +0000
<ankita@...dia.com> wrote:

> From: Ankit Agrawal <ankita@...dia.com>
> 
> The nvgrace-gpu-vfio-pci module [1] maps the device memory to the user VA
> (Qemu) using remap_pfn_range() without adding the memory to the kernel.
> The device memory pages are not backed by struct page. The previous
> patch implements the mechanism to handle ECC/poison on memory page without
> struct page. This new mechanism is being used here.
> 
> The module registers its memory region and the address_space with the
> kernel MM for ECC handling using the register_pfn_address_space()
> registration API exposed by the kernel.
> 
> Link: https://lore.kernel.org/all/20240220115055.23546-1-ankita@nvidia.com/ [1]
> 
> Signed-off-by: Ankit Agrawal <ankita@...dia.com>
> ---
>  drivers/vfio/pci/nvgrace-gpu/main.c | 45 ++++++++++++++++++++++++++++-
>  1 file changed, 44 insertions(+), 1 deletion(-)

LGTM.  I see Andrew has already picked this up in mm-new, if he
refreshes, here's another ack.

Acked-by: Alex Williamson <alex@...zbot.org>

Thanks,
Alex

> diff --git a/drivers/vfio/pci/nvgrace-gpu/main.c b/drivers/vfio/pci/nvgrace-gpu/main.c
> index d95761dcdd58..80b3ed63c682 100644
> --- a/drivers/vfio/pci/nvgrace-gpu/main.c
> +++ b/drivers/vfio/pci/nvgrace-gpu/main.c
> @@ -8,6 +8,10 @@
>  #include <linux/delay.h>
>  #include <linux/jiffies.h>
>  
> +#ifdef CONFIG_MEMORY_FAILURE
> +#include <linux/memory-failure.h>
> +#endif
> +
>  /*
>   * The device memory usable to the workloads running in the VM is cached
>   * and showcased as a 64b device BAR (comprising of BAR4 and BAR5 region)
> @@ -47,6 +51,9 @@ struct mem_region {
>  		void *memaddr;
>  		void __iomem *ioaddr;
>  	};                      /* Base virtual address of the region */
> +#ifdef CONFIG_MEMORY_FAILURE
> +	struct pfn_address_space pfn_address_space;
> +#endif
>  };
>  
>  struct nvgrace_gpu_pci_core_device {
> @@ -60,6 +67,28 @@ struct nvgrace_gpu_pci_core_device {
>  	bool has_mig_hw_bug;
>  };
>  
> +#ifdef CONFIG_MEMORY_FAILURE
> +
> +static int
> +nvgrace_gpu_vfio_pci_register_pfn_range(struct mem_region *region,
> +					struct vm_area_struct *vma)
> +{
> +	unsigned long nr_pages;
> +	int ret = 0;
> +
> +	nr_pages = region->memlength >> PAGE_SHIFT;
> +
> +	region->pfn_address_space.node.start = vma->vm_pgoff;
> +	region->pfn_address_space.node.last = vma->vm_pgoff + nr_pages - 1;
> +	region->pfn_address_space.mapping = vma->vm_file->f_mapping;
> +
> +	ret = register_pfn_address_space(&region->pfn_address_space);
> +
> +	return ret;
> +}
> +
> +#endif
> +
>  static void nvgrace_gpu_init_fake_bar_emu_regs(struct vfio_device *core_vdev)
>  {
>  	struct nvgrace_gpu_pci_core_device *nvdev =
> @@ -127,6 +156,13 @@ static void nvgrace_gpu_close_device(struct vfio_device *core_vdev)
>  
>  	mutex_destroy(&nvdev->remap_lock);
>  
> +#ifdef CONFIG_MEMORY_FAILURE
> +	if (nvdev->resmem.memlength)
> +		unregister_pfn_address_space(&nvdev->resmem.pfn_address_space);
> +
> +	unregister_pfn_address_space(&nvdev->usemem.pfn_address_space);
> +#endif
> +
>  	vfio_pci_core_close_device(core_vdev);
>  }
>  
> @@ -202,7 +238,14 @@ static int nvgrace_gpu_mmap(struct vfio_device *core_vdev,
>  
>  	vma->vm_pgoff = start_pfn;
>  
> -	return 0;
> +#ifdef CONFIG_MEMORY_FAILURE
> +	if (nvdev->resmem.memlength && index == VFIO_PCI_BAR2_REGION_INDEX)
> +		ret = nvgrace_gpu_vfio_pci_register_pfn_range(&nvdev->resmem, vma);
> +	else if (index == VFIO_PCI_BAR4_REGION_INDEX)
> +		ret = nvgrace_gpu_vfio_pci_register_pfn_range(&nvdev->usemem, vma);
> +#endif
> +
> +	return ret;
>  }
>  
>  static long


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ