linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ccross@android.com (Colin Cross)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: vfp: Fix up exception location in Thumb mode
Date: Thu, 13 Jan 2011 23:42:29 -0800	[thread overview]
Message-ID: <1294990949-2729-1-git-send-email-ccross@android.com> (raw)

The exception handler in entry-armv.S checks for thumb mode and
correctly determines the exception location and instruction,
but VFP_bounce uses the uncorrected location off the stack.
If the VFP exception occured in Thumb mode, fix up the
exception location to match the value that would be returned
in ARM mode.

Fixes segfaults in userspace applications running in Thumb mode
caused by a handled VFP exception returning to the middle of the
instruction that triggered the exception.

Change-Id: I6c6ba1ab88e107bec166ea334d7e0974a4f6bfba
Signed-off-by: Colin Cross <ccross@android.com>
---
 arch/arm/vfp/vfpmodule.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index 0797cb5..63ed73d 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -275,6 +275,16 @@ void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs)
 	pr_debug("VFP: bounce: trigger %08x fpexc %08x\n", trigger, fpexc);
 
 	/*
+	 * If the exception occured in thumb mode, pc is exception location + 2,
+	 * the middle of the 32-bit VFP instruction.  Add 2 to get exception
+	 * location + 4, the same we get in ARM mode.
+	 */
+#ifdef CONFIG_ARM_THUMB
+	if (regs->ARM_cpsr & PSR_T_BIT)
+		regs->ARM_pc += 2;
+#endif
+
+	/*
 	 * At this point, FPEXC can have the following configuration:
 	 *
 	 *  EX DEX IXE
-- 
1.7.3.1

             reply	other threads:[~2011-01-14  7:42 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-14  7:42 Colin Cross [this message]
2011-01-14 11:43 ` [PATCH] ARM: vfp: Fix up exception location in Thumb mode Catalin Marinas
2011-01-14 12:02   ` Russell King - ARM Linux
2011-01-14 14:10     ` Catalin Marinas
2011-01-14 15:49       ` Russell King - ARM Linux
2011-01-14 16:23         ` Catalin Marinas
2011-01-14 16:35           ` Russell King - ARM Linux
2011-01-14 16:58             ` Catalin Marinas
2011-01-14 17:30               ` Russell King - ARM Linux
2011-01-14 18:47                 ` Russell King - ARM Linux
2011-01-14 19:23                   ` Colin Cross
2011-01-14 19:51                     ` Colin Cross
2011-01-14 21:24                       ` Russell King - ARM Linux
2011-01-25 23:33                       ` Colin Cross
2011-01-26 11:26                         ` Russell King - ARM Linux
2011-01-27  6:11                           ` Colin Cross
2011-01-27  6:35                             ` Colin Cross
2011-01-27  7:30                               ` Colin Cross
2011-02-09 18:12                                 ` Colin Cross
2011-01-15 15:38                   ` Catalin Marinas
2011-01-15 15:43                     ` Russell King - ARM Linux
2011-01-16 11:51                       ` Catalin Marinas
2011-01-15 15:31                 ` Catalin Marinas
2011-01-15 15:40                   ` Russell King - ARM Linux
2011-01-16 11:49                     ` Catalin Marinas
2011-01-23 15:51                       ` Russell King - ARM Linux
2011-01-25 13:19                         ` Catalin Marinas
2011-01-16 21:25                     ` Catalin Marinas
2011-01-23 15:46                       ` Russell King - ARM Linux
2011-01-25 13:45                         ` Catalin Marinas
2011-01-14 16:24       ` Dave Martin
2011-01-14 16:52         ` Russell King - ARM Linux

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=1294990949-2729-1-git-send-email-ccross@android.com \
    --to=ccross@android.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).