linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Joakim Tjernlund <joakim.tjernlund@transmode.se>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Scott Wood <scottwood@freescale.com>,
	"linuxppc-dev@ozlabs.org" <linuxppc-dev@ozlabs.org>,
	Rex Feany <RFeany@mrv.com>
Subject: Re: [PATCH 0/6] PowerPc 8xx TLB/MMU fixes
Date: Tue, 6 Oct 2009 15:18:33 +0200	[thread overview]
Message-ID: <OFC5E527BE.77D28888-ONC1257647.00489546-C1257647.00491C0F@transmode.se> (raw)
In-Reply-To: <1254827186.6035.11.camel@pasglop>

Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote on 06/10/2009 13:06:26:
>
> On Tue, 2009-10-06 at 12:58 +0200, Joakim Tjernlund wrote:
>
> > Here I don't care if err. insn will be 0 if it fails and the following
> > if will be false
>
> I'd rather you use get_user() so it does access_ok().
>
> Else, you can probably manufacture some code that will make the kernel
> access some MMIO register for example, which could be nasty.
>
> At this point, you may as well also check the result even if indeed a
> fault isn't going to matter. Just makes the code cleaner and avoids some
> random janitor coming up with a patch later on :-)
>
> Cheers,
> Ben.

So my user space access was bust. Try slapping this on top
It might be that my crappy user space handling also tripped the
asm version, would be great if you could try that one again too.

I suspect that you both, Rex and Scott, have dcbX/icbi insn's in user
space that trip DTLB errors, that would explain everything I think.

      Jocke

diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index c33c6de..d757ec8 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -152,8 +152,16 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
 		unsigned long ra, rb, dar, insn;
 #ifdef DEBUG_DCBX
 		const char *istr = NULL;
+		int ret;
+
+		insn = 0;
+		if (user_mode(regs)) {
+			if ((ret = get_user(insn, (unsigned long __user *)regs->nip)))
+				printk(KERN_CRIT "get_user:NIP:0x%08lx, err:%d\n",
+				       regs->nip, ret);
+		} else
+			insn = *((unsigned long *)regs->nip);

-		insn = *((unsigned long *)regs->nip);
 		if (((insn >> (31-5)) & 0x3f) == 31) {
 			if (((insn >> 1) & 0x3ff) == 1014) /* dcbz ? 0x3f6 */
 				istr = "dcbz";
@@ -178,20 +186,27 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
 					       ra, rb, dar);
 					is_write = 0;
 				}
-
+#if 0
 				if (trap == 0x300 && address != dar) {
 					__asm__ ("mtdar %0" : : "r" (dar));
 					return 0;
 				}
+#endif
 			}
 		}
 #endif
 		if (address == 0x00f0 && trap == 0x300) {
-			pte_t *ptep;
-
+			int ret;
 			/* This is from a dcbX or icbi insn gone bad, these
 			 * insn do not set DAR so we have to do it here instead */
-			insn = *((unsigned long *)regs->nip);
+			if (user_mode(regs)) {
+				if ((ret = get_user(insn, (unsigned long __user *)regs->nip))) {
+					printk(KERN_CRIT "get_user:NIP:%lx, err:%d\n",
+					       regs->nip, ret);
+					goto bad_area_nosemaphore;
+				}
+			} else
+				insn = *((unsigned long *)regs->nip);

 			ra = (insn >> (31-15)) & 0x1f; /* Reg RA */
 			rb = (insn >> (31-20)) & 0x1f; /* Reg RB */
@@ -206,18 +221,6 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
 			       trap, address, dar, error_code, istr);
 #endif
 			address = dar;
