]> git.itanic.dy.fi Git - linux-stable/commit
arm/arm64: KVM: set right LR register value for 32 bit guest when inject abort
authorDongjiu Geng <gengdongjiu@huawei.com>
Tue, 17 Oct 2017 14:23:49 +0000 (22:23 +0800)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 1 Jan 2018 20:51:57 +0000 (20:51 +0000)
commitc070a9596d6fe032a1ca84c8a11e03f32671f69c
tree5c3ae34cca668a9361a1d5ce2d85672ffd745f4d
parentb2140a22396b4a8fd37d1fcf3e7a2b514526718c
arm/arm64: KVM: set right LR register value for 32 bit guest when inject abort

commit fd6c8c206fc5d0717b0433b191de0715122f33bb upstream.

When a exception is trapped to EL2, hardware uses  ELR_ELx to hold
the current fault instruction address. If KVM wants to inject a
abort to 32 bit guest, it needs to set the LR register for the
guest to emulate this abort happened in the guest. Because ARM32
architecture is pipelined execution, so the LR value has an offset to
the fault instruction address.

The offsets applied to Link value for exceptions as shown below,
which should be added for the ARM32 link register(LR).

Table taken from ARMv8 ARM DDI0487B-B, table G1-10:
Exception Offset, for PE state of:
A32    T32
Undefined Instruction  +4    +2
Prefetch Abort  +4    +4
Data Abort  +8    +8
IRQ or FIQ  +4    +4

  [ Removed unused variables in inject_abt to avoid compile warnings.
    -- Christoffer ]

Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com>
Tested-by: Haibin Zhang <zhanghaibin7@huawei.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <cdall@linaro.org>
[bwh: Backported to 3.16:
 - Don't delete cpsr variable in inject_abt() as it's still needed
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/arm/kvm/emulate.c
arch/arm64/kvm/inject_fault.c