Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 782ba411 authored by Shrenuj Bansal's avatar Shrenuj Bansal
Browse files

msm: kgsl: Restrict mmap area to the svm upper bound



Currently mmap can map a memory region upto TASK_SIZE which bodes
a problem for SVM on arm64. This is because the TASK_SIZE exceeds
the addresses which can be handled by the GPU and also goes into
the region where we place our global pagetable mappings. Therefore,
we need to restrict the region to match the arm32 address map.

Change-Id: Idae9e74d7ed9c78d3fabded0e0e974ef3c711351
Signed-off-by: default avatarShrenuj Bansal <shrenujb@codeaurora.org>
parent faefe1ea
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -3788,6 +3788,10 @@ kgsl_get_unmapped_area(struct file *file, unsigned long addr,
	}
	/* special case handling for MAP_FIXED */
	if (flags & MAP_FIXED) {
		if (addr + len > KGSL_SVM_UPPER_BOUND) {
			ret = -EFAULT;
			goto put;
		}
		ret = get_unmapped_area(NULL, addr, len, pgoff, flags);
		if (!ret || IS_ERR_VALUE(ret))
			goto put;
@@ -3816,7 +3820,7 @@ kgsl_get_unmapped_area(struct file *file, unsigned long addr,
	 * first try to see if the suggested address is accepted by the
	 * system map and our gpu map
	 */
	if (addr) {
	if (addr && (addr + len <= KGSL_SVM_UPPER_BOUND)) {
		vma = find_vma(current->mm, addr);
		if (!vma || ((addr + len) <= vma->vm_start)) {

@@ -3882,11 +3886,12 @@ kgsl_get_unmapped_area(struct file *file, unsigned long addr,
		if (flag_top_down) {
			info.flags = VM_UNMAPPED_AREA_TOPDOWN;
			info.low_limit = PAGE_SIZE;
			info.high_limit = addr;
			info.high_limit = (addr > KGSL_SVM_UPPER_BOUND) ?
						KGSL_SVM_UPPER_BOUND : addr;
		} else {
			info.flags = 0;
			info.low_limit = addr;
			info.high_limit = TASK_SIZE;
			info.high_limit = KGSL_SVM_UPPER_BOUND;
		}
		ret = vm_unmapped_area(&info);

+3 −0
Original line number Diff line number Diff line
@@ -43,6 +43,9 @@
/* The size of each entry in a page table */
#define KGSL_PAGETABLE_ENTRY_SIZE  4

/* The SVM upper bound is the same as the TASK_SIZE in arm32 */
#define KGSL_SVM_UPPER_BOUND (0xC0000000 - SZ_16M)

/* Pagetable Virtual Address base */
#ifndef CONFIG_MSM_KGSL_CFF_DUMP
#define KGSL_PAGETABLE_BASE	0x10000000