public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] x86: Further shrink ifdef sections in fault.c
@ 2008-01-25  1:05 Harvey Harrison
  2008-01-25 11:13 ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Harvey Harrison @ 2008-01-25  1:05 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: H. Peter Anvin, Thomas Gleixner, LKML

Move the vmalloc address tests from the if statement into
vmalloc_fault.  This allows 32 and 64 bit to share the same
if block.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 arch/x86/mm/fault.c |   24 +++++++-----------------
 1 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 95fe8bf..bdf0282 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -468,6 +468,9 @@ static int vmalloc_fault(unsigned long address)
 	pmd_t *pmd, *pmd_ref;
 	pte_t *pte, *pte_ref;
 
+	if (!(address >= VMALLOC_START && address < VMALLOC_END))
+		return -1;
+
 	/* Copy kernel mappings over when needed. This can also
 	   happen within a race in page table update. In the later
 	   case just flush. */
@@ -563,6 +566,9 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
 	 */
 #ifdef CONFIG_X86_32
 	if (unlikely(address >= TASK_SIZE)) {
+#else
+	if (unlikely(address >= TASK_SIZE64)) {
+#endif
 		if (!(error_code & (PF_RSVD|PF_USER|PF_PROT)) &&
 		    vmalloc_fault(address) >= 0)
 			return;
@@ -573,6 +579,7 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
 		goto bad_area_nosemaphore;
 	}
 
+#ifdef CONFIG_X86_32
 	/* It's safe to allow irq's after cr2 has been saved and the vmalloc
 	   fault has been handled. */
 	if (regs->flags & (X86_EFLAGS_IF|VM_MASK))
@@ -585,23 +592,6 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
 	if (in_atomic() || !mm)
 		goto bad_area_nosemaphore;
 #else /* CONFIG_X86_64 */
-	if (unlikely(address >= TASK_SIZE64)) {
-		/*
-		 * Don't check for the module range here: its PML4
-		 * is always initialized because it's shared with the main
-		 * kernel text. Only vmalloc may need PML4 syncups.
-		 */
-		if (!(error_code & (PF_RSVD|PF_USER|PF_PROT)) &&
-		      ((address >= VMALLOC_START && address < VMALLOC_END))) {
-			if (vmalloc_fault(address) >= 0)
-				return;
-		}
-		/*
-		 * Don't take the mm semaphore here. If we fixup a prefetch
-		 * fault we could otherwise deadlock.
-		 */
-		goto bad_area_nosemaphore;
-	}
 	if (likely(regs->flags & X86_EFLAGS_IF))
 		local_irq_enable();
 
-- 
1.5.4.rc4.1130.g9ad85


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] x86: Further shrink ifdef sections in fault.c
  2008-01-25  1:05 [PATCH 2/2] x86: Further shrink ifdef sections in fault.c Harvey Harrison
@ 2008-01-25 11:13 ` Ingo Molnar
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2008-01-25 11:13 UTC (permalink / raw)
  To: Harvey Harrison; +Cc: H. Peter Anvin, Thomas Gleixner, LKML


* Harvey Harrison <harvey.harrison@gmail.com> wrote:

> +	if (!(address >= VMALLOC_START && address < VMALLOC_END))
> +		return -1;

ah, this explains the weird chunk in your other patch.

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] x86: Further shrink ifdef sections in fault.c
       [not found] ` <9PuLt-2sk-33@gated-at.bofh.it>
@ 2008-04-23  7:20   ` Henry Nestler
       [not found]   ` <480E859D.80105@arcor.de>
  1 sibling, 0 replies; 4+ messages in thread
From: Henry Nestler @ 2008-04-23  7:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: harvey.harrison

Ingo Molnar wrote:
> * Harvey Harrison <harvey.harrison@gmail.com> wrote:
> 
>> +	if (!(address >= VMALLOC_START && address < VMALLOC_END))
>> +		return -1;
> 
> ah, this explains the weird chunk in your other patch.

Why this is not in x86_32?

Please see my other mail "x86: endless page faults in mount_block_root
for Linux 2.6", with problem without this check.

-- 
Henry N.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] x86: Further shrink ifdef sections in fault.c
       [not found]   ` <480E859D.80105@arcor.de>
@ 2008-04-23  8:05     ` Harvey Harrison
  0 siblings, 0 replies; 4+ messages in thread
From: Harvey Harrison @ 2008-04-23  8:05 UTC (permalink / raw)
  To: Henry Nestler; +Cc: Ingo Molnar, Andi Kleen, LKML

On Wed, 2008-04-23 at 02:41 +0200, Henry Nestler wrote:
> Ingo Molnar wrote:
> > * Harvey Harrison <harvey.harrison@gmail.com> wrote:
> > 
> >> +	if (!(address >= VMALLOC_START && address < VMALLOC_END))
> >> +		return -1;
> > 
> > ah, this explains the weird chunk in your other patch.
> 
> Why this is not in x86_32?
> 
> Please see my other mail "x86: endless page faults in mount_block_root
> for Linux 2.6"
> 

Hmm, no idea why it wasn't in the 32-bit version.  Looks like something
fixed in the 64 bit versions but not 32-bit.

See:

commit 3b9ba4d5e23fcab24dd4d2e46dce11f5863869b4
commit f95190b28daa1bebf78ab5ec4129d01a223982c5


Cheers,

Harvey


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-23  8:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-25  1:05 [PATCH 2/2] x86: Further shrink ifdef sections in fault.c Harvey Harrison
2008-01-25 11:13 ` Ingo Molnar
     [not found] <9Plf4-3KR-11@gated-at.bofh.it>
     [not found] ` <9PuLt-2sk-33@gated-at.bofh.it>
2008-04-23  7:20   ` Henry Nestler
     [not found]   ` <480E859D.80105@arcor.de>
2008-04-23  8:05     ` Harvey Harrison

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox