aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2012-04-23 15:42:16 +0100
committerChristian Neumüller <cn00@gmx.at>2014-12-30 12:53:29 +0100
commitef1bd2814672fe472f8cb21b43371445f8c24ec3 (patch)
tree7f11585cb17eaf63d00cc57c5430aa3cd7df24ab
parent5b8b77e8698e6acbdbb796e6bafe020190956394 (diff)
downloadkernel_samsung_smdk4412-ef1bd2814672fe472f8cb21b43371445f8c24ec3.zip
kernel_samsung_smdk4412-ef1bd2814672fe472f8cb21b43371445f8c24ec3.tar.gz
kernel_samsung_smdk4412-ef1bd2814672fe472f8cb21b43371445f8c24ec3.tar.bz2
ARM: 7400/1: vfp: clear fpscr length and stride bits on entry to sig handler
The ARM PCS mandates that the length and stride bits of the fpscr are cleared on entry to and return from a public interface. Although signal handlers run asynchronously with respect to the interrupted function, the handler itself expects to run as though it has been called like a normal function. This patch updates the state mirroring the VFP hardware before entry to a signal handler so that it adheres to the PCS. Furthermore, we disable VFP to ensure that we trap on any floating point operation performed by the signal handler and synchronise the hardware appropriately. A check is inserted after the signal handler to avoid redundant flushing if VFP was not used. Change-Id: Ic16296179773f609e2768c89756a0abece1a3247 Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Lanchon <lanchon@gmail.com>
-rw-r--r--arch/arm/vfp/vfpmodule.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index 25ad342..cd45626 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -572,6 +572,21 @@ int vfp_preserve_user_clear_hwstate(struct user_vfp __user *ufp,
if (err)
return -EFAULT;
+
+ /* Ensure that VFP is disabled. */
+ vfp_flush_hwstate(thread);
+
+ /*
+ * As per the PCS, clear the length and stride bits for function
+ * entry.
+ */
+ hwstate->fpscr &= ~(FPSCR_LENGTH_MASK | FPSCR_STRIDE_MASK);
+
+ /*
+ * Disable VFP in the hwstate so that we can detect if it gets
+ * used.
+ */
+ hwstate->fpexc &= ~FPEXC_EN;
return 0;
}
@@ -584,7 +599,12 @@ int vfp_restore_user_hwstate(struct user_vfp __user *ufp,
unsigned long fpexc;
int err = 0;
- vfp_flush_hwstate(thread);
+ /*
+ * If VFP has been used, then disable it to avoid corrupting
+ * the new thread state.
+ */
+ if (hwstate->fpexc & FPEXC_EN)
+ vfp_flush_hwstate(thread);
/*
* Copy the floating point registers. There can be unused