]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
KVM: arm/arm64: Correct CPSR on exception entry
authorMark Rutland <mark.rutland@arm.com>
Wed, 8 Jan 2020 13:43:23 +0000 (13:43 +0000)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 13 Mar 2020 05:19:20 +0000 (01:19 -0400)
commit13a322b594ac7494368dc018e3454f3321619fee
tree72a5868907802753f1a85c9de24a5b1114b0ee44
parent27f8530f77aeaa630720cc2b314b96d1737811be
KVM: arm/arm64: Correct CPSR on exception entry

BugLink: https://bugs.launchpad.net/bugs/1867051
commit 3c2483f15499b877ccb53250d88addb8c91da147 upstream.

When KVM injects an exception into a guest, it generates the CPSR value
from scratch, configuring CPSR.{M,A,I,T,E}, and setting all other
bits to zero.

This isn't correct, as the architecture specifies that some CPSR bits
are (conditionally) cleared or set upon an exception, and others are
unchanged from the original context.

This patch adds logic to match the architectural behaviour. To make this
simple to follow/audit/extend, documentation references are provided,
and bits are configured in order of their layout in SPSR_EL2. This
layout can be seen in the diagram on ARM DDI 0487E.a page C5-426.

Note that this code is used by both arm and arm64, and is intended to
fuction with the SPSR_EL2 and SPSR_HYP layouts.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200108134324.46500-3-mark.rutland@arm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/arm/include/asm/kvm_emulate.h
arch/arm64/include/asm/ptrace.h
virt/kvm/arm/aarch32.c