From e8670d68dcf70837ef6b7ad178e72963b3d2c90d Mon Sep 17 00:00:00 2001 From: Zhou Guanghui Date: Wed, 6 Nov 2019 16:33:40 +0800 Subject: [PATCH] svm: reserve 4G for dvpp in func get_unmaped_area of svm fops ascend inclusion category: bugfix bugzilla: NA CVE: NA ------------ Reserve 4G map for DVPP. Signed-off-by: Zhou Guanghui Signed-off-by: Lijun Fang Reviewed-by: Kefeng Wang Signed-off-by: Yang Yingliang --- drivers/char/svm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/char/svm.c b/drivers/char/svm.c index 7a97ad82bae8..a0aba1659727 100644 --- a/drivers/char/svm.c +++ b/drivers/char/svm.c @@ -1529,6 +1529,9 @@ static unsigned long svm_get_unmapped_area(struct file *file, struct vm_area_struct *vma = NULL; addr = ALIGN(addr, len); + if (!mmap_va32bit_check(addr, len, flags)) + return -ENOMEM; + vma = find_vma(mm, addr); if (TASK_SIZE - len >= addr && addr >= mmap_min_addr && (vma == NULL || addr + len <= vm_start_gap(vma))) @@ -1539,8 +1542,10 @@ static unsigned long svm_get_unmapped_area(struct file *file, info.length = len; info.low_limit = max(PAGE_SIZE, mmap_min_addr); info.high_limit = mm->mmap_base; + /* the addr will be get must align to the size of l2buf */ info.align_mask = ((len >> PAGE_SHIFT) - 1) << PAGE_SHIFT; info.align_offset = pgoff << PAGE_SHIFT; + mmap_va32bit_set_limit(&info, flags); addr = vm_unmapped_area(&info); if (offset_in_page(addr)) { @@ -1548,6 +1553,7 @@ static unsigned long svm_get_unmapped_area(struct file *file, info.flags = 0; info.low_limit = TASK_UNMAPPED_BASE; info.high_limit = TASK_SIZE; + mmap_va32bit_set_limit(&info, flags); addr = vm_unmapped_area(&info); } -- GitLab