ARM: KVM: Correctly ignore writes to l2ctlr and l2ectlr.

TRM says they're write ignored, so let's do that rather than injecting an
undefined trap into the guest.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
ARM: KVM: Add comments with references to documentation.

Keeps life simple for future readers.  Or forgetful ones like me :)

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
ARM: KVM: Pass table entry to access fn, rather than arg.

We don't actually use the arg any more, and we're about to expand
the struct, so give the callbacks direct access.

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
ARM: KVM: lazy save/restore of vfp/neon

In this patch, we use the Hyp Coprocessor Trap Register
(HPCTR) to trap VFP/NEON instructions, and switch the FPU
state at that point. After a guest exit, the VFP state is
returned to the host. When disabling access to floating point
instructions, we also mask FPEXC_EN in order to avoid the guest
receiving Undefined instruction exceptions before we have a
chance to switch back the floating point state.

Initial lazy switching implementation provided by Rusty Russell.

In this version of the patch, FPEXC_EN is no longer clobbered for
the host; we save FPEXC before we mask it.

We are reusing vfp_hard_struct, so now we depend on VFPv3 being
enabled in the host kernel. For now, if the kernel has not been
built with VFPv3, we don't build the VFP switching code in KVM,
however we still trap cp10 and cp11 in order to inject an undefined
instruction exception whenever the guest tries to use VFP/NEON.

Alternatives to this would be to either require VFPv3 for KVM in
the first place, or to implement this as a feature that can be switched
on and off. If we don't mind the #ifdefs we can keep the current solution.

For now I don't reuse vfp_save_state. If we still want to do that, we
would have to change it a bit and also add a vfp_restore_state, as
already mentioned by reviewers. However I have noticed that vfp_save_state
doesn't clear FPEXC_EX before reading the rest of the registers, as
we do according to the ARM ARM p. AppxF-2388. Can someone comment on
whether this is a bug in vfp_save_state?

Changes since v3:
 * Added comments and other minor improvements
 * Relocated vfp structures to the end of kvm_vcpu_arch, so we don't
   have to rewrite code that accesses existing members of the struct
   with limited offset addressing instructions.

Changes since v2:
 * Fix clobbering the host's FPEXC_EN on entry
 * Reuse vfp_hard_struct from asm/fpstate.h
 * Reuse macros from asm/vfpmacros.h (warning: out of date mnemonics)
 * Disable VFP support if kernel hasn't been cofigured with VFPv3
 * Tweak and reuse set_hcptr instead of setting the HCPTR manually

Changes since v1:
 * Lazy switching by Rusty Russell
 * Lazy switching fix; mask FPEXC_EN so guest processes don't crash
 * Simpler lazy switching handler
 * Replaced instruction mnemonics with coprocessor operations so the
   code can be built on gcc configurations with no full VFP-d32 support
 * VFP subarchitecture handling fix; disable FPEXC_EX before switching
   cp11 registers

Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>