MIPS: MSA unaligned memory access support
MIPS: MSA unaligned memory access support

The MSA architecture specification allows for hardware to not implement
unaligned vector memory accesses in some or all cases. A typical example
of this is the I6400 core which does not implement unaligned vector
memory access when the memory crosses a page boundary. The architecture
also requires that such memory accesses complete successfully as far as
userland is concerned, so the kernel is required to emulate them.

This patch implements support for emulating unaligned MSA ld & st
instructions by copying between the user memory & the tasks FP context
in struct thread_struct, updating hardware registers from there as
appropriate in order to avoid saving & restoring the entire vector
context for each unaligned memory access.

Tested both using an I6400 CPU and with a QEMU build hacked to produce
AdEL exceptions for unaligned vector memory accesses.

[85f1bffadddedccfafc0ae065a06aa636075387f@imgtec.com:
  - Remove #ifdef's
  - Move msa_op into enum major_op rather than #define
  - Replace msa_{to,from}_wd with {read,write}_msa_wr_{b,h,w,l} and the
    format-agnostic wrappers, removing the custom endian mangling for
    big endian systems.
  - Restructure the msa_op case in emulate_load_store_insn to share
    more code between the load & store cases.
  - Avoid the need for a temporary union fpureg on the stack by simply
    reusing the already suitably aligned context in struct
    thread_struct.
  - Use sizeof(*fpr) rather than hardcoding 16 as the size for user
    memory checks & copies.
  - Stop recalculating the address of the unaligned vector memory access
    and rely upon the value read from BadVAddr as we do for other
    unaligned memory access instructions.
  - Drop the now unused val8 & val16 fields in union fpureg.
  - Rewrite commit message.
  - General formatting cleanups.]

Signed-off-by: Paul Burton <85f1bffadddedccfafc0ae065a06aa636075387f@imgtec.com>
Cc: 562397917b9a8bf316569a848858b12fb417723f@linux-mips.org
Cc: Leonid Yegoshin <d6aca6b5694d055adc6cbbaf8ff810fc31ed7c5d@imgtec.com>
Cc: Huacai Chen <bddc6ef64099649954804bf58f2e4dee9b3b798f@lemote.com>
Cc: Maciej W. Rozycki <78f3a3d9d6e4d907a7d12e475d0a751d6b7e256b@linux-mips.org>
Cc: 2578944098299abf708b08eff6fcf60565553586@vger.kernel.org
Cc: Jie Chen <58d8bd45f7eb89673fd2f297a88c0a8a8ee49a44@lemote.com>
Cc: Markos Chandras <5cdbcb0e11d2b5ebc39222958c54a1c6329d0c9d@imgtec.com>
Patchwork: https://patchwork.linux-mips.org/patch/10573/
Signed-off-by: Ralf Baechle <92f48d309cda194c8eda36aa8f9ae28c488fa208@linux-mips.org>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs