@@ -78,6 +78,11 @@
ENTRY(vfp_support_entry)
DBGSTR3 "instr %08x pc %08x state %p", r0, r2, r10
+ ldr r3, [sp, #S_PSR] @ Neither lazy restore nor FP exceptions
+ and r3, r3, #MODE_MASK @ are supported in kernel mode
+ teq r3, #USR_MODE
+ bne vfp_kmode_exception @ Returns through lr
+
VFPFMRX r1, FPEXC @ Is the VFP enabled?
DBGSTR1 "fpexc %08x", r1
tst r1, #FPEXC_EN
@@ -27,6 +27,7 @@
#include <asm/system_info.h>
#include <asm/thread_notify.h>
#include <asm/vfp.h>
+#include <asm/bug.h>
#include "vfpinstr.h"
#include "vfp.h"
@@ -691,6 +692,16 @@ EXPORT_SYMBOL(kernel_neon_end);
#endif /* CONFIG_KERNEL_MODE_NEON */
+void vfp_kmode_exception(void)
+{
+ /*
+ * Taking an FP exception in kernel mode is always a bug, because
+ * none of the FP instructions currently supported in kernel mode
+ * (i.e., NEON) should ever be bounced back to the support code.
+ */
+ BUG_ON(fmrx(FPEXC) & FPEXC_EN);
+}
+
/*
* VFP support code initialisation.
*/