@@ -101,6 +101,19 @@ static int __init pj4_get_iwmmxt_version(void)
return -EINVAL;
}
+/*
+ * The iWMMXt ISA is only defined in ARM mode, but the generic coprocessor
+ * load/store instructions (LDC/STC) exist in a Thumb2 encoding as well, and
+ * may be used (e.g., by glibc) to preserve/restore the iWMMXt register file.
+ */
+static struct undef_hook iwmmxt_undef_t2_hook = {
+ .instr_mask = 0xee000f00,
+ .instr_val = 0xec000100,
+ .cpsr_mask = MODE_MASK | PSR_T_BIT,
+ .cpsr_val = USR_MODE | PSR_T_BIT,
+ .fn = iwmmxt_undef_handler,
+};
+
/*
* Disable CP0/CP1 on boot, and let call_fpe() and the iWMMXt lazy
* switch code handle iWMMXt context switching.
@@ -127,6 +140,9 @@ static int __init pj4_cp0_init(void)
elf_hwcap |= HWCAP_IWMMXT;
thread_register_notifier(&iwmmxt_notifier_block);
register_iwmmxt_undef_handler();
+
+ if (IS_ENABLED(CONFIG_ARM_THUMB))
+ register_undef_hook(&iwmmxt_undef_t2_hook);
#endif
return 0;