-#if 1
-			if (is_write && get_pteptr(mm, dar, &ptep, NULL)) {
-				pte_t my_pte = *ptep;
-
-				if (pte_present(my_pte) && pte_write(my_pte)) {
-					pte_val(my_pte) |= _PAGE_DIRTY|_PAGE_ACCESSED|_PAGE_HWWRITE;
-					set_pte_at(mm, dar, ptep, my_pte);
-				}
-			}
-#else
-			return 0;
-#endif
 		}
 	}
 #endif

  parent reply	other threads:[~2009-10-06 13:22 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-05 12:16 [PATCH 0/6] PowerPc 8xx TLB/MMU fixes Joakim Tjernlund
2009-10-05 12:16 ` [PATCH 1/6] 8xx: DTLB Error must check for more errors Joakim Tjernlund
2009-10-05 12:16   ` [PATCH 2/6] 8xx, fault: Add some debug code to do_page_fault() Joakim Tjernlund
2009-10-05 12:16     ` [PATCH 3/6] 8xx: get rid of _PAGE_HWWRITE dependency in MMU Joakim Tjernlund
2009-10-05 12:16       ` [PATCH 4/6] 8xx: Tag DAR with 0x00f0 to catch buggy instructions Joakim Tjernlund
2009-10-05 12:16         ` [PATCH 5/6] 8xx: Fixup DAR from buggy dcbX instructions Joakim Tjernlund
2009-10-05 12:16           ` [PATCH 6/6] 8xx: start using dcbX instructions in various copy routines Joakim Tjernlund
2009-10-05 20:17       ` [PATCH 3/6] 8xx: get rid of _PAGE_HWWRITE dependency in MMU Benjamin Herrenschmidt
2009-10-05 21:25         ` Joakim Tjernlund
2009-10-05 21:37           ` Benjamin Herrenschmidt
2009-10-05 22:00             ` Joakim Tjernlund
2009-10-05 22:09               ` Benjamin Herrenschmidt
2009-10-05 22:55                 ` Joakim Tjernlund
2009-10-05 23:15                   ` Benjamin Herrenschmidt
2009-10-05 23:35                     ` Joakim Tjernlund
2009-10-06  0:34                       ` Benjamin Herrenschmidt
2009-10-06  6:15                         ` Joakim Tjernlund
2009-10-06  6:45                           ` Benjamin Herrenschmidt
2009-10-06  7:54                             ` Joakim Tjernlund
2009-10-06 15:40                             ` Joakim Tjernlund
2009-10-06 17:28                               ` Joakim Tjernlund
2009-10-06 22:05                         ` Joakim Tjernlund
2009-10-06 23:25                           ` Benjamin Herrenschmidt
2009-10-07  1:07                           ` Benjamin Herrenschmidt
2009-10-07  7:47                             ` Joakim Tjernlund
2009-10-05 18:12 ` [PATCH 0/6] PowerPc 8xx TLB/MMU fixes Scott Wood
2009-10-05 18:27   ` Joakim Tjernlund
2009-10-05 20:09     ` Scott Wood
2009-10-05 21:04       ` Joakim Tjernlund
2009-10-05 21:31         ` Benjamin Herrenschmidt
2009-10-05 21:41           ` Joakim Tjernlund
2009-10-05 21:46             ` Scott Wood
2009-10-05 21:31         ` Scott Wood
2009-10-05 22:04 ` Rex Feany
2009-10-05 22:31   ` Joakim Tjernlund
2009-10-05 22:37     ` Benjamin Herrenschmidt
2009-10-05 22:58       ` Joakim Tjernlund
2009-10-05 23:49       ` Joakim Tjernlund
2009-10-06  1:52         ` Benjamin Herrenschmidt
2009-10-06  8:06           ` Joakim Tjernlund
2009-10-06  8:32             ` Benjamin Herrenschmidt
2009-10-06 10:58               ` Joakim Tjernlund
2009-10-06 11:06                 ` Benjamin Herrenschmidt
2009-10-06 11:39                   ` Joakim Tjernlund
2009-10-06 13:18                   ` Joakim Tjernlund [this message]
2009-10-05 22:42     ` Rex Feany
2009-10-05 23:00       ` Joakim Tjernlund
2009-10-06  6:25       ` Joakim Tjernlund
2009-10-06  6:44         ` Benjamin Herrenschmidt

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=OFC5E527BE.77D28888-ONC1257647.00489546-C1257647.00491C0F@transmode.se \
    --to=joakim.tjernlund@transmode.se \
    --cc=RFeany@mrv.com \
    --cc=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=scottwood@freescale.com \
    /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;
as well as URLs for NNTP newsgroup(s).