xen/arm: traps: Avoid using BUG_ON() to check guest state in advance_pc()
authorJulien Grall <julien.grall@arm.com>
Wed, 15 May 2019 20:17:30 +0000 (21:17 +0100)
committerStefano Stabellini <sstabellini@kernel.org>
Mon, 20 May 2019 18:08:58 +0000 (11:08 -0700)
commit72615f2e6b98e861c08abb1d2b194126013d54fe
treee1c6a0c821bf4e7ea4c3ef999c3aa63b9dc8f0aa
parent278c64519c661c851d37e2a929f006fb8a1dcd01
xen/arm: traps: Avoid using BUG_ON() to check guest state in advance_pc()

The condition of the BUG_ON() in advance_pc() is pretty wrong because
the bits [26:25] and [15:10] have a different meaning between AArch32
and AArch64 state.

On AArch32, they are used to store PSTATE.IT. On AArch64, they are RES0
or used for new feature (e.g ARMv8.0-SSBS, ARMv8.5-BTI).

This means a 64-bit guest will hit the BUG_ON() if it is trying to use
any of these features.

More generally, RES0 means that the bits is reserved for future use. So
crashing the host is definitely not the right solution.

In this particular case, we only need to know the guest was using 32-bit
Mode and the Thumb instructions. So replace the BUG_ON() by a proper
check.

Reported-by: Lukas Jünger <lukas.juenger@ice.rwth-aachen.de>
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/traps.c