Commit 4fc0870d authored by Christophe Lombard's avatar Christophe Lombard Committed by Michael Ellerman

cxl: Fix memory page not handled

The in-kernel 'library' API can be called by drivers to help
interaction with an IBM XSL on a POWER9 system.

The cxllib_handle_fault() API is used to handle memory fault. All memory
pages of the specified buffer have to be handled but under certain
conditions,the last page may not be touched, and the address the
adapter is trying to access is never sent to the kernel for resolution.

This patch reworks start address of the loop with an address aligned on
the page size. In this context, the last page is not missed.
Signed-off-by: default avatarChristophe Lombard <clombard@linux.vnet.ibm.com>
Acked-by: default avatarFrederic Barrat <fbarrat@linux.vnet.ibm.com>
Acked-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>

Fixes: 3ced8d73 ("cxl: Export library to support IBM XSL");
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent bca73f59
...@@ -219,8 +219,17 @@ int cxllib_handle_fault(struct mm_struct *mm, u64 addr, u64 size, u64 flags) ...@@ -219,8 +219,17 @@ int cxllib_handle_fault(struct mm_struct *mm, u64 addr, u64 size, u64 flags)
down_read(&mm->mmap_sem); down_read(&mm->mmap_sem);
for (dar = addr; dar < addr + size; dar += page_size) { vma = find_vma(mm, addr);
if (!vma || dar < vma->vm_start || dar > vma->vm_end) { if (!vma) {
pr_err("Can't find vma for addr %016llx\n", addr);
rc = -EFAULT;
goto out;
}
/* get the size of the pages allocated */
page_size = vma_kernel_pagesize(vma);
for (dar = (addr & ~(page_size - 1)); dar < (addr + size); dar += page_size) {
if (dar < vma->vm_start || dar >= vma->vm_end) {
vma = find_vma(mm, addr); vma = find_vma(mm, addr);
if (!vma) { if (!vma) {
pr_err("Can't find vma for addr %016llx\n", addr); pr_err("Can't find vma for addr %016llx\n", addr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment