Skip to content

Commit 1a77dec

Browse files
Ralph Campbelljgunthorpe
authored andcommitted
nouveau: fix storing invalid ptes
When migrating a range of system memory to device private memory, some of the pages in the address range may not be migrating. In this case, the non migrating pages won't have a new GPU MMU entry to store but the nvif_object_ioctl() NVIF_VMM_V0_PFNMAP method doesn't check the input and stores a bad valid GPU page table entry. Fix this by skipping the invalid input PTEs when updating the GPU page tables. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ralph Campbell <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent b223555 commit 1a77dec

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ gp100_vmm_pgt_pfn(struct nvkm_vmm *vmm, struct nvkm_mmu_pt *pt,
7979
dma_addr_t addr;
8080

8181
nvkm_kmap(pt->memory);
82-
while (ptes--) {
82+
for (; ptes; ptes--, map->pfn++) {
8383
u64 data = 0;
84+
85+
if (!(*map->pfn & NVKM_VMM_PFN_V))
86+
continue;
87+
8488
if (!(*map->pfn & NVKM_VMM_PFN_W))
8589
data |= BIT_ULL(6); /* RO. */
8690

@@ -100,7 +104,6 @@ gp100_vmm_pgt_pfn(struct nvkm_vmm *vmm, struct nvkm_mmu_pt *pt,
100104
}
101105

102106
VMM_WO064(pt, vmm, ptei++ * 8, data);
103-
map->pfn++;
104107
}
105108
nvkm_done(pt->memory);
106109
}
@@ -310,9 +313,12 @@ gp100_vmm_pd0_pfn(struct nvkm_vmm *vmm, struct nvkm_mmu_pt *pt,
310313
dma_addr_t addr;
311314

312315
nvkm_kmap(pt->memory);
313-
while (ptes--) {
316+
for (; ptes; ptes--, map->pfn++) {
314317
u64 data = 0;
315318

319+
if (!(*map->pfn & NVKM_VMM_PFN_V))
320+
continue;
321+
316322
if (!(*map->pfn & NVKM_VMM_PFN_W))
317323
data |= BIT_ULL(6); /* RO. */
318324

@@ -332,7 +338,6 @@ gp100_vmm_pd0_pfn(struct nvkm_vmm *vmm, struct nvkm_mmu_pt *pt,
332338
}
333339

334340
VMM_WO064(pt, vmm, ptei++ * 16, data);
335-
map->pfn++;
336341
}
337342
nvkm_done(pt->memory);
338343
}

0 commit comments

Comments
 (0)