xen/arm: Always trap AMU system registers
authorJulien Grall <jgrall@amazon.com>
Mon, 9 Nov 2020 20:28:59 +0000 (20:28 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 10 Nov 2020 17:43:13 +0000 (17:43 +0000)
commit73a09279de197c509a241ec20fa18c481c8503b2
tree9ecfd278fb4c75b5b1db2e7a039e13eef33708e6
parenta38060ece699f22cd317219bec53c0d27279155b
xen/arm: Always trap AMU system registers

The Activity Monitors Unit (AMU) has been introduced by ARMv8.4. It is
considered to be unsafe to be expose to guests as they might expose
information about code executed by other guests or the host.

Arm provided a way to trap all the AMU system registers by setting
CPTR_EL2.TAM to 1.

Unfortunately, on older revision of the specification, the bit 30 (now
CPTR_EL1.TAM) was RES0. Because of that, Xen is setting it to 0 and
therefore the system registers would be exposed to the guest when it is
run on processors with AMU.

As the bit is mark as UNKNOWN at boot in Armv8.4, the only safe solution
for us is to always set CPTR_EL1.TAM to 1.

Guest trying to access the AMU system registers will now receive an
undefined instruction. Unfortunately, this means that even well-behaved
guest may fail to boot because we don't sanitize the ID registers.

This is a known issues with other Armv8.0+ features (e.g. SVE, Pointer
Auth). This will taken care separately.

This is part of XSA-351 (or XSA-93 re-born).

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
(cherry picked from commit 628e1becb6fb121475a6ce68e3f1cb4499851255)
xen/arch/arm/traps.c
xen/include/asm-arm/processor.h