Revert "video: tegra: nvmap: Fix INT30-C overflow defects"

This reverts commit 537bcc28c6cc97586028a72c1555d7b70b6ed21b.

Reason for revert: Bug 5017529

Signed-off-by: Satvik Raj Gupta <satvikrajg@nvidia.com>
Change-Id: I7350199fe8d3929139ad3d88975ff65285363af7
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3270140
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Satvik Raj Gupta
2024-12-17 20:17:21 -08:00
committed by Jon Hunter
parent d1f2b6a051
commit 4b785c2e35
2 changed files with 11 additions and 40 deletions

View File

@@ -44,7 +44,7 @@ void *__nvmap_mmap(struct nvmap_handle *h)
{
pgprot_t prot;
void *vaddr;
unsigned long adj_size, sum;
unsigned long adj_size;
struct page **pages = NULL;
int i = 0;
@@ -96,10 +96,7 @@ void *__nvmap_mmap(struct nvmap_handle *h)
/* carveout - explicitly map the pfns into a vmalloc area */
adj_size = nvmap_get_heap_block_base(h->carveout) & ~PAGE_MASK;
if (check_add_overflow(adj_size, h->size, &sum))
goto dec_kmaps;
adj_size = sum;
adj_size += h->size;
adj_size = PAGE_ALIGN(adj_size);
if (pfn_valid(__phys_to_pfn(nvmap_get_heap_block_base(h->carveout) & PAGE_MASK))) {
@@ -152,7 +149,6 @@ void *__nvmap_mmap(struct nvmap_handle *h)
out:
if (pages)
vfree(pages);
dec_kmaps:
nvmap_kmaps_dec(h);
put_handle:
nvmap_handle_put(h);

View File

@@ -297,18 +297,17 @@ static int nvmap_page_mapcount(struct page *page)
}
#define PSS_SHIFT 12
static int nvmap_get_total_mss(u64 *pss, u64 *total, u32 heap_type, int numa_id)
static void nvmap_get_total_mss(u64 *pss, u64 *total, u32 heap_type, int numa_id)
{
int i;
struct rb_node *n;
struct nvmap_device *dev = nvmap_dev;
u64 sum;
*total = 0;
if (pss)
*pss = 0;
if (dev == NULL)
return 0;
return;
spin_lock(&dev->handle_lock);
n = rb_first(&dev->handles);
for (; n != NULL; n = rb_next(n)) {
@@ -323,30 +322,18 @@ static int nvmap_get_total_mss(u64 *pss, u64 *total, u32 heap_type, int numa_id)
numa_id))
continue;
if (check_sub_overflow(*total, (u64)h->size, &sum)) {
spin_unlock(&dev->handle_lock);
return -EOVERFLOW;
}
*total = sum;
*total += h->size;
if (!pss)
continue;
for (i = 0; i < h->size >> PAGE_SHIFT; i++) {
struct page *page = nvmap_to_page(h->pgalloc.pages[i]);
if (nvmap_page_mapcount(page) > 0) {
if (check_sub_overflow(*pss, (u64)PAGE_SIZE, &sum)) {
spin_unlock(&dev->handle_lock);
return -EOVERFLOW;
}
if (nvmap_page_mapcount(page) > 0)
*pss += PAGE_SIZE;
}
}
}
spin_unlock(&dev->handle_lock);
return 0;
}
static int nvmap_debug_allocations_show(struct seq_file *s, void *unused)
@@ -378,10 +365,7 @@ static int nvmap_debug_allocations_show(struct seq_file *s, void *unused)
seq_puts(s, "\n");
}
mutex_unlock(&nvmap_dev->clients_lock);
err = nvmap_get_total_mss(NULL, &total, heap_type, numa_id);
if (err != 0)
return err;
nvmap_get_total_mss(NULL, &total, heap_type, numa_id);
seq_printf(s, "%-18s %-18s %8s %10lluK\n", "total", "", "", K(total));
return 0;
}
@@ -597,10 +581,7 @@ static int nvmap_debug_maps_show(struct seq_file *s, void *unused)
}
mutex_unlock(&nvmap_dev->clients_lock);
err = nvmap_get_total_mss(NULL, &total, heap_type, numa_id);
if (err != 0)
return err;
nvmap_get_total_mss(NULL, &total, heap_type, numa_id);
seq_printf(s, "%-18s %-18s %8s %10lluK\n", "total", "", "", K(total));
return 0;
}
@@ -610,11 +591,11 @@ DEBUGFS_OPEN_FOPS(maps);
static int nvmap_debug_clients_show(struct seq_file *s, void *unused)
{
u64 total;
int err;
struct nvmap_client *client;
struct debugfs_info *debugfs_information = (struct debugfs_info *)s->private;
u32 heap_type = nvmap_get_debug_info_heap(debugfs_information);
int numa_id = nvmap_get_debug_info_nid(debugfs_information);
int err;
mutex_lock(&nvmap_dev->clients_lock);
seq_printf(s, "%-18s %18s %8s %11s\n",
@@ -631,10 +612,7 @@ static int nvmap_debug_clients_show(struct seq_file *s, void *unused)
seq_printf(s, " %10lluK\n", K(client_total));
}
mutex_unlock(&nvmap_dev->clients_lock);
err = nvmap_get_total_mss(NULL, &total, heap_type, numa_id);
if (err != 0)
return err;
nvmap_get_total_mss(NULL, &total, heap_type, numa_id);
seq_printf(s, "%-18s %18s %8s %10lluK\n", "total", "", "", K(total));
return 0;
}
@@ -855,10 +833,7 @@ static int nvmap_debug_iovmm_procrank_show(struct seq_file *s, void *unused)
}
mutex_unlock(&dev->clients_lock);
err = nvmap_get_total_mss(&total_pss, &total_memory, NVMAP_HEAP_IOVMM, NUMA_NO_NODE);
if (err != 0)
return err;
nvmap_get_total_mss(&total_pss, &total_memory, NVMAP_HEAP_IOVMM, NUMA_NO_NODE);
seq_printf(s, "%-18s %18s %8s %10lluK %10lluK\n",
"total", "", "", K(total_pss), K(total_memory));
return 0;