[linux-nvidia-6.18-next] Backport: Add Extended GPU Memory (EGM) virtualization support - #559
Conversation
BugLink: https://bugs.launchpad.net/bugs/2119656 The Extended GPU Memory (EGM) feature enables the GPU access to the system memory across sockets and nodes. In this mode, the physical memory can be allocated for GPU usage from anywhere in a multi-node system. The feature is being extended to virtualization. EGM when enabled in the virtualization stack, the host memory is partitioned into 2: One partition for the Host OS usage, and a second EGM region. The EGM region essentially becomes the system memory of the VM. The following figure shows the memory map in the virtualization environment. |---- Sysmem ----| |--- GPU mem ---| VM Memory Map | | | | | | | | |------ EGM -----|--Host Mem----| |--- GPU mem ---| Host Memory Map The EGM region is not available to the host memory for its usage as it is not added to the kernel. Its base HPA and the length is communicated through the DSDT entries. A linear mapping between the VM IPA and system HPA is a requirement for EGM support. The EGM region is thus assigned to a VM by mapping the QEMU VMA to a linearly increasing HPA of the EGM region using remap_pfn_range(). Introduce a new nvgrace-egm helper module to nvgrace-gpu to manage the EGM/VM region for the VM. nvgrace-egm module handles the following: 1. Fetch the EGM memory properties (base HPA, length, proximity domain). 2. Create a char device that can be used as memory-backend-file by Qemu for the VM and implement file operations. The char device is /dev/egmX, where X is the PXM node ID of the EGM being mapped fetched in 1. 3. Zero the EGM memory on first device open(). 4. Map the QEMU VMA to the EGM region using remap_pfn_range. 5. Cleaning up state and destroying the chardev on device unbind. Signed-off-by: Ankit Agrawal <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Kai-Heng Feng <[email protected]> Acked-by: Koba Ko <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 892ac24 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.8-next) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 3a1b819 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off-by: Brad Figg <[email protected]> (cherry picked from commit 8807f4b noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (backported from commit fa30498 noble:linux-nvidia-6.17) [jacobmartin: adjust patch context to align with upstream commit e5f19b6 ("vfio/nvgrace-gpu: register device memory for poison handling"), as opposed to the original SAUCE version of the same patch.] Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit 5a1e11b https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2119656 It is possible for some system memory pages on the EGM to have uncorrectable ECC errors. A list of pages known with such errors (referred as retired pages) are maintained by the Host UEFI. The Host UEFI populates such list in a reserved region. It communicates the SPA of this region through a ACPI DSDT property. nvgrace-egm module is responsible to store the list of retired page offsets to be made available for usermode processes. The module: 1. Get the reserved memory region SPA and maps to it to fetch the list of bad pages. 2. Calculate the retired page offsets in the EGM and stores it. 3. Expose an ioctl to allow querying of the offsets. The ioctl is called by usermode apps such as QEMU to get the retired page offsets. The usermode apps are expected to take appropriate action to communicate the list to the VM. Signed-off-by: Ankit Agrawal <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Kai-Heng Feng <[email protected]> Acked-by: Koba Ko <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit be54641 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.8-next) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit c4cb193 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit 6b0a6d6 noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit 6494245 noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit 4d66732 https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2119656 Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Kai-Heng Feng <[email protected]> Acked-by: Koba Ko <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 5bb23c1 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.8-next) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 7d2ea55 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit 077c834 noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit f5a03d0 noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (backported from commit 48a4124 https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) [kelseys: no changes to patch, resolved context conflict] Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2119656 nvgrace-egm exposes the API register_egm_node & unregister_egm_node to manage EGM (Extended GPU Memory) present on the system. To allow out-of-tree driver such as nvidia-vgpu-vfio make use of them, move the declaration to a new nvgrace-egm.h in include. Signed-off-by: Ankit Agrawal <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Kai-Heng Feng <[email protected]> Acked-by: Koba Ko <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit bed340f https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.8-next) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit a961663 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit 020c46c noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit 739457a noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit 627a278 https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
…tion BugLink: https://bugs.launchpad.net/bugs/2119656 Free the kmalloc'd region when the EGM is unregistered. Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Kai-Heng Feng <[email protected]> Acked-by: Carol L. Soto <[email protected]> Acked-by: Koba Ko <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit fc592b9 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.8-next) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit f24760c https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit 374b166 noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit 8f781d0 noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit de1f033 https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2119656 Move region hash initiaization alongside the other region initialization statements to avoid situations where the hash table was not properly initialized. Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Kai-Heng Feng <[email protected]> Acked-by: Carol L. Soto <[email protected]> Acked-by: Koba Ko <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 8021c1d https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.8-next) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit e1264a6 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit 0f8a098 noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit 22f790a noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit b0afaa8 https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
…rrors BugLink: https://bugs.launchpad.net/bugs/2119656 Update error handling within EGM regiration routine to catch and return errors to the caller. Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Kai-Heng Feng <[email protected]> Acked-by: Carol L. Soto <[email protected]> Acked-by: Koba Ko <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit a57210c https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.8-next) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit a706ff8 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit edc0ac0 noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit e7a177e noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit b8d20f6 https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2119656 Detect and handle a failure from the EGM registration service. Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Kai-Heng Feng <[email protected]> Acked-by: Carol L. Soto <[email protected]> Acked-by: Koba Ko <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit f18eee3 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.8-next) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 8371b68 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit be5ae8f noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit 2dd5903 noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit d841a67 https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2119656 Fix minor syntax errors from sparse. Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Kai-Heng Feng <[email protected]> Acked-by: Carol L. Soto <[email protected]> Acked-by: Koba Ko <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit bbb64e6 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.8-next) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit fe78194 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit b192960 noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit c1d3f21 noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit 9145d3c https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2119656 Ensure ACPI table reads are successful prior to using the value. Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Kai-Heng Feng <[email protected]> Acked-by: Carol L. Soto <[email protected]> Acked-by: Koba Ko <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit b2947b0 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.8-next) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 9258355 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit 2c5b472 noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit 3f72f24 noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit 63ccf20 https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2119656 Some environments may provide a "nvidia,egm-retired-pages-data-base” but fail to populate it with a base address, leaving it NULL. Mapping this invalid value results in a synchronous exception when the region is first touched. Detect a NULL value, generate a warning to draw attention to the firmware bug, and return without mapping. INFO: th500_ras_intr_handler: External Abort reason=1 syndrome=0x92000410 flags=0x1 [ 82.104493] Internal error: synchronous external abort: 0000000096000410 [NVIDIA#1] SMP [ 82.114898] Modules linked in: nvgrace_gpu_vfio_pci(E) nvgrace_egm(E) [ 82.257218] CPU: 0 PID: 10 Comm: kworker/0:1 Tainted: G OE 6.8.12+ NVIDIA#5 [ 82.265135] Hardware name: NVIDIA GH200 P5042, BIOS 24103110 20241031 [ 82.271720] Workqueue: events work_for_cpu_fn [ 82.276180] pstate: 03400009 (nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--) [ 82.283298] pc : register_egm_node+0x2cc/0x440 [nvgrace_egm] [ 82.289087] lr : register_egm_node+0x2c4/0x440 [nvgrace_egm] [ 82.294872] sp : ffff8000802ebc30 [ 82.298254] x29: ffff8000802ebc60 x28: 00000000000000ff x27: 0000000000000000 [ 82.305550] x26: ffff000087a320c8 x25: ffff0000a5700000 x24: ffff000087a32000 [ 82.312846] x23: ffffa77cd758e368 x22: 0000000000000000 x21: ffffa77cd758c640 [ 82.320141] x20: ffffa77cd758e170 x19: ffff800081e7d000 x18: ffff800080293038 [ 82.327437] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 [ 82.334732] x14: 0000000000000000 x13: 65203a65646f6e5f x12: 0000000000000000 [ 82.342027] x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000 [ 82.349322] x8 : 0000000000000000 x7 : 0000000000000000 x6 : 0000000000000000 [ 82.356618] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000 [ 82.363913] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff800081e7d000 [ 82.371210] Call trace: [ 82.373705] register_egm_node+0x2cc/0x440 [nvgrace_egm] [ 82.379135] nvgrace_gpu_probe+0x2ac/0x528 [nvgrace_gpu_vfio_pci] [ 82.385366] local_pci_probe+0x4c/0xe0 [ 82.389198] work_for_cpu_fn+0x28/0x58 [ 82.393026] process_one_work+0x168/0x3f0 [ 82.397123] worker_thread+0x360/0x480 [ 82.400952] kthread+0x11c/0x128 [ 82.404248] ret_from_fork+0x10/0x20 [ 82.407906] Code: d2820001 940002b3 aa0003f3 b4fffac0 (f9400017) [ 82.414134] ---[ end trace 0000000000000000 ]--- Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Kai-Heng Feng <[email protected]> Acked-by: Carol L. Soto <[email protected]> Acked-by: Koba Ko <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 7ba2930 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.8-next) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 349fb1c https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit 6e9c94a noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit c5992d5 noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit aff377b https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2119656 In an effort to simplify the programming model, use a symmetrical model for the the EGM regsiration APIs. This avoids the caller needing to keep a cookie or even have knowlege of if EGM is supported. Update the EGM unregisration API to use the PCI device as its parameter. Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit d8903ec https://github.com/nvmochs/NV-Kernels/tree/vegm_01232025) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 5839fc5 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit f6fb40e noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit 0e607bc noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit c89cfea https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
…egions BugLink: https://bugs.launchpad.net/bugs/2119656 GB200 systems could have multiple GPUs associated with an EGM region. For proper EGM functionality the host topology in terms of GPU affinity has to be replicated in the VM. Hence the EGM region structure must track the GPU devices belonging to the same socket. On the device probe, the device pci_dev struct is added to a linked list of the appropriate EGM region. Similarly on device remove, the pci_dev struct for the GPU is removed from the EGM region. Signed-off-by: Ankit Agrawal <[email protected]> Ref: sj24: /home/nvidia/ankita/kernel_patches/0001_vfio_nvgrace-egm_track_GPUs_associated_with_the_EGM_regions.patch (koba: Enhance error handling, Remove egm_node from unregister_egm_node and move destroy_egm_chardev a little forward) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 0222c35 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit 5ba1a1f noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit c167095 noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit 1f08cff https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2119656 To replicate the host EGM topology in the VM in terms of the GPU affinity, the userspace need to be aware of which GPUs belong to the same socket as the EGM region. Expose the list of GPUs associated with an EGM region through sysfs. The list can be queried from the location /sys/devices/virtual/egm/egmX/gpu_devices. Signed-off-by: Ankit Agrawal <[email protected]> Ref: sj24: /home/nvidia/ankita/kernel_patches/0002_vfio_nvgrace-egm_list_gpus_through_sysfs.patch (koba: Enchance error handling for sysfs_create_group) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit fec2356 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit 5dde2f0 noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit a5284ca noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit cc460ff https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2119656 To allocate the EGM, the userspace need to know it's size. Currently, there is no easy way for the userspace to determine that. Make nvgrace-egm expose the size through sysfs that can be queried by the userspace from /sys/devices/virtual/egm/egmX/egm_size. Signed-off-by: Ankit Agrawal <[email protected]> Ref: sj24: /home/nvidia/ankita/kernel_patches/0003_vfio_nvgrace-egm_expose_the_egm_size_through_sysfs.patch Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit dcdcef2 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit 9940157 noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit e025c29 noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit 4bf52ef https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
…y_failure BugLink: https://bugs.launchpad.net/bugs/2138892 EGM carveout memory is mapped directly into userspace (QEMU) and is not added to the kernel. It is not managed by the kernel page allocator and has no struct pages. The module can thus utilize the Linux memory manager's memory_failure mechanism for regions with no struct pages. The Linux MM code exposes register/unregister APIs allowing modules to register such memory regions for memory_failure handling. Register the EGM PFN range with the MM memory_failure infrastructure on open, and unregister it on the last close. Provide a PFN-to-VMA offset callback that validates the PFN is within the EGM region and the VMA, then converts it to a file offset and records the poisoned offset in the existing hashtable for reporting to userspace. Signed-off-by: Ankit Agrawal <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Jacob Martin <[email protected]> Acked-by: Noah Wager <[email protected]> Signed-off-by: Brad Figg <[email protected]> (cherry picked from commit 3fde504 noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit de5a032 https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2119656 Return the intended errno upon a copyout fault, remove unnecessary checks following container_of pointer derivation, and use the correct macro and types for overflow checking. Signed-off-by: Matthew R. Ochs <[email protected]> Acked-by: Kai-Heng Feng <[email protected]> Acked-by: Carol L. Soto <[email protected]> Acked-by: Koba Ko <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 429910b https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.8-next) Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit bda63f3 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit 942bf3b noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (cherry picked from commit 63dd059 noble:linux-nvidia-6.17) Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit f8c59b7 https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
… allocations BugLink: https://bugs.launchpad.net/bugs/2119656 Add missing null pointer checks after vzalloc() calls in the NVIDIA Grace GPU driver's EGM (External GPU Memory) handling code. This prevents potential null pointer dereferences in the memory failure handling and bad page fetching functions, providing proper error handling for allocation failures. Signed-off-by: Koba Ko <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Carol L. Soto <[email protected]> Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 63127e2 https://github.com/NVIDIA/NV-Kernels/tree/24.04_linux-nvidia-adv-6.11-next) Signed-off-by: Nirmoy Das <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matt Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off--by: Brad Figg <[email protected]> (cherry picked from commit e5f0c8d noble:linux-nvidia-6.14) Signed-off-by: Abdur Rahman <[email protected]> (backported from commit 862ed5a noble:linux-nvidia-6.17) [mochs: Addressed collission for a null pointer check that is no longer needed] Signed-off-by: Matthew R. Ochs <[email protected]> (cherry picked from commit 8e8763e https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/2142160 When initializing EGM (Extended GPU Memory) regions, the current implementation performs a single memset operation over the entire memory region. For very large regions, this can result in long-running uninterruptible operations that may cause system responsiveness issues or trigger watchdog timeouts. Split the memset operation into 1GB chunks. Signed-off-by: Ankit Agrawal <[email protected]> Acked-by: Carol L Soto <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Acked-by: Noah Wager <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off-by: Brad Figg <[email protected]> (cherry picked from commit 3554744 noble:linux-nvidia-6.17) Signed-off-by: Jacob Martin <[email protected]> (cherry picked from commit a577394 https://github.com/NVIDIA/NV-Kernels/tree/26.04_linux-nvidia) Signed-off-by: Kelsey Steele <[email protected]>
BaseOS Kernel ReviewWarning
|
|
|
|
|
I confirmed all the patches have the correct provenance. I also confirmed that CONFIG_NVGRACE_EGM is already present in the full*.config files which we typically use to construct a kconfig for this kernel. Reviewing with codex yielded some existing corner case issues, but I don't think it is worth fixing those as this series will eventually be replaced with a different implementation that is being pursued by Ankit upstream. I am providing my ack for the series based on review, but would like for Kelsey to complete testing on GH / GB before it is merged. |
Summary
Backports the EGM (Extended GPU Memory) driver support for Grace GPU passthrough.
18 of the 19 patches are clean cherry-picks from
26.04_linux-nvidia.The one backport "arm64: configs: Build CONFIG_NVGRACE_EGM as LKM", is only such due to context changes around the code. The patch itself is the same.
Testing
nvgrace_egmloads and correctly attaches as an auxiliary device ofnvgrace_gpu_vfio_pci(lsmodshowsnvgrace_egm ... 1 nvgrace_gpu_vfio_pci)./dev/egm*device creation, EGM-backed VM boot) as I seem to be restricted on enabling EGM through the bios on my reserved machine. I put out a request to enable this and waiting to hear back. Though since this was all a clean backport from 26.04 and lived in our 6.17 kernel also, I'm setting up the PR.