xen/arm: do not read MVFR2 when is not defined
authorStefano Stabellini <sstabellini@kernel.org>
Tue, 5 Jan 2021 19:05:48 +0000 (11:05 -0800)
committerStefano Stabellini <sstabellini@kernel.org>
Fri, 8 Jan 2021 23:35:51 +0000 (15:35 -0800)
commitce59e3dda5f99afbe7257e1e9a22dffd5c4d033c
tree1abf4ec97657b19b3d417919f752a015b5c9bc78
parentb468b464c89e92629bd52cec58e9f51eee2e950a
xen/arm: do not read MVFR2 when is not defined

MVFR2 is not available on ARMv7. It is available on ARMv8 aarch32 and
aarch64. If Xen reads MVFR2 on ARMv7 it could crash.

Avoid the issue by doing the following:

- define MVFR2_MAYBE_UNDEFINED on arm32
- if MVFR2_MAYBE_UNDEFINED, do not attempt to read MVFR2 in Xen
- keep the 3rd register_t in struct cpuinfo_arm.mvfr on arm32 so that a
  guest read to the register returns '0' instead of crashing the guest.

'0' is an appropriate value to return to the guest because it is defined
as "no support for miscellaneous features".

Aarch64 Xen is not affected by this patch.

Fixes: 9cfdb489af81 ("xen/arm: Add ID registers and complete cpuinfo")
Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Acked-by: Julien Grall <jgrall@amazon.com>
xen/arch/arm/cpufeature.c
xen/include/asm-arm/arm32/sysregs.h