vcsm: Treat EBUSY as success rather than SIGBUS
authorpopcornmix <popcornmix@gmail.com>
Tue, 2 May 2017 15:36:05 +0000 (16:36 +0100)
committerRaspbian kernel package updater <root@raspbian.org>
Sun, 8 Oct 2017 01:08:04 +0000 (01:08 +0000)
Currently if two cores access the same page concurrently one will return VM_FAULT_NOPAGE
and the other VM_FAULT_SIGBUS crashing the user code.

Also report when mapping fails.

Signed-off-by: popcornmix <popcornmix@gmail.com>
drivers/char/broadcom/vc_sm/vmcs_sm.c

index 1db6716c2c0c8b2013203391501f92d09db258af..ee4e05948c439a9045e0b65566d57587177a32e2 100644 (file)
@@ -1181,11 +1181,20 @@ static int vcsm_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
        switch (ret) {
        case 0:
        case -ERESTARTSYS:
+       /*
+       * EBUSY is ok: this just means that another thread
+       * already did the job.
+       */
+       case -EBUSY:
                return VM_FAULT_NOPAGE;
        case -ENOMEM:
        case -EAGAIN:
+               pr_err("[%s]: failed to map page pfn:%lx virt:%lx ret:%d\n", __func__,
+                       pfn, (unsigned long)vmf->virtual_address, ret);
                return VM_FAULT_OOM;
        default:
+               pr_err("[%s]: failed to map page pfn:%lx virt:%lx ret:%d\n", __func__,
+                       pfn, (unsigned long)vmf->virtual_address, ret);
                return VM_FAULT_SIGBUS;
        }
 }