All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Metcalf <cmetcalf@tilera.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] arch/tile: fix two bugs in the backtracer code
Date: Mon, 28 Feb 2011 15:30:16 -0500	[thread overview]
Message-ID: <201103011934.p21JYdCi010307@farm-0010.internal.tilera.com> (raw)
In-Reply-To: <201103011931.p21JVtqp010237@farm-0010.internal.tilera.com>

The first is that we were using an incorrect hand-rolled variant
of __kernel_text_address() which didn't handle module PCs.  We now
just use the standard API.

The second was that we weren't accounting for the three-level
page table when we were trying to pre-verify the addresses on
the 64-bit TILE-Gx processor; we now do that correctly.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
---
 arch/tile/kernel/stack.c |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/arch/tile/kernel/stack.c b/arch/tile/kernel/stack.c
index 0d54106..dd81713 100644
--- a/arch/tile/kernel/stack.c
+++ b/arch/tile/kernel/stack.c
@@ -44,13 +44,6 @@ static int in_kernel_stack(struct KBacktraceIterator *kbt, VirtualAddress sp)
 	return sp >= kstack_base && sp < kstack_base + THREAD_SIZE;
 }
 
-/* Is address in the specified kernel code? */
-static int in_kernel_text(VirtualAddress address)
-{
-	return (address >= MEM_SV_INTRPT &&
-		address < MEM_SV_INTRPT + HPAGE_SIZE);
-}
-
 /* Is address valid for reading? */
 static int valid_address(struct KBacktraceIterator *kbt, VirtualAddress address)
 {
@@ -63,6 +56,23 @@ static int valid_address(struct KBacktraceIterator *kbt, VirtualAddress address)
 	if (l1_pgtable == NULL)
 		return 0;	/* can't read user space in other tasks */
 
+#ifdef CONFIG_64BIT
+	/* Find the real l1_pgtable by looking in the l0_pgtable. */
+	pte = l1_pgtable[HV_L0_INDEX(address)];
+	if (!hv_pte_get_present(pte))
+		return 0;
+	pfn = hv_pte_get_pfn(pte);
+	if (pte_huge(pte)) {
+		if (!pfn_valid(pfn)) {
+			pr_err("L0 huge page has bad pfn %#lx\n", pfn);
+			return 0;
+		}
+		return hv_pte_get_present(pte) && hv_pte_get_readable(pte);
+	}
+	page = pfn_to_page(pfn);
+	BUG_ON(PageHighMem(page));  /* No HIGHMEM on 64-bit. */
+	l1_pgtable = (HV_PTE *)pfn_to_kaddr(pfn);
+#endif
 	pte = l1_pgtable[HV_L1_INDEX(address)];
 	if (!hv_pte_get_present(pte))
 		return 0;
@@ -92,7 +102,7 @@ static bool read_memory_func(void *result, VirtualAddress address,
 {
 	int retval;
 	struct KBacktraceIterator *kbt = (struct KBacktraceIterator *)vkbt;
-	if (in_kernel_text(address)) {
+	if (__kernel_text_address(address)) {
 		/* OK to read kernel code. */
 	} else if (address >= PAGE_OFFSET) {
 		/* We only tolerate kernel-space reads of this task's stack */
@@ -132,7 +142,7 @@ static struct pt_regs *valid_fault_handler(struct KBacktraceIterator* kbt)
 		}
 	}
 	if (EX1_PL(p->ex1) == KERNEL_PL &&
-	    in_kernel_text(p->pc) &&
+	    __kernel_text_address(p->pc) &&
 	    in_kernel_stack(kbt, p->sp) &&
 	    p->sp >= sp) {
 		if (kbt->verbose)
-- 
1.6.5.2


  parent reply	other threads:[~2011-03-01 19:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-27 23:52 arch/tile: various fixes for 2.6.39 Chris Metcalf
2011-02-27 23:52 ` [PATCH] arch/tile: catch up with section naming convention in 2.6.35 Chris Metcalf
2011-03-01 20:52   ` Sam Ravnborg
2011-03-01 21:17     ` Chris Metcalf
2011-02-28 18:08 ` [PATCH] arch/tile: bug fix: exec'ed task thought it was still single-stepping Chris Metcalf
2011-02-28 18:21 ` [PATCH] arch/tile: fix __ndelay etc to work better Chris Metcalf
2011-02-28 18:24 ` [PATCH] arch/tile: stop disabling INTCTRL_1 interrupts during hypervisor downcalls Chris Metcalf
2011-02-28 18:32 ` [PATCH] arch/tile: warn and retry if an IPI is not accepted by the target cpu Chris Metcalf
2011-02-28 18:35 ` [PATCH] arch/tile: export <asm/hardwall.h> to userspace Chris Metcalf
2011-02-28 20:01 ` [PATCH] arch/tile: avoid a simulator warning during bootup Chris Metcalf
2011-02-28 20:14 ` [PATCH] arch/tile: fix reversed test of strict_strtol() return value Chris Metcalf
2011-02-28 20:19 ` [PATCH] arch/tile: sync up with <arch/sim.h> and <arch/sim_def.h> changes Chris Metcalf
2011-02-28 20:22 ` [PATCH] arch/tile: use a cleaner technique to enable interrupt for cpu_idle() Chris Metcalf
2011-02-28 20:28 ` [PATCH] arch/tile: use extended assembly to inline __mb_incoherent() Chris Metcalf
2011-02-28 20:30 ` Chris Metcalf [this message]
2011-02-28 20:48 ` [PATCH] arch/tile: enhance existing finv_buffer_remote() routine Chris Metcalf
2011-02-28 20:51 ` [PATCH] arch/tile: export some additional module symbols Chris Metcalf
2011-02-28 20:58 ` [PATCH] arch/tile: fix some comments and whitespace Chris Metcalf
2011-02-28 21:01 ` [PATCH] arch/tile: add some more VMSPLIT options and use consistent naming Chris Metcalf
2011-02-28 21:37 ` [PATCH] arch/tile: support 4KB page size as well as 64KB Chris Metcalf

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=201103011934.p21JYdCi010307@farm-0010.internal.tilera.com \
    --to=cmetcalf@tilera.com \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.