From d8ad075ef60ca33f1bd8e227eed2202108fd6cd8 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Tue, 9 Jan 2007 10:18:50 +0100 Subject: [PATCH] [S390] don't call handle_mm_fault() if in an atomic context. There are several places in the futex code where a spin_lock is held and still uaccesses happen. Deadlocks are avoided by increasing the preempt count. The pagefault handler will then not take any locks but will immediately search the fixup tables. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/lib/uaccess_pt.c | 3 +++ arch/s390/lib/uaccess_std.c | 3 --- include/asm-s390/futex.h | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/s390/lib/uaccess_pt.c b/arch/s390/lib/uaccess_pt.c index 633249c3ba91..49c3e46b4065 100644 --- a/arch/s390/lib/uaccess_pt.c +++ b/arch/s390/lib/uaccess_pt.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -18,6 +19,8 @@ static inline int __handle_fault(struct mm_struct *mm, unsigned long address, struct vm_area_struct *vma; int ret = -EFAULT; + if (in_atomic()) + return ret; down_read(&mm->mmap_sem); vma = find_vma(mm, address); if (unlikely(!vma)) diff --git a/arch/s390/lib/uaccess_std.c b/arch/s390/lib/uaccess_std.c index bbaca66fa293..56a0214e9928 100644 --- a/arch/s390/lib/uaccess_std.c +++ b/arch/s390/lib/uaccess_std.c @@ -258,8 +258,6 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old) { int oldval = 0, newval, ret; - pagefault_disable(); - switch (op) { case FUTEX_OP_SET: __futex_atomic_op("lr %2,%5\n", @@ -284,7 +282,6 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old) default: ret = -ENOSYS; } - pagefault_enable(); *old = oldval; return ret; } diff --git a/include/asm-s390/futex.h b/include/asm-s390/futex.h index 5e261e1de671..5c5d02de49e9 100644 --- a/include/asm-s390/futex.h +++ b/include/asm-s390/futex.h @@ -4,8 +4,8 @@ #ifdef __KERNEL__ #include +#include #include -#include static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) { @@ -21,7 +21,9 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) return -EFAULT; + pagefault_disable(); ret = uaccess.futex_atomic_op(op, uaddr, oparg, &oldval); + pagefault_enable(); if (!ret) { switch (cmp) {