]> git.baikalelectronics.ru Git - kernel.git/commit
arm64: KVM: Correctly handle zero register during MMIO
authorPavel Fedin <p.fedin@samsung.com>
Fri, 4 Dec 2015 12:03:11 +0000 (15:03 +0300)
committerMarc Zyngier <marc.zyngier@arm.com>
Fri, 4 Dec 2015 16:29:37 +0000 (16:29 +0000)
commit503155fcfd40838408e3ce6ff3cf1eed077179ae
treeac99c251f2a2b292166fec8227f2438fb830150c
parent45fb89a289538287f45d8e31b376a9a259272bce
arm64: KVM: Correctly handle zero register during MMIO

On ARM64 register index of 31 corresponds to both zero register and SP.
However, all memory access instructions, use ZR as transfer register. SP
is used only as a base register in indirect memory addressing, or by
register-register arithmetics, which cannot be trapped here.

Correct emulation is achieved by introducing new register accessor
functions, which can do special handling for reg_num == 31. These new
accessors intentionally do not rely on old vcpu_reg() on ARM64, because
it is to be removed. Since the affected code is shared by both ARM
flavours, implementations of these accessors are also added to ARM32 code.

This patch fixes setting MMIO register to a random value (actually SP)
instead of zero by something like:

 *((volatile int *)reg) = 0;

compilers tend to generate "str wzr, [xx]" here

[Marc: Fixed 32bit splat]

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm/include/asm/kvm_emulate.h
arch/arm/kvm/mmio.c
arch/arm64/include/asm/kvm_emulate.h