public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@osdl.org
Cc: linux-kernel@vger.kernel.org,
	uClinux development list <uclinux-dev@uclinux.org>
Subject: [PATCH 3/3] FRV: Make futex code compilable on nommu [try #2]
Date: Tue, 29 Nov 2005 20:42:36 +0000	[thread overview]
Message-ID: <5460.1133296956@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <200511231509.jANF9EwM000983@warthog.cambridge.redhat.com>


The attached patch makes the futex code compilable and usable on NOMMU by
making the attempt to handle page faults conditional on CONFIG_MMU. If this is
not enabled, then we can assume that EFAULT returned from
futex_atomic_op_inuser() is not recoverable, and that the address lies outside
of valid memory.

handle_mm_fault() is made to BUG if called on NOMMU without attempting to
invoke the actual handler (__handle_mm_fault).

Signed-Off-By: David Howells <dhowells@redhat.com>
---
warthog>diffstat -p1 frv-futex-2615rc2-2.diff 
 include/linux/mm.h |   10 ++++++++++
 kernel/futex.c     |    7 +++++++
 2 files changed, 17 insertions(+)

diff -uNrp /warthog/kernels/linux-2.6.15-rc2/include/linux/mm.h linux-2.6.15-rc2-frv/include/linux/mm.h
--- /warthog/kernels/linux-2.6.15-rc2/include/linux/mm.h	2005-11-23 12:09:22.000000000 +0000
+++ linux-2.6.15-rc2-frv/include/linux/mm.h	2005-11-29 20:02:34.000000000 +0000
@@ -708,12 +708,22 @@ static inline void unmap_shared_mapping_
 extern int vmtruncate(struct inode * inode, loff_t offset);
 extern int install_page(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, struct page *page, pgprot_t prot);
 extern int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long pgoff, pgprot_t prot);
+
+#ifdef CONFIG_MMU
 extern int __handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, unsigned long address, int write_access);
 
 static inline int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, int write_access)
 {
 	return __handle_mm_fault(mm, vma, address, write_access) & (~VM_FAULT_WRITE);
 }
+#else
+static inline int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, int write_access)
+{
+	/* should never happen if there's no MMU */
+	BUG();
+	return VM_FAULT_SIGBUS;
+}
+#endif
 
 extern int make_pages_present(unsigned long addr, unsigned long end);
 extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
diff -uNrp /warthog/kernels/linux-2.6.15-rc2/kernel/futex.c linux-2.6.15-rc2-frv/kernel/futex.c
--- /warthog/kernels/linux-2.6.15-rc2/kernel/futex.c	2005-11-23 12:09:23.000000000 +0000
+++ linux-2.6.15-rc2-frv/kernel/futex.c	2005-11-29 20:01:07.000000000 +0000
@@ -365,6 +365,13 @@ retry:
 		if (bh1 != bh2)
 			spin_unlock(&bh2->lock);
 
+#ifndef CONFIG_MMU
+		/* we don't get EFAULT from MMU faults if we don't have an MMU,
+		 * but we might get them from range checking */
+		ret = op_ret;
+		goto out;
+#endif
+
 		if (unlikely(op_ret != -EFAULT)) {
 			ret = op_ret;
 			goto out;

  reply	other threads:[~2005-11-29 20:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-23 15:09 [PATCH 1/3] FRV: Make the FRV arch work again David Howells
2005-11-23 15:09 ` [PATCH 3/3] FRV: Make futex code compilable on nommu David Howells
2005-11-29 20:42   ` David Howells [this message]
2005-11-23 15:09 ` [PATCH 2/3] FRV: Clean up bootmem allocator's page freeing algorithm David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5460.1133296956@warthog.cambridge.redhat.com \
    --to=dhowells@redhat.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=uclinux-dev@uclinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox